feat:添加坐标轴配置选项
This commit is contained in:
parent
62c1d349fb
commit
9962a6718e
|
|
@ -14,6 +14,7 @@ public:
|
|||
void setTimeRange(TimeUnit) {}
|
||||
void setDateTime(const QDateTime&) {}
|
||||
void viewHistoricalData(const QDateTime&) {}
|
||||
void synchronizeConfigData(const configurationResults&) {}
|
||||
|
||||
protected:
|
||||
struct ChartStyle
|
||||
|
|
@ -23,7 +24,14 @@ protected:
|
|||
QColor tickColor; //刻度颜色
|
||||
QColor tickLabelColor; //刻度label颜色
|
||||
QFont tickLabelFont; //刻度label字体
|
||||
QPen gridPen; //网格线颜色
|
||||
QPen gridPen; //网格线画笔
|
||||
};
|
||||
|
||||
struct Axis //坐标轴配置信息
|
||||
{
|
||||
QString name; //坐标轴名称,例如:电压
|
||||
QString unit; //坐标轴单位,例如:V
|
||||
RealTimeDataType dataType;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include <QDateTime>
|
||||
#include <QPen>
|
||||
#include "global.h"
|
||||
#include "dpGlobals.h"
|
||||
|
||||
class dpBaseWidget : public QWidget
|
||||
{
|
||||
|
|
@ -26,6 +27,7 @@ public:
|
|||
virtual void setTimeRange(TimeUnit) {}
|
||||
virtual void setDateTime(const QDateTime&) {}
|
||||
virtual void viewHistoricalData(const QDateTime&) {}
|
||||
virtual void synchronizeConfigData(const configurationResults&) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -220,6 +220,22 @@ void dpConfigurationDialog::setPanel(DataPanel* pPanel)
|
|||
// ui->typeSelectedList->setModel(m_pModel_typeSelected);
|
||||
ui->serviceIP->setText(pPanel->m_cofigurationResults.dataServiceIP);
|
||||
ui->servicePort->setText(QString::number(pPanel->m_cofigurationResults.dataServicePort));
|
||||
|
||||
DataPanelType panelType = pPanel->getType();
|
||||
switch (panelType)
|
||||
{
|
||||
case lineChart:
|
||||
case curveChart:
|
||||
case barChart:
|
||||
{
|
||||
ui->specialSettings->setCurrentIndex(0);
|
||||
ui->specialSettings->setVisible(true);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ui->specialSettings->setVisible(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void dpConfigurationDialog::onBtnClicked_tabBtn()
|
||||
|
|
|
|||
|
|
@ -29,6 +29,12 @@ struct configurationResults
|
|||
QString dataServiceIP;
|
||||
int dataServicePort;
|
||||
|
||||
struct Axis
|
||||
{
|
||||
QString name;
|
||||
QString unit;
|
||||
} axisInfo;
|
||||
|
||||
configurationResults()
|
||||
{
|
||||
m_pModel_dataType = nullptr;
|
||||
|
|
@ -36,6 +42,9 @@ struct configurationResults
|
|||
|
||||
dataServiceIP = "127.0.0.1";
|
||||
dataServicePort = 1987;
|
||||
|
||||
axisInfo.name = "";
|
||||
axisInfo.unit = "";
|
||||
}
|
||||
|
||||
void setParent(QObject* parent)
|
||||
|
|
|
|||
|
|
@ -154,6 +154,21 @@ void dpLineChart::viewHistoricalData(const QDateTime& dateTime)
|
|||
|
||||
}
|
||||
|
||||
void dpLineChart::synchronizeConfigData(const configurationResults& cfg)
|
||||
{
|
||||
//Y坐标轴的数量由数据类型决定
|
||||
QHash<RealTimeDataType, Axis> cfgAxisMap; //将最新配置信息中的坐标轴相关数据存储在QHash中,有助于更好的判断当前坐标轴是否需要发生同步更新
|
||||
for(int i = 0; i< cfg.m_pModel_dataType->rowCount(); i++)
|
||||
{
|
||||
Axis axis;
|
||||
axis.name = cfg.axisInfo.name;
|
||||
axis.unit = cfg.axisInfo.unit;
|
||||
RealTimeDataType dataType = (RealTimeDataType)cfg.m_pModel_dataType->item(i, 0)->data(Qt::UserRole + itemRole_dataType).toInt();
|
||||
axis.dataType = dataType;
|
||||
cfgAxisMap.insert(dataType, axis);
|
||||
}
|
||||
}
|
||||
|
||||
void dpLineChart::onSignal_rangeChanged_xAxis(const QCPRange& range)
|
||||
{
|
||||
// qDebug() << "m_timeRange: " << m_timeRange;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ public:
|
|||
void setDateTime(const QDateTime&) override;
|
||||
void viewHistoricalData(const QDateTime&) override;
|
||||
|
||||
void synchronizeConfigData(const configurationResults&) override;
|
||||
|
||||
public slots:
|
||||
void onSignal_rangeChanged_xAxis(const QCPRange&);
|
||||
|
||||
|
|
@ -37,6 +39,7 @@ private:
|
|||
ChartStyle m_chartStyle;
|
||||
qint64 m_timeRange;
|
||||
QDateTime m_curDateTime;
|
||||
QVector<Axis> m_axes;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ signals:
|
|||
private:
|
||||
void setupScrollArea();
|
||||
void autoSetGeometry(); //在缩放和移动时以其它panel和parent的border为依据自动调整
|
||||
void createDataWidget(DataPanelType);
|
||||
void createDataWidget();
|
||||
|
||||
bool m_bMouseEnter;
|
||||
bool m_bConfigurationComplete;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>images/down-arrow.png</file>
|
||||
<file>images/branch_closed.png</file>
|
||||
<file>images/branch_open.png</file>
|
||||
<file>images/appIcon.png</file>
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 246 B |
|
|
@ -83,7 +83,7 @@ DataPanel::DataPanel(QWidget *parent, DataPanelType type)
|
|||
//m_pToolMenu->addAction(QString::fromWCharArray(L"放置最前"), this, SLOT(onAction_moveToFront()));
|
||||
m_pToolMenu->addAction(QString::fromWCharArray(L"放置最后"), this, SLOT(onAction_moveToBack()));
|
||||
|
||||
createDataWidget(type);
|
||||
createDataWidget();
|
||||
m_cofigurationResults.setParent(this);
|
||||
|
||||
connect(DataManager::instance(), &DataManager::dataUpdated, this, &DataPanel::onSignal_dataUpdated);
|
||||
|
|
@ -238,9 +238,9 @@ void DataPanel::autoSetGeometry()
|
|||
|
||||
}
|
||||
|
||||
void DataPanel::createDataWidget(DataPanelType type)
|
||||
void DataPanel::createDataWidget()
|
||||
{
|
||||
switch(type)
|
||||
switch(m_type)
|
||||
{
|
||||
case lineChart:
|
||||
{
|
||||
|
|
@ -402,8 +402,9 @@ void DataPanel::configurationComplete()
|
|||
if(m_pConfigurationWidget->isVisible())
|
||||
m_pConfigurationWidget->hide();
|
||||
|
||||
//读取配置数据,根据所选的数据类型数量同步创建不同的Y坐标轴
|
||||
|
||||
dpBaseWidget* baseWidget = qobject_cast<dpBaseWidget*>(m_pContentWidget);
|
||||
if(baseWidget)
|
||||
baseWidget->synchronizeConfigData(m_cofigurationResults);
|
||||
}
|
||||
|
||||
void DataPanel::onToolBtnClicked_setting()
|
||||
|
|
|
|||
|
|
@ -56,6 +56,44 @@ QLineEdit:focus
|
|||
border:1px solid rgb(67,160,249);
|
||||
}
|
||||
|
||||
QComboBox
|
||||
{
|
||||
font: 11pt "黑体";
|
||||
color: rgb(250, 250, 250);
|
||||
background-color: rgb(54, 62, 74);
|
||||
border: 0px;
|
||||
border-radius: 0px;
|
||||
}
|
||||
QComboBox:hover
|
||||
{
|
||||
background-color: rgb(72, 83, 99);
|
||||
}
|
||||
QComboBox::drop-down
|
||||
{
|
||||
border:0px;
|
||||
}
|
||||
QComboBox::down-arrow
|
||||
{
|
||||
margin-right:10px;
|
||||
width:14px;
|
||||
border-image: url(:/images/down-arrow.png);
|
||||
}
|
||||
QComboBox QAbstractItemView
|
||||
{
|
||||
outline: 0px; /*去除选中虚线框 */
|
||||
border:0px;
|
||||
background-color:rgba(25,25,25,240);
|
||||
}
|
||||
QComboBox QAbstractItemView::item:hover
|
||||
{
|
||||
background-color: rgb(43, 102, 158);
|
||||
}
|
||||
QComboBox QAbstractItemView::item:selected
|
||||
{
|
||||
color: rgb(250, 250, 250);
|
||||
background-color: rgb(43, 102, 158);
|
||||
}
|
||||
|
||||
QTreeView
|
||||
{
|
||||
padding:6px;
|
||||
|
|
@ -141,8 +179,7 @@ border:0px;
|
|||
QListView::item:hover {
|
||||
background-color: rgba(67,160,249, 30);
|
||||
border:0px;
|
||||
}
|
||||
</string>
|
||||
}</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="labeWindowlTitle">
|
||||
<property name="geometry">
|
||||
|
|
@ -240,7 +277,7 @@ QPushButton:pressed
|
|||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>数据配置</string>
|
||||
<string>其它配置</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="tabDataType">
|
||||
|
|
@ -286,7 +323,7 @@ QPushButton:pressed
|
|||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="pageDataType">
|
||||
<property name="styleSheet">
|
||||
|
|
@ -557,6 +594,112 @@ background-color: rgb(24, 32, 38);
|
|||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStackedWidget" name="specialSettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>110</y>
|
||||
<width>521</width>
|
||||
<height>221</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="coordinate">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget #coordinate
|
||||
{
|
||||
background-color:transparent;
|
||||
}</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="setting_Server_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>41</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Y轴:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>0</y>
|
||||
<width>91</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>电压</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>电流</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>功率</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_axisName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>35</y>
|
||||
<width>41</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>名称:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="axisName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>35</y>
|
||||
<width>71</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_axisUnit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>190</x>
|
||||
<y>35</y>
|
||||
<width>41</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>单位:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="axisUnit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>35</y>
|
||||
<width>71</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnCancle">
|
||||
|
|
|
|||
Loading…
Reference in New Issue