新增文字标签,新增折线拖拽功能

This commit is contained in:
baiYue 2024-12-13 18:08:00 +08:00
parent deec2c2d63
commit c1b1a0eb2e
33 changed files with 1595 additions and 147 deletions

View File

@ -53,15 +53,19 @@ set(H_HEADER_FILES
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
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
@ -119,15 +123,19 @@ set(CPP_SOURCE_FILES
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

315
CMakeLists.txt.user.180d0b4 Normal file
View File

@ -0,0 +1,315 @@
<?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 &quot;dwarf,4096&quot; -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>

315
CMakeLists.txt.user.f86a295 Normal file
View File

@ -0,0 +1,315 @@
<?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 &quot;dwarf,4096&quot; -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>

View File

@ -6,8 +6,8 @@
#include <QtSwap>
#include <QHash>
const double g_dGriaphicsScene_Width = 600;
const double g_dGriaphicsScene_Height = 450;
const double g_dGriaphicsScene_Width = 800;
const double g_dGriaphicsScene_Height = 600;
//Q_NAMESPACE
enum GraphicsItemType
@ -22,7 +22,7 @@ enum GraphicsItemType
GIT_bus = QGraphicsItem::UserType + 50,
GIT_itemRect = QGraphicsItem::UserType + 51,
GIT_itemTri = QGraphicsItem::UserType + 52,
GIT_connectLine = QGraphicsItem::UserType + 53
GIT_link= QGraphicsItem::UserType + 53
};
//Q_ENUM_NS(GraphicsItemType)

View File

@ -9,9 +9,11 @@ struct Connection
int nSrcNodeId;
int nSrcPort;
HandleType srcType;
PortPos srcPos;
int nDestNodeId;
int nDestPort;
HandleType destType;
PortPos destPos;
Connection()
{
@ -19,19 +21,23 @@ struct Connection
nSrcNodeId = -1;
nSrcPort = -1;
srcType = T_none;
srcPos = P_top;
nDestNodeId = -1;
nDestPort = -1;
destType = T_none;
destPos = P_top;
}
Connection(int nSNI,int nSP,HandleType sT,int nDNI,int nDP,HandleType dT)
Connection(int nSNI,int nSP,HandleType sT,PortPos sPOS,int nDNI,int nDP,HandleType dT,PortPos dPOS)
{
nSrcNodeId = nSNI;
nSrcPort = nSP;
srcType = sT;
srcPos = sPOS;
nDestNodeId = nDNI;
nDestPort = nDP;
destType = dT;
destPos = dPOS;
}
bool operator==(Connection& obj)
{
@ -45,9 +51,11 @@ struct Connection
nSrcNodeId = obj.nSrcNodeId;
nSrcPort = obj.nSrcPort;
srcType = obj.srcType;
srcPos = obj.srcPos;
nDestNodeId = obj.nDestNodeId;
nDestPort = obj.nDestPort;
destType = obj.destType;
destPos = obj.destPos;
return *this;
}
};
@ -58,23 +66,30 @@ public:
ElectricConnectLineItem(QGraphicsItem *parent = 0);
virtual ~ElectricConnectLineItem();
void setStartPoint(const QPointF& p){m_pStart = p;}
void setEndPoint(const QPointF& p){m_pEnd = p;}
void setStartPoint(const QPointF& p);
void setEndPoint(const QPointF& p);
QPainterPath getPoints(void) const { return m_points; }
void moveLine(QPointF); //鼠标点击拖动
void calculatePath();
bool addConnection();
void resetCurLine(){_curLine = QPoint();}
void updateConnection(int callerId,QPointF pos); //外部调用的更新函数,id为调用者id
void setConnection(Connection con){m_connectState = con;}
protected:
virtual QPainterPath shape();
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
virtual QPainterPath shape() const override;
virtual QRectF boundingRect() const override;
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
private:
Connection m_connectState;
QPainterPath m_points;
QPointF m_pStart;
QPointF m_pEnd;
Connection m_connectState;
QPainterPath m_points;
QPainterPath m_pointsBoundingRect; //包裹点的矩形集合
QList<QPointF> m_lstPoints;
QPoint _curLine; //参数1用点序号表示的当前线段起始点,参数2表示线段方向
//QPointF m_pStart;
//QPointF m_pEnd;
};
#endif

View File

@ -9,7 +9,7 @@
#include <QGraphicsSceneMouseEvent>
#include <QPen>
#include <QGraphicsSvgItem>
//#include "graphicsItem/itemPort.h"
enum ShapeType
{
@ -199,6 +199,21 @@ public:
}
}
}
virtual void setHandleIfShow(int tag,bool bVisible) //是否参与显示判断
{
foreach (int key, m_vecHanle.keys())
{
ItemControlHandle* pHandle = m_vecHanle.value(key);
if(pHandle)
{
if(pHandle->getTag() == tag)
{
pHandle->setIfShow(bVisible);
break;
}
}
}
}
virtual void setFunctionHandleIfShow(bool bVisible) //是否参与显示判断
{
foreach (int key, m_vecHanle.keys())
@ -398,6 +413,7 @@ public:
virtual void syncRotationDataFromParent(const double&) {}
virtual double getSyncRotationDataFromParent() {return m_dSyncRotationByParent;}
virtual void setTouched(bool b){m_touched = b;}
virtual void setLastPoint(QPointF p) {m_lastPoint = p;}
protected:
ShapeType m_type;
QPen m_pen;
@ -412,7 +428,7 @@ protected:
QGraphicsPathItem* m_pOperationCopy; //图元移动和旋转时的操作副本
QPointF m_movingIniPos; //移动副本开始移动初始
QPointF m_lastPoint; //鼠标上次点击位置
QMap<int,ItemControlHandle*> m_vecHanle;
};
@ -451,6 +467,7 @@ public:
virtual void setLastPort(int n){_lastPort = n;}
virtual int getLastPort() const {return _lastPort;}
virtual ItemPort* getPortPtr(int) const;
virtual ItemControlHandle* getHandlePtr(int) const;
virtual QMap<QString,ItemPort*>& getPorts() {return m_mapPort;}
protected:
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange, const QVariant&);

View File

@ -0,0 +1,19 @@
#ifndef HANDLERECT_H
#define HANDLERECT_H
#include "graphicsItem/itemControlHandle.h"
class HandleRect : public ItemControlHandle
{
Q_OBJECT
public:
HandleRect(QGraphicsItem *parent);
virtual ~HandleRect();
protected:
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent*) override;
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override;
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
virtual QRectF boundingRect() const override;
};
#endif

View File

@ -0,0 +1,33 @@
#ifndef HANDLETEXT_H
#define HANDLETEXT_H
#include <QFont>
#include "graphicsItem/itemControlHandle.h"
int const TEXT_WIDTH = 30;
int const TEXT_HEIGHT = 15;
class QGraphicsProxyWidget;
class HandleText : public ItemControlHandle
{
Q_OBJECT
public:
HandleText(QGraphicsItem *parent);
virtual ~HandleText();
void setText(QString);
void creatEditor(); //创建editor编辑文本
void setEditable(bool b){_editable = b;}
protected:
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
virtual QRectF boundingRect() const override;
private:
QString _text;
QFont _font;
QRectF _boundingRect;
QGraphicsProxyWidget* _proxy;
bool _editable;
};
#endif

View File

@ -9,6 +9,7 @@ enum HandleType
T_resize, //调整大小
T_rotate, //旋转
T_editShape, //编辑形状
T_text, //文本
T_lineIn, //入线口
T_lineOut, //出线口
T_lineInOut //双端线
@ -30,6 +31,7 @@ enum HandleTag
H_rotate_rightBottom,
H_rotate_leftBottom, //12
H_edit,
H_textCaption = 40, //标题文本
H_connect = 50 //连接操作点从50开始前面预留
};
@ -43,7 +45,9 @@ enum PortPos
const int HNDLE_SIZE = 8;
class ItemControlHandle : public QObject,public QGraphicsRectItem
class GraphicsBaseItem;
class ItemControlHandle : public QObject,public QGraphicsItem
{
Q_OBJECT
@ -52,30 +56,33 @@ public:
virtual ~ItemControlHandle();
public:
virtual int getSize();
virtual void move(double, double);
void setType(HandleType ht) { m_type = ht; }
HandleType getType() { return m_type; }
void setTag(int ht) { m_tag = ht; }
int getTag() { return m_tag; }
int getSize();
void move(double, double);
void setEnable(bool b){m_enable = b;}
bool enable(){return m_enable;}
void setIfShow(bool b){m_ifShow = b;}
bool ifShow(){return m_ifShow;}
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;
protected:
HandleType m_type;
int m_tag;
bool m_enable;
bool m_ifShow;
GraphicsBaseItem* _parent;
};
#endif

View File

@ -1,11 +1,11 @@
#ifndef ITEMPORT_H
#define ITEMPORT_H
#include "graphicsItem/itemControlHandle.h"
#include "graphicsItem/handleRect.h"
class ElectricConnectLineItem;
class ItemPort : public ItemControlHandle
class ItemPort : public HandleRect
{
Q_OBJECT

View File

@ -21,6 +21,8 @@ enum SelectorType
ST_scaling, //缩放
ST_rotation, //旋转
ST_connecting, //连接
ST_subMoving, //子对象移动
ST_linkMoving, //连接线移动
};
enum OperationMode
@ -32,6 +34,8 @@ enum OperationMode
OM_scale, //缩放
OM_rotate, //旋转
OM_connect, //连接
OM_subMove,//子对象移动
OM_linkMove, //连接线移动
};
class GraphicsBaseItem;

View File

@ -0,0 +1,30 @@
/**
*\file linkMovingSelector.h
*
*\brief 线selectormovingSelector作区分
*
*\author by
*/
#ifndef LINKMOVINGSELECTOR_H
#define LINKMOVINGSELECTOR_H
#include "baseSelector.h"
class ElectricConnectLineItem;
class LinkMovingSelector : public BaseSelector
{
Q_OBJECT
public:
explicit LinkMovingSelector(QObject *parent = 0);
virtual ~LinkMovingSelector();
public:
void mousePressEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
void mouseMoveEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
void mouseReleaseEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
private:
ElectricConnectLineItem* m_pMovingLine;
};
#endif

View File

@ -0,0 +1,28 @@
/**
*\file subMovingSelector.h
*
*\brief selectormovingSelector作区分
*
*\author by
*/
#ifndef SUBMOVINGSELECTOR_H
#define SUBMOVINGSELECTOR_H
#include "baseSelector.h"
class SubMovingSelector : public BaseSelector
{
Q_OBJECT
public:
explicit SubMovingSelector(QObject *parent = 0);
virtual ~SubMovingSelector();
public:
void mousePressEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
void mouseMoveEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
void mouseReleaseEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
private:
GraphicsBaseItem* m_pParentItem;
};
#endif

View File

@ -109,7 +109,7 @@ void DesignerScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* mouseEvent)
update();
}
else
QGraphicsScene::mouseReleaseEvent(mouseEvent);
QGraphicsScene::mouseDoubleClickEvent(mouseEvent);
}
void DesignerScene::keyPressEvent(QKeyEvent* event)

View File

@ -1,52 +1,384 @@
#include "graphicsItem/electricConnectLineItem.h"
#include <QGraphicsScene>
#include <QPainter>
#include <QStyleOptionGraphicsItem>
ElectricConnectLineItem::ElectricConnectLineItem(QGraphicsItem *parent)
: GraphicsBaseItem(parent)
{
m_boundingRect = QRectF();
m_pen = QPen(Qt::black);
m_brush = QBrush(Qt::NoBrush);
setHandleVisible(false);
setFunctionHandleIfShow(false);
setFunctionHandleEnaable(false);
m_lstPoints.push_back(QPointF()); //起点
m_lstPoints.push_back(QPointF()); //终点
_curLine = QPoint();
}
ElectricConnectLineItem::~ElectricConnectLineItem()
{
}
QPainterPath ElectricConnectLineItem::shape()
void ElectricConnectLineItem::setStartPoint(const QPointF& p)
{
int n = m_lstPoints.size();
if(n)
{
if(n >2)
{
if(m_lstPoints[0].x() == m_lstPoints[1].x()) //相邻点在垂直方向,水平移动,否则垂直移动
{
m_lstPoints[1].setX(p.x());
}
else
{
m_lstPoints[1].setY(p.y());
}
}
m_lstPoints[0] = p;
}
}
void ElectricConnectLineItem::setEndPoint(const QPointF& p)
{
int n = m_lstPoints.size();
if(n)
{
if(n >2)
{
if(m_lstPoints[n-1].x() == m_lstPoints[n-2].x()) //相邻点在垂直方向,水平移动,否则垂直移动
{
m_lstPoints[n-2].setX(p.x());
}
else
{
m_lstPoints[n-2].setY(p.y());
}
}
m_lstPoints[n-1] = p;
}
}
QPainterPath ElectricConnectLineItem::shape() const
{
QPainterPath path;
path.addPath(m_points);
path.closeSubpath(); //将路径闭合
//path.addPath(m_points);
path.addPath(m_pointsBoundingRect);
return path;
}
QRectF ElectricConnectLineItem::boundingRect() const
{
return m_boundingRect;
}
void ElectricConnectLineItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
painter->setPen(m_pen);
if (option->state & QStyle::State_Selected)
{
painter->setPen(Qt::red);
}
else
{
painter->setPen(m_pen);
}
painter->setBrush(m_brush);
painter->drawPath(m_points);
}
void ElectricConnectLineItem::moveLine(QPointF pos)
{
QPointF delta = pos - m_lastPoint;
if(_curLine.isNull())
{
if(m_lstPoints.size() > 1)
{
int n = m_lstPoints.size();
for(int i = 0;i < m_lstPoints.size() -1;++i)
{
QPointF p1 = m_lstPoints[i];
QPointF p2 = m_lstPoints[i+1];
if(p1.x() == p2.x() && abs(p1.x() - pos.x()) < 2) //在相同竖线
{
if(p1.y() > p2.y())
{
if(pos.y() > p2.y() && pos.y() < p1.y()) //在竖线上
{
if(i == 0 ) //起点是连接点,创建复制点
{
m_lstPoints.prepend(p1);
m_lstPoints.prepend(p1);
i+=2;
if(m_lstPoints.size() < 6) //补齐后端
{
m_lstPoints.append(m_lstPoints.last());
}
}
if(i+1 == n-1) //终点是连接点,创建复制点
{
m_lstPoints.append(p2);
m_lstPoints.append(p2);
m_lstPoints[i+1] = p2;
if(m_lstPoints.size() < 6) //补齐前端,移动后至少6个点
{
m_lstPoints.prepend(m_lstPoints.first());
i+=1;
}
}
//qDebug() << 1 <<" "<<i;
_curLine = QPoint(i,1);
break;
}
}
else if(p1.y() < p2.y())
{
if(pos.y() < p2.y() && pos.y() > p1.y()) //在竖线上
{
if(i == 0) //起点是连接点,创建复制点
{
m_lstPoints.prepend(p1);
m_lstPoints.prepend(p1);
i+=2;
if(m_lstPoints.size() < 6) //补齐后端
{
m_lstPoints.append(m_lstPoints.last());
}
}
if(i+1 == n-1) //终点是连接点,创建复制点
{
m_lstPoints.append(p2);
m_lstPoints.append(p2);
m_lstPoints[i+1] = p2;
if(m_lstPoints.size() < 6) //补齐前端
{
m_lstPoints.prepend(m_lstPoints.first());
i+=1;
}
}
//qDebug() << 2 <<" "<<i;
_curLine = QPoint(i,1);
break;
}
}
}
else if(p1.y() == p2.y() && abs(p1.y() - pos.y()) < 2) //在相同横线
{
if(p1.x() > p2.x())
{
if(pos.x() > p2.x() && pos.x() < p1.x())
{
if(i == 0) //起点是连接点,创建复制点
{
m_lstPoints.prepend(p1);
m_lstPoints.prepend(p1);
i+=2;
if(m_lstPoints.size() < 6) //补齐后端
{
m_lstPoints.append(m_lstPoints.last());
}
}
if(i+1 == n-1) //终点是连接点,创建复制点
{
m_lstPoints.append(p2);
m_lstPoints.append(p2);
if(m_lstPoints.size() < 6) //补齐前端,移动后至少6个点
{
m_lstPoints.prepend(m_lstPoints.first());
i+=1;
}
}
//qDebug() << 3 <<" "<<i;
_curLine = QPoint(i,-1);
break;
}
}
else if(p1.x() < p2.x())
{
if(pos.x() < p2.x() && pos.x() > p1.x())
{
if(i == 0) //起点是连接点,创建复制点
{
m_lstPoints.prepend(p1);
m_lstPoints.prepend(p1);
i+=2;
m_lstPoints[i] = p1;
if(m_lstPoints.size() < 6) //补齐后端
{
m_lstPoints.append(m_lstPoints.last());
}
}
if(i+1 == n-1) //终点是连接点,创建复制点
{
m_lstPoints.append(p2);
m_lstPoints.append(p2);
if(m_lstPoints.size() < 6) //补齐前端
{
m_lstPoints.prepend(m_lstPoints.first());
i+=1;
}
}
//qDebug() << 4 <<" "<<i;
_curLine = QPoint(i,-1);
break;
}
}
}
}
}
}
else
{
int n = _curLine.x();
//qDebug() << n <<" "<<_curLine.y();
//if(m_lstPoints.size() > 3)
{
if(_curLine.y() == 1) //竖线
{
if(n == 0) //起点是原点
{
QPointF p(0,delta.y()); //原点不动
m_lstPoints[n +1] = m_lstPoints[n +1] + p; //第二个点只竖直移动
m_lstPoints[n +2] = m_lstPoints[n +2] + p; //第三个点只竖直移动
}
else if(n == 1)
{
QPointF p(delta.x(),0);
m_lstPoints[n] += p; //第一个点只水平移动
m_lstPoints[n +1] += p; //第二个点只水平移动
}
else if(n == m_lstPoints.size()-2) //起点是倒数第二个点
{
QPointF p(0,delta.y());
m_lstPoints[n] += p; //起点只上下移动
m_lstPoints[n-1] += p; //上个点只竖直移动
}
else if(n == m_lstPoints.size()-3) //起点是倒数第三个点
{
QPointF py(0,delta.y());
QPointF px(delta.x(),0);
m_lstPoints[n-1] += py; //上个点只垂直移动
m_lstPoints[n] += delta; //起点任意动
m_lstPoints[n+1] += px; //第二个点只水平移动
}
else
{
m_lstPoints[n -1].setY(m_lstPoints[n ].y());
m_lstPoints[n] += delta;
m_lstPoints[n +1] += delta;
m_lstPoints[n +2].setY(m_lstPoints[n +1].y());
}
}
else //横线
{
if(n == 0) //起点是原点
{
QPointF p(delta.x(),0); //原点不动
m_lstPoints[n +1] = m_lstPoints[n +1] + p; //第二个点只水平移动
m_lstPoints[n +2] = m_lstPoints[n +2] + p; //第三个点只水平移动
}
else if(n == 1)
{
QPointF p(0,delta.y());
m_lstPoints[n] = m_lstPoints[n] + p; //第一个点只竖直移动
m_lstPoints[n +1] = m_lstPoints[n +1] + p; //第二个点只竖直移动
}
else if(n == m_lstPoints.size()-2) //起点是倒数第二个点
{
QPointF p(delta.x(),0);
m_lstPoints[n] += p; //起点水平移动
m_lstPoints[n-1] += p; //上个点只水平移动
}
else if(n == m_lstPoints.size()-3) //起点是倒数第三个点
{
QPointF py(0,delta.y());
QPointF px(delta.x(),0);
m_lstPoints[n-1] += px; //上个点只水平移动
m_lstPoints[n] += delta; //起点任意动
m_lstPoints[n+1] += py; //第二个点只上下移动
}
else
{
m_lstPoints[n -1].setX(m_lstPoints[n].x());
m_lstPoints[n] += delta;
m_lstPoints[n +1] += delta;
m_lstPoints[n +2].setX(m_lstPoints[n +1].x());
}
}
}
calculatePath();
}
m_lastPoint = pos;
}
void ElectricConnectLineItem::calculatePath()
{
int n = m_lstPoints.size();
/*for(int i = 0;i < n-1;++i)
{
if(m_lstPoints[i] == m_lstPoints[i+1])
{
if(i == 0) //头重复去除一个
{
m_lstPoints.removeAt(i+1);
}
else if((i+1 == n-1)) //尾重复去除一个
{
m_lstPoints.removeAt(i+1);
}
else
{
m_lstPoints.removeAt(i+1);
m_lstPoints.removeAt(i);
}
qDebug()<<"reset";
resetCurLine();
break;
}
}*/
prepareGeometryChange();
m_points.clear();
m_pointsBoundingRect.clear();
m_points.moveTo(m_pStart);
m_points.lineTo(m_pEnd.x(),m_pStart.y());
m_points.lineTo(m_pEnd);
if(m_lstPoints.size() == 2 && (m_lstPoints.first().x() != m_lstPoints.last().x()) && (m_lstPoints.first().y() != m_lstPoints.last().y()))
{
if(m_lstPoints.first().y() < m_lstPoints.last().y())
m_lstPoints.insert(1,QPointF(m_lstPoints.first().x(),m_lstPoints.last().y()));
else
m_lstPoints.insert(1,QPointF(m_lstPoints.last().x(),m_lstPoints.first().y()));
}
m_points.moveTo(m_lstPoints.first());
QPointF pLast = m_lstPoints.first();
for(int i = 1;i <m_lstPoints.size();++i)
{
m_points.lineTo(m_lstPoints[i]);
m_pointsBoundingRect.addRect(QRectF(QPointF(pLast.x()-1,pLast.y()-1),QPointF(m_lstPoints[i].x()+1,m_lstPoints[i].y()+1)));
pLast = m_lstPoints[i];
}
m_boundingRect = m_points.boundingRect();
}
void ElectricConnectLineItem::updateConnection(int callerId,QPointF pos)
{
qDebug()<<pos;
//qDebug()<<pos;
if(callerId == m_connectState.nSrcNodeId)
setStartPoint(pos);
else if(callerId == m_connectState.nDestNodeId)

View File

@ -8,6 +8,7 @@ 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);

View File

@ -8,6 +8,7 @@ ElectricSvgItemRect::ElectricSvgItemRect(const QRect &rect, QGraphicsItem *paren
: ElectricSvgItem(rect,parent)
{
loadSvg(":/images/element/svg_rect.svg");
setHandleIfShow(H_textCaption,false);
setHandleVisible(false);
setFunctionHandleIfShow(false);
setFunctionHandleEnaable(false);

View File

@ -8,6 +8,7 @@ ElectricSvgItemTriangle::ElectricSvgItemTriangle(const QRect &rect, QGraphicsIte
: ElectricSvgItem(rect,parent)
{
loadSvg(":/images/element/svg_triangle.svg");
setHandleIfShow(H_textCaption,false);
setHandleVisible(false);
setFunctionHandleIfShow(false);
setFunctionHandleEnaable(false);

View File

@ -1,4 +1,6 @@
#include "graphicsItem/graphicsBaseItem.h"
#include "graphicsItem/handleRect.h"
#include "graphicsItem/handleText.h"
#include "graphicsItem/itemPort.h"
#include <QGraphicsScene>
@ -13,19 +15,27 @@ GraphicsBaseItem::GraphicsBaseItem(QGraphicsItem *parent)
//m_vecHanle.reserve(H_left);
for(int i = H_leftTop; i <= H_left; i++)
{
ItemControlHandle* pHandle = new ItemControlHandle(this);
ItemControlHandle* pHandle = new HandleRect(this);
pHandle->setType(T_resize);
pHandle->setTag(i);
m_vecHanle.insert(i-1,pHandle);
}
for(int i = H_rotate_leftTop; i <= H_rotate_leftBottom; i++)
{
ItemControlHandle* pHandle = new ItemControlHandle(this);
ItemControlHandle* pHandle = new HandleRect(this);
pHandle->setType(T_rotate);
pHandle->setTag(i);
m_vecHanle.insert(i-1,pHandle);
}
HandleText* pHandle = new HandleText(this);
pHandle->setType(T_text);
pHandle->setTag(H_textCaption);
pHandle->setText(QString::number(123456));
pHandle->setPos(30,-20);
pHandle->setParent(this);
m_vecHanle.insert(H_textCaption,pHandle);
setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
@ -163,3 +173,14 @@ ItemPort* GraphicsBaseItem::getPortPtr(int n) const
}
return nullptr;
}
ItemControlHandle* GraphicsBaseItem::getHandlePtr(int n) const
{
for(auto iter:m_vecHanle)
{
int tag = iter->getTag();
if(tag == n)
return iter;
}
return nullptr;
}

View File

@ -1,4 +1,5 @@
#include "graphicsItem/graphicsItemGroup.h"
#include "graphicsItem/handleRect.h"
#include <QGraphicsScene>
#include <QPainter>
#include <QStyleOption>
@ -17,14 +18,14 @@ GraphicsItemGroup::GraphicsItemGroup(QGraphicsItem *parent)
//m_vecHanle.reserve(H_left);
for(int i = H_leftTop; i <= H_left; i++)
{
ItemControlHandle* pHandle = new ItemControlHandle(this);
ItemControlHandle* pHandle = new HandleRect(this);
pHandle->setType(T_resize);
pHandle->setTag(i);
m_vecHanle.insert(i-1,pHandle);
}
for(int i = H_rotate_leftTop; i <= H_rotate_leftBottom; i++)
{
ItemControlHandle* pHandle = new ItemControlHandle(this);
ItemControlHandle* pHandle = new HandleRect(this);
pHandle->setType(T_rotate);
pHandle->setTag(i);
m_vecHanle.insert(i-1,pHandle);

View File

@ -1,6 +1,6 @@
#include "graphicsItem/graphicsPolygonItem.h"
#include "graphicsItem/itemControlHandle.h"
//#include "graphicsItem/itemControlHandle.h"
#include "graphicsItem/handleRect.h"
#include <QPainter>
#include <QStyleOption>
@ -138,7 +138,7 @@ void GraphicPolygonItem::addPoint(const QPointF& point)
m_points.append(mapFromScene(point));
int nCount = m_points.count();
//每个顶点都可以编辑所以一个顶点需要编辑handle
ItemControlHandle* pHandle = new ItemControlHandle(this);
ItemControlHandle* pHandle = new HandleRect(this);
pHandle->setType(T_editShape);
pHandle->setTag(H_edit + nCount - 1);
m_vecHanle.insert(H_edit + nCount - 1,pHandle);

View File

@ -1,6 +1,6 @@
#include "graphicsItem/graphicsRectItem.h"
#include "graphicsItem/itemControlHandle.h"
//#include "graphicsItem/itemControlHandle.h"
#include "graphicsItem/handleRect.h"
#include <QPainter>
#include <QStyleOption>
@ -17,12 +17,12 @@ GraphicsRectItem::GraphicsRectItem(const QRect &rect, bool isRound, QGraphicsIte
if (m_bIsRound) //圆角矩形添加两个圆角大小控制点
{
//横轴X控制点
ItemControlHandle* pHandle1 = new ItemControlHandle(this);
ItemControlHandle* pHandle1 = new HandleRect(this);
pHandle1->setType(T_editShape);
pHandle1->setTag(H_edit);
m_vecHanle.insert(H_edit,pHandle1);
//纵轴Y控制点
ItemControlHandle* pHandle2 = new ItemControlHandle(this);
ItemControlHandle* pHandle2 = new HandleRect(this);
pHandle2->setType(T_editShape);
pHandle2->setTag(H_edit+1);
m_vecHanle.insert(H_edit+1,pHandle2);

View File

@ -0,0 +1,69 @@
#include "graphicsItem/handleRect.h"
#include <QPainter>
HandleRect::HandleRect(QGraphicsItem *parent)
:ItemControlHandle(parent)
{
}
HandleRect::~HandleRect()
{
}
QRectF HandleRect::boundingRect() const
{
// 设置边界矩形,这里我们返回一个从(10,10)开始宽度为100高度为50的矩形
return QRectF(-HNDLE_SIZE / 2,
-HNDLE_SIZE / 2,
HNDLE_SIZE,
HNDLE_SIZE);
}
void HandleRect::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
Q_UNUSED(option)
Q_UNUSED(widget)
painter->setPen(Qt::SolidLine);
painter->setRenderHint(QPainter::Antialiasing, true);
if(m_type==T_resize)
{
painter->setBrush(Qt::white);
painter->drawRect(boundingRect());
}
else if(m_type==T_rotate)
{
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::NoBrush);
painter->drawRect(boundingRect());
}
else if(m_type==T_editShape)
{
painter->setBrush(Qt::green);
painter->drawEllipse(boundingRect().center(), HNDLE_SIZE / 2, HNDLE_SIZE / 2);
}
else if(m_type==T_lineIn)
{
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::green);
painter->drawEllipse(boundingRect().center(), HNDLE_SIZE / 2, HNDLE_SIZE / 2);
}
else if(m_type==T_lineOut)
{
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::red);
painter->drawEllipse(boundingRect().center(), HNDLE_SIZE / 2, HNDLE_SIZE / 2);
}
}
void HandleRect::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
{
ItemControlHandle::hoverEnterEvent(event);
}
void HandleRect::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
{
ItemControlHandle::hoverLeaveEvent(event);
}

View File

@ -0,0 +1,68 @@
#include "graphicsItem/handleText.h"
#include <QPainter>
#include <QLineEdit>
#include <QGraphicsProxyWidget>
HandleText::HandleText(QGraphicsItem *parent)
: ItemControlHandle(parent)
,_font(QFont())
,_proxy(nullptr)
{
_editable = true;
_boundingRect = QRectF(-TEXT_WIDTH*0.5,-TEXT_WIDTH*0.5,TEXT_WIDTH,TEXT_HEIGHT);
}
HandleText::~HandleText()
{
}
void HandleText::setText(QString str)
{
_text = str;
QFontMetrics fontMetrics(_font);
_boundingRect = fontMetrics.boundingRect(_text);
int w = _boundingRect.width();
int h = _boundingRect.height();
_boundingRect.moveTo(QPointF(-w*0.5,-h*0.5));
}
void HandleText::creatEditor()
{
if(!_editable)
return;
if(!_proxy)
_proxy = new QGraphicsProxyWidget(this);
_proxy->setVisible(true);
QLineEdit *editor = new QLineEdit();
editor->setText(_text);
editor->resize(boundingRect().size().toSize()*1.5);
_proxy->setWidget(editor);
// 将文本编辑的更改连接到文本项
connect(editor, &QLineEdit::textChanged, this, [this, editor]() {
//_text = editor->text();
setText(editor->text());
});
// 完成编辑后删除QTextEdit
connect(editor, &QLineEdit::editingFinished, this, [this, editor]() {
//_text = editor->text();
setText(editor->text());
_proxy->setVisible(false);
});
}
void HandleText::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
painter->setPen(Qt::blue);
painter->setBrush(Qt::blue);
painter->setRenderHint(QPainter::TextAntialiasing, true);
int w = _boundingRect.width();
int h = _boundingRect.height();
painter->drawText(QPointF(-w*0.5,h*0.5),_text);
}
QRectF HandleText::boundingRect() const
{
return _boundingRect;
}

View File

@ -1,11 +1,10 @@
#include "graphicsItem/itemControlHandle.h"
#include "graphicsItem/graphicsBaseItem.h"
#include <QPainter>
ItemControlHandle::ItemControlHandle(QGraphicsItem *parent)
: QGraphicsRectItem(-HNDLE_SIZE / 2,
-HNDLE_SIZE / 2,
HNDLE_SIZE,
HNDLE_SIZE, parent)
: QGraphicsItem(parent)
,_parent(nullptr)
{
m_type = T_resize;
m_tag = H_none;
@ -21,48 +20,16 @@ void ItemControlHandle::paint(QPainter* painter, const QStyleOptionGraphicsItem*
{
Q_UNUSED(option)
Q_UNUSED(widget)
painter->setPen(Qt::SolidLine);
painter->setRenderHint(QPainter::Antialiasing, true);
if(m_type==T_resize)
{
painter->setBrush(Qt::white);
painter->drawRect(rect());
}
else if(m_type==T_rotate)
{
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::NoBrush);
painter->drawRect(rect());
}
else if(m_type==T_editShape)
{
painter->setBrush(Qt::green);
painter->drawEllipse(rect().center(), HNDLE_SIZE / 2, HNDLE_SIZE / 2);
}
else if(m_type==T_lineIn)
{
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::green);
painter->drawEllipse(rect().center(), HNDLE_SIZE / 2, HNDLE_SIZE / 2);
}
else if(m_type==T_lineOut)
{
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::red);
painter->drawEllipse(rect().center(), HNDLE_SIZE / 2, HNDLE_SIZE / 2);
}
}
void ItemControlHandle::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
{
QGraphicsRectItem::hoverEnterEvent(event);
QGraphicsItem::hoverEnterEvent(event);
}
void ItemControlHandle::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
{
QGraphicsRectItem::hoverLeaveEvent(event);
QGraphicsItem::hoverLeaveEvent(event);
}
int ItemControlHandle::getSize()

View File

@ -1,8 +1,9 @@
#include <QPainter>
#include "graphicsItem/itemPort.h"
#include "graphicsItem/handleRect.h"
ItemPort::ItemPort(QGraphicsItem *parent)
: ItemControlHandle(parent)
: HandleRect(parent)
{
_pos = P_top;
_ptr = nullptr;
@ -21,7 +22,7 @@ void ItemPort::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
painter->setRenderHint(QPainter::Antialiasing, true);
QPolygonF Triangle;
QRectF rec = rect();
QRectF rec = boundingRect();
qreal left = rec.left();
qreal right = rec.right();
qreal width = rec.width();
@ -58,20 +59,6 @@ void ItemPort::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
}
else if(m_type == T_lineInOut)
{
painter->drawEllipse(rect().center(), HNDLE_SIZE / 4, HNDLE_SIZE / 4);
painter->drawEllipse(boundingRect().center(), HNDLE_SIZE / 4, HNDLE_SIZE / 4);
}
/*if(m_type==T_lineIn)
{
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::green);
painter->drawEllipse(rect().center(), HNDLE_SIZE / 2, HNDLE_SIZE / 2);
}
else if(m_type==T_lineOut)
{
painter->setPen(Qt::NoPen);
painter->setBrush(Qt::red);
painter->drawEllipse(rect().center(), HNDLE_SIZE / 2, HNDLE_SIZE / 2);
}*/
//ItemControlHandle::paint(painter,option,widget);
}

View File

@ -1,8 +1,11 @@
#include "util/baseSelector.h"
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsView>
#include <graphicsItem/graphicsBaseItem.h>
#include <QDebug>
#include "graphicsItem/graphicsBaseItem.h"
#include "graphicsItem/handleText.h"
QPointF BaseSelector::ms_ptMouseDown(0.0,0.0);
QPointF BaseSelector::ms_ptMouseLast(0.0,0.0);
@ -39,48 +42,58 @@ void BaseSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, DesignerScen
QList<QGraphicsItem *> items = scene->selectedItems();
if (items.count() == 1) //只有一个选中
{
AbstractShape* item = qgraphicsitem_cast<AbstractShape*>(items.first());
GraphicsBaseItem* item = qgraphicsitem_cast<GraphicsBaseItem*>(items.first());
if(item)
{
//需要增加当前是否点击在控制点的判断函数
ms_nDragHandle = item->collidesWithHandle(event->scenePos());
if(ms_nDragHandle != H_none && ms_nDragHandle <= H_left) //在缩放控制点上
GraphicsItemType tpe = item->getItemType();
if(tpe == GIT_link) //对象是连接线
{
m_opMode = OM_scale;
emit setWorkingSelector(ST_scaling);
}
else if(ms_nDragHandle >= H_rotate_leftTop && ms_nDragHandle <= H_rotate_leftBottom) //在旋转控制点上
{
m_opMode = OM_rotate;
//计算夹角
QPointF originPoint = item->mapToScene(item->boundingRect().center());
double dLengthY = ms_ptMouseLast.y() - originPoint.y();
double dLengthX = ms_ptMouseLast.x() - originPoint.x();
ms_dAngleMouseDownToItem = atan2(dLengthY, dLengthX) * 180 / M_PI;
// if(atan2(dLengthY, dLengthX) < 0)
// ms_dAngleMouseDownToItem += 360.0;
//创建副本
item->createOperationCopy();
emit setWorkingSelector(ST_rotation);
}
else if(ms_nDragHandle > H_rotate_leftBottom && ms_nDragHandle < H_connect) //编辑控制点上
{
m_opMode = OM_edit;
setCursor(scene, Qt::ClosedHandCursor);
emit setWorkingSelector(ST_editing);
}
else if(ms_nDragHandle >= H_connect ) //连接控制点
{
m_opMode = OM_connect;
//setCursor(scene, Qt::ClosedHandCursor);
m_opMode = OM_linkMove;
setCursor(scene, Qt::ArrowCursor);
emit setWorkingSelector(ST_connecting);
emit setWorkingSelector(ST_linkMoving);
}
else
{
m_opMode = OM_move;
setCursor(scene, Qt::ClosedHandCursor);
emit setWorkingSelector(ST_moving);
//需要增加当前是否点击在控制点的判断函数
ms_nDragHandle = item->collidesWithHandle(event->scenePos());
if(ms_nDragHandle != H_none && ms_nDragHandle <= H_left) //在缩放控制点上
{
m_opMode = OM_scale;
emit setWorkingSelector(ST_scaling);
}
else if(ms_nDragHandle >= H_rotate_leftTop && ms_nDragHandle <= H_rotate_leftBottom) //在旋转控制点上
{
m_opMode = OM_rotate;
//计算夹角
QPointF originPoint = item->mapToScene(item->boundingRect().center());
double dLengthY = ms_ptMouseLast.y() - originPoint.y();
double dLengthX = ms_ptMouseLast.x() - originPoint.x();
ms_dAngleMouseDownToItem = atan2(dLengthY, dLengthX) * 180 / M_PI;
// if(atan2(dLengthY, dLengthX) < 0)
// ms_dAngleMouseDownToItem += 360.0;
//创建副本
item->createOperationCopy();
emit setWorkingSelector(ST_rotation);
}
else if(ms_nDragHandle > H_rotate_leftBottom && ms_nDragHandle < H_textCaption) //编辑控制点上
{
m_opMode = OM_edit;
setCursor(scene, Qt::ClosedHandCursor);
emit setWorkingSelector(ST_editing);
}
else if(ms_nDragHandle >= H_connect ) //连接控制点
{
m_opMode = OM_connect;
//setCursor(scene, Qt::ClosedHandCursor);
setCursor(scene, Qt::ArrowCursor);
emit setWorkingSelector(ST_connecting);
}
else
{
m_opMode = OM_move;
setCursor(scene, Qt::ClosedHandCursor);
emit setWorkingSelector(ST_moving);
}
}
}
}
@ -90,13 +103,36 @@ void BaseSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, DesignerScen
emit setWorkingSelector(ST_moving);
setCursor(scene, Qt::ClosedHandCursor);
}
else if(items.count() == 0) //单独移动子类
{
QList<QGraphicsItem *> items = scene->items(ms_ptMouseLast);
if (items.count() == 1)
{
ItemControlHandle* pHandle = qgraphicsitem_cast<ItemControlHandle*>(items.first());
if(pHandle)
{
//GraphicsBaseItem* item = pHandle->getParentPtr();
ms_nDragHandle = pHandle->getTag();
//ms_nDragHandle = item->collidesWithHandle(event->scenePos());
if(ms_nDragHandle >= H_textCaption && ms_nDragHandle < H_connect) //移动文本
{
m_opMode = OM_subMove;
setCursor(scene, Qt::ClosedHandCursor);
emit setWorkingSelector(ST_subMoving);
}
}
}
}
if(m_opMode == OM_move) //可以多个选中同时移动
{
for(int n = 0; n < items.size(); n++)
{
//创建副本
AbstractShape* item = qgraphicsitem_cast<AbstractShape*>(items.at(n));
GraphicsBaseItem* item = qgraphicsitem_cast<GraphicsBaseItem*>(items.at(n));
GraphicsItemType tpe = item->getItemType();
if(tpe == GIT_link)
continue;
item->createOperationCopy();
}
}
@ -303,8 +339,30 @@ void BaseSelector::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, DesignerSc
void BaseSelector::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, DesignerScene* scene)
{
Q_UNUSED(event)
Q_UNUSED(scene)
QList<QGraphicsItem *> items = scene->selectedItems();
if(items.count() == 0)
{
QList<QGraphicsItem *> items = scene->items(ms_ptMouseLast);
if (items.count() == 1)
{
ItemControlHandle* pHandle = qgraphicsitem_cast<ItemControlHandle*>(items.first());
if(pHandle)
{
ms_nDragHandle = pHandle->getTag();
//ms_nDragHandle = item->collidesWithHandle(event->scenePos());
if(ms_nDragHandle >= H_textCaption && ms_nDragHandle < H_connect) //移动文本
{
HandleText* pText = qgraphicsitem_cast<HandleText*>(pHandle);
if(pText)
{
//m_opMode = OM_subMove;
//emit setWorkingSelector(ST_subMoving);
pText->creatEditor();
}
}
}
}
}
}
void BaseSelector::setCursor(DesignerScene *scene, const QCursor &cursor)

View File

@ -90,13 +90,14 @@ void ConnectingSelector::createConnectLline(GraphicsBaseItem* connectingItem,Gra
{
ElectricConnectLineItem* pItem = new ElectricConnectLineItem();
pItem->setItemId(++_Id);
pItem->setItemType(GIT_connectLine);
pItem->setItemType(GIT_link);
scene->addItem(pItem);
ItemPort* ptSrc = connectingItem->getPortPtr(ms_nDragHandle);
int srcId = connectingItem->itemId();
int srcPort = ptSrc->getTag();
HandleType srcType = ptSrc->getType();
PortPos srcPos = ptSrc->portPos();
pItem->setStartPoint(ptSrc->scenePos());
ptSrc->setConnect(pItem);
@ -122,9 +123,10 @@ void ConnectingSelector::createConnectLline(GraphicsBaseItem* connectingItem,Gra
int destId = touchedItem->itemId();
int destPort = ptDest->getTag();
HandleType destType = ptDest->getType();
PortPos destPos = ptDest->portPos();
pItem->calculatePath();
pItem->setConnection(Connection(srcId,srcPort,srcType,destId,destPort,destType));
pItem->setConnection(Connection(srcId,srcPort,srcType,srcPos,destId,destPort,destType,destPos));
ptDest->setConnect(pItem);
m_graphicsItem[sceneName()].insert(QString::number(pItem->itemId()),pItem); //插入连接线到总表
@ -142,14 +144,20 @@ void ConnectingSelector::mouseMoveEvent(QGraphicsSceneMouseEvent* event, Designe
GraphicsBaseItem* item = qgraphicsitem_cast<GraphicsBaseItem*>(items.first());
if(item)
{
if(ms_nDragHandle != H_none)
if(ms_nDragHandle >= H_connect)
{
item->setState(S_prepareConnect);
QPointF start = item->mapFromScene(ms_ptMouseDown);
QPointF end = item->mapFromScene(ms_ptMouseLast);
item->setBeginConnectPos(start);
item->setEndConnectPos(end);
m_pConnectingItem = item;
ItemPort* pt = item->getPortPtr(ms_nDragHandle);
if(pt)
{
if(pt->connected()) //只判断未连接的port
return;
item->setState(S_prepareConnect);
QPointF start = item->mapFromScene(ms_ptMouseDown);
QPointF end = item->mapFromScene(ms_ptMouseLast);
item->setBeginConnectPos(start);
item->setEndConnectPos(end);
m_pConnectingItem = item;
}
}
}
}

View File

@ -68,7 +68,7 @@ void CreatingSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, Designer
case GIT_itemRect:
{
m_creatingMethod = CM_click;
m_pCreatingItem = new ElectricSvgItemRect(QRect(-20, -20, 40, 40));
m_pCreatingItem = new ElectricSvgItemRect(QRect(-15, -15, 30, 30));
m_pCreatingItem->setItemId(++_Id);
m_pCreatingItem->setItemType(GIT_itemRect);
m_pCreatingItem->editShape(ms_nDragHandle, ms_ptMouseLast);
@ -78,7 +78,7 @@ void CreatingSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, Designer
case GIT_itemTri:
{
m_creatingMethod = CM_click;
m_pCreatingItem = new ElectricSvgItemTriangle(QRect(-20, -20, 40, 40));
m_pCreatingItem = new ElectricSvgItemTriangle(QRect(-15, -15, 30, 30));
m_pCreatingItem->setItemId(++_Id);
m_pCreatingItem->setItemType(GIT_itemTri);
m_pCreatingItem->editShape(ms_nDragHandle, ms_ptMouseLast);

View File

@ -0,0 +1,62 @@
#include "util/linkMovingSelector.h"
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsView>
#include "graphicsItem/electricConnectLineItem.h"
LinkMovingSelector::LinkMovingSelector(QObject *parent)
: BaseSelector(parent)
,m_pMovingLine(nullptr)
{
m_type = ST_linkMoving;
}
LinkMovingSelector::~LinkMovingSelector()
{
}
void LinkMovingSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, DesignerScene* scene)
{
ms_ptMouseLast = event->scenePos();
//QList<QGraphicsItem *> items = scene->selectedItems();
}
void LinkMovingSelector::mouseMoveEvent(QGraphicsSceneMouseEvent* event, DesignerScene* scene)
{
ms_ptMouseLast = event->scenePos();
if(m_pMovingLine == nullptr)
{
QList<QGraphicsItem *> items = scene->selectedItems();
if (items.count() == 1) //只有一个选中
{
ElectricConnectLineItem* item = qgraphicsitem_cast<ElectricConnectLineItem*>(items.first());
if(item)
{
m_pMovingLine = item;
item->setLastPoint(ms_ptMouseLast);
}
}
}
else
{
if(m_pMovingLine)
m_pMovingLine->moveLine(ms_ptMouseLast);
}
}
void LinkMovingSelector::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, DesignerScene* scene)
{
if(m_pMovingLine)
{
m_pMovingLine->resetCurLine();
qDebug()<<"reset";
}
m_pMovingLine = nullptr;
ms_nDragHandle = H_none;
setCursor(scene, Qt::ArrowCursor);
scene->callParentEvent(event);
emit setWorkingSelector(ST_base);
}

View File

@ -59,7 +59,7 @@ void MovingSelector::updateConnectLine(QList<QGraphicsItem *> lst)
auto item = dynamic_cast<GraphicsBaseItem*>(iter);
if(item)
{
if(item->getItemType() != GIT_connectLine)
if(item->getItemType() != GIT_link)
{
int nId = item->itemId();
for(auto pPort:item->getPorts())

View File

@ -1,6 +1,8 @@
#include "util/selectorManager.h"
#include "util/creatingSelector.h"
#include "util/movingSelector.h"
#include "util/subMovingSelector.h"
#include "util/linkMovingSelector.h"
#include "util/rotationSelector.h"
#include "util/scalingSelector.h"
#include "util/editingSelector.h"
@ -21,6 +23,12 @@ SelectorManager::SelectorManager(QObject *parent)
MovingSelector* movingSelector = new MovingSelector(this);
connect(movingSelector, SIGNAL(setWorkingSelector(SelectorType)), this, SLOT(onSignal_setWorkingSelector(SelectorType)));
m_vecSelectors.push_back(movingSelector);
SubMovingSelector* subMovSelector = new SubMovingSelector(this);
connect(subMovSelector, SIGNAL(setWorkingSelector(SelectorType)), this, SLOT(onSignal_setWorkingSelector(SelectorType)));
m_vecSelectors.push_back(subMovSelector);
LinkMovingSelector* linkMovSelector = new LinkMovingSelector(this);
connect(linkMovSelector, SIGNAL(setWorkingSelector(SelectorType)), this, SLOT(onSignal_setWorkingSelector(SelectorType)));
m_vecSelectors.push_back(linkMovSelector);
RotationSelector* rotationSelector = new RotationSelector(this);
connect(rotationSelector, SIGNAL(setWorkingSelector(SelectorType)), this, SLOT(onSignal_setWorkingSelector(SelectorType)));
m_vecSelectors.push_back(rotationSelector);

View File

@ -0,0 +1,73 @@
#include "util/SubMovingSelector.h"
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsView>
#include "graphicsItem/graphicsBaseItem.h"
#include "graphicsItem/handleText.h"
SubMovingSelector::SubMovingSelector(QObject *parent)
: BaseSelector(parent)
,m_pParentItem(nullptr)
{
m_type = ST_subMoving;
}
SubMovingSelector::~SubMovingSelector()
{
}
void SubMovingSelector::mousePressEvent(QGraphicsSceneMouseEvent* event, DesignerScene* scene)
{
ms_ptMouseLast = event->scenePos();
QList<QGraphicsItem *> items = scene->selectedItems();
}
void SubMovingSelector::mouseMoveEvent(QGraphicsSceneMouseEvent* event, DesignerScene* scene)
{
ms_ptMouseLast = event->scenePos();
if(m_pParentItem == nullptr)
{
QList<QGraphicsItem *> items = scene->items(ms_ptMouseLast);
if (items.count() == 1)
{
ItemControlHandle* pHandle = qgraphicsitem_cast<ItemControlHandle*>(items.first());
if(pHandle)
{
GraphicsBaseItem* item = pHandle->getParentPtr();
if(item)
{
if(ms_nDragHandle >= H_textCaption && ms_nDragHandle < H_connect) //移动文本
{
pHandle->setPos(item->mapFromScene(ms_ptMouseLast));
m_pParentItem = item;
}
}
}
}
}
else
{
if(m_pParentItem)
{
if(ms_nDragHandle >= H_textCaption && ms_nDragHandle < H_connect) //文本
{
HandleText* pt = dynamic_cast<HandleText*>(m_pParentItem->getHandlePtr(ms_nDragHandle));
if(pt)
{
pt->setPos(m_pParentItem->mapFromScene(ms_ptMouseLast));
}
}
}
}
}
void SubMovingSelector::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, DesignerScene* scene)
{
m_pParentItem = nullptr;
ms_nDragHandle = H_none;
setCursor(scene, Qt::ArrowCursor);
scene->callParentEvent(event);
emit setWorkingSelector(ST_base);
}