topologic serialize finish
This commit is contained in:
parent
267026ddc4
commit
a5259319f7
|
|
@ -43,7 +43,18 @@ public:
|
||||||
enum DiagramMode //组态图模式
|
enum DiagramMode //组态图模式
|
||||||
{
|
{
|
||||||
DM_edit = 0,
|
DM_edit = 0,
|
||||||
DM_run
|
DM_run,
|
||||||
|
DM_academic
|
||||||
|
};
|
||||||
|
|
||||||
|
enum VariantIcon //变种图
|
||||||
|
{
|
||||||
|
VI_thumbnail = 0,
|
||||||
|
VI_normal_1,
|
||||||
|
VI_normal_2,
|
||||||
|
VI_normal_3,
|
||||||
|
VI_normal_4,
|
||||||
|
VI_normal_5
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Attribute //元模属性字段对照
|
enum Attribute //元模属性字段对照
|
||||||
|
|
@ -229,6 +240,12 @@ struct propertyContentInfo //单个属性结构
|
||||||
};
|
};
|
||||||
|
|
||||||
//==================组态拓扑结构======================
|
//==================组态拓扑结构======================
|
||||||
|
enum class DataState
|
||||||
|
{
|
||||||
|
unchanged = 0,
|
||||||
|
changed,
|
||||||
|
prepareDelete
|
||||||
|
};
|
||||||
/*struct diagramInfo
|
/*struct diagramInfo
|
||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
|
|
@ -314,7 +331,31 @@ struct componentInfo
|
||||||
int op = 0;
|
int op = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct busStability
|
struct topologicInfo
|
||||||
|
{
|
||||||
|
int id = -1;
|
||||||
|
int page_id;
|
||||||
|
QUuid uuid_from;
|
||||||
|
QUuid uuid_to;
|
||||||
|
QUuid pin_from;
|
||||||
|
QUuid pin_to;
|
||||||
|
int flag;
|
||||||
|
QString description;
|
||||||
|
int op;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pageInfo
|
||||||
|
{
|
||||||
|
int id = -1;
|
||||||
|
QString tag;
|
||||||
|
QString name;
|
||||||
|
int status;
|
||||||
|
QJsonObject label;
|
||||||
|
QJsonObject context;
|
||||||
|
QString description;
|
||||||
|
int op;
|
||||||
|
};
|
||||||
|
/*struct busStability
|
||||||
{
|
{
|
||||||
int componentId = 0;
|
int componentId = 0;
|
||||||
double resistance = 0;
|
double resistance = 0;
|
||||||
|
|
@ -324,7 +365,7 @@ struct busStability
|
||||||
bool anchor_i = false;
|
bool anchor_i = false;
|
||||||
double ui_alarm = 0;
|
double ui_alarm = 0;
|
||||||
double oi_alarm = 0;
|
double oi_alarm = 0;
|
||||||
};
|
};*/
|
||||||
//Q_ENUM_NS(GraphicsItemType)
|
//Q_ENUM_NS(GraphicsItemType)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -67,4 +67,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
int getLevel(QStandardItem *item);
|
int getLevel(QStandardItem *item);
|
||||||
|
QModelIndex findIndex(const QAbstractItemModel* model, const QVariant& target,
|
||||||
|
int role = Qt::DisplayRole, const QModelIndex& parent = QModelIndex());
|
||||||
#endif // DATABASE_H
|
#endif // DATABASE_H
|
||||||
|
|
|
||||||
|
|
@ -15,3 +15,21 @@ int getLevel(QStandardItem *item) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QModelIndex findIndex(const QAbstractItemModel* model, const QVariant& target,
|
||||||
|
int role, const QModelIndex& parent) {
|
||||||
|
for (int row = 0; row < model->rowCount(parent); ++row) {
|
||||||
|
QModelIndex idx = model->index(row, 0, parent); // 假设查找第0列
|
||||||
|
if (model->data(idx, role) == target) {
|
||||||
|
return idx; // 找到匹配项
|
||||||
|
}
|
||||||
|
// 递归查找子项
|
||||||
|
if (model->hasChildren(idx)) {
|
||||||
|
QModelIndex childIdx = findIndex(model, target, role, idx);
|
||||||
|
if (childIdx.isValid()) {
|
||||||
|
return childIdx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QModelIndex(); // 未找到
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,11 @@ set(DIAGRAMCAVAS_HEADER_FILES
|
||||||
include/serializable.h
|
include/serializable.h
|
||||||
include/statusBar.h
|
include/statusBar.h
|
||||||
include/powerEntity.h
|
include/powerEntity.h
|
||||||
include/topologyManager.h
|
|
||||||
include/powerConnection.h
|
include/powerConnection.h
|
||||||
include/powerTerminal.h
|
include/powerTerminal.h
|
||||||
|
include/topologyManager.h
|
||||||
|
include/baseInfoDlg.h
|
||||||
|
include/baseContentDlg.h
|
||||||
include/graphicsDataModel/baseModel.h
|
include/graphicsDataModel/baseModel.h
|
||||||
include/graphicsDataModel/fixedPortsModel.h
|
include/graphicsDataModel/fixedPortsModel.h
|
||||||
include/graphicsItem/electricConnectLineItem.h
|
include/graphicsItem/electricConnectLineItem.h
|
||||||
|
|
@ -56,9 +58,11 @@ set(DIAGRAMCAVAS_SOURCE_FILES
|
||||||
source/propertyContentDlg.cpp
|
source/propertyContentDlg.cpp
|
||||||
source/statusBar.cpp
|
source/statusBar.cpp
|
||||||
source/powerEntity.cpp
|
source/powerEntity.cpp
|
||||||
source/topologyManager.cpp
|
|
||||||
source/powerConnection.cpp
|
source/powerConnection.cpp
|
||||||
source/powerTerminal.cpp
|
source/powerTerminal.cpp
|
||||||
|
source/topologyManager.cpp
|
||||||
|
source/baseInfoDlg.cpp
|
||||||
|
source/baseContentDlg.cpp
|
||||||
#source/serializable.cpp
|
#source/serializable.cpp
|
||||||
source/graphicsDataModel/baseModel.cpp
|
source/graphicsDataModel/baseModel.cpp
|
||||||
source/graphicsDataModel/fixedPortsModel.cpp
|
source/graphicsDataModel/fixedPortsModel.cpp
|
||||||
|
|
@ -91,6 +95,7 @@ set(DIAGRAMCAVAS_SOURCE_FILES
|
||||||
set(UI_FILES
|
set(UI_FILES
|
||||||
ui/drawingPanel.ui
|
ui/drawingPanel.ui
|
||||||
ui/itemPropertyDlg.ui
|
ui/itemPropertyDlg.ui
|
||||||
|
ui/baseInfoDlg.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef BASECONTENTDLG_H
|
||||||
|
#define BASECONTENTDLG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include "global.h"
|
||||||
|
/*******************************************************
|
||||||
|
属性组界面基类
|
||||||
|
********************************************************/
|
||||||
|
|
||||||
|
class BaseContentDlg : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
BaseContentDlg(QWidget *parent = nullptr);
|
||||||
|
virtual ~BaseContentDlg();
|
||||||
|
virtual void createGroupView(groupStateInfo) = 0; //创建页面
|
||||||
|
virtual QMap<QString,propertyStateInfo> getPropertyValue() = 0; //返回当前页面的属性值
|
||||||
|
virtual void setPropertyValue(QMap<QString,propertyStateInfo>) = 0;
|
||||||
|
protected:
|
||||||
|
QMap<QString,propertyContentInfo> _mapPro;
|
||||||
|
QFormLayout* createFormLayout(QWidget* parent);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef BASEINFODLG_H
|
||||||
|
#define BASEINFODLG_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include "baseContentDlg.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
namespace Ui { class baseInfoDlg; }
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
|
class BaseInfoDlg : public BaseContentDlg
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
BaseInfoDlg(QWidget *parent = nullptr);
|
||||||
|
~BaseInfoDlg();
|
||||||
|
|
||||||
|
virtual void createGroupView(groupStateInfo);
|
||||||
|
virtual QMap<QString,propertyStateInfo> getPropertyValue();
|
||||||
|
virtual void setPropertyValue(QMap<QString,propertyStateInfo>);
|
||||||
|
private:
|
||||||
|
Ui::baseInfoDlg *ui;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -34,9 +34,9 @@ public:
|
||||||
QVariant nodeData(QUuid nodeId, NodeRole role) const;
|
QVariant nodeData(QUuid nodeId, NodeRole role) const;
|
||||||
BaseProperty* addNodeData(QUuid id,int type,QString name,QString modelName); //对应component数据,一个data可对应多个item
|
BaseProperty* addNodeData(QUuid id,int type,QString name,QString modelName); //对应component数据,一个data可对应多个item
|
||||||
void loadNodeDataFromDataBase(); //从数据库加载数据
|
void loadNodeDataFromDataBase(); //从数据库加载数据
|
||||||
void addConnectLline(QUuid srcId,QUuid destId,int srcPort,int destPort);
|
void addConnectLline(QUuid srcId,QUuid destId,QUuid srcPort,QUuid destPort);
|
||||||
void deleteNodeItem(GraphicsBaseItem*);
|
void deleteNodeItem(GraphicsBaseItem*);
|
||||||
QJsonObject saveNode(QUuid const) const;
|
//QJsonObject saveNode(QUuid const) const;
|
||||||
void saveNode(int nPageId);
|
void saveNode(int nPageId);
|
||||||
void setScene(DesignerScene* p){_scene = p;}
|
void setScene(DesignerScene* p){_scene = p;}
|
||||||
void setTopWidget(DrawingPanel* p) {_widget = p;}
|
void setTopWidget(DrawingPanel* p) {_widget = p;}
|
||||||
|
|
@ -48,7 +48,8 @@ public:
|
||||||
void initialPropertyDlg(); //初始化属性设置dlg,每个模型拥各自的dlg
|
void initialPropertyDlg(); //初始化属性设置dlg,每个模型拥各自的dlg
|
||||||
void generatePropertyDlg(const QString&);
|
void generatePropertyDlg(const QString&);
|
||||||
ConfigurationDiagram* getTopologyDiagram(); //返回当前组态图的拓扑实体
|
ConfigurationDiagram* getTopologyDiagram(); //返回当前组态图的拓扑实体
|
||||||
void createTopoTerminals(GraphicsBaseItem*);
|
void createTopoTerminalsByItem(GraphicsBaseItem*); //通过图形对象创建port接线点(新建)
|
||||||
|
void createTopoTerminalsByData(PowerEntity* pParent,QJsonObject componentCon); //通过componet数据创建port接线点(加载)
|
||||||
bool isItemValid(GraphicsBaseItem*); //判断item是否可以连接
|
bool isItemValid(GraphicsBaseItem*); //判断item是否可以连接
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void activatePage(const QString&); //激活当前model所在page
|
void activatePage(const QString&); //激活当前model所在page
|
||||||
|
|
|
||||||
|
|
@ -8,23 +8,18 @@
|
||||||
struct Connection
|
struct Connection
|
||||||
{
|
{
|
||||||
QUuid nSrcNodeId;
|
QUuid nSrcNodeId;
|
||||||
int nSrcPort;
|
QUuid nSrcPortId;
|
||||||
HandleType srcType;
|
HandleType srcType;
|
||||||
PortPos srcPos;
|
PortPos srcPos;
|
||||||
QUuid nDestNodeId;
|
QUuid nDestNodeId;
|
||||||
int nDestPort;
|
QUuid nDestPortId;
|
||||||
HandleType destType;
|
HandleType destType;
|
||||||
PortPos destPos;
|
PortPos destPos;
|
||||||
|
|
||||||
Connection()
|
Connection()
|
||||||
{
|
{
|
||||||
|
|
||||||
//nSrcNodeId = -1;
|
|
||||||
nSrcPort = -1;
|
|
||||||
srcType = T_none;
|
srcType = T_none;
|
||||||
srcPos = P_top;
|
srcPos = P_top;
|
||||||
//nDestNodeId = -1;
|
|
||||||
nDestPort = -1;
|
|
||||||
destType = T_none;
|
destType = T_none;
|
||||||
destPos = P_top;
|
destPos = P_top;
|
||||||
}
|
}
|
||||||
|
|
@ -32,29 +27,29 @@ struct Connection
|
||||||
Connection(const Connection& obj)
|
Connection(const Connection& obj)
|
||||||
{
|
{
|
||||||
nSrcNodeId = obj.nSrcNodeId;
|
nSrcNodeId = obj.nSrcNodeId;
|
||||||
nSrcPort = obj.nSrcPort;
|
nSrcPortId = obj.nSrcPortId;
|
||||||
srcType = obj.srcType;
|
srcType = obj.srcType;
|
||||||
srcPos = obj.srcPos;
|
srcPos = obj.srcPos;
|
||||||
nDestNodeId = obj.nDestNodeId;
|
nDestNodeId = obj.nDestNodeId;
|
||||||
nDestPort = obj.nDestPort;
|
nDestPortId = obj.nDestPortId;
|
||||||
destType = obj.destType;
|
destType = obj.destType;
|
||||||
destPos = obj.destPos;
|
destPos = obj.destPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection(QUuid nSNI,int nSP,HandleType sT,PortPos sPOS,QUuid nDNI,int nDP,HandleType dT,PortPos dPOS)
|
Connection(QUuid nSNI,QUuid nSPI,HandleType sT,PortPos sPOS,QUuid nDNI,QUuid nDPI,HandleType dT,PortPos dPOS)
|
||||||
{
|
{
|
||||||
nSrcNodeId = nSNI;
|
nSrcNodeId = nSNI;
|
||||||
nSrcPort = nSP;
|
nSrcPortId = nSPI;
|
||||||
srcType = sT;
|
srcType = sT;
|
||||||
srcPos = sPOS;
|
srcPos = sPOS;
|
||||||
nDestNodeId = nDNI;
|
nDestNodeId = nDNI;
|
||||||
nDestPort = nDP;
|
nDestPortId = nDPI;
|
||||||
destType = dT;
|
destType = dT;
|
||||||
destPos = dPOS;
|
destPos = dPOS;
|
||||||
}
|
}
|
||||||
bool operator==(const Connection& obj)
|
bool operator==(const Connection& obj)
|
||||||
{
|
{
|
||||||
return ((obj.nSrcNodeId == nSrcNodeId)&&(obj.nSrcPort == nSrcPort)&&(obj.srcType == srcType)&&(obj.nDestNodeId == nDestNodeId)&&(obj.nDestPort == nDestPort)&&(obj.destType == destType));
|
return ((obj.nSrcNodeId == nSrcNodeId)&&(obj.nSrcPortId == nSrcPortId)&&(obj.srcType == srcType)&&(obj.nDestNodeId == nDestNodeId)&&(obj.nDestPortId == nDestPortId)&&(obj.destType == destType));
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection& operator=(const Connection& obj)
|
Connection& operator=(const Connection& obj)
|
||||||
|
|
@ -62,11 +57,11 @@ struct Connection
|
||||||
if(*this == obj)
|
if(*this == obj)
|
||||||
return *this;
|
return *this;
|
||||||
nSrcNodeId = obj.nSrcNodeId;
|
nSrcNodeId = obj.nSrcNodeId;
|
||||||
nSrcPort = obj.nSrcPort;
|
nSrcPortId = obj.nSrcPortId;
|
||||||
srcType = obj.srcType;
|
srcType = obj.srcType;
|
||||||
srcPos = obj.srcPos;
|
srcPos = obj.srcPos;
|
||||||
nDestNodeId = obj.nDestNodeId;
|
nDestNodeId = obj.nDestNodeId;
|
||||||
nDestPort = obj.nDestPort;
|
nDestPortId = obj.nDestPortId;
|
||||||
destType = obj.destType;
|
destType = obj.destType;
|
||||||
destPos = obj.destPos;
|
destPos = obj.destPos;
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ class ElectricSvgItem :public GraphicsBaseItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ElectricSvgItem(const QRect &rect, QGraphicsItem *parent = 0);
|
ElectricSvgItem(const QRect &rect, bool genNewPort = true,QGraphicsItem *parent = 0); //genNewPort生成新接线点
|
||||||
virtual ~ElectricSvgItem();
|
virtual ~ElectricSvgItem();
|
||||||
void resize(int,double, double, const QPointF&);
|
void resize(int,double, double, const QPointF&);
|
||||||
void updateCoordinate();
|
void updateCoordinate();
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class ElectricSvgItemRect :public ElectricSvgItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ElectricSvgItemRect(const QRect &rect, QGraphicsItem *parent = 0);
|
ElectricSvgItemRect(const QRect &rect, bool genNewPort = true,QGraphicsItem *parent = 0);
|
||||||
virtual ~ElectricSvgItemRect();
|
virtual ~ElectricSvgItemRect();
|
||||||
|
|
||||||
//virtual void updateByProperty();
|
//virtual void updateByProperty();
|
||||||
|
|
|
||||||
|
|
@ -466,7 +466,7 @@ public:
|
||||||
virtual void setLabelVoltage(const QString& str); //设置电压标签
|
virtual void setLabelVoltage(const QString& str); //设置电压标签
|
||||||
virtual QString getLabelVoltage() const;
|
virtual QString getLabelVoltage() const;
|
||||||
virtual int addPort(PortState typ,QPointF vec,QString id = "",HandleType hType = T_lineInOut,PortPos pos = P_top); //新建,返回-1失败
|
virtual int addPort(PortState typ,QPointF vec,QString id = "",HandleType hType = T_lineInOut,PortPos pos = P_top); //新建,返回-1失败
|
||||||
virtual void addPort(PortState typ,int ntagId,QPointF vec); //载入 PortState为P_const时,QPointF中为(0~1,0~1)的相对位置;PortState为p_movable时,QPointF为坐标值
|
//virtual void addPort(PortState typ,int ntagId,QPointF vec); //载入 PortState为P_const时,QPointF中为(0~1,0~1)的相对位置;PortState为p_movable时,QPointF为坐标值
|
||||||
virtual QUuid itemId() const {return m_itemId;}
|
virtual QUuid itemId() const {return m_itemId;}
|
||||||
virtual void setItemId(QUuid n){m_itemId = n;}
|
virtual void setItemId(QUuid n){m_itemId = n;}
|
||||||
virtual void setState(ItemState s){m_state = s;}
|
virtual void setState(ItemState s){m_state = s;}
|
||||||
|
|
@ -476,6 +476,7 @@ public:
|
||||||
virtual GraphicsItemType getItemType() const {return m_Itemtype;}
|
virtual GraphicsItemType getItemType() const {return m_Itemtype;}
|
||||||
virtual void setLastPort(int n){_lastPort = n;}
|
virtual void setLastPort(int n){_lastPort = n;}
|
||||||
virtual int getLastPort() const {return _lastPort;}
|
virtual int getLastPort() const {return _lastPort;}
|
||||||
|
virtual ItemPort* getPortById(QString) const;
|
||||||
virtual ItemPort* getPortPtr(int) const;
|
virtual ItemPort* getPortPtr(int) const;
|
||||||
virtual ItemControlHandle* getHandlePtr(int) const;
|
virtual ItemControlHandle* getHandlePtr(int) const;
|
||||||
virtual QMap<QString,ItemPort*> getPorts() {return m_mapPort;}
|
virtual QMap<QString,ItemPort*> getPorts() {return m_mapPort;}
|
||||||
|
|
|
||||||
|
|
@ -5,17 +5,22 @@
|
||||||
* *************************/
|
* *************************/
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
// 连接线元数据(抽象连接关系)
|
// 连接线元数据(抽象连接关系)
|
||||||
class PowerConnection : public QObject {
|
class PowerConnection : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
PowerConnection(const QString& uuid,const QString& fromTerminalId,const QString& toTerminalId,QObject* parent = nullptr);
|
PowerConnection(const QString& uuid,const QString& fromTerminalId,const QString& toTerminalId,const QString& fromId,const QString& toId,QObject* parent = nullptr);
|
||||||
|
|
||||||
QString id() const {return m_uuid;}
|
QString id() const {return m_uuid;}
|
||||||
QString fromTerminalId() const { return m_fromTerminal; }
|
QString fromTerminalId() const { return m_fromTerminal; }
|
||||||
QString toTerminalId() const { return m_toTerminal; }
|
QString toTerminalId() const { return m_toTerminal; }
|
||||||
|
QString fromComponent() const {return m_fromComponent;}
|
||||||
|
QString toComponent() const {return m_toComponent;}
|
||||||
QVariantMap properties() const { return m_properties; }
|
QVariantMap properties() const { return m_properties; }
|
||||||
|
DataState state() {return m_state;}
|
||||||
|
void setState(DataState s) {m_state = s;}
|
||||||
|
|
||||||
void setProperty(const QString& key, const QVariant& value);
|
void setProperty(const QString& key, const QVariant& value);
|
||||||
|
|
||||||
|
|
@ -25,6 +30,9 @@ private:
|
||||||
QString m_uuid;
|
QString m_uuid;
|
||||||
QString m_fromTerminal;
|
QString m_fromTerminal;
|
||||||
QString m_toTerminal;
|
QString m_toTerminal;
|
||||||
|
QString m_fromComponent;
|
||||||
|
QString m_toComponent;
|
||||||
|
DataState m_state;
|
||||||
QVariantMap m_properties;
|
QVariantMap m_properties;
|
||||||
};
|
};
|
||||||
#endif //POWETCONNECTION_H
|
#endif //POWETCONNECTION_H
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,12 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "baseContentDlg.h"
|
||||||
/*******************************************************
|
/*******************************************************
|
||||||
每个属性组单独的界面信息,动态生成后加入到itemPropertyDlg
|
每个属性组单独的界面信息,动态生成后加入到itemPropertyDlg
|
||||||
********************************************************/
|
********************************************************/
|
||||||
|
|
||||||
class PropertyContentDlg : public QDialog
|
class PropertyContentDlg : public BaseContentDlg
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
@ -17,16 +18,13 @@ public:
|
||||||
PropertyContentDlg(QWidget *parent = nullptr);
|
PropertyContentDlg(QWidget *parent = nullptr);
|
||||||
~PropertyContentDlg();
|
~PropertyContentDlg();
|
||||||
|
|
||||||
void createGroupView(groupStateInfo); //创建页面
|
virtual void createGroupView(groupStateInfo); //创建页面
|
||||||
QWidget* createEditor(propertyStateInfo); //创建属性
|
virtual QMap<QString,propertyStateInfo> getPropertyValue(); //返回当前页面的属性值
|
||||||
QMap<QString,propertyStateInfo> getPropertyValue() const; //返回当前页面的属性值
|
virtual void setPropertyValue(QMap<QString,propertyStateInfo>);
|
||||||
void setPropertyValue(QMap<QString,propertyStateInfo>);
|
protected:
|
||||||
private:
|
|
||||||
QVBoxLayout* _layout;
|
QVBoxLayout* _layout;
|
||||||
|
QWidget* createEditor(propertyStateInfo); //创建属性
|
||||||
|
|
||||||
QMap<QString,propertyContentInfo> _mapPro;
|
|
||||||
private:
|
|
||||||
QFormLayout* createFormLayout(QWidget* parent);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public:
|
||||||
bool deleteEntity(const QString& id);
|
bool deleteEntity(const QString& id);
|
||||||
|
|
||||||
// 连接管理
|
// 连接管理
|
||||||
PowerConnection* createConnection(const QString& uuid,const QString& fromId, const QString& toId);
|
PowerConnection* createConnection(const QString& uuid,const QString& fromTerId, const QString& toTerId,const QString& fromId,const QString& toId);
|
||||||
QList<PowerConnection*> getConnectionsForTerminal(const QString& terminalId) const;
|
QList<PowerConnection*> getConnectionsForTerminal(const QString& terminalId) const;
|
||||||
void removeConnection(const QString& connId);
|
void removeConnection(const QString& connId);
|
||||||
bool validateConnection(const QString& fromTermId, const QString& toTermId) const;
|
bool validateConnection(const QString& fromTermId, const QString& toTermId) const;
|
||||||
|
|
@ -33,9 +33,11 @@ public:
|
||||||
QList<PowerConnection*> connectionsTo(const QString& elementId) const;
|
QList<PowerConnection*> connectionsTo(const QString& elementId) const;
|
||||||
QList<PowerConnection*> getConnectionsFor(const QString& entityId) const;
|
QList<PowerConnection*> getConnectionsFor(const QString& entityId) const;
|
||||||
PowerConnection* connection(const QString& conId) const;
|
PowerConnection* connection(const QString& conId) const;
|
||||||
|
PowerConnection* connection(const QString& fromPin,const QString& toPin);
|
||||||
|
QHash<QString,PowerConnection*> getAllConnections();
|
||||||
|
|
||||||
void saveToDB(const QString& path);
|
//void saveToDB(const QString& path);
|
||||||
void loadFromDB(const QString& path);
|
//void loadFromDB(const QString& path);
|
||||||
|
|
||||||
PowerEntity* getEntity(const QString& id) const;
|
PowerEntity* getEntity(const QString& id) const;
|
||||||
QList<PowerEntity*> findEntitiesByName(const QString& name) const;
|
QList<PowerEntity*> findEntitiesByName(const QString& name) const;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
#include "baseContentDlg.h"
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QDateEdit>
|
||||||
|
|
||||||
|
BaseContentDlg::BaseContentDlg(QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
{
|
||||||
|
setWindowFlags(Qt::Widget);
|
||||||
|
//this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseContentDlg::~BaseContentDlg()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QFormLayout* BaseContentDlg::createFormLayout(QWidget* parent)
|
||||||
|
{
|
||||||
|
QFormLayout* layout = new QFormLayout(parent);
|
||||||
|
layout->setHorizontalSpacing(20); // 标签与控件间距
|
||||||
|
layout->setVerticalSpacing(12); // 行间距
|
||||||
|
layout->setLabelAlignment(Qt::AlignRight); // 标签右对齐
|
||||||
|
layout->setContentsMargins(12, 12, 12, 12); // 内边距
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
#include "baseInfoDlg.h"
|
||||||
|
#include "ui_baseInfoDlg.h"
|
||||||
|
|
||||||
|
BaseInfoDlg::BaseInfoDlg(QWidget *parent)
|
||||||
|
: BaseContentDlg(parent)
|
||||||
|
, ui(new Ui::baseInfoDlg)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
//this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseInfoDlg::~BaseInfoDlg()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseInfoDlg::createGroupView(groupStateInfo infos)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QString,propertyStateInfo> BaseInfoDlg::getPropertyValue()
|
||||||
|
{
|
||||||
|
QMap<QString,propertyStateInfo> map;
|
||||||
|
|
||||||
|
propertyStateInfo uuid;
|
||||||
|
uuid.type = "UUID";
|
||||||
|
uuid.name = "global_uuid";
|
||||||
|
uuid.defaultValue = ui->le_uuid->text();
|
||||||
|
map.insert(uuid.name,uuid);
|
||||||
|
|
||||||
|
propertyStateInfo tag;
|
||||||
|
tag.type = "VARCHAR";
|
||||||
|
tag.name = "tag";
|
||||||
|
tag.defaultValue = ui->le_tag->text();
|
||||||
|
map.insert(tag.name,tag);
|
||||||
|
|
||||||
|
propertyStateInfo nsPath;
|
||||||
|
nsPath.type = "VARCHAR";
|
||||||
|
nsPath.name = "nspath";
|
||||||
|
nsPath.defaultValue = ui->le_nameSpace->text();
|
||||||
|
map.insert(nsPath.name,nsPath);
|
||||||
|
|
||||||
|
propertyStateInfo pName;
|
||||||
|
pName.type = "VARCHAR";
|
||||||
|
pName.name = "name";
|
||||||
|
pName.defaultValue = ui->le_name->text();
|
||||||
|
map.insert(pName.name,pName);
|
||||||
|
|
||||||
|
propertyStateInfo label;
|
||||||
|
label.type = "JSONB";
|
||||||
|
label.name = "label";
|
||||||
|
label.defaultValue = ui->le_label->text();
|
||||||
|
map.insert(label.name,label);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseInfoDlg::setPropertyValue(QMap<QString,propertyStateInfo> map)
|
||||||
|
{
|
||||||
|
for(auto &info:map)
|
||||||
|
{
|
||||||
|
propertyContentInfo pro = _mapPro[info.name];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
#include <QMdiSubWindow>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QStandardItem>
|
||||||
#include "drawingPanel.h"
|
#include "drawingPanel.h"
|
||||||
#include "diagramCavas.h"
|
#include "diagramCavas.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
@ -5,9 +9,7 @@
|
||||||
#include "graphicsItem/graphicsBaseItem.h"
|
#include "graphicsItem/graphicsBaseItem.h"
|
||||||
#include "topologyManager.h"
|
#include "topologyManager.h"
|
||||||
#include "powerEntity.h"
|
#include "powerEntity.h"
|
||||||
#include <QMdiSubWindow>
|
#include "componentIconManager.h"
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QJsonObject>
|
|
||||||
|
|
||||||
DiagramCavas::DiagramCavas(QWidget *parent)
|
DiagramCavas::DiagramCavas(QWidget *parent)
|
||||||
: QMdiArea(parent)
|
: QMdiArea(parent)
|
||||||
|
|
@ -23,7 +25,13 @@ DiagramCavas::~DiagramCavas()
|
||||||
void DiagramCavas::initial()
|
void DiagramCavas::initial()
|
||||||
{
|
{
|
||||||
//todo:读取数据并初始化
|
//todo:读取数据并初始化
|
||||||
//onSignal_addDrawingPanel(QString("electricElements"));
|
QList<pageInfo> lst = DataBase::GetInstance()->getAllPage();
|
||||||
|
for(auto info:lst)
|
||||||
|
{
|
||||||
|
TopologyManager::instance().createDiagram(QString::number(info.id),info.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//QString sPath = ComponentIconManager::instance().getIconPath("circuitBreaker",DM_edit,VI_thumbnail);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramCavas::onSignal_addDrawingPanel(PowerEntity* pItem,DiagramMode mode)
|
void DiagramCavas::onSignal_addDrawingPanel(PowerEntity* pItem,DiagramMode mode)
|
||||||
|
|
@ -275,7 +283,7 @@ void DiagramCavas::onSignal_deleteDiagram(DiagramInfo info)
|
||||||
|
|
||||||
void DiagramCavas::onSignal_selectDiagram(DiagramInfo info)
|
void DiagramCavas::onSignal_selectDiagram(DiagramInfo info)
|
||||||
{
|
{
|
||||||
PowerEntity* pEntity = TopologyManager::instance().findDiagram(info.id.toString());
|
PowerEntity* pEntity = TopologyManager::instance().findDiagram(QString::number(info.id.toInt()));
|
||||||
if(pEntity)
|
if(pEntity)
|
||||||
{
|
{
|
||||||
onSignal_loadPage(pEntity);
|
onSignal_loadPage(pEntity);
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include "statusBar.h"
|
#include "statusBar.h"
|
||||||
#include "dataBase.h"
|
#include "dataBase.h"
|
||||||
#include "powerEntity.h"
|
#include "powerEntity.h"
|
||||||
|
#include "topologyManager.h"
|
||||||
|
|
||||||
DrawingPanel::DrawingPanel(PowerEntity* pEntity,QWidget *parent,DiagramMode mode)
|
DrawingPanel::DrawingPanel(PowerEntity* pEntity,QWidget *parent,DiagramMode mode)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
|
@ -183,9 +184,9 @@ QJsonObject DrawingPanel::getDiagramInfo() const
|
||||||
{
|
{
|
||||||
QJsonObject connect;
|
QJsonObject connect;
|
||||||
connect["SrcNodeId"] = iter->nSrcNodeId.toString();
|
connect["SrcNodeId"] = iter->nSrcNodeId.toString();
|
||||||
connect["SrcPort"] = iter->nSrcPort;
|
connect["SrcPortId"] = iter->nSrcPortId.toString();
|
||||||
connect["DestNodeId"] = iter->nDestNodeId.toString();
|
connect["DestNodeId"] = iter->nDestNodeId.toString();
|
||||||
connect["DestPort"] = iter->nDestPort;
|
connect["DestPortId"] = iter->nDestPortId.toString();
|
||||||
arrConnect.append(connect);
|
arrConnect.append(connect);
|
||||||
}
|
}
|
||||||
obj["connections"] = arrConnect;
|
obj["connections"] = arrConnect;
|
||||||
|
|
@ -216,13 +217,24 @@ void DrawingPanel::loadNodes(QJsonObject obj)
|
||||||
{
|
{
|
||||||
QJsonObject connect = connectJson.toObject();
|
QJsonObject connect = connectJson.toObject();
|
||||||
QUuid srcId = QUuid(connect["SrcNodeId"].toString());
|
QUuid srcId = QUuid(connect["SrcNodeId"].toString());
|
||||||
int srcPort = connect["SrcPort"].toInt();
|
QUuid srcPortId = QUuid(connect["SrcPortId"].toString());
|
||||||
QUuid destId = QUuid(connect["DestNodeId"].toString());
|
QUuid destId = QUuid(connect["DestNodeId"].toString());
|
||||||
int destPort = connect["DestPort"].toInt();
|
QUuid destPortId = QUuid(connect["DestPortId"].toString());
|
||||||
|
|
||||||
if(_pModel)
|
PowerConnection* pCon = TopologyManager::instance().connection(srcPortId.toString(),destPortId.toString());
|
||||||
|
if(pCon)
|
||||||
{
|
{
|
||||||
_pModel->addConnectLline(srcId,destId,srcPort,destPort);
|
QString srcItemId = pCon->fromComponent();
|
||||||
|
QString destItemId = pCon->toComponent();
|
||||||
|
//todo:从拓扑结构中查找port的id
|
||||||
|
if(_pModel)
|
||||||
|
{
|
||||||
|
_pModel->addConnectLline(QUuid(srcItemId),QUuid(destItemId),srcPortId,destPortId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//todo:提示拓扑结构已改变
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,9 +88,10 @@ bool FixedPortsModel::addNodeItem(QUuid uuid,GraphicsBaseItem* pItem)
|
||||||
|
|
||||||
void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos)
|
void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos)
|
||||||
{
|
{
|
||||||
|
//todo:load图形时必有拓扑实体,关联到对应的entity
|
||||||
BaseProperty* pro = nullptr;
|
BaseProperty* pro = nullptr;
|
||||||
GraphicsBaseItem* item = nullptr;
|
GraphicsBaseItem* item = nullptr;
|
||||||
QMap<QUuid,BaseProperty*> mapData = TopologyManager::instance().getEntityData();
|
QMap<QUuid,BaseProperty*> mapData = TopologyManager::instance().getEntityData(); //加载的图形必定关联component(todo:完善判断条件,如判断拓扑节点)
|
||||||
if(mapData.contains(id))
|
if(mapData.contains(id))
|
||||||
{
|
{
|
||||||
pro = mapData[id];
|
pro = mapData[id];
|
||||||
|
|
@ -104,8 +105,19 @@ void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos)
|
||||||
}
|
}
|
||||||
else if(type == GIT_itemRect)
|
else if(type == GIT_itemRect)
|
||||||
{
|
{
|
||||||
item = new ElectricSvgItemRect(QRect(-15, -15, 30, 30));
|
item = new ElectricSvgItemRect(QRect(-15, -15, 30, 30),false);
|
||||||
item->setItemType(GIT_itemRect);
|
item->setItemType(GIT_itemRect);
|
||||||
|
QJsonArray portArr = pro->context()["port"].toArray();
|
||||||
|
for(QJsonValueRef portJson:portArr)
|
||||||
|
{
|
||||||
|
QJsonObject portObj = portJson.toObject();
|
||||||
|
QString portId = portObj["portId"].toString();
|
||||||
|
int x = portObj["x"].toInt();
|
||||||
|
int y = portObj["y"].toInt();
|
||||||
|
HandleType tye = HandleType(portObj["portType"].toInt());
|
||||||
|
PortPos locate = PortPos(portObj["locate"].toInt());
|
||||||
|
item->addPort(P_const,QPointF(x,y),portId,tye,locate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(type == GIT_bus)
|
else if(type == GIT_bus)
|
||||||
{
|
{
|
||||||
|
|
@ -116,10 +128,10 @@ void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos)
|
||||||
for(QJsonValueRef portJson:portArr)
|
for(QJsonValueRef portJson:portArr)
|
||||||
{
|
{
|
||||||
QJsonObject portObj = portJson.toObject();
|
QJsonObject portObj = portJson.toObject();
|
||||||
int nPort = portObj["portId"].toInt();
|
QString portId = portObj["portId"].toString();
|
||||||
int x = portObj["x"].toInt();
|
int x = portObj["x"].toInt();
|
||||||
int y = portObj["y"].toInt();
|
int y = portObj["y"].toInt();
|
||||||
item->addPort(p_movable,nPort,QPointF(x,y));
|
item->addPort(p_movable,QPointF(x,y),portId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(item)
|
if(item)
|
||||||
|
|
@ -184,23 +196,16 @@ void FixedPortsModel::loadNodeDataFromDataBase()
|
||||||
pData->setStation(info.station);
|
pData->setStation(info.station);
|
||||||
pData->setDataChanged(false);
|
pData->setDataChanged(false);
|
||||||
|
|
||||||
|
PowerEntity* pEntity = TopologyManager::instance().createEntity(EntityType::Component,info.uuid.toString(),info.name); //首先load所有data和entity,全局唯一
|
||||||
if(info.type == GIT_itemTri)
|
if(pEntity){
|
||||||
{
|
createTopoTerminalsByData(pEntity,info.context);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(info.type == GIT_itemRect)
|
}
|
||||||
{
|
|
||||||
//busStability bility = DataBase::GetInstance()->getBusStabilityById(info.id);
|
|
||||||
/*ElectricSvgItemRect_Property* pPro = dynamic_cast<ElectricSvgItemRect_Property*>(pData);
|
|
||||||
if(pPro)
|
|
||||||
{
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
else if(info.type == GIT_bus)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
QList<topologicInfo> lstTopo = DataBase::GetInstance()->getAllTopologics();
|
||||||
|
for(auto &info:lstTopo)
|
||||||
|
{
|
||||||
|
TopologyManager::instance().createConnection(QString::number(info.id),info.pin_from.toString(),info.pin_to.toString(),info.uuid_from.toString(),info.uuid_to.toString());
|
||||||
}
|
}
|
||||||
_dataInitialised = true;
|
_dataInitialised = true;
|
||||||
}
|
}
|
||||||
|
|
@ -213,7 +218,7 @@ void FixedPortsModel::loadNodeDataFromDataBase()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedPortsModel::addConnectLline(QUuid srcId,QUuid destId,int srcPort,int destPort)
|
void FixedPortsModel::addConnectLline(QUuid srcId,QUuid destId,QUuid srcPort,QUuid destPort)
|
||||||
{
|
{
|
||||||
GraphicsBaseItem* src = _nodeItem[srcId];
|
GraphicsBaseItem* src = _nodeItem[srcId];
|
||||||
GraphicsBaseItem* dest = _nodeItem[destId];
|
GraphicsBaseItem* dest = _nodeItem[destId];
|
||||||
|
|
@ -224,27 +229,28 @@ void FixedPortsModel::addConnectLline(QUuid srcId,QUuid destId,int srcPort,int d
|
||||||
pItem->setItemType(GIT_link);
|
pItem->setItemType(GIT_link);
|
||||||
_scene->addItem(pItem);
|
_scene->addItem(pItem);
|
||||||
|
|
||||||
ItemPort* ptSrc = src->getPortPtr(srcPort);
|
ItemPort* ptSrc = src->getPortById(srcPort.toString());
|
||||||
HandleType srcType = ptSrc->getType();
|
HandleType srcType = ptSrc->getType();
|
||||||
PortPos srcPos = ptSrc->portPos();
|
PortPos srcPos = ptSrc->portPos();
|
||||||
pItem->setStartPoint(ptSrc->scenePos());
|
pItem->setStartPoint(ptSrc->scenePos());
|
||||||
ptSrc->setConnect(pItem);
|
ptSrc->setConnect(pItem);
|
||||||
|
|
||||||
ItemPort* ptDest = nullptr;
|
ItemPort* ptDest = nullptr;
|
||||||
if(dest->getItemType() == GIT_bus) //母线动态创建port
|
ptDest = dest->getPortById(destPort.toString());
|
||||||
|
pItem->setEndPoint(ptDest->scenePos());
|
||||||
|
/*if(dest->getItemType() == GIT_bus) //母线动态创建port
|
||||||
{
|
{
|
||||||
ptDest = dest->getPortPtr(destPort);
|
ptDest = dest->getPortById(destPort.toString());
|
||||||
pItem->setEndPoint(ptDest->scenePos());
|
pItem->setEndPoint(ptDest->scenePos());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ptDest = dest->getPortPtr(destPort);
|
ptDest = dest->getPortById(destPort.toString());
|
||||||
pItem->setEndPoint(ptDest->scenePos());
|
pItem->setEndPoint(ptDest->scenePos());
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if(ptDest != nullptr)
|
if(ptDest != nullptr)
|
||||||
{
|
{
|
||||||
int destPort = ptDest->getTag();
|
|
||||||
HandleType destType = ptDest->getType();
|
HandleType destType = ptDest->getType();
|
||||||
PortPos destPos = ptDest->portPos();
|
PortPos destPos = ptDest->portPos();
|
||||||
|
|
||||||
|
|
@ -253,11 +259,6 @@ void FixedPortsModel::addConnectLline(QUuid srcId,QUuid destId,int srcPort,int d
|
||||||
ptDest->setConnect(pItem);
|
ptDest->setConnect(pItem);
|
||||||
|
|
||||||
addNodeItem(pItem->itemId(),pItem);
|
addNodeItem(pItem->itemId(),pItem);
|
||||||
/*auto srcParent = ptSrc->getParentPtr();
|
|
||||||
auto destParent = ptDest->getParentPtr();
|
|
||||||
|
|
||||||
srcParent->updateConnectData();
|
|
||||||
destParent->updateConnectData();*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -432,7 +433,7 @@ QVariant FixedPortsModel::nodeData(QUuid nodeId, NodeRole role) const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject FixedPortsModel::saveNode(QUuid const nodeId) const
|
/*QJsonObject FixedPortsModel::saveNode(QUuid const nodeId) const
|
||||||
{
|
{
|
||||||
QJsonObject nodeJson;
|
QJsonObject nodeJson;
|
||||||
|
|
||||||
|
|
@ -450,7 +451,7 @@ QJsonObject FixedPortsModel::saveNode(QUuid const nodeId) const
|
||||||
}
|
}
|
||||||
|
|
||||||
return nodeJson;
|
return nodeJson;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void FixedPortsModel::saveNode(int nPageId)
|
void FixedPortsModel::saveNode(int nPageId)
|
||||||
{
|
{
|
||||||
|
|
@ -489,7 +490,31 @@ void FixedPortsModel::saveNode(int nPageId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo:再循环一遍删除待删除项
|
//todo:增加判断,只在设置模式保存连接关系
|
||||||
|
QVector<Connection> vecCon = allConnections(); //保存当前页面中的连接关系
|
||||||
|
for(auto &con:vecCon)
|
||||||
|
{
|
||||||
|
QString fromPin = con.nSrcPortId.toString();
|
||||||
|
QString toPin = con.nDestPortId.toString();
|
||||||
|
PowerConnection* pCon = TopologyManager::instance().connection(fromPin,toPin);
|
||||||
|
if(pCon)
|
||||||
|
{
|
||||||
|
DataState state = pCon->state();
|
||||||
|
switch (state) {
|
||||||
|
case DataState::unchanged:
|
||||||
|
break;
|
||||||
|
case DataState::prepareDelete:
|
||||||
|
DataBase::GetInstance()->deleteTopologic(con.nSrcPortId,con.nDestPortId);
|
||||||
|
TopologyManager::instance().removeConnection(pCon->id());
|
||||||
|
break;
|
||||||
|
case DataState::changed:
|
||||||
|
DataBase::GetInstance()->insertTopologic(nPageId,con.nSrcNodeId,con.nDestNodeId,con.nSrcPortId,con.nDestPortId,0,"",0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedPortsModel::onSignal_ifExits(QUuid id,const QString& str,int type,GraphicsBaseItem* pitem)
|
void FixedPortsModel::onSignal_ifExits(QUuid id,const QString& str,int type,GraphicsBaseItem* pitem)
|
||||||
|
|
@ -550,7 +575,7 @@ void FixedPortsModel::onSignal_ifExits(QUuid id,const QString& str,int type,Grap
|
||||||
PowerEntity* pEntity = TopologyManager::instance().createEntity(EntityType::Component,id.toString(),str);
|
PowerEntity* pEntity = TopologyManager::instance().createEntity(EntityType::Component,id.toString(),str);
|
||||||
if(pEntity)
|
if(pEntity)
|
||||||
pitem->setEntity(pEntity);
|
pitem->setEntity(pEntity);
|
||||||
createTopoTerminals(pitem); //创建item对象的逻辑接线点
|
createTopoTerminalsByItem(pitem); //创建item对象的逻辑接线点
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -683,13 +708,13 @@ ConfigurationDiagram* FixedPortsModel::getTopologyDiagram()
|
||||||
return dynamic_cast<ConfigurationDiagram*>(_pEntity);
|
return dynamic_cast<ConfigurationDiagram*>(_pEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedPortsModel::createTopoTerminals(GraphicsBaseItem* pItem)
|
void FixedPortsModel::createTopoTerminalsByItem(GraphicsBaseItem* pItem)
|
||||||
{
|
{
|
||||||
PowerEntity* pEntity = pItem->entity();
|
PowerEntity* pEntity = pItem->entity();
|
||||||
|
|
||||||
if(pEntity)
|
if(pEntity)
|
||||||
{
|
{
|
||||||
QMap<QString,ItemPort*> mapPorts = pItem->getPorts(); //创建对应
|
QMap<QString,ItemPort*> mapPorts = pItem->getPorts(); //创建实体port对应的拓扑port
|
||||||
for(auto &port:mapPorts)
|
for(auto &port:mapPorts)
|
||||||
{
|
{
|
||||||
TerminalType terType;
|
TerminalType terType;
|
||||||
|
|
@ -713,6 +738,36 @@ void FixedPortsModel::createTopoTerminals(GraphicsBaseItem* pItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FixedPortsModel::createTopoTerminalsByData(PowerEntity* pParent,QJsonObject componentCon)
|
||||||
|
{
|
||||||
|
QJsonArray portsArray = componentCon["port"].toArray();
|
||||||
|
for (QJsonValueRef portJson : portsArray) //每个属性的状态信息
|
||||||
|
{
|
||||||
|
QJsonObject node = portJson.toObject();
|
||||||
|
QString portId = node["portId"].toString();
|
||||||
|
int x = node["x"].toInt();
|
||||||
|
int y = node["y"].toInt();
|
||||||
|
PortPos locate = PortPos(node["locate"].toInt());
|
||||||
|
HandleType portType = HandleType(node["portType"].toInt());
|
||||||
|
|
||||||
|
TerminalType terType;
|
||||||
|
switch (portType) {
|
||||||
|
case T_lineIn:
|
||||||
|
terType = TerminalType::PowerInput;
|
||||||
|
break;
|
||||||
|
case T_lineOut:
|
||||||
|
terType = TerminalType::PowerOutput;
|
||||||
|
break;
|
||||||
|
case T_lineInOut:
|
||||||
|
terType = TerminalType::PowerConnect;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
TopologyManager::instance().createTerminal(pParent->id(),terType,"",QPointF(x,y),portId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool FixedPortsModel::isItemValid(GraphicsBaseItem* pItem)
|
bool FixedPortsModel::isItemValid(GraphicsBaseItem* pItem)
|
||||||
{
|
{
|
||||||
BaseProperty* pData = pItem->getProperty();
|
BaseProperty* pData = pItem->getProperty();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#include <QSvgRenderer>
|
#include <QSvgRenderer>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
ElectricSvgItem::ElectricSvgItem(const QRect &rect, QGraphicsItem *parent)
|
ElectricSvgItem::ElectricSvgItem(const QRect &rect, bool autoGenPort,QGraphicsItem *parent)
|
||||||
: GraphicsBaseItem(parent),m_pRender(nullptr)
|
: GraphicsBaseItem(parent),m_pRender(nullptr)
|
||||||
{
|
{
|
||||||
m_lastBoudingRect = rect;
|
m_lastBoudingRect = rect;
|
||||||
|
|
|
||||||
|
|
@ -37,14 +37,14 @@ void ElectricSvgItemBus::updateConnectData()
|
||||||
{
|
{
|
||||||
for(auto ptr:m_mapPort)
|
for(auto ptr:m_mapPort)
|
||||||
{
|
{
|
||||||
if(ptr->connected())
|
//if(ptr->connected())
|
||||||
{
|
{
|
||||||
QJsonObject port;
|
QJsonObject port;
|
||||||
port["portId"] = ptr->getId();
|
port["portId"] = ptr->getId();
|
||||||
auto pLine = ptr->getConnectPtr();
|
auto pLine = ptr->getConnectPtr();
|
||||||
//port["connectedItem"] = pLine->getOppositeId(m_itemId).toString();
|
|
||||||
port["x"] = ptr->pos().x();
|
port["x"] = ptr->pos().x();
|
||||||
port["y"] = ptr->pos().y();
|
port["y"] = ptr->pos().y();
|
||||||
|
port["portType"] = ptr->getType();
|
||||||
arr.push_back(port);
|
arr.push_back(port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
|
|
||||||
ElectricSvgItemRect::ElectricSvgItemRect(const QRect &rect, QGraphicsItem *parent)
|
ElectricSvgItemRect::ElectricSvgItemRect(const QRect &rect, bool genNewPort, QGraphicsItem *parent)
|
||||||
: ElectricSvgItem(rect,parent)
|
: ElectricSvgItem(rect,parent)
|
||||||
{
|
{
|
||||||
loadSvg(":/images/element/svg_rect.svg");
|
loadSvg(":/images/element/svg_rect.svg");
|
||||||
|
|
@ -38,8 +38,11 @@ ElectricSvgItemRect::ElectricSvgItemRect(const QRect &rect, QGraphicsItem *paren
|
||||||
|
|
||||||
m_dRatioX = 0.5;
|
m_dRatioX = 0.5;
|
||||||
|
|
||||||
addPort(P_const,QPointF(boundingRect().right() - boundingRect().width() * m_dRatioX, boundingRect().top()),QUuid::createUuid().toString(),T_lineIn,P_top);
|
if(genNewPort)
|
||||||
addPort(P_const,QPointF(boundingRect().right() - boundingRect().width() * m_dRatioX, boundingRect().bottom()),QUuid::createUuid().toString(),T_lineOut,P_down);
|
{
|
||||||
|
addPort(P_const,QPointF(boundingRect().right() - boundingRect().width() * m_dRatioX, boundingRect().top()),QUuid::createUuid().toString(),T_lineIn,P_top);
|
||||||
|
addPort(P_const,QPointF(boundingRect().right() - boundingRect().width() * m_dRatioX, boundingRect().bottom()),QUuid::createUuid().toString(),T_lineOut,P_down);
|
||||||
|
}
|
||||||
|
|
||||||
qRegisterMetaType<PropertyInfo>("PropertyInfo"); //注册自定义数据类型
|
qRegisterMetaType<PropertyInfo>("PropertyInfo"); //注册自定义数据类型
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -223,11 +223,11 @@ int GraphicsBaseItem::addPort(PortState typ,QPointF vec,QString id,HandleType hT
|
||||||
pPort->setPos(vec);
|
pPort->setPos(vec);
|
||||||
pPort->setParent(this);
|
pPort->setParent(this);
|
||||||
|
|
||||||
m_mapPort.insert(QString::number(_portId++),pPort);
|
m_mapPort.insert(pPort->getId(),pPort);
|
||||||
return ntagId;
|
return ntagId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsBaseItem::addPort(PortState typ,int ntagId,QPointF vec)
|
/*void GraphicsBaseItem::addPort(PortState typ,int ntagId,QPointF vec)
|
||||||
{
|
{
|
||||||
if(typ == p_movable)
|
if(typ == p_movable)
|
||||||
{
|
{
|
||||||
|
|
@ -240,6 +240,17 @@ void GraphicsBaseItem::addPort(PortState typ,int ntagId,QPointF vec)
|
||||||
|
|
||||||
m_mapPort.insert(QString::number(_portId++),pPort);
|
m_mapPort.insert(QString::number(_portId++),pPort);
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
ItemPort* GraphicsBaseItem::getPortById(QString id) const
|
||||||
|
{
|
||||||
|
for(auto iter:m_mapPort)
|
||||||
|
{
|
||||||
|
QString portId = iter->getId();
|
||||||
|
if(portId == id)
|
||||||
|
return iter;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemPort* GraphicsBaseItem::getPortPtr(int n) const
|
ItemPort* GraphicsBaseItem::getPortPtr(int n) const
|
||||||
|
|
@ -296,12 +307,15 @@ void GraphicsBaseItem::updateConnectData()
|
||||||
{
|
{
|
||||||
for(auto ptr:m_mapPort)
|
for(auto ptr:m_mapPort)
|
||||||
{
|
{
|
||||||
if(ptr->connected())
|
//if(ptr->connected())
|
||||||
{
|
{
|
||||||
QJsonObject port;
|
QJsonObject port;
|
||||||
port["portId"] = ptr->getId();
|
port["portId"] = ptr->getId();
|
||||||
auto pLine = ptr->getConnectPtr();
|
auto pLine = ptr->getConnectPtr();
|
||||||
//port["connectedItem"] = pLine->getOppositeId(m_itemId).toString();
|
port["x"] = ptr->pos().x();
|
||||||
|
port["y"] = ptr->pos().y();
|
||||||
|
port["locate"] = ptr->portPos();
|
||||||
|
port["portType"] = ptr->getType();
|
||||||
arr.push_back(port);
|
arr.push_back(port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
|
#include <QMessageBox>
|
||||||
#include "itemPropertyDlg.h"
|
#include "itemPropertyDlg.h"
|
||||||
#include "propertyContentDlg.h"
|
#include "propertyContentDlg.h"
|
||||||
#include "dataManager.h"
|
#include "dataManager.h"
|
||||||
#include "graphicsItem/graphicsBaseItem.h"
|
#include "graphicsItem/graphicsBaseItem.h"
|
||||||
#include "ui_itemPropertyDlg.h"
|
#include "ui_itemPropertyDlg.h"
|
||||||
#include <QMessageBox>
|
#include "baseContentDlg.h"
|
||||||
|
#include "baseInfoDlg.h"
|
||||||
|
|
||||||
ItemPropertyDlg::ItemPropertyDlg(QWidget *parent)
|
ItemPropertyDlg::ItemPropertyDlg(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
|
|
@ -89,7 +91,7 @@ void ItemPropertyDlg::onGroupSelected(const QString& str)
|
||||||
createGroupView(str);
|
createGroupView(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyContentDlg* pDlg = qobject_cast<PropertyContentDlg*>(groupViews_[str]);
|
BaseContentDlg* pDlg = qobject_cast<BaseContentDlg*>(groupViews_[str]);
|
||||||
if(pDlg)
|
if(pDlg)
|
||||||
{
|
{
|
||||||
QMap<QString,propertyStateInfo> valueMap;
|
QMap<QString,propertyStateInfo> valueMap;
|
||||||
|
|
@ -106,7 +108,18 @@ void ItemPropertyDlg::onGroupSelected(const QString& str)
|
||||||
|
|
||||||
void ItemPropertyDlg::createGroupView(const QString& str)
|
void ItemPropertyDlg::createGroupView(const QString& str)
|
||||||
{
|
{
|
||||||
PropertyContentDlg* contentDlg = new PropertyContentDlg(ui->stackedWidget);
|
//todo:基础信息、间隔信息、动态界面在此分支
|
||||||
|
BaseContentDlg* contentDlg = nullptr;
|
||||||
|
if(str == QString("component") || str == QString::fromWCharArray(L"基本信息")){
|
||||||
|
contentDlg = new BaseInfoDlg(ui->stackedWidget);
|
||||||
|
}
|
||||||
|
else if(str == "bayInfo" || str == QString::fromWCharArray(L"间隔信息")){
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
contentDlg = new PropertyContentDlg(ui->stackedWidget);
|
||||||
|
}
|
||||||
|
|
||||||
if(contentDlg)
|
if(contentDlg)
|
||||||
{
|
{
|
||||||
contentDlg->createGroupView(groupInfo_[str]);
|
contentDlg->createGroupView(groupInfo_[str]);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include "powerConnection.h"
|
#include "powerConnection.h"
|
||||||
|
|
||||||
PowerConnection::PowerConnection(const QString& uuid,const QString& fromTerminal, const QString& toTerminal, QObject* parent)
|
PowerConnection::PowerConnection(const QString& uuid,const QString& fromTerminal, const QString& toTerminal,const QString& fromId,const QString& toId, QObject* parent)
|
||||||
: QObject(parent),m_uuid(uuid), m_fromTerminal(fromTerminal), m_toTerminal(toTerminal) {}
|
: QObject(parent),m_uuid(uuid), m_fromTerminal(fromTerminal), m_toTerminal(toTerminal),m_fromComponent(fromId),m_toComponent(toId) {}
|
||||||
|
|
||||||
QJsonObject PowerConnection::toJson() const {
|
QJsonObject PowerConnection::toJson() const {
|
||||||
QJsonObject obj;
|
QJsonObject obj;
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,8 @@
|
||||||
#include <QDateEdit>
|
#include <QDateEdit>
|
||||||
|
|
||||||
PropertyContentDlg::PropertyContentDlg(QWidget *parent)
|
PropertyContentDlg::PropertyContentDlg(QWidget *parent)
|
||||||
: QDialog(parent)
|
: BaseContentDlg(parent)
|
||||||
,_layout(nullptr)
|
|
||||||
{
|
{
|
||||||
setWindowFlags(Qt::Widget);
|
|
||||||
//this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
|
||||||
_layout = new QVBoxLayout(this);
|
_layout = new QVBoxLayout(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -151,7 +148,7 @@ QWidget* PropertyContentDlg::createEditor(propertyStateInfo pro)
|
||||||
return pWidget;
|
return pWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString,propertyStateInfo> PropertyContentDlg::getPropertyValue() const
|
QMap<QString,propertyStateInfo> PropertyContentDlg::getPropertyValue()
|
||||||
{
|
{
|
||||||
QMap<QString,propertyStateInfo> map;
|
QMap<QString,propertyStateInfo> map;
|
||||||
|
|
||||||
|
|
@ -334,13 +331,3 @@ void PropertyContentDlg::setPropertyValue(QMap<QString,propertyStateInfo> map)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QFormLayout* PropertyContentDlg::createFormLayout(QWidget* parent)
|
|
||||||
{
|
|
||||||
QFormLayout* layout = new QFormLayout(parent);
|
|
||||||
layout->setHorizontalSpacing(20); // 标签与控件间距
|
|
||||||
layout->setVerticalSpacing(12); // 行间距
|
|
||||||
layout->setLabelAlignment(Qt::AlignRight); // 标签右对齐
|
|
||||||
layout->setContentsMargins(12, 12, 12, 12); // 内边距
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -91,12 +91,12 @@ bool TopologyManager::deleteEntity(const QString& id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PowerConnection* TopologyManager::createConnection(const QString& connId,const QString& fromId, const QString& toId)
|
PowerConnection* TopologyManager::createConnection(const QString& connId,const QString& fromTerId, const QString& toTerId,const QString& fromId,const QString& toId)
|
||||||
{
|
{
|
||||||
// 验证有效性
|
// 验证有效性
|
||||||
if (!m_allTerminals.contains(fromId) ||
|
if (!m_allTerminals.contains(fromTerId) ||
|
||||||
!m_allTerminals.contains(toId) ||
|
!m_allTerminals.contains(toTerId) ||
|
||||||
fromId == toId)
|
fromTerId == toTerId)
|
||||||
{
|
{
|
||||||
qWarning() << "Invalid connection endpoints";
|
qWarning() << "Invalid connection endpoints";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -104,20 +104,20 @@ PowerConnection* TopologyManager::createConnection(const QString& connId,const Q
|
||||||
|
|
||||||
// 防止重复连接
|
// 防止重复连接
|
||||||
foreach (auto conn, m_connections) {
|
foreach (auto conn, m_connections) {
|
||||||
if (conn->fromTerminalId() == fromId &&
|
if (conn->fromTerminalId() == fromTerId &&
|
||||||
conn->toTerminalId() == toId)
|
conn->toTerminalId() == toTerId)
|
||||||
{
|
{
|
||||||
return conn; // 返回已存在的连接
|
return conn; // 返回已存在的连接
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建新连接
|
// 创建新连接
|
||||||
PowerConnection* conn = new PowerConnection(connId,fromId, toId);
|
PowerConnection* conn = new PowerConnection(connId,fromTerId, toTerId,fromId,toId);
|
||||||
m_connections[connId] = conn;
|
m_connections[connId] = conn;
|
||||||
|
|
||||||
// 更新索引
|
// 更新索引
|
||||||
m_connectionIndex.insert(fromId, conn);
|
m_connectionIndex.insert(fromTerId, conn);
|
||||||
m_connectionIndex.insert(toId, conn);
|
m_connectionIndex.insert(toTerId, conn);
|
||||||
|
|
||||||
emit connectionCreated(connId);
|
emit connectionCreated(connId);
|
||||||
return conn;
|
return conn;
|
||||||
|
|
@ -217,7 +217,22 @@ PowerConnection* TopologyManager::connection(const QString& conId) const
|
||||||
return m_connections.value(conId,nullptr);
|
return m_connections.value(conId,nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TopologyManager::saveToDB(const QString& path)
|
PowerConnection* TopologyManager::connection(const QString& fromPin,const QString& toPin)
|
||||||
|
{
|
||||||
|
for(auto &con:m_connections)
|
||||||
|
{
|
||||||
|
if(con->fromTerminalId() == fromPin && con->toTerminalId() == toPin)
|
||||||
|
return con;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QHash<QString,PowerConnection*> TopologyManager::getAllConnections()
|
||||||
|
{
|
||||||
|
return m_connections;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*void TopologyManager::saveToDB(const QString& path)
|
||||||
{
|
{
|
||||||
QJsonObject root;
|
QJsonObject root;
|
||||||
|
|
||||||
|
|
@ -242,9 +257,9 @@ void TopologyManager::saveToDB(const QString& path)
|
||||||
root["connections"] = connectionsArray;
|
root["connections"] = connectionsArray;
|
||||||
|
|
||||||
//todo:写入到数据库
|
//todo:写入到数据库
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void TopologyManager::loadFromDB(const QString& path)
|
/*void TopologyManager::loadFromDB(const QString& path)
|
||||||
{
|
{
|
||||||
//todo::将读到的字为json
|
//todo::将读到的字为json
|
||||||
QString strJson;
|
QString strJson;
|
||||||
|
|
@ -301,7 +316,7 @@ void TopologyManager::loadFromDB(const QString& path)
|
||||||
connObj["to"].toString()
|
connObj["to"].toString()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
PowerEntity* TopologyManager::getEntity(const QString& id) const
|
PowerEntity* TopologyManager::getEntity(const QString& id) const
|
||||||
{
|
{
|
||||||
|
|
@ -324,9 +339,12 @@ PowerEntity* TopologyManager::createDiagram(const QString& id,const QString& nam
|
||||||
{
|
{
|
||||||
PowerEntity* entity = nullptr;
|
PowerEntity* entity = nullptr;
|
||||||
|
|
||||||
entity = new ConfigurationDiagram(id,name);
|
if(!m_diagrams.contains(id))
|
||||||
|
{
|
||||||
|
entity = new ConfigurationDiagram(id,name);
|
||||||
|
m_diagrams.insert(entity->id(), entity);
|
||||||
|
}
|
||||||
|
|
||||||
m_diagrams.insert(entity->id(), entity);
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <QMessageBox>
|
||||||
#include "graphicsItem/graphicsBaseItem.h"
|
#include "graphicsItem/graphicsBaseItem.h"
|
||||||
#include "graphicsItem/handleText.h"
|
#include "graphicsItem/handleText.h"
|
||||||
#include "powerEntity.h"
|
#include "powerEntity.h"
|
||||||
|
|
@ -401,12 +402,22 @@ void BaseSelector::dropEvent(QGraphicsSceneDragDropEvent *event, DesignerScene*)
|
||||||
{
|
{
|
||||||
if (event->mimeData()->hasText()) {
|
if (event->mimeData()->hasText()) {
|
||||||
QString text = event->mimeData()->text();
|
QString text = event->mimeData()->text();
|
||||||
|
QString uuid = QString::fromLocal8Bit(event->mimeData()->data("application/id"));
|
||||||
// 根据拖拽的数据创建相应的图形项并添加到场景中
|
// 根据拖拽的数据创建相应的图形项并添加到场景中
|
||||||
// 例如创建一个文本项
|
|
||||||
QGraphicsTextItem *textItem = new QGraphicsTextItem(text);
|
QGraphicsTextItem *textItem = new QGraphicsTextItem(text);
|
||||||
textItem->setPos(event->scenePos());
|
textItem->setPos(event->scenePos());
|
||||||
//addItem(textItem);
|
//addItem(textItem);
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
|
|
||||||
|
//根据data数据新增拖拽的item
|
||||||
|
QMap<QUuid,GraphicsBaseItem*> items = _model->allItems();
|
||||||
|
if(items.contains(QUuid(uuid))){
|
||||||
|
QMessageBox::information(NULL, QString::fromWCharArray(L"提示"), QString::fromWCharArray(L"此对象在当前页已存在"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
_model->addNodeItem(QUuid(uuid),event->scenePos());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ void ConnectingSelector::createConnectLline(GraphicsBaseItem* connectingItem,Gra
|
||||||
pItem->setEndPoint(ptDest->scenePos());
|
pItem->setEndPoint(ptDest->scenePos());
|
||||||
}
|
}
|
||||||
|
|
||||||
_model->createTopoTerminals(touchedItem); //创建port时创建对应的terminal
|
_model->createTopoTerminalsByItem(touchedItem); //创建port时创建对应的terminal
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -129,9 +129,13 @@ void ConnectingSelector::createConnectLline(GraphicsBaseItem* connectingItem,Gra
|
||||||
{
|
{
|
||||||
QString destPortId = ptDest->getId(); //port自身id
|
QString destPortId = ptDest->getId(); //port自身id
|
||||||
|
|
||||||
if(TopologyManager::instance().validateConnection(srcPortId,destPortId))
|
if(TopologyManager::instance().validateConnection(srcPortId,destPortId)){
|
||||||
TopologyManager::instance().createConnection(uid.toString(),srcPortId,destPortId); //创建拓扑连接(逻辑)
|
PowerConnection* pCon = TopologyManager::instance().createConnection(uid.toString(),srcPortId,destPortId,connectingItem->itemId().toString(),touchedItem->itemId().toString()); //创建拓扑连接(逻辑)
|
||||||
|
if(pCon)
|
||||||
|
pCon->setState(DataState::changed);
|
||||||
|
}
|
||||||
|
|
||||||
|
pItem->setConnection(Connection(connectingItem->itemId(),QUuid(srcPortId),ptSrc->getType(),ptSrc->portPos(),touchedItem->itemId(),QUuid(destPortId),ptDest->getType(),ptDest->portPos()));
|
||||||
_model->addNodeItem(pItem->itemId(),pItem);
|
_model->addNodeItem(pItem->itemId(),pItem);
|
||||||
auto srcParent = ptSrc->getParentPtr();
|
auto srcParent = ptSrc->getParentPtr();
|
||||||
auto destParent = ptDest->getParentPtr();
|
auto destParent = ptDest->getParentPtr();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,339 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>baseInfoDlg</class>
|
||||||
|
<widget class="QWidget" name="baseInfoDlg">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>736</width>
|
||||||
|
<height>620</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1,1,0,1,0,1,0,1,0,1">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalSpacing">
|
||||||
|
<number>8</number>
|
||||||
|
</property>
|
||||||
|
<property name="verticalSpacing">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0" colspan="11">
|
||||||
|
<widget class="QLabel" name="label_title">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>30</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">border:4px double dark;</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>UUID</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" colspan="6">
|
||||||
|
<widget class="QLineEdit" name="le_uuid">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="7" rowspan="2" colspan="4">
|
||||||
|
<widget class="QWidget" name="widget" native="true">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">border:2px dashed black;
|
||||||
|
border-radius:5px;</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>TAG</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1" colspan="2">
|
||||||
|
<widget class="QLineEdit" name="le_tag">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>命名空间</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1" colspan="6">
|
||||||
|
<widget class="QLineEdit" name="le_nameSpace">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="7">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>名称</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="8" colspan="3">
|
||||||
|
<widget class="QLineEdit" name="le_name">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>标签</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1" colspan="2">
|
||||||
|
<widget class="QLineEdit" name="le_label">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="3">
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>注释</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="4" colspan="7">
|
||||||
|
<widget class="QLineEdit" name="le_description">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="text">
|
||||||
|
<string>电网</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1" colspan="2">
|
||||||
|
<widget class="QComboBox" name="cb_grid"/>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="3">
|
||||||
|
<widget class="QLabel" name="label_8">
|
||||||
|
<property name="text">
|
||||||
|
<string>区域</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="4" colspan="3">
|
||||||
|
<widget class="QComboBox" name="cb_zone"/>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="7">
|
||||||
|
<widget class="QLabel" name="label_9">
|
||||||
|
<property name="text">
|
||||||
|
<string>子站</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="8" colspan="3">
|
||||||
|
<widget class="QComboBox" name="cb_station"/>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QLabel" name="label_10">
|
||||||
|
<property name="text">
|
||||||
|
<string>间隔名称</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="1" colspan="6">
|
||||||
|
<widget class="QLineEdit" name="le_nameSpace_2">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="7">
|
||||||
|
<widget class="QLabel" name="label_11">
|
||||||
|
<property name="text">
|
||||||
|
<string>序号</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="8">
|
||||||
|
<widget class="QLineEdit" name="le_idx_1">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="9">
|
||||||
|
<widget class="QLabel" name="label_12">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>--</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="10">
|
||||||
|
<widget class="QLineEdit" name="le_idx_2">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0">
|
||||||
|
<widget class="QLabel" name="label_13">
|
||||||
|
<property name="text">
|
||||||
|
<string>联结 从</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="1" colspan="4">
|
||||||
|
<widget class="QLineEdit" name="le_from">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="5">
|
||||||
|
<widget class="QLabel" name="label_14">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>23</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>到</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="6" colspan="5">
|
||||||
|
<widget class="QLineEdit" name="le_to">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0">
|
||||||
|
<widget class="QLabel" name="label_15">
|
||||||
|
<property name="text">
|
||||||
|
<string>服役状态</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="1">
|
||||||
|
<widget class="QRadioButton" name="rb_inService">
|
||||||
|
<property name="text">
|
||||||
|
<string>IN 服役中</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="2" colspan="2">
|
||||||
|
<widget class="QRadioButton" name="rb_outService">
|
||||||
|
<property name="text">
|
||||||
|
<string>OUT 服役外</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="7">
|
||||||
|
<widget class="QLabel" name="label_16">
|
||||||
|
<property name="text">
|
||||||
|
<string>状态</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="8" colspan="3">
|
||||||
|
<widget class="QLineEdit" name="le_to_2">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="1" colspan="10">
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>30</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>设备库</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="1" colspan="10">
|
||||||
|
<widget class="QWidget" name="widget_runTime" native="true">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">border:1px dashed black;</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>642</width>
|
<width>879</width>
|
||||||
<height>552</height>
|
<height>672</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
|
@ -105,13 +105,13 @@
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>0</width>
|
||||||
<height>20</height>
|
<height>30</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>80</width>
|
<width>80</width>
|
||||||
<height>20</height>
|
<height>30</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
|
|
@ -132,13 +132,13 @@
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>0</width>
|
||||||
<height>20</height>
|
<height>30</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>80</width>
|
<width>80</width>
|
||||||
<height>20</height>
|
<height>30</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ project(diagramUtils)
|
||||||
set(DIAGRAMUTILS_HEADER_FILES
|
set(DIAGRAMUTILS_HEADER_FILES
|
||||||
include/logger.h
|
include/logger.h
|
||||||
include/dataManager.h
|
include/dataManager.h
|
||||||
|
include/componentIconManager.h
|
||||||
../common/include/global.h
|
../common/include/global.h
|
||||||
../common/include/compiler.hpp
|
../common/include/compiler.hpp
|
||||||
../common/include/export.hpp
|
../common/include/export.hpp
|
||||||
|
|
@ -13,6 +14,7 @@ set(DIAGRAMUTILS_SOURCE_FILES
|
||||||
source/logger.cpp
|
source/logger.cpp
|
||||||
source/dataBase.cpp
|
source/dataBase.cpp
|
||||||
source/dataManager.cpp
|
source/dataManager.cpp
|
||||||
|
source/componentIconManager.cpp
|
||||||
../common/source/global.cpp
|
../common/source/global.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef COMPONENTICONMANAGER_H
|
||||||
|
#define COMPONENTICONMANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "global.h"
|
||||||
|
#include "export.hpp"
|
||||||
|
/****图标管理类
|
||||||
|
* 对各种状态图标的管理
|
||||||
|
*****/
|
||||||
|
|
||||||
|
class DIAGRAM_DESIGNER_PUBLIC ComponentIconManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ComponentIconManager(QObject *parent = nullptr);
|
||||||
|
~ComponentIconManager();
|
||||||
|
static ComponentIconManager& instance();
|
||||||
|
public:
|
||||||
|
void initialData();
|
||||||
|
void addIcon(QString tpe,DiagramMode mode,VariantIcon varIcon,QString iconPath);
|
||||||
|
QString getIconPath(QString tpe,DiagramMode mode,VariantIcon varIcon);
|
||||||
|
private:
|
||||||
|
QMap<QString,QMap<DiagramMode,QMap<VariantIcon,QString>>> _mapIcon;
|
||||||
|
bool _init;
|
||||||
|
};
|
||||||
|
#endif // COMPONENTICONMANAGER_H
|
||||||
|
|
@ -30,11 +30,16 @@ public:
|
||||||
bool insertStation(int zoneId,QString name,QString description,bool isLocal,int op);
|
bool insertStation(int zoneId,QString name,QString description,bool isLocal,int op);
|
||||||
bool insertGrid(QString name,QString description,int op);
|
bool insertGrid(QString name,QString description,int op);
|
||||||
bool insertZone(int grid_id,QString name,QString description,int op);
|
bool insertZone(int grid_id,QString name,QString description,int op);
|
||||||
bool insertTopologic(int page_id,QUuid uuid_from,QUuid uuid_to,int flag,QString description,int op);
|
bool insertTopologic(int page_id,QUuid uuid_from,QUuid uuid_to,QUuid pin_from,QUuid pin_to,int flag,QString description,int op);
|
||||||
|
|
||||||
bool insertBus_stability(int componentId,double resistance,bool anchor_v,double uv_alarm,double ov_alarm,bool anchor_i,double ui_alarm,double oi_alarm,int op);
|
QString getGridNameById(int);
|
||||||
bool updateBus_stability(int componentId,double resistance,bool anchor_v,double uv_alarm,double ov_alarm,bool anchor_i,double ui_alarm,double oi_alarm,int op);
|
QString getZoneNameById(int);
|
||||||
busStability getBusStabilityById(int componentId);
|
QString getStationNameById(int);
|
||||||
|
|
||||||
|
QList<topologicInfo> getAllTopologics();
|
||||||
|
int topologicExist(QUuid fromPin,QUuid toPin);
|
||||||
|
topologicInfo getTopologicById(int id);
|
||||||
|
bool deleteTopologic(QUuid fromPin,QUuid toPin);
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
bool updateComponent(QUuid uuid,QString tag,QString name,QJsonObject context);
|
bool updateComponent(QUuid uuid,QString tag,QString name,QJsonObject context);
|
||||||
bool insertComponent(QUuid uuid,QString modelName,QString nspath,QString tag,QString name,QString description,QString grid,QString zone,QString station,int type,bool inService,int state,QJsonObject connected_bus,QJsonObject label,QJsonObject context,int page_id,int op);
|
bool insertComponent(QUuid uuid,QString modelName,QString nspath,QString tag,QString name,QString description,QString grid,QString zone,QString station,int type,bool inService,int state,QJsonObject connected_bus,QJsonObject label,QJsonObject context,int page_id,int op);
|
||||||
|
|
@ -49,7 +54,7 @@ public:
|
||||||
int getPageIdByName(QString name);
|
int getPageIdByName(QString name);
|
||||||
bool updatePage(QString tag,QString name,QJsonObject context);
|
bool updatePage(QString tag,QString name,QJsonObject context);
|
||||||
QJsonObject getPageContextByName(QString name);
|
QJsonObject getPageContextByName(QString name);
|
||||||
QStringList getAllPage();
|
QList<pageInfo> getAllPage();
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
bool deleteComponentById(int id);
|
bool deleteComponentById(int id);
|
||||||
void select();
|
void select();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
#include "componentIconManager.h"
|
||||||
|
|
||||||
|
ComponentIconManager& ComponentIconManager::instance()
|
||||||
|
{
|
||||||
|
//采用静态局部变量的方式,静态局部变量的初始化是在第一次访问时,以后的调用不会多次初始化,并且生命周期和程序一致
|
||||||
|
static ComponentIconManager instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
ComponentIconManager::ComponentIconManager(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
_init = false;
|
||||||
|
initialData();
|
||||||
|
}
|
||||||
|
|
||||||
|
ComponentIconManager::~ComponentIconManager()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComponentIconManager::initialData()
|
||||||
|
{
|
||||||
|
addIcon("circuitBreaker",DM_edit,VI_thumbnail,"abcde");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComponentIconManager::addIcon(QString sType,DiagramMode mode,VariantIcon varIcon, QString iconPath)
|
||||||
|
{
|
||||||
|
_mapIcon[sType][mode][varIcon] = iconPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ComponentIconManager::getIconPath(QString tpe,DiagramMode mode,VariantIcon varIcon)
|
||||||
|
{
|
||||||
|
if(_mapIcon.contains(tpe))
|
||||||
|
{
|
||||||
|
if(_mapIcon[tpe].contains(mode))
|
||||||
|
{
|
||||||
|
if(_mapIcon[tpe][mode].contains(varIcon))
|
||||||
|
{
|
||||||
|
return _mapIcon[tpe][mode][varIcon];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
@ -457,82 +457,23 @@ bool DataBase::insertZone(int grid_id,QString name,QString description,int op)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataBase::insertTopologic(int page_id,QUuid uuid_from,QUuid uuid_to,int flag,QString description,int op)
|
bool DataBase::insertTopologic(int page_id,QUuid uuid_from,QUuid uuid_to,QUuid pin_from,QUuid pin_to,int flag,QString description,int op)
|
||||||
{
|
{
|
||||||
if(db.open())
|
if(db.open())
|
||||||
{
|
{
|
||||||
QSqlQuery qry(db);
|
QSqlQuery qry(db);
|
||||||
qry.prepare("INSERT INTO topologic(page_id, uuid_from, uuid_to, flag, description, op, ts) VALUES (?, ?, ?, ?, ?, ?, ?);");
|
qry.prepare("INSERT INTO topologic(page_id, uuid_from, uuid_to, pin_from, pin_to, flag, description, op, ts) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||||
qry.bindValue(0,page_id);
|
qry.bindValue(0,page_id);
|
||||||
qry.bindValue(1,uuid_from);
|
qry.bindValue(1,uuid_from);
|
||||||
qry.bindValue(2,uuid_to);
|
qry.bindValue(2,uuid_to);
|
||||||
qry.bindValue(3,flag);
|
qry.bindValue(3,pin_from);
|
||||||
qry.bindValue(4,description);
|
qry.bindValue(4,pin_to);
|
||||||
qry.bindValue(5,op);
|
qry.bindValue(5,flag);
|
||||||
qry.bindValue(6,QDateTime::currentDateTime());
|
qry.bindValue(6,description);
|
||||||
bool res = qry.exec();
|
|
||||||
QString str = qry.lastQuery();
|
|
||||||
if(!res)
|
|
||||||
{
|
|
||||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
|
||||||
}
|
|
||||||
qry.clear();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool DataBase::insertBus_stability(int componentId,double resistance,bool anchor_v,double uv_alarm,double ov_alarm,bool anchor_i,double ui_alarm,double oi_alarm,int op)
|
|
||||||
{
|
|
||||||
if(db.open())
|
|
||||||
{
|
|
||||||
QSqlQuery qry(db);
|
|
||||||
|
|
||||||
qry.prepare("INSERT INTO bus_stability(component_id, resistance, anchor_v, uv_alarm, ov_alarm, anchor_i, ui_alarm, oi_alarm, op, ts) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
|
||||||
qry.bindValue(0,componentId);
|
|
||||||
qry.bindValue(1,resistance);
|
|
||||||
qry.bindValue(2,anchor_v);
|
|
||||||
qry.bindValue(3,uv_alarm);
|
|
||||||
qry.bindValue(4,ov_alarm);
|
|
||||||
qry.bindValue(5,anchor_i);
|
|
||||||
qry.bindValue(6,ui_alarm);
|
|
||||||
qry.bindValue(7,oi_alarm);
|
|
||||||
qry.bindValue(8,op);
|
|
||||||
qry.bindValue(9,QDateTime::currentDateTime());
|
|
||||||
bool res = qry.exec();
|
|
||||||
QString str = qry.lastQuery();
|
|
||||||
if(!res)
|
|
||||||
{
|
|
||||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DataBase::updateBus_stability(int componentId,double resistance,bool anchor_v,double uv_alarm,double ov_alarm,bool anchor_i,double ui_alarm,double oi_alarm,int op)
|
|
||||||
{
|
|
||||||
if(db.open())
|
|
||||||
{
|
|
||||||
QSqlQuery qry(db);
|
|
||||||
|
|
||||||
qry.prepare("UPDATE bus_stability SET resistance=?, anchor_v=?, uv_alarm=?, ov_alarm=?, anchor_i=?, ui_alarm=?, oi_alarm=?, op=?, ts=? WHERE component_id=?");
|
|
||||||
qry.bindValue(0,resistance);
|
|
||||||
qry.bindValue(1,anchor_v);
|
|
||||||
qry.bindValue(2,uv_alarm);
|
|
||||||
qry.bindValue(3,ov_alarm);
|
|
||||||
qry.bindValue(4,anchor_i);
|
|
||||||
qry.bindValue(5,ui_alarm);
|
|
||||||
qry.bindValue(6,oi_alarm);
|
|
||||||
qry.bindValue(7,op);
|
qry.bindValue(7,op);
|
||||||
qry.bindValue(8,QDateTime::currentDateTime());
|
qry.bindValue(8,QDateTime::currentDateTime());
|
||||||
qry.bindValue(9,componentId);
|
|
||||||
bool res = qry.exec();
|
bool res = qry.exec();
|
||||||
QString str = qry.lastQuery();
|
QString str = qry.lastQuery();
|
||||||
const QVariantList list = qry.boundValues();
|
|
||||||
for (qsizetype i = 0; i < list.size(); ++i)
|
|
||||||
qDebug() << i << ":" << list.at(i).toString();
|
|
||||||
if(!res)
|
if(!res)
|
||||||
{
|
{
|
||||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
qDebug()<<str<<"\n"<<qry.lastError().text();
|
||||||
|
|
@ -544,42 +485,176 @@ bool DataBase::updateBus_stability(int componentId,double resistance,bool anchor
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
busStability DataBase::getBusStabilityById(int componentId)
|
QString DataBase::getGridNameById(int id)
|
||||||
{
|
{
|
||||||
busStability inf;
|
QString sName;
|
||||||
if(db.open())
|
QString strSQL = "SELECT name FROM grid WHERE id = ?";
|
||||||
{
|
QVariantList params;
|
||||||
QSqlQuery qry(db);
|
params.append(id);
|
||||||
|
|
||||||
//qry.prepare("SELECT * FROM component WHERE global_uuid = ?");
|
try
|
||||||
qry.prepare("SELECT id, component_id, resistance, anchor_v, uv_alarm, ov_alarm, anchor_i, ui_alarm, oi_alarm, op FROM bus_stability WHERE component_id = ?");
|
{
|
||||||
qry.bindValue(0,componentId);
|
QSqlQuery query = executeSQL(strSQL,false,params);
|
||||||
bool res = qry.exec();
|
while (query.next())
|
||||||
QString str = qry.lastQuery();
|
|
||||||
if(!res)
|
|
||||||
{
|
{
|
||||||
qDebug()<<str<<"\n"<<qry.lastError().text();
|
sName = query.value(0).toString();
|
||||||
qry.clear();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while (qry.next())
|
|
||||||
{
|
|
||||||
int id = qry.value(0).toInt();
|
|
||||||
inf.componentId = qry.value(1).toInt();
|
|
||||||
inf.resistance = qry.value(2).toDouble();
|
|
||||||
inf.anchor_v = qry.value(3).toBool();
|
|
||||||
inf.uv_alarm = qry.value(4).toDouble();
|
|
||||||
inf.ov_alarm = qry.value(5).toDouble();
|
|
||||||
inf.anchor_i = qry.value(6).toBool();
|
|
||||||
inf.ui_alarm = qry.value(7).toDouble();
|
|
||||||
inf.oi_alarm = qry.value(8).toDouble();
|
|
||||||
qry.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
query.clear();
|
||||||
|
return sName;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return sName;
|
||||||
}
|
}
|
||||||
return inf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DataBase::getZoneNameById(int id)
|
||||||
|
{
|
||||||
|
QString sName;
|
||||||
|
QString strSQL = "SELECT name FROM zone WHERE id = ?";
|
||||||
|
QVariantList params;
|
||||||
|
params.append(id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QSqlQuery query = executeSQL(strSQL,false,params);
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
sName = query.value(0).toString();
|
||||||
|
}
|
||||||
|
query.clear();
|
||||||
|
return sName;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return sName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DataBase::getStationNameById(int id)
|
||||||
|
{
|
||||||
|
QString sName;
|
||||||
|
QString strSQL = "SELECT name FROM station WHERE id = ?";
|
||||||
|
QVariantList params;
|
||||||
|
params.append(id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QSqlQuery query = executeSQL(strSQL,false,params);
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
sName = query.value(0).toString();
|
||||||
|
}
|
||||||
|
query.clear();
|
||||||
|
return sName;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return sName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<topologicInfo> DataBase::getAllTopologics()
|
||||||
|
{
|
||||||
|
QList<topologicInfo> lst;
|
||||||
|
QString strSQL = "SELECT id,uuid_from,uuid_to,pin_from,pin_to,flag FROM topologic";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QSqlQuery query = executeSQL(strSQL);
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
topologicInfo info;
|
||||||
|
info.id = query.value(0).toInt();
|
||||||
|
info.uuid_from = QUuid(query.value(1).toString());
|
||||||
|
info.uuid_to = QUuid(query.value(2).toString());
|
||||||
|
info.pin_from = QUuid(query.value(3).toString());
|
||||||
|
info.pin_to = QUuid(query.value(4).toString());
|
||||||
|
info.flag = query.value(5).toInt();
|
||||||
|
|
||||||
|
lst.append(info);
|
||||||
|
}
|
||||||
|
query.clear();
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int DataBase::topologicExist(QUuid fromPin,QUuid toPin)
|
||||||
|
{
|
||||||
|
QString strSQL = "SELECT id FROM topologic WHERE pin_from = ? AND pin_to = ?";
|
||||||
|
QVariantList params;
|
||||||
|
params.append(fromPin.toString());
|
||||||
|
params.append(toPin.toString());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QSqlQuery query = executeSQL(strSQL,false,params);
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
int id = query.value(0).toInt();
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
query.clear();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
topologicInfo DataBase::getTopologicById(int id)
|
||||||
|
{
|
||||||
|
topologicInfo info;
|
||||||
|
QString strSQL = "SELECT id,uuid_from,uuid_to,pin_from,pin_to,flag FROM topologic WHERE id = ?";
|
||||||
|
QVariantList params;
|
||||||
|
params.append(id);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QSqlQuery query = executeSQL(strSQL);
|
||||||
|
while (query.next())
|
||||||
|
{
|
||||||
|
info.id = query.value(0).toInt();
|
||||||
|
info.uuid_from = QUuid(query.value(1).toString());
|
||||||
|
info.uuid_to = QUuid(query.value(2).toString());
|
||||||
|
info.pin_from = QUuid(query.value(3).toString());
|
||||||
|
info.pin_to = QUuid(query.value(4).toString());
|
||||||
|
info.flag = query.value(5).toInt();
|
||||||
|
}
|
||||||
|
query.clear();
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBase::deleteTopologic(QUuid fromPin,QUuid toPin)
|
||||||
|
{
|
||||||
|
QString strSQL = "DELETE FROM topologic WHERE pin_from = ? AND pin_to = ?";
|
||||||
|
QVariantList params;
|
||||||
|
params.append(fromPin.toString());
|
||||||
|
params.append(toPin.toString());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
executeSQL(strSQL,false,params);
|
||||||
|
LOG_INFO("DB", QString("Delete topologic from:%1 to:%2 success").arg(fromPin.toString(),toPin.toString()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
LOG_ERROR("DB", QString("Delete topologic from:%1 to:%2 fail").arg(fromPin.toString(),toPin.toString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
componentInfo DataBase::getComponentInfoByUuid(QString uuid)
|
componentInfo DataBase::getComponentInfoByUuid(QString uuid)
|
||||||
{
|
{
|
||||||
|
|
@ -805,33 +880,37 @@ QJsonObject DataBase::getPageContextByName(QString name)
|
||||||
return QJsonObject();
|
return QJsonObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList DataBase::getAllPage()
|
QList<pageInfo> DataBase::getAllPage()
|
||||||
{
|
{
|
||||||
if(db.open())
|
QList<pageInfo> lst;
|
||||||
|
QString strSQL = "SELECT id,tag,name,status,label,context,description,op FROM page";
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
QSqlQuery qry(db);
|
QSqlQuery query = executeSQL(strSQL);
|
||||||
qry.prepare("SELECT tag FROM page");
|
while (query.next())
|
||||||
bool res = qry.exec();
|
|
||||||
if(!res)
|
|
||||||
{
|
{
|
||||||
qDebug()<<qry.lastError().text();
|
pageInfo info;
|
||||||
qry.clear();
|
info.id = query.value(0).toInt();
|
||||||
return QStringList();
|
info.tag = query.value(1).toString();
|
||||||
}
|
info.name = query.value(2).toString();
|
||||||
else
|
info.status = query.value(3).toInt();
|
||||||
{
|
QString label = query.value(4).toString();
|
||||||
QStringList lst;
|
info.label = QstringToJson(label);
|
||||||
while (qry.next())
|
QString context = query.value(5).toString();
|
||||||
{
|
info.context = QstringToJson(context);
|
||||||
QString name = qry.value(0).toString();
|
info.description = query.value(6).toString();
|
||||||
lst.append(name);
|
info.op = query.value(7).toInt();
|
||||||
}
|
|
||||||
qry.clear();
|
lst.append(info);
|
||||||
return lst;
|
|
||||||
}
|
}
|
||||||
|
query.clear();
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
return lst;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return QStringList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataBase::deleteComponentById(int id)
|
bool DataBase::deleteComponentById(int id)
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,9 @@ public slots:
|
||||||
private:
|
private:
|
||||||
Ui::diagramView *ui;
|
Ui::diagramView *ui;
|
||||||
QStandardItemModel* _pModel;
|
QStandardItemModel* _pModel;
|
||||||
|
int _count;
|
||||||
|
private:
|
||||||
|
QString generateName();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
#include "diagramView.h"
|
|
||||||
#include "ui_diagramView.h"
|
|
||||||
#include "tools.h"
|
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
#include "diagramView.h"
|
||||||
|
#include "ui_diagramView.h"
|
||||||
|
#include "tools.h"
|
||||||
|
#include "topologyManager.h"
|
||||||
|
#include "dataBase.h"
|
||||||
|
|
||||||
DiagramView::DiagramView(QWidget *parent)
|
DiagramView::DiagramView(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
|
|
@ -14,6 +15,7 @@ DiagramView::DiagramView(QWidget *parent)
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
_pModel = new QStandardItemModel(this);
|
_pModel = new QStandardItemModel(this);
|
||||||
ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiagramView::~DiagramView()
|
DiagramView::~DiagramView()
|
||||||
|
|
@ -30,6 +32,16 @@ void DiagramView::initial()
|
||||||
// 设置模型的列数
|
// 设置模型的列数
|
||||||
_pModel->setColumnCount(1);
|
_pModel->setColumnCount(1);
|
||||||
|
|
||||||
|
QList<QStandardItem*> pageList;
|
||||||
|
QList<pageInfo> lst = DataBase::GetInstance()->getAllPage();
|
||||||
|
for(auto info:lst)
|
||||||
|
{
|
||||||
|
QStandardItem* pItem = new QStandardItem(info.name);
|
||||||
|
pItem->setData(info.id,Qt::UserRole);
|
||||||
|
pageList.append(pItem);
|
||||||
|
}
|
||||||
|
_pModel->appendRow(pageList);
|
||||||
|
|
||||||
// 创建树视图
|
// 创建树视图
|
||||||
ui->treeView->setModel(_pModel);
|
ui->treeView->setModel(_pModel);
|
||||||
|
|
||||||
|
|
@ -51,15 +63,16 @@ void DiagramView::onIndexRbtnClicked(const QPoint &pos)
|
||||||
QModelIndex index = ui->treeView->indexAt(pos);
|
QModelIndex index = ui->treeView->indexAt(pos);
|
||||||
if (!index.isValid()) {
|
if (!index.isValid()) {
|
||||||
// 如果点击的是空白区域,创建新组态图菜单
|
// 如果点击的是空白区域,创建新组态图菜单
|
||||||
int nCount = _pModel->invisibleRootItem()->rowCount();
|
|
||||||
QAction *addAction = new QAction("添加组态图", this);
|
QAction *addAction = new QAction("添加组态图", this);
|
||||||
|
|
||||||
connect(addAction,&QAction::triggered,this,[&](){
|
connect(addAction,&QAction::triggered,this,[&](){
|
||||||
QVariant id = QUuid::createUuid();
|
QVariant id = QUuid::createUuid();
|
||||||
QString sName = QString::fromWCharArray(L"组态图_")+QString::number(nCount);
|
|
||||||
QStandardItem *gridItem = new QStandardItem(sName);
|
QString sName = generateName();
|
||||||
gridItem->setData(id,Qt::UserRole+1);
|
QStandardItem *item = new QStandardItem(sName);
|
||||||
_pModel->appendRow(gridItem);
|
item->setData(id,Qt::UserRole+1);
|
||||||
|
_pModel->appendRow(item);
|
||||||
|
|
||||||
DiagramInfo info;
|
DiagramInfo info;
|
||||||
//todo:具体信息
|
//todo:具体信息
|
||||||
|
|
@ -77,15 +90,15 @@ void DiagramView::onIndexRbtnClicked(const QPoint &pos)
|
||||||
|
|
||||||
if(item)
|
if(item)
|
||||||
{
|
{
|
||||||
int nCount = item->rowCount();
|
|
||||||
QAction *addAction = new QAction("添加子组态图", this);
|
QAction *addAction = new QAction("添加子组态图", this);
|
||||||
|
|
||||||
connect(addAction,&QAction::triggered,this,[&](){
|
connect(addAction,&QAction::triggered,this,[&](){
|
||||||
QVariant id = QUuid::createUuid();
|
QVariant id = QUuid::createUuid();
|
||||||
QString sName = item->text()+"_"+QString::number(nCount);
|
|
||||||
QStandardItem *gridItem = new QStandardItem(sName);
|
QString sName = generateName();
|
||||||
gridItem->setData(id,Qt::UserRole+1);
|
QStandardItem *item = new QStandardItem(sName);
|
||||||
item->appendRow(gridItem);
|
item->setData(id,Qt::UserRole+1);
|
||||||
|
item->appendRow(item);
|
||||||
|
|
||||||
DiagramInfo info;
|
DiagramInfo info;
|
||||||
//todo:具体信息
|
//todo:具体信息
|
||||||
|
|
@ -137,19 +150,38 @@ void DiagramView::onIndexRbtnClicked(const QPoint &pos)
|
||||||
void DiagramView::onItemChanged(QStandardItem *item)
|
void DiagramView::onItemChanged(QStandardItem *item)
|
||||||
{
|
{
|
||||||
int nLevel = getLevel(item);
|
int nLevel = getLevel(item);
|
||||||
QString str = item->text();
|
QString str = item->text(); //名称可能修改
|
||||||
DiagramInfo info;
|
DiagramInfo info;
|
||||||
//todo:具体信息
|
info.id = item->data(Qt::UserRole).toInt();
|
||||||
|
info.sName = str;
|
||||||
emit diagramChange(info);
|
emit diagramChange(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramView::onItemClicked(const QModelIndex &index)
|
void DiagramView::onItemClicked(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
QStandardItem* item = _pModel->itemFromIndex(index);
|
QStandardItem* item = _pModel->itemFromIndex(index);
|
||||||
|
QStandardItem* parent = item->parent();
|
||||||
if(item)
|
if(item)
|
||||||
{
|
{
|
||||||
DiagramInfo info;
|
DiagramInfo info;
|
||||||
//todo:具体信息
|
info.id = item->data(Qt::UserRole).toInt();
|
||||||
|
info.sName = item->text();
|
||||||
|
if(parent)
|
||||||
|
info.parentId = parent->data(Qt::UserRole).toInt();
|
||||||
emit diagramSelected(info);
|
emit diagramSelected(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DiagramView::generateName()
|
||||||
|
{
|
||||||
|
QString sName = QString::fromWCharArray(L"组态图_")+QString::number(_count);
|
||||||
|
QModelIndex Idx = findIndex(_pModel,sName);
|
||||||
|
if(Idx.isValid()) //已存在
|
||||||
|
{
|
||||||
|
_count += 1;
|
||||||
|
return generateName();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return sName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,10 @@ void LoadPageDlg::updateList()
|
||||||
itemRoot->appendRow(itemPage);
|
itemRoot->appendRow(itemPage);
|
||||||
|
|
||||||
QList<QStandardItem*> pageList;
|
QList<QStandardItem*> pageList;
|
||||||
QStringList lst = DataBase::GetInstance()->getAllPage();
|
QList<pageInfo> lst = DataBase::GetInstance()->getAllPage();
|
||||||
for(auto name:lst)
|
for(auto info:lst)
|
||||||
{
|
{
|
||||||
pageList.append(new QStandardItem(name));
|
pageList.append(new QStandardItem(info.name));
|
||||||
}
|
}
|
||||||
itemPage->appendRows(pageList);
|
itemPage->appendRows(pageList);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1582,7 +1582,7 @@ int projectModelDlg::createPropertyTable(const QString& sProject,const QString&
|
||||||
QStringList fields;
|
QStringList fields;
|
||||||
fields.append("id SERIAL NOT NULL PRIMARY KEY");
|
fields.append("id SERIAL NOT NULL PRIMARY KEY");
|
||||||
fields.append("global_uuid uuid NOT NULL DEFAULT gen_random_uuid()");
|
fields.append("global_uuid uuid NOT NULL DEFAULT gen_random_uuid()");
|
||||||
fields.append("attribute_group VARCHAR(64) NOT NULL");
|
//fields.append("attribute_group VARCHAR(64) NOT NULL");
|
||||||
|
|
||||||
for(auto &item:lstSelect)
|
for(auto &item:lstSelect)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ void TopologyTree::mouseMoveEvent(QMouseEvent *event)
|
||||||
// 创建QMimeData,并将选中项的文本放入
|
// 创建QMimeData,并将选中项的文本放入
|
||||||
QMimeData *mimeData = new QMimeData();
|
QMimeData *mimeData = new QMimeData();
|
||||||
mimeData->setText(model()->data(index, Qt::DisplayRole).toString());
|
mimeData->setText(model()->data(index, Qt::DisplayRole).toString());
|
||||||
|
QString id = index.data(Qt::UserRole).toString();
|
||||||
|
mimeData->setData("application/id",id.toLocal8Bit());
|
||||||
|
|
||||||
// 创建拖拽对象
|
// 创建拖拽对象
|
||||||
QDrag *drag = new QDrag(this);
|
QDrag *drag = new QDrag(this);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include "ui_topologyView.h"
|
#include "ui_topologyView.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "topologyTree.h"
|
#include "topologyTree.h"
|
||||||
|
#include "dataBase.h"
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
@ -43,6 +44,62 @@ void TopologyView::initial()
|
||||||
rootItem->setFlags(rootItem->flags() & ~Qt::ItemIsEditable);
|
rootItem->setFlags(rootItem->flags() & ~Qt::ItemIsEditable);
|
||||||
_pModel->appendRow(rootItem);
|
_pModel->appendRow(rootItem);
|
||||||
|
|
||||||
|
QList<componentInfo> lst= DataBase::GetInstance()->getAllComponents();
|
||||||
|
for(auto &info:lst)
|
||||||
|
{
|
||||||
|
QString nG= info.grid;
|
||||||
|
QString nZ = info.zone;
|
||||||
|
QString nS= info.station;
|
||||||
|
|
||||||
|
QString sGrid = DataBase::GetInstance()->getGridNameById(nG.toInt());
|
||||||
|
QString sZone = DataBase::GetInstance()->getZoneNameById(nZ.toInt());
|
||||||
|
QString sStation = DataBase::GetInstance()->getStationNameById(nS.toInt());
|
||||||
|
|
||||||
|
QModelIndex iG = findIndex(_pModel,sGrid);
|
||||||
|
QModelIndex iZ = findIndex(_pModel,sZone);
|
||||||
|
QModelIndex iS = findIndex(_pModel,sStation);
|
||||||
|
|
||||||
|
QStandardItem *pItem = new QStandardItem(info.tag);
|
||||||
|
pItem->setData(info.uuid,Qt::UserRole);
|
||||||
|
if(iG.isValid()) //已创建
|
||||||
|
{
|
||||||
|
QStandardItem* itemGrid = _pModel->itemFromIndex(iG);
|
||||||
|
if(iZ.isValid())
|
||||||
|
{
|
||||||
|
QStandardItem* itemZone = _pModel->itemFromIndex(iZ);
|
||||||
|
if(iS.isValid())
|
||||||
|
{
|
||||||
|
QStandardItem* itemStation = _pModel->itemFromIndex(iS);
|
||||||
|
itemStation->appendRow(pItem);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QStandardItem* itemStation = new QStandardItem(sStation);
|
||||||
|
itemStation->appendRow(pItem);
|
||||||
|
itemZone->appendRow(itemStation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QStandardItem* itemZone = new QStandardItem(sZone);
|
||||||
|
QStandardItem* itemStation = new QStandardItem(sStation);
|
||||||
|
itemStation->appendRow(pItem);
|
||||||
|
itemZone->appendRow(itemStation);
|
||||||
|
itemGrid->appendRow(itemZone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QStandardItem* itemGrid = new QStandardItem(sGrid);
|
||||||
|
QStandardItem* itemZone = new QStandardItem(sZone);
|
||||||
|
QStandardItem* itemStation = new QStandardItem(sStation);
|
||||||
|
itemStation->appendRow(pItem);
|
||||||
|
itemZone->appendRow(itemStation);
|
||||||
|
itemGrid->appendRow(itemZone);
|
||||||
|
rootItem->appendRow(itemGrid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 创建树视图
|
// 创建树视图
|
||||||
_treeView->setModel(_pModel);
|
_treeView->setModel(_pModel);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue