master
lzhyasuo 2022-05-06 15:34:00 +08:00
commit 16e695954d
51 changed files with 8185 additions and 0 deletions

89
QT_IEK.pro Normal file
View File

@ -0,0 +1,89 @@
#-------------------------------------------------
#
# Project created by QtCreator 2022-03-09T10:00:00
#
#-------------------------------------------------
QT += core gui charts
INCLUDEPATH += F:/lib_opencv/include/opencv \
F:/lib_opencv/include/opencv2 \
F:/lib_opencv/include
LIBS += -L F:/lib_opencv/lib/libopencv_*.a
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = QT_IEK
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
SOURCES += \
main.cpp \
Src/Gui/MainWindow.cpp \
Src/Gui/DockWidget.cpp \
Src/Chart/ChartCurve.cpp \
Src/Chart/ChartLine.cpp \
Src/Chart/Chart.cpp \
Src/Chart/ChartBar.cpp \
Src/Chart/ChartPie.cpp \
Src/Control/ControlDashBoard.cpp \
Src/Control/ControlRoundProBar.cpp \
Src/Gui/SmallWindow.cpp \
Src/Gui/BaseWidget.cpp \
Src/Pub/PubCss.cpp \
Src/Model/MoldProModelDelegate.cpp \
Src/Model/MoldProTableView.cpp \
Src/Model/LoadDistributionModelDelegate.cpp \
Src/Model/LoadDistributionTableView.cpp \
Src/Chart/ChartBaseSeries.cpp \
Src/Model/PartsInventoryModelDelegate.cpp \
Src/Model/PartsInventoryTableView.cpp \
Src/Gui/OpenCVGLWidget.cpp \
Src/Task/OpenCVVideo.cpp \
Src/Gui/TypeWindow.cpp \
Src/Gui/ModuleWidget.cpp \
Src/Pub/PubFunction.cpp
HEADERS += \
Src/Gui/MainWindow.h \
Src/Gui/DockWidget.h \
Src/Chart/ChartCurve.h \
Src/Chart/ChartLine.h \
Src/Chart/Chart.h \
Src/Chart/ChartBar.h \
Src/Chart/ChartPie.h \
Src/Control/ControlDashBoard.h \
Src/Control/ControlRoundProBar.h \
Src/Gui/SmallWindow.h \
Src/Gui/BaseWidget.h \
Src/Pub/PubCss.h \
Src/Model/MoldProModelDelegate.h \
Src/Model/MoldProTableView.h \
Src/Model/LoadDistributionModelDelegate.h \
Src/Model/LoadDistributionTableView.h \
Src/Chart/ChartBaseSeries.h \
Src/Model/PartsInventoryModelDelegate.h \
Src/Model/PartsInventoryTableView.h \
Src/Gui/OpenCVGLWidget.h \
Src/Task/OpenCVVideo.h \
Src/Gui/TypeWindow.h \
Src/Gui/ModuleWidget.h \
Src/Pub/PubFunction.h
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

328
QT_IEK.pro.user Normal file
View File

@ -0,0 +1,328 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.8.2, 2022-04-23T15:27:13. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{ae4a1ab9-8f5c-48c1-9d0f-3c0d553fd55e}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">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="int" 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="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</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="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="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey">
<value type="QString">-fno-delayed-template-parsing</value>
</valuelist>
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.9.8 MinGW 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.9.8 MinGW 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.598.win32_mingw53_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">F:/QTpro/Work/build-QT_IEK-Desktop_Qt_5_9_8_MinGW_32bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</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="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</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.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">F:/QTpro/Work/build-QT_IEK-Desktop_Qt_5_9_8_MinGW_32bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</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="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</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.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">F:/QTpro/Work/build-QT_IEK-Desktop_Qt_5_9_8_MinGW_32bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</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="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</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.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" 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>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy Configuration</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">QT_IEK</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:F:/QTpro/Work/QT_IEK/QT_IEK.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">QT_IEK.pro</value>
<value type="QString" key="RunConfiguration.Arguments"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">F:/QTpro/Work/build-QT_IEK-Desktop_Qt_5_9_8_MinGW_32bit-Debug</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">20</value>
</data>
<data>
<variable>Version</variable>
<value type="int">20</value>
</data>
</qtcreator>

147
Src/Chart/Chart.cpp Normal file
View File

@ -0,0 +1,147 @@
#include "Chart.h"
#include <QValueAxis>
#include <QBarCategoryAxis>
#include <QGraphicsGridLayout>
Chart::Chart()
{
}
Chart::~Chart()
{
}
void Chart::InitChart()
{
//---------------------------------图表----------------------
//设置系统主题
// this->setTheme(QChart::ChartThemeBlueCerulean);
//是否启用动画
// this->setAnimationOptions(QChart::AllAnimations);
//背景色设置 背景色 笔
this->setBackgroundBrush(QBrush(_chartPar._backBrush));
// this->setBackgroundPen(QPen(_chartPar._pen));
this->setBackgroundVisible(true);
//设置数据是否本地化
this->setLocalizeNumbers(true);
//设置标题
this->setTitle("");
//标题字体
this->setTitleFont(QFont());
//标题刷
this->setTitleBrush(QBrush(QColor()));
//设置外边界全部为0
this->layout()->setContentsMargins(0, 0, 0, 0);
//设置内边界全部为0
this->setMargins(QMargins(0, 0, 0, 0));
//设置背景区域无圆角
this->setBackgroundRoundness(0);
}
void Chart::InitLegend()
{
//---------------------------------标签-----------------------
this->legend()->setVisible(true);
//对齐
this->legend()->setAlignment(Qt::AlignTop);
//图例图标分离
//this->legend()->detachFromChart();
//设置背景是否可视
//this->legend()->setBackgroundVisible(true);
//设置背景自动填充
//this->legend()->setAutoFillBackground(true);
//设置标签颜色
this->legend()->setColor(QColor(255,255,255));
//设置边距left,top,right,bottom
//this->legend()->setContentsMargins(10,10,10,10);
//设置标签颜色
// this->legend()->setLabelColor(QColor(255,128,255));
//设置是否可视
this->legend()->setVisible(true);
//设置背景色
//this->legend()->setBrush(QBrush(QColor(128,128,128,255)));
//设置画笔
//this->legend()->setPen(QPen(QColor(192,192, 192,192)));
//设置边框颜色
// this->legend()->setBorderColor(QColor(255,255,170,185));
// QFont font1;
// font1.setItalic(!font1.italic());
// font1.setPointSizeF(8);
// font.setFamily("微软雅黑");
// chart->legend()->setFont(font1);
}
void Chart::InitAxis()
{
if(_axisPar.xNameList.size() > 0)
{
QBarCategoryAxis* axis = new QBarCategoryAxis ();
axis->setLabelsBrush(QBrush(QColor(235,235,235)));
axis->append(_axisPar.xNameList);
this->setAxisX(axis);
}
else if(_axisPar.xCount > 0)
{
QValueAxis* xAxis = new QValueAxis();
xAxis->setLabelsBrush(QBrush(QColor(235,235,235)));
xAxis->setTitleText(_axisPar.xTitle);
xAxis->setTitleFont(QFont());
xAxis->setRange(_axisPar.xMin,_axisPar.xMax);
xAxis->setTickCount(_axisPar.xCount);
if(!_axisPar.xformat.isEmpty())
{
xAxis->setLabelFormat(_axisPar.xformat);
xAxis->setLabelsVisible(true);
}
this->setAxisX(xAxis);
}
if(_axisPar.yNameList.size() > 0)
{
QBarCategoryAxis* axis = new QBarCategoryAxis();
axis->setLabelsBrush(QBrush(QColor(235,235,235)));
axis->append(_axisPar.yNameList);
this->setAxisY(axis);
}
else if(_axisPar.yCount > 0)
{
QValueAxis* Axis = new QValueAxis();
Axis->setLabelsBrush(QBrush(QColor(235,235,235)));
Axis->setTitleText(_axisPar.yTitle);
Axis->setTitleFont(QFont());
Axis->setRange(_axisPar.yMin,_axisPar.yMax);
Axis->setTickCount(_axisPar.yCount);
if(!_axisPar.yformat.isEmpty())
{
Axis->setLabelFormat(_axisPar.yformat);
Axis->setLabelsVisible(true);
}
this->setAxisY(Axis);
}
// QValueAxis* yAxis = new QValueAxis();
// yAxis->setTitleText("");
// yAxis->setTitleFont(font);
// yAxis->setRange(0,120);
// yAxis->setTickCount(13);
// chart->addAxis(xAxis,Qt::AlignBottom);
// chart->addAxis(yAxis,Qt::AlignLeft);
// QBarCategoryAxis *pAxisX = new QBarCategoryAxis();
}
void Chart::Set(AxisPar par)
{
_axisPar = par;
}
void Chart::Set(ChartPar par)
{
_chartPar = par;
}

58
Src/Chart/Chart.h Normal file
View File

@ -0,0 +1,58 @@
#ifndef _CHART_H_
#define _CHART_H_
#include <QChart>
QT_CHARTS_USE_NAMESPACE
//图表参数
struct ChartPar
{
QBrush _backBrush;
QPen _pen;
};
//标签参数
struct LegendPar
{
//后续要什么加什么
};
//XY参数
struct AxisPar
{
QString xTitle = "";
QStringList xNameList = QStringList();
int xMin = 0;
int xMax = 0;
int xCount = 0;
bool xIsShow = false;
QString xformat = "";
QString yTitle = "";
QStringList yNameList = QStringList();
int yMin = 0;
int yMax = 0;
int yCount = 0;
QString yformat = "";
};
class Chart : public QChart
{
public:
Chart();
~Chart();
void InitChart();
void InitLegend();
void InitAxis();
void Set(AxisPar axisPar);
void Set(ChartPar);
private:
ChartPar _chartPar;
AxisPar _axisPar;
};
#endif //_CHART_H_

530
Src/Chart/ChartBar.cpp Normal file
View File

@ -0,0 +1,530 @@
#include "ChartBar.h"
#include <QHBoxLayout>
#include <QChartView>
#include <QDebug>
#include <QTime>
ChartBar::ChartBar(int index,QWidget *parent)
:ChartBaseSeries (parent)
{
_index = index;
}
ChartBar::~ChartBar()
{
}
void ChartBar::Init(QList<BarPer> bar)
{
QHBoxLayout* mLayout = new QHBoxLayout();
mLayout->setSpacing(0);
mLayout->setContentsMargins(0,0,0,0);
QBarSeries* barSeries = nullptr;
QStackedBarSeries* stackedBarSeries = nullptr;
QHorizontalBarSeries* hBarSeries = nullptr;
QHorizontalStackedBarSeries* hstackedBarSeries = nullptr;
if(_index == 1)
{
barSeries = InitBarSeries(bar);
}
else if(_index == 2)
{
stackedBarSeries = InitStackedBarSeries(bar);
}
else if(_index == 3)
{
barSeries = InitBarSeries(bar);
}
else if(_index == 4)
{
hBarSeries = InitHBarSeries(bar);
}
else if(_index == 5)
{
hstackedBarSeries = InithStackedBarSeries(bar);
}
else if(_index == 6)
{
hBarSeries = InitHBarSeries(bar);
}
Chart* chart = new Chart();
chart->Set(_cPar);
chart->Set(_aPar);
chart->InitChart();
chart->InitAxis();
if(_index == 1 || _index == 3)
{
chart->addSeries(barSeries);
if(chart->axisX() != nullptr)
chart->setAxisX(chart->axisX(),barSeries);
if(chart->axisY() != nullptr)
chart->setAxisY(chart->axisY(),barSeries);
}
else if(_index == 2)
{
chart->addSeries(stackedBarSeries);
if(chart->axisX() != nullptr)
chart->setAxisX(chart->axisX(),stackedBarSeries);
if(chart->axisY() != nullptr)
chart->setAxisY(chart->axisY(),stackedBarSeries);
}
else if(_index == 4 || _index == 6)
{
chart->addSeries(hBarSeries);
if(chart->axisX() != nullptr)
chart->setAxisX(chart->axisX(),hBarSeries);
if(chart->axisY() != nullptr)
chart->setAxisY(chart->axisY(),hBarSeries);
}
else if(_index == 5)
{
chart->addSeries(hstackedBarSeries);
if(chart->axisX() != nullptr)
chart->setAxisX(chart->axisX(),hstackedBarSeries);
if(chart->axisY() != nullptr)
chart->setAxisY(chart->axisY(),hstackedBarSeries);
}
chart->InitLegend();
if(_index == 1)
{
if(bar.size() == 1)
{
if(_max > 0)
{
SetMoreColor(barSeries,bar);
}
}
}
QChartView* view = new QChartView(chart);
mLayout->addWidget(view);
this->setLayout(mLayout);
}
QList<BarPer> ChartBar::GetBPar(BParListModel index)
{
QList<BarPer> _valueList;
switch (index)
{
case BPRODUCTIONSUMVALUE1:
{
QList<BarPer> valueList;
QList<qreal> List1;
List1 << 2 << 4 << 4;
QList<qreal> List2;
List2 << 2 << 2 << 3;
valueList.push_back(BarPer{"",List1,QColor(255,255,255),QColor(0,175,179)});
valueList.push_back(BarPer{"",List2,QColor(255,255,255),QColor(32,158,222)});
_valueList = valueList;
break;
}
case BPRODUCTIONSUMVALUE2:
{
QList<BarPer> valueList;
QList<qreal> List3;
List3 << 9814 << 9952 << 5000;
QList<qreal> List4;
List4 << 6867 << 5000 << 7927;
valueList.push_back(BarPer{"",List3,QColor(255,255,255),QColor(0,175,179),});
valueList.push_back(BarPer{"",List4,QColor(255,255,255),QColor(32,158,222)});
_valueList = valueList;
break;
}
case BPLANFORTHEMONTHVALUE1:
{
QList<BarPer> valueList;
QList<qreal> valueList1 = QList<qreal>() << 452 << 332 << 232 << 380;
QList<qreal> valueList2 = QList<qreal>() << 227 << 412 << 295 << 549;
valueList.push_back(BarPer{"",valueList1,QColor(255,255,255),QColor(0,176,180)});
valueList.push_back(BarPer{"",valueList2,QColor(255,255,255),QColor(32,158,222)});
_valueList = valueList;
break;
}
case BPLANFORTHEMONTHVALUE2:
{
QList<BarPer> valueList;
qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); //不能放在循环里,否则容易出现很多相同随机数
QList<qreal> valueList2 = QList<qreal>() << 0;
QList<qreal> valueList3 = QList<qreal>() << 0;
QList<qreal> valueList4 = QList<qreal>() << 0;
for(int var =0; var < 31;++var)
{
valueList2.append(qrand()%(20));
}
for(int var =0; var < 31;++var)
{
valueList3.append(qrand()%(20));
}
for(int var =0; var < 31;++var)
{
valueList4.append(qrand()%(20));
}
valueList.push_back(BarPer{"",valueList2,QColor(255,255,255),QColor(0,176,180)});
valueList.push_back(BarPer{"",valueList3,QColor(255,255,255),QColor(255,192,0)});
valueList.push_back(BarPer{"",valueList4,QColor(255,255,255),QColor(32,158,222)});
_valueList = valueList;
break;
}
case BLOADDISTRIBUTIONVALUE1:
{
QList<BarPer> valueList;
QList<qreal> valueList1 = QList<qreal>();
QList<qreal> valueList2 = QList<qreal>();
for(int var = 0; var < 6;++var)
{
valueList1.append(qrand()%(40));
}
for(int var =0; var < 6;++var)
{
valueList2.append(qrand()%(40));
}
valueList.push_back(BarPer{"",valueList1,QColor(255,255,255),QColor(0,176,180)});
valueList.push_back(BarPer{"",valueList2,QColor(255,255,255),QColor(255,42,45)});
_valueList = valueList;
break;
}
case BPASSEDTHEINSPECTIONVALUE1:
{
QList<BarPer> valueList;
QList<qreal> valueList1 = QList<qreal>() << 77 << 68 << 43 << 30 << 47 << 30;
valueList.push_back(BarPer{"",valueList1,QColor(255,255,255),QColor(255,42,45)});
_valueList = valueList;
break;
}
case BQUALITYMANAGEMENTVALUE1:
{
QList<BarPer> valueList;
QList<qreal> valueList1 = QList<qreal>() << 46 << 39 << 30 << 81 << 43 << 30;
valueList.push_back(BarPer{"",valueList1,QColor(255,255,255),QColor(255,42,45)});
_valueList = valueList;
break;
}
case BCHARTBAR1VALUE1:
{
QList<BarPer> valueList;
QList<qreal> valueList1 = QList<qreal>() << 57 << 72 << 88 << 41 << 88 << 55;
valueList.push_back(BarPer{"",valueList1,QColor(255,255,255),QColor(255,42,45)});
_valueList = valueList;
break;
}
case BCHARTBAR1VALUE2:
{
QList<BarPer> valueList;
QList<qreal> valueList1 = QList<qreal>() << 72 << 74 << 87 << 64 << 43 << 43;
valueList.push_back(BarPer{"",valueList1,QColor(255,255,255),QColor(255,42,45)});
_valueList = valueList;
break;
}
case BCHARTBAR2VALUE1:
{
QList<BarPer> valueList;
QList<qreal> valueList1;
QList<qreal> valueList2;
QList<qreal> valueList3;
valueList1.push_back(0);
valueList2.push_back(0);
valueList3.push_back(0);
qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); //不能放在循环里,否则容易出现很多相同随机数
for(int var =0; var < 31;++var)
{
valueList1.append(qrand()%(33));
}
for(int var =0; var < 31;++var)
{
valueList2.append(qrand()%(33));
}
for(int var =0; var < 31;++var)
{
valueList3.append(qrand()%(33));
}
valueList.push_back(BarPer{"",valueList1,QColor(255,255,255),QColor(1,178,179)});
valueList.push_back(BarPer{"",valueList2,QColor(255,255,255),QColor(1,133,189)});
valueList.push_back(BarPer{"",valueList3,QColor(255,255,255),QColor(253,191,1)});
_valueList = valueList;
break;
}
case BCHARTBAR2VALUE2:
{
QList<BarPer> valueList;
QList<qreal> valueList1;
QList<qreal> valueList2;
QList<qreal> valueList3;
valueList1.push_back(0);
valueList2.push_back(0);
valueList3.push_back(0);
qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); //不能放在循环里,否则容易出现很多相同随机数
for(int var =0; var < 31;++var)
{
valueList1.append(qrand()%(33));
}
for(int var =0; var < 31;++var)
{
valueList2.append(qrand()%(33));
}
for(int var =0; var < 31;++var)
{
valueList3.append(qrand()%(33));
}
valueList.push_back(BarPer{"",valueList1,QColor(255,255,255),QColor(52,182,214)});
valueList.push_back(BarPer{"",valueList2,QColor(255,255,255),QColor(254,183,41)});
valueList.push_back(BarPer{"",valueList3,QColor(255,255,255),QColor(234,81,45)});
_valueList = valueList;
break;
}
case BCHARTBAR3VALUE1:
{
QList<BarPer> valueList;
QList<qreal> valueList1 = QList<qreal>() << 281 << 461 << 299 << 131;
QList<qreal> valueList2 = QList<qreal>() << 453 << 336 << 428 << 398;
valueList.push_back(BarPer{"",valueList1,QColor(255,255,255),QColor(1,176,181)});
valueList.push_back(BarPer{"",valueList2,QColor(255,255,255),QColor(0,113,193)});
_valueList = valueList;
break;
}
case BCHARTBAR3VALUE2:
{
QList<BarPer> valueList;
QList<qreal> valueList1 = QList<qreal>() << 210 << 213 << 259 << 245;
QList<qreal> valueList2 = QList<qreal>() << 177 << 473 << 177 << 512;
valueList.push_back(BarPer{"",valueList1,QColor(255,255,255),QColor(253,139,40)});
valueList.push_back(BarPer{"",valueList2,QColor(255,255,255),QColor(117,55,118)});
_valueList = valueList;
break;
}
case BCAHRTBAR4VALUE1:
{
QList<BarPer> valueList;
QList<qreal> valueList1 = QList<qreal>() << 88 << 45 << 42 << 75 << 71 << 83;
valueList.push_back(BarPer{"",valueList1,QColor(255,255,255),QColor(253,139,40)});
_valueList = valueList;
break;
}
case BCAHRTBAR5VALUE1:
{
QList<BarPer> valueList;
QList<qreal> valueList1;
QList<qreal> valueList2;
QList<qreal> valueList3;
valueList1.push_back(0);
valueList2.push_back(0);
valueList3.push_back(0);
qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); //不能放在循环里,否则容易出现很多相同随机数
for(int var =0; var < 31;++var)
{
valueList1.append(qrand()%(33));
}
for(int var =0; var < 31;++var)
{
valueList2.append(qrand()%(33));
}
for(int var =0; var < 31;++var)
{
valueList3.append(qrand()%(33));
}
valueList.push_back(BarPer{"",valueList1,QColor(255,255,255),QColor(1,178,179)});
valueList.push_back(BarPer{"",valueList2,QColor(255,255,255),QColor(1,133,189)});
valueList.push_back(BarPer{"",valueList3,QColor(255,255,255),QColor(253,191,1)});
_valueList = valueList;
break;
}
case BCAHRTBAR5VALUE2:
{
QList<BarPer> valueList;
QList<qreal> valueList1;
QList<qreal> valueList2;
QList<qreal> valueList3;
valueList1.push_back(0);
valueList2.push_back(0);
valueList3.push_back(0);
qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); //不能放在循环里,否则容易出现很多相同随机数
for(int var =0; var < 31;++var)
{
valueList1.append(qrand()%(33));
}
for(int var =0; var < 31;++var)
{
valueList2.append(qrand()%(33));
}
for(int var =0; var < 31;++var)
{
valueList3.append(qrand()%(33));
}
valueList.push_back(BarPer{"",valueList1,QColor(255,255,255),QColor(52,182,214)});
valueList.push_back(BarPer{"",valueList2,QColor(255,255,255),QColor(254,183,41)});
valueList.push_back(BarPer{"",valueList3,QColor(255,255,255),QColor(234,81,45)});
_valueList = valueList;
break;
}
case BCAHRTBAR6VALUE1:
{
QList<BarPer> valueList;
QList<qreal> valueList1 = QList<qreal>() << 40 << 53 << 90;
QList<qreal> valueList2 = QList<qreal>() << 68 << 64 << 58;
valueList.push_back(BarPer{"",valueList1,QColor(255,255,255),QColor(0,113,194)});
valueList.push_back(BarPer{"",valueList2,QColor(255,255,255),QColor(1,176,181)});
_valueList = valueList;
break;
}
}
return _valueList;
}
void ChartBar::SetMax(int max)
{
_max = max;
}
void ChartBar::SetMaxColor(QColor color)
{
_maxColor = color;
}
void ChartBar::SetMoreColor(QBarSeries* barSeries, QList<BarPer> List)
{
QList<QBarSet*> barSetList = barSeries->barSets();
qDebug() << barSetList.at(0)->at(1);
if(barSetList.size() == List.size())
return;
for(int i = 0 ; i < barSetList.size(); i++)
{
if(List.at(0)._value.at(i) > _max)
{
barSetList.at(i)->setColor(_maxColor);
}
}
}
QBarSeries *ChartBar::InitBarSeries(QList<BarPer> list)
{
QFont fontText("SimHei");
fontText.setPixelSize(12);
QBarSeries* barSet = new QBarSeries();
//设置文字可视化
barSet->setLabelsVisible(true);
//设置文字格式 高
barSet->setLabelsFormat("@value");
//设置文字所处位置
barSet->setLabelsPosition(QAbstractBarSeries::LabelsOutsideEnd);
for(auto &i : list)
{
//创建柱
QBarSet* set = new QBarSet(i._name);
//设置字体
set->setLabelFont(fontText);
//设置背景色
set->setBrush(i._brushColor);
//设置边框色
set->setBorderColor(i._borderColor);
//设置值
set->append(i._value);
//添加
barSet->append(set);
}
return barSet;
}
QStackedBarSeries *ChartBar::InitStackedBarSeries(QList<BarPer> list)
{
QFont fontText("SimHei");
fontText.setPixelSize(12);
QStackedBarSeries* barSet = new QStackedBarSeries();
//设置文字可视化
barSet->setLabelsVisible(true);
//设置文字格式 高
barSet->setLabelsFormat("@value");
//设置文字所处位置
barSet->setLabelsPosition(QAbstractBarSeries::LabelsOutsideEnd);
for(auto &i : list)
{
//创建柱
QBarSet* set = new QBarSet(i._name);
//设置字体
set->setLabelFont(fontText);
//设置背景色
set->setBrush(i._brushColor);
//设置边框色
set->setBorderColor(i._borderColor);
//设置值
set->append(i._value);
//添加
barSet->append(set);
}
return barSet;
}
QHorizontalBarSeries *ChartBar::InitHBarSeries(QList<BarPer> list)
{
QFont fontText("SimHei");
fontText.setPixelSize(12);
QHorizontalBarSeries* barSet = new QHorizontalBarSeries();
//设置文字可视化
barSet->setLabelsVisible(true);
//设置文字格式 高
barSet->setLabelsFormat("@value");
//设置文字所处位置
barSet->setLabelsPosition(QAbstractBarSeries::LabelsOutsideEnd);
for(auto &i : list)
{
//创建柱
QBarSet* set = new QBarSet(i._name);
//设置字体
set->setLabelFont(fontText);
//设置背景色
set->setBrush(i._brushColor);
//设置边框色
set->setBorderColor(i._borderColor);
//设置值
set->append(i._value);
//添加
barSet->append(set);
}
return barSet;
}
QHorizontalStackedBarSeries* ChartBar::InithStackedBarSeries(QList<BarPer> list)
{
QFont fontText("SimHei");
fontText.setPixelSize(12);
QHorizontalStackedBarSeries* barSet = new QHorizontalStackedBarSeries();
//设置文字可视化
barSet->setLabelsVisible(true);
//设置文字格式 高
barSet->setLabelsFormat("@value");
//设置文字所处位置
barSet->setLabelsPosition(QAbstractBarSeries::LabelsOutsideEnd);
for(auto &i : list)
{
//创建柱
QBarSet* set = new QBarSet(i._name);
//设置字体
set->setLabelFont(fontText);
//设置背景色
set->setBrush(i._brushColor);
//设置边框色
set->setBorderColor(i._borderColor);
//设置值
set->append(i._value);
//添加
barSet->append(set);
}
return barSet;
}

68
Src/Chart/ChartBar.h Normal file
View File

@ -0,0 +1,68 @@
#ifndef _CHART_BARSET_H_
#define _CHART_BARSET_H_
#include "ChartBaseSeries.h"
#include <QBarSeries>
#include <QBarSet>
#include <QPercentBarSeries>
#include <QStackedBarSeries>
#include <QHorizontalBarSeries>
#include <QHorizontalStackedBarSeries>
#include "Chart.h"
QT_CHARTS_USE_NAMESPACE//QtChart名空间
enum BParListModel
{
BPRODUCTIONSUMVALUE1,
BPRODUCTIONSUMVALUE2,
BPLANFORTHEMONTHVALUE1,
BPLANFORTHEMONTHVALUE2,
BLOADDISTRIBUTIONVALUE1,
BPASSEDTHEINSPECTIONVALUE1,
BQUALITYMANAGEMENTVALUE1,
BCHARTBAR1VALUE1,
BCHARTBAR1VALUE2,
BCHARTBAR2VALUE1,
BCHARTBAR2VALUE2,
BCHARTBAR3VALUE1,
BCHARTBAR3VALUE2,
BCAHRTBAR4VALUE1,
BCAHRTBAR5VALUE1,
BCAHRTBAR5VALUE2,
BCAHRTBAR6VALUE1,
};
struct BarPer
{
QString _name;
QList<qreal> _value;
QColor _borderColor;
QColor _brushColor;
};
class ChartBar : public ChartBaseSeries
{
Q_OBJECT
public:
ChartBar(int index,QWidget* parent = nullptr);
~ChartBar();
void Init(QList<BarPer> list);
QList<BarPer> GetBPar(BParListModel);
void SetMoreColor(QBarSeries*,QList<BarPer>);
void SetMax(int max);
void SetMaxColor(QColor);
private:
QBarSeries* InitBarSeries(QList<BarPer> list);
QStackedBarSeries* InitStackedBarSeries(QList<BarPer> list);
QHorizontalBarSeries* InitHBarSeries(QList<BarPer> list);
QHorizontalStackedBarSeries* InithStackedBarSeries(QList<BarPer> list);
int _index = 0;
int _max = 0;
QColor _maxColor = QColor();
};
#endif //_CHART_BARSET_H_

View File

@ -0,0 +1,500 @@
#include "ChartBaseSeries.h"
ChartBaseSeries::ChartBaseSeries(QWidget *parent)
{
}
ChartBaseSeries::~ChartBaseSeries()
{
}
AxisPar ChartBaseSeries::GetPar(AParModel model)
{
AxisPar aPar;
switch(model)
{
case APRODUCTIONSUM1:
{
AxisPar par;
par.xMax = 5;
par.xCount = 1;
par.yNameList = QStringList() << "设变" << "修膜" << "新模";
aPar = par;
break;
}
case APRODUCTIONSUM2:
{
AxisPar par;
par.yMax = 100;
par.yCount = 6;
par.xNameList = QStringList() << "1月" << "2月" << "3月" << "4月" << "5月" << "6月" << "7月" << "8月";
aPar = par;
break;
}
case APRODUCTIONSUM3:
{
AxisPar par;
par.xCount = 1;
par.xMax = 12000;
par.yNameList = QStringList() << "设变" << "修膜" << "新模";
aPar = par;
break;
}
case APRODUCTIONSUM4:
{
AxisPar par;
par.yMax = 100;
par.yCount = 6;
par.xNameList = QStringList() << "1月" << "2月" << "3月" << "4月" << "5月" << "6月" << "7月" << "8月";
aPar = par;
break;
}
case APLANFORTHEMONTH1:
{
AxisPar par;
par.yMax = 700;
par.xCount = 8;
par.xNameList = QStringList() << "摸仁" << "不会" << "辅件" << "电极";
aPar = par;
break;
}
case APLANFORTHEMONTH2:
{
AxisPar par;
par.yMax = 100;
par.xMax = 32;
par.yCount = 6;
par.xCount = 33;
aPar = par;
break;
}
case ALOADDISTRIBUTION1:
{
AxisPar par;
par.yMax = 90;
par.yCount = 10;
par.xNameList = QStringList() << "CNC组" << "CNC精" << "EDM" << "WEDM" << "锐床" << "磨末";
aPar = par;
break;
}
case ALOADDISTRIBUTION2:
{
AxisPar par;
par.yMax = 200;
par.yCount = 9;
par.xMax = 8;
par.xCount = 9;
aPar = par;
break;
}
case APASSEDTHEINSPECTION1:
{
AxisPar par;
par.yMax = 120;
par.yCount = 7;
par.xMax = 11;
par.xCount = 12;
aPar = par;
break;
}
case APASSEDTHEINSPECTION2:
{
AxisPar par;
par.yMax = 120;
par.yCount = 7;
par.xMax = 11;
par.xCount = 12;
aPar = par;
break;
}
case APASSEDTHEINSPECTION3:
{
AxisPar par;
par.yMax = 100;
par.yCount = 6;
par.xNameList = QStringList() << "CNC组" << "CNC精" << "EDM" << "WEDM" << "铣床" << "磨床";
par.xCount = 0;
aPar = par;
break;
}
case AQUALITYMANAGEMENT1:
{
break;
}
case AQUALITYMANAGEMENT2:
{
AxisPar par;
par.yMax = 100;
par.yCount = 6;
par.xNameList = QStringList() << "CNC" << "EDM" << "线割" << "磨床" << "铣床" << "外协";
aPar = par;
break;
}
case AQUALITYMANAGEMENT3:
{
AxisPar par;
par.yMax = 120;
par.yCount = 7;
par.xMax = 32;
par.xCount = 33;
aPar = par;
break;
}
case ACHARTLINE:
{
AxisPar par;
par.yMax = 120;
par.yCount = 13;
// par.xMax = 12;
// par.xCount = 13;
par.xNameList = QStringList() << "1月" << "2月" << "3月" << "4月" << "5月" << "6月"
<< "7月" << "8月" << "9月" << "10月" << "11月" << "12月";
aPar = par;
break;
}
case ACHARTCURVE1:
{
AxisPar par;
par.yMax = 120;
par.yCount = 5;
par.xMax = 16;
par.xCount = 17;
aPar = par;
break;
}
case ACHARTCURVE2:
{
AxisPar par;
par.yMax = 120;
par.yCount = 5;
par.xMax = 16;
par.xCount = 17;
aPar = par;
break;
}
case ACHARTCURVE3:
{
AxisPar par;
par.yMax = 120;
par.yCount = 5;
par.xMax = 16;
par.xCount = 17;
aPar = par;
break;
}
case ACHARTBAR1:
{
AxisPar par;
par.yMax = 100;
par.yCount = 6;
par.yformat = "%.0f%";
par.xNameList = QStringList() << "项目1" << "项目2" << "项目3" << "项目4" << "项目5" << "项目6";
aPar = par;
break;
}
case ACHARTBAR2:
{
AxisPar par;
par.yMax = 100;
par.yCount = 6;
par.yformat = "%.0f%";
par.xNameList = QStringList() << "小组1" << "小组2" << "小组3" << "小组4" << "小组5" << "小组6";
aPar = par;
break;
}
case ACHARTBAR3:
{
AxisPar par;
par.yMax = 100;
par.yCount = 6;
par.xMax = 32;
par.xCount = 17;
aPar = par;
break;
}
case ACHARTBAR4:
{
AxisPar par;
par.yMax = 100;
par.yCount = 6;
par.xMax = 32;
par.xCount = 17;
aPar = par;
break;
}
case ACHARTBAR5:
{
AxisPar par;
par.yMax = 600;
par.yCount = 7;
par.xNameList = QStringList() << "模仁" << "揽件" << "辅件" << "电极";
aPar = par;
break;
}
case ACHARTBAR6:
{
AxisPar par;
par.yMax = 600;
par.yCount = 7;
par.xNameList = QStringList() << "模仁" << "揽件" << "辅件" << "电极";
aPar = par;
break;
}
case ACHARTBAR7:
{
AxisPar par;
par.xMax = 100;
par.xCount = 6;
par.yNameList = QStringList() << "项目1" << "项目2" << "项目3" << "项目4" << "项目5" << "项目6";
aPar = par;
break;
}
case ACHARTBAR8:
{
AxisPar par;
par.xMax = 100;
par.xCount = 6;
par.yMax = 32;
par.yCount = 17;
aPar = par;
break;
}
case ACHARTBAR9:
{
AxisPar par;
par.xMax = 100;
par.xCount = 6;
par.yMax = 32;
par.yCount = 17;
aPar = par;
break;
}
case ACHARTBAR10:
{
AxisPar par;
par.xMax = 100;
par.xCount = 1;
par.yNameList = QStringList() << "设变" << "修膜" << "新模";
aPar = par;
break;
}
}
return aPar;
}
ChartPar ChartBaseSeries::GetPar(CParModel index)
{
ChartPar _cPar;
switch (index)
{
case CPRODUCTIONSUM1:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CPRODUCTIONSUM2:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CPRODUCTIONSUM3:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CPRODUCTIONSUM4:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CPLANFORTHEMONTH1:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CPLANFORTHEMONTH2:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CLOADDISTRIBUTION1:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CLOADDISTRIBUTION2:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CPASSEDTHEINSPECTION1:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CPASSEDTHEINSPECTION2:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CPASSEDTHEINSPECTION3:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CQUALITYMANAGEMENT1:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CQUALITYMANAGEMENT2:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CQUALITYMANAGEMENT3:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CCHARTLINE:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(18,60,120));
_cPar = cPar;
break;
}
case CCHARTCURVE1:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CCHARTCURVE2:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CCHARTCURVE3:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(40,42,76));
_cPar = cPar;
break;
}
case CCHARTBAR1:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(18,60,120));
_cPar = cPar;
break;
}
case CCHARTBAR2:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(18,60,120));
_cPar = cPar;
break;
}
case CCHARTBAR3:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(18,60,120));
_cPar = cPar;
break;
}
case CCHARTBAR4:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(18,60,120));
_cPar = cPar;
break;
}
case CCHARTBAR5:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(18,60,120));
_cPar = cPar;
break;
}
case CCHARTBAR6:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(18,60,120));
_cPar = cPar;
break;
}
case CCHARTBAR7:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(18,60,120));
_cPar = cPar;
break;
}
case CCHARTBAR8:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(18,60,120));
_cPar = cPar;
break;
}
case CCHARTBAR9:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(18,60,120));
_cPar = cPar;
break;
}
case CCHARTBAR10:
{
ChartPar cPar;
cPar._backBrush = QBrush(QColor(18,60,120));
_cPar = cPar;
break;
}
}
return _cPar;
}
void ChartBaseSeries::Set(ChartPar par)
{
_cPar = par;
}
void ChartBaseSeries::Set(AxisPar par)
{
_aPar = par;
}

View File

@ -0,0 +1,92 @@
#ifndef _CHART_BASE_SERIES_H_
#define _CHART_BASE_SERIES_H_
#include <QWidget>
#include "Chart.h"
enum AParModel
{
APRODUCTIONSUM1,
APRODUCTIONSUM2,
APRODUCTIONSUM3,
APRODUCTIONSUM4,
APLANFORTHEMONTH1,
APLANFORTHEMONTH2,
ALOADDISTRIBUTION1,
ALOADDISTRIBUTION2,
APASSEDTHEINSPECTION1,
APASSEDTHEINSPECTION2,
APASSEDTHEINSPECTION3,
AQUALITYMANAGEMENT1,
AQUALITYMANAGEMENT2,
AQUALITYMANAGEMENT3,
ACHARTLINE,
ACHARTCURVE1,
ACHARTCURVE2,
ACHARTCURVE3,
ACHARTBAR1,
ACHARTBAR2,
ACHARTBAR3,
ACHARTBAR4,
ACHARTBAR5,
ACHARTBAR6,
ACHARTBAR7,
ACHARTBAR8,
ACHARTBAR9,
ACHARTBAR10,
};
enum CParModel
{
CPRODUCTIONSUM1,
CPRODUCTIONSUM2,
CPRODUCTIONSUM3,
CPRODUCTIONSUM4,
CPLANFORTHEMONTH1,
CPLANFORTHEMONTH2,
CLOADDISTRIBUTION1,
CLOADDISTRIBUTION2,
CPASSEDTHEINSPECTION1,
CPASSEDTHEINSPECTION2,
CPASSEDTHEINSPECTION3,
CQUALITYMANAGEMENT1,
CQUALITYMANAGEMENT2,
CQUALITYMANAGEMENT3,
CCHARTLINE,
CCHARTCURVE1,
CCHARTCURVE2,
CCHARTCURVE3,
CCHARTBAR1,
CCHARTBAR2,
CCHARTBAR3,
CCHARTBAR4,
CCHARTBAR5,
CCHARTBAR6,
CCHARTBAR7,
CCHARTBAR8,
CCHARTBAR9,
CCHARTBAR10,
};
class ChartBaseSeries : public QWidget
{
Q_OBJECT
public:
ChartBaseSeries(QWidget* parent = nullptr);
~ChartBaseSeries();
AxisPar GetPar(AParModel);
ChartPar GetPar(CParModel);
void Set(ChartPar par);
void Set(AxisPar par);
protected:
ChartPar _cPar;
AxisPar _aPar;
QMap<AParModel,AParModel> _aMapList;
QMap<CParModel,CParModel> _cMapList;
};
#endif //_CHART_BASE_SERIES_H_

147
Src/Chart/ChartCurve.cpp Normal file
View File

@ -0,0 +1,147 @@
#include "ChartCurve.h"
#include <QValueAxis>
#include <QHBoxLayout>
#include "Chart.h"
#include "QTime"
ChartCurve::ChartCurve(QWidget *parent)
:ChartBaseSeries(parent)
{
}
void ReadData()
{
}
ChartCurve::~ChartCurve()
{
}
QList<CurvePar> ChartCurve::GetCuPar(CuParListModel index)
{
QList<CurvePar> cuPar;
switch (index)
{
case CUCHARTCURVE1:
{
QList<CurvePar> valueList;
QList<QPointF> point1;
qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); //不能放在循环里,否则容易出现很多相同随机数
for(int i = 0; i < 15; i++)
{
point1.append(QPointF(i + 1,qrand() % 100));
}
valueList.push_back(CurvePar{QColor(73,183,199),"",point1});
cuPar = valueList;
break;
}
case CUCHARTCURVE2:
{
QList<CurvePar> valueList;
QList<QPointF> point1;
qsrand(QTime(0,6,0).secsTo(QTime::currentTime())); //不能放在循环里,否则容易出现很多相同随机数
for(int i = 0; i < 15; i++)
{
point1.append(QPointF(i + 1,qrand() % 100));
}
valueList.push_back(CurvePar{QColor(96,79,121),"",point1});
cuPar = valueList;
break;
}
case CUCHARTCURVE3:
{
QList<CurvePar> valueList;
QList<QPointF> point1;
qsrand(QTime(0,0,3).secsTo(QTime::currentTime())); //不能放在循环里,否则容易出现很多相同随机数
for(int i = 0; i < 15; i++)
{
point1.append(QPointF(i + 1,qrand() % 100));
}
valueList.push_back(CurvePar{QColor(254,137,44),"",point1});
cuPar = valueList;
break;
}
}
return cuPar;
}
void ChartCurve::Init(QList<CurvePar> cuPar)
{
QHBoxLayout* mLayout = new QHBoxLayout();
mLayout->setSpacing(0);
mLayout->setContentsMargins(0,0,0,0);
QList<QAbstractSeries*> SeriesList;
for(int i = 0; i < cuPar.size(); i++)
{
QSplineSeries* lineSeries = InitLine(cuPar.at(i).Color,cuPar.at(i).name,cuPar.at(i).list);
SeriesList.push_back(lineSeries);
}
//生成图表
Chart* chart = new Chart();
chart->Set(_cPar);
chart->Set(_aPar);
chart->InitChart();
chart->InitAxis();
for(auto& i : SeriesList)
{
chart->addSeries(i);
chart->setAxisX(chart->axisX(),i);
chart->setAxisY(chart->axisY(),i);
}
chart->InitLegend();
//生成View
QChartView *chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
mLayout->addWidget(chartView);
this->setLayout(mLayout);
}
void ChartCurve::SetPointShow(bool isShow)
{
isPointLabelShow = isShow;
}
QSplineSeries* ChartCurve::InitLine(QColor color,QString name, QList<QPointF> list)
{
QFont font;
font.setItalic(!font.italic());
font.setPointSizeF(15);
font.setFamily("微软雅黑");
QSplineSeries* lineSeries = new QSplineSeries();
//添加数据
lineSeries->append(list);
//设置线段的名称
lineSeries->setName(name);
//设置线段的颜色
lineSeries->setColor(QColor());
//设置线段是否可视话
lineSeries->setVisible(true);
//点标签文字是否可见
lineSeries->setPointLabelsVisible(isPointLabelShow);
//点标签字体
lineSeries->setPointLabelsFont(font);
//点标签颜色
lineSeries->setPointLabelsColor(QColor(color));
//点标签格式
lineSeries->setPointLabelsFormat("@yPoint");
//是否切割边缘点标签默认为true
lineSeries->setPointLabelsClipping(true);
//设置点是否可视
lineSeries->setPointsVisible(true);
//设置笔
lineSeries->setPen(QPen(QBrush(color),2));
//使用opengl渲染
lineSeries->setUseOpenGL(true);
return lineSeries;
}

45
Src/Chart/ChartCurve.h Normal file
View File

@ -0,0 +1,45 @@
#ifndef _CHART_CURVE_H_
#define _CHART_CURVE_H_
#include <QWidget>
#include "ChartBaseSeries.h"
#include <QChartView>//显示图表
#include <QSplineSeries>
#include <QDoubleSpinBox>
#include <QList>
#include <QPointF>
QT_CHARTS_USE_NAMESPACE//QtChart名空间
enum CuParListModel
{
CUCHARTCURVE1,
CUCHARTCURVE2,
CUCHARTCURVE3
};
struct CurvePar
{
QColor Color;
QString name;
QList<QPointF> list;
};
class ChartCurve : public ChartBaseSeries
{
Q_OBJECT
public:
ChartCurve(QWidget* parent = nullptr);
~ChartCurve();
QList<CurvePar> GetCuPar(CuParListModel);
void Init(QList<CurvePar>);
void SetPointShow(bool);
private:
QSplineSeries* InitLine(QColor,QString,QList<QPointF> list);
bool isPointLabelShow = false;
};
#endif //_CHART_CURVE_H_

255
Src/Chart/ChartLine.cpp Normal file
View File

@ -0,0 +1,255 @@
#include "ChartLine.h"
#include <QValueAxis>
#include <QHBoxLayout>
#include <QScatterSeries>
#include <QTime>
ChartLine::ChartLine(QWidget *parent)
:ChartBaseSeries(parent)
{
}
ChartLine::~ChartLine()
{
}
void ChartLine::Init(QList<LinePar> linepar)
{
QHBoxLayout* mLayout = new QHBoxLayout();
mLayout->setSpacing(0);
mLayout->setContentsMargins(0,0,0,0);
QList<QAbstractSeries*> SeriesList;
for(auto &i : linepar)
{
QLineSeries* lineSeries = InitLine(i.Color,i.name,i.list);
QScatterSeries* sc1 = InitOutSeries(i.list);
QScatterSeries* sc2 = InitInSeries(i.Color,i.list);
SeriesList.push_back(lineSeries);
SeriesList.push_back(sc1);
SeriesList.push_back(sc2);
}
//生成图表
Chart* chart = new Chart();
chart->Set(_cPar);
chart->Set(_aPar);
chart->InitChart();
chart->InitAxis();
for(auto &j : SeriesList)
{
chart->addSeries(j);
chart->setAxisX(chart->axisX(),j);
chart->setAxisY(chart->axisY(),j);
}
chart->InitLegend();
//生成View
QChartView *chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
mLayout->addWidget(chartView);
this->setLayout(mLayout);
}
QList<LinePar> ChartLine::GetLPar(LParListModel index)
{
QList<LinePar> _valueList;
switch(index)
{
case LPRODUCTIONSUMVALUE1:
{
QList<LinePar> valueList;
QList<QPointF> point;
point << QPointF(0,20) << QPointF(1,80) << QPointF(2,35) << QPointF(3,82) << QPointF(4,85) << QPointF(5,18) << QPointF(6,22) << QPointF(7,16);
QList<QPointF> point1;
point1 << QPointF(0,15) << QPointF(1,60) << QPointF(2,63) << QPointF(3,78) << QPointF(4,85) << QPointF(5,70) << QPointF(6,18) << QPointF(7,36);
QList<QPointF> point2;
point2 << QPointF(0,18) << QPointF(1,22) << QPointF(2,32) << QPointF(3,83) << QPointF(4,56) << QPointF(5,10) << QPointF(6,37) << QPointF(7,35);
valueList.push_back(LinePar{QColor(255,200,0),"",point});
valueList.push_back(LinePar{QColor(1,177,181),"",point1});
valueList.push_back(LinePar{QColor(7,106,182),"",point2});
_valueList = valueList;
break;
}
case LPRODUCTIONSUMVALUE2:
{
QList<LinePar> valueList;
QList<QPointF> point3;
point3 << QPointF(0,20) << QPointF(1,80) << QPointF(2,35) << QPointF(3,82) << QPointF(4,85) << QPointF(5,18) << QPointF(6,22) << QPointF(7,16);
QList<QPointF> point4;
point4 << QPointF(0,15) << QPointF(1,60) << QPointF(2,63) << QPointF(3,78) << QPointF(4,85) << QPointF(5,70) << QPointF(6,18) << QPointF(7,36);
QList<QPointF> point5;
point5 << QPointF(0,18) << QPointF(1,22) << QPointF(2,32) << QPointF(3,83) << QPointF(4,56) << QPointF(5,10) << QPointF(6,37) << QPointF(7,35);
valueList.push_back(LinePar{QColor(255,200,0),"",point3});
valueList.push_back(LinePar{QColor(1,177,181),"",point4});
valueList.push_back(LinePar{QColor(7,106,182),"",point5});
_valueList = valueList;
break;
}
case LLOADDISTRIBUTIONVALUE1:
{
QList<LinePar> valueList;
QList<QPointF> point1 = QList<QPointF>() << QPointF(1,20) << QPointF(2,50) << QPointF(3,100) << QPointF(4,180) << QPointF(5,85) << QPointF(6,18) << QPointF(7,60);
QList<QPointF> point2 = QList<QPointF>() << QPointF(1,25) << QPointF(2,70) << QPointF(3,60) << QPointF(4,160) << QPointF(5,85) << QPointF(6,70) << QPointF(7,18);
QList<QPointF> point3 = QList<QPointF>() << QPointF(1,40) << QPointF(2,10) << QPointF(3,120) << QPointF(4,150) << QPointF(5,56) << QPointF(6,30) << QPointF(7,55);
QList<QPointF> point4 = QList<QPointF>() << QPointF(1,60) << QPointF(2,150) << QPointF(3,125) << QPointF(4,165) << QPointF(5,85) << QPointF(6,60) << QPointF(7,120);
QList<QPointF> point5 = QList<QPointF>() << QPointF(1,30) << QPointF(2,80) << QPointF(3,20) << QPointF(4,175) << QPointF(5,85) << QPointF(6,110) << QPointF(7,40);
QList<QPointF> point6 = QList<QPointF>() << QPointF(1,75) << QPointF(2,50) << QPointF(3,10) << QPointF(4,100) << QPointF(5,180) << QPointF(6,50) << QPointF(7,80);
valueList.push_back(LinePar{QColor(0,181,183),"",point1});
valueList.push_back(LinePar{QColor(254,190,0),"",point2});
valueList.push_back(LinePar{QColor(0,112,191),"",point3});
valueList.push_back(LinePar{QColor(71,100,147),"",point4});
valueList.push_back(LinePar{QColor(214,77,84),"",point5});
valueList.push_back(LinePar{QColor(0,174,123),"",point6});
_valueList = valueList;
break;
}
case LPASSEDTHEINSPECTIONVALUE1:
{
QList<LinePar> valueList;
QList<QPointF> point1 = QList<QPointF>() << QPointF(1,87) << QPointF(2,30) << QPointF(3,32) << QPointF(4,31) << QPointF(5,33)
<< QPointF(6,36) << QPointF(7,37) << QPointF(8,30) << QPointF(9,80) << QPointF(10,75);
valueList.push_back(LinePar{QColor(0,181,183),"",point1});
_valueList = valueList;
break;
}
case LPASSEDTHEINSPECTIONVALUE2:
{
QList<LinePar> valueList;
QList<QPointF> point1 = QList<QPointF>() << QPointF(1,73) << QPointF(2,32) << QPointF(3,33) << QPointF(4,31) << QPointF(5,32)
<< QPointF(6,60) << QPointF(7,76) << QPointF(8,80) << QPointF(9,35) << QPointF(10,43);
valueList.push_back(LinePar{QColor(0,181,183),"",point1});
_valueList = valueList;
break;
}
case LQUALITYMANAGEMENTVALUE1:
{
QList<LinePar> valueList;
QList<QPointF> point1 = QList<QPointF>();
qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); //不能放在循环里,否则容易出现很多相同随机数
for(int i = 0; i < 31; i++)
{
point1.append(QPointF(i + 1,qrand() % 100));
}
valueList.push_back(LinePar{QColor(0,181,183),"",point1});
_valueList = valueList;
break;
}
case LCHARTLINEVALUE:
{
QList<LinePar> valueList;
QList<QPointF> point1;
QList<QPointF> point2;
QList<QPointF> point3;
QList<QPointF> point4;
QList<QPointF> point5;
qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); //不能放在循环里,否则容易出现很多相同随机数
for(int i = 0; i < 12; i++)
{
point1.append(QPointF(i,qrand() % 120));
}
for(int i = 0; i < 12; i++)
{
point2.append(QPointF(i,qrand() % 120));
}
for(int i = 0; i < 12; i++)
{
point3.append(QPointF(i,qrand() % 120));
}
for(int i = 0; i < 12; i++)
{
point4.append(QPointF(i,qrand() % 120));
}
for(int i = 0; i < 12; i++)
{
point5.append(QPointF(i,qrand() % 120));
}
valueList.push_back(LinePar{QColor(47,166,242),"",point1});
valueList.push_back(LinePar{QColor(51,215,218),"",point2});
valueList.push_back(LinePar{QColor(222,129,50),"",point3});
valueList.push_back(LinePar{QColor(74,100,151),"",point4});
valueList.push_back(LinePar{QColor(188,92,88),"",point5});
_valueList = valueList;
break;
}
}
return _valueList;
}
QLineSeries *ChartLine::InitLine(QColor Color, QString name, QList<QPointF> list)
{
QFont font;
font.setItalic(!font.italic());
font.setPointSizeF(12);
font.setFamily("微软雅黑");
QLineSeries* lineSeries = new QLineSeries();
//添加数据
lineSeries->append(list);
//设置线段的名称
lineSeries->setName(name);
//设置线段的颜色
lineSeries->setColor(QColor());
//设置线段是否可视话
lineSeries->setVisible(true);
//点标签文字是否可见
lineSeries->setPointLabelsVisible(false);
//点标签字体
lineSeries->setPointLabelsFont(font);
//点标签格式
lineSeries->setPointLabelsFormat("@xPoint,@yPoint");
//是否切割边缘点标签默认为true
lineSeries->setPointLabelsClipping(true);
//设置点是否可视
lineSeries->setPointsVisible(true);
//设置笔
lineSeries->setPen(QPen(QBrush(Color),2));
//使用opengl渲染
lineSeries->setUseOpenGL(true);
//离散点
QScatterSeries *series1 = new QScatterSeries();
//圆形的点
series1->setMarkerShape(QScatterSeries::MarkerShapeCircle);
//离散点边框颜色
series1->setBorderColor(QColor(21, 100, 255));
//离散点背景色
series1->setBrush(QBrush(QColor(21, 100, 255)));
//离散点大小
series1->setMarkerSize(12);
//添加数据
series1->append(list);
return lineSeries;
}
QScatterSeries *ChartLine::InitOutSeries(QList<QPointF> list)
{
QScatterSeries *series1 = new QScatterSeries();
series1->setMarkerShape(QScatterSeries::MarkerShapeCircle);//圆形的点
series1->setBorderColor(QColor(255, 255, 255)); //边框颜色
series1->setBrush(QBrush(QColor(255, 255, 255)));//背景颜色
series1->setMarkerSize(12);
series1->append(list);
series1->setUseOpenGL(true);
return series1;
}
QScatterSeries *ChartLine::InitInSeries(QColor color,QList<QPointF> list)
{
QScatterSeries *series1 = new QScatterSeries();
series1->setMarkerShape(QScatterSeries::MarkerShapeCircle);//圆形的点
series1->setBorderColor(color); //边框颜色
series1->setBrush(QBrush(color));//背景颜色
series1->setMarkerSize(6);
series1->append(list);
series1->setUseOpenGL(true);
return series1;
}

50
Src/Chart/ChartLine.h Normal file
View File

@ -0,0 +1,50 @@
#ifndef _CHART_LINE_H_
#define _CHART_LINE_H_
#include "ChartBaseSeries.h"
#include <QChartView>//显示图表
#include <QLineSeries>
#include <QDoubleSpinBox>
#include <QList>
#include <QScatterSeries>
#include "Chart.h"
QT_CHARTS_USE_NAMESPACE//QtChart名空间
enum LParListModel
{
LPRODUCTIONSUMVALUE1,
LPRODUCTIONSUMVALUE2,
LLOADDISTRIBUTIONVALUE1,
LPASSEDTHEINSPECTIONVALUE1,
LPASSEDTHEINSPECTIONVALUE2,
LQUALITYMANAGEMENTVALUE1,
LCHARTLINEVALUE,
};
struct LinePar
{
QColor Color;
QString name;
QList<QPointF> list;
};
class ChartLine : public ChartBaseSeries
{
Q_OBJECT
public:
ChartLine(QWidget* parent = nullptr);
~ChartLine();
void Init(QList<LinePar>);
QList<LinePar> GetLPar(LParListModel);
private:
QLineSeries* InitLine(QColor Color,QString name,QList<QPointF> list);
QScatterSeries* InitInSeries(QColor,QList<QPointF> list);
QScatterSeries* InitOutSeries(QList<QPointF> list);
};
#endif //_CHART_LINE_H_

86
Src/Chart/ChartPie.cpp Normal file
View File

@ -0,0 +1,86 @@
#include "ChartPie.h"
#include "Chart.h"
#include <QChartView>
#include <QHBoxLayout>
#include <QDebug>
#include <QGraphicsLayout>
ChartPie::ChartPie(QWidget *parent)
:ChartBaseSeries (parent)
{
}
ChartPie::~ChartPie()
{
}
void ChartPie::Init(QList<QColor> colorList,QStringList nameList,QList<int> valueList,int total)
{
if(colorList.size() != nameList.size() || colorList.size() != valueList.size() )
return;
_total = total;
QHBoxLayout* mLayout = new QHBoxLayout();
mLayout->setSpacing(0);
mLayout->setContentsMargins(0,0,0,0);
QPieSeries* pieSeries = new QPieSeries();
//孔大小
pieSeries->setHoleSize(0.0);
//水平位置
pieSeries->setHorizontalPosition(0.5);
//设置文字位置
// pieSeries->setLabelsPosition(QPieSlice::LabelInsideTangential);
//设置文字是否可视化
// pieSeries->setLabelsVisible(true);
//饼图尺寸
pieSeries->setPieSize(0.7);
//设置12方向是几度
pieSeries->setPieStartAngle(0);
pieSeries->setVerticalPosition(0.5);
pieSeries->setVisible(true);
pieSeries->setUseOpenGL(true);
for(int i = 0; i < colorList.size(); i++)
{
CreatePieSlice(pieSeries,colorList.at(i),nameList.at(i),valueList.at(i),i);
}
// CreatePieSlice(pieSeries,QColor(90,180,180),"bcc",30,1);
// CreatePieSlice(pieSeries,QColor(150,180,180),"ccc",30,2);
// CreatePieSlice(pieSeries,QColor(210,180,180),"dcc",10,3);
QChart* chart = new QChart();
//设置系统主题
chart->setTheme(QChart::ChartThemeBlueCerulean);
//是否启用动画
chart->setAnimationOptions(QChart::AllAnimations);
chart->layout()->setContentsMargins(0, 0, 0, 0);//设置外边界全部为0
chart->setMargins(QMargins(0, 0, 0, 0));//设置内边界全部为0
chart->setBackgroundRoundness(0);//设置背景区域无圆角
// chart->InitChart();
// chart->InitLegend();
// chart->InitAxis();
chart->addSeries(pieSeries);
QChartView* view = new QChartView(chart);
mLayout->addWidget(view);
this->setLayout(mLayout);
}
void ChartPie::CreatePieSlice(QPieSeries* pieSeries,QColor color,QString name,int value,int index, bool isExploded)
{
pieSeries->append(name,value);
QPieSlice* slice = pieSeries->slices().at(index);
slice->setExploded(isExploded);
slice->setLabelColor(color);
slice->setColor(color);
// qDebug() <<color;
const float fValue = (slice->value() / _total * 100);
// qDebug() << fValue;
QString sValue = QString::number(fValue,'f',2);
slice->setLabelPosition(QPieSlice::LabelOutside);
slice->setLabel(slice->label() + " - "+ sValue + "%");
slice->setLabelFont(QFont("微软雅黑"));
slice->setLabelVisible(true);
}

25
Src/Chart/ChartPie.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef _CHART_PIE_H_
#define _CHART_PIE_H_
#include "ChartBaseSeries.h"
#include "QWidget"
#include <QPieSeries>
#include <QPieSlice>
QT_CHARTS_USE_NAMESPACE //QtChart名空间
class ChartPie : public ChartBaseSeries
{
Q_OBJECT
public:
ChartPie(QWidget* parent = nullptr);
~ChartPie();
void Init(QList<QColor>,QStringList,QList<int>,int total);
private:
void CreatePieSlice(QPieSeries*,QColor color,QString name,int value,int index,bool isExploded = false);
private:
int _total = 0;
};
#endif //_CHART_PIE_H_

View File

@ -0,0 +1,29 @@
#include "ControlDashBoard.h"
#include <QPainter>
ControlDashBoard::ControlDashBoard(QWidget *parent)
:QWidget (parent)
{
}
ControlDashBoard::~ControlDashBoard()
{
}
void ControlDashBoard::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
DrawBackGround(&painter);
}
void ControlDashBoard::DrawBackGround(QPainter* painter)
{
painter->save();
painter->restore();
}

View File

@ -0,0 +1,19 @@
#ifndef _CONTROL_DASH_BOARD_H_
#define _CONTROL_DASH_BOARD_H_
#include <QWidget>
class ControlDashBoard : public QWidget
{
Q_OBJECT
public:
ControlDashBoard(QWidget* parent = nullptr);
~ControlDashBoard();
protected:
void paintEvent(QPaintEvent *event);
private:
void DrawBackGround(QPainter*);
};
#endif //_CONTROL_DASH_BOARD_H_

View File

@ -0,0 +1,114 @@
#include "ControlRoundProBar.h"
#include <QPainter>
#include <QPen>
#include <QTimer>
#include <QDebug>
#include <QPropertyAnimation>
ContorlRoundProBar::ContorlRoundProBar(QWidget* parent)
:QWidget(parent)
{
QTimer* mTimer = new QTimer(this);
mTimer->setInterval(2000);
this->connect(mTimer,&QTimer::timeout,this,[=](){
int Angle = qrand() % 100;
proportion = (double)Angle / 100.0;
ChangeValue();
});
mTimer->start();
}
void ContorlRoundProBar::ChangeValue()
{
QPropertyAnimation *pAnimation = new QPropertyAnimation(this, "oldproprortion");
pAnimation->setDuration(1000);
pAnimation->setStartValue(oldproprortion);
pAnimation->setEndValue(proportion);
pAnimation->start(QAbstractAnimation::DeleteWhenStopped);
// qDebug() << oldproprortion;
str = QString::number(proportion * 100) + "%";
update();
}
void ContorlRoundProBar::SetOldproprortion(double d)
{
oldproprortion = d;
repaint();
}
double ContorlRoundProBar::GetOldproprortion()
{
return oldproprortion;
}
ContorlRoundProBar::~ContorlRoundProBar()
{
}
void ContorlRoundProBar::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
DrawOotRound(&painter);
DrawInRound(&painter);
DrawOutRound1(&painter);
DrawText(&painter);
}
void ContorlRoundProBar::DrawOotRound(QPainter* painter)
{
painter->save();
QPen pen;
pen.setWidth(18);
pen.setColor(QColor(233,248,248));
painter->setPen(pen);
painter->setBrush(Qt::NoBrush);
painter->drawEllipse(QRect(28,28,this->width() - 56,this->height() - 56));
painter->restore();
}
void ContorlRoundProBar::DrawInRound(QPainter* painter)
{
painter->save();
QPen pen;
pen.setWidth(18);
pen.setStyle(Qt::SolidLine);
pen.setCapStyle(Qt::RoundCap);
pen.setJoinStyle(Qt::RoundJoin);
pen.setColor(QColor(49, 177, 190));
painter->setPen(pen);
QRectF rectangle(28,28,this->width() - 56,this->height() - 56);
//从90度开始逆时针旋转
int startAngle = 90 * 16;
int spanAngle = oldproprortion * 360 * 16 * -1;
painter->drawArc(rectangle,startAngle,spanAngle);
painter->restore();
}
void ContorlRoundProBar::DrawOutRound1(QPainter* painter)
{
//当bar宽度小于3时便不再绘制装饰圆点
painter->setPen(QColor(255,255,255));
painter->setBrush(QColor(255,255,255));
//区域为圆点绘制正方形区域
painter->drawEllipse((28 + (this->width() - 56)) / 2 + 6,28 - 3,6,6);
}
void ContorlRoundProBar::DrawText(QPainter* painter)
{
painter->save();
//设置画笔
painter->setPen(QPen(QColor(220,220,220),12));
//设置字体
painter->setFont(QFont("黑体",30));
//画文字
QPointF point(this->width() / 2 - 30, this->height() / 2 + 15);
painter->drawText(point,str);
painter->restore();
}

View File

@ -0,0 +1,33 @@
#ifndef _CONTROL_ROUND_PRO_BAR_H_
#define _CONTROL_ROUND_PRO_BAR_H_
#include <QWidget>
class ContorlRoundProBar : public QWidget
{
Q_OBJECT
public:
ContorlRoundProBar(QWidget* parent = nullptr);
~ContorlRoundProBar();
Q_PROPERTY( double oldproprortion READ GetOldproprortion WRITE SetOldproprortion);
void ChangeValue();
void SetOldproprortion(double d);
double GetOldproprortion();
private:
void paintEvent(QPaintEvent *event);
void DrawOotRound(QPainter*);
void DrawInRound(QPainter*);
void DrawOutRound1(QPainter*);
void DrawText(QPainter*);
private:
double oldproprortion = 0.0;
double proportion = 0.0;
QString str = "";
};
#endif //_CONTROL_ROUND_PRO_BAR_H_

82
Src/Gui/BaseWidget.cpp Normal file
View File

@ -0,0 +1,82 @@
#include "BaseWidget.h"
#include <QHBoxLayout>
#include <QPushButton>
#include <QLabel>
BaseWidget::BaseWidget(QWidget *parent)
:QWidget (parent)
{
}
BaseWidget::~BaseWidget()
{
}
QPushButton *BaseWidget::InitButton(QString name, int width, int height, QString style)
{
QPushButton* btn = new QPushButton();
btn->setText(name);
if(width != 0)
btn->setFixedWidth(width);
if(height)
btn->setFixedHeight(height);
btn->setStyleSheet(style);
return btn;
}
QPushButton *BaseWidget::InitButton(QString name, int width, int height, QString icon, int iconWidth, int iconHeight, QString style)
{
QPushButton* btn = new QPushButton();
btn->setText(name);
if(width != 0)
btn->setFixedWidth(width);
if(height)
btn->setFixedHeight(height);
btn->setIcon(QIcon(icon));
btn->setIconSize(QSize(iconWidth,iconHeight));
btn->setStyleSheet(style);
return btn;
}
QLabel *BaseWidget::InitLabel(QString name, int width, int height, LabelPos pos, QString style)
{
QLabel* lbl = new QLabel();
lbl->setText(name);
if(width != 0)
lbl->setFixedWidth(width);
else if(height != 0)
lbl->setFixedHeight(height);
if(pos == POSLEFT)
lbl->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
else if(pos == POSCENTER)
lbl->setAlignment(Qt::AlignCenter);
else if(pos == POSRIGHT)
lbl->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
lbl->setStyleSheet(style);
return lbl;
}
QHBoxLayout *BaseWidget::InitHLayout(int spcaeing, int left, int top, int right, int bottom)
{
QHBoxLayout* mLayout = new QHBoxLayout();
mLayout->setSpacing(spcaeing);
mLayout->setContentsMargins(left,top,right,bottom);
return mLayout;
}
QVBoxLayout *BaseWidget::InitVLayout(int spaceing, int left, int top, int right, int bottom)
{
QVBoxLayout* mLayout = new QVBoxLayout();
mLayout->setSpacing(spaceing);
mLayout->setContentsMargins(left,top,right,bottom);
return mLayout;
}

41
Src/Gui/BaseWidget.h Normal file
View File

@ -0,0 +1,41 @@
#ifndef _BASE_WIDGET_H_
#define _BASE_WIDGET_H_
#include <QWidget>
class QHBoxLayout;
class QVBoxLayout;
class QPushButton;
class QLabel;
class BaseWidget : public QWidget
{
Q_OBJECT
protected:
enum LabelPos
{
POSLEFT,
POSCENTER,
POSRIGHT,
};
public:
BaseWidget(QWidget* parent = nullptr);
~BaseWidget();
protected:
//名字 长 宽 样式表
QPushButton* InitButton(QString name,int width,int height,QString style = "");
//名字 长 宽 图标 图标大小 样式表
QPushButton* InitButton(QString name,int width,int height,QString icon,int iconWidth,int iconHeight,QString style = "");
//名字 长 宽 位置 (1左 2中 3右) 样式表
QLabel* InitLabel(QString name,int width,int height,LabelPos pos,QString style = "");
//间隔 左 上 右 下
QHBoxLayout* InitHLayout(int spcaeing = 0,int left = 0,int top = 0,int right = 0,int bottom = 0);
//间隔 左 上 右 下
QVBoxLayout* InitVLayout(int spaceing = 0,int left = 0,int top = 0,int right = 0,int bottom = 0);
};
#endif //_BASE_WIDGET_H_

153
Src/Gui/DockWidget.cpp Normal file
View File

@ -0,0 +1,153 @@
#include "DockWidget.h"
#include <QDebug>
#include <QHBoxLayout>
DockWidgetTitle::DockWidgetTitle(QLabel *lbl,QWidget *parent)
:QWidget (parent)
{
QHBoxLayout* mLayout = new QHBoxLayout();
mLayout->setSpacing(0);
mLayout->setContentsMargins(0,0,0,0);
mLayout->addWidget(lbl);
this->setLayout(mLayout);
}
DockWidgetTitle::DockWidgetTitle(QString text, QWidget *parent)
{
QHBoxLayout* mLayout = new QHBoxLayout();
mLayout->setSpacing(0);
mLayout->setContentsMargins(0,0,0,0);
QLabel* lbl = new QLabel();
lbl->setAlignment(Qt::AlignCenter);
lbl->setStyleSheet("background-color:rgb(41,43,77);"
"font : ""楷体"" 15pt;"
"color:rgb(240,240,240);");
lbl->setText(text);
lbl->setFixedHeight(30);
mLayout->addWidget(lbl);
this->setLayout(mLayout);
}
DockWidgetTitle::~DockWidgetTitle()
{
}
void DockWidgetTitle::mouseMoveEvent(QMouseEvent *event)
{
QWidget::mouseMoveEvent(event);
}
void DockWidgetTitle::mousePressEvent(QMouseEvent *event)
{
QWidget::mousePressEvent(event);
}
void DockWidgetTitle::mouseReleaseEvent(QMouseEvent *event)
{
QWidget::mouseReleaseEvent(event);
}
DockWidget::DockWidget(QString text, QWidget *parent)
:QDockWidget (parent)
{
DockWidgetTitle* mTitle = new DockWidgetTitle(text);
this->setTitleBarWidget(mTitle);
DockWidgetList::Get()->Push(this);
}
DockWidget::DockWidget(QLabel *lbl, QWidget *parent)
:QDockWidget (parent)
{
DockWidgetTitle* mTitle = new DockWidgetTitle(lbl);
this->setTitleBarWidget(mTitle);
DockWidgetList::Get()->Push(this);
}
DockWidget::~DockWidget()
{
}
void DockWidget::SetDockWidget(QWidget *widget)
{
this->setWidget(widget);
}
DockWidgetList *DockWidgetList::Get()
{
static DockWidgetList cx;
return &cx;
}
void DockWidgetList::Push(DockWidget *wid)
{
_list.push_back(wid);
}
void DockWidgetList::DeleteAll()
{
for(auto & i : _list)
{
i->deleteLater();
i = nullptr;
}
}
void DockWidgetList::HideAll()
{
for(auto & i : _list)
{
i->hide();
}
}
void DockWidgetList::HideIndex(int index)
{
if(index > _list.size() - 1)
{
return;
}
_list.at(index)->hide();
}
void DockWidgetList::ShowAll()
{
for(auto &i : _list)
{
i->show();
}
}
void DockWidgetList::ShowIndex(int index)
{
if(index > _list.size() - 1)
{
return;
}
_list.at(index)->show();
}
DockWidget *DockWidgetList::GetDockWidgetIndex(int index)
{
DockWidget* dock = new DockWidget("11");
if(index >= _list.size())
return dock;
DockWidget* widget = _list.at(index);
ShowIndex(index);
return widget;
}
DockWidgetList::DockWidgetList(QObject *obj)
:QObject (obj)
{
}
DockWidgetList::~DockWidgetList()
{
}

59
Src/Gui/DockWidget.h Normal file
View File

@ -0,0 +1,59 @@
#ifndef _DOCK_WIDGET_H_
#define _DOCK_WIDGET_H_
#include <QDockWidget>
#include <QLabel>
class DockWidgetTitle : public QWidget
{
Q_OBJECT
public:
DockWidgetTitle(QLabel* lbl = nullptr,QWidget* parent = nullptr);
DockWidgetTitle(QString text = "",QWidget* parent = nullptr);
~DockWidgetTitle();
protected:
void mouseMoveEvent(QMouseEvent* e);
void mousePressEvent(QMouseEvent* e);
void mouseReleaseEvent(QMouseEvent* e);
private:
};
class DockWidget : public QDockWidget
{
Q_OBJECT
public:
DockWidget(QString text = "",QWidget* parent = nullptr);
DockWidget(QLabel* lbl = nullptr,QWidget* parent = nullptr);
~DockWidget();
void SetDockWidget(QWidget* widget);
// void Remove();
};
class DockWidgetList : public QObject
{
Q_OBJECT
public:
static DockWidgetList* Get();
void Push(DockWidget*);
void DeleteAll();
void HideAll();
void HideIndex(int index);
void ShowAll();
void ShowIndex(int index);
DockWidget* GetDockWidgetIndex(int);
private:
QList<DockWidget*> _list;
private:
DockWidgetList(QObject* obj = nullptr);
~DockWidgetList();
};
#endif //_DOCK_WIDGET_H_

280
Src/Gui/MainWindow.cpp Normal file
View File

@ -0,0 +1,280 @@
#include "MainWindow.h"
#include <QHBoxLayout>
#include "ModuleWidget.h"
#include <QMenu>
#include <QContextMenuEvent>
#include "DockWidget.h"
#include <QFileDialog>
#include <QMessageBox>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
// QWidget* mWidget = new QWidget();
// QHBoxLayout* mLayout = new QHBoxLayout();
// mLayout->setSpacing(0);
// mLayout->setContentsMargins(0,0,0,0);
// mWidget->setLayout(mLayout);
// this->setCentralWidget(mWidget);
this->setObjectName("MainWindow");
this->setStyleSheet("#MainWindow{background-color:rgb(12,15,46);}");
InitWidget();
InitMenu();
}
MainWindow::~MainWindow()
{
}
void MainWindow::contextMenuEvent(QContextMenuEvent *event)
{
_menu->exec(QCursor::pos());
event->accept();
}
void MainWindow::InitWidget()
{
ModuleWidget* productionSumWidget = new ModuleWidget(PRODUCTIONSUM);
ModuleWidget* planForTheMonthWidget = new ModuleWidget(PLANFORTHEMONTH);
ModuleWidget* deviceMonitorRingWidget = new ModuleWidget(DEVICEMONITORING);
ModuleWidget* MdloProgressWidget = new ModuleWidget(MOLDPROGRESS);
ModuleWidget* LoadDistributionWidget = new ModuleWidget(LOADDISTRIBUTION);
ModuleWidget* PassedTheInSpectionWidget = new ModuleWidget(PASSEDTHEINSPECTION);
ModuleWidget* QualityManagementWidget = new ModuleWidget(QUALITYMANAGEMENT);
ModuleWidget* MaterialManagementWidget = new ModuleWidget(MATERIALMANAGEMENT);
ModuleWidget* VideoSurveillance = new ModuleWidget(VIDEOSURVEILLANCE);
DockWidget* dockWidget1 = new DockWidget("随便吧");
dockWidget1->SetDockWidget(productionSumWidget);
dockWidget1->setObjectName("dockWidget1");
DockWidget* dockWidget2 = new DockWidget("随便了");
dockWidget2->SetDockWidget(planForTheMonthWidget);
dockWidget2->setObjectName("dockWidget2");
DockWidget* dockWidget3 = new DockWidget("随便吧");
dockWidget3->SetDockWidget(deviceMonitorRingWidget);
dockWidget3->setObjectName("dockWidget3");
DockWidget* dockWidget4 = new DockWidget("随便了");
dockWidget4->SetDockWidget(MdloProgressWidget);
dockWidget4->setObjectName("dockWidget4");
DockWidget* dockWidget5 = new DockWidget("随便吧");
dockWidget5->SetDockWidget(LoadDistributionWidget);
dockWidget5->setObjectName("dockWidget5");
DockWidget* dockWidget6 = new DockWidget("随便了");
dockWidget6->SetDockWidget(PassedTheInSpectionWidget);
dockWidget6->setObjectName("dockWidget6");
DockWidget* dockWidget7 = new DockWidget("随便吧");
dockWidget7->SetDockWidget(QualityManagementWidget);
dockWidget7->setObjectName("dockWidget7");
DockWidget* dockWidget8 = new DockWidget("随便了");
dockWidget8->SetDockWidget(MaterialManagementWidget);
dockWidget8->setObjectName("dockWidget8");
DockWidget* dockWidget9 = new DockWidget("随便了");
dockWidget9->SetDockWidget(VideoSurveillance);
dockWidget9->setObjectName("dockWidget9");
this->addDockWidget(Qt::LeftDockWidgetArea,dockWidget1);
this->splitDockWidget(dockWidget1,dockWidget2,Qt::Horizontal);
this->splitDockWidget(dockWidget2,dockWidget3,Qt::Horizontal);
this->splitDockWidget(dockWidget1,dockWidget4,Qt::Vertical);
this->splitDockWidget(dockWidget2,dockWidget5,Qt::Vertical);
this->splitDockWidget(dockWidget3,dockWidget6,Qt::Vertical);
}
void MainWindow::InitMenu()
{
_menu = new QMenu();
QAction* actionStyle = new QAction("样式");
QAction* actionSaveLayout = new QAction("保存布局");
QAction* actionLoadLayout = new QAction("使用布局");
QMenu* StyleMenu = new QMenu();
QAction* actionStyle1 = new QAction("样式1");
QAction* actionStyle2 = new QAction("样式2");
QAction* actionStyle3 = new QAction("样式3");
QAction* actionStyle4 = new QAction("样式4");
QAction* actionStyle5 = new QAction("样式5");
QAction* actionStyle6 = new QAction("样式6");
QAction* actionStyle7 = new QAction("样式7");
StyleMenu->addAction(actionStyle1);
StyleMenu->addAction(actionStyle2);
StyleMenu->addAction(actionStyle3);
StyleMenu->addAction(actionStyle4);
StyleMenu->addAction(actionStyle5);
StyleMenu->addAction(actionStyle6);
StyleMenu->addAction(actionStyle7);
actionStyle->setMenu(StyleMenu);
_menu->addAction(actionStyle);
_menu->addAction(actionSaveLayout);
_menu->addAction(actionLoadLayout);
this->connect(actionStyle1,&QAction::triggered,this,[=](){
DockWidgetList::Get()->HideAll();
this->addDockWidget(Qt::LeftDockWidgetArea,DockWidgetList::Get()->GetDockWidgetIndex(0));
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(0),DockWidgetList::Get()->GetDockWidgetIndex(1),Qt::Horizontal);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(1),DockWidgetList::Get()->GetDockWidgetIndex(2),Qt::Horizontal);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(0),DockWidgetList::Get()->GetDockWidgetIndex(3),Qt::Vertical);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(1),DockWidgetList::Get()->GetDockWidgetIndex(4),Qt::Vertical);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(2),DockWidgetList::Get()->GetDockWidgetIndex(5),Qt::Vertical);
});
this->connect(actionStyle2,&QAction::triggered,this,[=](){
DockWidgetList::Get()->HideAll();
this->addDockWidget(Qt::LeftDockWidgetArea,DockWidgetList::Get()->GetDockWidgetIndex(1));
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(1),DockWidgetList::Get()->GetDockWidgetIndex(5),Qt::Horizontal);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(5),DockWidgetList::Get()->GetDockWidgetIndex(6),Qt::Horizontal);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(1),DockWidgetList::Get()->GetDockWidgetIndex(7),Qt::Vertical);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(5),DockWidgetList::Get()->GetDockWidgetIndex(4),Qt::Vertical);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(6),DockWidgetList::Get()->GetDockWidgetIndex(8),Qt::Vertical);
});
this->connect(actionStyle3,&QAction::triggered,this,[=](){
DockWidgetList::Get()->HideAll();
this->addDockWidget(Qt::LeftDockWidgetArea,DockWidgetList::Get()->GetDockWidgetIndex(0));
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(0),DockWidgetList::Get()->GetDockWidgetIndex(2),Qt::Horizontal);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(2),DockWidgetList::Get()->GetDockWidgetIndex(5),Qt::Horizontal);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(0),DockWidgetList::Get()->GetDockWidgetIndex(3),Qt::Vertical);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(2),DockWidgetList::Get()->GetDockWidgetIndex(6),Qt::Vertical);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(5),DockWidgetList::Get()->GetDockWidgetIndex(7),Qt::Vertical);
});
this->connect(actionStyle4,&QAction::triggered,this,[=](){
DockWidgetList::Get()->HideAll();
this->addDockWidget(Qt::LeftDockWidgetArea,DockWidgetList::Get()->GetDockWidgetIndex(0));
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(0),DockWidgetList::Get()->GetDockWidgetIndex(2),Qt::Horizontal);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(2),DockWidgetList::Get()->GetDockWidgetIndex(4),Qt::Horizontal);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(0),DockWidgetList::Get()->GetDockWidgetIndex(3),Qt::Vertical);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(2),DockWidgetList::Get()->GetDockWidgetIndex(5),Qt::Vertical);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(4),DockWidgetList::Get()->GetDockWidgetIndex(7),Qt::Vertical);
});
this->connect(actionStyle5,&QAction::triggered,this,[=](){
DockWidgetList::Get()->HideAll();
this->addDockWidget(Qt::LeftDockWidgetArea,DockWidgetList::Get()->GetDockWidgetIndex(0));
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(0),DockWidgetList::Get()->GetDockWidgetIndex(2),Qt::Horizontal);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(2),DockWidgetList::Get()->GetDockWidgetIndex(3),Qt::Horizontal);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(0),DockWidgetList::Get()->GetDockWidgetIndex(4),Qt::Vertical);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(2),DockWidgetList::Get()->GetDockWidgetIndex(5),Qt::Vertical);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(3),DockWidgetList::Get()->GetDockWidgetIndex(6),Qt::Vertical);
});
this->connect(actionStyle6,&QAction::triggered,this,[=](){
DockWidgetList::Get()->HideAll();
this->addDockWidget(Qt::LeftDockWidgetArea,DockWidgetList::Get()->GetDockWidgetIndex(0));
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(0),DockWidgetList::Get()->GetDockWidgetIndex(1),Qt::Horizontal);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(1),DockWidgetList::Get()->GetDockWidgetIndex(2),Qt::Horizontal);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(0),DockWidgetList::Get()->GetDockWidgetIndex(3),Qt::Vertical);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(1),DockWidgetList::Get()->GetDockWidgetIndex(4),Qt::Vertical);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(2),DockWidgetList::Get()->GetDockWidgetIndex(5),Qt::Vertical);
});
this->connect(actionStyle7,&QAction::triggered,this,[=](){
DockWidgetList::Get()->HideAll();
this->addDockWidget(Qt::LeftDockWidgetArea,DockWidgetList::Get()->GetDockWidgetIndex(0));
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(0),DockWidgetList::Get()->GetDockWidgetIndex(3),Qt::Horizontal);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(3),DockWidgetList::Get()->GetDockWidgetIndex(4),Qt::Horizontal);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(0),DockWidgetList::Get()->GetDockWidgetIndex(5),Qt::Vertical);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(3),DockWidgetList::Get()->GetDockWidgetIndex(6),Qt::Vertical);
this->splitDockWidget(DockWidgetList::Get()->GetDockWidgetIndex(4),DockWidgetList::Get()->GetDockWidgetIndex(7),Qt::Vertical);
});
this->connect(actionSaveLayout,&QAction::triggered,this,[=](){
SaveLayout();
});
this->connect(actionLoadLayout,&QAction::triggered,this,[=](){
LoadLayout();
});
}
void MainWindow::SaveLayout()
{
const QString fileName = QDir::currentPath() + "/Layout.txt";
qDebug() << fileName;
if (fileName.isEmpty())
return;
QFile file(fileName);
if (!file.open(QFile::WriteOnly)) {
QString msg = tr("Failed to open %1\n%2")
.arg(fileName)
.arg(file.errorString());
QMessageBox::warning(nullptr, tr("Error"), msg);
return;
}
QByteArray geo_data = saveGeometry();
QByteArray layout_data = saveState();
bool ok = file.putChar((uchar)geo_data.size());
if (ok)
ok = file.write(geo_data) == geo_data.size();
if (ok)
ok = file.write(layout_data) == layout_data.size();
if (!ok) {
QString msg = tr("Error writing to %1\n%2")
.arg(fileName)
.arg(file.errorString());
QMessageBox::warning(this, tr("Error"), msg);
return;
}
}
void MainWindow::LoadLayout()
{
// QString fileName
// = QFileDialog::getOpenFileName(this, tr("Load layout"));
const QString fileName = QDir::currentPath() + "/Layout.txt";
if (fileName.isEmpty())
return;
QFile file(fileName);
if (!file.open(QFile::ReadOnly)) {
QString msg = tr("Failed to open %1\n%2")
.arg(fileName)
.arg(file.errorString());
QMessageBox::warning(this, tr("Error"), msg);
return;
}
uchar geo_size;
QByteArray geo_data;
QByteArray layout_data;
bool ok = file.getChar((char*)&geo_size);
if (ok) {
geo_data = file.read(geo_size);
ok = geo_data.size() == geo_size;
}
if (ok) {
layout_data = file.readAll();
ok = layout_data.size() > 0;
}
if (ok)
ok = restoreGeometry(geo_data);
if (ok)
ok = restoreState(layout_data);
if (!ok) {
QString msg = tr("Error reading %1")
.arg(fileName);
QMessageBox::warning(this, tr("Error"), msg);
return;
}
}

28
Src/Gui/MainWindow.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
class QMenu;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
void contextMenuEvent(QContextMenuEvent *event);
void InitWidget();
void InitMenu();
private:
void SaveLayout();
void LoadLayout();
private:
QMenu* _menu;
};
#endif // MAINWINDOW_H

1048
Src/Gui/ModuleWidget.cpp Normal file

File diff suppressed because it is too large Load Diff

51
Src/Gui/ModuleWidget.h Normal file
View File

@ -0,0 +1,51 @@
#ifndef _MODULE_WIDGET_H_
#define _MODULE_WIDGET_H_
#include <QWidget>
#include "BaseWidget.h"
enum SmallWindowModel
{
PRODUCTIONSUM, //产量汇总
PLANFORTHEMONTH, //当月计划
DEVICEMONITORING, //设备监控
MOLDPROGRESS, //模具进度
LOADDISTRIBUTION, //负荷分布
PASSEDTHEINSPECTION, //送检合格
QUALITYMANAGEMENT, //品质管理
MATERIALMANAGEMENT, //物料管理
VIDEOSURVEILLANCE, //视频监控
LARGESCREENMAP, //大屏地图
SYSTEMSETUP, //系统设置
LoadDistribution
};
class ModuleWidget : public BaseWidget
{
Q_OBJECT
public:
ModuleWidget(SmallWindowModel,QWidget* parent = nullptr);
~ModuleWidget();
private:
QWidget* Init(SmallWindowModel);
QWidget* InitWidget1();
QWidget* InitWidget2();
QWidget* InitWidget3();
QWidget* InitWidget4();
QWidget* InitWidget5();
QWidget* InitWidget6();
QWidget* InitWidget7();
QWidget* InitWidget8();
QWidget* InitWidget9();
QLabel* GetLabel(QString name);
QWidget* Device_InitRightWidget(QStringList nameList, QStringList valueList);
QWidget* Device_InitBodyWidget(QStringList colorList,QStringList nameList, QStringList nameList1, QList<bool> boolList);
QWidget* Device_InitBottomWidget(QStringList list);
QWidget* GetColorWidget(QString color, QString text, QString text1, bool isActivation);
};
#endif //_MODULE_WIDGET_H_

104
Src/Gui/OpenCVGLWidget.cpp Normal file
View File

@ -0,0 +1,104 @@
#include "OpenCVGLWidget.h"
#include <QPainter>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <QResizeEvent>
#include <QDebug>
#include <QShowEvent>
OpenCVGLWidget::OpenCVGLWidget(QWidget *parent)
:QOpenGLWidget (parent)
{
}
OpenCVGLWidget::~OpenCVGLWidget()
{
}
void OpenCVGLWidget::ShowImg(cv::Mat mat)
{
if(this->width() == 0 || this->height() == 0)
return;
cv::resize(mat,mat,cv::Size(this->width(),this->height()));
img = MatToQImage(mat);
update();
}
QImage OpenCVGLWidget::MatToQImage(const cv::Mat& mat)
{
switch (mat.type())
{
// 8-bit, 4 channel
case CV_8UC4:
{
QImage image(mat.data,
mat.cols, mat.rows,
static_cast<int>(mat.step),
QImage::Format_ARGB32);
return image;
}
// 8-bit, 3 channel
case CV_8UC3:
{
QImage image(mat.data,
mat.cols, mat.rows,
static_cast<int>(mat.step),
QImage::Format_RGB888);
return image.rgbSwapped();
}
// 8-bit, 1 channel
case CV_8UC1:
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
QImage image(mat.data,
mat.cols, mat.rows,
static_cast<int>(mat.step),
QImage::Format_Grayscale8);
#else
static QVector<QRgb> sColorTable;
// only create our color table the first time
if (sColorTable.isEmpty())
{
sColorTable.resize( 256 );
for ( int i = 0; i < 256; ++i )
{
sColorTable[i] = qRgb( i, i, i );
}
}
QImage image(mat.data,
mat.cols, mat.rows,
static_cast<int>(mat.step),
QImage::Format_Indexed8 );
image.setColorTable(sColorTable);
#endif
return image;
}
// wrong
default:
break;
}
return QImage();
}
void OpenCVGLWidget::paintEvent(QPaintEvent *e)
{
QPainter p;
p.begin(this);
p.drawImage(QPointF(0, 0), img);
p.end();
}

31
Src/Gui/OpenCVGLWidget.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef _OPENCV_PV_GLWIDGET_H_
#define _OPENCV_PV_GLWIDGET_H_
#include <QOpenGLWidget>
#include <opencv2/imgproc.hpp>
class OpenCVGLWidget : public QOpenGLWidget
{
Q_OBJECT
public:
OpenCVGLWidget(QWidget* parent = nullptr);
~OpenCVGLWidget();
public slots:
//把图片传入 通过paintEvent显示
void ShowImg(cv::Mat);
QImage MatToQImage(const cv::Mat& mat);
protected:
void paintEvent(QPaintEvent *e);
// void resizeEvent(QResizeEvent *e);
// void showEvent(QShowEvent *event);
private:
QImage img;
int SubHeight = 0;
int SubWidth = 0;
int Height = 0;
int Width = 0;
};
#endif //_OPENCV_PV_GLWIDGET_H_

1187
Src/Gui/SmallWindow.cpp Normal file

File diff suppressed because it is too large Load Diff

24
Src/Gui/SmallWindow.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef _SMALL_WINDOW_H_
#define _SMALL_WINDOW_H_
#include "BaseWidget.h"
class SmallWindow : public BaseWidget
{
Q_OBJECT
public:
SmallWindow(QWidget* parent = nullptr);
~SmallWindow();
private:
QWidget* Init();
QWidget* InitWindowModel(int index);
protected:
QPushButton* GetLeftButton(QString);
QLabel* GetLabel(QString name);
};
#endif //_SMALL_WINDOW_H_

351
Src/Gui/TypeWindow.cpp Normal file
View File

@ -0,0 +1,351 @@
#include "QVBoxLayout"
#include "QPushButton"
#include "QStackedWidget"
#include "TypeWindow.h"
#include "../Pub/PubCss.h"
#include "../Chart/ChartLine.h"
#include "../Chart/ChartCurve.h"
#include "../Chart/ChartBar.h"
TypeWindow::TypeWindow(QWidget *parent)
:BaseWidget(parent)
{
this->Init();
this->setObjectName("TypeWindow");
this->setStyleSheet("#TypeWindow{background-color:rgb(5,30,83);}");
}
TypeWindow::~TypeWindow()
{
}
QPushButton* TypeWindow::GetLeftButton(QString name)
{
const QString css = PubCss::Get()->GetStr(SMALLWINDOW_LEFTBUTTONSTYLE);
QPushButton* btn = InitButton(name,0,30,css);
return btn;
}
void TypeWindow::Init()
{
this->setFixedSize(980,610);
QHBoxLayout* mLayout = InitHLayout();
QWidget* leftWidget = new QWidget();
leftWidget->setObjectName("leftWidget");
leftWidget->setStyleSheet("#leftWidget{background-color:rgb(4,46,106);}");
leftWidget->setFixedWidth(110);
QVBoxLayout* leftLayout = InitVLayout(5);
QPushButton* btn1 = GetLeftButton("标准折线");
QPushButton* btn2 = GetLeftButton("标准曲线");
QPushButton* btn3 = GetLeftButton("标准柱状");
QPushButton* btn4 = GetLeftButton("柱状堆积");
QPushButton* btn5 = GetLeftButton("柱状分组");
QPushButton* btn6 = GetLeftButton("横状柱状");
QPushButton* btn7 = GetLeftButton("横装堆积");
QPushButton* btn8 = GetLeftButton("横装分组");
QPushButton* btn9 = GetLeftButton("数据转换");
QPushButton* btn10 = GetLeftButton("平滑曲线");
QPushButton* btn11 = GetLeftButton("系统设置");
leftLayout->addWidget(btn1);
leftLayout->addWidget(btn2);
leftLayout->addWidget(btn3);
leftLayout->addWidget(btn4);
leftLayout->addWidget(btn5);
leftLayout->addWidget(btn6);
leftLayout->addWidget(btn7);
leftLayout->addWidget(btn8);
leftLayout->addWidget(btn9);
leftLayout->addWidget(btn10);
leftLayout->addWidget(btn11);
leftLayout->addStretch();
leftWidget->setLayout(leftLayout);
QWidget* rightWidget = new QWidget();
QHBoxLayout* rightLayout = InitHLayout();
QStackedWidget* mSWidget = new QStackedWidget();
QWidget* ChartLine = InitWidget(CHARTLINE);
QWidget* ChartCurve = InitWidget(CHARTCURVE);
QWidget* ChartBar1 = InitWidget(CHARTBAR);
QWidget* ChartBar2 = InitWidget(CHARTBAR1);
QWidget* ChartBar3 = InitWidget(CHARTBAR2);
QWidget* ChartBar4 = InitWidget(CHARTBAR3);
QWidget* ChartBar5 = InitWidget(CHARTBAR4);
QWidget* ChartBar6 = InitWidget(CHARTBAR5);
mSWidget->addWidget(ChartLine);
mSWidget->addWidget(ChartCurve);
mSWidget->addWidget(ChartBar1);
mSWidget->addWidget(ChartBar2);
mSWidget->addWidget(ChartBar3);
mSWidget->addWidget(ChartBar4);
mSWidget->addWidget(ChartBar5);
mSWidget->addWidget(ChartBar6);
this->connect(btn1,&QPushButton::clicked,this,[=](){
mSWidget->setCurrentIndex(0);
});
this->connect(btn2,&QPushButton::clicked,this,[=](){
mSWidget->setCurrentIndex(1);
});
this->connect(btn3,&QPushButton::clicked,this,[=](){
mSWidget->setCurrentIndex(2);
});
this->connect(btn4,&QPushButton::clicked,this,[=](){
mSWidget->setCurrentIndex(3);
});
this->connect(btn5,&QPushButton::clicked,this,[=](){
mSWidget->setCurrentIndex(4);
});
this->connect(btn6,&QPushButton::clicked,this,[=](){
mSWidget->setCurrentIndex(5);
});
this->connect(btn7,&QPushButton::clicked,this,[=](){
mSWidget->setCurrentIndex(6);
});
this->connect(btn8,&QPushButton::clicked,this,[=](){
mSWidget->setCurrentIndex(7);
});
rightLayout->addWidget(mSWidget);
rightWidget->setLayout(rightLayout);
mLayout->addWidget(leftWidget);
mLayout->addWidget(rightWidget);
this->setLayout(mLayout);
}
QWidget *TypeWindow::InitWidget(TypeWindowModel index)
{
QWidget* Widget = nullptr;
switch (index)
{
case CHARTLINE:
{
QWidget* mWidget = new QWidget();
QHBoxLayout* mLayout = InitHLayout();
ChartLine* line = new ChartLine();
ChartPar cPar = line->GetPar(CCHARTLINE);
AxisPar aPar = line->GetPar(ACHARTLINE);
QList<LinePar> lPar = line->GetLPar(LCHARTLINEVALUE);
line->Set(cPar);
line->Set(aPar);
line->Init(lPar);
mLayout->addWidget(line);
mWidget->setLayout(mLayout);
Widget = mWidget;
break;
}
case CHARTCURVE:
{
QWidget* mWidget = new QWidget();
QVBoxLayout* mLayout = InitVLayout(7);
ChartCurve* curve1 = new ChartCurve();
ChartPar cPar1 = curve1->GetPar(CCHARTCURVE1);
AxisPar aPar1 = curve1->GetPar(ACHARTCURVE1);
QList<CurvePar> cuPar1 = curve1->GetCuPar(CUCHARTCURVE1);
curve1->Set(cPar1);
curve1->Set(aPar1);
curve1->Init(cuPar1);
ChartCurve* curve2 = new ChartCurve();
ChartPar cPar2 = curve2->GetPar(CCHARTCURVE2);
AxisPar aPar2 = curve2->GetPar(ACHARTCURVE2);
QList<CurvePar> cuPar2 = curve2->GetCuPar(CUCHARTCURVE2);
curve2->Set(cPar2);
curve2->Set(aPar2);
curve2->Init(cuPar2);
ChartCurve* curve3 = new ChartCurve();
ChartPar cPar3 = curve3->GetPar(CCHARTCURVE3);
AxisPar aPar3 = curve3->GetPar(ACHARTCURVE3);
QList<CurvePar> cuPar3 = curve3->GetCuPar(CUCHARTCURVE3);
curve3->SetPointShow(true);
curve3->Set(cPar3);
curve3->Set(aPar3);
curve3->Init(cuPar3);
mLayout->addWidget(curve1);
mLayout->addWidget(curve2);
mLayout->addWidget(curve3);
mWidget->setLayout(mLayout);
Widget = mWidget;
break;
}
case CHARTBAR:
{
QWidget* mWidget = new QWidget();
QVBoxLayout* mLayout = new QVBoxLayout();
ChartBar* bar1 = new ChartBar(1);
ChartPar cPar1 = bar1->GetPar(CCHARTBAR1);
AxisPar aPar1 = bar1->GetPar(ACHARTBAR1);
QList<BarPer> bPar1 = bar1->GetBPar(BCHARTBAR1VALUE1);
bar1->Set(cPar1);
bar1->Set(aPar1);
bar1->Init(bPar1);
ChartBar* bar2 = new ChartBar(1);
ChartPar cPar2 = bar2->GetPar(CCHARTBAR1);
AxisPar aPar2 = bar2->GetPar(ACHARTBAR1);
QList<BarPer> bPar2 = bar2->GetBPar(BCHARTBAR1VALUE1);
bar2->Set(cPar2);
bar2->Set(aPar2);
bar2->Init(bPar2);
mLayout->addWidget(bar1);
mLayout->addWidget(bar2);
mWidget->setLayout(mLayout);
Widget = mWidget;
break;
}
case CHARTBAR1:
{
QWidget* mWidget = new QWidget();
QVBoxLayout* mLayout = InitVLayout();
ChartBar* bar3 = new ChartBar(2);
ChartPar cPar3 = bar3->GetPar(CCHARTBAR3);
AxisPar aPar3 = bar3->GetPar(ACHARTBAR3);
QList<BarPer> bPar3 = bar3->GetBPar(BCHARTBAR2VALUE1);
bar3->Set(cPar3);
bar3->Set(aPar3);
bar3->Init(bPar3);
ChartBar* bar4 = new ChartBar(2);
ChartPar cPar4 = bar4->GetPar(CCHARTBAR4);
AxisPar aPar4 = bar4->GetPar(ACHARTBAR4);
QList<BarPer> bPar4 = bar4->GetBPar(BCHARTBAR2VALUE2);
bar4->Set(cPar4);
bar4->Set(aPar4);
bar4->Init(bPar4);
mLayout->addWidget(bar3);
mLayout->addWidget(bar4);
mWidget->setLayout(mLayout);
Widget = mWidget;
break;
}
case CHARTBAR2:
{
QWidget* mWidget = new QWidget();
QVBoxLayout* mLayout = InitVLayout();
ChartBar* bar5 = new ChartBar(3);
ChartPar cPar5 = bar5->GetPar(CCHARTBAR5);
AxisPar aPar5 = bar5->GetPar(ACHARTBAR5);
QList<BarPer> bPar5 = bar5->GetBPar(BCHARTBAR3VALUE1);
bar5->Set(cPar5);
bar5->Set(aPar5);
bar5->Init(bPar5);
ChartBar* bar6 = new ChartBar(3);
ChartPar cPar6 = bar6->GetPar(CCHARTBAR6);
AxisPar aPar6 = bar6->GetPar(ACHARTBAR6);
QList<BarPer> bPar6 = bar6->GetBPar(BCHARTBAR3VALUE2);
bar6->Set(cPar6);
bar6->Set(aPar6);
bar6->Init(bPar6);
mLayout->addWidget(bar5);
mLayout->addWidget(bar6);
mWidget->setLayout(mLayout);
Widget = mWidget;
break;
}
case CHARTBAR3:
{
QWidget* mWidget = new QWidget();
QVBoxLayout* mLayout = InitVLayout();
ChartBar* bar7 = new ChartBar(4);
ChartPar cPar7 = bar7->GetPar(CCHARTBAR7);
AxisPar aPar7 = bar7->GetPar(ACHARTBAR7);
QList<BarPer> bPar7 = bar7->GetBPar(BCAHRTBAR4VALUE1);
bar7->Set(cPar7);
bar7->Set(aPar7);
bar7->Init(bPar7);
mLayout->addWidget(bar7);
mWidget->setLayout(mLayout);
Widget = mWidget;
break;
}
case CHARTBAR4:
{
QWidget* mWidget = new QWidget();
QVBoxLayout* mLayout = InitVLayout();
ChartBar* bar8 = new ChartBar(5);
ChartPar cPar8 = bar8->GetPar(CCHARTBAR8);
AxisPar aPar8 = bar8->GetPar(ACHARTBAR8);
QList<BarPer> bPar8 = bar8->GetBPar(BCAHRTBAR5VALUE1);
bar8->Set(cPar8);
bar8->Set(aPar8);
bar8->Init(bPar8);
ChartBar* bar9 = new ChartBar(5);
ChartPar cPar9 = bar9->GetPar(CCHARTBAR9);
AxisPar aPar9 = bar9->GetPar(ACHARTBAR9);
QList<BarPer> bPar9 = bar9->GetBPar(BCAHRTBAR5VALUE2);
bar9->Set(cPar9);
bar9->Set(aPar9);
bar9->Init(bPar9);
mLayout->addWidget(bar8);
mLayout->addWidget(bar9);
mWidget->setLayout(mLayout);
Widget = mWidget;
break;
}
case CHARTBAR5:
{
QWidget* mWidget = new QWidget();
QVBoxLayout* mLayout = InitVLayout();
ChartBar* bar10 = new ChartBar(6);
ChartPar cPar10 = bar10->GetPar(CCHARTBAR10);
AxisPar aPar10 = bar10->GetPar(ACHARTBAR10);
QList<BarPer> bPar10 = bar10->GetBPar(BCAHRTBAR6VALUE1);
bar10->Set(aPar10);
bar10->Set(cPar10);
bar10->Init(bPar10);
mLayout->addWidget(bar10);
mWidget->setLayout(mLayout);
Widget = mWidget;
break;
}
}
return Widget;
}

33
Src/Gui/TypeWindow.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef _TYPE_WINDOW_H_
#define _TYPE_WINDOW_H_
#include <QWidget>
#include "BaseWidget.h"
enum TypeWindowModel
{
CHARTLINE,
CHARTCURVE,
CHARTBAR,
CHARTBAR1,
CHARTBAR2,
CHARTBAR3,
CHARTBAR4,
CHARTBAR5
};
class TypeWindow : public BaseWidget
{
Q_OBJECT
public:
TypeWindow(QWidget* parent = nullptr);
~TypeWindow();
QPushButton* GetLeftButton(QString name);
private:
void Init();
QWidget* InitWidget(TypeWindowModel);
};
#endif //_TYPE_WINDOW_H_

View File

@ -0,0 +1,275 @@
#include "LoadDistributionModelDelegate.h"
#include <QPainter>
#include <QDebug>
LoadDistributionProModelItem::LoadDistributionProModelItem()
{
}
LoadDistributionProModelItem::~LoadDistributionProModelItem()
{
}
LoadDistributionTableModel::LoadDistributionTableModel(QObject* parent)
:QAbstractTableModel (parent)
{
}
LoadDistributionTableModel::~LoadDistributionTableModel()
{
}
#if 0
Qt::ItemFlags LoadDistributionTableModel::flags(const QModelIndex &index) const
{
if(index.column() != 0)
return Qt::ItemIsEditable | Qt::ItemIsSelectable | QAbstractTableModel::flags(index);
return QAbstractTableModel::flags(index);
}
#endif
int LoadDistributionTableModel::rowCount(const QModelIndex &parent) const
{
if(parent.isValid())
return 0;
return Ary_row_List.size();
}
int LoadDistributionTableModel::columnCount(const QModelIndex &parent) const
{
if(parent.isValid())
return 0;
return 8;
}
QVariant LoadDistributionTableModel::data(const QModelIndex &index, int role) const
{
if(Ary_row_List.size() < 1 || !index.isValid())
return QVariant();
if (role == Qt::TextAlignmentRole)
{
return int (Qt::AlignHCenter | Qt::AlignVCenter);
}
if(role == Qt::DisplayRole || role == Qt::EditRole)
{
if(index.column() == 0)
{
return Ary_row_List.at(index.row()).GetNumNo();
}
else if(index.column() == 1)
{
return Ary_row_List.at(index.row()).GetTime1();
}
else if(index.column() == 2)
{
return Ary_row_List.at(index.row()).GetTime2();
}
else if(index.column() == 3)
{
return Ary_row_List.at(index.row()).GetTime3();
}
else if(index.column() == 4)
{
return Ary_row_List.at(index.row()).GetTime4();
}
else if(index.column() == 5)
{
return Ary_row_List.at(index.row()).GetTime5();
}
else if(index.column() == 6)
{
return Ary_row_List.at(index.row()).GetTime6();
}
else if(index.column() == 7)
{
return Ary_row_List.at(index.row()).GetTime7();
}
}
return QVariant();
}
QVariant LoadDistributionTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(role == Qt::DisplayRole || role == Qt::EditRole)
{
if(orientation == Qt::Horizontal)
{
if(horizontal_header_list.size() > section)
return horizontal_header_list[section];
else
return QVariant();
}
if(orientation == Qt::Vertical)
{
if(vertical_header_list.size() > section)
return vertical_header_list[section];
else
return QVariant();
}
}
return QAbstractTableModel::headerData(section, orientation, role);
}
void LoadDistributionTableModel::setHorizontalHeaderList(QStringList hHeadList)
{
horizontal_header_list = hHeadList;
}
void LoadDistributionTableModel::setVerticalHeaderList(QStringList VHeadList)
{
vertical_header_list = VHeadList;
}
void LoadDistributionTableModel::RefrushModel(LoadDistributionProModelItem item)
{
const int count = Ary_row_List.size();
beginInsertRows(QModelIndex(), count, count);
Ary_row_List.push_back(item);
endInsertRows();
}
bool LoadDistributionTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
Q_UNUSED(value);
if(Ary_row_List.size() < 1 || !index.isValid())
return false;
if (role == Qt::TextAlignmentRole)
{
return int (Qt::AlignHCenter | Qt::AlignVCenter);
}
if(role == Qt::DisplayRole || role == Qt::EditRole)
{
#if 0
if(index.column() == 0)
{
Ary_row_List->at(index.row())->Set_Name(value.toString());
}
if(index.column() == 1)
{
Ary_row_List->at(index.row())->Set_FirstVal(value.toString());
}
else if(index.column() == 2)
{
Ary_row_List->at(index.row())->Set_SecondVal(value.toString());
}
else if(index.column() == 3)
{
Ary_row_List->at(index.row())->Set_ThirdVal(value.toString());
}
else if(index.column() == 4)
{
Ary_row_List->at(index.row())->Set_FourVal(value.toString());
}
emit ModityData(index.row(),index.column(),value);
#endif
return true;
}
return false;
}
void LoadDistributionTableModel::PushBackData(QList<QStringList> list)
{
if(list.size() <= 0)
{
return;
}
if(list.at(0).size() < 7)
{
return;
}
for(int i = 0; i < list.size(); i++)
{
LoadDistributionProModelItem Item;
const QString null = "";
Item.SetNumNo(list.at(i).at(0).isEmpty() ? null : list.at(i).at(0));
Item.SetTime1(list.at(i).at(1).isEmpty() ? null : list.at(i).at(1));
Item.SetTime2(list.at(i).at(2).isEmpty() ? null : list.at(i).at(2));
Item.SetTime3(list.at(i).at(3).isEmpty() ? null : list.at(i).at(3));
Item.SetTime4(list.at(i).at(4).isEmpty() ? null : list.at(i).at(4));
Item.SetTime5(list.at(i).at(5).isEmpty() ? null : list.at(i).at(5));
Item.SetTime6(list.at(i).at(6).isEmpty() ? null : list.at(i).at(6));
Item.SetTime7(list.at(i).at(7).isEmpty() ? null : list.at(i).at(7));
Ary_row_List.push_back(Item);
}
RefrushModelData();
}
//void LoadDistributionTableModel::PopBackData()
//{
// for(int i = 0; i < Ary_row_List.size(); i++)
// {
// Ary_row_List.removeAt(0);
// }
// Ary_row_List.clear();
// RefrushModelData();
//}
void LoadDistributionTableModel::RefrushModelData()
{
this->beginResetModel();
this->endResetModel();
}
LoadDistributionModelDelegate::LoadDistributionModelDelegate(QObject *parent)
:QItemDelegate (parent)
{
}
LoadDistributionModelDelegate::~LoadDistributionModelDelegate()
{
}
void LoadDistributionModelDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if(index.column() == 0 || index.column() == 1 || index.column() == 2 || index.column() == 3 || index.column() == 4
|| index.column() == 5 || index.column() == 6 || index.column() == 7)
{
painter->setPen(QPen(QColor(255,255,255)));
QString mos = index.model()->data(index,Qt::DisplayRole).toString();
QTextOption o;
o.setAlignment(Qt::AlignCenter);
painter->drawText(option.rect,mos,o);
}
#if 0
else if(index.column() == 1)
{
QString mos = index.model()->data(index,Qt::DisplayRole).toString();
QTextOption o;
o.setAlignment(Qt::AlignCenter);
painter->drawText(option.rect,mos,o);
}
else if(index.column() == 2)
{
QString mos = index.model()->data(index,Qt::DisplayRole).toString();
QTextOption o;
o.setAlignment(Qt::AlignCenter);
painter->drawText(option.rect,mos,o);
}
else if(index.column() == 3)
{
QString mos = index.model()->data(index,Qt::DisplayRole).toString();
QTextOption o;
o.setAlignment(Qt::AlignCenter);
painter->drawText(option.rect,mos,o);
}
else if(index.column() == 4)
{
QString mos = index.model()->data(index,Qt::DisplayRole).toString();
QTextOption o;
o.setAlignment(Qt::AlignCenter);
painter->drawText(option.rect,mos,o);
}
#endif
else
{
QItemDelegate::paint(painter,option,index);
}
}

View File

@ -0,0 +1,137 @@
#ifndef _LOAD_DISTRIBUTION_MODEL_DELEGATE_H_
#define _LOAD_DISTRIBUTION_MODEL_DELEGATE_H_
#include <QObject>
#include <QAbstractTableModel>
#include <QItemDelegate>
class LoadDistributionProModelItem
{
public:
LoadDistributionProModelItem();
~LoadDistributionProModelItem();
QString GetNumNo() const
{
return _numNo;
}
void SetNumNo(const QString numNo)
{
_numNo = numNo;
}
QString GetTime1() const
{
return _time1;
}
void SetTime1(const QString time)
{
_time1 = time;
}
QString GetTime2() const
{
return _time2;
}
void SetTime2(const QString time)
{
_time2 = time;
}
QString GetTime3() const
{
return _time3;
}
void SetTime3(const QString time)
{
_time3 = time;
}
QString GetTime4() const
{
return _time4;
}
void SetTime4(const QString time)
{
_time4 = time;
}
QString GetTime5() const
{
return _time1;
}
void SetTime5(const QString time)
{
_time1 = time;
}
QString GetTime6() const
{
return _time1;
}
void SetTime6(const QString time)
{
_time1 = time;
}
QString GetTime7() const
{
return _time1;
}
void SetTime7(const QString time)
{
_time1 = time;
}
private:
QString _numNo;
QString _time1;
QString _time2;
QString _time3;
QString _time4;
QString _time5;
QString _time6;
QString _time7;
};
class LoadDistributionTableModel: public QAbstractTableModel
{
Q_OBJECT
public:
LoadDistributionTableModel(QObject* parent = nullptr);
~LoadDistributionTableModel();
// Qt::ItemFlags flags(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole);
void RefrushModel(LoadDistributionProModelItem);
void setHorizontalHeaderList(QStringList hHeadList);
void setVerticalHeaderList(QStringList VHeadList);
void RefrushModelData();
void PushBackData(QList<QStringList>);
// void PopBackData();
signals:
void ModityData(int,int,QVariant);
private:
QStringList horizontal_header_list;
QStringList vertical_header_list;
QList<LoadDistributionProModelItem> Ary_row_List;
};
class LoadDistributionModelDelegate : public QItemDelegate
{
Q_OBJECT
public:
explicit LoadDistributionModelDelegate(QObject *parent = nullptr);
virtual ~LoadDistributionModelDelegate();
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private:
};
#endif //_LOAD_DISTRIBUTION_MODEL_DELEGATE_H_

View File

@ -0,0 +1,184 @@
#include <QHBoxLayout>
#include <QTableView>
#include <QHeaderView>
#include <QMouseEvent>
#include <QScrollBar>
#include <QDebug>
#include "LoadDistributionTableView.h"
#include "LoadDistributionModelDelegate.h"
LoadDistributionTableView::LoadDistributionTableView(QWidget* parent/* = nullptr*/)
:QTableView(parent)
{
this->setMouseTracking(true);
const QStringList horHeadList = (QStringList() << "工序" << "4月1号" << "4月2号" << "4月3号"<< "4月4号" << "4月5号" << "4月6号" << "4月7号");
LoadDistributionTableModel* tableModel = new LoadDistributionTableModel(this);
tableModel->setObjectName("Model");
LoadDistributionModelDelegate* tableDelegate = new LoadDistributionModelDelegate(this);
tableDelegate->setObjectName("Delegate");
this->setModel(tableModel);
this->setItemDelegate(tableDelegate);
tableModel->setHorizontalHeaderList(horHeadList);
this->setSelectionBehavior( QAbstractItemView::SelectRows);
//显示子网格
this->setShowGrid(true);
//取消进度条
this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
//设置默认高度
this->verticalHeader()->setDefaultSectionSize(23);
//设置表头高度
this->horizontalHeader()->setFixedHeight(25);
this->setColumnWidth(0,70);
this->setColumnWidth(1,100);
this->setColumnWidth(2,100);
this->setColumnWidth(3,100);
this->setColumnWidth(4,100);
this->setColumnWidth(5,100);
this->setColumnWidth(6,100);
this->setColumnWidth(7,100);
this->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
this->verticalHeader()->hide();
this->horizontalHeader()->setStyleSheet("QHeaderView::section "
"{"
"color:rgb(0,170,190);"
"background-color:rgb(48,48,88);"
"border-left:none;"
"border-bottom:1px solid rgb(40,40,40,150);"
"border-top:1px solid rgb(40,40,40,150);"
"border-right:1px solid rgb(40,40,40,150);}");
this->setStyleSheet("background-color:rgb(48,48,88);"
"border:none;");
// this->connect(this->verticalScrollBar(),&QScrollBar::valueChanged,this,[=](int value){
// if(value + 13 < _max)
// {
// if(value == this->verticalScrollBar()->maximum())
// {
// _row += 1;
// emit RefrushData(_row);
// }
// }
// });
//设置行列表头无法点击
this->setCornerButtonEnabled(false);
this->horizontalHeader()->setSectionsClickable(false);
}
LoadDistributionTableView::~LoadDistributionTableView()
{
}
void LoadDistributionTableView::Set_Model_Data(QList<QStringList> data)
{
LoadDistributionTableModel* tableModel = this->findChild<LoadDistributionTableModel*>("Model");
tableModel->PushBackData(data);
}
#if 0
QString LoadDistributionTableView::Get_ModelData(const int row, const int Col) const
{
LoadDistributionTableModel* tableModel = this->findChild<LoadDistributionTableModel*>("Model");
const QModelIndex index = tableModel->index(row,Col);
const QString value = this->model()->data(index).toString();
return value;
}
void LoadDistributionTableView::Pop_Model_Data()
{
this->verticalScrollBar()->setValue(0);
LoadDistributionTableModel* tableModel = this->findChild<LoadDistributionTableModel*>("Model");
tableModel->PopBackData();
_row = 0;
}
void LoadDistributionTableView::mousePressEvent(QMouseEvent *event)
{
MoldProModelDelegate* tableDelegate = this->findChild<MoldProModelDelegate*>("Delegate");
LoadDistributionTableModel* tableModel = this->findChild<LoadDistributionTableModel*>("Model");
int row = indexAt(event->pos()).row();
if(row >= 0)
{
tableDelegate->Set_ClickedRow(row);
}
else
{
tableDelegate->Set_ClickedRow(-1);
}
tableModel->RefrushModelData();
return QTableView::mousePressEvent(event);
}
#endif
#if 0
void ClickedRow(int Row);
void LoadDistributionTableView::ClickedRow(int Row)
{
const QModelIndex index = this->model()->index(Row,0);
this->clicked(index);
}
#if 0
void ChangePaint(QString,QString,QString);
bool Get_RowInfo(QStringList&);
bool LoadDistributionTableView::Get_RowInfo(QStringList& value)
{
DBDataModelDelegate* tableDelegate = this->findChild<DBDataModelDelegate*>("Delegate");
LoadDistributionTableModel* tableModel = this->findChild<LoadDistributionTableModel*>("Model");
const int ClickedRow = tableDelegate->Get_ClickedRow();
if(ClickedRow == -1)
{
return false;
}
#if 0
const QModelIndex nameIndex = tableModel->index(ClickedRow,7);
const QModelIndex codeIndex = tableModel->index(ClickedRow,9);
const QModelIndex TypeIndex = tableModel->index(ClickedRow,8);
//层位
const QModelIndex DiskIndex = tableModel->index(ClickedRow,2);
const QModelIndex WorkIndex = tableModel->index(ClickedRow,3);
const QModelIndex ResultIndex = tableModel->index(ClickedRow,10);
const QModelIndex ActionIndex = tableModel->index(ClickedRow,6);
const QModelIndex TimeIndex = tableModel->index(ClickedRow,14);
const QString nameValue = this->model()->data(nameIndex).toString();
const QString codeValue = this->model()->data(codeIndex).toString();
const QString typeValue = this->model()->data(TypeIndex).toString();
const QString diskValue = this->model()->data(DiskIndex).toString();
const QString workValue = this->model()->data(WorkIndex).toString();
const QString resultValue = this->model()->data(ResultIndex).toString();
const QString actionValue = this->model()->data(ActionIndex).toString();
const QString timeValue = this->model()->data(TimeIndex).toString();
#endif
const QString nameValue = Get_ModelData(ClickedRow,7);
const QString codeValue = Get_ModelData(ClickedRow,9);
const QString typeValue = Get_ModelData(ClickedRow,8);
const QString frameValue = Get_ModelData(ClickedRow,1);
const QString diskValue = Get_ModelData(ClickedRow,2);
const QString workValue = Get_ModelData(ClickedRow,3);
const QString resultValue = Get_ModelData(ClickedRow,10);
const QString actionValue = Get_ModelData(ClickedRow,6);
const QString timeValue = Get_ModelData(ClickedRow,14);
value << nameValue << codeValue << typeValue << frameValue << diskValue << workValue << resultValue << actionValue << timeValue;
return true;
}
#endif
#endif

View File

@ -0,0 +1,39 @@
#ifndef LOAD_DISTRIBUTION_TABLE_VIEW_H_
#define LOAD_DISTRIBUTION_TABLE_VIEW_H_
#include <QWidget>
#include <QTableView>
class QTableView;
class LoadDistributionTableView : public QTableView
{
Q_OBJECT
public:
//SettingFourValTableView(QStringList HorList,int TableMaxNum,int NameWidth,int TableWidth,int DefaultHeight,int TableHeight,QWidget* parent = nullptr);
LoadDistributionTableView(QWidget* parent = nullptr);
~LoadDistributionTableView();
void Set_Model_Data(QList<QStringList> data);
// void Pop_Model_Data();
// QString Get_ModelData(const int row,const int Col) const;
// void mousePressEvent(QMouseEvent *event);
int Get_Row() const
{
return _row;
}
void Set_Max(int max)
{
_max = max;
}
signals:
void TableModityData(int,int,QVariant);
void RefrushData(int Row);
private:
int _row = 0;
int _max = 0;
};
#endif //LOAD_DISTRIBUTION_TABLE_VIEW_H_

View File

@ -0,0 +1,312 @@
#include "MoldProModelDelegate.h"
#include <QPainter>
#include <QDebug>
MoldProModelItem::MoldProModelItem()
{
}
MoldProModelItem::~MoldProModelItem()
{
}
MoldProTableModel::MoldProTableModel(QObject* parent)
:QAbstractTableModel (parent)
{
}
MoldProTableModel::~MoldProTableModel()
{
}
#if 0
Qt::ItemFlags MoldProTableModel::flags(const QModelIndex &index) const
{
if(index.column() != 0)
return Qt::ItemIsEditable | Qt::ItemIsSelectable | QAbstractTableModel::flags(index);
return QAbstractTableModel::flags(index);
}
#endif
int MoldProTableModel::rowCount(const QModelIndex &parent) const
{
if(parent.isValid())
return 0;
return Ary_row_List.size();
}
int MoldProTableModel::columnCount(const QModelIndex &parent) const
{
if(parent.isValid())
return 0;
return 8;
}
QVariant MoldProTableModel::data(const QModelIndex &index, int role) const
{
if(Ary_row_List.size() < 1 || !index.isValid())
return QVariant();
if (role == Qt::TextAlignmentRole)
{
return int (Qt::AlignHCenter | Qt::AlignVCenter);
}
if(role == Qt::DisplayRole || role == Qt::EditRole)
{
if(index.column() == 0)
{
return Ary_row_List.at(index.row()).GetId();
}
else if(index.column() == 1)
{
return Ary_row_List.at(index.row()).GetNumNo();
}
else if(index.column() == 2)
{
return Ary_row_List.at(index.row()).GetVersion();
}
else if(index.column() == 3)
{
return Ary_row_List.at(index.row()).GetType();
}
else if(index.column() == 4)
{
return Ary_row_List.at(index.row()).GetState();
}
else if(index.column() == 5)
{
return Ary_row_List.at(index.row()).GetName();
}
else if(index.column() == 6)
{
return Ary_row_List.at(index.row()).GetTime();
}
else if(index.column() == 7)
{
return Ary_row_List.at(index.row()).GetList();
}
}
return QVariant();
}
QVariant MoldProTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(role == Qt::DisplayRole || role == Qt::EditRole)
{
if(orientation == Qt::Horizontal)
{
if(horizontal_header_list.size() > section)
return horizontal_header_list[section];
else
return QVariant();
}
if(orientation == Qt::Vertical)
{
if(vertical_header_list.size() > section)
return vertical_header_list[section];
else
return QVariant();
}
}
return QAbstractTableModel::headerData(section, orientation, role);
}
void MoldProTableModel::setHorizontalHeaderList(QStringList hHeadList)
{
horizontal_header_list = hHeadList;
}
void MoldProTableModel::setVerticalHeaderList(QStringList VHeadList)
{
vertical_header_list = VHeadList;
}
void MoldProTableModel::RefrushModel(MoldProModelItem item)
{
const int count = Ary_row_List.size();
beginInsertRows(QModelIndex(), count, count);
Ary_row_List.push_back(item);
endInsertRows();
}
bool MoldProTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
Q_UNUSED(value);
if(Ary_row_List.size() < 1 || !index.isValid())
return false;
if (role == Qt::TextAlignmentRole)
{
return int (Qt::AlignHCenter | Qt::AlignVCenter);
}
if(role == Qt::DisplayRole || role == Qt::EditRole)
{
#if 0
if(index.column() == 0)
{
Ary_row_List->at(index.row())->Set_Name(value.toString());
}
if(index.column() == 1)
{
Ary_row_List->at(index.row())->Set_FirstVal(value.toString());
}
else if(index.column() == 2)
{
Ary_row_List->at(index.row())->Set_SecondVal(value.toString());
}
else if(index.column() == 3)
{
Ary_row_List->at(index.row())->Set_ThirdVal(value.toString());
}
else if(index.column() == 4)
{
Ary_row_List->at(index.row())->Set_FourVal(value.toString());
}
emit ModityData(index.row(),index.column(),value);
#endif
return true;
}
return false;
}
void MoldProTableModel::PushBackData(QList<QStringList> list,QList<QVariantList> valueList)
{
if(list.size() <= 0 || valueList.size() <= 0)
{
return;
}
if(list.at(0).size() < 7)
{
return;
}
if(list.size() != valueList.size())
{
return;
}
for(int i = 0; i < list.size(); i++)
{
MoldProModelItem Item;
const QString null = "";
Item.SetId(list.at(i).at(0).isEmpty() ? null : list.at(i).at(0));
Item.SetNumNo(list.at(i).at(1).isEmpty() ? null : list.at(i).at(1));
Item.SetVersion(list.at(i).at(2).isEmpty() ? null : list.at(i).at(2));
Item.SetType(list.at(i).at(3).isEmpty() ? null : list.at(i).at(3));
Item.SetState(list.at(i).at(4).isEmpty() ? null : list.at(i).at(4));
Item.SetName(list.at(i).at(5).isEmpty() ? null : list.at(i).at(5));
Item.SetTime(list.at(i).at(6).isEmpty() ? null : list.at(i).at(6));
Item.SetList(valueList.at(i));
Ary_row_List.push_back(Item);
}
RefrushModelData();
}
//void MoldProTableModel::PopBackData()
//{
// for(int i = 0; i < Ary_row_List.size(); i++)
// {
// Ary_row_List.removeAt(0);
// }
// Ary_row_List.clear();
// RefrushModelData();
//}
void MoldProTableModel::RefrushModelData()
{
this->beginResetModel();
this->endResetModel();
}
MoldProModelDelegate::MoldProModelDelegate(QObject *parent)
:QItemDelegate (parent)
{
}
MoldProModelDelegate::~MoldProModelDelegate()
{
}
void MoldProModelDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if(index.column() == 0 || index.column() == 1 || index.column() == 2 || index.column() == 3 || index.column() == 4
|| index.column() == 5 || index.column() == 6)
{
// painter->setPen(QPen(QColor(0,0,0)));
// if(index.row() == ClickedRow)
// {
// painter->setBrush(QColor(0,0,50));
// painter->setPen(QPen(QColor(255,255,255)));
// painter->drawRect(option.rect);
// }
painter->setPen(QPen(QColor(255,255,255)));
QString mos = index.model()->data(index,Qt::DisplayRole).toString();
QTextOption o;
o.setAlignment(Qt::AlignCenter);
painter->drawText(option.rect,mos,o);
}
else if(index.column() == 7)
{
QVariantList list = index.model()->data(index,Qt::DisplayRole).toList();
int total = 0;
for(auto& i : list)
{
total += i.toInt();
}
float pro = (float)option.rect.width() / float(total);
QList<float> proList;
for(int i = 0; i < list.size(); i++)
{
const float Pro = list.at(i).toFloat() * pro;
proList.push_back(Pro);
}
QList<QColor> colorList = QList<QColor>() << QColor(0,176,180) << QColor(255,192,0) << QColor(214,77,84);
float proX = 0.0f;
for(int i = 0; i <proList.size(); i++)
{
painter->setPen(QPen(colorList.at(i)));
painter->setBrush(QBrush(colorList.at(i)));
const int height = 10;
int y = option.rect.y() + (option.rect.height() / 2) - (height / 2);
painter->drawRect(option.rect.x() + proX,y,proList.at(i),height);
proX += proList.at(i);
}
}
#if 0
else if(index.column() == 1)
{
QString mos = index.model()->data(index,Qt::DisplayRole).toString();
QTextOption o;
o.setAlignment(Qt::AlignCenter);
painter->drawText(option.rect,mos,o);
}
else if(index.column() == 2)
{
QString mos = index.model()->data(index,Qt::DisplayRole).toString();
QTextOption o;
o.setAlignment(Qt::AlignCenter);
painter->drawText(option.rect,mos,o);
}
else if(index.column() == 3)
{
QString mos = index.model()->data(index,Qt::DisplayRole).toString();
QTextOption o;
o.setAlignment(Qt::AlignCenter);
painter->drawText(option.rect,mos,o);
}
else if(index.column() == 4)
{
QString mos = index.model()->data(index,Qt::DisplayRole).toString();
QTextOption o;
o.setAlignment(Qt::AlignCenter);
painter->drawText(option.rect,mos,o);
}
#endif
else
{
QItemDelegate::paint(painter,option,index);
}
}

View File

@ -0,0 +1,137 @@
#ifndef MOLD_PRO_MODEL_DELEGATE_H_
#define MOLD_PRO_MODEL_DELEGATE_H_
#include <QObject>
#include <QAbstractTableModel>
#include <QItemDelegate>
class MoldProModelItem
{
public:
MoldProModelItem();
~MoldProModelItem();
QString GetId() const
{
return _id;
}
void SetId(QString id)
{
_id = id;
}
QString GetNumNo() const
{
return _numNo;
}
void SetNumNo(const QString numNo)
{
_numNo = numNo;
}
QString GetVersion() const
{
return _version;
}
void SetVersion(QString version)
{
_version = version;
}
QString GetType() const
{
return _type;
}
void SetType(QString type)
{
_type = type;
}
QString GetState() const
{
return _state;
}
void SetState(QString state)
{
_state = state;
}
QString GetName() const
{
return _name;
}
void SetName(QString name)
{
_name = name;
}
QString GetTime() const
{
return _time;
}
void SetTime(QString time)
{
_time = time;
}
QVariantList GetList() const
{
return _progressList;
}
void SetList(QVariantList list)
{
_progressList = list;
}
private:
QString _id;
QString _numNo;
QString _version;
QString _type;
QString _state;
QString _name;
QString _time;
QVariantList _progressList;
};
class MoldProTableModel: public QAbstractTableModel
{
Q_OBJECT
public:
MoldProTableModel(QObject* parent = nullptr);
~MoldProTableModel();
// Qt::ItemFlags flags(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole);
void RefrushModel(MoldProModelItem);
void setHorizontalHeaderList(QStringList hHeadList);
void setVerticalHeaderList(QStringList VHeadList);
void RefrushModelData();
void PushBackData(QList<QStringList>,QList<QVariantList>);
void PopBackData();
signals:
void ModityData(int,int,QVariant);
private:
QStringList horizontal_header_list;
QStringList vertical_header_list;
QList<MoldProModelItem> Ary_row_List;
};
class MoldProModelDelegate : public QItemDelegate
{
Q_OBJECT
public:
explicit MoldProModelDelegate(QObject *parent = nullptr);
virtual ~MoldProModelDelegate();
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private:
};
#endif //MOLD_PRO_MODEL_DELEGATE_H_

View File

@ -0,0 +1,184 @@
#include <QHBoxLayout>
#include <QTableView>
#include <QHeaderView>
#include <QMouseEvent>
#include <QScrollBar>
#include <QDebug>
#include "MoldProTableView.h"
#include "MoldProModelDelegate.h"
MoldProTableView::MoldProTableView(QWidget* parent/* = nullptr*/)
:QTableView(parent)
{
this->setMouseTracking(true);
const QStringList horHeadList = (QStringList() << "序号" << "模具编号" << "版本号" << "类型"<< "状态" << "产品名称" << "计划交期" << "当前进度");
MoldProTableModel* tableModel = new MoldProTableModel(this);
tableModel->setObjectName("Model");
MoldProModelDelegate* tableDelegate = new MoldProModelDelegate(this);
tableDelegate->setObjectName("Delegate");
this->setModel(tableModel);
this->setItemDelegate(tableDelegate);
tableModel->setHorizontalHeaderList(horHeadList);
this->setSelectionBehavior( QAbstractItemView::SelectRows);
//显示子网格
this->setShowGrid(true);
//取消进度条
this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
//设置默认高度
this->verticalHeader()->setDefaultSectionSize(23);
//设置表头高度
this->horizontalHeader()->setFixedHeight(25);
this->setColumnWidth(0,40);
this->setColumnWidth(1,70);
this->setColumnWidth(2,55);
this->setColumnWidth(3,55);
this->setColumnWidth(4,60);
this->setColumnWidth(5,60);
this->setColumnWidth(6,90);
this->setColumnWidth(7,130);
this->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
this->verticalHeader()->hide();
this->horizontalHeader()->setStyleSheet("QHeaderView::section "
"{"
"color:rgb(0,170,190);"
"background-color:rgb(48,48,88);"
"border-left:none;"
"border-bottom:1px solid rgb(40,40,40,150);"
"border-top:1px solid rgb(40,40,40,150);"
"border-right:1px solid rgb(40,40,40,150);}");
this->setStyleSheet("background-color:rgb(48,48,88);"
"border:none;");
// this->connect(this->verticalScrollBar(),&QScrollBar::valueChanged,this,[=](int value){
// if(value + 13 < _max)
// {
// if(value == this->verticalScrollBar()->maximum())
// {
// _row += 1;
// emit RefrushData(_row);
// }
// }
// });
//设置行列表头无法点击
this->setCornerButtonEnabled(false);
this->horizontalHeader()->setSectionsClickable(false);
}
MoldProTableView::~MoldProTableView()
{
}
void MoldProTableView::Set_Model_Data(QList<QStringList> data,QList<QVariantList> list)
{
MoldProTableModel* tableModel = this->findChild<MoldProTableModel*>("Model");
tableModel->PushBackData(data,list);
}
#if 0
QString MoldProTableView::Get_ModelData(const int row, const int Col) const
{
MoldProTableModel* tableModel = this->findChild<MoldProTableModel*>("Model");
const QModelIndex index = tableModel->index(row,Col);
const QString value = this->model()->data(index).toString();
return value;
}
void MoldProTableView::Pop_Model_Data()
{
this->verticalScrollBar()->setValue(0);
MoldProTableModel* tableModel = this->findChild<MoldProTableModel*>("Model");
tableModel->PopBackData();
_row = 0;
}
void MoldProTableView::mousePressEvent(QMouseEvent *event)
{
MoldProModelDelegate* tableDelegate = this->findChild<MoldProModelDelegate*>("Delegate");
MoldProTableModel* tableModel = this->findChild<MoldProTableModel*>("Model");
int row = indexAt(event->pos()).row();
if(row >= 0)
{
tableDelegate->Set_ClickedRow(row);
}
else
{
tableDelegate->Set_ClickedRow(-1);
}
tableModel->RefrushModelData();
return QTableView::mousePressEvent(event);
}
#endif
#if 0
void ClickedRow(int Row);
void MoldProTableView::ClickedRow(int Row)
{
const QModelIndex index = this->model()->index(Row,0);
this->clicked(index);
}
#if 0
void ChangePaint(QString,QString,QString);
bool Get_RowInfo(QStringList&);
bool MoldProTableView::Get_RowInfo(QStringList& value)
{
DBDataModelDelegate* tableDelegate = this->findChild<DBDataModelDelegate*>("Delegate");
MoldProTableModel* tableModel = this->findChild<MoldProTableModel*>("Model");
const int ClickedRow = tableDelegate->Get_ClickedRow();
if(ClickedRow == -1)
{
return false;
}
#if 0
const QModelIndex nameIndex = tableModel->index(ClickedRow,7);
const QModelIndex codeIndex = tableModel->index(ClickedRow,9);
const QModelIndex TypeIndex = tableModel->index(ClickedRow,8);
//层位
const QModelIndex DiskIndex = tableModel->index(ClickedRow,2);
const QModelIndex WorkIndex = tableModel->index(ClickedRow,3);
const QModelIndex ResultIndex = tableModel->index(ClickedRow,10);
const QModelIndex ActionIndex = tableModel->index(ClickedRow,6);
const QModelIndex TimeIndex = tableModel->index(ClickedRow,14);
const QString nameValue = this->model()->data(nameIndex).toString();
const QString codeValue = this->model()->data(codeIndex).toString();
const QString typeValue = this->model()->data(TypeIndex).toString();
const QString diskValue = this->model()->data(DiskIndex).toString();
const QString workValue = this->model()->data(WorkIndex).toString();
const QString resultValue = this->model()->data(ResultIndex).toString();
const QString actionValue = this->model()->data(ActionIndex).toString();
const QString timeValue = this->model()->data(TimeIndex).toString();
#endif
const QString nameValue = Get_ModelData(ClickedRow,7);
const QString codeValue = Get_ModelData(ClickedRow,9);
const QString typeValue = Get_ModelData(ClickedRow,8);
const QString frameValue = Get_ModelData(ClickedRow,1);
const QString diskValue = Get_ModelData(ClickedRow,2);
const QString workValue = Get_ModelData(ClickedRow,3);
const QString resultValue = Get_ModelData(ClickedRow,10);
const QString actionValue = Get_ModelData(ClickedRow,6);
const QString timeValue = Get_ModelData(ClickedRow,14);
value << nameValue << codeValue << typeValue << frameValue << diskValue << workValue << resultValue << actionValue << timeValue;
return true;
}
#endif
#endif

View File

@ -0,0 +1,39 @@
#ifndef MOLD_PRO_TABLE_VIEW
#define MOLD_PRO_TABLE_VIEW
#include <QWidget>
#include <QTableView>
class QTableView;
class MoldProTableView : public QTableView
{
Q_OBJECT
public:
//SettingFourValTableView(QStringList HorList,int TableMaxNum,int NameWidth,int TableWidth,int DefaultHeight,int TableHeight,QWidget* parent = nullptr);
MoldProTableView(QWidget* parent = nullptr);
~MoldProTableView();
void Set_Model_Data(QList<QStringList> data,QList<QVariantList> list);
// void Pop_Model_Data();
// QString Get_ModelData(const int row,const int Col) const;
// void mousePressEvent(QMouseEvent *event);
int Get_Row() const
{
return _row;
}
void Set_Max(int max)
{
_max = max;
}
signals:
void TableModityData(int,int,QVariant);
void RefrushData(int Row);
private:
int _row = 0;
int _max = 0;
};
#endif //MOLD_PRO_TABLE_VIEW

View File

@ -0,0 +1,278 @@
#include "PartsInventoryModelDelegate.h"
#include <QPainter>
#include <QDebug>
PartsInventoryModelItem::PartsInventoryModelItem()
{
}
PartsInventoryModelItem::~PartsInventoryModelItem()
{
}
PartsInventoryTableModel::PartsInventoryTableModel(QObject* parent)
:QAbstractTableModel (parent)
{
}
PartsInventoryTableModel::~PartsInventoryTableModel()
{
}
#if 0
Qt::ItemFlags PartsInventoryTableModel::flags(const QModelIndex &index) const
{
if(index.column() != 0)
return Qt::ItemIsEditable | Qt::ItemIsSelectable | QAbstractTableModel::flags(index);
return QAbstractTableModel::flags(index);
}
#endif
int PartsInventoryTableModel::rowCount(const QModelIndex &parent) const
{
if(parent.isValid())
return 0;
return Ary_row_List.size();
}
int PartsInventoryTableModel::columnCount(const QModelIndex &parent) const
{
if(parent.isValid())
return 0;
return 10;
}
QVariant PartsInventoryTableModel::data(const QModelIndex &index, int role) const
{
if(Ary_row_List.size() < 1 || !index.isValid())
return QVariant();
if (role == Qt::TextAlignmentRole)
{
return int (Qt::AlignHCenter | Qt::AlignVCenter);
}
if(role == Qt::DisplayRole || role == Qt::EditRole)
{
if(index.column() == 0)
{
return Ary_row_List.at(index.row()).GetId();
}
else if(index.column() == 1)
{
return Ary_row_List.at(index.row()).GetNumNo();
}
else if(index.column() == 2)
{
return Ary_row_List.at(index.row()).GetName();
}
else if(index.column() == 3)
{
return Ary_row_List.at(index.row()).GetSpecification();
}
else if(index.column() == 4)
{
return Ary_row_List.at(index.row()).GetMaterial();
}
else if(index.column() == 5)
{
return Ary_row_List.at(index.row()).GetSize();
}
else if(index.column() == 6)
{
return Ary_row_List.at(index.row()).GetRepositories();
}
else if(index.column() == 7)
{
return Ary_row_List.at(index.row()).GetRemainder();
}
else if(index.column() == 8)
{
return Ary_row_List.at(index.row()).GetPercentage();
}
else if(index.column() == 9)
{
return Ary_row_List.at(index.row()).GetList();
}
}
return QVariant();
}
QVariant PartsInventoryTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(role == Qt::DisplayRole || role == Qt::EditRole)
{
if(orientation == Qt::Horizontal)
{
if(horizontal_header_list.size() > section)
return horizontal_header_list[section];
else
return QVariant();
}
if(orientation == Qt::Vertical)
{
if(vertical_header_list.size() > section)
return vertical_header_list[section];
else
return QVariant();
}
}
return QAbstractTableModel::headerData(section, orientation, role);
}
void PartsInventoryTableModel::setHorizontalHeaderList(QStringList hHeadList)
{
horizontal_header_list = hHeadList;
}
void PartsInventoryTableModel::setVerticalHeaderList(QStringList VHeadList)
{
vertical_header_list = VHeadList;
}
void PartsInventoryTableModel::RefrushModel(PartsInventoryModelItem item)
{
const int count = Ary_row_List.size();
beginInsertRows(QModelIndex(), count, count);
Ary_row_List.push_back(item);
endInsertRows();
}
bool PartsInventoryTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
Q_UNUSED(value);
if(Ary_row_List.size() < 1 || !index.isValid())
return false;
if (role == Qt::TextAlignmentRole)
{
return int (Qt::AlignHCenter | Qt::AlignVCenter);
}
if(role == Qt::DisplayRole || role == Qt::EditRole)
{
return true;
}
return false;
}
void PartsInventoryTableModel::PushBackData(QList<QStringList> list,QList<QVariantList> valueList)
{
if(list.size() <= 0 || valueList.size() <= 0)
{
return;
}
if(list.at(0).size() < 9)
{
return;
}
if(list.size() != valueList.size())
{
return;
}
for(int i = 0; i < list.size(); i++)
{
PartsInventoryModelItem Item;
const QString null = "";
Item.SetId(list.at(i).at(0).isEmpty() ? null : list.at(i).at(0));
Item.SetNumNo(list.at(i).at(1).isEmpty() ? null : list.at(i).at(1));
Item.SetName(list.at(i).at(2).isEmpty() ? null : list.at(i).at(2));
Item.SetSpecification(list.at(i).at(3).isEmpty() ? null : list.at(i).at(3));
Item.SetMaterial(list.at(i).at(4).isEmpty() ? null : list.at(i).at(4));
Item.SetSize(list.at(i).at(5).isEmpty() ? null : list.at(i).at(5));
Item.SetRepositories(list.at(i).at(6).isEmpty() ? null : list.at(i).at(6));
Item.SetRemainder(list.at(i).at(7).isEmpty() ? null : list.at(i).at(7));
Item.SetPercentage(list.at(i).at(8).isEmpty() ? null : list.at(i).at(8));
Item.SetList(valueList.at(i));
Ary_row_List.push_back(Item);
}
RefrushModelData();
}
//void PartsInventoryTableModel::PopBackData()
//{
// for(int i = 0; i < Ary_row_List.size(); i++)
// {
// Ary_row_List.removeAt(0);
// }
// Ary_row_List.clear();
// RefrushModelData();
//}
void PartsInventoryTableModel::RefrushModelData()
{
this->beginResetModel();
this->endResetModel();
}
PartsInventoryModelDelegate::PartsInventoryModelDelegate(QObject *parent)
:QItemDelegate (parent)
{
}
PartsInventoryModelDelegate::~PartsInventoryModelDelegate()
{
}
void PartsInventoryModelDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if(index.column() == 0 || index.column() == 1 || index.column() == 2 || index.column() == 3 || index.column() == 4
|| index.column() == 5 || index.column() == 6 || index.column() == 7 || index.column() == 8)
{
painter->setPen(QPen(QColor(255,255,255)));
QString mos = index.model()->data(index,Qt::DisplayRole).toString();
QTextOption o;
o.setAlignment(Qt::AlignCenter);
painter->drawText(option.rect,mos,o);
}
if(index.column() == 9)
{
painter->save();
painter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
QVariantList valueList = index.model()->data(index,Qt::DisplayRole).toList();
int radius = option.rect.height() / 2;
// QFont font;
// font.setPixelSize(option.rect.height() * 0.9);
// painter->setFont(font);
const int value1 = valueList.at(0).toInt();
const int value2 = valueList.at(1).toInt();
const int sum = value1 + value2;
const double percent1 = (double)value1 / (double)sum;
const double percent2 = (double)value2 / (double)sum;
const int width1 = option.rect.width() * percent1;
const int width2 = option.rect.width() * percent2;
const QString text1 = QString("%1%").arg(QString::number(percent1 * 100, 'f', 0));
const QString text2 = QString("%1%").arg(QString::number(percent2 * 100, 'f', 0));
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(0,255,0));
//计算绘制的区域,需要裁剪圆角部分
QPainterPath clipPath1;
clipPath1.addRoundedRect(option.rect, radius, radius);
painter->setClipPath(clipPath1);
QRect rect1(option.rect.x(), option.rect.y(), width1,option.rect.height());
painter->drawRect(rect1);
painter->setPen(QColor(255,255,255));
painter->drawText(rect1, Qt::AlignCenter, text1);
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(255,0,0));
QPainterPath clipPath2;
clipPath2.addRoundedRect(option.rect, radius, radius);
painter->setClipPath(clipPath2);
QRect rect2(option.rect.x() + width1, option.rect.y(), width2,option.rect.height());
painter->drawRect(rect2);
painter->setPen(QColor(255,255,255));
painter->drawText(rect2, Qt::AlignCenter, text2);
painter->restore();
}
// else
// {
// QItemDelegate::paint(painter,option,index);
// }
}

View File

@ -0,0 +1,157 @@
#ifndef PARTS_INVENTORY_MODEL_DELEGATE_H_
#define PARTS_INVENTORY_MODEL_DELEGATE_H_
#include <QObject>
#include <QAbstractTableModel>
#include <QItemDelegate>
class PartsInventoryModelItem
{
public:
PartsInventoryModelItem();
~PartsInventoryModelItem();
QString GetId() const
{
return _id;
}
void SetId(QString id)
{
_id = id;
}
QString GetNumNo() const
{
return _numNo;
}
void SetNumNo(const QString numNo)
{
_numNo = numNo;
}
QString GetName() const
{
return _name;
}
void SetName(QString name)
{
_name = name;
}
QString GetSpecification() const
{
return _specification;
}
void SetSpecification(QString specification)
{
_specification = specification;
}
QString GetMaterial() const
{
return _material;
}
void SetMaterial(QString Material)
{
_material = Material;
}
QString GetSize() const
{
return _size;
}
void SetSize(QString size)
{
_size = size;
}
QString GetRepositories() const
{
return _repositories;
}
void SetRepositories(QString Repositories)
{
_repositories = Repositories;
}
QString GetRemainder() const
{
return _repositories;
}
void SetRemainder(QString Remainder)
{
_remainder = Remainder;
}
QString GetPercentage() const
{
return _percentage;
}
void SetPercentage(QString Percentage)
{
_percentage = Percentage;
}
QVariantList GetList() const
{
return _progressList;
}
void SetList(QVariantList list)
{
_progressList = list;
}
private:
QString _id;
QString _numNo;
QString _name;
QString _specification;
QString _material;
QString _size;
QString _repositories;
QString _remainder;
QString _percentage;
QVariantList _progressList;
};
class PartsInventoryTableModel: public QAbstractTableModel
{
Q_OBJECT
public:
PartsInventoryTableModel(QObject* parent = nullptr);
~PartsInventoryTableModel();
// Qt::ItemFlags flags(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole);
void RefrushModel(PartsInventoryModelItem);
void setHorizontalHeaderList(QStringList hHeadList);
void setVerticalHeaderList(QStringList VHeadList);
void RefrushModelData();
void PushBackData(QList<QStringList>,QList<QVariantList>);
void PopBackData();
signals:
void ModityData(int,int,QVariant);
private:
QStringList horizontal_header_list;
QStringList vertical_header_list;
QList<PartsInventoryModelItem> Ary_row_List;
};
class PartsInventoryModelDelegate : public QItemDelegate
{
Q_OBJECT
public:
explicit PartsInventoryModelDelegate(QObject *parent = nullptr);
virtual ~PartsInventoryModelDelegate();
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private:
};
#endif //PARTS_INVENTORY_MODEL_DELEGATE_H_

View File

@ -0,0 +1,76 @@
#include <QHBoxLayout>
#include <QTableView>
#include <QHeaderView>
#include <QMouseEvent>
#include <QScrollBar>
#include <QDebug>
#include "PartsInventoryModelDelegate.h"
#include "PartsInventoryTableView.h"
PartsInventoryTableView::PartsInventoryTableView(QWidget* parent/* = nullptr*/)
:QTableView(parent)
{
this->setMouseTracking(true);
const QStringList horHeadList = (QStringList() << "序号" << "模具编号" << "品名" << "规格"<< "材料" << "尺寸" << "目标存库" << "当前库存" << "库存百分比" << "预警");
PartsInventoryTableModel* tableModel = new PartsInventoryTableModel(this);
tableModel->setObjectName("Model");
PartsInventoryModelDelegate* tableDelegate = new PartsInventoryModelDelegate(this);
tableDelegate->setObjectName("Delegate");
this->setModel(tableModel);
this->setItemDelegate(tableDelegate);
tableModel->setHorizontalHeaderList(horHeadList);
this->setSelectionBehavior( QAbstractItemView::SelectRows);
//显示子网格
this->setShowGrid(true);
//取消进度条
this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
//设置默认高度
this->verticalHeader()->setDefaultSectionSize(23);
//设置表头高度
this->horizontalHeader()->setFixedHeight(25);
this->setColumnWidth(0,40);
this->setColumnWidth(1,70);
this->setColumnWidth(2,70);
this->setColumnWidth(3,70);
this->setColumnWidth(4,70);
this->setColumnWidth(5,75);
this->setColumnWidth(6,75);
this->setColumnWidth(7,75);
this->setColumnWidth(8,75);
this->setColumnWidth(9,200);
this->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
this->verticalHeader()->hide();
this->horizontalHeader()->setStyleSheet("QHeaderView::section "
"{"
"color:rgb(0,170,190);"
"background-color:rgb(48,48,88);"
"border-left:none;"
"border-bottom:1px solid rgb(40,40,40,150);"
"border-top:1px solid rgb(40,40,40,150);"
"border-right:1px solid rgb(40,40,40,150);}");
this->setStyleSheet("background-color:rgb(48,48,88);"
"border:none;");
this->setCornerButtonEnabled(false);
this->horizontalHeader()->setSectionsClickable(false);
}
PartsInventoryTableView::~PartsInventoryTableView()
{
}
void PartsInventoryTableView::Set_Model_Data(QList<QStringList> data,QList<QVariantList> list)
{
PartsInventoryTableModel* tableModel = this->findChild<PartsInventoryTableModel*>("Model");
tableModel->PushBackData(data,list);
}

View File

@ -0,0 +1,35 @@
#ifndef PARTS_INVENTORY_TABLE_VIEW_H_
#define PARTS_INVENTORY_TABLE_VIEW_H_
#include <QWidget>
#include <QTableView>
class QTableView;
class PartsInventoryTableView : public QTableView
{
Q_OBJECT
public:
PartsInventoryTableView(QWidget* parent = nullptr);
~PartsInventoryTableView();
void Set_Model_Data(QList<QStringList> data,QList<QVariantList> list);
int Get_Row() const
{
return _row;
}
void Set_Max(int max)
{
_max = max;
}
signals:
void TableModityData(int,int,QVariant);
void RefrushData(int Row);
private:
int _row = 0;
int _max = 0;
};
#endif //PARTS_INVENTORY_TABLE_VIEW_H_

62
Src/Pub/PubCss.cpp Normal file
View File

@ -0,0 +1,62 @@
#include "PubCss.h"
#define GETSTR(x) #x
PubCss *PubCss::Get()
{
static PubCss cx;
return &cx;
}
QString PubCss::GetStr(CSS css) const
{
auto it = _mapList.begin();
for(; it != _mapList.end(); ++it)
{
if(it.key() == css)
{
return it.value();
}
}
return "";
}
PubCss::PubCss(QObject *obj)
:QObject (obj)
{
_mapList[SMALLWINDOW_LEFTBUTTONSTYLE] = GETSTR
(
QPushButton
{
border:none;
color:rgb(255,255,255);
}
QPushButton:hover
{
background-color:rgb(25,28,59);
}
);
_mapList[SMALLWINDOW_TITLELABEL] = GETSTR
(
QLabel
{
border:none;
color:rgb(255,255,255);
font: "楷体" 13pt;
}
);
_mapList[DEVICEMONITORING_BOTTOMLABEL] = GETSTR
(
QLabel
{
border:none;
color:rgb(235,235,235);
background-color:rgb(48,48,85);
}
);
}
PubCss::~PubCss()
{
}

29
Src/Pub/PubCss.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef _PUB_CSS_H_
#define _PUB_CSS_H_
#include <QObject>
#include <QMap>
enum CSS
{
SMALLWINDOW_LEFTBUTTONSTYLE,
SMALLWINDOW_TITLELABEL,
DEVICEMONITORING_BOTTOMLABEL,
};
class PubCss : public QObject
{
public:
static PubCss* Get();
QString GetStr(CSS) const;
private:
PubCss(QObject* obj = nullptr);
~PubCss();
QMap<CSS,QString> _mapList;
};
#endif //_PUB_CSS_H_

14
Src/Pub/PubFunction.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "PubFunction.h"
#include <QFileDialog>
#include <QMessageBox>
Pub_Function::Pub_Function(QObject *parent)
{
}
Pub_Function::~Pub_Function()
{
}

25
Src/Pub/PubFunction.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef _PUB_FUNCTION_H_
#define _PUB_FUNCTION_H_
#include <QObject>
class Pub_Function : public QObject
{
Q_OBJECT
private:
Pub_Function(QObject* parent = nullptr);
~Pub_Function();
public:
static Pub_Function* Get()
{
static Pub_Function cx;
return &cx;
}
void LoadLayout();
//读取布局
void SaveLayout();
//保存布局
};
#endif //_PUB_FUNCTION_H_

63
Src/Task/OpenCVVideo.cpp Normal file
View File

@ -0,0 +1,63 @@
#include "OpenCVVideo.h"
#include <QDebug>
#include <windows.h>
#include <QElapsedTimer>
static cv::VideoCapture cap2;
static cv::Mat MatCamear;
OpenCV_PV_Thread::OpenCV_PV_Thread()
{
}
OpenCV_PV_Thread::~OpenCV_PV_Thread()
{
isClose = true;
this->quit();
this->wait();
}
bool OpenCV_PV_Thread::Open()
{
mux.lock();
bool isOpen = cap2.open(0);
mux.unlock();
if(!isOpen)
{
return false;
}
isCamear = true;
return true;
}
void OpenCV_PV_Thread::run()
{
while(1)
{
mux.lock();
if(isClose)
{
mux.unlock();
break;
}
if(!isCamear)
{
mux.unlock();
continue;
}
if(isCamear && cap2.isOpened())
{
bool isRead = cap2.read(MatCamear);
if(isRead)
emit ShowCamera(MatCamear);
}
else
{
Sleep(30);
}
mux.unlock();
}
}

39
Src/Task/OpenCVVideo.h Normal file
View File

@ -0,0 +1,39 @@
#ifndef _OPENCV_PV_THREAD_H_
#define _OPENCV_PV_THREAD_H_
#include <QThread>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/core.hpp>
#include <QMutex>
#include <string.h>
enum SavePaintModel
{
pSavePaint,
vSavePaint,
cSavePaint,
};
class OpenCV_PV_Thread : public QThread
{
Q_OBJECT
public:
OpenCV_PV_Thread();
~OpenCV_PV_Thread();
bool Open();
void run();
signals:
void ShowCamera(cv::Mat);
private:
//摄像头是否被打开
bool isCamear = false;
QMutex mux;
bool isClose = false;
};
#endif //_OPENCV_PV_THREAD_H_

13
main.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "Src/Gui/SmallWindow.h"
#include "Src/Gui/TypeWindow.h"
#include "Src/Gui/MainWindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}