├── C-DS
├── Resources
│ ├── DSU.png
│ ├── mob.png
│ ├── C-DS.png
│ ├── deque.png
│ ├── graphs.png
│ ├── grids.png
│ ├── icon.png
│ ├── queue.png
│ ├── stack.png
│ ├── trie.png
│ ├── vector.png
│ ├── LogoDark.png
│ ├── hash_map.png
│ ├── logoFont.ttf
│ ├── mainFont.ttf
│ ├── LogoLight.png
│ ├── hash_table.png
│ ├── linked_list.png
│ ├── mainFont-bold.ttf
│ ├── sparce_table.png
│ └── mainFont-italic.ttf
├── C-DS.vcxproj.user
├── Image.h
├── TextArea.h
├── DockingArea.h
├── Settings.h
├── CodeVisualizer.h
├── Markdown.h
├── DockingArea.cpp
├── main.cpp
├── TextArea.cpp
├── GrandWindow.h
├── imgui.ini
├── GrandWindow.cpp
├── Image.cpp
├── QueueVisualization.h
├── App.h
├── Vector.h
├── Stack.h
├── SparseTable.h
├── Segment_Tree.h
├── Tree.h
├── Segment_Tree.cpp
├── LinkedList.h
├── MainMenu.h
├── Deque.h
├── Trie.h
├── CodeVisualizer.cpp
├── DSU.h
├── HashTable.h
├── HashMap.h
├── Grid.h
├── GraphTools.h
├── SparseTable.cpp
├── Markdown.cpp
├── C-DS.vcxproj.filters
├── MainMenu.cpp
├── Tree.cpp
├── Stack.cpp
├── QueueVisualization.cpp
├── C-DS.vcxproj
├── App.cpp
├── Vector.cpp
└── Settings.cpp
├── glfw
├── lib-vc2010-32
│ └── glfw3.lib
└── lib-vc2010-64
│ └── glfw3.lib
├── imgui
├── LICENSE.txt
├── imgui_impl_opengl3.h
├── imgui_impl_glfw.h
└── imconfig.h
├── C-DS.sln
├── .gitattributes
├── README.md
└── .gitignore
/C-DS/Resources/DSU.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/DSU.png
--------------------------------------------------------------------------------
/C-DS/Resources/mob.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/mob.png
--------------------------------------------------------------------------------
/C-DS/Resources/C-DS.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/C-DS.png
--------------------------------------------------------------------------------
/C-DS/Resources/deque.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/deque.png
--------------------------------------------------------------------------------
/C-DS/Resources/graphs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/graphs.png
--------------------------------------------------------------------------------
/C-DS/Resources/grids.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/grids.png
--------------------------------------------------------------------------------
/C-DS/Resources/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/icon.png
--------------------------------------------------------------------------------
/C-DS/Resources/queue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/queue.png
--------------------------------------------------------------------------------
/C-DS/Resources/stack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/stack.png
--------------------------------------------------------------------------------
/C-DS/Resources/trie.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/trie.png
--------------------------------------------------------------------------------
/C-DS/Resources/vector.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/vector.png
--------------------------------------------------------------------------------
/C-DS/Resources/LogoDark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/LogoDark.png
--------------------------------------------------------------------------------
/C-DS/Resources/hash_map.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/hash_map.png
--------------------------------------------------------------------------------
/C-DS/Resources/logoFont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/logoFont.ttf
--------------------------------------------------------------------------------
/C-DS/Resources/mainFont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/mainFont.ttf
--------------------------------------------------------------------------------
/C-DS/Resources/LogoLight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/LogoLight.png
--------------------------------------------------------------------------------
/C-DS/Resources/hash_table.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/hash_table.png
--------------------------------------------------------------------------------
/C-DS/Resources/linked_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/linked_list.png
--------------------------------------------------------------------------------
/glfw/lib-vc2010-32/glfw3.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/glfw/lib-vc2010-32/glfw3.lib
--------------------------------------------------------------------------------
/glfw/lib-vc2010-64/glfw3.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/glfw/lib-vc2010-64/glfw3.lib
--------------------------------------------------------------------------------
/C-DS/Resources/mainFont-bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/mainFont-bold.ttf
--------------------------------------------------------------------------------
/C-DS/Resources/sparce_table.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/sparce_table.png
--------------------------------------------------------------------------------
/C-DS/Resources/mainFont-italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WisdomCasual/C-DS/HEAD/C-DS/Resources/mainFont-italic.ttf
--------------------------------------------------------------------------------
/C-DS/C-DS.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | false
5 |
6 |
--------------------------------------------------------------------------------
/C-DS/Image.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #define GL_SILENCE_DEPRECATION
3 | #if defined(IMGUI_IMPL_OPENGL_ES2)
4 | #include
5 | #endif
6 | #include
7 |
8 |
9 | namespace image_imp {
10 |
11 | bool loadImage(const char*, GLuint*, int*, int*);
12 | void SetWindowIcon(GLFWwindow*, const char*);
13 |
14 | }
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/C-DS/TextArea.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "imgui.h"
3 | #include
4 | #include
5 |
6 | class TextArea
7 | {
8 | // private fields:
9 | ImGuiWindowClass window_class;
10 | const std::string name;
11 |
12 | public:
13 |
14 | TextArea(std::string);
15 | ~TextArea();
16 |
17 | // public methods:
18 | void update();
19 | const std::string getName();
20 |
21 | };
--------------------------------------------------------------------------------
/C-DS/DockingArea.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "imgui.h"
3 | #include
4 | #include
5 |
6 | class DockingArea
7 | {
8 | private:
9 | // private fields:
10 | ImGuiWindowClass window_class;
11 | const std::string name;
12 |
13 | public:
14 |
15 | DockingArea(std::string);
16 | ~DockingArea();
17 |
18 | // public methods:
19 | void update();
20 | const std::string getName();
21 |
22 | };
23 |
24 |
--------------------------------------------------------------------------------
/C-DS/Settings.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "GrandWindow.h"
3 | #include
4 |
5 | class Settings :
6 | public GrandWindow
7 | {
8 | // private fields:
9 | ImGuiStyle* style;
10 | bool initialized = false, debuggingSettings = false;
11 |
12 | public:
13 |
14 | Settings(std::string, int&, float&, bool&, int&);
15 | ~Settings();
16 |
17 | // public methods:
18 | void update();
19 |
20 | };
21 |
22 |
--------------------------------------------------------------------------------
/C-DS/CodeVisualizer.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "GrandWindow.h"
3 | #include
4 | #include
5 |
6 | #include "DockingArea.h"
7 | #include "TextArea.h"
8 |
9 | class CodeVisualizer :
10 | public GrandWindow
11 | {
12 | private:
13 | // private fields:
14 | DockingArea* docking_area;
15 | TextArea* text_area;
16 |
17 | // private methods:
18 | void updateMenuBar();
19 |
20 | public:
21 |
22 | CodeVisualizer(std::string, int&, float&, bool&, int&);
23 | ~CodeVisualizer();
24 |
25 | // public methods:
26 | void update();
27 |
28 | };
29 |
30 |
--------------------------------------------------------------------------------
/C-DS/Markdown.h:
--------------------------------------------------------------------------------
1 | #include "ImGui.h" // https://github.com/ocornut/imgui
2 | #include "imgui_markdown.h" // https://github.com/juliettef/imgui_markdown
3 | //#include "IconsFontAwesome5.h" // https://github.com/juliettef/IconFontCppHeaders
4 |
5 | #include
6 |
7 | void LinkCallback(ImGui::MarkdownLinkCallbackData data_);
8 |
9 | ImGui::MarkdownImageData ImageCallback(ImGui::MarkdownLinkCallbackData data_);
10 |
11 | void LinkCallback(ImGui::MarkdownLinkCallbackData data_);
12 |
13 | void LoadFonts(float fontSize_);
14 |
15 | void MarkdownFormatCallback(const ImGui::MarkdownFormatInfo& markdownFormatInfo_, bool start_);
16 |
17 | void Markdown(const std::string& markdown_);
18 |
19 | void clearCachedImages();
--------------------------------------------------------------------------------
/C-DS/DockingArea.cpp:
--------------------------------------------------------------------------------
1 | #include "DockingArea.h"
2 |
3 | DockingArea::DockingArea(std::string name)
4 | : name(name)
5 | {
6 | window_class.DockNodeFlagsOverrideSet = ImGuiDockNodeFlags_NoTabBar | ImGuiDockNodeFlags_NoDockingOverMe | ImGuiDockNodeFlags_NoDockingOverOther | ImGuiDockNodeFlags_NoDockingSplitOther;
7 | }
8 |
9 | DockingArea::~DockingArea()
10 | {
11 |
12 | }
13 |
14 | void DockingArea::update()
15 | {
16 | ImGui::SetNextWindowClass(&window_class);
17 | ImGui::Begin(name.c_str(), NULL, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar);
18 | ImGuiID dockSpace = ImGui::GetID("dockSpace");
19 | ImGui::DockSpace(dockSpace);
20 | ImGui::End();
21 | }
22 |
23 | const std::string DockingArea::getName()
24 | {
25 | return name;
26 | }
27 |
--------------------------------------------------------------------------------
/C-DS/main.cpp:
--------------------------------------------------------------------------------
1 | #include "App.h"
2 |
3 | App *app;
4 |
5 | static void glfw_error_callback(int error, const char* description)
6 | {
7 | fprintf(stderr, "GLFW Error %d: %s\n", error, description);
8 | }
9 |
10 | void framebuffer_size_callback(GLFWwindow* window, int width, int height)
11 | {
12 | glViewport(0, 0, width, height);
13 | }
14 |
15 | void window_refresh_callback(GLFWwindow* window)
16 | {
17 | app->update();
18 | app->render();
19 | glFinish();
20 | }
21 |
22 | int main() {
23 | glfwSetErrorCallback(glfw_error_callback);
24 | if (!glfwInit())
25 | exit(1);
26 | app = new App("C-DS");
27 |
28 | glfwSetWindowRefreshCallback(app->getWindow(), window_refresh_callback);
29 | glfwSetFramebufferSizeCallback(app->getWindow(), framebuffer_size_callback);
30 |
31 | app->run();
32 |
33 | return 0;
34 | }
--------------------------------------------------------------------------------
/C-DS/TextArea.cpp:
--------------------------------------------------------------------------------
1 | #include "TextArea.h"
2 |
3 | TextArea::TextArea(std::string name)
4 | : name(name)
5 | {
6 | window_class.DockNodeFlagsOverrideSet = ImGuiDockNodeFlags_NoTabBar | ImGuiDockNodeFlags_NoDocking;
7 | }
8 |
9 | TextArea::~TextArea()
10 | {
11 |
12 | }
13 |
14 | void TextArea::update()
15 | {
16 | ImGui::SetNextWindowClass(&window_class);
17 | ImGui::Begin(name.c_str(), NULL, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar);
18 |
19 | if (ImGui::Button("Run")) {
20 |
21 | }
22 |
23 | ImGui::SameLine();
24 | ImGui::Text("Text 2");
25 | static char text[int(1e4)];
26 | ImGui::InputTextMultiline("IDE", text, IM_ARRAYSIZE(text), ImVec2(-FLT_MIN, -FLT_MIN));
27 |
28 | ImGui::End();
29 | }
30 |
31 | const std::string TextArea::getName()
32 | {
33 | return name;
34 | }
35 |
--------------------------------------------------------------------------------
/imgui/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2024 Omar Cornut
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/C-DS/GrandWindow.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 |
6 | class GrandWindow
7 | {
8 | private:
9 |
10 | std::string name;
11 | bool autoZooming = false;
12 | float targetZoom = 1.0f;
13 |
14 | protected:
15 |
16 | int& state;
17 | float& GuiScale;
18 | float zoomScale = 1.0f;
19 | bool& settingsEnabled;
20 | int& colorMode;
21 | float center_x_percent = 0.5f, center_y_percent = 0.5f;
22 | ImVec2 camPos = { 0.0f, 1000.f * GuiScale }, camTarget = { 0.0f, 0.0f };
23 | ImVec2 center = { 0, 0 };
24 |
25 | const ImGuiViewport* viewport = ImGui::GetMainViewport();
26 | const ImGuiIO* io = &ImGui::GetIO();
27 |
28 | GrandWindow(std::string name, int& state, float& GuiScale, bool& settingsEnabled, int& colorMode) : name(name), state(state), GuiScale(GuiScale), settingsEnabled(settingsEnabled), colorMode(colorMode){};
29 |
30 | void drawWatermark(float opacity = 0.7f) const;
31 | void updateCam(float minZoomScale = 0.5f, float maxZoomScale = 3.0f);
32 | void autoZoom(float newZoom);
33 | void inline updateCenter() {
34 | // updates the center to the center of the current window
35 | center = ImVec2(ImGui::GetWindowPos().x + ImGui::GetWindowSize().x * center_x_percent, ImGui::GetWindowPos().y + ImGui::GetWindowSize().y * center_y_percent);
36 | };
37 |
38 | public:
39 |
40 | virtual void update() = 0;
41 |
42 | const inline std::string getName() { return name; };
43 |
44 | };
45 |
46 |
--------------------------------------------------------------------------------
/C-DS.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.8.34601.278
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "C-DS", "C-DS\C-DS.vcxproj", "{1A4DFB39-2234-48A4-B2E6-475E5D52D2A9}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {1A4DFB39-2234-48A4-B2E6-475E5D52D2A9}.Debug|x64.ActiveCfg = Debug|x64
17 | {1A4DFB39-2234-48A4-B2E6-475E5D52D2A9}.Debug|x64.Build.0 = Debug|x64
18 | {1A4DFB39-2234-48A4-B2E6-475E5D52D2A9}.Debug|x86.ActiveCfg = Debug|Win32
19 | {1A4DFB39-2234-48A4-B2E6-475E5D52D2A9}.Debug|x86.Build.0 = Debug|Win32
20 | {1A4DFB39-2234-48A4-B2E6-475E5D52D2A9}.Release|x64.ActiveCfg = Release|x64
21 | {1A4DFB39-2234-48A4-B2E6-475E5D52D2A9}.Release|x64.Build.0 = Release|x64
22 | {1A4DFB39-2234-48A4-B2E6-475E5D52D2A9}.Release|x86.ActiveCfg = Release|Win32
23 | {1A4DFB39-2234-48A4-B2E6-475E5D52D2A9}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {B4B9F2B5-0072-42FE-AA7F-F666DAC73291}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/C-DS/imgui.ini:
--------------------------------------------------------------------------------
1 | [Window][Window_1]
2 | Pos=0,26
3 | Size=894,694
4 | Collapsed=0
5 |
6 | [Window][Window_2]
7 | Pos=896,26
8 | Size=384,694
9 | Collapsed=0
10 |
11 | [Window][DockSpaceViewport_11111111]
12 | Pos=0,36
13 | Size=1920,938
14 | Collapsed=0
15 |
16 | [Window][Debug##Default]
17 | Pos=213,150
18 | Size=400,400
19 | Collapsed=1
20 |
21 | [Window][Hello, world!]
22 | Pos=212,119
23 | Size=734,624
24 | Collapsed=0
25 |
26 | [Window][Dock_Area]
27 | Pos=0,26
28 | Size=630,544
29 | Collapsed=0
30 |
31 | [Window][IDE_Area]
32 | Pos=632,26
33 | Size=270,544
34 | Collapsed=0
35 |
36 | [Window][JOONYOU]
37 | Pos=8,375
38 | Size=514,337
39 | Collapsed=0
40 | DockId=0x00000003,0
41 |
42 | [Window][Docking_Area]
43 | Pos=0,36
44 | Size=1342,938
45 | Collapsed=0
46 | DockId=0x00000001
47 |
48 | [Window][Text_Area]
49 | Pos=1344,36
50 | Size=576,938
51 | Collapsed=0
52 | DockId=0x00000002
53 |
54 | [Window][Settings]
55 | Pos=96,111
56 | Size=758,1099
57 | Collapsed=0
58 |
59 | [Window][Graph_Tools]
60 | Pos=290,136
61 | Size=1432,885
62 | Collapsed=0
63 |
64 | [Window][Hash_Map]
65 | Size=1334,979
66 | Collapsed=0
67 |
68 | [Docking][Data]
69 | DockSpace ID=0x8B93E3BD Pos=0,36 Size=1920,938 Split=X
70 | DockNode ID=0x00000001 Parent=0x8B93E3BD SizeRef=1342,974 Selected=0xFA64D971
71 | DockNode ID=0x00000002 Parent=0x8B93E3BD SizeRef=576,974 Selected=0xAA3703AF
72 | DockSpace ID=0xD7F179FF Pos=8,34 Size=614,528 Split=X
73 | DockNode ID=0x00000003 Parent=0xD7F179FF SizeRef=514,678 Selected=0xD00C9CD4
74 | DockNode ID=0x00000004 Parent=0xD7F179FF SizeRef=139,678 CentralNode=1 Selected=0xD00C9CD4
75 |
76 |
--------------------------------------------------------------------------------
/C-DS/GrandWindow.cpp:
--------------------------------------------------------------------------------
1 | #include "GrandWindow.h"
2 |
3 |
4 | void GrandWindow::drawWatermark(float opacity) const {
5 | ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[5]);
6 |
7 | float shade = abs(colorMode - 0.8f);
8 | ImGui::TextColored(ImVec4(shade, shade, shade, opacity), "C-");
9 | ImGui::SameLine();
10 | ImGui::TextColored(ImVec4(0.3f, 0.6f, 1.0f, opacity), "DS");
11 | ImGui::PopFont();
12 | };
13 |
14 | void GrandWindow::updateCam(float minZoomScale, float maxZoomScale) {
15 |
16 | updateCenter();
17 |
18 | camPos.x += (camTarget.x - camPos.x) * 10.f * io->DeltaTime;
19 | camPos.y += (camTarget.y - camPos.y) * 10.f * io->DeltaTime;
20 |
21 | if (ImGui::IsWindowHovered() && io->MouseWheel != 0.0f) {
22 | targetZoom += io->MouseWheel * 0.15f;
23 | targetZoom = std::min(std::max(targetZoom, minZoomScale), maxZoomScale);
24 | autoZooming = false;
25 | }
26 |
27 | if (abs(zoomScale - targetZoom) <= 0.005f) return;
28 |
29 | if (!autoZooming) {
30 | camTarget.x -= (io->MousePos.x - center.x) / zoomScale;
31 | camTarget.y -= (io->MousePos.y - center.y) / zoomScale;
32 | camPos.x -= (io->MousePos.x - center.x) / zoomScale;
33 | camPos.y -= (io->MousePos.y - center.y) / zoomScale;
34 | }
35 |
36 | zoomScale += (targetZoom - zoomScale) * 10.f * io->DeltaTime;
37 | zoomScale = std::min(std::max(zoomScale, minZoomScale), maxZoomScale);
38 |
39 | if (!autoZooming) {
40 | camTarget.x += (io->MousePos.x - center.x) / zoomScale;
41 | camTarget.y += (io->MousePos.y - center.y) / zoomScale;
42 | camPos.x += (io->MousePos.x - center.x) / zoomScale;
43 | camPos.y += (io->MousePos.y - center.y) / zoomScale;
44 | }
45 |
46 | }
47 |
48 | void GrandWindow::autoZoom(float newZoom) {
49 | targetZoom = newZoom;
50 | autoZooming = true;
51 | camTarget = { 0, 0 };
52 | };
--------------------------------------------------------------------------------
/C-DS/Image.cpp:
--------------------------------------------------------------------------------
1 | #include "Image.h"
2 |
3 | #define STB_IMAGE_IMPLEMENTATION
4 | #include "stb_image.h"
5 | #include
6 |
7 | bool image_imp::loadImage(const char* filename, GLuint* out_texture, int* out_width, int* out_height) {
8 | int width, height, channels;
9 | unsigned char* imageData = stbi_load(filename, &width, &height, &channels, 0);
10 |
11 | if (!imageData) {
12 | std::cout << "Failed to load image file: " << filename << '\n';
13 | return false;
14 | }
15 |
16 | GLuint textureID;
17 | glGenTextures(1, &textureID);
18 | glBindTexture(GL_TEXTURE_2D, textureID);
19 |
20 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
21 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
22 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
23 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
24 |
25 | GLenum format = (channels == 3) ? GL_RGB : GL_RGBA;
26 | glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, imageData);
27 |
28 | stbi_image_free(imageData);
29 |
30 | *out_texture = textureID;
31 | if (out_width != NULL)
32 | *out_width = width;
33 | if (out_height != NULL)
34 | *out_height = height;
35 | return true;
36 | }
37 |
38 | void image_imp::SetWindowIcon(GLFWwindow* window, const char* iconPath) {
39 | int width, height, channels;
40 | unsigned char* data = stbi_load(iconPath, &width, &height, &channels, 0);
41 | if (data) {
42 | GLFWimage icon;
43 | icon.width = width;
44 | icon.height = height;
45 | icon.pixels = data;
46 | glfwSetWindowIcon(window, 1, &icon);
47 | stbi_image_free(data);
48 | }
49 | else {
50 | printf("Failed to load icon: %s\n", iconPath);
51 | }
52 | }
--------------------------------------------------------------------------------
/C-DS/QueueVisualization.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "GrandWindow.h"
3 | #include
4 | #include
5 | #include
6 | class QueueVisualization : public GrandWindow
7 | {
8 | private:
9 |
10 | const int MAX_SIZE = 1024;
11 |
12 | // speed constraints:
13 | const float MAX_SPEED = 10.0f;
14 | const float MIN_SPEED = 0.1f;
15 | const float DELAY_TIME = 0.2f;
16 | const float BASE_DELAY = 0.6f;
17 |
18 | const float QUEUE_ROUNDNESS = 10.f;
19 | const float CELL_SIZE = 70.f;
20 | const float SEPARATOR_SIZE = 5.f;
21 |
22 | enum {
23 | DEFAULT_CELL_COL,
24 | CELL_BORDER_COL,
25 | ARROW1_COL,
26 | ARROW2_COL,
27 | TEXT_COLOR,
28 | TEXT_OUTLINE_COL
29 | };
30 |
31 | // private fields:
32 | ImGuiWindowFlags main_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoBringToFrontOnFocus;
33 | ImGuiWindowFlags controls_flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings;
34 |
35 |
36 |
37 |
38 | int cur_tool = 0, sz = 0, tailpointer = 0, headpointer = 0, currentMaxSize = 1, expansion = -1, tempSize = 0;
39 | bool camfollow = false, movingCam = false;
40 |
41 | char add_element_content[200] = {};
42 | float speed = 1.f, passedTime = 0.f;
43 |
44 | std::string* content = new std::string[currentMaxSize], *tempContent = nullptr;
45 | std::queue pending;
46 |
47 | void controlsUpdate();
48 | void getInput();
49 | ImU32 getColor(int);
50 | void drawText(ImVec2, const char*);
51 | void queueUpdate();
52 | void drawQueue(int, std::string[], int, int, int);
53 | void drawArrow(int, int, int, bool);
54 | bool Enqueue(std::string);
55 | void Dequeue();
56 | void expand();
57 |
58 | public:
59 | QueueVisualization(std::string, int&, float&, bool&, int&);
60 | ~QueueVisualization();
61 | void update();
62 |
63 | };
--------------------------------------------------------------------------------
/C-DS/App.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "imgui.h"
3 | #include "imgui_impl_glfw.h"
4 | #include "imgui_impl_opengl3.h"
5 | #define GL_SILENCE_DEPRECATION
6 | #if defined(IMGUI_IMPL_OPENGL_ES2)
7 | #include
8 | #endif
9 | #include
10 |
11 | #define IMGUI_ENABLE_FREETYPE
12 |
13 | #if defined(_MSC_VER) && (_MSC_VER >= 1900) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
14 | #pragma comment(lib, "legacy_stdio_definitions")
15 | #endif
16 |
17 | #include
18 | #include
19 | #include
20 |
21 | #include "Settings.h"
22 | #include "MainMenu.h"
23 | #include "Grid.h"
24 | #include "GraphTools.h"
25 | #include "DSU.h"
26 | #include "CodeVisualizer.h"
27 | #include "Tree.h"
28 | #include "Trie.h"
29 | #include "QueueVisualization.h"
30 | #include "SparseTable.h"
31 | #include "LinkedList.h"
32 | #include "Deque.h"
33 | #include "HashTable.h"
34 | #include "HashMap.h"
35 | #include "Stack.h"
36 | #include "Vector.h"
37 |
38 | class App
39 | {
40 | private:
41 |
42 | // private fields:
43 | GLFWwindow* window;
44 | ImGuiStyle* style;
45 | const ImVec4 clear_color = ImVec4(0.f, 0.f, 0.f, 1.00f);
46 |
47 | GrandWindow* curWindow = nullptr;
48 | Settings* settings = nullptr;
49 | ImGuiIO* io;
50 |
51 | bool vSyncEnabled = true;
52 | int windowPosX = 100, windowPosY = 100;
53 | int windowWidth = 1280, windowHeight = 720;
54 | bool settingsEnabled = false, overlayEndabled = false, f3Pressed = false;
55 | bool isFullscreen = false, f11Pressed = false;
56 | int colorMode = 1;
57 | int state = 0;
58 | float GuiScale = 1.f;
59 | bool zoomIn = false, zoomOut = false;
60 |
61 | // private methods:
62 | void initWindow(std::string);
63 | void initStyle();
64 | void toggleFullscreen();
65 | void updateWindow();
66 | void overlay();
67 |
68 | public:
69 |
70 | App(std::string);
71 | ~App();
72 |
73 |
74 | // public methods:
75 | void run();
76 | void update();
77 | void render();
78 | GLFWwindow* getWindow();
79 |
80 | };
81 |
82 |
--------------------------------------------------------------------------------
/C-DS/Vector.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "GrandWindow.h"
3 | #include
4 | #include
5 | #include
6 | class Vector : public GrandWindow
7 | {
8 | public:
9 | void update();
10 | Vector(std::string, int&, float&, bool&, int&);
11 | ~Vector();
12 | private:
13 |
14 | const int MAX_SIZE = 1024;
15 |
16 | // speed constraints:
17 | const float MAX_SPEED = 10.0f;
18 | const float MIN_SPEED = 0.1f;
19 | const float DELAY_TIME = 0.2f;
20 | const float BASE_DELAY = 0.6f;
21 |
22 | const float VEC_ROUNDNESS = 10.f;
23 | const float VEC_CELL_SIZE = 70.f;
24 | const float VEC_SEPARATOR_SIZE = 5.f;
25 |
26 | enum {
27 | DEFAULT_CELL_COL,
28 | MARKED_CELL_COL,
29 | CELL_BORDER_COL,
30 | END_CELL_COL,
31 | ARROW1_COL,
32 | ARROW2_COL,
33 | TEXT_COLOR,
34 | TEXT_OUTLINE_COL
35 | };
36 |
37 | // private fields:
38 | ImGuiWindowFlags main_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoBringToFrontOnFocus;
39 | ImGuiWindowFlags controls_flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings;
40 |
41 |
42 |
43 |
44 |
45 | int cur_tool = 0, sz = 0, tailpointer = 0, currentMaxSize = 1, expansion = -1, tempSize = 0, insertIdx = -1, eraseIdx = -1, selected_index = 0;
46 | bool camfollow = false, movingCam = false, inserting = 0;
47 |
48 | char add_element_content[200] = {};
49 | float speed = 1.f, passedTime = 0.f;
50 |
51 | std::string* content = new std::string[currentMaxSize], * tempContent = nullptr;
52 | std::queue pending;
53 |
54 |
55 | void updateMenuBar();
56 | void controlsUpdate();
57 |
58 |
59 |
60 | ImU32 getColor(int);
61 | void drawText(ImVec2, const char*);
62 | void vectorUpdate();
63 | void drawVector(int, std::string[], int, int, bool);
64 | void getInput();
65 | void drawArrow(int, int, int, bool);
66 | bool pushBack(std::string);
67 | void popBack();
68 | void expand();
69 | void erase();
70 | void insert();
71 | };
--------------------------------------------------------------------------------
/C-DS/Stack.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "GrandWindow.h"
3 | #include
4 | #include
5 | #include
6 | class Stack : public GrandWindow
7 | {
8 | private:
9 |
10 | const int STACK_MAX_SIZE = 1024;
11 |
12 | // speed constraints:
13 | const float STACK_MAX_SPEED = 10.0f;
14 | const float STACK_MIN_SPEED = 0.1f;
15 | const float STACK_DELAY_TIME = 0.2f;
16 | const float STACK_BASE_DELAY = 0.6f;
17 |
18 | const float STACK_ROUNDNESS = 10.f;
19 | const float STACK_CELL_SIZE = 70.f;
20 | const float STACK_SEPARATOR_SIZE = 5.f;
21 |
22 | enum {
23 | DEFAULT_CELL_COL,
24 | CELL_BORDER_COL,
25 | END_CELL_COL,
26 | ARROW1_COL,
27 | ARROW2_COL,
28 | TEXT_COLOR,
29 | TEXT_OUTLINE_COL
30 | };
31 |
32 | // private fields:
33 | ImGuiWindowFlags main_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoBringToFrontOnFocus;
34 | ImGuiWindowFlags controls_flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings;
35 |
36 |
37 |
38 |
39 | // tools for stack:
40 | // 1: enqueue
41 | // 2: dequeue
42 | // 3: expand (behind the scenes) (for later visualize the the expansion process : ~visualize the 2 contentays~)
43 | int cur_tool = 0, sz = 0, headpointer = 0, currentMaxSize = 1, expansion = -1, tempSize = 0;
44 | bool camfollow = false, movingCam = false;
45 |
46 | char add_element_content[200] = {};
47 | float speed = 1.f, passedTime = 0.f;
48 |
49 | std::string* content = new std::string[currentMaxSize], * tempContent = nullptr;
50 | std::queue pending;
51 |
52 |
53 | void controlsUpdate();
54 |
55 | ImU32 getColor(int);
56 | void drawText(ImVec2, const char*);
57 | void getInput();
58 | void stackUpdate();
59 | void drawStack(int, std::string[], int, int, float, bool);
60 | void drawArrow(int, int, int, bool, float);
61 | bool Push(std::string);
62 | void Pop();
63 | void expand();
64 |
65 | public:
66 |
67 | Stack(std::string, int&, float&, bool&, int&);
68 | ~Stack();
69 | void update();
70 |
71 | };
--------------------------------------------------------------------------------
/C-DS/SparseTable.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "GrandWindow.h"
3 | #include
4 | #include
5 | #include
6 | class SparseTable : public GrandWindow
7 | {
8 | private:
9 | // grid size constraints:
10 | #define X_MAX 50
11 | #define X_MIN 2
12 | #define Y_MAX 50
13 | #define Y_MIN 2
14 |
15 | // speed constraints:
16 | #define GRID_MAX_SPEED 100.0f
17 | #define GRID_MIN_SPEED 0.1f
18 | #define GRID_DELAY_TIME 0.2f
19 |
20 | #define CELL_SIZE 70.f
21 | #define SEPARATOR_SIZE 5.f
22 |
23 | // private fields:
24 | ImGuiWindowFlags main_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoBringToFrontOnFocus;
25 | ImGuiWindowFlags controls_flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings;
26 |
27 |
28 |
29 | int cur_tool = 0, LOG = 18, x_size, y_size,sz=0;
30 | float speed = 1.f, curTime = 0;
31 | bool cleared = true, paused = false, camFollow = false, movingCam = false, building = false, built=false;
32 | ImVec2 camPos = { 0, 0 }, camTarget = { 0, 0 }, cur_pos{ 0,0 }, s_pos{ 0,0 }, cur_cell{ 0,0 };
33 | char buffer[256];
34 | std::vectorElements;
35 | std::vector>selected;
36 | std::vector>table;
37 | std::vectorlogs;
38 | /*
39 | Sparse_Table[LOG][arr_size]
40 | first row will hold the full array
41 | for every row will hold the answer for the query that starts at indx i and ends at j + 2^i
42 | first the user will enter the array and
43 | and the grid will adjust to fit the number
44 | then he will press the build button
45 | when building every cell will be highlighted and the cells it will take it's answer from
46 |
47 | */
48 |
49 | void controlsUpdate();
50 | ImU32 getColor(int, int);
51 | void build();
52 | void init();
53 | void drawtable();
54 | void drawarray(float);
55 | public:
56 | void update();
57 | SparseTable(std::string, int&, float&, bool&, int&);
58 | ~SparseTable();
59 | };
60 |
61 |
--------------------------------------------------------------------------------
/C-DS/Segment_Tree.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "GrandWindow.h"
3 | #include
4 | #include