From 722b4bfacd4cb8c2261d8c60fed0b71645ca1b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B0=81=E7=BE=BD?= <2360164671@qq.com> Date: Sat, 19 Nov 2022 16:12:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E5=90=88=E4=BA=86Editor=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=9A=84=E6=8A=BD=E8=B1=A1=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ArchitectureColoredPainting.vcxproj | 7 ++++ ...rchitectureColoredPainting.vcxproj.filters | 21 +++++++++++ .../src/Editor/ElementManager.cpp | 15 ++++++++ .../src/Editor/ElementManager.h | 19 ++++++++++ .../src/Editor/LayerManager.cpp | 5 +++ .../src/Editor/LayerManager.h | 18 +++++++++ .../src/Editor/LayerStyle.h | 6 +++ .../src/Editor/LayerWrapper.cpp | 11 ++++++ .../src/Editor/LayerWrapper.h | 37 +++++++++++++++++++ 9 files changed, 139 insertions(+) create mode 100644 ArchitectureColoredPainting/src/Editor/ElementManager.cpp create mode 100644 ArchitectureColoredPainting/src/Editor/ElementManager.h create mode 100644 ArchitectureColoredPainting/src/Editor/LayerManager.cpp create mode 100644 ArchitectureColoredPainting/src/Editor/LayerManager.h create mode 100644 ArchitectureColoredPainting/src/Editor/LayerStyle.h create mode 100644 ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp create mode 100644 ArchitectureColoredPainting/src/Editor/LayerWrapper.h diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj index 1c52dfd..6aaae03 100644 --- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj +++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj @@ -99,7 +99,10 @@ + + + @@ -151,7 +154,11 @@ + + + + diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters index b73c477..1d9364f 100644 --- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters +++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters @@ -129,6 +129,15 @@ Source Files\Editor + + Source Files + + + Source Files + + + Source Files + @@ -272,6 +281,18 @@ Header Files\Editor + + Header Files + + + Header Files + + + Header Files + + + Header Files + diff --git a/ArchitectureColoredPainting/src/Editor/ElementManager.cpp b/ArchitectureColoredPainting/src/Editor/ElementManager.cpp new file mode 100644 index 0000000..af7cbde --- /dev/null +++ b/ArchitectureColoredPainting/src/Editor/ElementManager.cpp @@ -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; +} diff --git a/ArchitectureColoredPainting/src/Editor/ElementManager.h b/ArchitectureColoredPainting/src/Editor/ElementManager.h new file mode 100644 index 0000000..0397576 --- /dev/null +++ b/ArchitectureColoredPainting/src/Editor/ElementManager.h @@ -0,0 +1,19 @@ +#pragma once +#include "GraphicElement.h" +#include +using std::vector; +class ElementManager +{ + private: + static ElementManager *INSTANCE; + vector mElements; + + public: + static ElementManager *getInstance(); + void addElement(GraphicElement *element); + void removeElement(GraphicElement *pElement); + /** + * only used in initialization + */ + GraphicElement *getElementById(int index); +}; diff --git a/ArchitectureColoredPainting/src/Editor/LayerManager.cpp b/ArchitectureColoredPainting/src/Editor/LayerManager.cpp new file mode 100644 index 0000000..8c36f08 --- /dev/null +++ b/ArchitectureColoredPainting/src/Editor/LayerManager.cpp @@ -0,0 +1,5 @@ +#include "LayerManager.h" + +void LayerManager::paint(QPainter *painter) const +{ +} diff --git a/ArchitectureColoredPainting/src/Editor/LayerManager.h b/ArchitectureColoredPainting/src/Editor/LayerManager.h new file mode 100644 index 0000000..02653a8 --- /dev/null +++ b/ArchitectureColoredPainting/src/Editor/LayerManager.h @@ -0,0 +1,18 @@ +#pragma once +#include "LayerWrapper.h" +#include +#include +#include +using std::pair; +using std::vector; +class LayerManager +{ + private: + using LayerPtrs = vector; + LayerWrapper root; + LayerPtrs selectedLayers; + LayerPtrs involvedLeafLayersCache; + + public: + void paint(QPainter *painter) const; +}; diff --git a/ArchitectureColoredPainting/src/Editor/LayerStyle.h b/ArchitectureColoredPainting/src/Editor/LayerStyle.h new file mode 100644 index 0000000..d3966ab --- /dev/null +++ b/ArchitectureColoredPainting/src/Editor/LayerStyle.h @@ -0,0 +1,6 @@ +#pragma once +class LayerStyle +{ + public: + virtual void apply() = 0; +}; diff --git a/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp b/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp new file mode 100644 index 0000000..6f5dcb1 --- /dev/null +++ b/ArchitectureColoredPainting/src/Editor/LayerWrapper.cpp @@ -0,0 +1,11 @@ +#include "LayerWrapper.h" + +void LayerWrapper::applyStyles(SimpleElement &element) +{ +} +void FolderLayerWrapper::addChild(LayerWrapper *child) +{ +} +void FolderLayerWrapper::removeChild(LayerWrapper *child) +{ +} diff --git a/ArchitectureColoredPainting/src/Editor/LayerWrapper.h b/ArchitectureColoredPainting/src/Editor/LayerWrapper.h new file mode 100644 index 0000000..426f88f --- /dev/null +++ b/ArchitectureColoredPainting/src/Editor/LayerWrapper.h @@ -0,0 +1,37 @@ +#pragma once +#include "GraphicElement.h" +#include "LayerStyle.h" +#include +#include +#include +#include +using std::shared_ptr; +using std::vector; +class LayerWrapper +{ + protected: + shared_ptr parent; + QPointF referencePoint; + vector 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> children; + + public: + void addChild(LayerWrapper *child); + void removeChild(LayerWrapper *child); +}; + +class LeafLayerWrapper : public LayerWrapper +{ + private: + shared_ptr wrappedElement; +};