Commit a9b6c249 authored by Leander Schulten's avatar Leander Schulten
Browse files

Moving Polygon, MapView and MapEditor in GUI namespace to avoid duplicated names

parent aca3e6ba
...@@ -54,7 +54,7 @@ QByteArray saveData(){ ...@@ -54,7 +54,7 @@ QByteArray saveData(){
o.insert("ControlPanel",u); o.insert("ControlPanel",u);
}{ }{
QJsonObject u; QJsonObject u;
MapView::getLastCreated()->writeJsonObject(u); GUI::MapView::getLastCreated()->writeJsonObject(u);
o.insert("MapView",u); o.insert("MapView",u);
}{ }{
QJsonObject u; QJsonObject u;
...@@ -110,7 +110,7 @@ std::function<void()> loadData(QByteArray data){ ...@@ -110,7 +110,7 @@ std::function<void()> loadData(QByteArray data){
password=QCryptographicHash::hash(QString("admin").toLatin1(),QCryptographicHash::Sha3_256); password=QCryptographicHash::hash(QString("admin").toLatin1(),QCryptographicHash::Sha3_256);
return [=](){ return [=](){
ControlPanel::getLastCreated()->loadFromJsonObject(o["ControlPanel"].toObject()); ControlPanel::getLastCreated()->loadFromJsonObject(o["ControlPanel"].toObject());
MapView::getLastCreated()->loadFromJsonObject(o["MapView"].toObject()); GUI::MapView::getLastCreated()->loadFromJsonObject(o["MapView"].toObject());
Modules::ProgramBlockManager::readFromJsonObject(o["ProgramBlockManager"].toObject()); Modules::ProgramBlockManager::readFromJsonObject(o["ProgramBlockManager"].toObject());
}; };
......
...@@ -91,8 +91,8 @@ int main(int argc, char *argv[]) ...@@ -91,8 +91,8 @@ int main(int argc, char *argv[])
ProgramBlockEditor::engine = &engine; ProgramBlockEditor::engine = &engine;
//qmlRegisterType<const ChannelVector*>("my.models",1,0,"ChannelVector"); //qmlRegisterType<const ChannelVector*>("my.models",1,0,"ChannelVector");
qmlRegisterType<ChannelProgrammEditor>("custom.licht",1,0,"ChannelProgrammEditor"); qmlRegisterType<ChannelProgrammEditor>("custom.licht",1,0,"ChannelProgrammEditor");
qmlRegisterType<MapView>("custom.licht",1,0,"MapView"); qmlRegisterType<GUI::MapView>("custom.licht",1,0,"MapView");
qmlRegisterType<MapEditor>("custom.licht",1,0,"MapEditor"); qmlRegisterType<GUI::MapEditor>("custom.licht",1,0,"MapEditor");
qmlRegisterType<ControlPanel>("custom.licht",1,0,"ControlPanel"); qmlRegisterType<ControlPanel>("custom.licht",1,0,"ControlPanel");
qmlRegisterType<Graph>("custom.licht",1,0,"Graph"); qmlRegisterType<Graph>("custom.licht",1,0,"Graph");
qmlRegisterType<Oscillogram>("custom.licht",1,0,"Oscillogram"); qmlRegisterType<Oscillogram>("custom.licht",1,0,"Oscillogram");
......
#include "mapeditor.h" #include "mapeditor.h"
namespace GUI{
MapEditor::MapEditor() MapEditor::MapEditor()
{ {
setAcceptedMouseButtons(Qt::AllButtons); setAcceptedMouseButtons(Qt::AllButtons);
...@@ -24,3 +26,5 @@ void MapEditor::mouseMoveEvent(QMouseEvent *event){ ...@@ -24,3 +26,5 @@ void MapEditor::mouseMoveEvent(QMouseEvent *event){
event->accept(); event->accept();
} }
} }
}
...@@ -3,10 +3,12 @@ ...@@ -3,10 +3,12 @@
#include "mapview.h" #include "mapview.h"
namespace GUI{
class MapEditor : public MapView class MapEditor : public MapView
{ {
private: private:
Polygon::Point * currentPressedPoint = nullptr; GUI::Polygon::Point * currentPressedPoint = nullptr;
public: public:
MapEditor(); MapEditor();
...@@ -15,4 +17,6 @@ protected: ...@@ -15,4 +17,6 @@ protected:
virtual void mousePressEvent(QMouseEvent *event)override; virtual void mousePressEvent(QMouseEvent *event)override;
}; };
}
#endif // MAPEDITOR_H #endif // MAPEDITOR_H
#include "mapview.h" #include "mapview.h"
#include <QJsonArray> #include <QJsonArray>
namespace GUI {
MapView * MapView::lastCreated = nullptr; MapView * MapView::lastCreated = nullptr;
...@@ -48,3 +49,5 @@ void MapView::writeJsonObject(QJsonObject &o) const{ ...@@ -48,3 +49,5 @@ void MapView::writeJsonObject(QJsonObject &o) const{
} }
o.insert("polygons",a); o.insert("polygons",a);
} }
}
...@@ -4,14 +4,16 @@ ...@@ -4,14 +4,16 @@
#include "polygon.h" #include "polygon.h"
#include "gridbackground.h" #include "gridbackground.h"
namespace GUI{
class MapView : public GridBackground class MapView : public GridBackground
{ {
Q_OBJECT Q_OBJECT
static MapView * lastCreated; static MapView * lastCreated;
protected: protected:
std::vector<Polygon *> polygons; std::vector<GUI::Polygon *> polygons;
Polygon * stonework; GUI::Polygon * stonework;
Polygon * surfaces; GUI::Polygon * surfaces;
public: public:
MapView(); MapView();
static MapView * getLastCreated(){return lastCreated;} static MapView * getLastCreated(){return lastCreated;}
...@@ -22,4 +24,6 @@ signals: ...@@ -22,4 +24,6 @@ signals:
public slots: public slots:
}; };
}
#endif // MAPVIEW_H #endif // MAPVIEW_H
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include <corecrt_math_defines.h> #include <corecrt_math_defines.h>
#endif #endif
namespace GUI {
Polygon::Polygon(QString name):name(name) Polygon::Polygon(QString name):name(name)
{ {
setFlag(ItemHasContents); setFlag(ItemHasContents);
...@@ -288,3 +290,6 @@ void Polygon::addRectangle(Point p1, Point p2, Point p3, Point p4){ ...@@ -288,3 +290,6 @@ void Polygon::addRectangle(Point p1, Point p2, Point p3, Point p4){
triangles.emplace_back(i1,i2,i3); triangles.emplace_back(i1,i2,i3);
triangles.emplace_back(i2,i3,i4); triangles.emplace_back(i2,i3,i4);
} }
}
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
#include <corecrt_math_defines.h> #include <corecrt_math_defines.h>
#endif #endif
namespace GUI {
class Polygon;
}
namespace Primitives { namespace Primitives {
...@@ -57,7 +61,7 @@ class Arc{ ...@@ -57,7 +61,7 @@ class Arc{
public: public:
Indextype left, mid, right; Indextype left, mid, right;
public: public:
friend class Polygon; friend class GUI::Polygon;
typedef Indextype index_type; typedef Indextype index_type;
Arc(Indextype left,Indextype mid,Indextype right):left(left),mid(mid),right(right){} Arc(Indextype left,Indextype mid,Indextype right):left(left),mid(mid),right(right){}
Arc(const QJsonObject &o):left(o["left"].toInt()),mid(o["mid"].toInt()),right(o["right"].toInt()){} Arc(const QJsonObject &o):left(o["left"].toInt()),mid(o["mid"].toInt()),right(o["right"].toInt()){}
...@@ -104,6 +108,9 @@ public: ...@@ -104,6 +108,9 @@ public:
} }
namespace GUI {
/** /**
* @brief The Polygon class holds an Polygon. Its contains multiple Points that con be combined to Triangles and Arcs * @brief The Polygon class holds an Polygon. Its contains multiple Points that con be combined to Triangles and Arcs
*/ */
...@@ -227,4 +234,6 @@ public: ...@@ -227,4 +234,6 @@ public:
QSGNode * updatePaintNode(QSGNode *, UpdatePaintNodeData *)override; QSGNode * updatePaintNode(QSGNode *, UpdatePaintNodeData *)override;
}; };
}
#endif // POLYGON_H #endif // POLYGON_H
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment