Skip to content

Commit

Permalink
Improve app scalability
Browse files Browse the repository at this point in the history
  • Loading branch information
Horizon-NTH committed May 11, 2024
1 parent d58bdb2 commit 2263996
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 198 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Folder.DotSettings.user
.vs
.idea
ShapeDrawer.exe
ShapeDrawer
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.12)

project(ShapeDrawer VERSION 1.0.0)
project(ShapeDrawer VERSION 1.1)

add_subdirectory(deps/HorizonGUI)

Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ShapeDrawer

[![Release](https://img.shields.io/badge/Release-v1.1-blueviolet)](https://github.com/Horizon-NTH/ShapeDrawer/releases)
[![Language](https://img.shields.io/badge/Language-C%2B%2B-0052cf)](https://en.wikipedia.org/wiki/C++)
[![Licence](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

![ShapeDrawer's Logo](assets/textures/ShapeDrawer.png)

## Introduction
Expand Down Expand Up @@ -65,4 +69,8 @@ To learn how to use this application, please refer to the [wiki](https://github.

* **HorizonGUI**

The code relies on [HorizonGUI](https://github.com/Horizon-NTH/HorizonGUI) for all the graphics-related functionality of the application.
The code relies on [HorizonGUI](https://github.com/Horizon-NTH/HorizonGUI) for all the graphics-related functionality of the application.

## License

ShapeDrawer is licensed under the [MIT license](https://github.com/Horizon-NTH/ShapeDrawer/blob/master/LICENSE).
2 changes: 1 addition & 1 deletion deps/HorizonGUI
Submodule HorizonGUI updated 162 files
1 change: 1 addition & 0 deletions include/ShapeDrawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ShapeDrawer
bool m_randomDrawing;
std::vector<hgui::point> m_shapeDrawn;
hgui::point m_cursorPosition;
std::vector<std::string> m_order;

void set_main_menu();
void set_option_menu();
Expand Down
56 changes: 34 additions & 22 deletions src/DataManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ void DataManager::load(const std::string& path)
hgui::point center;
float radius;
bool fill;
float x;
float y;

ss >> center.x;
ss >> center.y;
ss >> x >> y;
center = hgui::point(x, y);
ss >> radius;
ss >> color.r;
ss >> color.g;
Expand All @@ -54,13 +56,16 @@ void DataManager::load(const std::string& path)
}
case shape::RECTANGLE:
{
hgui::point topLeftVertex, bottomRightVertex;
hgui::point topLeftVertex;
hgui::point bottomRightVertex;
bool fill;
float x;
float y;

ss >> topLeftVertex.x;
ss >> topLeftVertex.y;
ss >> bottomRightVertex.x;
ss >> bottomRightVertex.y;
ss >> x >> y;
topLeftVertex = hgui::point(x, y);
ss >> x >> y;
bottomRightVertex = hgui::point(x, y);
ss >> color.r;
ss >> color.g;
ss >> color.b;
Expand All @@ -73,12 +78,15 @@ void DataManager::load(const std::string& path)
}
case shape::LINE:
{
hgui::point firstVertex, secondVertex;

ss >> firstVertex.x;
ss >> firstVertex.y;
ss >> secondVertex.x;
ss >> secondVertex.y;
hgui::point firstVertex;
hgui::point secondVertex;
float x;
float y;

ss >> x >> y;
firstVertex = hgui::point(x, y);
ss >> x >> y;
secondVertex = hgui::point(x, y);
ss >> color.r;
ss >> color.g;
ss >> color.b;
Expand All @@ -90,15 +98,19 @@ void DataManager::load(const std::string& path)
}
case shape::TRIANGLE:
{
hgui::point firstVertex, secondVertex, thirdVertex;
hgui::point firstVertex;
hgui::point secondVertex;
hgui::point thirdVertex;
bool fill;

ss >> firstVertex.x;
ss >> firstVertex.y;
ss >> secondVertex.x;
ss >> secondVertex.y;
ss >> thirdVertex.x;
ss >> thirdVertex.y;
float x;
float y;

ss >> x >> y;
firstVertex = hgui::point(x, y);
ss >> x >> y;
secondVertex = hgui::point(x, y);
ss >> x >> y;
thirdVertex = hgui::point(x, y);
ss >> color.r;
ss >> color.g;
ss >> color.b;
Expand All @@ -123,7 +135,7 @@ void DataManager::save(const std::string& path) const
{
if (std::ofstream file(path); file.is_open())
{
for (const auto& shape : *m_shapes->get_shapes())
for (const auto& [id, shape] : *m_shapes->get_shapes())
{
hgui::kernel::shape::ShapeData data = shape->get_data();
if (const auto& points = std::get_if<std::pair<hgui::point, hgui::point>>(&data))
Expand Down
Loading

0 comments on commit 2263996

Please sign in to comment.