runtime dynamic link library version
This commit is contained in:
parent
53e6b22c69
commit
a5f787c41b
143
CMakeLists.txt
143
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")
|
||||
|
|
|
|||
|
|
@ -1,315 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 14.0.2, 2024-12-09T17:26:00. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{180d0b44-822c-4522-af92-2d8bdefcfe6f}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="qlonglong">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
|
||||
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
|
||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.CTest">false</value>
|
||||
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||
</valuemap>
|
||||
<value type="bool" key="AutoTest.ApplyFilter">false</value>
|
||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||
<valuelist type="QVariantList" key="AutoTest.PathFilters"/>
|
||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||
<valuemap type="QVariantMap" key="ClangTools">
|
||||
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||
<value type="int" key="ClangTools.ParallelJobs">14</value>
|
||||
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="DeviceType">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.7.2 MinGW 64-bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.7.2 MinGW 64-bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.672.win64_mingw_kit</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="CMake.Build.Type">Debug</value>
|
||||
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
||||
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="CMake.Initial.Parameters">-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</value>
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\work\project\DiagramDesigner\DiagramDesigner\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString">all</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString">clean</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="CMake.Build.Type">Release</value>
|
||||
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
||||
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="CMake.Initial.Parameters">-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</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\work\project\DiagramDesigner\DiagramDesigner\build\Desktop_Qt_6_7_2_MinGW_64_bit-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString">all</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString">clean</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
<value type="QString" key="CMake.Build.Type">Debug</value>
|
||||
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
||||
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="CMake.Initial.Parameters">-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</value>
|
||||
<value type="QString" key="CMake.Source.Directory">D:\work\project\DiagramDesigner\DiagramDesigner</value>
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\work\project\DiagramDesigner\DiagramDesigner\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString">all</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString">clean</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">部署</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph "dwarf,4096" -F 250</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">DiagramDesigner</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.DiagramDesigner</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">DiagramDesigner</value>
|
||||
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/work/project/DiagramDesigner/DiagramDesigner/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug/x64/bin</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="qlonglong">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
</qtcreator>
|
||||
|
|
@ -1,315 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 14.0.2, 2024-12-09T17:28:02. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{f86a2956-ea1a-464e-91b2-1ab824389029}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="qlonglong">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
|
||||
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
|
||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.CTest">false</value>
|
||||
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||
</valuemap>
|
||||
<value type="bool" key="AutoTest.ApplyFilter">false</value>
|
||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||
<valuelist type="QVariantList" key="AutoTest.PathFilters"/>
|
||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||
<valuemap type="QVariantMap" key="ClangTools">
|
||||
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||
<value type="int" key="ClangTools.ParallelJobs">14</value>
|
||||
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="DeviceType">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.7.2 MinGW 64-bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.7.2 MinGW 64-bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.672.win64_mingw_kit</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="CMake.Build.Type">Debug</value>
|
||||
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
||||
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="CMake.Initial.Parameters">-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}</value>
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\work\project\DiagramDesigner\DiagramDesigner\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString">all</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString">clean</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="CMake.Build.Type">Release</value>
|
||||
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
||||
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="CMake.Initial.Parameters">-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}</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\work\project\DiagramDesigner\DiagramDesigner\build\Desktop_Qt_6_7_2_MinGW_64_bit-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString">all</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString">clean</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
<value type="QString" key="CMake.Build.Type">Debug</value>
|
||||
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
||||
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="CMake.Initial.Parameters">-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}</value>
|
||||
<value type="QString" key="CMake.Source.Directory">D:\work\project\DiagramDesigner\DiagramDesigner</value>
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\work\project\DiagramDesigner\DiagramDesigner\build\Desktop_Qt_6_7_2_MinGW_64_bit-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString">all</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">构建</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="QString" key="CMakeProjectManager.MakeStep.BuildPreset"></value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
|
||||
<value type="QString">clean</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="CMakeProjectManager.MakeStep.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.UserEnvironmentChanges"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">清除</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">部署</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph "dwarf,4096" -F 250</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">DiagramDesigner</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.DiagramDesigner</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">DiagramDesigner</value>
|
||||
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/work/project/DiagramDesigner/DiagramDesigner/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug/x64/bin</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="qlonglong">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
</qtcreator>
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
#ifndef DATABASE_H
|
||||
#define DATABASE_H
|
||||
|
||||
#include <QSqlDatabase>
|
||||
#include <QObject>
|
||||
#include <QUuid>
|
||||
#include <QJsonObject>
|
||||
|
||||
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<componentInfo> 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
|
||||
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
|
||||
/**
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef HTTPINTERFACE_H
|
||||
#define HTTPINTERFACE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QJsonObject>
|
||||
|
||||
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<qint64,double> 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
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,849 @@
|
|||
#include "dataBase.h"
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QMessageBox>
|
||||
#include <QSqlQuery>
|
||||
#include <QJsonObject>
|
||||
#include <QSqlError>
|
||||
#include <QSqlDriver>
|
||||
#include <QJsonDocument>
|
||||
|
||||
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()<<qry.lastError().text();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (qry.next())
|
||||
{
|
||||
int id = qry.value(0).toInt();
|
||||
structID.componentId = structID.componentId > id ? structID.componentId:id;
|
||||
}
|
||||
}
|
||||
qry.finish();
|
||||
|
||||
success = qry.exec("SELECT id FROM station");
|
||||
if (!success) {
|
||||
qDebug()<<qry.lastError().text();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (qry.next())
|
||||
{
|
||||
int id = qry.value(0).toInt();
|
||||
structID.stationId = structID.stationId > id ? structID.stationId:id;
|
||||
}
|
||||
}
|
||||
qry.finish();
|
||||
|
||||
success = qry.exec("SELECT id FROM page");
|
||||
if (!success) {
|
||||
qDebug()<<qry.lastError().text();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (qry.next())
|
||||
{
|
||||
int id = qry.value(0).toInt();
|
||||
structID.pageId = structID.pageId > id ? structID.pageId:id;
|
||||
}
|
||||
}
|
||||
qry.finish();
|
||||
|
||||
success = qry.exec("SELECT id FROM grid");
|
||||
if (!success) {
|
||||
qDebug()<<qry.lastError().text();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (qry.next())
|
||||
{
|
||||
int id = qry.value(0).toInt();
|
||||
structID.gridId = structID.gridId > id ? structID.gridId:id;
|
||||
}
|
||||
}
|
||||
qry.finish();
|
||||
|
||||
success = qry.exec("SELECT id FROM zone");
|
||||
if (!success) {
|
||||
qDebug()<<qry.lastError().text();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (qry.next())
|
||||
{
|
||||
int id = qry.value(0).toInt();
|
||||
structID.zoneId = structID.zoneId > id ? structID.zoneId:id;
|
||||
}
|
||||
}
|
||||
qry.finish();
|
||||
|
||||
success = qry.exec("SELECT id FROM topologic");
|
||||
if (!success) {
|
||||
qDebug()<<qry.lastError().text();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (qry.next())
|
||||
{
|
||||
int id = qry.value(0).toInt();
|
||||
structID.topoId = structID.topoId > 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()<<str<<"\n"<<qry.lastError().text();
|
||||
}
|
||||
qry.clear();
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DataBase::updateComponent(QUuid uuid,QString tag,QString name,QJsonObject context)
|
||||
{
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
|
||||
QJsonDocument contextDoc(context);
|
||||
QString strCon = contextDoc.toJson(QJsonDocument::Compact);
|
||||
|
||||
qry.prepare("UPDATE component SET tag=?, name=?, context=?, ts=? WHERE global_uuid=?");
|
||||
qry.bindValue(0,tag);
|
||||
qry.bindValue(1,name);
|
||||
qry.bindValue(2,strCon);
|
||||
qry.bindValue(3,QDateTime::currentDateTime());
|
||||
qry.bindValue(4,uuid);
|
||||
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()<<str<<"\n"<<qry.lastError().text();
|
||||
}
|
||||
qry.clear();
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DataBase::insertPage(QString tag,QString name,int status,QJsonObject label,QJsonObject context,QString description,int op)
|
||||
{
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
|
||||
QJsonDocument labelDoc(label);
|
||||
QString strLabel = labelDoc.toJson(QJsonDocument::Compact);
|
||||
|
||||
QJsonDocument contextDoc(context);
|
||||
QString strCon = contextDoc.toJson(QJsonDocument::Compact);
|
||||
|
||||
qry.prepare("INSERT INTO page(tag, name, status, label, context, description, op, ts) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
qry.bindValue(0,tag);
|
||||
qry.bindValue(1,name);
|
||||
qry.bindValue(2,status);
|
||||
qry.bindValue(3,strLabel);
|
||||
qry.bindValue(4,strCon);
|
||||
qry.bindValue(5,description);
|
||||
qry.bindValue(6,op);
|
||||
qry.bindValue(7,QDateTime::currentDateTime());
|
||||
bool res = qry.exec();
|
||||
QString str = qry.lastQuery();
|
||||
if(!res)
|
||||
{
|
||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||
}
|
||||
qry.clear();
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DataBase::insertStation(int zoneId,QString name,QString description,bool isLocal,int op)
|
||||
{
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
|
||||
qry.prepare("INSERT INTO station(zone_id, name, description, is_local, op, ts) VALUES (?, ?, ?, ?, ?, ?)");
|
||||
qry.bindValue(0,zoneId);
|
||||
qry.bindValue(1,name);
|
||||
qry.bindValue(2,description);
|
||||
qry.bindValue(3,isLocal);
|
||||
qry.bindValue(4,op);
|
||||
qry.bindValue(5,QDateTime::currentDateTime());
|
||||
|
||||
bool res = qry.exec();
|
||||
QString str = qry.lastQuery();
|
||||
if(!res)
|
||||
{
|
||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||
}
|
||||
qry.clear();
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DataBase::insertGrid(QString name,QString description,int op)
|
||||
{
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
qry.prepare("INSERT INTO grid(name, description, op, ts) VALUES (?, ?, ?, ?);");
|
||||
qry.bindValue(0,name);
|
||||
qry.bindValue(1,description);
|
||||
qry.bindValue(2,op);
|
||||
qry.bindValue(3,QDateTime::currentDateTime());
|
||||
bool res = qry.exec();
|
||||
QString str = qry.lastQuery();
|
||||
if(!res)
|
||||
{
|
||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||
}
|
||||
qry.clear();
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DataBase::insertZone(int grid_id,QString name,QString description,int op)
|
||||
{
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
qry.prepare("INSERT INTO zone(grid_id, name, description, op, ts) VALUES (?, ?, ?, ?, ?)");
|
||||
qry.bindValue(0,grid_id);
|
||||
qry.bindValue(1,name);
|
||||
qry.bindValue(2,description);
|
||||
qry.bindValue(3,op);
|
||||
qry.bindValue(4,QDateTime::currentDateTime());
|
||||
bool res = qry.exec();
|
||||
QString str = qry.lastQuery();
|
||||
if(!res)
|
||||
{
|
||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||
}
|
||||
qry.clear();
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DataBase::insertTopologic(int page_id,QUuid uuid_from,QUuid uuid_to,int flag,QString description,int op)
|
||||
{
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
qry.prepare("INSERT INTO topologic(page_id, uuid_from, uuid_to, flag, description, op, ts) VALUES (?, ?, ?, ?, ?, ?, ?);");
|
||||
qry.bindValue(0,page_id);
|
||||
qry.bindValue(1,uuid_from);
|
||||
qry.bindValue(2,uuid_to);
|
||||
qry.bindValue(3,flag);
|
||||
qry.bindValue(4,description);
|
||||
qry.bindValue(5,op);
|
||||
qry.bindValue(6,QDateTime::currentDateTime());
|
||||
bool res = qry.exec();
|
||||
QString str = qry.lastQuery();
|
||||
if(!res)
|
||||
{
|
||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||
}
|
||||
qry.clear();
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool DataBase::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)
|
||||
{
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
|
||||
qry.prepare("INSERT INTO bus_stability(component_id, resistance, anchor_v, uv_alarm, ov_alarm, anchor_i, ui_alarm, oi_alarm, op, ts) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
qry.bindValue(0,componentId);
|
||||
qry.bindValue(1,resistance);
|
||||
qry.bindValue(2,anchor_v);
|
||||
qry.bindValue(3,uv_alarm);
|
||||
qry.bindValue(4,ov_alarm);
|
||||
qry.bindValue(5,anchor_i);
|
||||
qry.bindValue(6,ui_alarm);
|
||||
qry.bindValue(7,oi_alarm);
|
||||
qry.bindValue(8,op);
|
||||
qry.bindValue(9,QDateTime::currentDateTime());
|
||||
bool res = qry.exec();
|
||||
QString str = qry.lastQuery();
|
||||
if(!res)
|
||||
{
|
||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DataBase::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)
|
||||
{
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
|
||||
qry.prepare("UPDATE bus_stability SET resistance=?, anchor_v=?, uv_alarm=?, ov_alarm=?, anchor_i=?, ui_alarm=?, oi_alarm=?, op=?, ts=? WHERE component_id=?");
|
||||
qry.bindValue(0,resistance);
|
||||
qry.bindValue(1,anchor_v);
|
||||
qry.bindValue(2,uv_alarm);
|
||||
qry.bindValue(3,ov_alarm);
|
||||
qry.bindValue(4,anchor_i);
|
||||
qry.bindValue(5,ui_alarm);
|
||||
qry.bindValue(6,oi_alarm);
|
||||
qry.bindValue(7,op);
|
||||
qry.bindValue(8,QDateTime::currentDateTime());
|
||||
qry.bindValue(9,componentId);
|
||||
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()<<str<<"\n"<<qry.lastError().text();
|
||||
}
|
||||
qry.clear();
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
busStability DataBase::getBusStabilityById(int componentId)
|
||||
{
|
||||
busStability inf;
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
|
||||
//qry.prepare("SELECT * FROM component WHERE global_uuid = ?");
|
||||
qry.prepare("SELECT id, component_id, resistance, anchor_v, uv_alarm, ov_alarm, anchor_i, ui_alarm, oi_alarm, op FROM bus_stability WHERE component_id = ?");
|
||||
qry.bindValue(0,componentId);
|
||||
bool res = qry.exec();
|
||||
QString str = qry.lastQuery();
|
||||
if(!res)
|
||||
{
|
||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||
qry.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (qry.next())
|
||||
{
|
||||
int id = qry.value(0).toInt();
|
||||
inf.componentId = qry.value(1).toInt();
|
||||
inf.resistance = qry.value(2).toDouble();
|
||||
inf.anchor_v = qry.value(3).toBool();
|
||||
inf.uv_alarm = qry.value(4).toDouble();
|
||||
inf.ov_alarm = qry.value(5).toDouble();
|
||||
inf.anchor_i = qry.value(6).toBool();
|
||||
inf.ui_alarm = qry.value(7).toDouble();
|
||||
inf.oi_alarm = qry.value(8).toDouble();
|
||||
qry.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
return inf;
|
||||
}
|
||||
/************************************************************/
|
||||
componentInfo DataBase::getComponentInfoByUuid(QString uuid)
|
||||
{
|
||||
componentInfo inf;
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
|
||||
//qry.prepare("SELECT * FROM component WHERE global_uuid = ?");
|
||||
qry.prepare("SELECT id, global_uuid, tag, name, grid, zone, station, type, context, page_id, op FROM component WHERE global_uuid = ?");
|
||||
qry.bindValue(0,uuid);
|
||||
bool res = qry.exec();
|
||||
QString str = qry.lastQuery();
|
||||
if(!res)
|
||||
{
|
||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||
qry.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (qry.next())
|
||||
{
|
||||
inf.id = qry.value(0).toInt();
|
||||
inf.uuid = QUuid(qry.value(1).toString());
|
||||
inf.tag = qry.value(2).toString();
|
||||
inf.name = qry.value(3).toString();
|
||||
inf.grid = qry.value(4).toString();
|
||||
inf.zone = qry.value(5).toString();
|
||||
inf.station = qry.value(6).toString();
|
||||
inf.type = qry.value(7).toInt();
|
||||
QString str = qry.value(8).toString();
|
||||
inf.context = QstringToJson(str);
|
||||
inf.page_id = qry.value(9).toInt();
|
||||
inf.op = qry.value(10).toInt();
|
||||
qry.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
return inf;
|
||||
}
|
||||
|
||||
QList<componentInfo> DataBase::getAllComponents()
|
||||
{
|
||||
QList<componentInfo> 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()<<str<<"\n"<<qry.lastError().text();
|
||||
qry.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (qry.next())
|
||||
{
|
||||
componentInfo inf;
|
||||
inf.id = qry.value(0).toInt();
|
||||
inf.uuid = QUuid(qry.value(1).toString());
|
||||
inf.tag = qry.value(2).toString();
|
||||
inf.name = qry.value(3).toString();
|
||||
inf.grid = qry.value(4).toString();
|
||||
inf.zone = qry.value(5).toString();
|
||||
inf.station = qry.value(6).toString();
|
||||
inf.type = qry.value(7).toInt();
|
||||
QString str = qry.value(8).toString();
|
||||
inf.context = QstringToJson(str);
|
||||
inf.page_id = qry.value(9).toInt();
|
||||
inf.op = qry.value(10).toInt();
|
||||
lst.push_back(inf);
|
||||
}
|
||||
qry.clear();
|
||||
}
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
bool DataBase::componentExist(QString uuid)
|
||||
{
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
|
||||
qry.prepare("SELECT id FROM component WHERE global_uuid = ?");
|
||||
qry.bindValue(0,uuid);
|
||||
bool res = qry.exec();
|
||||
QString str = qry.lastQuery();
|
||||
if(!res)
|
||||
{
|
||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||
qry.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(qry.size() > 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()<<str<<"\n"<<qry.lastError().text();
|
||||
}
|
||||
qry.clear();
|
||||
return res;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/************************************************************/
|
||||
|
||||
bool DataBase::updatePage(QString tag,QString name,QJsonObject context)
|
||||
{
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
|
||||
QJsonDocument contextDoc(context);
|
||||
QString strCon = contextDoc.toJson(QJsonDocument::Compact);
|
||||
|
||||
qry.prepare("UPDATE page SET name=?, context=?, ts=? WHERE tag=?");
|
||||
qry.bindValue(0,name);
|
||||
qry.bindValue(1,strCon);
|
||||
qry.bindValue(2,QDateTime::currentDateTime());
|
||||
qry.bindValue(3,tag);
|
||||
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()<<str<<"\n"<<qry.lastError().text();
|
||||
}
|
||||
qry.clear();
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
int DataBase::getPageIdByName(QString name)
|
||||
{
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
|
||||
qry.prepare("SELECT id FROM page WHERE tag = ?");
|
||||
qry.bindValue(0,name);
|
||||
bool res = qry.exec();
|
||||
QString str = qry.lastQuery();
|
||||
if(!res)
|
||||
{
|
||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||
qry.clear();
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (qry.next())
|
||||
{
|
||||
int id = qry.value(0).toInt();
|
||||
qry.clear();
|
||||
return id;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
QJsonObject DataBase::getPageContextByName(QString name)
|
||||
{
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
|
||||
qry.prepare("SELECT context FROM page WHERE tag = ?");
|
||||
qry.bindValue(0,name);
|
||||
bool res = qry.exec();
|
||||
QString str = qry.lastQuery();
|
||||
if(!res)
|
||||
{
|
||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||
qry.clear();
|
||||
return QJsonObject();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (qry.next())
|
||||
{
|
||||
|
||||
QString str = qry.value(0).toString();
|
||||
QJsonObject obj = QstringToJson(str);
|
||||
qry.clear();
|
||||
return obj;
|
||||
}
|
||||
return QJsonObject();
|
||||
}
|
||||
}
|
||||
else
|
||||
return QJsonObject();
|
||||
}
|
||||
|
||||
QStringList DataBase::getAllPage()
|
||||
{
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
qry.prepare("SELECT tag FROM page");
|
||||
bool res = qry.exec();
|
||||
if(!res)
|
||||
{
|
||||
qDebug()<<qry.lastError().text();
|
||||
qry.clear();
|
||||
return QStringList();
|
||||
}
|
||||
else
|
||||
{
|
||||
QStringList lst;
|
||||
while (qry.next())
|
||||
{
|
||||
QString name = qry.value(0).toString();
|
||||
lst.append(name);
|
||||
}
|
||||
qry.clear();
|
||||
return lst;
|
||||
}
|
||||
}
|
||||
else
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
bool DataBase::deleteComponentById(int id)
|
||||
{
|
||||
if(db.open())
|
||||
{
|
||||
QSqlQuery qry(db);
|
||||
|
||||
qry.prepare("DELETE FROM topologic WHERE com_from = ? or com_to = ?");
|
||||
qry.bindValue(0,id);
|
||||
qry.bindValue(1,id);
|
||||
bool res = qry.exec();
|
||||
QString str = qry.lastQuery();
|
||||
if(!res)
|
||||
{
|
||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||
return res;
|
||||
}
|
||||
qry.finish();
|
||||
|
||||
qry.prepare("DELETE FROM component WHERE id = ?");
|
||||
qry.bindValue(0,id);
|
||||
res = qry.exec();
|
||||
str = qry.lastQuery();
|
||||
if(!res)
|
||||
{
|
||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||
}
|
||||
qry.clear();
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void DataBase::select()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DataBase::parallelUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DataBase::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("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;
|
||||
}
|
||||
|
|
@ -0,0 +1,150 @@
|
|||
#include "httpInterface.h"
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QMessageBox>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QJsonArray>
|
||||
|
||||
//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<qint64,double> 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<qint64,double> 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(); //销毁请求对象
|
||||
}
|
||||
|
|
@ -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
|
||||
)
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#pragma once
|
||||
|
||||
#include <QtCore/QUuid>
|
||||
#include <QtWidgets/QGraphicsScene>
|
||||
#include <QtWidgets/QMenu>
|
||||
|
||||
#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;
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -2,19 +2,19 @@
|
|||
#define DESIGNER_SCENE_H
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#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<NodeId> 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
|
||||
|
|
@ -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();
|
||||
//视图操作相关
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef DIAGRAMCAVAS_H
|
||||
#define DIAGRAMCAVAS_H
|
||||
|
||||
#include <QMdiArea>
|
||||
#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<QString,DrawingPanel*> m_mapDrawPanel;
|
||||
int _pageIndex;
|
||||
QString _curPage;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -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<NodeDelegateModelRegistry> registerDataModels();
|
||||
private:
|
||||
Ui::drawingPanel *ui;
|
||||
DesignerView* m_pGraphicsView;
|
||||
DesignerScene* m_pGraphicsScene;
|
||||
SelectorManager* m_pSelectorManager;
|
||||
StatusBar* m_pStatusBar;
|
||||
FixedPortsModel* _pModel;
|
||||
DiagramMode _mode;
|
||||
QString _name;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
#pragma once
|
||||
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
#include <QVector>
|
||||
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QUuid>
|
||||
|
||||
#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<typename T>
|
||||
T nodeData(QUuid nodeId, NodeRole role) const
|
||||
{
|
||||
return nodeData(nodeId, role).value<T>();
|
||||
}
|
||||
|
||||
virtual NodeFlags nodeFlags(NodeId nodeId) const
|
||||
{
|
||||
Q_UNUSED(nodeId);
|
||||
return NodeFlag::NoFlags;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
#pragma once
|
||||
|
||||
#include "graphicsDataModel/baseModel.h"
|
||||
#include "serializable.h"
|
||||
|
||||
#include <QSharedPointer>
|
||||
#include <QJsonObject>
|
||||
#include <QTimer>
|
||||
|
||||
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<QUuid,QPointF> allNodePos() const;
|
||||
QVector<Connection> allConnections();
|
||||
QMap<QUuid,GraphicsBaseItem*>& 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<qint64,double> map);
|
||||
|
||||
private:
|
||||
|
||||
QMap<QUuid,GraphicsBaseItem*> _nodeItem;
|
||||
|
||||
QString _pageName;
|
||||
DesignerScene* _scene;
|
||||
DrawingPanel* _widget; //顶层widget
|
||||
HttpInterface* _Interface;
|
||||
QTimer* _timer;
|
||||
public:
|
||||
static bool _dataInitialised;
|
||||
static QMap<QUuid,BaseProperty*> _nodeData; //一个data可对应多个item
|
||||
};
|
||||
|
||||
|
|
@ -2,15 +2,16 @@
|
|||
#define ELECTRICCONNECTLINEITEM_H
|
||||
|
||||
#include <QPainterPath>
|
||||
#include <QUuid>
|
||||
#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;
|
||||
|
|
@ -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
|
||||
|
|
@ -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<ElectricSvgItemRect_Property*>(_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
|
||||
|
|
@ -17,4 +17,11 @@ private:
|
|||
double m_dBottomRatioX;
|
||||
};
|
||||
|
||||
class ElectricSvgItemTriangle_Property: public BaseProperty
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ElectricSvgItemTriangle_Property(QObject* parent);
|
||||
~ElectricSvgItemTriangle_Property();
|
||||
};
|
||||
#endif
|
||||
|
|
@ -9,6 +9,8 @@
|
|||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QPen>
|
||||
#include <QGraphicsSvgItem>
|
||||
#include <QUuid>
|
||||
#include <QJsonObject>
|
||||
//#include "graphicsItem/itemPort.h"
|
||||
|
||||
enum ShapeType
|
||||
|
|
@ -434,6 +436,7 @@ protected:
|
|||
};
|
||||
|
||||
class ItemPort;
|
||||
class BaseProperty;
|
||||
|
||||
typedef AbstractShapeType<QGraphicsItem> 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<QString,ItemPort*>& 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<QString,ItemPort*> 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
|
||||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef ITEMPROPERTYDLG_H
|
||||
#define ITEMPROPERTYDLG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMetaType>
|
||||
|
||||
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
|
||||
|
|
@ -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; //存储所有对象 类型 <图名<id,对象>>
|
||||
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;
|
||||
|
|
@ -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);
|
||||
|
|
@ -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:
|
||||
|
|
@ -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:
|
||||
|
|
@ -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*);
|
||||
|
|
@ -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<QGraphicsItem *>);
|
||||
|
|
@ -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:
|
||||
|
|
@ -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:
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
#include <QObject>
|
||||
#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<BaseSelector*> m_vecSelectors;
|
||||
FixedPortsModel *_graphModel;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -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*);
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
#include "baseScene.h"
|
||||
|
||||
#include <QUndoStack>
|
||||
|
||||
#include <QtWidgets/QFileDialog>
|
||||
#include <QtWidgets/QGraphicsSceneMoveEvent>
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QDataStream>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QJsonArray>
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -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 <QPainter>
|
||||
#include <QKeyEvent>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QByteArray>
|
||||
|
|
@ -22,17 +26,15 @@
|
|||
#include <QtWidgets/QTreeWidget>
|
||||
#include <QtWidgets/QWidgetAction>
|
||||
|
||||
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<DrawingPanel*>(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<QGraphicsItem*> 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<QGraphicsItem*> listItem = selectedItems();
|
||||
if(listItem.isEmpty())
|
||||
return;
|
||||
else if(listItem.count() == 1)
|
||||
{
|
||||
GraphicsBaseItem* item = qgraphicsitem_cast<GraphicsBaseItem*>(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<NodeId> DesignerScene::selectedNodes() const
|
||||
{
|
||||
QList<QGraphicsItem *> graphicsItems = selectedItems();
|
||||
|
||||
std::vector<NodeId> result;
|
||||
result.reserve(graphicsItems.size());
|
||||
|
||||
/*for (QGraphicsItem *obj : graphicsItems) {
|
||||
auto ngo = qgraphicsitem_cast<NodeGraphicsObject *>(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;
|
||||
}
|
||||
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
#include "designerView.h"
|
||||
#include "designerScene.h"
|
||||
#include <QMouseEvent>
|
||||
|
||||
#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)
|
||||
{
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
#include "drawingPanel.h"
|
||||
#include "diagramCavas.h"
|
||||
#include "mainwindow.h"
|
||||
#include "dataBase.h"
|
||||
#include "graphicsItem/graphicsBaseItem.h"
|
||||
#include <QMdiSubWindow>
|
||||
#include <QMessageBox>
|
||||
#include <QJsonObject>
|
||||
|
||||
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<DrawingPanel*>(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<DrawingPanel*>(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<QUuid,GraphicsBaseItem*> 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;
|
||||
}
|
||||
|
|
@ -0,0 +1,235 @@
|
|||
#include <QJsonArray>
|
||||
#include "drawingPanel.h"
|
||||
#include "ui_drawingPanel.h"
|
||||
#include <QMessageBox>
|
||||
#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<QUuid,GraphicsBaseItem*> 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<QUuid,QPointF> 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<Connection> 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);
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
#include "graphicsDataModel/baseModel.h"
|
||||
|
||||
|
|
@ -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 <QJsonArray>
|
||||
#include <QMessageBox>
|
||||
|
||||
QMap<QUuid,BaseProperty*> 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<QUuid,QPointF> FixedPortsModel::allNodePos() const
|
||||
{
|
||||
QMap<QUuid,QPointF> map;
|
||||
for(auto pItem:_nodeItem)
|
||||
{
|
||||
if(pItem->getItemType() != GIT_link)
|
||||
map.insert(pItem->itemId(),pItem->pos());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
QVector<Connection> FixedPortsModel::allConnections()
|
||||
{
|
||||
QVector<Connection> vec;
|
||||
for(auto pItem:_nodeItem)
|
||||
{
|
||||
if(pItem->getItemType() == GIT_link)
|
||||
{
|
||||
auto pLine = dynamic_cast<ElectricConnectLineItem*>(pItem);
|
||||
if(pLine)
|
||||
{
|
||||
vec.push_back(pLine->getConnection());
|
||||
}
|
||||
}
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
QMap<QUuid,GraphicsBaseItem*>& 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<componentInfo> 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<ElectricSvgItemRect_Property*>(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<ElectricConnectLineItem*>(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<QString,ItemPort*> 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<QPointF>();
|
||||
|
||||
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<ElectricSvgItemRect_Property*>(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<ElectricSvgItemRect_Property*>(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<qint64,double> 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<ElectricSvgItemRect_Property*>(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<QWidget*>(_widget);
|
||||
}
|
||||
|
||||
|
|
@ -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()<<pos;
|
||||
if(callerId == m_connectState.nSrcNodeId)
|
||||
|
|
@ -387,3 +387,11 @@ void ElectricConnectLineItem::updateConnection(int callerId,QPointF pos)
|
|||
qDebug()<<"ConnectLine update err";
|
||||
calculatePath();
|
||||
}
|
||||
|
||||
QUuid ElectricConnectLineItem::getOppositeId(QUuid id)
|
||||
{
|
||||
if(id == m_connectState.nSrcNodeId)
|
||||
return m_connectState.nDestNodeId;
|
||||
else
|
||||
return m_connectState.nSrcNodeId;
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
#include "graphicsItem/electricSvgItemBus.h"
|
||||
#include "graphicsItem/itemControlHandle.h"
|
||||
#include "graphicsItem/itemPort.h"
|
||||
#include "graphicsItem/electricConnectLineItem.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
#include <QJsonArray>
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
#include "graphicsItem/electricSvgItemRect.h"
|
||||
#include "graphicsItem/itemPort.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
|
||||
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>("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<ElectricSvgItemRect_Property*>(_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()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -2,15 +2,19 @@
|
|||
#include "graphicsItem/handleRect.h"
|
||||
#include "graphicsItem/handleText.h"
|
||||
#include "graphicsItem/itemPort.h"
|
||||
#include "graphicsItem/electricConnectLineItem.h"
|
||||
#include <QGraphicsScene>
|
||||
#include <QJsonArray>
|
||||
|
||||
|
||||
GraphicsBaseItem::GraphicsBaseItem(QGraphicsItem *parent)
|
||||
: AbstractShapeType<QGraphicsItem>(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()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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<HandleText*>(pHandle);
|
||||
if(pText)
|
||||
|
|
@ -363,6 +363,18 @@ void BaseSelector::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, Design
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(items.count() == 1) //不是文字节点
|
||||
{
|
||||
GraphicsBaseItem* item = qgraphicsitem_cast<GraphicsBaseItem*>(items.first());
|
||||
if(item)
|
||||
{
|
||||
GraphicsItemType tpe = item->getItemType();
|
||||
if(tpe != GIT_link)
|
||||
{
|
||||
item->showPropertyDlg(_model->getTopWidget());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BaseSelector::setCursor(DesignerScene *scene, const QCursor &cursor)
|
||||
|
|
@ -6,8 +6,8 @@
|
|||
#include <QGraphicsView>
|
||||
#include <graphicsItem/graphicsBaseItem.h>
|
||||
|
||||
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<GraphicsBaseItem*>(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;
|
||||
|
|
@ -9,14 +9,13 @@
|
|||
#include <QGraphicsSvgItem>
|
||||
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
#include <QGraphicsView>
|
||||
|
||||
|
||||
EditingSelector::EditingSelector(QObject *parent)
|
||||
: BaseSelector(parent)
|
||||
EditingSelector::EditingSelector(FixedPortsModel* model,QObject *parent)
|
||||
: BaseSelector(model,parent)
|
||||
{
|
||||
m_type = ST_editing;
|
||||
}
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
#include <QGraphicsView>
|
||||
#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;
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
#include <graphicsItem/graphicsBaseItem.h>
|
||||
#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<QGraphicsItem *> lst)
|
|||
{
|
||||
if(item->getItemType() != GIT_link)
|
||||
{
|
||||
int nId = item->itemId();
|
||||
QUuid nId = item->itemId();
|
||||
for(auto pPort:item->getPorts())
|
||||
{
|
||||
if(pPort->connected())
|
||||
|
|
@ -4,8 +4,8 @@
|
|||
#include <graphicsItem/graphicsBaseItem.h>
|
||||
|
||||
|
||||
RotationSelector::RotationSelector(QObject *parent)
|
||||
: BaseSelector(parent)
|
||||
RotationSelector::RotationSelector(FixedPortsModel* model,QObject *parent)
|
||||
: BaseSelector(model,parent)
|
||||
{
|
||||
m_type = ST_rotation;
|
||||
}
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
#include <QGraphicsView>
|
||||
#include <graphicsItem/graphicsBaseItem.h>
|
||||
|
||||
ScalingSelector::ScalingSelector(QObject *parent)
|
||||
: BaseSelector(parent)
|
||||
ScalingSelector::ScalingSelector(FixedPortsModel* model,QObject *parent)
|
||||
: BaseSelector(model,parent)
|
||||
{
|
||||
m_type = ST_scaling;
|
||||
m_scalBasePoint = QPointF();
|
||||
|
|
@ -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);
|
||||
|
||||
|
|
@ -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;
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>drawingPanel</class>
|
||||
<widget class="QWidget" name="drawingPanel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>801</width>
|
||||
<height>501</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="mainLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../resource/DiagramDesigner.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -0,0 +1,331 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>itemPropertyDlg</class>
|
||||
<widget class="QDialog" name="itemPropertyDlg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>642</width>
|
||||
<height>552</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_title" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(183, 183, 183);</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" columnstretch="1,4">
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QStackedWidget" name="stackedWidget_button">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_JianGeXinXi">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>间隔信息</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>471</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Microsoft YaHei UI</family>
|
||||
<pointsize>10</pointsize>
|
||||
<italic>false</italic>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(224, 224, 224);
|
||||
color:black;
|
||||
font: 10pt "Microsoft YaHei UI";</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_JianGeXinXi">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>间隔信息</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2" rowstretch="0,0,0,0" columnstretch="1,1,1,1,2,1,1,2">
|
||||
<item row="0" column="6" colspan="2">
|
||||
<widget class="QCheckBox" name="cb_MaoDingDianLiu">
|
||||
<property name="text">
|
||||
<string>是否锚定电流</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5" rowspan="4">
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4" rowspan="2">
|
||||
<widget class="QDoubleSpinBox" name="sp_DianYaXiaXian">
|
||||
<property name="value">
|
||||
<double>90.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>电压下限</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="4">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="6">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>电流下限</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QDoubleSpinBox" name="sp_DianYaShangXian">
|
||||
<property name="maximum">
|
||||
<double>200.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>110.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="2">
|
||||
<widget class="QDoubleSpinBox" name="sp_DianZu">
|
||||
<property name="maximum">
|
||||
<double>10000.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" colspan="2">
|
||||
<widget class="QCheckBox" name="cb_MaoDingDianYa">
|
||||
<property name="text">
|
||||
<string>是否锚定电压</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="6">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>电流上限</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="7">
|
||||
<widget class="QDoubleSpinBox" name="sp_DianLiuXiaXian">
|
||||
<property name="value">
|
||||
<double>45.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="7" rowspan="2">
|
||||
<widget class="QDoubleSpinBox" name="sp_DianLiuShangXian">
|
||||
<property name="maximum">
|
||||
<double>200.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>55.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>电压上限</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>电阻</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>354</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>223</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_cancel_jianGe">
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_apply_jianGe">
|
||||
<property name="text">
|
||||
<string>应用</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_ok_jianGe">
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_4"/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -1,245 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
#include <QVector>
|
||||
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
#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<NodeId> allNodeIds() const = 0;
|
||||
|
||||
/**
|
||||
* A collection of all input and output connections for the given `nodeId`.
|
||||
*/
|
||||
virtual QSet<ConnectionId> 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<ConnectionId> 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<typename T>
|
||||
T nodeData(NodeId nodeId, NodeRole role) const
|
||||
{
|
||||
return nodeData(nodeId, role).value<T>();
|
||||
}
|
||||
|
||||
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<typename T>
|
||||
T portData(NodeId nodeId, PortType portType, PortIndex index, PortRole role) const
|
||||
{
|
||||
return portData(nodeId, portType, index, role).value<T>();
|
||||
}
|
||||
|
||||
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<ConnectionId> _shiftedByDynamicPortsConnections;
|
||||
};
|
||||
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include <QRectF>
|
||||
#include <QSize>
|
||||
#include <QTransform>
|
||||
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
#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;
|
||||
};
|
||||
|
|
@ -1,168 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QtCore/QUuid>
|
||||
#include <QtWidgets/QGraphicsScene>
|
||||
#include <QtWidgets/QMenu>
|
||||
|
||||
#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<AbstractNodePainter> 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<ConnectionGraphicsObject> 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<NodeGraphicsObject>;
|
||||
|
||||
using UniqueConnectionGraphicsObject = QSharedPointer<ConnectionGraphicsObject>;
|
||||
|
||||
QMap<NodeId, UniqueNodeGraphicsObject> _nodeGraphicsObjects;
|
||||
|
||||
QMap<ConnectionId, UniqueConnectionGraphicsObject> _connectionGraphicsObjects;
|
||||
|
||||
QSharedPointer<ConnectionGraphicsObject> _draftConnection;
|
||||
|
||||
QSharedPointer<AbstractNodeGeometry> _nodeGeometry;
|
||||
|
||||
QSharedPointer<AbstractNodePainter> _nodePainter;
|
||||
|
||||
bool _nodeDrag;
|
||||
|
||||
QUndoStack *_undoStack;
|
||||
|
||||
Qt::Orientation _orientation;
|
||||
};
|
||||
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <QtCore/QUuid>
|
||||
#include <QtWidgets/QGraphicsObject>
|
||||
|
||||
#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<QPointF, QPointF> 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<QPointF, QPointF> pointsC1C2Horizontal() const;
|
||||
|
||||
std::pair<QPointF, QPointF> pointsC1C2Vertical() const;
|
||||
|
||||
private:
|
||||
ConnectionId _connectionId;
|
||||
|
||||
AbstractGraphModel &_graphModel;
|
||||
|
||||
ConnectionState _connectionState;
|
||||
|
||||
mutable QPointF _out;
|
||||
mutable QPointF _in;
|
||||
};
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
||||
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<qint64>(connId.outNodeId);
|
||||
connJson["outPortIndex"] = static_cast<qint64>(connId.outPortIndex);
|
||||
connJson["intNodeId"] = static_cast<qint64>(connId.inNodeId);
|
||||
connJson["inPortIndex"] = static_cast<qint64>(connId.inPortIndex);
|
||||
|
||||
return connJson;
|
||||
}
|
||||
|
||||
inline ConnectionId fromJson(QJsonObject const &connJson)
|
||||
{
|
||||
ConnectionId connId{static_cast<NodeId>(connJson["outNodeId"].toInt(InvalidNodeId)),
|
||||
static_cast<PortIndex>(connJson["outPortIndex"].toInt(InvalidPortIndex)),
|
||||
static_cast<NodeId>(connJson["intNodeId"].toInt(InvalidNodeId)),
|
||||
static_cast<PortIndex>(connJson["inPortIndex"].toInt(InvalidPortIndex))};
|
||||
|
||||
return connId;
|
||||
}
|
||||
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QPainterPath>
|
||||
|
||||
#include "global.h"
|
||||
|
||||
class ConnectionGeometry;
|
||||
class ConnectionGraphicsObject;
|
||||
|
||||
class ConnectionPainter
|
||||
{
|
||||
public:
|
||||
static void paint(QPainter *painter, ConnectionGraphicsObject const &cgo);
|
||||
|
||||
static QPainterPath getPainterStroke(ConnectionGraphicsObject const &cgo);
|
||||
};
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QtCore/QUuid>
|
||||
|
||||
#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};
|
||||
};
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QtGui/QColor>
|
||||
|
||||
#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;
|
||||
};
|
||||
|
||||
|
|
@ -1,131 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "abstractGraphModel.h"
|
||||
#include "connectionIdUtils.h"
|
||||
#include "nodeDelegateModelRegistry.h"
|
||||
#include "serializable.h"
|
||||
#include "styleCollection.h"
|
||||
|
||||
#include <QSharedPointer>
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
class DataFlowGraphModel : public AbstractGraphModel, public Serializable
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
struct NodeGeometryData
|
||||
{
|
||||
QSize size;
|
||||
QPointF pos;
|
||||
};
|
||||
|
||||
public:
|
||||
DataFlowGraphModel(QSharedPointer<NodeDelegateModelRegistry> registry);
|
||||
|
||||
QSharedPointer<NodeDelegateModelRegistry> dataModelRegistry() { return _registry; }
|
||||
|
||||
public:
|
||||
QSet<NodeId> allNodeIds() const override;
|
||||
|
||||
QSet<ConnectionId> allConnectionIds(NodeId const nodeId) const override;
|
||||
|
||||
QSet<ConnectionId> 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<typename NodeDelegateModelType>
|
||||
NodeDelegateModelType *delegateModel(NodeId const nodeId)
|
||||
{
|
||||
auto it = _models.find(nodeId);
|
||||
if (it == _models.end())
|
||||
return nullptr;
|
||||
|
||||
//auto model = dynamic_cast<NodeDelegateModelType *>(it->second.get());
|
||||
auto model = dynamic_cast<NodeDelegateModelType *>(*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<NodeDelegateModelRegistry> _registry;
|
||||
|
||||
NodeId _nextNodeId;
|
||||
|
||||
QMap<NodeId, QSharedPointer<NodeDelegateModel>> _models;
|
||||
|
||||
QSet<ConnectionId> _connectivity;
|
||||
|
||||
mutable QMap<NodeId, NodeGeometryData> _nodeGeometryData;
|
||||
};
|
||||
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "abstractNodeGeometry.h"
|
||||
|
||||
#include <QtGui/QFontMetrics>
|
||||
|
||||
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;
|
||||
};
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QtGui/QPainter>
|
||||
|
||||
#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;
|
||||
};
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "abstractNodeGeometry.h"
|
||||
|
||||
#include <QtGui/QFontMetrics>
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
#ifndef DIAGRAMCAVAS_H
|
||||
#define DIAGRAMCAVAS_H
|
||||
|
||||
#include <QMdiArea>
|
||||
#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<QString,DrawingPanel*> m_mapDrawPanel;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,131 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "abstractGraphModel.h"
|
||||
#include "connectionIdUtils.h"
|
||||
#include "nodeDelegateModelRegistry.h"
|
||||
#include "serializable.h"
|
||||
#include "styleCollection.h"
|
||||
|
||||
#include <QSharedPointer>
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
class FixedPortsModel : public AbstractGraphModel, public Serializable
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
struct NodeGeometryData
|
||||
{
|
||||
QSize size;
|
||||
QPointF pos;
|
||||
};
|
||||
|
||||
public:
|
||||
FixedPortsModel(QSharedPointer<NodeDelegateModelRegistry> registry);
|
||||
|
||||
QSharedPointer<NodeDelegateModelRegistry> dataModelRegistry() { return _registry; }
|
||||
|
||||
public:
|
||||
QSet<NodeId> allNodeIds() const override;
|
||||
|
||||
QSet<ConnectionId> allConnectionIds(NodeId const nodeId) const override;
|
||||
|
||||
QSet<ConnectionId> 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<typename NodeDelegateModelType>
|
||||
NodeDelegateModelType *delegateModel(NodeId const nodeId)
|
||||
{
|
||||
auto it = _models.find(nodeId);
|
||||
if (it == _models.end())
|
||||
return nullptr;
|
||||
|
||||
//auto model = dynamic_cast<NodeDelegateModelType *>(it->second.get());
|
||||
auto model = dynamic_cast<NodeDelegateModelType *>(*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<NodeDelegateModelRegistry> _registry;
|
||||
|
||||
NodeId _nextNodeId;
|
||||
|
||||
QMap<NodeId, QSharedPointer<NodeDelegateModel>> _models;
|
||||
|
||||
QSet<ConnectionId> _connectivity;
|
||||
|
||||
mutable QMap<NodeId, NodeGeometryData> _nodeGeometryData;
|
||||
};
|
||||
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QtNodes/NodeDelegateModel>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#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<NodeData> outData(PortIndex port) override;
|
||||
|
||||
void setInData(std::shared_ptr<NodeData> data, PortIndex portIndex) override;
|
||||
|
||||
QWidget *embeddedWidget() override;
|
||||
|
||||
double number() const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<DecimalData> _numberData;
|
||||
|
||||
QLabel *_label;
|
||||
};
|
||||
|
|
@ -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
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QtGui/QColor>
|
||||
|
||||
#include "style.h"
|
||||
|
||||
|
||||
class GraphicsViewStyle : public Style
|
||||
{
|
||||
public:
|
||||
GraphicsViewStyle();
|
||||
|
||||
GraphicsViewStyle(QString jsonText);
|
||||
|
||||
~GraphicsViewStyle() = default;
|
||||
|
||||
public:
|
||||
static void setStyle(QString jsonText);
|
||||
|
||||
private:
|
||||
void loadJson(QJsonObject const &json) override;
|
||||
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
public:
|
||||
QColor BackgroundColor;
|
||||
QColor FineGridColor;
|
||||
QColor CoarseGridColor;
|
||||
};
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef LOADPAGEDLG_H
|
||||
#define LOADPAGEDLG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class loadPageDlg; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class LoadPageDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LoadPageDlg(QWidget *parent = nullptr);
|
||||
~LoadPageDlg();
|
||||
|
||||
void initial();
|
||||
void updateList();
|
||||
signals:
|
||||
void selectedPage(const QString&);
|
||||
public slots:
|
||||
void onOkClicked();
|
||||
void onCancelClicked();
|
||||
void onItemChanged(const QModelIndex& current);
|
||||
private:
|
||||
Ui::loadPageDlg *ui;
|
||||
QStandardItemModel* m_standardItemModel;
|
||||
QString _pageName;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QtCore/QPointF>
|
||||
#include <QtGui/QTransform>
|
||||
|
||||
class QGraphicsScene;
|
||||
|
||||
class NodeGraphicsObject;
|
||||
|
||||
NodeGraphicsObject *locateNodeAt(QPointF scenePoint,
|
||||
QGraphicsScene &scene,
|
||||
QTransform const &viewTransform);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue