diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ca4c7b..3d0ffe0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,16 +2,17 @@ cmake_minimum_required(VERSION 3.5)
project(DiagramDesigner LANGUAGES CXX VERSION 1.0)
+
+
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
-#set(ADS_VERSION 4.3.1)
-#add_subdirectory(QtADS)
-
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
-find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets REQUIRED)
+find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets Sql Xml REQUIRED)
find_package(Qt6 REQUIRED COMPONENTS SvgWidgets)
+find_package(Qt6 COMPONENTS Network REQUIRED)
+find_package(PostgreSQL REQUIRED)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -35,74 +36,23 @@ else()
endif()
set(H_HEADER_FILES
- include/global.h
include/mainwindow.h
include/graphicElementsPanel.h
include/electricElementsPanel.h
include/electricElementsBox.h
include/electricElementsListwidget.h
- include/drawingPanel.h
- include/diagramCavas.h
- include/designerScene.h
- include/designerView.h
include/operationCommand.h
include/toolPage.h
include/toolBox.h
- include/statusBar.h
+ include/loadPageDlg.h
- include/util/baseSelector.h
- include/util/creatingSelector.h
- include/util/movingSelector.h
- include/util/subMovingSelector.h
- include/util/rotationSelector.h
- include/util/scalingSelector.h
- include/util/editingSelector.h
- include/util/connectingSelector.h
- include/util/linkMovingSelector.h
- include/util/selectorManager.h
+ common/include/global.h
+ common/include/dataBase.h
+ common/include/httpInterface.h
+ common/include/compiler.hpp
+ common/include/export.hpp
+ common/include/operatingSystem.hpp
- include/graphicsDataModel/fixedPortsModel.h
-
- include/graphicsItem/itemControlHandle.h
- include/graphicsItem/handleRect.h
- include/graphicsItem/handleText.h
- include/graphicsItem/itemPort.h
- include/graphicsItem/graphicsBaseItem.h
- include/graphicsItem/graphicsRectItem.h
- include/graphicsItem/graphicsPolygonItem.h
- include/graphicsItem/graphicsItemGroup.h
- include/graphicsItem/electricSvgItem.h
- include/graphicsItem/electricSvgItemBus.h
- include/graphicsItem/electricSvgItemRect.h
- include/graphicsItem/electricSvgItemTriangle.h
- include/graphicsItem/electricConnectLineItem.h
-
- include/abstractGraphModel.h
- include/connectionIdUtils.h
- include/serializable.h
- include/dataFlowGraphModel.h
- include/nodeData.h
- include/nodeDelegateModel.h
- include/nodeDelegateModelRegistry.h
- include/style.h
- include/nodeStyle.h
- include/connectionStyle.h
- include/graphicsViewStyle.h
- include/styleCollection.h
- include/abstractNodeGeometry.h
- include/basicGraphicsScene.h
- include/connectionState.h
- include/connectionGraphicsObject.h
- include/nodeGraphicsObject.h
- include/nodeState.h
- include/connectionPainter.h
- include/nodeConnectionInteraction.h
- include/undoCommands.h
- include/locateNode.h
- include/defaultNodePainter.h
- include/abstractNodePainter.h
- include/defaultHorizontalNodeGeometry.h
- include/defaultVerticalNodeGeometry.h
)
set(CPP_SOURCE_FILES
source/main.cpp
@@ -111,67 +61,18 @@ set(CPP_SOURCE_FILES
source/electricElementsPanel.cpp
source/electricElementsBox.cpp
source/electricElementsListwidget.cpp
- source/drawingPanel.cpp
- source/diagramCavas.cpp
- source/designerScene.cpp
- source/designerView.cpp
source/operationCommand.cpp
source/toolPage.cpp
source/toolBox.cpp
- source/statusBar.cpp
+ source/loadPageDlg.cpp
- source/util/baseSelector.cpp
- source/util/creatingSelector.cpp
- source/util/movingSelector.cpp
- source/util/subMovingSelector.cpp
- source/util/rotationSelector.cpp
- source/util/scalingSelector.cpp
- source/util/editingSelector.cpp
- source/util/connectingSelector.cpp
- source/util/linkMovingSelector.cpp
- source/util/selectorManager.cpp
-
- source/graphicsDataModel/fixedPortsModel.cpp
-
- source/graphicsItem/itemControlHandle.cpp
- source/graphicsItem/handleRect.cpp
- source/graphicsItem/handleText.cpp
- source/graphicsItem/itemPort.cpp
- source/graphicsItem/graphicsBaseItem.cpp
- source/graphicsItem/graphicsRectItem.cpp
- source/graphicsItem/graphicsPolygonItem.cpp
- source/graphicsItem/graphicsItemGroup.cpp
- source/graphicsItem/electricSvgItem.cpp
- source/graphicsItem/electricSvgItemBus.cpp
- source/graphicsItem/electricSvgItemRect.cpp
- source/graphicsItem/electricSvgItemTriangle.cpp
- source/graphicsItem/electricConnectLineItem.cpp
-
- source/abstractGraphModel.cpp
- source/dataFlowGraphModel.cpp
- source/nodeDelegateModel.cpp
- source/nodeDelegateModelRegistry.cpp
- source/nodeStyle.cpp
- source/styleCollection.cpp
- source/connectionStyle.cpp
- source/graphicsViewStyle.cpp
- source/abstractNodeGeometry.cpp
- source/basicGraphicsScene.cpp
- source/connectionState.cpp
- source/nodeState.cpp
- source/connectionPainter.cpp
- source/nodeConnectionInteraction.cpp
- source/undoCommands.cpp
- source/locateNode.cpp
- source/connectionGraphicsObject.cpp
- source/defaultVerticalNodeGeometry.cpp
- source/defaultHorizontalNodeGeometry.cpp
- source/nodeGraphicsObject.cpp
+ common/source/dataBase.cpp
+ common/source/httpInterface.cpp
)
set(UI_FILES
ui/mainwindow.ui
ui/graphicElementsPanel.ui
- ui/drawingPanel.ui
+ ui/loadPageDlg.ui
)
# 包含源文件目录
@@ -184,8 +85,6 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
${CPP_SOURCE_FILES}
${UI_FILES}
resource/DiagramDesigner.qrc
- include/graphicsDataModel/fixedPortsModel.h
- source/graphicsDataModel/fixedPortsModel.cpp
)
else()
if(ANDROID)
@@ -206,13 +105,17 @@ else()
endif()
include_directories(include)
+include_directories(common/include)
+include_directories(${POSTGRESQL_INCLUDE_DIRS})
target_include_directories(DiagramDesigner PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
-#target_link_libraries(DiagramDesigner PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
target_link_libraries(DiagramDesigner PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets)
target_link_libraries(DiagramDesigner PRIVATE Qt6::SvgWidgets)
+target_link_libraries(DiagramDesigner PRIVATE Qt6::Xml)
+target_link_libraries(DiagramDesigner PRIVATE Qt6::Network)
+target_link_libraries(DiagramDesigner PRIVATE Qt6::Sql ${POSTGRESQL_LIBRARIES})
set_target_properties(DiagramDesigner PROPERTIES
AUTOMOC ON
AUTORCC ON
@@ -227,3 +130,7 @@ set_target_properties(DiagramDesigner PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${dd_PlatformDir}/bin"
)
+target_link_libraries(DiagramDesigner PRIVATE diagramCavas)
+add_subdirectory(diagramCavas)
+
+file(COPY setting.xml DESTINATION "${CMAKE_BINARY_DIR}/${dd_PlatformDir}/bin")
diff --git a/CMakeLists.txt.user.180d0b4 b/CMakeLists.txt.user.180d0b4
deleted file mode 100644
index f06aac5..0000000
--- a/CMakeLists.txt.user.180d0b4
+++ /dev/null
@@ -1,315 +0,0 @@
-
-
-
-
-
- EnvironmentId
- {180d0b44-822c-4522-af92-2d8bdefcfe6f}
-
-
- ProjectExplorer.Project.ActiveTarget
- 0
-
-
- ProjectExplorer.Project.EditorSettings
-
- true
- false
- true
-
- Cpp
-
- CppGlobal
-
-
-
- QmlJS
-
- QmlJSGlobal
-
-
- 2
- UTF-8
- false
- 4
- false
- 80
- true
- true
- 1
- 0
- false
- true
- false
- 2
- true
- true
- 0
- 8
- true
- false
- 1
- true
- true
- true
- *.md, *.MD, Makefile
- false
- true
- true
-
-
-
- ProjectExplorer.Project.PluginSettings
-
-
- true
- false
- true
- true
- true
- true
-
- false
-
-
- 0
- true
-
- true
- true
- Builtin.DefaultTidyAndClazy
- 14
- true
-
-
-
- true
-
-
-
-
- ProjectExplorer.Project.Target.0
-
- Desktop
- Desktop Qt 6.7.2 MinGW 64-bit
- Desktop Qt 6.7.2 MinGW 64-bit
- qt.qt6.672.win64_mingw_kit
- 0
- 0
- 0
-
- Debug
- 2
- false
-
- -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DCMAKE_BUILD_TYPE:STRING=Debug
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
--DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
--DCMAKE_GENERATOR:STRING=Ninja
--DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
- 0
- D:\work\project\DiagramDesigner\DiagramDesigner\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug
-
-
-
-
- all
-
- false
-
- true
- 构建
- CMakeProjectManager.MakeStep
-
- 1
- 构建
- 构建
- ProjectExplorer.BuildSteps.Build
-
-
-
-
-
- clean
-
- false
-
- true
- 构建
- CMakeProjectManager.MakeStep
-
- 1
- 清除
- 清除
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- false
-
- Debug
- CMakeProjectManager.CMakeBuildConfiguration
-
-
- Release
- 2
- false
-
- -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DCMAKE_BUILD_TYPE:STRING=Release
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
--DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
--DCMAKE_GENERATOR:STRING=Ninja
--DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
- D:\work\project\DiagramDesigner\DiagramDesigner\build\Desktop_Qt_6_7_2_MinGW_64_bit-Release
-
-
-
-
- all
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 构建
- 构建
- ProjectExplorer.BuildSteps.Build
-
-
-
-
-
- clean
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 清除
- 清除
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- false
-
- Release
- CMakeProjectManager.CMakeBuildConfiguration
-
-
- Debug
- 2
- false
-
- -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DCMAKE_BUILD_TYPE:STRING=Debug
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
--DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
--DCMAKE_GENERATOR:STRING=Ninja
--DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
- D:\work\project\DiagramDesigner\DiagramDesigner
- 0
- D:\work\project\DiagramDesigner\DiagramDesigner\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug
-
-
-
-
- all
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 构建
- 构建
- ProjectExplorer.BuildSteps.Build
-
-
-
-
-
- clean
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 清除
- 清除
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- false
-
- Debug2
- CMakeProjectManager.CMakeBuildConfiguration
-
- 3
-
-
- 0
- 部署
- 部署
- ProjectExplorer.BuildSteps.Deploy
-
- 1
-
- false
- ProjectExplorer.DefaultDeployConfiguration
-
- 1
-
- true
- true
- 0
- true
-
- 2
-
- false
- -e cpu-cycles --call-graph "dwarf,4096" -F 250
- DiagramDesigner
- CMakeProjectManager.CMakeRunConfiguration.DiagramDesigner
- DiagramDesigner
- false
- true
- true
- true
- D:/work/project/DiagramDesigner/DiagramDesigner/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug/x64/bin
-
- 1
-
-
-
- ProjectExplorer.Project.TargetCount
- 1
-
-
- ProjectExplorer.Project.Updater.FileVersion
- 22
-
-
- Version
- 22
-
-
diff --git a/CMakeLists.txt.user.f86a295 b/CMakeLists.txt.user.f86a295
deleted file mode 100644
index 0994d91..0000000
--- a/CMakeLists.txt.user.f86a295
+++ /dev/null
@@ -1,315 +0,0 @@
-
-
-
-
-
- EnvironmentId
- {f86a2956-ea1a-464e-91b2-1ab824389029}
-
-
- ProjectExplorer.Project.ActiveTarget
- 0
-
-
- ProjectExplorer.Project.EditorSettings
-
- true
- false
- true
-
- Cpp
-
- CppGlobal
-
-
-
- QmlJS
-
- QmlJSGlobal
-
-
- 2
- UTF-8
- false
- 4
- false
- 80
- true
- true
- 1
- 0
- false
- true
- false
- 2
- true
- true
- 0
- 8
- true
- false
- 1
- true
- true
- true
- *.md, *.MD, Makefile
- false
- true
- true
-
-
-
- ProjectExplorer.Project.PluginSettings
-
-
- true
- false
- true
- true
- true
- true
-
- false
-
-
- 0
- true
-
- true
- true
- Builtin.DefaultTidyAndClazy
- 14
- true
-
-
-
- true
-
-
-
-
- ProjectExplorer.Project.Target.0
-
- Desktop
- Desktop Qt 6.7.2 MinGW 64-bit
- Desktop Qt 6.7.2 MinGW 64-bit
- qt.qt6.672.win64_mingw_kit
- 0
- 0
- 0
-
- Debug
- 2
- false
-
- -DCMAKE_GENERATOR:STRING=Ninja
--DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
--DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DCMAKE_BUILD_TYPE:STRING=Debug
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
- 0
- D:\work\project\DiagramDesigner\DiagramDesigner\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug
-
-
-
-
- all
-
- false
-
- true
- 构建
- CMakeProjectManager.MakeStep
-
- 1
- 构建
- 构建
- ProjectExplorer.BuildSteps.Build
-
-
-
-
-
- clean
-
- false
-
- true
- 构建
- CMakeProjectManager.MakeStep
-
- 1
- 清除
- 清除
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- false
-
- Debug
- CMakeProjectManager.CMakeBuildConfiguration
-
-
- Release
- 2
- false
-
- -DCMAKE_GENERATOR:STRING=Ninja
--DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
--DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DCMAKE_BUILD_TYPE:STRING=Release
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
- D:\work\project\DiagramDesigner\DiagramDesigner\build\Desktop_Qt_6_7_2_MinGW_64_bit-Release
-
-
-
-
- all
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 构建
- 构建
- ProjectExplorer.BuildSteps.Build
-
-
-
-
-
- clean
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 清除
- 清除
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- false
-
- Release
- CMakeProjectManager.CMakeBuildConfiguration
-
-
- Debug
- 2
- false
-
- -DCMAKE_GENERATOR:STRING=Ninja
--DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
--DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
--DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
--DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
--DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
--DCMAKE_BUILD_TYPE:STRING=Debug
--DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
- D:\work\project\DiagramDesigner\DiagramDesigner
- 0
- D:\work\project\DiagramDesigner\DiagramDesigner\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug
-
-
-
-
- all
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 构建
- 构建
- ProjectExplorer.BuildSteps.Build
-
-
-
-
-
- clean
-
- false
-
- true
- CMakeProjectManager.MakeStep
-
- 1
- 清除
- 清除
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- false
-
- Debug2
- CMakeProjectManager.CMakeBuildConfiguration
-
- 3
-
-
- 0
- 部署
- 部署
- ProjectExplorer.BuildSteps.Deploy
-
- 1
-
- false
- ProjectExplorer.DefaultDeployConfiguration
-
- 1
-
- true
- true
- 0
- true
-
- 2
-
- false
- -e cpu-cycles --call-graph "dwarf,4096" -F 250
- DiagramDesigner
- CMakeProjectManager.CMakeRunConfiguration.DiagramDesigner
- DiagramDesigner
- false
- true
- true
- true
- D:/work/project/DiagramDesigner/DiagramDesigner/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug/x64/bin
-
- 1
-
-
-
- ProjectExplorer.Project.TargetCount
- 1
-
-
- ProjectExplorer.Project.Updater.FileVersion
- 22
-
-
- Version
- 22
-
-
diff --git a/common/include/compiler.hpp b/common/include/compiler.hpp
new file mode 100644
index 0000000..fb90a53
--- /dev/null
+++ b/common/include/compiler.hpp
@@ -0,0 +1,40 @@
+#pragma once
+
+#if defined(__MINGW32__) || defined(__MINGW64__)
+#define DIAGRAM_DESIGNER_COMPILER "MinGW"
+#define DIAGRAM_DESIGNER_COMPILER_MINGW
+#elif defined(__clang__)
+#define DIAGRAM_DESIGNER_COMPILER "Clang"
+#define DIAGRAM_DESIGNER_COMPILER_CLANG
+#elif defined(_MSC_VER)
+#define DIAGRAM_DESIGNER_COMPILER "Microsoft Visual C++"
+#define DIAGRAM_DESIGNER_COMPILER_MICROSOFT
+#elif defined(__GNUC__)
+#define DIAGRAM_DESIGNER_COMPILER "GNU"
+#define DIAGRAM_DESIGNER_COMPILER_GNU
+#define DIAGRAM_DESIGNER_COMPILER_GNU_VERSION_MAJOR __GNUC__
+#define DIAGRAM_DESIGNER_COMPILER_GNU_VERSION_MINOR __GNUC_MINOR__
+#define DIAGRAM_DESIGNER_COMPILER_GNU_VERSION_PATCH __GNUC_PATCHLEVEL__
+#elif defined(__BORLANDC__)
+#define DIAGRAM_DESIGNER_COMPILER "Borland C++ Builder"
+#define DIAGRAM_DESIGNER_COMPILER_BORLAND
+#elif defined(__CODEGEARC__)
+#define DIAGRAM_DESIGNER_COMPILER "CodeGear C++ Builder"
+#define DIAGRAM_DESIGNER_COMPILER_CODEGEAR
+#elif defined(__INTEL_COMPILER) || defined(__ICL)
+#define DIAGRAM_DESIGNER_COMPILER "Intel C++"
+#define DIAGRAM_DESIGNER_COMPILER_INTEL
+#elif defined(__xlC__) || defined(__IBMCPP__)
+#define DIAGRAM_DESIGNER_COMPILER "IBM XL C++"
+#define DIAGRAM_DESIGNER_COMPILER_IBM
+#elif defined(__HP_aCC)
+#define DIAGRAM_DESIGNER_COMPILER "HP aC++"
+#define DIAGRAM_DESIGNER_COMPILER_HP
+#elif defined(__WATCOMC__)
+#define DIAGRAM_DESIGNER_COMPILER "Watcom C++"
+#define DIAGRAM_DESIGNER_COMPILER_WATCOM
+#endif
+
+#ifndef DIAGRAM_DESIGNER_COMPILER
+#error "Current compiler is not supported."
+#endif
diff --git a/common/include/dataBase.h b/common/include/dataBase.h
new file mode 100644
index 0000000..c9f0d9b
--- /dev/null
+++ b/common/include/dataBase.h
@@ -0,0 +1,142 @@
+#ifndef DATABASE_H
+#define DATABASE_H
+
+#include
+#include
+#include
+#include
+
+struct availableID //可用id
+{
+ int componentId = -1;
+ int pageId = -1;
+ int stationId = -1;
+ int gridId = -1;
+ int zoneId = -1;
+ int topoId = -1;
+};
+
+struct componentInfo
+{
+ int id = 0;
+ QUuid uuid;
+ QString nspath;
+ QString tag;
+ QString name;
+ QString description;
+ QString grid;
+ QString zone;
+ QString station;
+ int type = 0;
+ bool inService = true;
+ int state = 0;
+ QJsonObject connected_bus;
+ QJsonObject label;
+ QJsonObject context;
+ int page_id = 0;
+ int op = 0;
+ componentInfo& operator=(const componentInfo& obj)
+ {
+ if(this == &obj)
+ return *this;
+ id = obj.id;
+ uuid = obj.uuid;
+ nspath = obj.nspath;
+ tag = obj.tag;
+ name = obj.name;
+ description = obj.description;
+ grid = obj.grid;
+ zone = obj.zone;
+ station = obj.station;
+ type = obj.type;
+ inService = obj.inService;
+ state = obj.state;
+ connected_bus = obj.connected_bus;
+ label = obj.label;
+ context = obj.context;
+ page_id = obj.page_id;
+ op = obj.op;
+ return *this;
+ }
+};
+
+struct busStability
+{
+ int componentId = 0;
+ double resistance = 0;
+ bool anchor_v = false;
+ double uv_alarm = 0;
+ double ov_alarm = 0;
+ bool anchor_i = false;
+ double ui_alarm = 0;
+ double oi_alarm = 0;
+ busStability& operator=(const busStability& obj)
+ {
+ if(this == &obj)
+ return *this;
+ componentId = obj.componentId;
+ resistance = obj.resistance;
+ anchor_v = obj.anchor_v;
+ uv_alarm = obj.uv_alarm;
+ ov_alarm = obj.ov_alarm;
+ anchor_i = obj.anchor_i;
+ ui_alarm = obj.ui_alarm;
+ oi_alarm = obj.oi_alarm;
+ return *this;
+ }
+};
+
+class DataBase
+{
+ //Q_OBJECT
+public:
+ DataBase();
+ ~DataBase();
+ static DataBase* GetInstance();
+public:
+ availableID structID;
+public:
+ void updateId();
+ bool insertPage(QString tag,QString name,int status,QJsonObject label,QJsonObject context,QString description,int op);
+ bool insertStation(int zoneId,QString name,QString description,bool isLocal,int op);
+ bool insertGrid(QString name,QString description,int op);
+ bool insertZone(int grid_id,QString name,QString description,int op);
+ bool insertTopologic(int page_id,QUuid uuid_from,QUuid uuid_to,int flag,QString description,int op);
+
+ bool insertBus_stability(int componentId,double resistance,bool anchor_v,double uv_alarm,double ov_alarm,bool anchor_i,double ui_alarm,double oi_alarm,int op);
+ bool updateBus_stability(int componentId,double resistance,bool anchor_v,double uv_alarm,double ov_alarm,bool anchor_i,double ui_alarm,double oi_alarm,int op);
+ busStability getBusStabilityById(int componentId);
+ /*********************************************************************************/
+ bool updateComponent(QUuid uuid,QString tag,QString name,QJsonObject context);
+ bool insertComponent(QUuid uuid,QString nspath,QString tag,QString name,QString description,QString grid,QString zone,QString station,int type,bool inService,int state,QJsonObject connected_bus,QJsonObject label,QJsonObject context,int page_id,int op);
+ componentInfo getComponentInfoByUuid(QString uuid);
+ QList getAllComponents();
+ bool componentExist(QString uuid);
+ bool deleteComponent(QString uuid);
+
+ /*********************************************************************************/
+ int getPageIdByName(QString name);
+ bool updatePage(QString tag,QString name,QJsonObject context);
+ QJsonObject getPageContextByName(QString name);
+ QStringList getAllPage();
+ /*********************************************************************************/
+ bool deleteComponentById(int id);
+ void select();
+ void parallelUpdate();
+
+ QJsonObject QstringToJson(QString jsonString);
+private:
+ void initial();
+ void readXML();
+ static DataBase* instance;
+ static int _id;
+ QSqlDatabase db;
+ QString m_sFileName;
+ QString _DataBaseType;
+ QString _DataBaseName;
+ QString _HostName;
+ int _Port;
+ QString _UserName;
+ QString _PassWord;
+};
+#endif // DATABASE_H
diff --git a/common/include/export.hpp b/common/include/export.hpp
new file mode 100644
index 0000000..16b138a
--- /dev/null
+++ b/common/include/export.hpp
@@ -0,0 +1,48 @@
+#pragma once
+
+#include "compiler.hpp"
+#include "operatingSystem.hpp"
+
+#ifdef DIAGRAM_DESIGNER_PLATFORM_WINDOWS
+#define DIAGRAM_DESIGNER_EXPORT __declspec(dllexport)
+#define DIAGRAM_DESIGNER_IMPORT __declspec(dllimport)
+#define DIAGRAM_DESIGNER_LOCAL
+#elif DIAGRAM_DESIGNER_COMPILER_GNU_VERSION_MAJOR >= 4 || defined(DIAGRAM_DESIGNER_COMPILER_CLANG)
+#define DIAGRAM_DESIGNER_EXPORT __attribute__((visibility("default")))
+#define DIAGRAM_DESIGNER_IMPORT __attribute__((visibility("default")))
+#define DIAGRAM_DESIGNER_LOCAL __attribute__((visibility("hidden")))
+#else
+#define DIAGRAM_DESIGNER_EXPORT
+#define DIAGRAM_DESIGNER_IMPORT
+#define DIAGRAM_DESIGNER_LOCAL
+#endif
+
+#ifdef __cplusplus
+#define DIAGRAM_DESIGNER_DEMANGLED extern "C"
+#else
+#define DIAGRAM_DESIGNER_DEMANGLED
+#endif
+
+#if defined(DIAGRAM_DESIGNER_SHARED) && !defined(DIAGRAM_DESIGNER_STATIC)
+#ifdef DIAGRAM_DESIGNER_EXPORTS
+#define DIAGRAM_DESIGNER_PUBLIC DIAGRAM_DESIGNER_EXPORT
+#else
+#define DIAGRAM_DESIGNER_PUBLIC DIAGRAM_DESIGNER_IMPORT
+#endif
+#define DIAGRAM_DESIGNER_PRIVATE DIAGRAM_DESIGNER_LOCAL
+#elif !defined(DIAGRAM_DESIGNER_SHARED) && defined(DIAGRAM_DESIGNER_STATIC)
+#define DIAGRAM_DESIGNER_PUBLIC
+#define DIAGRAM_DESIGNER_PRIVATE
+#elif defined(DIAGRAM_DESIGNER_SHARED) && defined(DIAGRAM_DESIGNER_STATIC)
+#ifdef DIAGRAM_DESIGNER_EXPORTS
+#error "Cannot build as shared and static simultaneously."
+#else
+#error "Cannot link against shared and static simultaneously."
+#endif
+#else
+#ifdef DIAGRAM_DESIGNER_EXPORTS
+#error "Choose whether to build as shared or static."
+#else
+#error "Choose whether to link against shared or static."
+#endif
+#endif
diff --git a/include/global.h b/common/include/global.h
similarity index 98%
rename from include/global.h
rename to common/include/global.h
index ac89082..cbdf013 100644
--- a/include/global.h
+++ b/common/include/global.h
@@ -24,6 +24,12 @@ enum GraphicsItemType
GIT_itemTri = QGraphicsItem::UserType + 52,
GIT_link= QGraphicsItem::UserType + 53
};
+
+enum DiagramMode //组态图模式
+{
+ DM_edit = 0,
+ DM_run
+};
//Q_ENUM_NS(GraphicsItemType)
/**
diff --git a/common/include/httpInterface.h b/common/include/httpInterface.h
new file mode 100644
index 0000000..86f79c1
--- /dev/null
+++ b/common/include/httpInterface.h
@@ -0,0 +1,33 @@
+#ifndef HTTPINTERFACE_H
+#define HTTPINTERFACE_H
+
+#include
+#include
+
+class QNetworkAccessManager;
+class QNetworkReply;
+
+class HttpInterface:public QObject
+{
+ Q_OBJECT
+public:
+ HttpInterface(QObject* parent = nullptr);
+ ~HttpInterface();
+ //static HttpInterface* GetInstance();
+
+ void getPointData(QString type,QString station = QString("0"),QString component = QString("0"),QString begin = "",QString end = "");
+signals:
+ void sendPointData(QString type,QMap map);
+public slots:
+ void replyFinished(QNetworkReply *reply);
+private:
+ void initial();
+ void readXML();
+ static HttpInterface* instance;
+ QString m_sFileName;
+ QString _Host;
+ QString _Port;
+ QString _Interface;
+ QNetworkAccessManager* _manager;
+};
+#endif // DATABASE_H
diff --git a/common/include/operatingSystem.hpp b/common/include/operatingSystem.hpp
new file mode 100644
index 0000000..a653fee
--- /dev/null
+++ b/common/include/operatingSystem.hpp
@@ -0,0 +1,49 @@
+#pragma once
+
+#if defined(__CYGWIN__) || defined(__CYGWIN32__)
+#define DIAGRAM_DESIGNER_PLATFORM "Cygwin"
+#define DIAGRAM_DESIGNER_PLATFORM_CYGWIN
+#define DIAGRAM_DESIGNER_PLATFORM_UNIX
+#define DIAGRAM_DESIGNER_PLATFORM_WINDOWS
+#elif defined(_WIN16) || defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) \
+ || defined(__TOS_WIN__) || defined(__WINDOWS__)
+#define DIAGRAM_DESIGNER_PLATFORM "Windows"
+#define DIAGRAM_DESIGNER_PLATFORM_WINDOWS
+#elif defined(macintosh) || defined(Macintosh) || defined(__TOS_MACOS__) \
+ || (defined(__APPLE__) && defined(__MACH__))
+#define DIAGRAM_DESIGNER_PLATFORM "Mac"
+#define DIAGRAM_DESIGNER_PLATFORM_MAC
+#define DIAGRAM_DESIGNER_PLATFORM_UNIX
+#elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__TOS_LINUX__)
+#define DIAGRAM_DESIGNER_PLATFORM "Linux"
+#define DIAGRAM_DESIGNER_PLATFORM_LINUX
+#define DIAGRAM_DESIGNER_PLATFORM_UNIX
+#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__bsdi__) \
+ || defined(__DragonFly__)
+#define DIAGRAM_DESIGNER_PLATFORM "BSD"
+#define DIAGRAM_DESIGNER_PLATFORM_BSD
+#define DIAGRAM_DESIGNER_PLATFORM_UNIX
+#elif defined(sun) || defined(__sun)
+#define DIAGRAM_DESIGNER_PLATFORM "Solaris"
+#define DIAGRAM_DESIGNER_PLATFORM_SOLARIS
+#define DIAGRAM_DESIGNER_PLATFORM_UNIX
+#elif defined(_AIX) || defined(__TOS_AIX__)
+#define DIAGRAM_DESIGNER_PLATFORM "AIX"
+#define DIAGRAM_DESIGNER_PLATFORM_AIX
+#define DIAGRAM_DESIGNER_PLATFORM_UNIX
+#elif defined(hpux) || defined(_hpux) || defined(__hpux)
+#define DIAGRAM_DESIGNER_PLATFORM "HPUX"
+#define DIAGRAM_DESIGNER_PLATFORM_HPUX
+#define DIAGRAM_DESIGNER_PLATFORM_UNIX
+#elif defined(__QNX__)
+#define DIAGRAM_DESIGNER_PLATFORM "QNX"
+#define DIAGRAM_DESIGNER_PLATFORM_QNX
+#define DIAGRAM_DESIGNER_PLATFORM_UNIX
+#elif defined(unix) || defined(__unix) || defined(__unix__)
+#define DIAGRAM_DESIGNER_PLATFORM "Unix"
+#define DIAGRAM_DESIGNER_PLATFORM_UNIX
+#endif
+
+#ifndef DIAGRAM_DESIGNER_PLATFORM
+#error "Current platform is not supported."
+#endif
diff --git a/common/source/dataBase.cpp b/common/source/dataBase.cpp
new file mode 100644
index 0000000..3cc584b
--- /dev/null
+++ b/common/source/dataBase.cpp
@@ -0,0 +1,849 @@
+#include "dataBase.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+DataBase* DataBase::instance = nullptr;
+int DataBase::_id = 0;
+
+DataBase::DataBase()
+{
+ m_sFileName = QString("setting.xml");
+ initial();
+ //insertComponent(QUuid::createUuid(),QString("111"),QString("111"),QString("111"),QString("111"),QString("111"),QString("111"),QString("111"),1,true,1,QJsonObject(),QJsonObject(),QJsonObject(),1,1);
+ //insertPage(QString("111"),QString("111"),4,QJsonObject(),QJsonObject(),QString("111"),1);
+ //insertStation(1,QString("111"),QString("111"),true,1);
+ //insertGrid(QString("111"),QString("111"),1);
+ //insertZone(1,QString("111"),QString("111"),1);
+ //insertTopologic(1,QUuid::createUuid(),QUuid::createUuid(),1,QString("111"),1);
+ //updateId();
+ //deleteComponentById(1);
+}
+
+DataBase::~DataBase()
+{
+ QString connectionName = QSqlDatabase::database().connectionName();
+ QSqlDatabase::removeDatabase(connectionName);
+}
+
+void DataBase::initial()
+{
+ readXML();
+ if (QSqlDatabase::contains("qt_sql_default_connection"))
+ db = QSqlDatabase::database("qt_sql_default_connection");
+ else
+ db = QSqlDatabase::addDatabase(_DataBaseType);
+ //db = QSqlDatabase::addDatabase(_DataBaseType);
+ db.setDatabaseName(_DataBaseName);
+ db.setHostName(_HostName);
+ db.setPort(_Port);
+ // 需要改成自己的用户名和密码
+ db.setUserName(_UserName);
+ db.setPassword(_PassWord);
+
+ if (db.open()) {
+ qDebug()<<"success";
+ } else {
+ qDebug()<<"failed";
+ }
+}
+
+void DataBase::updateId()
+{
+ if(db.open())
+ {
+ QSqlQuery qry(db);
+ bool success = qry.exec("SELECT id FROM component");
+ if (!success) {
+ qDebug()< id ? structID.componentId:id;
+ }
+ }
+ qry.finish();
+
+ success = qry.exec("SELECT id FROM station");
+ if (!success) {
+ qDebug()< id ? structID.stationId:id;
+ }
+ }
+ qry.finish();
+
+ success = qry.exec("SELECT id FROM page");
+ if (!success) {
+ qDebug()< id ? structID.pageId:id;
+ }
+ }
+ qry.finish();
+
+ success = qry.exec("SELECT id FROM grid");
+ if (!success) {
+ qDebug()< id ? structID.gridId:id;
+ }
+ }
+ qry.finish();
+
+ success = qry.exec("SELECT id FROM zone");
+ if (!success) {
+ qDebug()< id ? structID.zoneId:id;
+ }
+ }
+ qry.finish();
+
+ success = qry.exec("SELECT id FROM topologic");
+ if (!success) {
+ qDebug()< id ? structID.topoId:id;
+ }
+ }
+ qry.clear();
+ }
+}
+
+bool DataBase::insertComponent(QUuid uuid,QString nspath,QString tag,QString name,QString description,QString grid,QString zone,QString station,int type,bool inService,int state,QJsonObject connected_bus,QJsonObject label,QJsonObject context,int page_id,int op)
+{
+ if(db.open())
+ {
+ QSqlQuery qry(db);
+
+ /*QJsonDocument busDoc(connected_bus);
+ QString strBus = busDoc.toJson(QJsonDocument::Compact);
+
+ QJsonDocument labelDoc(label);
+ QString strLabel = labelDoc.toJson(QJsonDocument::Compact);*/
+
+ QJsonDocument contextDoc(context);
+ QString strCon = contextDoc.toJson(QJsonDocument::Compact);
+
+ /*qry.prepare("INSERT INTO component(global_uuid, nspath, tag, name, description, grid, zone, station, type, in_service, state, connected_bus, label, context, page_id, op, ts) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ qry.bindValue(0,uuid);
+ qry.bindValue(1,nspath);
+ qry.bindValue(2,tag);
+ qry.bindValue(3,name);
+ qry.bindValue(4,description);
+ qry.bindValue(5,grid);
+ qry.bindValue(6,zone);
+ qry.bindValue(7,station);
+ qry.bindValue(8,type);
+ qry.bindValue(9,inService);
+ qry.bindValue(10,state);
+ qry.bindValue(11,strBus);
+ qry.bindValue(12,strLabel);
+ qry.bindValue(13,strCon);
+ qry.bindValue(14,page_id);
+ qry.bindValue(15,op);
+ qry.bindValue(16,QDateTime::currentDateTime());*/
+ qry.prepare("INSERT INTO component(global_uuid, tag, name, grid, zone, station, type, context, page_id, op, ts) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ qry.bindValue(0,uuid);
+ qry.bindValue(1,tag);
+ qry.bindValue(2,name);
+ qry.bindValue(3,grid);
+ qry.bindValue(4,zone);
+ qry.bindValue(5,station);
+ qry.bindValue(6,type);
+ qry.bindValue(7,strCon);
+ qry.bindValue(8,page_id);
+ qry.bindValue(9,op);
+ qry.bindValue(10,QDateTime::currentDateTime());
+ bool res = qry.exec();
+ QString str = qry.lastQuery();
+ const QVariantList list = qry.boundValues();
+ for (qsizetype i = 0; i < list.size(); ++i)
+ qDebug() << i << ":" << list.at(i).toString();
+ if(!res)
+ {
+ qDebug()< DataBase::getAllComponents()
+{
+ QList lst;
+ if(db.open())
+ {
+ QSqlQuery qry(db);
+
+ qry.prepare("SELECT id, global_uuid, tag, name, grid, zone, station, type, context, page_id, op FROM component");
+ bool res = qry.exec();
+ QString str = qry.lastQuery();
+ if(!res)
+ {
+ qDebug()< 0)
+ return true;
+ else
+ return false;
+ qry.clear();
+ }
+ }
+ return false;
+}
+
+bool DataBase::deleteComponent(QString uuid)
+{
+ if(db.open())
+ {
+ QSqlQuery qry(db);
+
+ qry.prepare("DELETE FROM component WHERE global_uuid = ?");
+ qry.bindValue(0,uuid);
+ bool res = qry.exec();
+ QString str = qry.lastQuery();
+ if(!res)
+ {
+ qDebug()<open(QIODevice::ReadOnly | QFile::Text))
+ {
+ QMessageBox::information(NULL, QString("title"), QString::fromWCharArray(L"配置文件打开错误"));
+ return;
+ }
+
+ QXmlStreamReader* m_pReader = new QXmlStreamReader(pFile);
+ while (!m_pReader->atEnd() && !m_pReader->hasError())
+ {
+ m_pReader->lineNumber();
+ QXmlStreamReader::TokenType token = m_pReader->readNext();
+ if (token == QXmlStreamReader::StartDocument)
+ continue;
+
+ //qDebug() << m_pReader->name();
+ if (m_pReader->isStartElement())
+ {
+ if(m_pReader->name() == QString("DataBase"))
+ {
+ QXmlStreamAttributes attributes = m_pReader->attributes();
+ QString tpe = attributes.value("Type").toString();
+ QString sName = attributes.value("Name").toString();
+ if (tpe == QString("PostgreSQL"))
+ {
+ _DataBaseType = QString("QPSQL");
+ _DataBaseName = sName;
+ }
+ }
+ else if(m_pReader->name() == QString("HostName"))
+ {
+ _HostName = m_pReader->readElementText();
+ }
+ else if(m_pReader->name() == QString("Port"))
+ {
+ _Port = m_pReader->readElementText().toInt();
+ }
+ else if(m_pReader->name() == QString("UserName"))
+ {
+ _UserName = m_pReader->readElementText();
+ }
+ else if(m_pReader->name() == QString("Password"))
+ {
+ _PassWord = m_pReader->readElementText();
+ }
+ }
+ m_pReader->readNext();
+ }
+ if (m_pReader->hasError())
+ {
+ qDebug() << m_pReader->errorString();
+ }
+ m_pReader->clear();
+ delete m_pReader;
+ m_pReader = NULL;
+ pFile->close();
+ delete pFile;
+ pFile = NULL;
+}
+
+DataBase* DataBase::GetInstance()
+{
+ if(instance == nullptr)
+ {
+ instance = new DataBase();
+ }
+ return instance;
+}
+
+QJsonObject DataBase::QstringToJson(QString jsonString)
+{
+ QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonString.toUtf8().data());
+ if(jsonDocument.isNull())
+ {
+ qDebug()<< "String NULL"<< jsonString.toLocal8Bit().data();
+ }
+ QJsonObject jsonObject = jsonDocument.object();
+ return jsonObject;
+}
diff --git a/common/source/httpInterface.cpp b/common/source/httpInterface.cpp
new file mode 100644
index 0000000..4431982
--- /dev/null
+++ b/common/source/httpInterface.cpp
@@ -0,0 +1,150 @@
+#include "httpInterface.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+//HttpInterface* HttpInterface::instance = nullptr;
+
+HttpInterface::HttpInterface(QObject* parent)
+ :QObject(parent)
+{
+ m_sFileName = QString("setting.xml");
+ _manager = new QNetworkAccessManager(this);
+ initial();
+}
+
+HttpInterface::~HttpInterface()
+{
+ if(_manager)
+ _manager->deleteLater();
+}
+
+void HttpInterface::initial()
+{
+ readXML();
+ connect(_manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(replyFinished(QNetworkReply*)));
+}
+
+void HttpInterface::readXML()
+{
+ if (m_sFileName.isEmpty())
+ return;
+
+ QFile *pFile = new QFile(m_sFileName);
+ if (!pFile->open(QIODevice::ReadOnly | QFile::Text))
+ {
+ QMessageBox::information(NULL, QString("title"), QString::fromWCharArray(L"配置文件打开错误"));
+ return;
+ }
+
+ QXmlStreamReader* m_pReader = new QXmlStreamReader(pFile);
+ while (!m_pReader->atEnd() && !m_pReader->hasError())
+ {
+ m_pReader->lineNumber();
+ QXmlStreamReader::TokenType token = m_pReader->readNext();
+ if (token == QXmlStreamReader::StartDocument)
+ continue;
+
+ //qDebug() << m_pReader->name();
+ if (m_pReader->isStartElement())
+ {
+ if(m_pReader->name() == QString("HttpInterface"))
+ {
+ QXmlStreamAttributes attributes = m_pReader->attributes();
+ _Host = attributes.value("Ip").toString();
+ _Port = attributes.value("Port").toString();
+ }
+ else if(m_pReader->name() == QString("GetPointData"))
+ {
+ _Interface = m_pReader->readElementText();
+ }
+ }
+ m_pReader->readNext();
+ }
+ if (m_pReader->hasError())
+ {
+ qDebug() << m_pReader->errorString();
+ }
+ m_pReader->clear();
+ delete m_pReader;
+ m_pReader = NULL;
+ pFile->close();
+ delete pFile;
+ pFile = NULL;
+}
+
+/*HttpInterface* HttpInterface::GetInstance()
+{
+ if(instance == nullptr)
+ {
+ instance = new HttpInterface();
+ }
+ return instance;
+}*/
+
+void HttpInterface::getPointData(QString type,QString station,QString component,QString begin,QString end)
+{
+ QNetworkRequest request;
+ QString scheme = "http";
+ QString requestHeader = scheme + QString("://") + _Host + QString(":") + _Port + QString("/") + _Interface;
+ QString fullRequest;
+ if(begin.isEmpty() && end.isEmpty())
+ fullRequest = requestHeader + QString("?station=%1&component=%2&point=%3").arg(station,component,type);
+ else
+ fullRequest = requestHeader + QString("?station=%1&component=%2&point=%3&begin=%4&end=%5").arg(station,component,type,begin,end);
+ request.setUrl(QUrl(fullRequest));
+ _manager->get(request);
+}
+
+void HttpInterface::replyFinished(QNetworkReply *reply)
+{
+ QString allinfo = reply->readAll();
+
+ QJsonParseError err;
+ QJsonDocument json_recv = QJsonDocument::fromJson(allinfo.toUtf8(),&err);//解析json对象
+ if(!json_recv.isNull())
+ {
+ QJsonObject object = json_recv.object();
+ if(object.contains("data"))
+ {
+ /*QJsonObject dataObj = object["data"].toObject();
+ QString type = dataObj["point"].toString();
+
+ QJsonArray nodesJsonArray = dataObj["values"].toArray();
+
+ QMap map;
+ for (QJsonValueRef nodeJson : nodesJsonArray)
+ {
+ QJsonObject node = nodeJson.toObject();
+ QString time = node["time"].toString();
+ double value = node["value"].toDouble();
+ qint64 tval = time.toLongLong();
+ map.insert(tval,value);
+ }*/
+ QJsonArray nodesJsonArray = object["data"].toArray();
+
+ QMap map;
+ for (QJsonValueRef nodeJson : nodesJsonArray)
+ {
+ QJsonObject node = nodeJson.toObject();
+ QString time = node["time"].toString();
+ double value = node["value"].toDouble();
+ qint64 tval = time.toLongLong();
+ map.insert(tval,value);
+ }
+ emit sendPointData("v",map);
+ }
+
+ }else
+ {
+ qDebug()<<"json_recv is NULL or is not a object !!";
+ }
+ reply->deleteLater(); //销毁请求对象
+}
diff --git a/diagramCavas/CMakeLists.txt b/diagramCavas/CMakeLists.txt
new file mode 100644
index 0000000..f6210a8
--- /dev/null
+++ b/diagramCavas/CMakeLists.txt
@@ -0,0 +1,125 @@
+project(diagramCavas)
+
+set(DIAGRAMCAVAS_HEADER_FILES
+ include/baseScene.h
+ include/designerScene.h
+ include/designerView.h
+ include/diagramCavas.h
+ include/drawingPanel.h
+ include/itemPropertyDlg.h
+ include/serializable.h
+ include/statusBar.h
+ include/graphicsDataModel/baseModel.h
+ include/graphicsDataModel/fixedPortsModel.h
+ include/graphicsItem/electricConnectLineItem.h
+ include/graphicsItem/electricSvgItem.h
+ include/graphicsItem/electricSvgItemBus.h
+ include/graphicsItem/electricSvgItemRect.h
+ include/graphicsItem/electricSvgItemTriangle.h
+ include/graphicsItem/graphicsBaseItem.h
+ include/graphicsItem/graphicsItemGroup.h
+ include/graphicsItem/graphicsPolygonItem.h
+ include/graphicsItem/graphicsRectItem.h
+ include/graphicsItem/handleRect.h
+ include/graphicsItem/handleText.h
+ include/graphicsItem/itemControlHandle.h
+ include/graphicsItem/itemPort.h
+ include/util/baseSelector.h
+ include/util/connectingSelector.h
+ include/util/creatingSelector.h
+ include/util/editingSelector.h
+ include/util/linkMovingSelector.h
+ include/util/movingSelector.h
+ include/util/rotationSelector.h
+ include/util/scalingSelector.h
+ include/util/selectorManager.h
+ include/util/subMovingSelector.h
+ ../common/include/dataBase.h
+ ../common/include/httpInterface.h
+ ../common/include/global.h
+ ../common/include/compiler.hpp
+ ../common/include/export.hpp
+ ../common/include/operatingSystem.hpp
+)
+
+set(DIAGRAMCAVAS_SOURCE_FILES
+ source/baseScene.cpp
+ source/designerScene.cpp
+ source/designerView.cpp
+ source/diagramCavas.cpp
+ source/drawingPanel.cpp
+ source/itemPropertyDlg.cpp
+ source/statusBar.cpp
+ #source/serializable.cpp
+ source/graphicsDataModel/baseModel.cpp
+ source/graphicsDataModel/fixedPortsModel.cpp
+ source/graphicsItem/electricConnectLineItem.cpp
+ source/graphicsItem/electricSvgItem.cpp
+ source/graphicsItem/electricSvgItemBus.cpp
+ source/graphicsItem/electricSvgItemRect.cpp
+ source/graphicsItem/electricSvgItemTriangle.cpp
+ source/graphicsItem/graphicsBaseItem.cpp
+ source/graphicsItem/graphicsItemGroup.cpp
+ source/graphicsItem/graphicsPolygonItem.cpp
+ source/graphicsItem/graphicsRectItem.cpp
+ source/graphicsItem/handleRect.cpp
+ source/graphicsItem/handleText.cpp
+ source/graphicsItem/itemControlHandle.cpp
+ source/graphicsItem/itemPort.cpp
+ source/util/baseSelector.cpp
+ source/util/connectingSelector.cpp
+ source/util/creatingSelector.cpp
+ source/util/editingSelector.cpp
+ source/util/linkMovingSelector.cpp
+ source/util/movingSelector.cpp
+ source/util/rotationSelector.cpp
+ source/util/scalingSelector.cpp
+ source/util/selectorManager.cpp
+ source/util/subMovingSelector.cpp
+ ../common/source/dataBase.cpp
+ ../common/source/httpInterface.cpp
+)
+
+set(UI_FILES
+ ui/drawingPanel.ui
+ ui/itemPropertyDlg.ui
+)
+
+if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
+ qt_add_library(diagramCavas SHARED
+ MANUAL_FINALIZATION
+ ${DIAGRAMCAVAS_HEADER_FILES}
+ ${DIAGRAMCAVAS_SOURCE_FILES}
+ ${UI_FILES}
+ ../resource/DiagramDesigner.qrc
+ )
+else()
+ add_library(diagramCavas SHARED
+ ${DIAGRAMCAVAS_HEADER_FILES}
+ ${DIAGRAMCAVAS_SOURCE_FILES}
+ ${UI_FILES}
+ ../resource/DiagramDesigner.qrc
+ )
+endif()
+
+target_link_libraries(diagramCavas PUBLIC Qt${QT_VERSION_MAJOR}::Core
+ Qt${QT_VERSION_MAJOR}::Gui
+ Qt${QT_VERSION_MAJOR}::Widgets)
+target_link_libraries(diagramCavas PRIVATE Qt6::SvgWidgets)
+target_link_libraries(diagramCavas PRIVATE Qt6::Xml)
+target_link_libraries(diagramCavas PRIVATE Qt6::Network)
+target_link_libraries(diagramCavas PRIVATE Qt6::Sql ${POSTGRESQL_LIBRARIES})
+
+option(BUILD_SHARED_LIBS "Build as shared library" ON)
+
+
+
+target_include_directories(diagramCavas PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+target_compile_definitions(diagramCavas
+ PUBLIC
+ DIAGRAM_DESIGNER_SHARED
+ PRIVATE
+ DIAGRAM_DESIGNER_EXPORTS
+ #QT_NO_KEYWORDS
+)
diff --git a/diagramCavas/include/baseScene.h b/diagramCavas/include/baseScene.h
new file mode 100644
index 0000000..f2a23e2
--- /dev/null
+++ b/diagramCavas/include/baseScene.h
@@ -0,0 +1,42 @@
+#pragma once
+
+#include
+#include
+#include
+
+#include "graphicsDataModel/baseModel.h"
+#include "global.h"
+
+class QUndoStack;
+
+class BaseModel;
+
+/// An instance of QGraphicsScene, holds connections and nodes.
+class BaseScene : public QGraphicsScene
+{
+ Q_OBJECT
+public:
+ BaseScene(BaseModel* graphModel, QObject *parent = nullptr);
+
+ // Scenes without models are not supported
+ BaseScene() = delete;
+
+ ~BaseScene();
+
+public:
+ /// @returns associated BaseModel.
+ BaseModel const *graphModel() const;
+
+ BaseModel *graphModel();
+
+ QUndoStack &undoStack();
+
+
+private:
+ BaseModel* _graphModel;
+
+
+ QUndoStack *_undoStack;
+
+};
+
diff --git a/include/designerScene.h b/diagramCavas/include/designerScene.h
similarity index 70%
rename from include/designerScene.h
rename to diagramCavas/include/designerScene.h
index 29a700d..45bf681 100644
--- a/include/designerScene.h
+++ b/diagramCavas/include/designerScene.h
@@ -2,19 +2,19 @@
#define DESIGNER_SCENE_H
#include
-#include "basicGraphicsScene.h"
-#include "dataFlowGraphModel.h"
+#include "baseScene.h"
+#include "graphicsDataModel/fixedPortsModel.h"
class GraphicsItemGroup;
class DrawingPanel;
-class DesignerScene : public BasicGraphicsScene
+class DesignerScene : public BaseScene
{
Q_OBJECT
public:
- DesignerScene(DataFlowGraphModel &graphModel,QObject *parent = 0);
+ DesignerScene(FixedPortsModel* graphModel,QObject *parent = 0);
virtual ~DesignerScene();
void setGridVisible(bool);
@@ -27,7 +27,8 @@ public:
signals:
void signalAddItem(QGraphicsItem*);
-
+public slots:
+ void onDeleteClicked();
protected:
void drawBackground(QPainter*, const QRectF&) override;
void mousePressEvent(QGraphicsSceneMouseEvent*) override;
@@ -36,28 +37,14 @@ protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) override;
void keyPressEvent(QKeyEvent*) override;
void keyReleaseEvent(QKeyEvent*) override;
-
+ void contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent) override;
private:
bool m_bGridVisible;
QGraphicsView* m_pView;
DrawingPanel* m_pDrawingPanel; //保存父指针
-public:
- std::vector selectedNodes() const;
-
-public:
- QMenu *createSceneMenu(QPointF const scenePos) override;
-
-public Q_SLOTS:
- bool save() const;
-
- bool load();
-
-Q_SIGNALS:
- void sceneLoaded();
-
private:
- DataFlowGraphModel &_graphModel;
+ FixedPortsModel* _graphModel;
};
#endif
diff --git a/include/designerView.h b/diagramCavas/include/designerView.h
similarity index 93%
rename from include/designerView.h
rename to diagramCavas/include/designerView.h
index 27d359d..8adcbb9 100644
--- a/include/designerView.h
+++ b/diagramCavas/include/designerView.h
@@ -17,12 +17,11 @@ public:
void zoomFit();
protected:
- virtual void contextMenuEvent(QContextMenuEvent*) override;
+ //virtual void contextMenuEvent(QContextMenuEvent*) override;
virtual void mousePressEvent(QMouseEvent*) override;
virtual void mouseMoveEvent(QMouseEvent*) override;
virtual void mouseReleaseEvent(QMouseEvent*) override;
virtual void wheelEvent(QWheelEvent*) override;
-
private:
void initialize();
//视图操作相关
diff --git a/diagramCavas/include/diagramCavas.h b/diagramCavas/include/diagramCavas.h
new file mode 100644
index 0000000..a623993
--- /dev/null
+++ b/diagramCavas/include/diagramCavas.h
@@ -0,0 +1,42 @@
+#ifndef DIAGRAMCAVAS_H
+#define DIAGRAMCAVAS_H
+
+#include
+#include "global.h"
+#include "export.hpp"
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class diagramCavas; }
+QT_END_NAMESPACE
+
+class DrawingPanel;
+
+class DIAGRAM_DESIGNER_PUBLIC DiagramCavas : public QMdiArea
+{
+ Q_OBJECT
+
+public:
+ DiagramCavas(QWidget *parent = nullptr);
+ ~DiagramCavas();
+
+public:
+ void initial();
+public slots:
+ void onSignal_addDrawingPanel(const QString& sTitile,DiagramMode = DM_edit);
+ void onSignal_addGraphicsItem(GraphicsItemType&);
+ void onSignal_addPage();
+ void onSignal_savePage();
+ void onSignal_loadPage(const QString&);
+ void runPage(const QString); //运行时
+ void onSignal_runPage();
+ void onSignal_deletePage();
+
+ void onSignal_activatePage(const QString& name);
+ void onSignal_panelDelete(const QString& name);
+private:
+ QMap m_mapDrawPanel;
+ int _pageIndex;
+ QString _curPage;
+};
+
+#endif
diff --git a/include/drawingPanel.h b/diagramCavas/include/drawingPanel.h
similarity index 57%
rename from include/drawingPanel.h
rename to diagramCavas/include/drawingPanel.h
index 9ced31c..7e94234 100644
--- a/include/drawingPanel.h
+++ b/diagramCavas/include/drawingPanel.h
@@ -20,7 +20,7 @@ class DrawingPanel : public QWidget
Q_OBJECT
public:
- DrawingPanel(QWidget *parent = nullptr);
+ DrawingPanel(QWidget *parent = nullptr,DiagramMode mode = DM_edit);
~DrawingPanel();
QGraphicsScene* getQGraphicsScene();
@@ -35,16 +35,30 @@ public:
SelectorManager* selectorManager() const; //返回manager指针
+ void setPageName(QString s){_name = s;_pModel->setPageName(_name);} //设置当前page名称
+ QString pageName(){return _name;}
+
+ FixedPortsModel* getModel() const {return _pModel;}
+ DiagramMode getMode(){return _mode;}
+
+ QJsonObject getDiagramInfo() const; //返回图元位置信息
+ void loadNodes(QJsonObject obj); //加载图元信息
+ void saveNodes(int pageId); //保存到数据库
+signals:
+ void panelDelete(const QString&);
+protected:
+ void closeEvent(QCloseEvent *closeEvent);
public slots:
void onSignal_addGraphicsItem(GraphicsItemType&);
-private:
- QSharedPointer registerDataModels();
private:
Ui::drawingPanel *ui;
DesignerView* m_pGraphicsView;
DesignerScene* m_pGraphicsScene;
SelectorManager* m_pSelectorManager;
StatusBar* m_pStatusBar;
+ FixedPortsModel* _pModel;
+ DiagramMode _mode;
+ QString _name;
};
#endif
diff --git a/diagramCavas/include/graphicsDataModel/baseModel.h b/diagramCavas/include/graphicsDataModel/baseModel.h
new file mode 100644
index 0000000..562bc39
--- /dev/null
+++ b/diagramCavas/include/graphicsDataModel/baseModel.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+#include "global.h"
+
+
+/**
+ * The central class in the Model-View approach. It delivers all kinds
+ * of information from the backing user data structures that represent
+ * the graph. The class allows to modify the graph structure: create
+ * and remove nodes and connections.
+ *
+ * We use two types of the unique ids for graph manipulations:
+ * - NodeId
+ * - ConnectionId
+ */
+class BaseModel : public QObject
+{
+ Q_OBJECT
+ /// @brief Returns node-related data for requested NodeRole.
+ /**
+ * @returns Node Caption, Node Caption Visibility, Node Position etc.
+ */
+ virtual QVariant nodeData(QUuid nodeId, NodeRole role) const = 0;
+
+ /**
+ * A utility function that unwraps the `QVariant` value returned from the
+ * standard `QVariant AbstractGraphModel::nodeData(NodeId, NodeRole)` function.
+ */
+ template
+ T nodeData(QUuid nodeId, NodeRole role) const
+ {
+ return nodeData(nodeId, role).value();
+ }
+
+ virtual NodeFlags nodeFlags(NodeId nodeId) const
+ {
+ Q_UNUSED(nodeId);
+ return NodeFlag::NoFlags;
+ }
+};
+
diff --git a/diagramCavas/include/graphicsDataModel/fixedPortsModel.h b/diagramCavas/include/graphicsDataModel/fixedPortsModel.h
new file mode 100644
index 0000000..0014c4d
--- /dev/null
+++ b/diagramCavas/include/graphicsDataModel/fixedPortsModel.h
@@ -0,0 +1,65 @@
+#pragma once
+
+#include "graphicsDataModel/baseModel.h"
+#include "serializable.h"
+
+#include
+#include
+#include
+
+class DrawingPanel;
+class GraphicsBaseItem;
+class BaseProperty;
+class DesignerScene;
+class HttpInterface;
+struct Connection;
+
+class FixedPortsModel : public BaseModel, public Serializable
+{
+ Q_OBJECT
+
+public:
+ FixedPortsModel();
+ ~FixedPortsModel();
+public:
+ QMap allNodePos() const;
+ QVector allConnections();
+ QMap& allItems();
+ bool addNodeItem(QUuid uuid,GraphicsBaseItem*);
+ void addNodeItem(QUuid id,/*int type,*/QPointF pos);
+ QVariant nodeData(QUuid nodeId, NodeRole role) const;
+ BaseProperty* addNodeData(QUuid id,int type,QString name); //对应component数据,一个data可对应多个item
+ void loadNodeDataFromDataBase(); //从数据库加载数据
+ void addConnectLline(QUuid srcId,QUuid destId,int srcPort,int destPort);
+ void deleteNodeItem(GraphicsBaseItem*);
+ QJsonObject saveNode(QUuid const) const;
+ void saveNode(int nPageId);
+ void setScene(DesignerScene* p){_scene = p;}
+ void setTopWidget(DrawingPanel* p) {_widget = p;}
+ QWidget* getTopWidget();
+Q_SIGNALS:
+ void activatePage(const QString&); //激活当前model所在page
+public:
+ void setPageName(QString s) {_pageName = s;} //设置表名称
+ QString pageName() const {return _pageName;}
+ void activateModel() {Q_EMIT activatePage(_pageName);} //发送激活信号(点击)
+ void startHttpRequest(); //开始请求数据(运行时)
+public Q_SLOTS:
+ void onSignal_ifExits(QUuid id,const QString&,int type,GraphicsBaseItem*); //判断用户输入的名称是否已存在
+ void onTimeOut();
+ void onSignal_GetPointData(QString type,QMap map);
+
+private:
+
+ QMap _nodeItem;
+
+ QString _pageName;
+ DesignerScene* _scene;
+ DrawingPanel* _widget; //顶层widget
+ HttpInterface* _Interface;
+ QTimer* _timer;
+public:
+ static bool _dataInitialised;
+ static QMap _nodeData; //一个data可对应多个item
+};
+
diff --git a/include/graphicsItem/electricConnectLineItem.h b/diagramCavas/include/graphicsItem/electricConnectLineItem.h
similarity index 72%
rename from include/graphicsItem/electricConnectLineItem.h
rename to diagramCavas/include/graphicsItem/electricConnectLineItem.h
index 0a1ff42..10393e9 100644
--- a/include/graphicsItem/electricConnectLineItem.h
+++ b/diagramCavas/include/graphicsItem/electricConnectLineItem.h
@@ -2,15 +2,16 @@
#define ELECTRICCONNECTLINEITEM_H
#include
+#include
#include "graphicsBaseItem.h"
struct Connection
{
- int nSrcNodeId;
+ QUuid nSrcNodeId;
int nSrcPort;
HandleType srcType;
PortPos srcPos;
- int nDestNodeId;
+ QUuid nDestNodeId;
int nDestPort;
HandleType destType;
PortPos destPos;
@@ -18,17 +19,29 @@ struct Connection
Connection()
{
- nSrcNodeId = -1;
+ //nSrcNodeId = -1;
nSrcPort = -1;
srcType = T_none;
srcPos = P_top;
- nDestNodeId = -1;
+ //nDestNodeId = -1;
nDestPort = -1;
destType = T_none;
destPos = P_top;
}
- Connection(int nSNI,int nSP,HandleType sT,PortPos sPOS,int nDNI,int nDP,HandleType dT,PortPos dPOS)
+ Connection(const Connection& obj)
+ {
+ nSrcNodeId = obj.nSrcNodeId;
+ nSrcPort = obj.nSrcPort;
+ srcType = obj.srcType;
+ srcPos = obj.srcPos;
+ nDestNodeId = obj.nDestNodeId;
+ nDestPort = obj.nDestPort;
+ destType = obj.destType;
+ destPos = obj.destPos;
+ }
+
+ Connection(QUuid nSNI,int nSP,HandleType sT,PortPos sPOS,QUuid nDNI,int nDP,HandleType dT,PortPos dPOS)
{
nSrcNodeId = nSNI;
nSrcPort = nSP;
@@ -39,12 +52,12 @@ struct Connection
destType = dT;
destPos = dPOS;
}
- bool operator==(Connection& obj)
+ bool operator==(const Connection& obj)
{
return ((obj.nSrcNodeId == nSrcNodeId)&&(obj.nSrcPort == nSrcPort)&&(obj.srcType == srcType)&&(obj.nDestNodeId == nDestNodeId)&&(obj.nDestPort == nDestPort)&&(obj.destType == destType));
}
- Connection& operator=(Connection& obj)
+ Connection& operator=(const Connection& obj)
{
if(*this == obj)
return *this;
@@ -75,8 +88,10 @@ public:
bool addConnection();
void resetCurLine(){_curLine = QPoint();}
- void updateConnection(int callerId,QPointF pos); //外部调用的更新函数,id为调用者id
+ void updateConnection(QUuid callerId,QPointF pos); //外部调用的更新函数,id为调用者id
void setConnection(Connection con){m_connectState = con;}
+ Connection getConnection() const {return m_connectState;}
+ QUuid getOppositeId(QUuid); //获取另一端点id
protected:
virtual QPainterPath shape() const override;
virtual QRectF boundingRect() const override;
diff --git a/include/graphicsItem/electricSvgItem.h b/diagramCavas/include/graphicsItem/electricSvgItem.h
similarity index 100%
rename from include/graphicsItem/electricSvgItem.h
rename to diagramCavas/include/graphicsItem/electricSvgItem.h
diff --git a/include/graphicsItem/electricSvgItemBus.h b/diagramCavas/include/graphicsItem/electricSvgItemBus.h
similarity index 66%
rename from include/graphicsItem/electricSvgItemBus.h
rename to diagramCavas/include/graphicsItem/electricSvgItemBus.h
index 8052f77..0f6400a 100644
--- a/include/graphicsItem/electricSvgItemBus.h
+++ b/diagramCavas/include/graphicsItem/electricSvgItemBus.h
@@ -11,10 +11,19 @@ public:
virtual ~ElectricSvgItemBus();
void addPort();
+public:
+ virtual void updateConnectData();
protected:
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
private:
virtual void updateHandles();
};
+class ElectricSvgItemBus_Property: public BaseProperty
+{
+ Q_OBJECT
+public:
+ ElectricSvgItemBus_Property(QObject* parent);
+ ~ElectricSvgItemBus_Property();
+};
#endif
diff --git a/diagramCavas/include/graphicsItem/electricSvgItemRect.h b/diagramCavas/include/graphicsItem/electricSvgItemRect.h
new file mode 100644
index 0000000..1444ca6
--- /dev/null
+++ b/diagramCavas/include/graphicsItem/electricSvgItemRect.h
@@ -0,0 +1,95 @@
+#ifndef ELECTRICSVGITEMRECT_H
+#define ELECTRICSVGITEMRECT_H
+
+#include "electricSvgItem.h"
+#include "itemPropertyDlg.h"
+
+class ElectricSvgItemRect_Property: public BaseProperty
+{
+ Q_OBJECT
+public:
+ ElectricSvgItemRect_Property(QObject* parent);
+ ~ElectricSvgItemRect_Property();
+
+ void setComponent_id(int n) {componentId = n;}
+ int component_id() const {return componentId;}
+
+ void setResistance(double d){resistance = d;}
+ double getResistance() const {return resistance;}
+
+ void setAnchor_v(bool b){anchor_v = b;}
+ bool getAnchor_v() const {return anchor_v;}
+
+ void setUv_alarm(double d){uv_alarm = d;}
+ double getUv_alarm() const {return uv_alarm;}
+
+ void setOv_alarm(double d){ov_alarm = d;}
+ double getOv_alarm() const {return ov_alarm;}
+
+ void setAnchor_i(bool b) {anchor_i = b;}
+ bool getAnchor_i() const {return anchor_i;}
+
+ void setUi_alarm(double d) {ui_alarm = d;}
+ double getUi_alarm() const {return ui_alarm;}
+
+ void setOi_alarm(double d) {oi_alarm = d;}
+ double getOi_alarm() const {return oi_alarm;}
+
+ void setElec(double d) {electricity = d;}
+ double getElec() const {return electricity;}
+
+ void setVolt(double d) {voltage = d;}
+ double getVolt() const {return voltage;}
+protected:
+ int componentId;
+ double resistance; //电阻 DEFAULT 2,
+ bool anchor_v; //是否锚定电压 DEFAULT FALSE,
+ double uv_alarm; //电压下限 DEFAULT 90,
+ double ov_alarm; //电压上限 DEFAULT 110,
+ bool anchor_i; //是否锚定电流 DEFAULT FALSE,
+ double ui_alarm; //电流下限 DEFAULT 45,
+ double oi_alarm; //电流上限 DEFAULT 55,
+ double electricity;
+ double voltage;
+ /*double uv_warn_rate; //-- 欠压预警 阈值 0~100(%) DEFAULT 95 *********正式参数**********
+ QString uv_warn_unit; //欠压预警 单位 周波t/秒s/分钟m/小时h DEFAULT 's'
+ double uv_warn_dur; //DEFAULT 10, -- 欠压预警 运行时间 0~100
+ double uv_alarm_rate; //DEFAULT 90, -- 欠压警告 阈值 0~100(%)
+ QString uv_alarm_unit; //DEFAULT 's', -- 欠压警告 单位 周波t/秒s/分钟m/小时h
+ double uv_alarm_dur; //DEFAULT 10, -- 欠压警告 运行时间 0~100
+ double ov_warn_rate; //DEFAULT 105, -- 过压预警 阈值 100~500(%)
+ QString ov_warn_unit; //DEFAULT 's', -- 过压预警 单位 周波t/秒s/分钟m/小时h
+ double ov_warn_dur; //DEFAULT 10, -- 过压预警 运行时间 0~100
+ double ov_alarm_rate; //DEFAULT 110, -- 过压警告 阈值 100~500(%)
+ QString ov_alarm_unit; //DEFAULT 's', -- 过压警告 单位 周波t/秒s/分钟m/小时h
+ double ov_alarm_dur; //DEFAULT 10, -- 过压警告 运行时间 0~100
+ double svm_pmax; //DEFAULT 0, -- 区域电压静稳裕度参数 Pmax 0~65536
+ double svm_qmax; //DEFAULT 0, -- 区域电压静稳裕度参数 Qmax 0~65536
+ double svm_ulim; //DEFAULT 90, -- 区域电压静稳裕度参数 Ulim 0~1000
+ double svm_prate; //DEFAULT 30, -- 区域电压静稳裕度参数 有功稳定裕度限值 0~100(%)
+ double svm_qrate; //DEFAULT 30, -- 区域电压静稳裕度参数 无功稳定裕度限值 0~100(%)*/
+ int op;
+};
+
+class ElectricSvgItemRect :public ElectricSvgItem
+{
+ Q_OBJECT
+public:
+ ElectricSvgItemRect(const QRect &rect, QGraphicsItem *parent = 0);
+ virtual ~ElectricSvgItemRect();
+
+ virtual ElectricSvgItemRect_Property* getProperty() {return dynamic_cast(_property);}
+ virtual void showPropertyDlg(QWidget* p);
+ virtual void updateByProperty();
+public slots:
+ void onPropertyChanged(const PropertyInfo);
+protected:
+ virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
+private:
+ virtual void updateHandles();
+
+ double m_dRatioX;
+ ItemPropertyDlg* _pDlg;
+};
+
+#endif
diff --git a/include/graphicsItem/electricSvgItemTriangle.h b/diagramCavas/include/graphicsItem/electricSvgItemTriangle.h
similarity index 72%
rename from include/graphicsItem/electricSvgItemTriangle.h
rename to diagramCavas/include/graphicsItem/electricSvgItemTriangle.h
index a258f12..d5a1251 100644
--- a/include/graphicsItem/electricSvgItemTriangle.h
+++ b/diagramCavas/include/graphicsItem/electricSvgItemTriangle.h
@@ -17,4 +17,11 @@ private:
double m_dBottomRatioX;
};
+class ElectricSvgItemTriangle_Property: public BaseProperty
+{
+ Q_OBJECT
+public:
+ ElectricSvgItemTriangle_Property(QObject* parent);
+ ~ElectricSvgItemTriangle_Property();
+};
#endif
diff --git a/include/graphicsItem/graphicsBaseItem.h b/diagramCavas/include/graphicsItem/graphicsBaseItem.h
similarity index 80%
rename from include/graphicsItem/graphicsBaseItem.h
rename to diagramCavas/include/graphicsItem/graphicsBaseItem.h
index 0482ca0..cbb3a5a 100644
--- a/include/graphicsItem/graphicsBaseItem.h
+++ b/diagramCavas/include/graphicsItem/graphicsBaseItem.h
@@ -9,6 +9,8 @@
#include
#include
#include
+#include
+#include
//#include "graphicsItem/itemPort.h"
enum ShapeType
@@ -434,6 +436,7 @@ protected:
};
class ItemPort;
+class BaseProperty;
typedef AbstractShapeType AbstractShape;
@@ -455,10 +458,16 @@ public:
virtual bool endDrawing() { return true; }
+ virtual void setLabelTag(const QString& name); //设置名字牌
+ virtual QString getLabelTag() const;
+ virtual void setLabelCurrent(const QString& str); //设置电流标签
+ virtual QString getLabelCurrent() const;
+ virtual void setLabelVoltage(const QString& str); //设置电压标签
+ virtual QString getLabelVoltage() const;
virtual int addPort(PortState typ,QPointF vec); //新建,返回-1失败
virtual void addPort(PortState typ,int ntagId,QPointF vec); //载入 PortState为P_const时,QPointF中为(0~1,0~1)的相对位置;PortState为p_movable时,QPointF为坐标值
- virtual uint itemId() const {return m_itemId;}
- virtual void setItemId(uint n){m_itemId = n;}
+ virtual QUuid itemId() const {return m_itemId;}
+ virtual void setItemId(QUuid n){m_itemId = n;}
virtual void setState(ItemState s){m_state = s;}
virtual void setBeginConnectPos(QPointF p){m_beginConnectPoint = p;}
virtual void setEndConnectPos(QPointF p){m_endConnectPoint = p;}
@@ -469,12 +478,24 @@ public:
virtual ItemPort* getPortPtr(int) const;
virtual ItemControlHandle* getHandlePtr(int) const;
virtual QMap& getPorts() {return m_mapPort;}
+ virtual void setProperty(BaseProperty* p);
+ virtual BaseProperty* getProperty() {return _property;}
+ virtual void unbindProperty(); //断开图元与数据的绑定
+ virtual void updateByProperty(); //使用data对象更新自己
+ virtual void showPropertyDlg(QWidget* p); //显示属性对话框,参数为父对象
+ virtual void updateConnectData(); //更新连接关系数据
+ virtual void setItemChanged(bool b){_itemChanged = b;}
+ virtual bool itemChanged() const {return _itemChanged;}
protected:
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange, const QVariant&);
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*);
-
+signals:
+ void ifExist(QUuid id,const QString&,int type,GraphicsBaseItem*);
+public slots:
+ void onEditNameFinish(const QString&);
+ void onUpdateData(); //data发送的更新通知
protected:
- uint m_itemId;
+ QUuid m_itemId;
GraphicsItemType m_Itemtype;
ItemState m_state;
QMap m_mapPort; //单独存放port
@@ -482,6 +503,74 @@ protected:
QPointF m_endConnectPoint;
uint _portId; //port编号
int _lastPort; //最后触碰的port
+ BaseProperty* _property;
+ bool _itemChanged; //图元变化标志,判断是否需要保存
+};
+
+class BaseProperty:public QObject //属性类,存放电路元件属性
+{
+ Q_OBJECT
+public:
+ BaseProperty(QObject* parent);
+ virtual ~BaseProperty();
+
+ void setUuid(QUuid id) {uUid = id;}
+ QUuid uuid() const {return uUid;}
+ void setType(int n) {nType = n;}
+ int type() const {return nType;}
+ void setPage(int n){nPageId = n;}
+ int page() const {return nPageId;}
+ void setTag(QString s){sTag = s;}
+ QString tag() const {return sTag;}
+ void setName(QString s){sName = s;}
+ QString name() const {return sName;}
+ void setPath(QString s){sPath = s;}
+ QString path() const {return sPath;}
+ void setDescription(QString s) {sDescription = s;}
+ QString description() const {return sDescription;}
+ void setInService(bool b) {bInService = b;}
+ bool inService() {return bInService;}
+ void setState(int n) {nState = n;}
+ int state() const {return nState;}
+ void setConnectedBus(QJsonObject j) {jConnectedBus = j;}
+ QJsonObject connectedBus() const {return jConnectedBus;}
+ void setLabel(QJsonObject j){jLabel = j;}
+ QJsonObject label() const {return jLabel;}
+ void setContext(QJsonObject j){jContext = j;}
+ QJsonObject context() const {return jContext;}
+ void setGrid(const QString& s) {sGrid = s;}
+ QString grid() const {return sGrid;}
+ void setZone(const QString& s) {sZone = s;}
+ QString zone() const {return sZone;}
+ void setStation(const QString& s) {sStation = s;}
+ QString station() const {return sStation;}
+
+ void setPrepareDelete(bool b) {_prepareDelete = b;}
+ bool prepareDelete() const {return _prepareDelete;}
+ void setDataChanged(bool b) {_dataChanged = b;} //数据变换标签
+ bool dataChanged() const {return _dataChanged;}
+ void notifyUpdate(){emit updateData();}
+signals:
+ void updateData(); //通知数据拥有者更新
+protected:
+ QUuid uUid;
+ int nType; //设备类型
+ int nPageId; //暂定为创建本数据的图Id(待定)
+ QString sTag;
+ QString sName;
+ QString sPath;
+ QString sDescription;
+ QString sGrid;
+ QString sZone;
+ QString sStation;
+ bool bInService;
+ int nState;
+ QJsonObject jConnectedBus;
+ QJsonObject jLabel;
+ QJsonObject jContext; //存放port信息
+
+ bool _dataChanged; //数据状态,为真则写入库
+ bool _prepareDelete; //状态,为真准备删除
};
#endif
diff --git a/include/graphicsItem/graphicsItemGroup.h b/diagramCavas/include/graphicsItem/graphicsItemGroup.h
similarity index 100%
rename from include/graphicsItem/graphicsItemGroup.h
rename to diagramCavas/include/graphicsItem/graphicsItemGroup.h
diff --git a/include/graphicsItem/graphicsPolygonItem.h b/diagramCavas/include/graphicsItem/graphicsPolygonItem.h
similarity index 100%
rename from include/graphicsItem/graphicsPolygonItem.h
rename to diagramCavas/include/graphicsItem/graphicsPolygonItem.h
diff --git a/include/graphicsItem/graphicsRectItem.h b/diagramCavas/include/graphicsItem/graphicsRectItem.h
similarity index 100%
rename from include/graphicsItem/graphicsRectItem.h
rename to diagramCavas/include/graphicsItem/graphicsRectItem.h
diff --git a/include/graphicsItem/handleRect.h b/diagramCavas/include/graphicsItem/handleRect.h
similarity index 100%
rename from include/graphicsItem/handleRect.h
rename to diagramCavas/include/graphicsItem/handleRect.h
diff --git a/include/graphicsItem/handleText.h b/diagramCavas/include/graphicsItem/handleText.h
similarity index 84%
rename from include/graphicsItem/handleText.h
rename to diagramCavas/include/graphicsItem/handleText.h
index a2ed54d..a51368a 100644
--- a/include/graphicsItem/handleText.h
+++ b/diagramCavas/include/graphicsItem/handleText.h
@@ -16,9 +16,12 @@ public:
HandleText(QGraphicsItem *parent);
virtual ~HandleText();
- void setText(QString);
+ virtual void setText(QString) override;
+ virtual QString getText() const override;
void creatEditor(); //创建editor编辑文本
void setEditable(bool b){_editable = b;}
+signals:
+ void editFinish(const QString&);
protected:
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
virtual QRectF boundingRect() const override;
diff --git a/include/graphicsItem/itemControlHandle.h b/diagramCavas/include/graphicsItem/itemControlHandle.h
similarity index 91%
rename from include/graphicsItem/itemControlHandle.h
rename to diagramCavas/include/graphicsItem/itemControlHandle.h
index 8379b97..49af2de 100644
--- a/include/graphicsItem/itemControlHandle.h
+++ b/diagramCavas/include/graphicsItem/itemControlHandle.h
@@ -32,6 +32,8 @@ enum HandleTag
H_rotate_leftBottom, //12
H_edit,
H_textCaption = 40, //标题文本
+ H_textCurrent, //电流
+ h_textVoltage, //电压
H_connect = 50 //连接操作点从50开始,前面预留
};
@@ -50,7 +52,7 @@ class GraphicsBaseItem;
class ItemControlHandle : public QObject,public QGraphicsItem
{
Q_OBJECT
-
+ Q_INTERFACES(QGraphicsItem)
public:
ItemControlHandle(QGraphicsItem *parent);
virtual ~ItemControlHandle();
@@ -59,6 +61,9 @@ public:
virtual int getSize();
virtual void move(double, double);
+ virtual void setText(QString);
+ virtual QString getText() const;
+
void setType(HandleType ht) { m_type = ht; }
HandleType getType() { return m_type; }
@@ -74,6 +79,7 @@ public:
GraphicsBaseItem* getParentPtr() const {return _parent;}
void setParent(GraphicsBaseItem* p) {_parent = p;}
protected:
+
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent*) override;
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override;
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
diff --git a/include/graphicsItem/itemPort.h b/diagramCavas/include/graphicsItem/itemPort.h
similarity index 100%
rename from include/graphicsItem/itemPort.h
rename to diagramCavas/include/graphicsItem/itemPort.h
diff --git a/diagramCavas/include/itemPropertyDlg.h b/diagramCavas/include/itemPropertyDlg.h
new file mode 100644
index 0000000..482c0f5
--- /dev/null
+++ b/diagramCavas/include/itemPropertyDlg.h
@@ -0,0 +1,43 @@
+#ifndef ITEMPROPERTYDLG_H
+#define ITEMPROPERTYDLG_H
+
+#include
+#include
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class itemPropertyDlg; }
+QT_END_NAMESPACE
+
+struct PropertyInfo
+{
+ double resistance = 0; //电阻 DEFAULT 2,
+ bool anchor_v = false; //是否锚定电压 DEFAULT FALSE,
+ double uv_alarm = 0; //电压下限 DEFAULT 90,
+ double ov_alarm = 0; //电压上限 DEFAULT 110,
+ bool anchor_i = false; //是否锚定电流 DEFAULT FALSE,
+ double ui_alarm = 0; //电流下限 DEFAULT 45,
+ double oi_alarm = 0; //电流上限 DEFAULT 55,
+};
+Q_DECLARE_METATYPE(PropertyInfo);
+
+class ItemPropertyDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ ItemPropertyDlg(QWidget *parent = nullptr);
+ ~ItemPropertyDlg();
+
+ void synchroniseData(const PropertyInfo); //外部调用
+signals:
+ void PropertyChange(const PropertyInfo);
+public slots:
+ void onOkClicked();
+ void onCancelClicked();
+ void onApplyClicked();
+private:
+ Ui::itemPropertyDlg *ui;
+
+};
+
+#endif
diff --git a/include/serializable.h b/diagramCavas/include/serializable.h
similarity index 100%
rename from include/serializable.h
rename to diagramCavas/include/serializable.h
diff --git a/include/statusBar.h b/diagramCavas/include/statusBar.h
similarity index 100%
rename from include/statusBar.h
rename to diagramCavas/include/statusBar.h
diff --git a/include/util/baseSelector.h b/diagramCavas/include/util/baseSelector.h
similarity index 92%
rename from include/util/baseSelector.h
rename to diagramCavas/include/util/baseSelector.h
index 06947b7..4ea9ca7 100644
--- a/include/util/baseSelector.h
+++ b/diagramCavas/include/util/baseSelector.h
@@ -47,7 +47,7 @@ class BaseSelector : public QObject
Q_OBJECT
public:
- explicit BaseSelector(QObject *parent = 0);
+ explicit BaseSelector(FixedPortsModel* model,QObject *parent = 0);
virtual ~BaseSelector();
public:
@@ -64,8 +64,6 @@ public:
void setSceneName(const QString& str) {m_sceneName = str;}
QString sceneName() const {return m_sceneName;}
-public:
- static ItemMap m_graphicsItem; //存储所有对象 类型 <图名>
signals:
void setWorkingSelector(SelectorType);
@@ -76,10 +74,10 @@ protected:
static QPointF ms_ptMouseLast;
static double ms_dAngleMouseDownToItem; //鼠标按下时其位置和item中心点形成的夹角
static int ms_nDragHandle; //当前抓取的控制点
- static uint _Id;
SelectorType m_type;
QString m_sceneName;
+ FixedPortsModel* _model;
private:
bool m_bHoverOnHandel; //鼠标是否悬停在handel
OperationMode m_opMode;
diff --git a/include/util/connectingSelector.h b/diagramCavas/include/util/connectingSelector.h
similarity index 92%
rename from include/util/connectingSelector.h
rename to diagramCavas/include/util/connectingSelector.h
index ea2b609..ef602c3 100644
--- a/include/util/connectingSelector.h
+++ b/diagramCavas/include/util/connectingSelector.h
@@ -19,7 +19,7 @@ class ConnectingSelector : public BaseSelector
Q_OBJECT
public:
- explicit ConnectingSelector(QObject *parent = 0);
+ explicit ConnectingSelector(FixedPortsModel* model,QObject *parent = 0);
virtual ~ConnectingSelector();
public:
bool targetCouldConnect(GraphicsBaseItem* p,QPointF pos);
diff --git a/include/util/creatingSelector.h b/diagramCavas/include/util/creatingSelector.h
similarity index 93%
rename from include/util/creatingSelector.h
rename to diagramCavas/include/util/creatingSelector.h
index ae0fa15..5673ac3 100644
--- a/include/util/creatingSelector.h
+++ b/diagramCavas/include/util/creatingSelector.h
@@ -27,7 +27,7 @@ class CreatingSelector : public BaseSelector
Q_OBJECT
public:
- explicit CreatingSelector(QObject *parent = 0);
+ explicit CreatingSelector(FixedPortsModel* model,QObject *parent = 0);
virtual ~CreatingSelector();
public:
diff --git a/include/util/editingSelector.h b/diagramCavas/include/util/editingSelector.h
similarity index 89%
rename from include/util/editingSelector.h
rename to diagramCavas/include/util/editingSelector.h
index c7f4ca4..f8ae2ac 100644
--- a/include/util/editingSelector.h
+++ b/diagramCavas/include/util/editingSelector.h
@@ -19,7 +19,7 @@ class EditingSelector : public BaseSelector
Q_OBJECT
public:
- explicit EditingSelector(QObject *parent = 0);
+ explicit EditingSelector(FixedPortsModel* model,QObject *parent = 0);
virtual ~EditingSelector();
public:
diff --git a/include/util/linkMovingSelector.h b/diagramCavas/include/util/linkMovingSelector.h
similarity index 89%
rename from include/util/linkMovingSelector.h
rename to diagramCavas/include/util/linkMovingSelector.h
index 2bcf67c..f207e46 100644
--- a/include/util/linkMovingSelector.h
+++ b/diagramCavas/include/util/linkMovingSelector.h
@@ -17,7 +17,7 @@ class LinkMovingSelector : public BaseSelector
{
Q_OBJECT
public:
- explicit LinkMovingSelector(QObject *parent = 0);
+ explicit LinkMovingSelector(FixedPortsModel* model,QObject *parent = 0);
virtual ~LinkMovingSelector();
public:
void mousePressEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
diff --git a/include/util/movingSelector.h b/diagramCavas/include/util/movingSelector.h
similarity index 88%
rename from include/util/movingSelector.h
rename to diagramCavas/include/util/movingSelector.h
index 20f87f1..b3eb5ff 100644
--- a/include/util/movingSelector.h
+++ b/diagramCavas/include/util/movingSelector.h
@@ -16,7 +16,7 @@ class MovingSelector : public BaseSelector
Q_OBJECT
public:
- explicit MovingSelector(QObject *parent = 0);
+ explicit MovingSelector(FixedPortsModel* model,QObject *parent = 0);
virtual ~MovingSelector();
void updateConnectLine(QList);
diff --git a/include/util/rotationSelector.h b/diagramCavas/include/util/rotationSelector.h
similarity index 87%
rename from include/util/rotationSelector.h
rename to diagramCavas/include/util/rotationSelector.h
index 22c4610..0d603ac 100644
--- a/include/util/rotationSelector.h
+++ b/diagramCavas/include/util/rotationSelector.h
@@ -16,7 +16,7 @@ class RotationSelector : public BaseSelector
Q_OBJECT
public:
- explicit RotationSelector(QObject *parent = 0);
+ explicit RotationSelector(FixedPortsModel* model,QObject *parent = 0);
virtual ~RotationSelector();
public:
diff --git a/include/util/scalingSelector.h b/diagramCavas/include/util/scalingSelector.h
similarity index 88%
rename from include/util/scalingSelector.h
rename to diagramCavas/include/util/scalingSelector.h
index e12333f..0682c97 100644
--- a/include/util/scalingSelector.h
+++ b/diagramCavas/include/util/scalingSelector.h
@@ -15,7 +15,7 @@ class ScalingSelector : public BaseSelector
Q_OBJECT
public:
- explicit ScalingSelector(QObject *parent = 0);
+ explicit ScalingSelector(FixedPortsModel* model,QObject *parent = 0);
virtual ~ScalingSelector();
public:
diff --git a/include/util/selectorManager.h b/diagramCavas/include/util/selectorManager.h
similarity index 82%
rename from include/util/selectorManager.h
rename to diagramCavas/include/util/selectorManager.h
index 845c583..4ee7573 100644
--- a/include/util/selectorManager.h
+++ b/diagramCavas/include/util/selectorManager.h
@@ -12,6 +12,7 @@
#include
#include "baseSelector.h"
#include "global.h"
+#include "graphicsDataModel/fixedPortsModel.h"
class SelectorManager : public QObject
@@ -19,7 +20,8 @@ class SelectorManager : public QObject
Q_OBJECT
public:
- SelectorManager(QObject *parent = 0);
+ SelectorManager(FixedPortsModel*,QObject *parent = 0);
+ SelectorManager() = delete;
~SelectorManager();
public:
@@ -34,6 +36,7 @@ public slots:
private:
SelectorType m_curSelector;
QVector m_vecSelectors;
+ FixedPortsModel *_graphModel;
};
#endif
diff --git a/include/util/subMovingSelector.h b/diagramCavas/include/util/subMovingSelector.h
similarity index 89%
rename from include/util/subMovingSelector.h
rename to diagramCavas/include/util/subMovingSelector.h
index 9b1eadd..b0a525c 100644
--- a/include/util/subMovingSelector.h
+++ b/diagramCavas/include/util/subMovingSelector.h
@@ -15,7 +15,7 @@ class SubMovingSelector : public BaseSelector
{
Q_OBJECT
public:
- explicit SubMovingSelector(QObject *parent = 0);
+ explicit SubMovingSelector(FixedPortsModel* model,QObject *parent = 0);
virtual ~SubMovingSelector();
public:
void mousePressEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
diff --git a/diagramCavas/source/baseScene.cpp b/diagramCavas/source/baseScene.cpp
new file mode 100644
index 0000000..1e6cab3
--- /dev/null
+++ b/diagramCavas/source/baseScene.cpp
@@ -0,0 +1,41 @@
+#include "baseScene.h"
+
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+BaseScene::BaseScene(BaseModel* graphModel, QObject *parent)
+ : QGraphicsScene(parent)
+ , _graphModel(graphModel)
+ , _undoStack(new QUndoStack(this))
+{
+ setItemIndexMethod(QGraphicsScene::NoIndex);
+}
+
+BaseScene::~BaseScene() = default;
+
+BaseModel const *BaseScene::graphModel() const
+{
+ return _graphModel;
+}
+
+BaseModel *BaseScene::graphModel()
+{
+ return _graphModel;
+}
+
+
+QUndoStack &BaseScene::undoStack()
+{
+ return *_undoStack;
+}
diff --git a/source/designerScene.cpp b/diagramCavas/source/designerScene.cpp
similarity index 72%
rename from source/designerScene.cpp
rename to diagramCavas/source/designerScene.cpp
index d128d61..0df279a 100644
--- a/source/designerScene.cpp
+++ b/diagramCavas/source/designerScene.cpp
@@ -1,9 +1,13 @@
#include "designerScene.h"
#include "util/selectorManager.h"
#include "graphicsItem/graphicsItemGroup.h"
+#include "graphicsItem/electricConnectLineItem.h"
+#include "graphicsItem/itemPort.h"
#include "drawingPanel.h"
+#include "global.h"
#include
+#include
#include
#include
#include
@@ -22,17 +26,15 @@
#include
#include
-DesignerScene::DesignerScene(DataFlowGraphModel &graphModel, QObject *parent)
- : BasicGraphicsScene(graphModel,parent),
+DesignerScene::DesignerScene(FixedPortsModel* graphModel, QObject *parent)
+ : BaseScene(graphModel,parent),
m_pDrawingPanel(NULL),
_graphModel(graphModel)
{
m_bGridVisible = true;
m_pView = nullptr;
m_pDrawingPanel = dynamic_cast(parent);
- connect(&_graphModel,
- &DataFlowGraphModel::inPortDataWasSet,
- [this](NodeId const nodeId, PortType const, PortIndex const) { onNodeUpdated(nodeId); });
+
}
DesignerScene::~DesignerScene()
{
@@ -72,6 +74,8 @@ void DesignerScene::mousePressEvent(QGraphicsSceneMouseEvent* mouseEvent)
{
if(m_pDrawingPanel)
{
+ if(m_pDrawingPanel->getMode() == DM_run)
+ return;
m_pDrawingPanel->selectorManager()->getWorkingSelector()->mousePressEvent(mouseEvent, this);
update();
}
@@ -83,6 +87,8 @@ void DesignerScene::mouseMoveEvent(QGraphicsSceneMouseEvent* mouseEvent)
{
if(m_pDrawingPanel)
{
+ if(m_pDrawingPanel->getMode() == DM_run)
+ return;
m_pDrawingPanel->selectorManager()->getWorkingSelector()->mouseMoveEvent(mouseEvent, this);
update();
}
@@ -94,6 +100,8 @@ void DesignerScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* mouseEvent)
{
if(m_pDrawingPanel)
{
+ if(m_pDrawingPanel->getMode() == DM_run)
+ return;
m_pDrawingPanel->selectorManager()->getWorkingSelector()->mouseReleaseEvent(mouseEvent, this);
update();
}
@@ -105,6 +113,8 @@ void DesignerScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* mouseEvent)
{
if(m_pDrawingPanel)
{
+ if(m_pDrawingPanel->getMode() == DM_run)
+ return;
m_pDrawingPanel->selectorManager()->getWorkingSelector()->mouseDoubleClickEvent(mouseEvent, this);
update();
}
@@ -122,6 +132,40 @@ void DesignerScene::keyReleaseEvent(QKeyEvent* event)
QGraphicsScene::keyReleaseEvent(event);
}
+void DesignerScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent)
+{
+ QList listItem = selectedItems();
+ if(listItem.isEmpty())
+ return;
+ else if(listItem.count() == 1)
+ {
+ QMenu menu;
+ QAction *removeAction = menu.addAction(QString::fromWCharArray(L"删除"));
+ connect(removeAction,&QAction::triggered,this,&DesignerScene::onDeleteClicked);
+ menu.exec(QCursor::pos());
+ }
+}
+
+void DesignerScene::onDeleteClicked()
+{
+ QList listItem = selectedItems();
+ if(listItem.isEmpty())
+ return;
+ else if(listItem.count() == 1)
+ {
+ GraphicsBaseItem* item = qgraphicsitem_cast(listItem.first());
+ if(item)
+ {
+ GraphicsItemType tpe = item->getItemType();
+ if(tpe > QGraphicsItem::UserType && tpe < QGraphicsItem::UserType+1000)
+ {
+ if(_graphModel)
+ _graphModel->deleteNodeItem(item);
+ }
+ }
+ }
+}
+
void DesignerScene::setGridVisible(bool bVisible)
{
m_bGridVisible = bVisible;
@@ -198,77 +242,3 @@ void DesignerScene::destroyGroup()
}
-std::vector DesignerScene::selectedNodes() const
-{
- QList graphicsItems = selectedItems();
-
- std::vector result;
- result.reserve(graphicsItems.size());
-
- /*for (QGraphicsItem *obj : graphicsItems) {
- auto ngo = qgraphicsitem_cast(obj);
-
- if (ngo != nullptr) {
- result.push_back(ngo->nodeId());
- }
- }*/
-
- return result;
-}
-
-QMenu *DesignerScene::createSceneMenu(QPointF const scenePos)
-{
- QMenu *modelMenu = new QMenu();
-
- // QMenu's instance auto-destruction
- modelMenu->setAttribute(Qt::WA_DeleteOnClose);
-
- return modelMenu;
-}
-
-bool DesignerScene::save() const
-{
- QString fileName = QFileDialog::getSaveFileName(nullptr,
- tr("Open Flow Scene"),
- QDir::homePath(),
- tr("Flow Scene Files (*.flow)"));
-
- if (!fileName.isEmpty()) {
- if (!fileName.endsWith("flow", Qt::CaseInsensitive))
- fileName += ".flow";
-
- QFile file(fileName);
- if (file.open(QIODevice::WriteOnly)) {
- file.write(QJsonDocument(_graphModel.save()).toJson());
- return true;
- }
- }
- return false;
-}
-
-bool DesignerScene::load()
-{
- QString fileName = QFileDialog::getOpenFileName(nullptr,
- tr("Open Flow Scene"),
- QDir::homePath(),
- tr("Flow Scene Files (*.flow)"));
-
- if (!QFileInfo::exists(fileName))
- return false;
-
- QFile file(fileName);
-
- if (!file.open(QIODevice::ReadOnly))
- return false;
-
- clearScene();
-
- QByteArray const wholeFile = file.readAll();
-
- _graphModel.load(QJsonDocument::fromJson(wholeFile).object());
-
- Q_EMIT sceneLoaded();
-
- return true;
-}
-
diff --git a/source/designerView.cpp b/diagramCavas/source/designerView.cpp
similarity index 94%
rename from source/designerView.cpp
rename to diagramCavas/source/designerView.cpp
index b654767..b11dc03 100644
--- a/source/designerView.cpp
+++ b/diagramCavas/source/designerView.cpp
@@ -1,4 +1,5 @@
#include "designerView.h"
+#include "designerScene.h"
#include
#define MAX_ZoomValue 50.0
@@ -11,6 +12,7 @@ DesignerView::DesignerView(QWidget *parent)
m_dScale = 1.0;
initialize();
m_nLevel = 10;
+ this->setFocusPolicy(Qt::ClickFocus);
}
DesignerView::~DesignerView()
{
@@ -34,11 +36,14 @@ void DesignerView::initialize()
centerOn(0, 0);
}
-void DesignerView::contextMenuEvent(QContextMenuEvent* event)
+/*void DesignerView::contextMenuEvent(QContextMenuEvent* event)
{
- Q_UNUSED(event);
+ /*Q_UNUSED(event);
m_bMousePress = false;
-}
+ QMenu menu;
+ QAction *removeAction = menu.addAction(QString::fromWCharArray(L"删除"));
+ menu.exec(QCursor::pos());
+}*/
void DesignerView::mousePressEvent(QMouseEvent* event)
{
diff --git a/diagramCavas/source/diagramCavas.cpp b/diagramCavas/source/diagramCavas.cpp
new file mode 100644
index 0000000..c28bc01
--- /dev/null
+++ b/diagramCavas/source/diagramCavas.cpp
@@ -0,0 +1,168 @@
+#include "drawingPanel.h"
+#include "diagramCavas.h"
+#include "mainwindow.h"
+#include "dataBase.h"
+#include "graphicsItem/graphicsBaseItem.h"
+#include
+#include
+#include
+
+DiagramCavas::DiagramCavas(QWidget *parent)
+ : QMdiArea(parent)
+{
+ _pageIndex = 0;
+}
+
+DiagramCavas::~DiagramCavas()
+{
+
+}
+
+void DiagramCavas::initial()
+{
+ //todo:读取数据并初始化
+ //onSignal_addDrawingPanel(QString("electricElements"));
+}
+
+void DiagramCavas::onSignal_addDrawingPanel(const QString& sTitile,DiagramMode mode)
+{
+ DrawingPanel* pPanel = new DrawingPanel(this,mode);
+ _curPage = sTitile;
+ pPanel->setPageName(sTitile);
+ m_mapDrawPanel.insert(sTitile,pPanel);
+ pPanel->setWindowTitle(sTitile);
+ this->addSubWindow(pPanel);
+ pPanel->show();
+
+ FixedPortsModel* pModel = pPanel->getModel();
+ connect(pModel,&FixedPortsModel::activatePage,this,&DiagramCavas::onSignal_activatePage);
+ connect(pPanel,&DrawingPanel::panelDelete,this,&DiagramCavas::onSignal_panelDelete);
+}
+
+void DiagramCavas::onSignal_addGraphicsItem(GraphicsItemType& type)
+{
+ QWidget* pWindow= currentSubWindow()->widget();
+ DrawingPanel* pPanel = dynamic_cast(pWindow);
+
+ if(pPanel)
+ pPanel->onSignal_addGraphicsItem(type);
+}
+
+void DiagramCavas::onSignal_addPage()
+{
+ onSignal_addDrawingPanel(QString("Page_")+QString::number(++_pageIndex));
+}
+
+void DiagramCavas::onSignal_savePage()
+{
+ QWidget* pWindow= currentSubWindow()->widget();
+ DrawingPanel* pPanel = dynamic_cast(pWindow);
+ if(pPanel)
+ {
+ if(pPanel->getMode() == DM_run)
+ {
+ QMessageBox::about(NULL,QString::fromWCharArray(L"提示"), QString::fromWCharArray(L"运行中无法保存!"));
+ }
+ else if(pPanel->getMode() == DM_edit)
+ {
+ _curPage = pPanel->pageName();
+ QMessageBox msgBox;
+ msgBox.setText(QString::fromWCharArray(L"提示"));
+ msgBox.setInformativeText(QString::fromWCharArray(L"内容已修改,是否保存?"));
+ msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Cancel);
+ msgBox.setDefaultButton(QMessageBox::Save);
+ int ret = msgBox.exec();
+
+ switch (ret) {
+ case QMessageBox::Save: //todo:已存在更新
+ {
+ QMap map = pPanel->getModel()->allItems();
+ for(auto pItem:map)
+ {
+ if(pItem->itemChanged())
+ {
+ pItem->updateConnectData(); //更新连接状态
+ pItem->setItemChanged(false);
+ }
+ }
+
+ if(DataBase::GetInstance()->getPageIdByName(_curPage) == -1) //不存在,创建
+ DataBase::GetInstance()->insertPage(_curPage,_curPage,1,QJsonObject(),pPanel->getDiagramInfo(),QString("page"),1);
+ else
+ DataBase::GetInstance()->updatePage(_curPage,_curPage,pPanel->getDiagramInfo());
+ int pageId = DataBase::GetInstance()->getPageIdByName(_curPage);
+ pPanel->saveNodes(pageId);
+ }
+ break;
+ case QMessageBox::Cancel:
+ // Cancel was clicked
+ break;
+ default:
+ // should never be reached
+ break;
+ }
+ }
+ }
+}
+
+void DiagramCavas::onSignal_loadPage(const QString& sName)
+{
+ if(!m_mapDrawPanel.contains(sName))
+ {
+ //todo:加载数据
+ onSignal_addDrawingPanel(sName);
+ QJsonObject context = DataBase::GetInstance()->getPageContextByName(sName);
+ m_mapDrawPanel[sName]->loadNodes(context);
+ }
+ else //已存在
+ {
+ m_mapDrawPanel[sName]->show();
+ }
+}
+
+void DiagramCavas::runPage(const QString sName)
+{
+ QString pageName = sName+QString("_run");
+ if(!m_mapDrawPanel.contains(pageName))
+ {
+ onSignal_addDrawingPanel(pageName,DM_run);
+ QJsonObject context = DataBase::GetInstance()->getPageContextByName(sName);
+ m_mapDrawPanel[pageName]->loadNodes(context);
+ }
+ else //已存在
+ {
+ m_mapDrawPanel[pageName]->show();
+ }
+}
+
+void DiagramCavas::onSignal_runPage()
+{
+ runPage(_curPage);
+}
+
+void DiagramCavas::onSignal_deletePage()
+{
+
+}
+
+void DiagramCavas::onSignal_activatePage(const QString& name)
+{
+ _curPage = name;
+}
+
+void DiagramCavas::onSignal_panelDelete(const QString& name)
+{
+ DrawingPanel* pPanel = m_mapDrawPanel.take(name);
+ if(m_mapDrawPanel.isEmpty())
+ {
+ /*for(auto it = FixedPortsModel::_nodeData.begin();it!=FixedPortsModel::_nodeData.end();)
+ {
+ it = FixedPortsModel::_nodeData.erase(it);
+ }*/
+ qDeleteAll(FixedPortsModel::_nodeData);
+ FixedPortsModel::_nodeData.clear();
+ FixedPortsModel::_dataInitialised = false;
+ }
+ this->removeSubWindow(pPanel);
+ delete pPanel;
+}
diff --git a/diagramCavas/source/drawingPanel.cpp b/diagramCavas/source/drawingPanel.cpp
new file mode 100644
index 0000000..dcd8062
--- /dev/null
+++ b/diagramCavas/source/drawingPanel.cpp
@@ -0,0 +1,235 @@
+#include
+#include "drawingPanel.h"
+#include "ui_drawingPanel.h"
+#include
+#include "designerView.h"
+#include "graphicsDataModel/fixedPortsModel.h"
+#include "util/selectorManager.h"
+#include "graphicsItem/electricConnectLineItem.h"
+#include "statusBar.h"
+#include "dataBase.h"
+
+DrawingPanel::DrawingPanel(QWidget *parent,DiagramMode mode)
+ : QWidget(parent)
+ , ui(new Ui::drawingPanel)
+ ,_pModel(nullptr)
+ ,_mode(mode)
+{
+ ui->setupUi(this);
+
+ _pModel = new FixedPortsModel();
+ _pModel->setTopWidget(this);
+ if(mode == DM_edit)
+ m_pSelectorManager = new SelectorManager(_pModel,this);
+ m_pGraphicsScene = new DesignerScene(_pModel,this);
+ //设置场景大小.前两个参数为scene的坐标远点,设置到view的中心点后,无论view如何缩放,secne的坐标原点都不会动,方便后续的位置计算
+ m_pGraphicsScene->setSceneRect(-g_dGriaphicsScene_Width / 2, -g_dGriaphicsScene_Height / 2, g_dGriaphicsScene_Width, g_dGriaphicsScene_Height);
+ m_pGraphicsScene->setGridVisible(true);
+
+ m_pGraphicsView = new DesignerView(this);
+ m_pGraphicsView->setScene(m_pGraphicsScene);
+ m_pGraphicsScene->setView(m_pGraphicsView);
+ ui->mainLayout->addWidget(m_pGraphicsView);
+ _pModel->setScene(m_pGraphicsScene);
+
+ m_pStatusBar = new StatusBar(this);
+ ui->mainLayout->addWidget(m_pStatusBar);
+ connect(m_pGraphicsView,&DesignerView::onScaleChanged,m_pStatusBar,&StatusBar::onScaleLevelChanged);
+
+}
+
+DrawingPanel::~DrawingPanel()
+{
+ delete ui;
+ if(_pModel)
+ delete _pModel;
+}
+
+QGraphicsScene* DrawingPanel::getQGraphicsScene()
+{
+ return m_pGraphicsView->scene();
+}
+
+DesignerScene* DrawingPanel::getDesignerScene()
+{
+ return m_pGraphicsScene;
+}
+
+void DrawingPanel::grahpicsViewZoomIn()
+{
+ m_pGraphicsView->zoomIn();
+}
+
+void DrawingPanel::grahpicsViewZoomOut()
+{
+ m_pGraphicsView->zoomOut();
+}
+
+void DrawingPanel::grahpicsViewZoomFit()
+{
+ m_pGraphicsView->zoomFit();
+}
+
+GraphicsItemGroup* DrawingPanel::createItemGroup()
+{
+ return m_pGraphicsScene->createGroup();
+}
+
+void DrawingPanel::destroyItemGroup()
+{
+ m_pGraphicsScene->destroyGroup();
+}
+
+SelectorManager* DrawingPanel::selectorManager() const
+{
+ if(m_pSelectorManager)
+ return m_pSelectorManager;
+ else
+ return NULL;
+}
+
+void DrawingPanel::closeEvent(QCloseEvent *closeEvent)
+{
+ bool changed = false;
+ QMap map = _pModel->allItems();
+ if(_pModel)
+ {
+ for(auto pItem:map)
+ {
+ if(pItem->itemChanged())
+ {
+ changed = true;
+ break;
+ }
+ }
+ }
+
+ if(changed)
+ {
+ QMessageBox msgBox;
+ msgBox.setText(QString::fromWCharArray(L"提示"));
+ msgBox.setInformativeText(QString::fromWCharArray(L"保存修改内容?"));
+ msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
+ msgBox.setDefaultButton(QMessageBox::Cancel);
+ int ret = msgBox.exec();
+ switch (ret) {
+ case QMessageBox::Ok:
+ {
+ for(auto pItem:map)
+ {
+ if(pItem->itemChanged())
+ pItem->updateConnectData();
+ }
+ if(DataBase::GetInstance()->getPageIdByName(_name) == -1) //不存在,创建
+ DataBase::GetInstance()->insertPage(_name,_name,1,QJsonObject(),getDiagramInfo(),QString("page"),1);
+ else
+ DataBase::GetInstance()->updatePage(_name,_name,getDiagramInfo());
+ int pageId = DataBase::GetInstance()->getPageIdByName(_name);
+ saveNodes(pageId);
+ //todo:同步图形数据到数据对象,保存到服务器
+ }
+ break;
+ case QMessageBox::Cancel:
+ {
+ //todo:取消保存,删除panel
+ }
+ break;
+ default:
+ // should never be reached
+ break;
+ }
+ }
+ /*for(auto pItem:map) //删除图元前先解绑
+ {
+ pItem->unbindProperty();
+ }*/
+ emit panelDelete(_name);
+}
+
+void DrawingPanel::onSignal_addGraphicsItem(GraphicsItemType& itemType)
+{
+ if(m_pSelectorManager)
+ {
+ m_pSelectorManager->setWorkingSelector(ST_cerating);
+ m_pSelectorManager->setDrawGraphicsItem(itemType);
+ }
+}
+
+QJsonObject DrawingPanel::getDiagramInfo() const
+{
+ QJsonObject obj;
+ QJsonArray arr;
+ if(_pModel)
+ {
+ QMap map = _pModel->allNodePos();
+ for(auto iter = map.begin();iter != map.end();++iter)
+ {
+ QJsonObject node;
+ node["id"] = iter.key().toString();
+ node["x"] = iter.value().x();
+ node["y"] = iter.value().y();
+ arr.append(node);
+ }
+ obj["nodes"] = arr;
+
+ QJsonArray arrConnect;
+ QVector vec = _pModel->allConnections();
+ for(auto iter = vec.begin(); iter != vec.end();++iter)
+ {
+ QJsonObject connect;
+ connect["SrcNodeId"] = iter->nSrcNodeId.toString();
+ connect["SrcPort"] = iter->nSrcPort;
+ connect["DestNodeId"] = iter->nDestNodeId.toString();
+ connect["DestPort"] = iter->nDestPort;
+ arrConnect.append(connect);
+ }
+ obj["connections"] = arrConnect;
+ }
+ return obj;
+}
+
+void DrawingPanel::loadNodes(QJsonObject obj)
+{
+ QJsonArray nodesJsonArray = obj["nodes"].toArray();
+
+ for (QJsonValueRef nodeJson : nodesJsonArray)
+ {
+ QJsonObject node = nodeJson.toObject();
+ QString uuid = node["id"].toString();
+ double dX = node["x"].toDouble();
+ double dY = node["y"].toDouble();
+
+ //componentInfo info =DataBase::GetInstance()->getComponentInfoByUuid(uuid);
+ if(_pModel)
+ {
+ _pModel->addNodeItem(QUuid(uuid)/*,info.type*/,QPointF(dX,dY));
+ }
+ }
+
+ QJsonArray connectArr = obj["connections"].toArray();
+ for(QJsonValueRef connectJson:connectArr)
+ {
+ QJsonObject connect = connectJson.toObject();
+ QUuid srcId = QUuid(connect["SrcNodeId"].toString());
+ int srcPort = connect["SrcPort"].toInt();
+ QUuid destId = QUuid(connect["DestNodeId"].toString());
+ int destPort = connect["DestPort"].toInt();
+
+ if(_pModel)
+ {
+ _pModel->addConnectLline(srcId,destId,srcPort,destPort);
+ }
+ }
+
+ if(_mode == DM_run)
+ {
+ if(_pModel)
+ _pModel->startHttpRequest();
+ }
+}
+
+void DrawingPanel::saveNodes(int pageId)
+{
+ if(_pModel)
+ _pModel->saveNode(pageId);
+}
diff --git a/source/graphicsDataModel/NumberDisplayDataModel.cpp b/diagramCavas/source/graphicsDataModel/NumberDisplayDataModel.cpp
similarity index 100%
rename from source/graphicsDataModel/NumberDisplayDataModel.cpp
rename to diagramCavas/source/graphicsDataModel/NumberDisplayDataModel.cpp
diff --git a/diagramCavas/source/graphicsDataModel/baseModel.cpp b/diagramCavas/source/graphicsDataModel/baseModel.cpp
new file mode 100644
index 0000000..a35c5c3
--- /dev/null
+++ b/diagramCavas/source/graphicsDataModel/baseModel.cpp
@@ -0,0 +1,3 @@
+
+#include "graphicsDataModel/baseModel.h"
+
diff --git a/diagramCavas/source/graphicsDataModel/fixedPortsModel.cpp b/diagramCavas/source/graphicsDataModel/fixedPortsModel.cpp
new file mode 100644
index 0000000..4454ead
--- /dev/null
+++ b/diagramCavas/source/graphicsDataModel/fixedPortsModel.cpp
@@ -0,0 +1,571 @@
+#include "graphicsDataModel/fixedPortsModel.h"
+#include "graphicsItem/graphicsBaseItem.h"
+#include "graphicsItem/electricSvgItemBus.h"
+#include "graphicsItem/electricSvgItemRect.h"
+#include "graphicsItem/electricSvgItemTriangle.h"
+#include "graphicsItem/electricConnectLineItem.h"
+#include "graphicsItem/itemPort.h"
+#include "designerScene.h"
+#include "dataBase.h"
+#include "httpInterface.h"
+#include "drawingPanel.h"
+#include
+#include
+
+QMap FixedPortsModel::_nodeData;
+bool FixedPortsModel::_dataInitialised = false;
+
+FixedPortsModel::FixedPortsModel()
+ :_scene(nullptr)
+ ,_widget(nullptr)
+ ,_Interface(nullptr)
+{
+ loadNodeDataFromDataBase();
+ _Interface = new HttpInterface(this);
+ _timer = new QTimer(this);
+
+ connect(_timer,SIGNAL(timeout()),this,SLOT(onTimeOut()));
+ connect(_Interface,&HttpInterface::sendPointData,this,&FixedPortsModel::onSignal_GetPointData);
+}
+
+FixedPortsModel::~FixedPortsModel()
+{
+
+}
+
+QMap FixedPortsModel::allNodePos() const
+{
+ QMap map;
+ for(auto pItem:_nodeItem)
+ {
+ if(pItem->getItemType() != GIT_link)
+ map.insert(pItem->itemId(),pItem->pos());
+ }
+ return map;
+}
+
+QVector FixedPortsModel::allConnections()
+{
+ QVector vec;
+ for(auto pItem:_nodeItem)
+ {
+ if(pItem->getItemType() == GIT_link)
+ {
+ auto pLine = dynamic_cast(pItem);
+ if(pLine)
+ {
+ vec.push_back(pLine->getConnection());
+ }
+ }
+ }
+ return vec;
+}
+
+QMap& FixedPortsModel::allItems()
+{
+ return _nodeItem;
+}
+
+bool FixedPortsModel::addNodeItem(QUuid uuid,GraphicsBaseItem* pItem)
+{
+
+ if(_nodeItem.contains(uuid))
+ return false;
+ else
+ {
+ _nodeItem.insert(uuid,pItem);
+ connect(pItem,&GraphicsBaseItem::ifExist,this,&FixedPortsModel::onSignal_ifExits);
+ return true;
+ }
+}
+
+void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos)
+{
+ BaseProperty* pro = nullptr;
+ GraphicsBaseItem* item = nullptr;
+ if(_nodeData.contains(id))
+ {
+ pro = _nodeData[id];
+ if(pro)
+ {
+ int type = pro->type();
+ if(type == GIT_itemTri)
+ {
+ item = new ElectricSvgItemTriangle(QRect(-15, -15, 30, 30));
+ item->setItemType(GIT_itemTri);
+ }
+ else if(type == GIT_itemRect)
+ {
+ item = new ElectricSvgItemRect(QRect(-15, -15, 30, 30));
+ item->setItemType(GIT_itemRect);
+ }
+ else if(type == GIT_bus)
+ {
+ item = new ElectricSvgItemBus(QRect(-100, -3, 200, 6));
+ item->setItemType(GIT_bus);
+
+ QJsonArray portArr = pro->context()["port"].toArray();
+ for(QJsonValueRef portJson:portArr)
+ {
+ QJsonObject portObj = portJson.toObject();
+ int nPort = portObj["portId"].toInt();
+ int x = portObj["x"].toInt();
+ int y = portObj["y"].toInt();
+ item->addPort(p_movable,nPort,QPointF(x,y));
+ }
+ }
+ if(item)
+ {
+ item->setItemId(id);
+ item->editShape(0, pos);
+ item->setPos(pos);
+ //item->setSelected(true);
+ _scene->addItem(item);
+ item->addPoint(pos);
+ item->setProperty(pro); //绑定模型
+ item->updateByProperty(); //使用模型更新自身
+ _nodeItem.insert(id,item);
+ connect(item,&GraphicsBaseItem::ifExist,this,&FixedPortsModel::onSignal_ifExits);
+ }
+ }
+ }
+}
+
+BaseProperty* FixedPortsModel::addNodeData(QUuid id,int type,QString name)
+{
+ if(_nodeData.contains(id))
+ return nullptr;
+ BaseProperty* item = nullptr;
+ if(type == GIT_itemTri)
+ {
+ item = new ElectricSvgItemTriangle_Property(this);
+ }
+ else if(type == GIT_itemRect)
+ {
+ item = new ElectricSvgItemRect_Property(this);
+ }
+ else if(type == GIT_bus)
+ {
+ item = new ElectricSvgItemBus_Property(this);
+ }
+ if(item)
+ {
+ item->setUuid(id);
+ item->setType(type);
+ item->setTag(name);
+ item->setName(name);
+ _nodeData.insert(id,item);
+ }
+ return item;
+}
+
+void FixedPortsModel::loadNodeDataFromDataBase()
+{
+ if(!_dataInitialised)
+ {
+ QList lst= DataBase::GetInstance()->getAllComponents();
+ for(auto &info:lst)
+ {
+ BaseProperty* pData = addNodeData(info.uuid,info.type,info.name);
+ pData->setPage(info.page_id);
+ pData->setTag(info.tag);
+ pData->setName(info.name);
+ pData->setPath(info.nspath);
+ pData->setDescription(info.description);
+ pData->setInService(info.inService);
+ pData->setState(info.state);
+ pData->setConnectedBus(info.connected_bus);
+ pData->setLabel(info.label);
+ pData->setContext(info.context);
+ pData->setGrid(info.grid);
+ pData->setZone(info.zone);
+ pData->setStation(info.station);
+ pData->setDataChanged(false);
+
+ if(info.type == GIT_itemTri)
+ {
+
+ }
+ else if(info.type == GIT_itemRect)
+ {
+ busStability bility = DataBase::GetInstance()->getBusStabilityById(info.id);
+ ElectricSvgItemRect_Property* pPro = dynamic_cast(pData);
+ if(pPro)
+ {
+ pPro->setComponent_id(info.id);
+ pPro->setResistance(bility.resistance);
+ pPro->setAnchor_v(bility.anchor_v);
+ pPro->setUv_alarm(bility.uv_alarm);
+ pPro->setOv_alarm(bility.ov_alarm);
+ pPro->setAnchor_i(bility.anchor_i);
+ pPro->setUi_alarm(bility.ui_alarm);
+ pPro->setOi_alarm(bility.oi_alarm);
+ }
+ }
+ else if(info.type == GIT_bus)
+ {
+
+ }
+ }
+ _dataInitialised = true;
+ }
+ else
+ {
+ for(auto p:_nodeData)
+ {
+ int a = 1;
+ }
+ }
+}
+
+void FixedPortsModel::addConnectLline(QUuid srcId,QUuid destId,int srcPort,int destPort)
+{
+ GraphicsBaseItem* src = _nodeItem[srcId];
+ GraphicsBaseItem* dest = _nodeItem[destId];
+ if(src && dest)
+ {
+ ElectricConnectLineItem* pItem = new ElectricConnectLineItem();
+ pItem->setItemId(QUuid::createUuid());
+ pItem->setItemType(GIT_link);
+ _scene->addItem(pItem);
+
+ ItemPort* ptSrc = src->getPortPtr(srcPort);
+ HandleType srcType = ptSrc->getType();
+ PortPos srcPos = ptSrc->portPos();
+ pItem->setStartPoint(ptSrc->scenePos());
+ ptSrc->setConnect(pItem);
+
+ ItemPort* ptDest = nullptr;
+ if(dest->getItemType() == GIT_bus) //母线动态创建port
+ {
+ ptDest = dest->getPortPtr(destPort);
+ pItem->setEndPoint(ptDest->scenePos());
+ }
+ else
+ {
+ ptDest = dest->getPortPtr(destPort);
+ pItem->setEndPoint(ptDest->scenePos());
+ }
+
+ if(ptDest != nullptr)
+ {
+ int destPort = ptDest->getTag();
+ HandleType destType = ptDest->getType();
+ PortPos destPos = ptDest->portPos();
+
+ pItem->calculatePath();
+ pItem->setConnection(Connection(srcId,srcPort,srcType,srcPos,destId,destPort,destType,destPos));
+ ptDest->setConnect(pItem);
+
+ addNodeItem(pItem->itemId(),pItem);
+ /*auto srcParent = ptSrc->getParentPtr();
+ auto destParent = ptDest->getParentPtr();
+
+ srcParent->updateConnectData();
+ destParent->updateConnectData();*/
+ }
+ }
+}
+
+void FixedPortsModel::deleteNodeItem(GraphicsBaseItem* pItem)
+{
+ if(pItem->getItemType() == GIT_link)
+ {
+ auto pLine = dynamic_cast(pItem);
+ if(pLine)
+ {
+ Connection con = pLine->getConnection();
+ GraphicsBaseItem* srcItem = _nodeItem[con.nSrcNodeId];
+ if(srcItem)
+ {
+ ItemPort* ptSrc = srcItem->getPortPtr(con.nSrcPort);
+ ptSrc->disConnect();
+ srcItem->setItemChanged(true);
+ //srcItem->updateConnectData();
+ }
+
+ GraphicsBaseItem* destItem = _nodeItem[con.nDestNodeId];
+ if(destItem)
+ {
+ ItemPort* ptDest = pItem->getPortPtr(con.nDestPort);
+ ptDest->disConnect();
+ destItem->setItemChanged(true);
+ //destItem->updateConnectData();
+ }
+
+ QUuid lineId = pLine->itemId();
+ _nodeItem.take(lineId);
+ _scene->removeItem(pLine);
+ delete pLine;
+ }
+ }
+ else
+ {
+ QMap ports = pItem->getPorts();
+ for(auto port:ports)
+ {
+ if(port->connected())
+ {
+ ElectricConnectLineItem* pLine = port->getConnectPtr();
+ Connection con = pLine->getConnection();
+ QUuid oppositeId = pLine->getOppositeId(pItem->itemId());
+ int oppositePort = (con.nSrcNodeId==pItem->itemId())?con.nDestPort:con.nSrcPort; //取另一端点序号
+ GraphicsBaseItem* oppositeItem = _nodeItem[oppositeId];
+ if(oppositeItem)
+ {
+ ItemPort* ptOppo = oppositeItem->getPortPtr(oppositePort);
+ ptOppo->disConnect();
+ oppositeItem->setItemChanged(true);
+ //oppositeItem->updateConnectData();
+ }
+
+ QUuid lineId = pLine->itemId();
+ _nodeItem.take(lineId);
+ _scene->removeItem(pLine);
+ delete pLine;
+
+ port->disConnect();
+ }
+ }
+ QUuid srcId = pItem->itemId();
+ pItem->setItemChanged(true);
+ //pItem->updateConnectData();
+ _nodeItem.take(srcId);
+ _scene->removeItem(pItem);
+ delete pItem;
+ }
+}
+
+QVariant FixedPortsModel::nodeData(QUuid nodeId, NodeRole role) const
+{
+ QVariant result;
+ switch(role)
+ {
+ case NodeRole::Position:
+ result = _nodeItem[nodeId]->pos();
+ break;
+ }
+
+ /*auto it = _models.find(nodeId);
+ if (it == _models.end())
+ return result;
+
+ auto &model = *it;
+
+ switch (role) {
+ case NodeRole::Type:
+ result = model->name();
+ break;
+
+ case NodeRole::Position:
+ result = _nodeGeometryData[nodeId].pos;
+ break;
+
+ case NodeRole::Size:
+ result = _nodeGeometryData[nodeId].size;
+ break;
+
+ case NodeRole::CaptionVisible:
+ result = model->captionVisible();
+ break;
+
+ case NodeRole::Caption:
+ result = model->caption();
+ break;
+
+ case NodeRole::Style: {
+ //auto style = StyleCollection::nodeStyle();
+ //result = style.toJson().toVariantMap();
+ } break;
+
+ case NodeRole::InternalData: {
+ QJsonObject nodeJson;
+
+ //nodeJson["internal-data"] = _models[nodeId]->save();
+
+ result = nodeJson.toVariantMap();
+ break;
+ }
+
+ case NodeRole::InPortCount:
+ result = model->nPorts(PortType::In);
+ break;
+
+ case NodeRole::OutPortCount:
+ result = model->nPorts(PortType::Out);
+ break;
+
+ case NodeRole::Widget: {
+ auto w = model->embeddedWidget();
+ result = QVariant::fromValue(w);
+ } break;
+ }*/
+
+ return result;
+}
+
+QJsonObject FixedPortsModel::saveNode(QUuid const nodeId) const
+{
+ QJsonObject nodeJson;
+
+ nodeJson["id"] = nodeId.toString();
+
+ nodeJson["type"] = _nodeItem[nodeId]->getItemType();
+
+ {
+ QPointF const pos = nodeData(nodeId, NodeRole::Position).value();
+
+ QJsonObject posJson;
+ posJson["x"] = pos.x();
+ posJson["y"] = pos.y();
+ nodeJson["position"] = posJson;
+ }
+
+ return nodeJson;
+}
+
+void FixedPortsModel::saveNode(int nPageId)
+{
+ for(auto &pData:_nodeData)
+ {
+ if(pData->prepareDelete())
+ {
+ DataBase::GetInstance()->deleteComponent(pData->uuid().toString());
+ continue;
+ }
+ if(pData->dataChanged())
+ {
+ bool exist = DataBase::GetInstance()->componentExist(pData->uuid().toString());
+ if(exist) //已存在更新
+ {
+ DataBase::GetInstance()->updateComponent(pData->uuid(),pData->tag(),pData->name(),pData->context());
+ int type = pData->type();
+ if(type == GIT_itemRect)
+ {
+ ElectricSvgItemRect_Property* pro = dynamic_cast(pData);
+ if(pro)
+ {
+ DataBase::GetInstance()->updateBus_stability(pro->component_id(),pro->getResistance(),pro->getAnchor_v(),pro->getUv_alarm(),pro->getOv_alarm(),pro->getAnchor_i(),pro->getUi_alarm(),pro->getOi_alarm(),1);
+ }
+ }
+ }
+ else
+ {
+ DataBase::GetInstance()->insertComponent(pData->uuid(),pData->path(),pData->tag(),pData->name(),pData->description(),pData->grid(),pData->zone(),pData->station(),pData->type(),true,pData->state(),pData->connectedBus(),pData->label(),pData->context(),nPageId,1);
+ int type = pData->type();
+ if(type == GIT_itemRect)
+ {
+ ElectricSvgItemRect_Property* pro = dynamic_cast(pData);
+ if(pro)
+ {
+ componentInfo info = DataBase::GetInstance()->getComponentInfoByUuid(pData->uuid().toString());
+ DataBase::GetInstance()->insertBus_stability(info.id,pro->getResistance(),pro->getAnchor_v(),pro->getUv_alarm(),pro->getOv_alarm(),pro->getAnchor_i(),pro->getUi_alarm(),pro->getOi_alarm(),1);
+ }
+ }
+ }
+ }
+ }
+
+ //todo:再循环一遍删除待删除项
+}
+
+void FixedPortsModel::onSignal_ifExits(QUuid id,const QString& str,int type,GraphicsBaseItem* pitem)
+{
+ bool exist = false;
+ BaseProperty* pData = nullptr;
+ for(auto pro:_nodeData)
+ {
+ if(pro->tag() == str)
+ {
+ pData = pro;
+ exist = true;
+ break;
+ }
+ }
+ if(exist) //已存在,将发出信号的item绑定到此data
+ {
+ if(_nodeItem.contains(id)) //发出信号对象id与data对象id相同,已绑定,不做响应
+ return;
+ QMessageBox msgBox;
+ msgBox.setText(QString::fromWCharArray(L"提示"));
+ msgBox.setInformativeText(QString::fromWCharArray(L"此名称模型已存在,是否替换?"));
+ msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
+ msgBox.setDefaultButton(QMessageBox::Cancel);
+ int ret = msgBox.exec();
+ switch (ret) {
+ case QMessageBox::Ok:
+ {
+ //todo:断开原来的连接关系
+ pitem->setProperty(pData);
+ pitem->setItemId(pData->uuid());
+ _nodeItem.take(id);
+ _nodeItem.insert(pData->uuid(),pitem);
+ }
+ break;
+ case QMessageBox::Cancel:
+ // Cancel was clicked
+ break;
+ default:
+ // should never be reached
+ break;
+ }
+ }
+ else //创建新data并绑定
+ {
+ BaseProperty* pItem = addNodeData(id,type,str);
+ if(pItem)
+ {
+ pitem->setProperty(pItem);
+ pItem->setDataChanged(true); //数据状态改变
+ }
+ }
+}
+
+
+void FixedPortsModel::onTimeOut()
+{
+ _Interface->getPointData("i");
+ _Interface->getPointData("v");
+}
+
+void FixedPortsModel::onSignal_GetPointData(QString type,QMap map)
+{
+ if(map.size() == 1) //实时数据
+ {
+ double d = map.first();
+
+ for(auto pro:_nodeData) //demo版本只有一个数据
+ {
+ int t = pro->type();
+ if(t == GIT_itemRect)
+ {
+ //todo:根据id匹配数据
+ auto p = dynamic_cast(pro);
+ if(p)
+ {
+ if(type == QString("v"))
+ p->setVolt(d);
+ else if(type == QString("i"))
+ p->setElec(d);
+
+ p->notifyUpdate(); //通知更新
+ }
+ }
+ }
+ }
+}
+
+void FixedPortsModel::startHttpRequest()
+{
+ if(_timer)
+ {
+ _timer->setInterval(1000);
+ _timer->start();
+ }
+}
+
+QWidget* FixedPortsModel::getTopWidget()
+{
+ return dynamic_cast(_widget);
+}
+
diff --git a/source/graphicsItem/electricConnectLineItem.cpp b/diagramCavas/source/graphicsItem/electricConnectLineItem.cpp
similarity index 98%
rename from source/graphicsItem/electricConnectLineItem.cpp
rename to diagramCavas/source/graphicsItem/electricConnectLineItem.cpp
index 2cf814b..3e735f4 100644
--- a/source/graphicsItem/electricConnectLineItem.cpp
+++ b/diagramCavas/source/graphicsItem/electricConnectLineItem.cpp
@@ -376,7 +376,7 @@ void ElectricConnectLineItem::calculatePath()
m_boundingRect = m_points.boundingRect();
}
-void ElectricConnectLineItem::updateConnection(int callerId,QPointF pos)
+void ElectricConnectLineItem::updateConnection(QUuid callerId,QPointF pos)
{
//qDebug()<
+#include
+#include
+
+ElectricSvgItemBus::ElectricSvgItemBus(const QRect &rect, QGraphicsItem *parent)
+ : ElectricSvgItem(rect,parent)
+{
+ loadSvg(":/images/element/svg_bus.svg");
+ setHandleIfShow(H_textCaption,false);
+ setHandleVisible(false);
+ setFunctionHandleIfShow(false);
+ setFunctionHandleEnaable(false);
+ setHandleEnaable(H_right,true);
+ setHandleEnaable(H_left,true);
+}
+
+ElectricSvgItemBus::~ElectricSvgItemBus()
+{
+
+}
+
+void ElectricSvgItemBus::updateHandles()
+{
+ ElectricSvgItem::updateHandles();
+}
+
+void ElectricSvgItemBus::updateConnectData()
+{
+ QJsonObject obj;
+ QJsonArray arr;
+ if(_property)
+ {
+ for(auto ptr:m_mapPort)
+ {
+ if(ptr->connected())
+ {
+ QJsonObject port;
+ port["portId"] = ptr->getTag();
+ auto pLine = ptr->getConnectPtr();
+ port["connectedItem"] = pLine->getOppositeId(m_itemId).toString();
+ port["x"] = ptr->pos().x();
+ port["y"] = ptr->pos().y();
+ arr.push_back(port);
+ }
+ }
+
+ obj["port"] = arr;
+ _property->setContext(obj);
+ }
+}
+
+void ElectricSvgItemBus::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+{
+ ElectricSvgItem::paint(painter,option,widget);
+}
+
+/************************************************************************/
+
+ElectricSvgItemBus_Property::ElectricSvgItemBus_Property(QObject* parent)
+ :BaseProperty(parent)
+{
+
+}
+
+ElectricSvgItemBus_Property::~ElectricSvgItemBus_Property()
+{
+
+}
diff --git a/diagramCavas/source/graphicsItem/electricSvgItemRect.cpp b/diagramCavas/source/graphicsItem/electricSvgItemRect.cpp
new file mode 100644
index 0000000..8f1a49d
--- /dev/null
+++ b/diagramCavas/source/graphicsItem/electricSvgItemRect.cpp
@@ -0,0 +1,154 @@
+#include "graphicsItem/electricSvgItemRect.h"
+#include "graphicsItem/itemPort.h"
+
+#include
+#include
+#include
+#include
+
+ElectricSvgItemRect::ElectricSvgItemRect(const QRect &rect, QGraphicsItem *parent)
+ : ElectricSvgItem(rect,parent)
+ ,_pDlg(nullptr)
+{
+ loadSvg(":/images/element/svg_rect.svg");
+ setHandleIfShow(H_textCaption,false);
+ setHandleIfShow(H_textCurrent,false);
+ setHandleIfShow(h_textVoltage,false);
+ setHandleVisible(false);
+ setFunctionHandleIfShow(false);
+ setFunctionHandleEnaable(false);
+
+ //入线口
+ ItemPort* pHandle1 = new ItemPort(this);
+ pHandle1->setType(T_lineIn);
+ pHandle1->setTag(H_connect);
+ pHandle1->setPortPos(P_top);
+ pHandle1->setParent(this);
+ m_vecHanle.insert(H_connect,pHandle1);
+ //出线口
+ ItemPort* pHandle2 = new ItemPort(this);
+ pHandle2->setType(T_lineOut);
+ pHandle2->setTag(H_connect+1);
+ pHandle2->setPortPos(P_down);
+ pHandle2->setParent(this);
+ m_vecHanle.insert(H_connect+1,pHandle2);
+
+ m_dRatioX = 0.5;
+
+ m_mapPort.insert(QString::number(_portId++),pHandle1);
+ m_mapPort.insert(QString::number(_portId++),pHandle2);
+
+ qRegisterMetaType("PropertyInfo"); //注册自定义数据类型
+}
+
+ElectricSvgItemRect::~ElectricSvgItemRect()
+{
+
+}
+
+
+void ElectricSvgItemRect::updateHandles()
+{
+ ElectricSvgItem::updateHandles();
+ if( m_vecHanle.contains(H_connect))
+ {
+ const QRectF& boundingRect = this->boundingRect();
+
+ if(m_vecHanle.contains(H_connect))
+ {
+ m_vecHanle[H_connect]->move(boundingRect.right() - boundingRect.width() * m_dRatioX, boundingRect.top());
+ }
+
+ if(m_vecHanle.contains(H_connect + 1))
+ {
+ m_vecHanle[H_connect + 1]->move(boundingRect.right() - boundingRect.width() * m_dRatioX, boundingRect.bottom());
+ }
+ }
+}
+
+void ElectricSvgItemRect::onPropertyChanged(PropertyInfo inf)
+{
+ auto p = getProperty();
+ if(p)
+ {
+ p->setResistance(inf.resistance);
+ p->setAnchor_v(inf.anchor_v);
+ p->setUv_alarm(inf.uv_alarm);
+ p->setOv_alarm(inf.ov_alarm);
+ p->setAnchor_i(inf.anchor_i);
+ p->setUi_alarm(inf.ui_alarm);
+ p->setOi_alarm(inf.oi_alarm);
+ p->setDataChanged(true);
+ }
+}
+
+void ElectricSvgItemRect::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+{
+ ElectricSvgItem::paint(painter,option,widget);
+}
+
+void ElectricSvgItemRect::showPropertyDlg(QWidget* p)
+{
+ auto pro = getProperty();
+ if(pro)
+ {
+ PropertyInfo data;
+ data.resistance = pro->getResistance();
+ data.anchor_v = pro->getAnchor_v();
+ data.uv_alarm = pro->getUv_alarm();
+ data.ov_alarm = pro->getOv_alarm();
+ data.anchor_i = pro->getAnchor_i();
+ data.ui_alarm = pro->getUi_alarm();
+ data.oi_alarm = pro->getOi_alarm();
+ if(_pDlg)
+ {
+ _pDlg->show();
+ _pDlg->synchroniseData(data);
+ }
+ else
+ {
+ _pDlg = new ItemPropertyDlg(p);
+ connect(_pDlg,&ItemPropertyDlg::PropertyChange,this,&ElectricSvgItemRect::onPropertyChanged);
+ _pDlg->show();
+ _pDlg->synchroniseData(data);
+ }
+
+ }
+ else
+ {
+ //todo:没有关联数据,提示
+ qDebug()<<"no associate data";
+ }
+}
+
+void ElectricSvgItemRect::updateByProperty()
+{
+ auto p = dynamic_cast(_property);
+ if(p)
+ {
+ setLabelTag(p->tag());
+ setLabelVoltage(QString::number(p->getVolt()));
+ setLabelCurrent(QString::number(p->getElec()));
+ scene()->update();
+ }
+}
+/****************************************************************/
+
+ElectricSvgItemRect_Property::ElectricSvgItemRect_Property(QObject* parent)
+ :BaseProperty(parent)
+{
+ electricity = 0;
+ voltage = 0;
+ resistance = 2; //电阻
+ anchor_v = false; //是否锚定电压
+ uv_alarm = 90; //电压下限
+ ov_alarm = 110; //电压上限
+ anchor_i = false; //是否锚定电流
+ ui_alarm = 45; //电流下限
+ oi_alarm = 55; //电流上限
+}
+
+ElectricSvgItemRect_Property::~ElectricSvgItemRect_Property()
+{
+
+}
diff --git a/source/graphicsItem/electricSvgItemTriangle.cpp b/diagramCavas/source/graphicsItem/electricSvgItemTriangle.cpp
similarity index 86%
rename from source/graphicsItem/electricSvgItemTriangle.cpp
rename to diagramCavas/source/graphicsItem/electricSvgItemTriangle.cpp
index adf9553..db198f4 100644
--- a/source/graphicsItem/electricSvgItemTriangle.cpp
+++ b/diagramCavas/source/graphicsItem/electricSvgItemTriangle.cpp
@@ -18,18 +18,21 @@ ElectricSvgItemTriangle::ElectricSvgItemTriangle(const QRect &rect, QGraphicsIte
pHandle1->setType(T_lineOut);
pHandle1->setTag(H_connect);
pHandle1->setPortPos(P_top);
+ pHandle1->setParent(this);
m_vecHanle.insert(H_connect,pHandle1);
//出线口
ItemPort* pHandle2 = new ItemPort(this);
pHandle2->setType(T_lineIn);
pHandle2->setTag(H_connect+1);
pHandle2->setPortPos(P_down);
+ pHandle2->setParent(this);
m_vecHanle.insert(H_connect+1,pHandle2);
ItemPort* pHandle3 = new ItemPort(this);
pHandle3->setType(T_lineIn);
pHandle3->setTag(H_connect+2);
pHandle3->setPortPos(P_down);
+ pHandle3->setParent(this);
m_vecHanle.insert(H_connect+2,pHandle3);
m_dTopRatioX = 0.5;
@@ -73,3 +76,15 @@ void ElectricSvgItemTriangle::paint(QPainter* painter, const QStyleOptionGraphic
ElectricSvgItem::paint(painter,option,widget);
}
+/***********************************************************/
+ElectricSvgItemTriangle_Property::ElectricSvgItemTriangle_Property(QObject* parent)
+ :BaseProperty(parent)
+{
+
+}
+
+ElectricSvgItemTriangle_Property::~ElectricSvgItemTriangle_Property()
+{
+
+}
+
diff --git a/source/graphicsItem/graphicsBaseItem.cpp b/diagramCavas/source/graphicsItem/graphicsBaseItem.cpp
similarity index 60%
rename from source/graphicsItem/graphicsBaseItem.cpp
rename to diagramCavas/source/graphicsItem/graphicsBaseItem.cpp
index 13205b0..fd8e221 100644
--- a/source/graphicsItem/graphicsBaseItem.cpp
+++ b/diagramCavas/source/graphicsItem/graphicsBaseItem.cpp
@@ -2,15 +2,19 @@
#include "graphicsItem/handleRect.h"
#include "graphicsItem/handleText.h"
#include "graphicsItem/itemPort.h"
+#include "graphicsItem/electricConnectLineItem.h"
#include
+#include
GraphicsBaseItem::GraphicsBaseItem(QGraphicsItem *parent)
: AbstractShapeType(parent)
+ ,_property(nullptr)
{
m_type = T_item;
_portId = 1;
_lastPort = -1;
+ _itemChanged = false;
//初始化缩放操作用的handle
//m_vecHanle.reserve(H_left);
for(int i = H_leftTop; i <= H_left; i++)
@@ -31,10 +35,28 @@ GraphicsBaseItem::GraphicsBaseItem(QGraphicsItem *parent)
HandleText* pHandle = new HandleText(this);
pHandle->setType(T_text);
pHandle->setTag(H_textCaption);
- pHandle->setText(QString::number(123456));
- pHandle->setPos(30,-20);
+ pHandle->setText(QString("uname"));
+ pHandle->setPos(30,-30);
pHandle->setParent(this);
m_vecHanle.insert(H_textCaption,pHandle);
+ connect(pHandle,&HandleText::editFinish,this,&GraphicsBaseItem::onEditNameFinish);
+
+ HandleText* pCurrent = new HandleText(this); //电流
+ pCurrent->setEditable(false);
+ pCurrent->setType(T_text);
+ pCurrent->setTag(H_textCurrent);
+ pCurrent->setText(QString("I:"));
+ pCurrent->setPos(-30,-30);
+ pCurrent->setParent(this);
+ m_vecHanle.insert(H_textCurrent,pCurrent);
+
+ HandleText* pVoltage = new HandleText(this); //电压
+ pVoltage->setType(T_text);
+ pVoltage->setTag(h_textVoltage);
+ pVoltage->setText(QString("V:"));
+ pVoltage->setPos(-30,30);
+ pVoltage->setParent(this);
+ m_vecHanle.insert(h_textVoltage,pVoltage);
setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
@@ -128,6 +150,36 @@ void GraphicsBaseItem::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
Q_UNUSED(event);
}
+void GraphicsBaseItem::setLabelTag(const QString& name)
+{
+ m_vecHanle[H_textCaption]->setText(name);
+}
+
+QString GraphicsBaseItem::getLabelTag() const
+{
+ return m_vecHanle[H_textCaption]->getText();
+}
+
+void GraphicsBaseItem::setLabelCurrent(const QString& str)
+{
+ m_vecHanle[H_textCurrent]->setText(str);
+}
+
+QString GraphicsBaseItem::getLabelCurrent() const
+{
+ return m_vecHanle[H_textCurrent]->getText();
+}
+
+void GraphicsBaseItem::setLabelVoltage(const QString& str)
+{
+ m_vecHanle[h_textVoltage]->setText(str);
+}
+
+QString GraphicsBaseItem::getLabelVoltage() const
+{
+ return m_vecHanle[h_textVoltage]->getText();
+}
+
int GraphicsBaseItem::addPort(PortState typ,QPointF vec)
{
int ntagId = -1;
@@ -143,6 +195,7 @@ int GraphicsBaseItem::addPort(PortState typ,QPointF vec)
pPort->setTag(ntagId);
m_vecHanle.insert(ntagId,pPort);
pPort->setPos(vec);
+ pPort->setParent(this);
m_mapPort.insert(QString::number(_portId++),pPort);
}
@@ -158,6 +211,7 @@ void GraphicsBaseItem::addPort(PortState typ,int ntagId,QPointF vec)
pPort->setTag(ntagId);
m_vecHanle.insert(ntagId,pPort);
pPort->setPos(vec);
+ pPort->setParent(this);
m_mapPort.insert(QString::number(_portId++),pPort);
}
@@ -184,3 +238,86 @@ ItemControlHandle* GraphicsBaseItem::getHandlePtr(int n) const
}
return nullptr;
}
+
+void GraphicsBaseItem::updateByProperty()
+{
+ if(_property)
+ {
+ setLabelTag(_property->tag());
+ }
+}
+
+void GraphicsBaseItem::setProperty(BaseProperty* p)
+{
+ if(_property) //已经有对象
+ {
+ disconnect(_property,&BaseProperty::updateData,this,&GraphicsBaseItem::onUpdateData); //断开老数据
+ }
+ connect(p,&BaseProperty::updateData,this,&GraphicsBaseItem::onUpdateData);
+ _property = p;
+}
+
+void GraphicsBaseItem::unbindProperty()
+{
+ _property = nullptr;
+}
+
+void GraphicsBaseItem::showPropertyDlg(QWidget* p)
+{
+
+}
+
+void GraphicsBaseItem::updateConnectData()
+{
+ QJsonObject obj;
+ QJsonArray arr;
+ if(_property)
+ {
+ for(auto ptr:m_mapPort)
+ {
+ if(ptr->connected())
+ {
+ QJsonObject port;
+ port["portId"] = ptr->getTag();
+ auto pLine = ptr->getConnectPtr();
+ port["connectedItem"] = pLine->getOppositeId(m_itemId).toString();
+ arr.push_back(port);
+ }
+ }
+
+ obj["port"] = arr;
+ _property->setContext(obj);
+ }
+}
+
+void GraphicsBaseItem::onEditNameFinish(const QString& str)
+{
+ emit ifExist(m_itemId,str,m_Itemtype,this);
+}
+
+void GraphicsBaseItem::onUpdateData()
+{
+ updateByProperty();
+}
+/****************************属性****************************/
+
+BaseProperty::BaseProperty(QObject* parent)
+ : QObject(parent)
+{
+ nType = 0; //设备类型
+ nPageId = 0; //暂定为创建本数据的图Id(待定)
+ bInService = true;
+ nState = 1;
+
+ _dataChanged = false;
+ _prepareDelete = false;
+
+ sGrid=QString("1"); //暂时修改,数据库字段不为空
+ sZone=QString("1");
+ sStation=QString("1");
+}
+
+BaseProperty::~BaseProperty()
+{
+
+}
diff --git a/source/graphicsItem/graphicsItemGroup.cpp b/diagramCavas/source/graphicsItem/graphicsItemGroup.cpp
similarity index 100%
rename from source/graphicsItem/graphicsItemGroup.cpp
rename to diagramCavas/source/graphicsItem/graphicsItemGroup.cpp
diff --git a/source/graphicsItem/graphicsPolygonItem.cpp b/diagramCavas/source/graphicsItem/graphicsPolygonItem.cpp
similarity index 100%
rename from source/graphicsItem/graphicsPolygonItem.cpp
rename to diagramCavas/source/graphicsItem/graphicsPolygonItem.cpp
diff --git a/source/graphicsItem/graphicsRectItem.cpp b/diagramCavas/source/graphicsItem/graphicsRectItem.cpp
similarity index 100%
rename from source/graphicsItem/graphicsRectItem.cpp
rename to diagramCavas/source/graphicsItem/graphicsRectItem.cpp
diff --git a/source/graphicsItem/handleRect.cpp b/diagramCavas/source/graphicsItem/handleRect.cpp
similarity index 100%
rename from source/graphicsItem/handleRect.cpp
rename to diagramCavas/source/graphicsItem/handleRect.cpp
diff --git a/source/graphicsItem/handleText.cpp b/diagramCavas/source/graphicsItem/handleText.cpp
similarity index 94%
rename from source/graphicsItem/handleText.cpp
rename to diagramCavas/source/graphicsItem/handleText.cpp
index bd67df2..260b739 100644
--- a/source/graphicsItem/handleText.cpp
+++ b/diagramCavas/source/graphicsItem/handleText.cpp
@@ -26,6 +26,11 @@ void HandleText::setText(QString str)
_boundingRect.moveTo(QPointF(-w*0.5,-h*0.5));
}
+QString HandleText::getText() const
+{
+ return _text;
+}
+
void HandleText::creatEditor()
{
if(!_editable)
@@ -48,6 +53,7 @@ void HandleText::creatEditor()
connect(editor, &QLineEdit::editingFinished, this, [this, editor]() {
//_text = editor->text();
setText(editor->text());
+ emit editFinish(editor->text());
_proxy->setVisible(false);
});
}
diff --git a/source/graphicsItem/itemControlHandle.cpp b/diagramCavas/source/graphicsItem/itemControlHandle.cpp
similarity index 88%
rename from source/graphicsItem/itemControlHandle.cpp
rename to diagramCavas/source/graphicsItem/itemControlHandle.cpp
index f5f83ec..8082c62 100644
--- a/source/graphicsItem/itemControlHandle.cpp
+++ b/diagramCavas/source/graphicsItem/itemControlHandle.cpp
@@ -42,3 +42,12 @@ void ItemControlHandle::move(double x, double y)
{
setPos(x, y);
}
+
+void ItemControlHandle::setText(QString s)
+{
+
+}
+QString ItemControlHandle::getText() const
+{
+ return QString();
+}
diff --git a/source/graphicsItem/itemPort.cpp b/diagramCavas/source/graphicsItem/itemPort.cpp
similarity index 100%
rename from source/graphicsItem/itemPort.cpp
rename to diagramCavas/source/graphicsItem/itemPort.cpp
diff --git a/diagramCavas/source/itemPropertyDlg.cpp b/diagramCavas/source/itemPropertyDlg.cpp
new file mode 100644
index 0000000..da80c47
--- /dev/null
+++ b/diagramCavas/source/itemPropertyDlg.cpp
@@ -0,0 +1,53 @@
+#include "itemPropertyDlg.h"
+#include "ui_itemPropertyDlg.h"
+
+ItemPropertyDlg::ItemPropertyDlg(QWidget *parent)
+ : QDialog(parent)
+ , ui(new Ui::itemPropertyDlg)
+{
+ ui->setupUi(this);
+ this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
+ connect(ui->btn_ok_jianGe,&QPushButton::clicked,this,&ItemPropertyDlg::onOkClicked);
+ connect(ui->btn_apply_jianGe,&QPushButton::clicked,this,&ItemPropertyDlg::onApplyClicked);
+ connect(ui->btn_cancel_jianGe,&QPushButton::clicked,this,&ItemPropertyDlg::onCancelClicked);
+}
+
+ItemPropertyDlg::~ItemPropertyDlg()
+{
+ delete ui;
+}
+
+void ItemPropertyDlg::synchroniseData(const PropertyInfo pro)
+{
+ ui->sp_DianZu->setValue(pro.resistance);
+ ui->cb_MaoDingDianYa->setChecked(pro.anchor_v);
+ ui->sp_DianYaXiaXian->setValue(pro.uv_alarm);
+ ui->sp_DianYaShangXian->setValue(pro.ov_alarm);
+ ui->cb_MaoDingDianLiu->setChecked(pro.anchor_i);
+ ui->sp_DianLiuXiaXian->setValue(pro.ui_alarm);
+ ui->sp_DianLiuShangXian->setValue(pro.oi_alarm);
+}
+
+void ItemPropertyDlg::onOkClicked()
+{
+ onApplyClicked();
+ hide();
+}
+
+void ItemPropertyDlg::onCancelClicked()
+{
+ hide();
+}
+
+void ItemPropertyDlg::onApplyClicked()
+{
+ PropertyInfo info;
+ info.resistance = ui->sp_DianZu->value();
+ info.anchor_v = ui->cb_MaoDingDianYa->isChecked();
+ info.uv_alarm = ui->sp_DianYaXiaXian->value();
+ info.ov_alarm = ui->sp_DianYaShangXian->value();
+ info.anchor_i = ui->cb_MaoDingDianLiu->isChecked();
+ info.ui_alarm = ui->sp_DianLiuXiaXian->value();
+ info.oi_alarm = ui->sp_DianLiuShangXian->value();
+ emit PropertyChange(info);
+}
diff --git a/source/statusBar.cpp b/diagramCavas/source/statusBar.cpp
similarity index 100%
rename from source/statusBar.cpp
rename to diagramCavas/source/statusBar.cpp
diff --git a/source/util/baseSelector.cpp b/diagramCavas/source/util/baseSelector.cpp
similarity index 96%
rename from source/util/baseSelector.cpp
rename to diagramCavas/source/util/baseSelector.cpp
index e9f0a07..c16f0c8 100644
--- a/source/util/baseSelector.cpp
+++ b/diagramCavas/source/util/baseSelector.cpp
@@ -11,11 +11,10 @@ QPointF BaseSelector::ms_ptMouseDown(0.0,0.0);
QPointF BaseSelector::ms_ptMouseLast(0.0,0.0);
double BaseSelector::ms_dAngleMouseDownToItem = 0.0;
int BaseSelector::ms_nDragHandle = 0;
-uint BaseSelector::_Id = 0;
-ItemMap BaseSelector::m_graphicsItem;
-BaseSelector::BaseSelector(QObject *parent)
- : QObject(parent)
+BaseSelector::BaseSelector(FixedPortsModel* model,QObject *parent)
+ : _model(model)
+ ,QObject(parent)
{
m_type = ST_base;
m_opMode = OM_none;
@@ -31,6 +30,7 @@ void BaseSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, DesignerScen
if (event->button() != Qt::LeftButton)
return;
+ _model->activateModel(); //激活当前窗口
ms_ptMouseDown = event->scenePos();
ms_ptMouseLast = event->scenePos();
@@ -350,7 +350,7 @@ void BaseSelector::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, Design
{
ms_nDragHandle = pHandle->getTag();
//ms_nDragHandle = item->collidesWithHandle(event->scenePos());
- if(ms_nDragHandle >= H_textCaption && ms_nDragHandle < H_connect) //移动文本
+ if(ms_nDragHandle >= H_textCaption && ms_nDragHandle < H_connect) //是文字节点
{
HandleText* pText = qgraphicsitem_cast(pHandle);
if(pText)
@@ -363,6 +363,18 @@ void BaseSelector::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, Design
}
}
}
+ else if(items.count() == 1) //不是文字节点
+ {
+ GraphicsBaseItem* item = qgraphicsitem_cast(items.first());
+ if(item)
+ {
+ GraphicsItemType tpe = item->getItemType();
+ if(tpe != GIT_link)
+ {
+ item->showPropertyDlg(_model->getTopWidget());
+ }
+ }
+ }
}
void BaseSelector::setCursor(DesignerScene *scene, const QCursor &cursor)
diff --git a/source/util/connectingSelector.cpp b/diagramCavas/source/util/connectingSelector.cpp
similarity index 89%
rename from source/util/connectingSelector.cpp
rename to diagramCavas/source/util/connectingSelector.cpp
index 78e14ad..e5e7f4f 100644
--- a/source/util/connectingSelector.cpp
+++ b/diagramCavas/source/util/connectingSelector.cpp
@@ -6,8 +6,8 @@
#include
#include
-ConnectingSelector::ConnectingSelector(QObject *parent)
- : BaseSelector(parent)
+ConnectingSelector::ConnectingSelector(FixedPortsModel* model,QObject *parent)
+ : BaseSelector(model,parent)
,m_pConnectingItem(nullptr)
,m_pTouchedItem(nullptr)
{
@@ -89,12 +89,12 @@ void ConnectingSelector::setTargetHighLight(bool val)
void ConnectingSelector::createConnectLline(GraphicsBaseItem* connectingItem,GraphicsBaseItem* touchedItem,DesignerScene* scene)
{
ElectricConnectLineItem* pItem = new ElectricConnectLineItem();
- pItem->setItemId(++_Id);
+ pItem->setItemId(QUuid::createUuid());
pItem->setItemType(GIT_link);
scene->addItem(pItem);
ItemPort* ptSrc = connectingItem->getPortPtr(ms_nDragHandle);
- int srcId = connectingItem->itemId();
+ QUuid srcId = connectingItem->itemId();
int srcPort = ptSrc->getTag();
HandleType srcType = ptSrc->getType();
PortPos srcPos = ptSrc->portPos();
@@ -120,7 +120,7 @@ void ConnectingSelector::createConnectLline(GraphicsBaseItem* connectingItem,Gra
if(ptDest != nullptr)
{
- int destId = touchedItem->itemId();
+ QUuid destId = touchedItem->itemId();
int destPort = ptDest->getTag();
HandleType destType = ptDest->getType();
PortPos destPos = ptDest->portPos();
@@ -129,7 +129,15 @@ void ConnectingSelector::createConnectLline(GraphicsBaseItem* connectingItem,Gra
pItem->setConnection(Connection(srcId,srcPort,srcType,srcPos,destId,destPort,destType,destPos));
ptDest->setConnect(pItem);
- m_graphicsItem[sceneName()].insert(QString::number(pItem->itemId()),pItem); //插入连接线到总表
+ _model->addNodeItem(pItem->itemId(),pItem);
+ auto srcParent = ptSrc->getParentPtr();
+ auto destParent = ptDest->getParentPtr();
+
+ srcParent->setItemChanged(true);
+ destParent->setItemChanged(true);
+ //srcParent->updateConnectData();
+ //destParent->updateConnectData();
+ //m_graphicsItem[sceneName()].insert(QString::number(pItem->itemId()),pItem); //插入连接线到总表
}
}
@@ -175,8 +183,8 @@ void ConnectingSelector::mouseMoveEvent(QGraphicsSceneMouseEvent* event, Designe
GraphicsBaseItem* item = dynamic_cast(items.first());
if(item)
{
- int n1 = item->itemId();
- int n2 = m_pConnectingItem->itemId();
+ QUuid n1 = item->itemId();
+ QUuid n2 = m_pConnectingItem->itemId();
if(n1 != n2) //判断两个对象是否相同
{
m_pTouchedItem = item;
diff --git a/source/util/creatingSelector.cpp b/diagramCavas/source/util/creatingSelector.cpp
similarity index 91%
rename from source/util/creatingSelector.cpp
rename to diagramCavas/source/util/creatingSelector.cpp
index 01f2921..2e9eb58 100644
--- a/source/util/creatingSelector.cpp
+++ b/diagramCavas/source/util/creatingSelector.cpp
@@ -9,14 +9,13 @@
#include
-CreatingSelector::CreatingSelector(QObject *parent)
- : BaseSelector(parent)
+CreatingSelector::CreatingSelector(FixedPortsModel* model,QObject *parent)
+ : BaseSelector(model,parent)
{
m_type = ST_cerating;
m_creatingMethod = CM_drag;
m_pCreatingItem = nullptr;
m_scalBasePoint = QPointF();
- _Id = 0;
}
CreatingSelector::~CreatingSelector()
{
@@ -59,7 +58,7 @@ void CreatingSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, Designer
{
m_creatingMethod = CM_click;
m_pCreatingItem = new ElectricSvgItemBus(QRect(-100, -3, 200, 6));
- m_pCreatingItem->setItemId(++_Id);
+ m_pCreatingItem->setItemId(QUuid::createUuid());
m_pCreatingItem->setItemType(GIT_bus);
m_pCreatingItem->editShape(ms_nDragHandle, ms_ptMouseLast);
emit setWorkingSelector(ST_base);
@@ -69,7 +68,7 @@ void CreatingSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, Designer
{
m_creatingMethod = CM_click;
m_pCreatingItem = new ElectricSvgItemRect(QRect(-15, -15, 30, 30));
- m_pCreatingItem->setItemId(++_Id);
+ m_pCreatingItem->setItemId(QUuid::createUuid());
m_pCreatingItem->setItemType(GIT_itemRect);
m_pCreatingItem->editShape(ms_nDragHandle, ms_ptMouseLast);
emit setWorkingSelector(ST_base);
@@ -79,7 +78,7 @@ void CreatingSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, Designer
{
m_creatingMethod = CM_click;
m_pCreatingItem = new ElectricSvgItemTriangle(QRect(-15, -15, 30, 30));
- m_pCreatingItem->setItemId(++_Id);
+ m_pCreatingItem->setItemId(QUuid::createUuid());
m_pCreatingItem->setItemType(GIT_itemTri);
m_pCreatingItem->editShape(ms_nDragHandle, ms_ptMouseLast);
emit setWorkingSelector(ST_base);
@@ -94,6 +93,7 @@ void CreatingSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, Designer
m_pCreatingItem->setPos(event->scenePos());
m_pCreatingItem->setSelected(true);
scene->addItem(m_pCreatingItem);
+ m_pCreatingItem->setItemChanged(true);
if(m_creatingMethod == CM_drag)
{
@@ -110,7 +110,8 @@ void CreatingSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, Designer
//创建时添加了第一个点,紧接着再次添加第二点,然后从第二个点开始进行移动绘制
m_pCreatingItem->addPoint(ms_ptMouseDown);
ms_nDragHandle = m_pCreatingItem->handleCount();
- m_graphicsItem[sceneName()].insert(QString::number(m_pCreatingItem->itemId()),m_pCreatingItem); //插入数据到总表
+ //m_graphicsItem[sceneName()].insert(QString::number(m_pCreatingItem->itemId()),m_pCreatingItem); //插入数据到总表
+ _model->addNodeItem(m_pCreatingItem->itemId(),m_pCreatingItem);
m_pCreatingItem = nullptr; //先舍弃多次点击创建对象241124 by
}
}
diff --git a/source/util/editingSelector.cpp b/diagramCavas/source/util/editingSelector.cpp
similarity index 92%
rename from source/util/editingSelector.cpp
rename to diagramCavas/source/util/editingSelector.cpp
index c991e4a..f07c5d0 100644
--- a/source/util/editingSelector.cpp
+++ b/diagramCavas/source/util/editingSelector.cpp
@@ -3,8 +3,8 @@
#include
-EditingSelector::EditingSelector(QObject *parent)
- : BaseSelector(parent)
+EditingSelector::EditingSelector(FixedPortsModel* model,QObject *parent)
+ : BaseSelector(model,parent)
{
m_type = ST_editing;
}
diff --git a/source/util/linkMovingSelector.cpp b/diagramCavas/source/util/linkMovingSelector.cpp
similarity index 93%
rename from source/util/linkMovingSelector.cpp
rename to diagramCavas/source/util/linkMovingSelector.cpp
index 607ca3d..f40bede 100644
--- a/source/util/linkMovingSelector.cpp
+++ b/diagramCavas/source/util/linkMovingSelector.cpp
@@ -3,8 +3,8 @@
#include
#include "graphicsItem/electricConnectLineItem.h"
-LinkMovingSelector::LinkMovingSelector(QObject *parent)
- : BaseSelector(parent)
+LinkMovingSelector::LinkMovingSelector(FixedPortsModel* model,QObject *parent)
+ : BaseSelector(model,parent)
,m_pMovingLine(nullptr)
{
m_type = ST_linkMoving;
diff --git a/source/util/movingSelector.cpp b/diagramCavas/source/util/movingSelector.cpp
similarity index 93%
rename from source/util/movingSelector.cpp
rename to diagramCavas/source/util/movingSelector.cpp
index 47ef7d2..9891a9b 100644
--- a/source/util/movingSelector.cpp
+++ b/diagramCavas/source/util/movingSelector.cpp
@@ -5,8 +5,8 @@
#include
#include "graphicsItem/electricConnectLineItem.h"
-MovingSelector::MovingSelector(QObject *parent)
- : BaseSelector(parent)
+MovingSelector::MovingSelector(FixedPortsModel* model,QObject *parent)
+ : BaseSelector(model,parent)
{
m_type = ST_moving;
}
@@ -61,7 +61,7 @@ void MovingSelector::updateConnectLine(QList lst)
{
if(item->getItemType() != GIT_link)
{
- int nId = item->itemId();
+ QUuid nId = item->itemId();
for(auto pPort:item->getPorts())
{
if(pPort->connected())
diff --git a/source/util/rotationSelector.cpp b/diagramCavas/source/util/rotationSelector.cpp
similarity index 94%
rename from source/util/rotationSelector.cpp
rename to diagramCavas/source/util/rotationSelector.cpp
index 01bdeb5..cd51999 100644
--- a/source/util/rotationSelector.cpp
+++ b/diagramCavas/source/util/rotationSelector.cpp
@@ -4,8 +4,8 @@
#include
-RotationSelector::RotationSelector(QObject *parent)
- : BaseSelector(parent)
+RotationSelector::RotationSelector(FixedPortsModel* model,QObject *parent)
+ : BaseSelector(model,parent)
{
m_type = ST_rotation;
}
diff --git a/source/util/scalingSelector.cpp b/diagramCavas/source/util/scalingSelector.cpp
similarity index 95%
rename from source/util/scalingSelector.cpp
rename to diagramCavas/source/util/scalingSelector.cpp
index ceae42f..8ab0ae3 100644
--- a/source/util/scalingSelector.cpp
+++ b/diagramCavas/source/util/scalingSelector.cpp
@@ -3,8 +3,8 @@
#include
#include
-ScalingSelector::ScalingSelector(QObject *parent)
- : BaseSelector(parent)
+ScalingSelector::ScalingSelector(FixedPortsModel* model,QObject *parent)
+ : BaseSelector(model,parent)
{
m_type = ST_scaling;
m_scalBasePoint = QPointF();
diff --git a/source/util/selectorManager.cpp b/diagramCavas/source/util/selectorManager.cpp
similarity index 83%
rename from source/util/selectorManager.cpp
rename to diagramCavas/source/util/selectorManager.cpp
index aa96a6d..e77da59 100644
--- a/source/util/selectorManager.cpp
+++ b/diagramCavas/source/util/selectorManager.cpp
@@ -9,36 +9,37 @@
#include "util/connectingSelector.h"
-SelectorManager::SelectorManager(QObject *parent)
- : QObject(parent)
+SelectorManager::SelectorManager(FixedPortsModel* model,QObject *parent)
+ : _graphModel(model)
+ ,QObject(parent)
{
//创建所有的selector
- BaseSelector* baseSelector = new BaseSelector(this);
+ BaseSelector* baseSelector = new BaseSelector(model,this);
connect(baseSelector, SIGNAL(setWorkingSelector(SelectorType)), this, SLOT(onSignal_setWorkingSelector(SelectorType)));
m_vecSelectors.push_back(baseSelector);
- CreatingSelector* creatingSelector = new CreatingSelector(this);
+ CreatingSelector* creatingSelector = new CreatingSelector(model,this);
connect(creatingSelector, SIGNAL(setWorkingSelector(SelectorType)), this, SLOT(onSignal_setWorkingSelector(SelectorType)));
m_vecSelectors.push_back(creatingSelector);
- MovingSelector* movingSelector = new MovingSelector(this);
+ MovingSelector* movingSelector = new MovingSelector(model,this);
connect(movingSelector, SIGNAL(setWorkingSelector(SelectorType)), this, SLOT(onSignal_setWorkingSelector(SelectorType)));
m_vecSelectors.push_back(movingSelector);
- SubMovingSelector* subMovSelector = new SubMovingSelector(this);
+ SubMovingSelector* subMovSelector = new SubMovingSelector(model,this);
connect(subMovSelector, SIGNAL(setWorkingSelector(SelectorType)), this, SLOT(onSignal_setWorkingSelector(SelectorType)));
m_vecSelectors.push_back(subMovSelector);
- LinkMovingSelector* linkMovSelector = new LinkMovingSelector(this);
+ LinkMovingSelector* linkMovSelector = new LinkMovingSelector(model,this);
connect(linkMovSelector, SIGNAL(setWorkingSelector(SelectorType)), this, SLOT(onSignal_setWorkingSelector(SelectorType)));
m_vecSelectors.push_back(linkMovSelector);
- RotationSelector* rotationSelector = new RotationSelector(this);
+ RotationSelector* rotationSelector = new RotationSelector(model,this);
connect(rotationSelector, SIGNAL(setWorkingSelector(SelectorType)), this, SLOT(onSignal_setWorkingSelector(SelectorType)));
m_vecSelectors.push_back(rotationSelector);
- ScalingSelector* scalingSelector = new ScalingSelector(this);
+ ScalingSelector* scalingSelector = new ScalingSelector(model,this);
connect(scalingSelector, SIGNAL(setWorkingSelector(SelectorType)), this, SLOT(onSignal_setWorkingSelector(SelectorType)));
m_vecSelectors.push_back(scalingSelector);
- EditingSelector* editingSelector = new EditingSelector(this);
+ EditingSelector* editingSelector = new EditingSelector(model,this);
connect(editingSelector, SIGNAL(setWorkingSelector(SelectorType)), this, SLOT(onSignal_setWorkingSelector(SelectorType)));
m_vecSelectors.push_back(editingSelector);
- ConnectingSelector* connectingSelector = new ConnectingSelector(this);
+ ConnectingSelector* connectingSelector = new ConnectingSelector(model,this);
connect(connectingSelector, SIGNAL(setWorkingSelector(SelectorType)), this, SLOT(onSignal_setWorkingSelector(SelectorType)));
m_vecSelectors.push_back(connectingSelector);
diff --git a/source/util/subMovingSelector.cpp b/diagramCavas/source/util/subMovingSelector.cpp
similarity index 94%
rename from source/util/subMovingSelector.cpp
rename to diagramCavas/source/util/subMovingSelector.cpp
index cebe86f..88de516 100644
--- a/source/util/subMovingSelector.cpp
+++ b/diagramCavas/source/util/subMovingSelector.cpp
@@ -4,8 +4,8 @@
#include "graphicsItem/graphicsBaseItem.h"
#include "graphicsItem/handleText.h"
-SubMovingSelector::SubMovingSelector(QObject *parent)
- : BaseSelector(parent)
+SubMovingSelector::SubMovingSelector(FixedPortsModel* model,QObject *parent)
+ : BaseSelector(model,parent)
,m_pParentItem(nullptr)
{
m_type = ST_subMoving;
diff --git a/diagramCavas/ui/drawingPanel.ui b/diagramCavas/ui/drawingPanel.ui
new file mode 100644
index 0000000..d70447e
--- /dev/null
+++ b/diagramCavas/ui/drawingPanel.ui
@@ -0,0 +1,41 @@
+
+
+ drawingPanel
+
+
+
+ 0
+ 0
+ 801
+ 501
+
+
+
+ Form
+
+
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+
+
+
+
+
+
diff --git a/diagramCavas/ui/itemPropertyDlg.ui b/diagramCavas/ui/itemPropertyDlg.ui
new file mode 100644
index 0000000..3636d6d
--- /dev/null
+++ b/diagramCavas/ui/itemPropertyDlg.ui
@@ -0,0 +1,331 @@
+
+
+ itemPropertyDlg
+
+
+
+ 0
+ 0
+ 642
+ 552
+
+
+
+ Dialog
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+
+ 0
+ 20
+
+
+
+
+ 16777215
+ 20
+
+
+
+ background-color: rgb(183, 183, 183);
+
+
+
+ -
+
+
+
+
+
+
+ 10
+
+
+ 10
+
+
+ 10
+
+
+ 10
+
+
+ 10
+
+
-
+
+
+
+
+
+
+
-
+
+
+
+ 12
+
+
+
+ 间隔信息
+
+
+
+ -
+
+
+ Qt::Orientation::Vertical
+
+
+
+ 20
+ 471
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ Microsoft YaHei UI
+ 10
+ false
+ false
+
+
+
+ background-color: rgb(224, 224, 224);
+color:black;
+font: 10pt "Microsoft YaHei UI";
+
+
+
+
+ 6
+
+
+ 6
+
+
+ 6
+
+
+ 6
+
+
-
+
+
+ 间隔信息
+
+
+
-
+
+
+ 是否锚定电流
+
+
+
+ -
+
+
+ Qt::Orientation::Vertical
+
+
+
+ -
+
+
+ 90.000000000000000
+
+
+
+ -
+
+
+ 电压下限
+
+
+
+ -
+
+
+ Qt::Orientation::Vertical
+
+
+
+ -
+
+
+ 电流下限
+
+
+
+ -
+
+
+ 200.000000000000000
+
+
+ 110.000000000000000
+
+
+
+ -
+
+
+ 10000.000000000000000
+
+
+ 2.000000000000000
+
+
+
+ -
+
+
+ 是否锚定电压
+
+
+
+ -
+
+
+ 电流上限
+
+
+
+ -
+
+
+ 45.000000000000000
+
+
+
+ -
+
+
+ 200.000000000000000
+
+
+ 55.000000000000000
+
+
+
+ -
+
+
+ 电压上限
+
+
+
+ -
+
+
+ 电阻
+
+
+
+
+
+
+ -
+
+
+ Qt::Orientation::Vertical
+
+
+
+ 20
+ 354
+
+
+
+
+ -
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ Qt::Orientation::Horizontal
+
+
+
+ 223
+ 20
+
+
+
+
+ -
+
+
+ 取消
+
+
+
+ -
+
+
+ 应用
+
+
+
+ -
+
+
+ 确定
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/include/abstractGraphModel.h b/include/abstractGraphModel.h
deleted file mode 100644
index dd67b29..0000000
--- a/include/abstractGraphModel.h
+++ /dev/null
@@ -1,245 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#include "global.h"
-
-
-/**
- * The central class in the Model-View approach. It delivers all kinds
- * of information from the backing user data structures that represent
- * the graph. The class allows to modify the graph structure: create
- * and remove nodes and connections.
- *
- * We use two types of the unique ids for graph manipulations:
- * - NodeId
- * - ConnectionId
- */
-class AbstractGraphModel : public QObject
-{
- Q_OBJECT
-public:
- /// Generates a new unique NodeId.
- virtual NodeId newNodeId() = 0;
-
- /// @brief Returns the full set of unique Node Ids.
- /**
- * Model creator is responsible for generating unique `unsigned int`
- * Ids for all the nodes in the graph. From an Id it should be
- * possible to trace back to the model's internal representation of
- * the node.
- */
- virtual QSet allNodeIds() const = 0;
-
- /**
- * A collection of all input and output connections for the given `nodeId`.
- */
- virtual QSet allConnectionIds(NodeId const nodeId) const = 0;
-
- /// @brief Returns all connected Node Ids for given port.
- /**
- * The returned set of nodes and port indices correspond to the type
- * opposite to the given `portType`.
- */
- virtual QSet connections(NodeId nodeId,
- PortType portType,
- PortIndex index) const
- = 0;
-
- /// Checks if two nodes with the given `connectionId` are connected.
- virtual bool connectionExists(ConnectionId const connectionId) const = 0;
-
- /// Creates a new node instance in the derived class.
- /**
- * The model is responsible for generating a unique `NodeId`.
- * @param[in] nodeType is free to be used and interpreted by the
- * model on its own, it helps to distinguish between possible node
- * types and create a correct instance inside.
- */
- virtual NodeId addNode(QString const nodeType = QString()) = 0;
-
- /// Model decides if a conection with a given connection Id possible.
- /**
- * The default implementation compares corresponding data types.
- *
- * It is possible to override the function and connect non-equal
- * data types.
- */
- virtual bool connectionPossible(ConnectionId const connectionId) const = 0;
-
- /// Defines if detaching the connection is possible.
- virtual bool detachPossible(ConnectionId const) const { return true; }
-
- /// Creates a new connection between two nodes.
- /**
- * Default implementation emits signal
- * `connectionCreated(connectionId)`
- *
- * In the derived classes user must emite the signal to notify the
- * scene about the changes.
- */
- virtual void addConnection(ConnectionId const connectionId) = 0;
-
- /**
- * @returns `true` if there is data in the model associated with the
- * given `nodeId`.
- */
- virtual bool nodeExists(NodeId const nodeId) const = 0;
-
- /// @brief Returns node-related data for requested NodeRole.
- /**
- * @returns Node Caption, Node Caption Visibility, Node Position etc.
- */
- virtual QVariant nodeData(NodeId nodeId, NodeRole role) const = 0;
-
- /**
- * A utility function that unwraps the `QVariant` value returned from the
- * standard `QVariant AbstractGraphModel::nodeData(NodeId, NodeRole)` function.
- */
- template
- T nodeData(NodeId nodeId, NodeRole role) const
- {
- return nodeData(nodeId, role).value();
- }
-
- virtual NodeFlags nodeFlags(NodeId nodeId) const
- {
- Q_UNUSED(nodeId);
- return NodeFlag::NoFlags;
- }
-
- /// @brief Sets node properties.
- /**
- * Sets: Node Caption, Node Caption Visibility,
- * Shyle, State, Node Position etc.
- * @see NodeRole.
- */
- virtual bool setNodeData(NodeId nodeId, NodeRole role, QVariant value) = 0;
-
- /// @brief Returns port-related data for requested NodeRole.
- /**
- * @returns Port Data Type, Port Data, Connection Policy, Port
- * Caption.
- */
- virtual QVariant portData(NodeId nodeId, PortType portType, PortIndex index, PortRole role) const
- = 0;
-
- /**
- * A utility function that unwraps the `QVariant` value returned from the
- * standard `QVariant AbstractGraphModel::portData(...)` function.
- */
- template
- T portData(NodeId nodeId, PortType portType, PortIndex index, PortRole role) const
- {
- return portData(nodeId, portType, index, role).value();
- }
-
- virtual bool setPortData(NodeId nodeId,
- PortType portType,
- PortIndex index,
- QVariant const &value,
- PortRole role = PortRole::Data)
- = 0;
-
- virtual bool deleteConnection(ConnectionId const connectionId) = 0;
-
- virtual bool deleteNode(NodeId const nodeId) = 0;
-
- /**
- * Reimplement the function if you want to store/restore the node's
- * inner state during undo/redo node deletion operations.
- */
- virtual QJsonObject saveNode(NodeId const) const { return {}; }
-
- /**
- * Reimplement the function if you want to support:
- *
- * - graph save/restore operations,
- * - undo/redo operations after deleting the node.
- *
- * QJsonObject must contain following fields:
- *
- *
- * ```
- * {
- * id : 5,
- * position : { x : 100, y : 200 },
- * internal-data {
- * "your model specific data here"
- * }
- * }
- * ```
- *
- * The function must do almost exacly the same thing as the normal addNode().
- * The main difference is in a model-specific `inner-data` processing.
- */
- virtual void loadNode(QJsonObject const &) {}
-
-public:
- /**
- * Function clears connections attached to the ports that are scheduled to be
- * deleted. It must be called right before the model removes its old port data.
- *
- * @param nodeId Defines the node to be modified
- * @param portType Is either PortType::In or PortType::Out
- * @param first Index of the first port to be removed
- * @param last Index of the last port to be removed
- */
- void portsAboutToBeDeleted(NodeId const nodeId,
- PortType const portType,
- PortIndex const first,
- PortIndex const last);
-
- /**
- * Signal emitted when model no longer has the old data associated with the
- * given port indices and when the node must be repainted.
- */
- void portsDeleted();
-
- /**
- * Signal emitted when model is about to create new ports on the given node.
- * @param first Is the first index of the new port after insertion.
- * @param last Is the last index of the new port after insertion.
- *
- * Function caches existing connections that are located after the `last` port
- * index. For such connections the new "post-insertion" addresses are computed
- * and stored until the function AbstractGraphModel::portsInserted is called.
- */
- void portsAboutToBeInserted(NodeId const nodeId,
- PortType const portType,
- PortIndex const first,
- PortIndex const last);
-
- /**
- * Function re-creates the connections that were shifted during the port
- * insertion. After that the node is updated.
- */
- void portsInserted();
-
-Q_SIGNALS:
- void connectionCreated(ConnectionId const connectionId);
-
- void connectionDeleted(ConnectionId const connectionId);
-
- void nodeCreated(NodeId const nodeId);
-
- void nodeDeleted(NodeId const nodeId);
-
- void nodeUpdated(NodeId const nodeId);
-
- void nodeFlagsUpdated(NodeId const nodeId);
-
- void nodePositionUpdated(NodeId const nodeId);
-
- void modelReset();
-
-private:
- QVector _shiftedByDynamicPortsConnections;
-};
-
diff --git a/include/abstractNodeGeometry.h b/include/abstractNodeGeometry.h
deleted file mode 100644
index e7ae2c4..0000000
--- a/include/abstractNodeGeometry.h
+++ /dev/null
@@ -1,76 +0,0 @@
-#pragma once
-
-#include "global.h"
-
-#include
-#include
-#include
-
-
-class AbstractGraphModel;
-
-class AbstractNodeGeometry
-{
-public:
- AbstractNodeGeometry(AbstractGraphModel &);
- virtual ~AbstractNodeGeometry() {}
-
- /**
- * The node's size plus some additional margin around it to account for drawing
- * effects (for example shadows) or node's parts outside the size rectangle
- * (for example port points).
- *
- * The default implementation returns QSize + 20 percent of width and heights
- * at each side of the rectangle.
- */
- virtual QRectF boundingRect(NodeId const nodeId) const;
-
- /// A direct rectangle defining the borders of the node's rectangle.
- virtual QSize size(NodeId const nodeId) const = 0;
-
- /**
- * The function is triggeren when a nuber of ports is changed or when an
- * embedded widget needs an update.
- */
- virtual void recomputeSize(NodeId const nodeId) const = 0;
-
- /// Port position in node's coordinate system.
- virtual QPointF portPosition(NodeId const nodeId,
- PortType const portType,
- PortIndex const index) const
- = 0;
-
- /// A convenience function using the `portPosition` and a given transformation.
- virtual QPointF portScenePosition(NodeId const nodeId,
- PortType const portType,
- PortIndex const index,
- QTransform const &t) const;
-
- /// Defines where to draw port label. The point corresponds to a font baseline.
- virtual QPointF portTextPosition(NodeId const nodeId,
- PortType const portType,
- PortIndex const portIndex) const
- = 0;
-
- /**
- * Defines where to start drawing the caption. The point corresponds to a font
- * baseline.
- */
- virtual QPointF captionPosition(NodeId const nodeId) const = 0;
-
- /// Caption rect is needed for estimating the total node size.
- virtual QRectF captionRect(NodeId const nodeId) const = 0;
-
- /// Position for an embedded widget. Return any value if you don't embed.
- virtual QPointF widgetPosition(NodeId const nodeId) const = 0;
-
- virtual PortIndex checkPortHit(NodeId const nodeId,
- PortType const portType,
- QPointF const nodePoint) const;
-
- virtual QRect resizeHandleRect(NodeId const nodeId) const = 0;
-
-protected:
- AbstractGraphModel &_graphModel;
-};
-
diff --git a/include/abstractNodePainter.h b/include/abstractNodePainter.h
deleted file mode 100644
index b745ed6..0000000
--- a/include/abstractNodePainter.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-
-#include
-
-#include "global.h"
-
-class QPainter;
-
-
-class NodeGraphicsObject;
-class NodeDataModel;
-
-/// Class enables custom painting.
-class AbstractNodePainter
-{
-public:
- virtual ~AbstractNodePainter() = default;
-
- /**
- * Reimplement this function in order to have a custom painting.
- *
- * Useful functions:
- * `NodeGraphicsObject::nodeScene()->nodeGeometry()`
- * `NodeGraphicsObject::graphModel()`
- */
- virtual void paint(QPainter *painter, NodeGraphicsObject &ngo) const = 0;
-};
diff --git a/include/basicGraphicsScene.h b/include/basicGraphicsScene.h
deleted file mode 100644
index de3998c..0000000
--- a/include/basicGraphicsScene.h
+++ /dev/null
@@ -1,168 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-
-#include "abstractGraphModel.h"
-#include "abstractNodeGeometry.h"
-#include "global.h"
-
-class QUndoStack;
-
-class AbstractGraphModel;
-class AbstractNodePainter;
-class ConnectionGraphicsObject;
-class NodeGraphicsObject;
-class NodeStyle;
-
-/// An instance of QGraphicsScene, holds connections and nodes.
-class BasicGraphicsScene : public QGraphicsScene
-{
- Q_OBJECT
-public:
- BasicGraphicsScene(AbstractGraphModel &graphModel, QObject *parent = nullptr);
-
- // Scenes without models are not supported
- BasicGraphicsScene() = delete;
-
- ~BasicGraphicsScene();
-
-public:
- /// @returns associated AbstractGraphModel.
- AbstractGraphModel const &graphModel() const;
-
- AbstractGraphModel &graphModel();
-
- AbstractNodeGeometry &nodeGeometry();
-
- AbstractNodePainter &nodePainter();
-
- void setNodePainter(QSharedPointer newPainter);
-
- QUndoStack &undoStack();
-
-public:
- /// Creates a "draft" instance of ConnectionGraphicsObject.
- /**
- * The scene caches a "draft" connection which has one loose end.
- * After attachment the "draft" instance is deleted and instead a
- * normal "full" connection is created.
- * Function @returns the "draft" instance for further geometry
- * manipulations.
- */
- QSharedPointer const &makeDraftConnection(
- ConnectionId const newConnectionId);
-
- /// Deletes "draft" connection.
- /**
- * The function is called when user releases the mouse button during
- * the construction of the new connection without attaching it to any
- * node.
- */
- void resetDraftConnection();
-
- /// Deletes all the nodes. Connections are removed automatically.
- void clearScene();
-
-public:
- /// @returns NodeGraphicsObject associated with the given nodeId.
- /**
- * @returns nullptr when the object is not found.
- */
- NodeGraphicsObject *nodeGraphicsObject(NodeId nodeId);
-
- /// @returns ConnectionGraphicsObject corresponding to `connectionId`.
- /**
- * @returns `nullptr` when the object is not found.
- */
- ConnectionGraphicsObject *connectionGraphicsObject(ConnectionId connectionId);
-
- Qt::Orientation orientation() const { return _orientation; }
-
- void setOrientation(Qt::Orientation const orientation);
-
-public:
- /// Can @return an instance of the scene context menu in subclass.
- /**
- * Default implementation returns `nullptr`.
- */
- virtual QMenu *createSceneMenu(QPointF const scenePos);
-
-Q_SIGNALS:
- void modified(BasicGraphicsScene *);
-
- void nodeMoved(NodeId const nodeId, QPointF const &newLocation);
-
- void nodeClicked(NodeId const nodeId);
-
- void nodeSelected(NodeId const nodeId);
-
- void nodeDoubleClicked(NodeId const nodeId);
-
- void nodeHovered(NodeId const nodeId, QPoint const screenPos);
-
- void nodeHoverLeft(NodeId const nodeId);
-
- void connectionHovered(ConnectionId const connectionId, QPoint const screenPos);
-
- void connectionHoverLeft(ConnectionId const connectionId);
-
- /// Signal allows showing custom context menu upon clicking a node.
- void nodeContextMenu(NodeId const nodeId, QPointF const pos);
-
-private:
- /// @brief Creates Node and Connection graphics objects.
- /**
- * Function is used to populate an empty scene in the constructor. We
- * perform depth-first AbstractGraphModel traversal. The connections are
- * created by checking non-empty node `Out` ports.
- */
- void traverseGraphAndPopulateGraphicsObjects();
-
- /// Redraws adjacent nodes for given `connectionId`
- void updateAttachedNodes(ConnectionId const connectionId, PortType const portType);
-
-public Q_SLOTS:
- /// Slot called when the `connectionId` is erased form the AbstractGraphModel.
- void onConnectionDeleted(ConnectionId const connectionId);
-
- /// Slot called when the `connectionId` is created in the AbstractGraphModel.
- void onConnectionCreated(ConnectionId const connectionId);
-
- void onNodeDeleted(NodeId const nodeId);
-
- void onNodeCreated(NodeId const nodeId);
-
- void onNodePositionUpdated(NodeId const nodeId);
-
- void onNodeUpdated(NodeId const nodeId);
-
- void onNodeClicked(NodeId const nodeId);
-
- void onModelReset();
-
-private:
- AbstractGraphModel &_graphModel;
-
- using UniqueNodeGraphicsObject = QSharedPointer;
-
- using UniqueConnectionGraphicsObject = QSharedPointer;
-
- QMap _nodeGraphicsObjects;
-
- QMap _connectionGraphicsObjects;
-
- QSharedPointer _draftConnection;
-
- QSharedPointer _nodeGeometry;
-
- QSharedPointer _nodePainter;
-
- bool _nodeDrag;
-
- QUndoStack *_undoStack;
-
- Qt::Orientation _orientation;
-};
-
diff --git a/include/connectionGraphicsObject.h b/include/connectionGraphicsObject.h
deleted file mode 100644
index 31ee70b..0000000
--- a/include/connectionGraphicsObject.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#pragma once
-
-#include
-
-#include
-#include
-
-#include "connectionState.h"
-#include "global.h"
-
-class QGraphicsSceneMouseEvent;
-
-
-class AbstractGraphModel;
-class BasicGraphicsScene;
-
-/// Graphic Object for connection. Adds itself to scene
-class ConnectionGraphicsObject : public QGraphicsObject
-{
- Q_OBJECT
-public:
- // Needed for qgraphicsitem_cast
- enum { Type = UserType + 2 };
-
- int type() const override { return Type; }
-
-public:
- ConnectionGraphicsObject(BasicGraphicsScene &scene, ConnectionId const connectionId);
-
- ~ConnectionGraphicsObject() = default;
-
-public:
- AbstractGraphModel &graphModel() const;
-
- BasicGraphicsScene *nodeScene() const;
-
- ConnectionId const &connectionId() const;
-
- QRectF boundingRect() const override;
-
- QPainterPath shape() const override;
-
- QPointF const &endPoint(PortType portType) const;
-
- QPointF out() const { return _out; }
-
- QPointF in() const { return _in; }
-
- std::pair pointsC1C2() const;
-
- void setEndPoint(PortType portType, QPointF const &point);
-
- /// Updates the position of both ends
- void move();
-
- ConnectionState const &connectionState() const;
-
- ConnectionState &connectionState();
-
-protected:
- void paint(QPainter *painter,
- QStyleOptionGraphicsItem const *option,
- QWidget *widget = 0) override;
-
- void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
-
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
-
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
-
- void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
-
- void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
-
-private:
- void initializePosition();
-
- void addGraphicsEffect();
-
- std::pair pointsC1C2Horizontal() const;
-
- std::pair pointsC1C2Vertical() const;
-
-private:
- ConnectionId _connectionId;
-
- AbstractGraphModel &_graphModel;
-
- ConnectionState _connectionState;
-
- mutable QPointF _out;
- mutable QPointF _in;
-};
diff --git a/include/connectionIdUtils.h b/include/connectionIdUtils.h
deleted file mode 100644
index 793f4fe..0000000
--- a/include/connectionIdUtils.h
+++ /dev/null
@@ -1,149 +0,0 @@
-#pragma once
-
-#include "global.h"
-
-#include
-
-#include
-#include
-
-
-inline PortIndex getNodeId(PortType portType, ConnectionId connectionId)
-{
- NodeId id = InvalidNodeId;
-
- if (portType == PortType::Out) {
- id = connectionId.outNodeId;
- } else if (portType == PortType::In) {
- id = connectionId.inNodeId;
- }
-
- return id;
-}
-
-inline PortIndex getPortIndex(PortType portType, ConnectionId connectionId)
-{
- PortIndex index = InvalidPortIndex;
-
- if (portType == PortType::Out) {
- index = connectionId.outPortIndex;
- } else if (portType == PortType::In) {
- index = connectionId.inPortIndex;
- }
-
- return index;
-}
-
-inline PortType oppositePort(PortType port)
-{
- PortType result = PortType::None;
-
- switch (port) {
- case PortType::In:
- result = PortType::Out;
- break;
-
- case PortType::Out:
- result = PortType::In;
- break;
-
- case PortType::None:
- result = PortType::None;
- break;
-
- default:
- break;
- }
- return result;
-}
-
-inline bool isPortIndexValid(PortIndex index)
-{
- return index != InvalidPortIndex;
-}
-
-inline bool isPortTypeValid(PortType portType)
-{
- return portType != PortType::None;
-}
-
-/**
- * Creates a connection Id instance filled just on one side.
- */
-inline ConnectionId makeIncompleteConnectionId(NodeId const connectedNodeId,
- PortType const connectedPort,
- PortIndex const connectedPortIndex)
-{
- return (connectedPort == PortType::In)
- ? ConnectionId{InvalidNodeId, InvalidPortIndex, connectedNodeId, connectedPortIndex}
- : ConnectionId{connectedNodeId, connectedPortIndex, InvalidNodeId, InvalidPortIndex};
-}
-
-/**
- * Turns a full connection Id into an incomplete one by removing the
- * data on the given side
- */
-inline ConnectionId makeIncompleteConnectionId(ConnectionId connectionId,
- PortType const portToDisconnect)
-{
- if (portToDisconnect == PortType::Out) {
- connectionId.outNodeId = InvalidNodeId;
- connectionId.outPortIndex = InvalidPortIndex;
- } else {
- connectionId.inNodeId = InvalidNodeId;
- connectionId.inPortIndex = InvalidPortIndex;
- }
-
- return connectionId;
-}
-
-inline ConnectionId makeCompleteConnectionId(ConnectionId incompleteConnectionId,
- NodeId const nodeId,
- PortIndex const portIndex)
-{
- if (incompleteConnectionId.outNodeId == InvalidNodeId) {
- incompleteConnectionId.outNodeId = nodeId;
- incompleteConnectionId.outPortIndex = portIndex;
- } else {
- incompleteConnectionId.inNodeId = nodeId;
- incompleteConnectionId.inPortIndex = portIndex;
- }
-
- return incompleteConnectionId;
-}
-
-inline std::ostream &operator<<(std::ostream &ostr, ConnectionId const connectionId)
-{
- ostr << "(" << connectionId.outNodeId << ", "
- << (isPortIndexValid(connectionId.outPortIndex) ? std::to_string(connectionId.outPortIndex)
- : "INVALID")
- << ", " << connectionId.inNodeId << ", "
- << (isPortIndexValid(connectionId.inPortIndex) ? std::to_string(connectionId.inPortIndex)
- : "INVALID")
- << ")" << std::endl;
-
- return ostr;
-}
-
-inline QJsonObject toJson(ConnectionId const &connId)
-{
- QJsonObject connJson;
-
- connJson["outNodeId"] = static_cast(connId.outNodeId);
- connJson["outPortIndex"] = static_cast(connId.outPortIndex);
- connJson["intNodeId"] = static_cast(connId.inNodeId);
- connJson["inPortIndex"] = static_cast(connId.inPortIndex);
-
- return connJson;
-}
-
-inline ConnectionId fromJson(QJsonObject const &connJson)
-{
- ConnectionId connId{static_cast(connJson["outNodeId"].toInt(InvalidNodeId)),
- static_cast(connJson["outPortIndex"].toInt(InvalidPortIndex)),
- static_cast(connJson["intNodeId"].toInt(InvalidNodeId)),
- static_cast(connJson["inPortIndex"].toInt(InvalidPortIndex))};
-
- return connId;
-}
-
diff --git a/include/connectionPainter.h b/include/connectionPainter.h
deleted file mode 100644
index 1e6f46c..0000000
--- a/include/connectionPainter.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#pragma once
-
-#include
-#include
-
-#include "global.h"
-
-class ConnectionGeometry;
-class ConnectionGraphicsObject;
-
-class ConnectionPainter
-{
-public:
- static void paint(QPainter *painter, ConnectionGraphicsObject const &cgo);
-
- static QPainterPath getPainterStroke(ConnectionGraphicsObject const &cgo);
-};
diff --git a/include/connectionState.h b/include/connectionState.h
deleted file mode 100644
index 15ecabe..0000000
--- a/include/connectionState.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#pragma once
-
-#include
-
-#include "global.h"
-
-class QPointF;
-
-class ConnectionGraphicsObject;
-
-/// Stores currently draggind end.
-/// Remembers last hovered Node.
-class ConnectionState
-{
-public:
- /// Defines whether we construct a new connection
- /// or it is already binding two nodes.
- enum LooseEnd { Pending = 0, Connected = 1 };
-
-public:
- ConnectionState(ConnectionGraphicsObject &cgo)
- : _cgo(cgo)
- , _hovered(false)
- {}
-
- ConnectionState(ConnectionState const &) = delete;
- ConnectionState(ConnectionState &&) = delete;
-
- ConnectionState &operator=(ConnectionState const &) = delete;
- ConnectionState &operator=(ConnectionState &&) = delete;
-
- ~ConnectionState();
-
-public:
- PortType requiredPort() const;
- bool requiresPort() const;
-
- bool hovered() const;
- void setHovered(bool hovered);
-
-public:
- /// Caches NodeId for further interaction.
- void setLastHoveredNode(NodeId const nodeId);
-
- NodeId lastHoveredNode() const;
-
- void resetLastHoveredNode();
-
-private:
- ConnectionGraphicsObject &_cgo;
-
- bool _hovered;
-
- NodeId _lastHoveredNode{InvalidNodeId};
-};
diff --git a/include/connectionStyle.h b/include/connectionStyle.h
deleted file mode 100644
index 191a85a..0000000
--- a/include/connectionStyle.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#pragma once
-
-#include
-
-#include "style.h"
-
-class ConnectionStyle : public Style
-{
-public:
- ConnectionStyle();
-
- ConnectionStyle(QString jsonText);
-
- ~ConnectionStyle() = default;
-
-public:
- static void setConnectionStyle(QString jsonText);
-
-public:
- void loadJson(QJsonObject const &json) override;
-
- QJsonObject toJson() const override;
-
-public:
- QColor constructionColor() const;
- QColor normalColor() const;
- QColor normalColor(QString typeId) const;
- QColor selectedColor() const;
- QColor selectedHaloColor() const;
- QColor hoveredColor() const;
-
- float lineWidth() const;
- float constructionLineWidth() const;
- float pointDiameter() const;
-
- bool useDataDefinedColors() const;
-
-private:
- QColor ConstructionColor;
- QColor NormalColor;
- QColor SelectedColor;
- QColor SelectedHaloColor;
- QColor HoveredColor;
-
- float LineWidth;
- float ConstructionLineWidth;
- float PointDiameter;
-
- bool UseDataDefinedColors;
-};
-
diff --git a/include/dataFlowGraphModel.h b/include/dataFlowGraphModel.h
deleted file mode 100644
index 410c7c8..0000000
--- a/include/dataFlowGraphModel.h
+++ /dev/null
@@ -1,131 +0,0 @@
-#pragma once
-
-#include "abstractGraphModel.h"
-#include "connectionIdUtils.h"
-#include "nodeDelegateModelRegistry.h"
-#include "serializable.h"
-#include "styleCollection.h"
-
-#include
-#include
-
-
-class DataFlowGraphModel : public AbstractGraphModel, public Serializable
-{
- Q_OBJECT
-
-public:
- struct NodeGeometryData
- {
- QSize size;
- QPointF pos;
- };
-
-public:
- DataFlowGraphModel(QSharedPointer registry);
-
- QSharedPointer dataModelRegistry() { return _registry; }
-
-public:
- QSet allNodeIds() const override;
-
- QSet allConnectionIds(NodeId const nodeId) const override;
-
- QSet connections(NodeId nodeId,
- PortType portType,
- PortIndex portIndex) const override;
-
- bool connectionExists(ConnectionId const connectionId) const override;
-
- NodeId addNode(QString const nodeType) override;
-
- bool connectionPossible(ConnectionId const connectionId) const override;
-
- void addConnection(ConnectionId const connectionId) override;
-
- bool nodeExists(NodeId const nodeId) const override;
-
- QVariant nodeData(NodeId nodeId, NodeRole role) const override;
-
- NodeFlags nodeFlags(NodeId nodeId) const override;
-
- bool setNodeData(NodeId nodeId, NodeRole role, QVariant value) override;
-
- QVariant portData(NodeId nodeId,
- PortType portType,
- PortIndex portIndex,
- PortRole role) const override;
-
- bool setPortData(NodeId nodeId,
- PortType portType,
- PortIndex portIndex,
- QVariant const &value,
- PortRole role = PortRole::Data) override;
-
- bool deleteConnection(ConnectionId const connectionId) override;
-
- bool deleteNode(NodeId const nodeId) override;
-
- QJsonObject saveNode(NodeId const) const override;
-
- QJsonObject save() const override;
-
- void loadNode(QJsonObject const &nodeJson) override;
-
- void load(QJsonObject const &json) override;
-
- /**
- * Fetches the NodeDelegateModel for the given `nodeId` and tries to cast the
- * stored pointer to the given type
- */
- template
- NodeDelegateModelType *delegateModel(NodeId const nodeId)
- {
- auto it = _models.find(nodeId);
- if (it == _models.end())
- return nullptr;
-
- //auto model = dynamic_cast(it->second.get());
- auto model = dynamic_cast(*it);
-
- return model;
- }
-
-Q_SIGNALS:
- void inPortDataWasSet(NodeId const, PortType const, PortIndex const);
-
-private:
- NodeId newNodeId() override { return _nextNodeId++; }
-
- void sendConnectionCreation(ConnectionId const connectionId);
-
- void sendConnectionDeletion(ConnectionId const connectionId);
-
-private Q_SLOTS:
- /**
- * Fuction is called in three cases:
- *
- * - By underlying NodeDelegateModel when a node has new data to propagate.
- * @see DataFlowGraphModel::addNode
- * - When a new connection is created.
- * @see DataFlowGraphModel::addConnection
- * - When a node restored from JSON an needs to send data downstream.
- * @see DataFlowGraphModel::loadNode
- */
- void onOutPortDataUpdated(NodeId const nodeId, PortIndex const portIndex);
-
- /// Function is called after detaching a connection.
- void propagateEmptyDataTo(NodeId const nodeId, PortIndex const portIndex);
-
-private:
- QSharedPointer _registry;
-
- NodeId _nextNodeId;
-
- QMap> _models;
-
- QSet _connectivity;
-
- mutable QMap _nodeGeometryData;
-};
-
diff --git a/include/defaultHorizontalNodeGeometry.h b/include/defaultHorizontalNodeGeometry.h
deleted file mode 100644
index 94d13f6..0000000
--- a/include/defaultHorizontalNodeGeometry.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#pragma once
-
-#include "abstractNodeGeometry.h"
-
-#include
-
-class AbstractGraphModel;
-class BasicGraphicsScene;
-
-class DefaultHorizontalNodeGeometry : public AbstractNodeGeometry
-{
-public:
- DefaultHorizontalNodeGeometry(AbstractGraphModel &graphModel);
-
-public:
- QSize size(NodeId const nodeId) const override;
-
- void recomputeSize(NodeId const nodeId) const override;
-
- QPointF portPosition(NodeId const nodeId,
- PortType const portType,
- PortIndex const index) const override;
-
- QPointF portTextPosition(NodeId const nodeId,
- PortType const portType,
- PortIndex const PortIndex) const override;
- QPointF captionPosition(NodeId const nodeId) const override;
-
- QRectF captionRect(NodeId const nodeId) const override;
-
- QPointF widgetPosition(NodeId const nodeId) const override;
-
- QRect resizeHandleRect(NodeId const nodeId) const override;
-
-private:
- QRectF portTextRect(NodeId const nodeId,
- PortType const portType,
- PortIndex const portIndex) const;
-
- /// Finds max number of ports and multiplies by (a port height + interval)
- unsigned int maxVerticalPortsExtent(NodeId const nodeId) const;
-
- unsigned int maxPortsTextAdvance(NodeId const nodeId, PortType const portType) const;
-
-private:
- // Some variables are mutable because we need to change drawing
- // metrics corresponding to fontMetrics but this doesn't change
- // constness of the Node.
-
- mutable unsigned int _portSize;
- unsigned int _portSpasing;
- mutable QFontMetrics _fontMetrics;
- mutable QFontMetrics _boldFontMetrics;
-};
diff --git a/include/defaultNodePainter.h b/include/defaultNodePainter.h
deleted file mode 100644
index 240e06b..0000000
--- a/include/defaultNodePainter.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#pragma once
-
-#include
-
-#include "abstractNodePainter.h"
-#include "global.h"
-
-
-class BasicGraphicsScene;
-class GraphModel;
-class NodeGeometry;
-class NodeGraphicsObject;
-class NodeState;
-
-/// @ Lightweight class incapsulating paint code.
-class DefaultNodePainter : public AbstractNodePainter
-{
-public:
- void paint(QPainter *painter, NodeGraphicsObject &ngo) const override;
-
- void drawNodeRect(QPainter *painter, NodeGraphicsObject &ngo) const;
-
- void drawConnectionPoints(QPainter *painter, NodeGraphicsObject &ngo) const;
-
- void drawFilledConnectionPoints(QPainter *painter, NodeGraphicsObject &ngo) const;
-
- void drawNodeCaption(QPainter *painter, NodeGraphicsObject &ngo) const;
-
- void drawEntryLabels(QPainter *painter, NodeGraphicsObject &ngo) const;
-
- void drawResizeRect(QPainter *painter, NodeGraphicsObject &ngo) const;
-};
diff --git a/include/defaultVerticalNodeGeometry.h b/include/defaultVerticalNodeGeometry.h
deleted file mode 100644
index fdafde5..0000000
--- a/include/defaultVerticalNodeGeometry.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#pragma once
-
-#include "abstractNodeGeometry.h"
-
-#include
-
-class AbstractGraphModel;
-class BasicGraphicsScene;
-
-class DefaultVerticalNodeGeometry : public AbstractNodeGeometry
-{
-public:
- DefaultVerticalNodeGeometry(AbstractGraphModel &graphModel);
-
-public:
- QSize size(NodeId const nodeId) const override;
-
- void recomputeSize(NodeId const nodeId) const override;
-
- QPointF portPosition(NodeId const nodeId,
- PortType const portType,
- PortIndex const index) const override;
-
- QPointF portTextPosition(NodeId const nodeId,
- PortType const portType,
- PortIndex const PortIndex) const override;
-
- QPointF captionPosition(NodeId const nodeId) const override;
-
- QRectF captionRect(NodeId const nodeId) const override;
-
- QPointF widgetPosition(NodeId const nodeId) const override;
-
- QRect resizeHandleRect(NodeId const nodeId) const override;
-
-private:
- QRectF portTextRect(NodeId const nodeId,
- PortType const portType,
- PortIndex const portIndex) const;
- /// Finds
- unsigned int maxHorizontalPortsExtent(NodeId const nodeId) const;
-
- unsigned int maxPortsTextAdvance(NodeId const nodeId, PortType const portType) const;
-
- unsigned int portCaptionsHeight(NodeId const nodeId, PortType const portType) const;
-
-private:
- // Some variables are mutable because we need to change drawing
- // metrics corresponding to fontMetrics but this doesn't change
- // constness of the Node.
-
- mutable unsigned int _portSize;
- unsigned int _portSpasing;
- mutable QFontMetrics _fontMetrics;
- mutable QFontMetrics _boldFontMetrics;
-};
-
diff --git a/include/diagramCavas.h b/include/diagramCavas.h
deleted file mode 100644
index c696ccf..0000000
--- a/include/diagramCavas.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef DIAGRAMCAVAS_H
-#define DIAGRAMCAVAS_H
-
-#include
-#include "global.h"
-
-QT_BEGIN_NAMESPACE
-namespace Ui { class diagramCavas; }
-QT_END_NAMESPACE
-
-class DrawingPanel;
-
-class DiagramCavas : public QMdiArea
-{
- Q_OBJECT
-
-public:
- DiagramCavas(QWidget *parent = nullptr);
- ~DiagramCavas();
-
-public:
- void initial();
-
-public slots:
- void onSignal_addDrawingPanel(const QString& sTitile);
- void onSignal_addGraphicsItem(GraphicsItemType&);
-
-private:
- QMap m_mapDrawPanel;
-
-};
-
-#endif
diff --git a/include/graphicsDataModel/fixedPortsModel.h b/include/graphicsDataModel/fixedPortsModel.h
deleted file mode 100644
index 65ae02c..0000000
--- a/include/graphicsDataModel/fixedPortsModel.h
+++ /dev/null
@@ -1,131 +0,0 @@
-#pragma once
-
-#include "abstractGraphModel.h"
-#include "connectionIdUtils.h"
-#include "nodeDelegateModelRegistry.h"
-#include "serializable.h"
-#include "styleCollection.h"
-
-#include
-#include
-
-
-class FixedPortsModel : public AbstractGraphModel, public Serializable
-{
- Q_OBJECT
-
-public:
- struct NodeGeometryData
- {
- QSize size;
- QPointF pos;
- };
-
-public:
- FixedPortsModel(QSharedPointer registry);
-
- QSharedPointer dataModelRegistry() { return _registry; }
-
-public:
- QSet allNodeIds() const override;
-
- QSet allConnectionIds(NodeId const nodeId) const override;
-
- QSet connections(NodeId nodeId,
- PortType portType,
- PortIndex portIndex) const override;
-
- bool connectionExists(ConnectionId const connectionId) const override;
-
- NodeId addNode(QString const nodeType) override;
-
- bool connectionPossible(ConnectionId const connectionId) const override;
-
- void addConnection(ConnectionId const connectionId) override;
-
- bool nodeExists(NodeId const nodeId) const override;
-
- QVariant nodeData(NodeId nodeId, NodeRole role) const override;
-
- NodeFlags nodeFlags(NodeId nodeId) const override;
-
- bool setNodeData(NodeId nodeId, NodeRole role, QVariant value) override;
-
- QVariant portData(NodeId nodeId,
- PortType portType,
- PortIndex portIndex,
- PortRole role) const override;
-
- bool setPortData(NodeId nodeId,
- PortType portType,
- PortIndex portIndex,
- QVariant const &value,
- PortRole role = PortRole::Data) override;
-
- bool deleteConnection(ConnectionId const connectionId) override;
-
- bool deleteNode(NodeId const nodeId) override;
-
- QJsonObject saveNode(NodeId const) const override;
-
- QJsonObject save() const override;
-
- void loadNode(QJsonObject const &nodeJson) override;
-
- void load(QJsonObject const &json) override;
-
- /**
- * Fetches the NodeDelegateModel for the given `nodeId` and tries to cast the
- * stored pointer to the given type
- */
- template
- NodeDelegateModelType *delegateModel(NodeId const nodeId)
- {
- auto it = _models.find(nodeId);
- if (it == _models.end())
- return nullptr;
-
- //auto model = dynamic_cast(it->second.get());
- auto model = dynamic_cast(*it);
-
- return model;
- }
-
-Q_SIGNALS:
- void inPortDataWasSet(NodeId const, PortType const, PortIndex const);
-
-private:
- NodeId newNodeId() override { return _nextNodeId++; }
-
- void sendConnectionCreation(ConnectionId const connectionId);
-
- void sendConnectionDeletion(ConnectionId const connectionId);
-
-private Q_SLOTS:
- /**
- * Fuction is called in three cases:
- *
- * - By underlying NodeDelegateModel when a node has new data to propagate.
- * @see DataFlowGraphModel::addNode
- * - When a new connection is created.
- * @see DataFlowGraphModel::addConnection
- * - When a node restored from JSON an needs to send data downstream.
- * @see DataFlowGraphModel::loadNode
- */
- void onOutPortDataUpdated(NodeId const nodeId, PortIndex const portIndex);
-
- /// Function is called after detaching a connection.
- void propagateEmptyDataTo(NodeId const nodeId, PortIndex const portIndex);
-
-private:
- QSharedPointer _registry;
-
- NodeId _nextNodeId;
-
- QMap> _models;
-
- QSet _connectivity;
-
- mutable QMap _nodeGeometryData;
-};
-
diff --git a/include/graphicsDataModel/triangleDelegateModel.h b/include/graphicsDataModel/triangleDelegateModel.h
deleted file mode 100644
index 78f984f..0000000
--- a/include/graphicsDataModel/triangleDelegateModel.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#pragma once
-
-#include
-
-#include
-
-#include
-
-#include "DecimalData.hpp"
-
-using QtNodes::NodeData;
-using QtNodes::NodeDataType;
-using QtNodes::NodeDelegateModel;
-using QtNodes::PortIndex;
-using QtNodes::PortType;
-
-class QLabel;
-
-/// The model dictates the number of inputs and outputs for the Node.
-/// In this example it has no logic.
-class NumberDisplayDataModel : public NodeDelegateModel
-{
- Q_OBJECT
-
-public:
- NumberDisplayDataModel();
-
- ~NumberDisplayDataModel() = default;
-
-public:
- QString caption() const override { return QStringLiteral("Result"); }
-
- bool captionVisible() const override { return false; }
-
- QString name() const override { return QStringLiteral("Result"); }
-
-public:
- unsigned int nPorts(PortType portType) const override;
-
- NodeDataType dataType(PortType portType, PortIndex portIndex) const override;
-
- std::shared_ptr outData(PortIndex port) override;
-
- void setInData(std::shared_ptr data, PortIndex portIndex) override;
-
- QWidget *embeddedWidget() override;
-
- double number() const;
-
-private:
- std::shared_ptr _numberData;
-
- QLabel *_label;
-};
diff --git a/include/graphicsItem/electricSvgItemRect.h b/include/graphicsItem/electricSvgItemRect.h
deleted file mode 100644
index d7601b0..0000000
--- a/include/graphicsItem/electricSvgItemRect.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef ELECTRICSVGITEMRECT_H
-#define ELECTRICSVGITEMRECT_H
-
-#include "electricSvgItem.h"
-
-class ElectricSvgItemRect :public ElectricSvgItem
-{
- Q_OBJECT
-public:
- ElectricSvgItemRect(const QRect &rect, QGraphicsItem *parent = 0);
- virtual ~ElectricSvgItemRect();
-protected:
- virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
-private:
- virtual void updateHandles();
-
- double m_dRatioX;
-};
-
-#endif
diff --git a/include/graphicsViewStyle.h b/include/graphicsViewStyle.h
deleted file mode 100644
index 035147e..0000000
--- a/include/graphicsViewStyle.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#pragma once
-
-#include