整合了Editor部分类的抽象模型
parent
cbc4c2ebf5
commit
722b4bfacd
|
@ -99,7 +99,10 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\CaptionButton.cpp" />
|
<ClCompile Include="src\CaptionButton.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidget.cpp" />
|
<ClCompile Include="src\Editor\EditorWidget.cpp" />
|
||||||
|
<ClCompile Include="src\Editor\ElementManager.cpp" />
|
||||||
<ClCompile Include="src\Editor\GraphicElement.cpp" />
|
<ClCompile Include="src\Editor\GraphicElement.cpp" />
|
||||||
|
<ClCompile Include="src\Editor\LayerManager.cpp" />
|
||||||
|
<ClCompile Include="src\Editor\LayerWrapper.cpp" />
|
||||||
<ClCompile Include="src\IconWidget.cpp" />
|
<ClCompile Include="src\IconWidget.cpp" />
|
||||||
<ClCompile Include="src\main.cpp" />
|
<ClCompile Include="src\main.cpp" />
|
||||||
<ClCompile Include="src\MainWindow.cpp" />
|
<ClCompile Include="src\MainWindow.cpp" />
|
||||||
|
@ -151,7 +154,11 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="src\MainWindow.h" />
|
<QtMoc Include="src\MainWindow.h" />
|
||||||
|
<ClInclude Include="src\Editor\ElementManager.h" />
|
||||||
<ClInclude Include="src\Editor\GraphicElement.h" />
|
<ClInclude Include="src\Editor\GraphicElement.h" />
|
||||||
|
<ClInclude Include="src\Editor\LayerManager.h" />
|
||||||
|
<ClInclude Include="src\Editor\LayerStyle.h" />
|
||||||
|
<ClInclude Include="src\Editor\LayerWrapper.h" />
|
||||||
<ClInclude Include="src\Renderer\Painting\Element.h" />
|
<ClInclude Include="src\Renderer\Painting\Element.h" />
|
||||||
<ClInclude Include="src\Renderer\Painting\Painting.h" />
|
<ClInclude Include="src\Renderer\Painting\Painting.h" />
|
||||||
<ClInclude Include="src\SvgParser.h" />
|
<ClInclude Include="src\SvgParser.h" />
|
||||||
|
|
|
@ -129,6 +129,15 @@
|
||||||
<ClCompile Include="src\Editor\GraphicElement.cpp">
|
<ClCompile Include="src\Editor\GraphicElement.cpp">
|
||||||
<Filter>Source Files\Editor</Filter>
|
<Filter>Source Files\Editor</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\ElementManager.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\LayerManager.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\LayerWrapper.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
||||||
|
@ -272,6 +281,18 @@
|
||||||
<ClInclude Include="src\Editor\GraphicElement.h">
|
<ClInclude Include="src\Editor\GraphicElement.h">
|
||||||
<Filter>Header Files\Editor</Filter>
|
<Filter>Header Files\Editor</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\ElementManager.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\LayerManager.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\LayerStyle.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\LayerWrapper.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtRcc Include="MainWindow.qrc">
|
<QtRcc Include="MainWindow.qrc">
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#include "ElementManager.h"
|
||||||
|
ElementManager *ElementManager::getInstance()
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
void ElementManager::addElement(GraphicElement *element)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void ElementManager::removeElement(GraphicElement *pElement)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
GraphicElement *ElementManager::getElementById(int index)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
#pragma once
|
||||||
|
#include "GraphicElement.h"
|
||||||
|
#include <vector>
|
||||||
|
using std::vector;
|
||||||
|
class ElementManager
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
static ElementManager *INSTANCE;
|
||||||
|
vector<GraphicElement> mElements;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static ElementManager *getInstance();
|
||||||
|
void addElement(GraphicElement *element);
|
||||||
|
void removeElement(GraphicElement *pElement);
|
||||||
|
/**
|
||||||
|
* only used in initialization
|
||||||
|
*/
|
||||||
|
GraphicElement *getElementById(int index);
|
||||||
|
};
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "LayerManager.h"
|
||||||
|
|
||||||
|
void LayerManager::paint(QPainter *painter) const
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
#pragma once
|
||||||
|
#include "LayerWrapper.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
using std::pair;
|
||||||
|
using std::vector;
|
||||||
|
class LayerManager
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
using LayerPtrs = vector<LayerWrapper *>;
|
||||||
|
LayerWrapper root;
|
||||||
|
LayerPtrs selectedLayers;
|
||||||
|
LayerPtrs involvedLeafLayersCache;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void paint(QPainter *painter) const;
|
||||||
|
};
|
|
@ -0,0 +1,6 @@
|
||||||
|
#pragma once
|
||||||
|
class LayerStyle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void apply() = 0;
|
||||||
|
};
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "LayerWrapper.h"
|
||||||
|
|
||||||
|
void LayerWrapper::applyStyles(SimpleElement &element)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void FolderLayerWrapper::addChild(LayerWrapper *child)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void FolderLayerWrapper::removeChild(LayerWrapper *child)
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
#pragma once
|
||||||
|
#include "GraphicElement.h"
|
||||||
|
#include "LayerStyle.h"
|
||||||
|
#include <QLine>
|
||||||
|
#include <QPoint>
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
using std::shared_ptr;
|
||||||
|
using std::vector;
|
||||||
|
class LayerWrapper
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
shared_ptr<LayerWrapper> parent;
|
||||||
|
QPointF referencePoint;
|
||||||
|
vector<LayerStyle> styles;
|
||||||
|
QPainterPath cache;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void applyStyles(SimpleElement &element); // invoke by manager, then invoke parent's applyStyles
|
||||||
|
// todo: provide atomic operations for Events
|
||||||
|
};
|
||||||
|
|
||||||
|
class FolderLayerWrapper : public LayerWrapper
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
vector<shared_ptr<LayerWrapper>> children;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void addChild(LayerWrapper *child);
|
||||||
|
void removeChild(LayerWrapper *child);
|
||||||
|
};
|
||||||
|
|
||||||
|
class LeafLayerWrapper : public LayerWrapper
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
shared_ptr<SimpleElement> wrappedElement;
|
||||||
|
};
|
Loading…
Reference in New Issue