add diagram editor preview structure
This commit is contained in:
parent
ad44b48ec2
commit
15b2be3fef
|
|
@ -461,12 +461,21 @@ struct DiagramEditorComponentInfo //组态设备信息
|
||||||
QString sName;
|
QString sName;
|
||||||
int nType = 0; //类型 1母线2异步电动机3断路器4电缆5电流互感器6电压互感器7隔离开关8接地开关9快速接地开关10双掷接地隔离开关11带电指示器12避雷器13电缆出线套筒14电缆端
|
int nType = 0; //类型 1母线2异步电动机3断路器4电缆5电流互感器6电压互感器7隔离开关8接地开关9快速接地开关10双掷接地隔离开关11带电指示器12避雷器13电缆出线套筒14电缆端
|
||||||
QString sBindObj; //所关联的实体名 (母线block,间隔block)
|
QString sBindObj; //所关联的实体名 (母线block,间隔block)
|
||||||
|
int nBindType = 0; //关联实体的类型 1母线2间隔3变压器
|
||||||
QStringList sUsedRoute; //使用设备的线路名
|
QStringList sUsedRoute; //使用设备的线路名
|
||||||
int nUsedDirection = 0; //被占用的方向 8421 上下左右
|
int nUsedDirection = 0; //被占用的方向 8421 上下左右
|
||||||
QPoint deltaPos = QPoint(0,0); //相对坐标(相对间隔)
|
QPoint deltaPos = QPoint(0,0); //相对坐标(相对间隔)
|
||||||
QUuid uid;
|
QUuid uid;
|
||||||
int nFlag = 0; //标志0未使用1新建2修改
|
int nFlag = 0; //标志0未使用1新建2修改
|
||||||
int nRotate = 0; //旋转角
|
int nRotate = 0; //旋转角
|
||||||
|
|
||||||
|
bool operator ==(const DiagramEditorComponentInfo& obj) const {
|
||||||
|
if(nCategory == obj.nCategory && sName == obj.sName && nType == obj.nType && sBindObj == obj.sBindObj && nBindType == obj.nBindType &&
|
||||||
|
sUsedRoute == obj.sUsedRoute && nUsedDirection == obj.nUsedDirection && deltaPos == obj.deltaPos && uid == obj.uid && nFlag == obj.nFlag && nRotate == obj.nRotate)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DiagramEditorRouteInfo //间隔中单条线路信息
|
struct DiagramEditorRouteInfo //间隔中单条线路信息
|
||||||
|
|
@ -478,6 +487,14 @@ struct DiagramEditorRouteInfo //间隔中单条线路信息
|
||||||
QList<DiagramEditorComponentInfo> lstReverse; //逆序容器(计算用)
|
QList<DiagramEditorComponentInfo> lstReverse; //逆序容器(计算用)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DiagramEditorBayInfo //组态编辑间隔信息
|
||||||
|
{
|
||||||
|
QString name;
|
||||||
|
int nLayout; //布局 0纵向1横向
|
||||||
|
QMap<QString,DiagramEditorRouteInfo> mapRoute; //线路信息
|
||||||
|
QMap<QString,DiagramEditorComponentInfo> mapComponent; //设备信息
|
||||||
|
};
|
||||||
|
|
||||||
enum class DiagramEditorStructType
|
enum class DiagramEditorStructType
|
||||||
{
|
{
|
||||||
block = 0, //模块(母线段、间隔、变压器)
|
block = 0, //模块(母线段、间隔、变压器)
|
||||||
|
|
@ -508,12 +525,12 @@ struct DiagramEditorBriefConnect //组态编辑时连接信息
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getOppositeName(const QString& s){ //获取另一端名称
|
DiagramEditorConnectType getOpposite(const QString& s){ //获取另一端名称
|
||||||
if(con1.sName == s)
|
if(con1.sName == s)
|
||||||
return con2.sName;
|
return con2;
|
||||||
else if(con2.sName == s)
|
else if(con2.sName == s)
|
||||||
return con1.sName;
|
return con1;
|
||||||
return QString();
|
return DiagramEditorConnectType();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,14 +65,11 @@ public:
|
||||||
virtual ~DiagramEditorBayBlock();
|
virtual ~DiagramEditorBayBlock();
|
||||||
virtual void setBayType(BayType typ) {nBayType = typ;}
|
virtual void setBayType(BayType typ) {nBayType = typ;}
|
||||||
virtual BayType getBayType() {return nBayType;}
|
virtual BayType getBayType() {return nBayType;}
|
||||||
virtual void setRouteInfoMap(QMap<QString,DiagramEditorRouteInfo> info) {mapRouteInfo = info;}
|
virtual void setBayInfo(DiagramEditorBayInfo info) {bayInfo = info;}
|
||||||
virtual QMap<QString,DiagramEditorRouteInfo>& getRouteInfoMap() {return mapRouteInfo;}
|
virtual DiagramEditorBayInfo& getBayInfo(){return bayInfo;}
|
||||||
virtual void setComponentMap(QMap<QString,DiagramEditorComponentInfo> info) {mapComponents = info;}
|
|
||||||
virtual QMap<QString,DiagramEditorComponentInfo>& getComponentMap() {return mapComponents;}
|
|
||||||
protected:
|
protected:
|
||||||
BayType nBayType;
|
BayType nBayType;
|
||||||
QMap<QString,DiagramEditorRouteInfo> mapRouteInfo; //间隔中的线路信息
|
DiagramEditorBayInfo bayInfo; //间隔信息
|
||||||
QMap<QString,DiagramEditorComponentInfo> mapComponents; //间隔中的所有设备信息
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/***************************transformer单元****************************/
|
/***************************transformer单元****************************/
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ public:
|
||||||
void showDlg();
|
void showDlg();
|
||||||
void showDlg(DiagramEditorRouteInfo info); //编辑
|
void showDlg(DiagramEditorRouteInfo info); //编辑
|
||||||
void setParent(DiagramEditorBayDetailSettingDlg* p) {_pParent = p;}
|
void setParent(DiagramEditorBayDetailSettingDlg* p) {_pParent = p;}
|
||||||
|
private:
|
||||||
|
void updateBindLst(); //刷新关联列表
|
||||||
public slots:
|
public slots:
|
||||||
void onAddClicked();
|
void onAddClicked();
|
||||||
void onDeleteClicked();
|
void onDeleteClicked();
|
||||||
|
|
@ -38,6 +40,7 @@ private:
|
||||||
QStandardItemModel* _selectedModel;
|
QStandardItemModel* _selectedModel;
|
||||||
DiagramEditorBayDetailSettingDlg* _pParent;
|
DiagramEditorBayDetailSettingDlg* _pParent;
|
||||||
int _curMode; //0新建1修改
|
int _curMode; //0新建1修改
|
||||||
|
QStandardItemModel* _bindItemModel; //绑定的对象模型
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,15 @@ public:
|
||||||
void initial();
|
void initial();
|
||||||
void refreshModel(); //刷新view显示的model
|
void refreshModel(); //刷新view显示的model
|
||||||
void showDlg(DiagramEditorBayBlock*);
|
void showDlg(DiagramEditorBayBlock*);
|
||||||
void setParent(DiagramEditorWizard* p) {_pWizard = p;}
|
void setWizard(DiagramEditorWizard* p) {_pWizard = p;}
|
||||||
QStandardItemModel* getComponentModel() {return _compoModel;}
|
QStandardItemModel* getComponentModel() {return _compoModel;}
|
||||||
QStandardItemModel* getRouteModel() {return _routeModel;}
|
QStandardItemModel* getRouteModel() {return _routeModel;}
|
||||||
void setRouteMap(QMap<QString,DiagramEditorRouteInfo> map) {_mapRouteInfo = map;}
|
void setBayInfo(DiagramEditorBayInfo info){_curBayInfo = info;}
|
||||||
QMap<QString,DiagramEditorRouteInfo>& getRouteMap(){return _mapRouteInfo;}
|
DiagramEditorBayInfo& getBayInfo(){return _curBayInfo;}
|
||||||
void setModelDelegate(DiagramEditorModel* p){_pModel = p;}
|
void setModelDelegate(DiagramEditorModel* p){_pModel = p;}
|
||||||
DiagramEditorModel* getModel() {return _pModel;}
|
DiagramEditorModel* getModel() {return _pModel;}
|
||||||
|
DiagramEditorBayBlock* getCurBlock(){return _curOperateObj;}
|
||||||
|
DiagramEditorWizard* getWizard() {return _pWizard;}
|
||||||
public slots:
|
public slots:
|
||||||
void onAddClicked();
|
void onAddClicked();
|
||||||
void onOkClicked();
|
void onOkClicked();
|
||||||
|
|
@ -48,7 +50,7 @@ private:
|
||||||
DiagramEditorBayBlock* _curOperateObj; //当前加载的block对象
|
DiagramEditorBayBlock* _curOperateObj; //当前加载的block对象
|
||||||
QStandardItemModel* _compoModel; //设备库model name中的data:1为占用方向,2为相对坐标,3为uuid,4为item标志位(1新建2修改),5旋转角度
|
QStandardItemModel* _compoModel; //设备库model name中的data:1为占用方向,2为相对坐标,3为uuid,4为item标志位(1新建2修改),5旋转角度
|
||||||
QStandardItemModel* _routeModel; //所有线路model
|
QStandardItemModel* _routeModel; //所有线路model
|
||||||
QMap<QString,DiagramEditorRouteInfo> _mapRouteInfo; //所有线路信息
|
DiagramEditorBayInfo _curBayInfo; //当前使用的间隔信息
|
||||||
DiagramEditorModel* _pModel;
|
DiagramEditorModel* _pModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ public:
|
||||||
~DiagramEditorBayPreviewDlg();
|
~DiagramEditorBayPreviewDlg();
|
||||||
|
|
||||||
void initial();
|
void initial();
|
||||||
void showDlg();
|
void showDlg(int nLayout); //0纵向1横向
|
||||||
void setParent(DiagramEditorBayDetailSettingDlg* p) {_pParent = p;}
|
void setParent(DiagramEditorBayDetailSettingDlg* p) {_pParent = p;}
|
||||||
//void updateModelData(); //根据设置更新data中布局、方向
|
//void updateModelData(); //根据设置更新data中布局、方向
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
#ifndef DIAGRAMEDITORPREVIEWDLG_H
|
#ifndef DIAGRAMEDITORPREVIEWDLG_H
|
||||||
#define DIAGRAMEDITORPREVIEWDLG_H
|
#define DIAGRAMEDITORPREVIEWDLG_H
|
||||||
//间隔预览窗口
|
//组态图预览
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QStandardItem>
|
#include <QStandardItem>
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
class EditView;
|
class EditView;
|
||||||
class EditPreviewScene;
|
class EditScene;
|
||||||
class EditPanel;
|
class EditPanel;
|
||||||
|
|
||||||
class DiagramEditorPreviewDlg : public QDialog
|
class DiagramEditorPreviewDlg : public QDialog
|
||||||
|
|
@ -22,7 +22,7 @@ public:
|
||||||
void setParent(EditPanel* p) {_pParent = p;}
|
void setParent(EditPanel* p) {_pParent = p;}
|
||||||
private:
|
private:
|
||||||
EditView* _pView;
|
EditView* _pView;
|
||||||
EditPreviewScene* _pScene;
|
EditScene* _pScene;
|
||||||
QVBoxLayout* _pMainLayout;
|
QVBoxLayout* _pMainLayout;
|
||||||
EditPanel* _pParent;
|
EditPanel* _pParent;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ class EditBaseItem;
|
||||||
class DiagramEditorBayDetailSettingDlg;
|
class DiagramEditorBayDetailSettingDlg;
|
||||||
class DiagramEditorTransDetailSettingDlg;
|
class DiagramEditorTransDetailSettingDlg;
|
||||||
class DiagramEditorModel;
|
class DiagramEditorModel;
|
||||||
|
class DiagramEditorPreviewDlg;
|
||||||
|
|
||||||
class EditPanel : public QWidget
|
class EditPanel : public QWidget
|
||||||
{
|
{
|
||||||
|
|
@ -31,6 +32,7 @@ public:
|
||||||
void initByWizardInfo();
|
void initByWizardInfo();
|
||||||
void initBlockConnection(); //初始化block之间的连接信息
|
void initBlockConnection(); //初始化block之间的连接信息
|
||||||
void setOperateWizard(QPointer<DiagramEditorWizard> p) {_curWizard = p;}
|
void setOperateWizard(QPointer<DiagramEditorWizard> p) {_curWizard = p;}
|
||||||
|
void showPreview(); //展示预览
|
||||||
|
|
||||||
DiagramEditorModel* getModel() {return _pModel;}
|
DiagramEditorModel* getModel() {return _pModel;}
|
||||||
EditScene* getScene() {return m_pEditScene;}
|
EditScene* getScene() {return m_pEditScene;}
|
||||||
|
|
@ -59,6 +61,7 @@ private:
|
||||||
QMap<int,QMap<int,EditContainerItem*>> _mapStruct;
|
QMap<int,QMap<int,EditContainerItem*>> _mapStruct;
|
||||||
QPointer<DiagramEditorWizard> _curWizard;
|
QPointer<DiagramEditorWizard> _curWizard;
|
||||||
DiagramEditorModel* _pModel;
|
DiagramEditorModel* _pModel;
|
||||||
|
DiagramEditorPreviewDlg* _pPreview;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@
|
||||||
#define EDITSCENE_H
|
#define EDITSCENE_H
|
||||||
|
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
|
class DiagramEditorModel;
|
||||||
|
|
||||||
class EditBaseScene : public QGraphicsScene
|
class EditBaseScene : public QGraphicsScene
|
||||||
{
|
{
|
||||||
|
|
@ -9,6 +12,9 @@ class EditBaseScene : public QGraphicsScene
|
||||||
public:
|
public:
|
||||||
EditBaseScene(QObject *parent = 0);
|
EditBaseScene(QObject *parent = 0);
|
||||||
virtual ~EditBaseScene();
|
virtual ~EditBaseScene();
|
||||||
|
virtual void setModel(QPointer<DiagramEditorModel> p){_pModel = p;}
|
||||||
|
protected:
|
||||||
|
QPointer<DiagramEditorModel> _pModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EditScene : public EditBaseScene //editor主界面scene
|
class EditScene : public EditBaseScene //editor主界面scene
|
||||||
|
|
@ -17,6 +23,8 @@ class EditScene : public EditBaseScene //editor主界面scene
|
||||||
public:
|
public:
|
||||||
EditScene(QObject *parent = 0);
|
EditScene(QObject *parent = 0);
|
||||||
virtual ~EditScene();
|
virtual ~EditScene();
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
class EditPreviewScene : public EditBaseScene //bay预览scene
|
class EditPreviewScene : public EditBaseScene //bay预览scene
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
class GraphicsBaseItem;
|
class GraphicsBaseItem;
|
||||||
|
class ItemPort;
|
||||||
|
|
||||||
class BaseModel : public QObject
|
class BaseModel : public QObject
|
||||||
{
|
{
|
||||||
|
|
@ -27,6 +28,7 @@ public:
|
||||||
QPointF diff = center1 - center2;
|
QPointF diff = center1 - center2;
|
||||||
return qSqrt(diff.x() * diff.x() + diff.y() * diff.y());
|
return qSqrt(diff.x() * diff.x() + diff.y() * diff.y());
|
||||||
}
|
}
|
||||||
|
ItemPort* getClosestUnusedPort(QMap<QString,ItemPort*>,GraphicsBaseItem* item,ModelFunctionType); //返回距离item最近未使用端点
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
/**组态编辑时的数据模型*/
|
/**组态编辑时的数据模型*/
|
||||||
#include "graphicsDataModel/baseModel.h"
|
#include "graphicsDataModel/baseModel.h"
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
class GraphicsBaseModelItem;
|
class GraphicsBaseModelItem;
|
||||||
class DiagramEditorItemProperty;
|
class DiagramEditorItemProperty;
|
||||||
class GraphicsBaseItem;
|
class GraphicsBaseItem;
|
||||||
class EditPreviewScene;
|
class EditBaseScene;
|
||||||
class ElectricBaseModelLineItem;
|
class ElectricBaseModelLineItem;
|
||||||
class DiagramEditorTransformerBlock;
|
class DiagramEditorTransformerBlock;
|
||||||
class EditPanel;
|
class EditPanel;
|
||||||
|
class DiagramEditorWizard;
|
||||||
|
|
||||||
class DiagramEditorModel : public BaseModel
|
class DiagramEditorModel : public BaseModel
|
||||||
{
|
{
|
||||||
|
|
@ -17,17 +19,19 @@ public:
|
||||||
DiagramEditorModel();
|
DiagramEditorModel();
|
||||||
~DiagramEditorModel();
|
~DiagramEditorModel();
|
||||||
|
|
||||||
bool addTempPreviewItem(QUuid uuid,GraphicsBaseModelItem*);
|
bool addPreviewItem(QUuid uuid,GraphicsBaseModelItem*,int mode); //mode 0局部1整体
|
||||||
DiagramEditorItemProperty* addTempPreviewData(QUuid id,int type,QString name,QString metaName,QString sBlock = QString()); //添加图元基模数据
|
DiagramEditorItemProperty* addPreviewData(QUuid id,int type,QString name,QString metaName,QString sBlock,int mode = 0); //添加图元基模数据 mode:0局部1整体
|
||||||
void createTopoTerminalsByItem(GraphicsBaseItem*,ModelFunctionType funType = ModelFunctionType::ProjectModel); //通过图形对象创建port接线点(新建)
|
void createTopoTerminalsByItem(GraphicsBaseItem*,ModelFunctionType funType = ModelFunctionType::ProjectModel); //通过图形对象创建port接线点(新建)
|
||||||
void generateTempBay(); //通过设置生成间隔预览对象
|
void generateTempBay(); //通过设置生成间隔预览对象
|
||||||
void generateTempTrans(int nType,DiagramEditorTransformerBlock* block = nullptr); //0高压侧1中压侧2低压侧3整个变压器
|
void generateTempTrans(int nType,DiagramEditorTransformerBlock* block = nullptr); //0高压侧1中压侧2低压侧3整个变压器
|
||||||
void connectTransToNeutral(DiagramEditorTransformerBlock* block); //连接变压器与中性点设备
|
void connectTransToNeutral(DiagramEditorTransformerBlock* block); //连接变压器与中性点设备
|
||||||
void linkTransItem(GraphicsBaseModelItem*,QStandardItemModel*); //连接中性点与设备点
|
void linkTransItem(GraphicsBaseModelItem*,QStandardItemModel*); //连接中性点与设备点
|
||||||
void generateTempComponent(QUuid uid,QString sName,int nCategory,int nType,QPoint pos,int nRotate = 0); //生成设备 uid,分类(设备、逻辑点),类型,旋转
|
GraphicsBaseModelItem* generateComponent(QUuid uid,QString sName,int nCategory,int nType,QPointF pos,int nRotate,int mode); //生成设备 uid,分类(设备、逻辑点),类型,旋转,模式(0局部1整体)
|
||||||
ElectricBaseModelLineItem* generateTempLine(QUuid uid,QString sName); //生成连线
|
ElectricBaseModelLineItem* generateLine(QUuid uid,QString sName,int mode); //生成连线 mode 0局部1整体
|
||||||
void clearCurPreview();
|
void clearCurPreview();
|
||||||
void setPanel(EditPanel* p) {_pPanel = p;}
|
void setPanel(EditPanel* p) {_pPanel = p;}
|
||||||
|
void setWizard(QPointer<DiagramEditorWizard> p){_pWizard = p;}
|
||||||
|
void generatePreview(); //生成预览
|
||||||
|
|
||||||
void setCurBayRouteModel(QStandardItemModel* p) {_pCurBayRoute = p;}
|
void setCurBayRouteModel(QStandardItemModel* p) {_pCurBayRoute = p;}
|
||||||
QStandardItemModel* getCurBayRouteModel() {return _pCurBayRoute;}
|
QStandardItemModel* getCurBayRouteModel() {return _pCurBayRoute;}
|
||||||
|
|
@ -38,19 +42,24 @@ public:
|
||||||
QMap<int,QStandardItemModel*> getCurTransRouteModels() {return _pCurTransLRoutes;}
|
QMap<int,QStandardItemModel*> getCurTransRouteModels() {return _pCurTransLRoutes;}
|
||||||
void setCurTransComponentModel(QStandardItemModel* p) {_pCurTransComponent = p;}
|
void setCurTransComponentModel(QStandardItemModel* p) {_pCurTransComponent = p;}
|
||||||
QStandardItemModel* setCurTransComponentModel() {return _pCurTransComponent;}
|
QStandardItemModel* setCurTransComponentModel() {return _pCurTransComponent;}
|
||||||
void setCurPreviewScene(EditPreviewScene* p) {_pCurPreviewScene = p;}
|
void setCurPreviewScene(EditBaseScene* p) {_pCurPreviewScene = p;}
|
||||||
QStandardItem* getNameItem(const QString&,int nFrom = 0); //获取返回当前设备模型中的name项 nFrom,0间隔1变压器
|
QStandardItem* getNameItem(const QString&,int nFrom = 0); //获取返回当前设备模型中的name项 nFrom,0间隔1变压器
|
||||||
|
|
||||||
void generateItemByModel(QStandardItemModel* pModel,int nFrom = 0,QPoint delta = QPoint(0,0)); //0间隔1变压器
|
void generateItemByModel(QStandardItemModel* pModel,int nFrom = 0,QPoint delta = QPoint(0,0)); //0间隔1变压器
|
||||||
void generateItemByInfo(QMap<QString,DiagramEditorRouteInfo> mapRoute,QMap<QString,DiagramEditorComponentInfo> mapCompo,QPoint delta = QPoint(0,0)); //根据data生成item
|
void generateItemByInfo(QMap<QString,DiagramEditorRouteInfo> mapRoute,QMap<QString,DiagramEditorComponentInfo> mapCompo,QPointF delta = QPointF(0,0)); //根据data生成item
|
||||||
void updateTarget(QMap<QString,DiagramEditorRouteInfo>&,int nLayout,int nSource); //更新位置 nLayout主次朝向:8421,8421 上下左右,上下左右 nSource:0间隔1变压器
|
void updateTarget(QMap<QString,DiagramEditorRouteInfo>&,int nLayout,int nSource); //更新位置 nLayout主次朝向:8421,8421 上下左右,上下左右 nSource:0间隔1变压器
|
||||||
|
private:
|
||||||
|
void bulidAndLinkComponent(QList<DiagramEditorComponentInfo>); //生成并连接线路上的设备
|
||||||
|
//DiagramEditorComponentInfo getCompoDataFromName(const QString&,QMap<QString,DiagramEditorComponentInfo>); //根据名称获取数据
|
||||||
private:
|
private:
|
||||||
QMap<QUuid,GraphicsBaseModelItem*> _tempItem; //临时预览对象
|
QMap<QUuid,GraphicsBaseModelItem*> _tempItem; //临时预览对象
|
||||||
|
QMap<QUuid,GraphicsBaseModelItem*> _previewItem; //预览对象
|
||||||
QStandardItemModel* _pCurBayRoute; //当前使用的间隔路线
|
QStandardItemModel* _pCurBayRoute; //当前使用的间隔路线
|
||||||
QStandardItemModel* _pCurBayComponent; //当前使用的间隔设备库
|
QStandardItemModel* _pCurBayComponent; //当前使用的间隔设备库
|
||||||
QMap<int,QStandardItemModel*> _pCurTransLRoutes; //变压器中性点路线
|
QMap<int,QStandardItemModel*> _pCurTransLRoutes; //变压器中性点路线
|
||||||
QStandardItemModel* _pCurTransComponent; //当前使用的变压器设备库
|
QStandardItemModel* _pCurTransComponent; //当前使用的变压器设备库
|
||||||
EditPreviewScene* _pCurPreviewScene; //当前预览scene
|
EditBaseScene* _pCurPreviewScene; //当前预览scene
|
||||||
EditPanel* _pPanel; //主界面
|
EditPanel* _pPanel; //主界面
|
||||||
|
QPointer<DiagramEditorWizard> _pWizard; //向导界面数据
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ public:
|
||||||
|
|
||||||
virtual void updateCoordinate() {}
|
virtual void updateCoordinate() {}
|
||||||
|
|
||||||
|
virtual void setBoundingRect(QRectF rec){m_boundingRect = rec;}
|
||||||
virtual QRectF boundingRect() const { return m_boundingRect; }
|
virtual QRectF boundingRect() const { return m_boundingRect; }
|
||||||
virtual QPainterPath shape()
|
virtual QPainterPath shape()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
//#include "componentIconManager.h"
|
//#include "componentIconManager.h"
|
||||||
#include "baseProperty.h"
|
#include "baseProperty.h"
|
||||||
#include "diagramEditor/editPanel.h"
|
#include "diagramEditor/editPanel.h"
|
||||||
|
#include "graphicsDataModel/diagramEditorModel.h"
|
||||||
|
|
||||||
DiagramCavas::DiagramCavas(QWidget *parent)
|
DiagramCavas::DiagramCavas(QWidget *parent)
|
||||||
: QMdiArea(parent)
|
: QMdiArea(parent)
|
||||||
|
|
@ -378,6 +379,9 @@ void DiagramCavas::onSignal_addEditWizard(QString name)
|
||||||
connect(_pEditorWizard,&DiagramEditorWizard::wizardFinish,this,[&,name](){
|
connect(_pEditorWizard,&DiagramEditorWizard::wizardFinish,this,[&,name](){
|
||||||
EditPanel* pPanel = onSignal_addEditPanel(name);
|
EditPanel* pPanel = onSignal_addEditPanel(name);
|
||||||
pPanel->setOperateWizard(_pEditorWizard);
|
pPanel->setOperateWizard(_pEditorWizard);
|
||||||
|
auto pModel = pPanel->getModel();
|
||||||
|
if(pModel)
|
||||||
|
pModel->setWizard(_pEditorWizard);
|
||||||
pPanel->initByWizardInfo();
|
pPanel->initByWizardInfo();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,19 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QStandardItemModel>
|
||||||
#include "diagramEditor/diagramEditorBayDetailAddDlg.h"
|
#include "diagramEditor/diagramEditorBayDetailAddDlg.h"
|
||||||
#include "diagramEditor/diagramEditorBayDetailSettingDlg.h"
|
#include "diagramEditor/diagramEditorBayDetailSettingDlg.h"
|
||||||
#include "ui_diagramEditorBayDetailAddDlg.h"
|
#include "ui_diagramEditorBayDetailAddDlg.h"
|
||||||
|
#include "diagramEditor/diagramEditorBaseBlock.h"
|
||||||
|
#include "diagramEditor/diagramEditorWizard.h"
|
||||||
|
#include "diagramEditor/diagramEditorStructContainer.h"
|
||||||
|
|
||||||
DiagramEditorBayDetailAddDlg::DiagramEditorBayDetailAddDlg(QWidget *parent)
|
DiagramEditorBayDetailAddDlg::DiagramEditorBayDetailAddDlg(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, ui(new Ui::diagramEditorBayDetailAddDlg)
|
, ui(new Ui::diagramEditorBayDetailAddDlg)
|
||||||
,_selectedModel(nullptr)
|
,_selectedModel(nullptr)
|
||||||
,_pParent(nullptr)
|
,_pParent(nullptr)
|
||||||
|
,_bindItemModel(nullptr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||||
|
|
@ -64,6 +69,63 @@ void DiagramEditorBayDetailAddDlg::initial()
|
||||||
ui->tableView_selected->setSelectionBehavior(QAbstractItemView::SelectRows);
|
ui->tableView_selected->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
ui->tableView_selected->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
ui->tableView_selected->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||||
ui->tableView_selected->verticalHeader()->setVisible(false);
|
ui->tableView_selected->verticalHeader()->setVisible(false);
|
||||||
|
|
||||||
|
ui->cb_lineType->setItemData(0,1); //设置主线支线
|
||||||
|
ui->cb_lineType->setItemData(1,0);
|
||||||
|
//_bindItemModel = new QStandardItemModel(this);
|
||||||
|
//ui->cb_bindObj->setModel(_bindItemModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiagramEditorBayDetailAddDlg::updateBindLst()
|
||||||
|
{
|
||||||
|
ui->cb_bindObj->clear();
|
||||||
|
ui->cb_bindObj->addItem("无");
|
||||||
|
DiagramEditorBayBlock* pBlock = _pParent->getCurBlock();
|
||||||
|
if(pBlock){
|
||||||
|
QList<QUuid> lstCon = pBlock->getConnect();
|
||||||
|
DiagramEditorWizard* pWizard = _pParent->getWizard();
|
||||||
|
if(pWizard){
|
||||||
|
QMap<QUuid,DiagramEditorBriefConnect> mapCon = pWizard->getConnection();
|
||||||
|
for(auto& uid:lstCon){
|
||||||
|
if(mapCon.contains(uid)){
|
||||||
|
auto con = mapCon.value(uid);
|
||||||
|
DiagramEditorConnectType conOp = con.getOpposite(pBlock->getName());
|
||||||
|
if(conOp.nType == 1){ //母线单block单item
|
||||||
|
ui->cb_bindObj->addItem(conOp.sName,conOp.nType);
|
||||||
|
}
|
||||||
|
else if(conOp.nType == 3){ //变压器,选择对应进/出线口
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui->cb_bindObj->setCurrentIndex(0);
|
||||||
|
|
||||||
|
//_bindItemModel->clear();
|
||||||
|
/** pBlock = _pParent->getCurBlock();
|
||||||
|
if(pBlock){
|
||||||
|
QList<QUuid> lstCon = pBlock->getConnect();
|
||||||
|
DiagramEditorWizard* pWizard = _pParent->getWizard();
|
||||||
|
if(pWizard){
|
||||||
|
QMap<QUuid,DiagramEditorBriefConnect> mapCon = pWizard->getConnection();
|
||||||
|
for(auto& uid:lstCon){
|
||||||
|
if(mapCon.contains(uid)){
|
||||||
|
auto con = mapCon.value(uid);
|
||||||
|
DiagramEditorConnectType conOp = con.getOpposite(pBlock->getName());
|
||||||
|
auto container = pWizard->getContainerByBlock_all(conOp.sName);
|
||||||
|
|
||||||
|
if(conOp.nType == 1){
|
||||||
|
//ui->cb_bindObj->addItem(conOp.sName,conOp.nType);
|
||||||
|
auto pItem = new QStandardItem(conOp.sName);
|
||||||
|
pItem->setData(conOp.nType,Qt::UserRole);
|
||||||
|
pItem->setData(container->getId(),Qt::UserRole+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui->cb_bindObj->setCurrentIndex(0);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramEditorBayDetailAddDlg::showDlg()
|
void DiagramEditorBayDetailAddDlg::showDlg()
|
||||||
|
|
@ -80,6 +142,16 @@ void DiagramEditorBayDetailAddDlg::showDlg()
|
||||||
ui->label->setText("新建线路");
|
ui->label->setText("新建线路");
|
||||||
ui->le_routeName->setReadOnly(true);
|
ui->le_routeName->setReadOnly(true);
|
||||||
_curMode = 0;
|
_curMode = 0;
|
||||||
|
updateBindLst();
|
||||||
|
|
||||||
|
int nCount = pRoute->rowCount();
|
||||||
|
for(int i = 0;i < nCount;++i){
|
||||||
|
QStandardItem *itemRouteName = pRoute->item(i, 0);
|
||||||
|
int nMain = itemRouteName->data().toInt();
|
||||||
|
if(nMain == 1){ //主线已存在
|
||||||
|
ui->cb_lineType->setCurrentIndex(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,6 +236,23 @@ void DiagramEditorBayDetailAddDlg::showDlg(DiagramEditorRouteInfo info)
|
||||||
ui->label->setText("编辑线路");
|
ui->label->setText("编辑线路");
|
||||||
ui->le_routeName->setReadOnly(false);
|
ui->le_routeName->setReadOnly(false);
|
||||||
_curMode = 1;
|
_curMode = 1;
|
||||||
|
updateBindLst();
|
||||||
|
|
||||||
|
auto pRoute = _pParent->getRouteModel();
|
||||||
|
int nCount = pRoute->rowCount();
|
||||||
|
for(int i = 0;i < nCount;++i){
|
||||||
|
QStandardItem *itemRouteName = pRoute->item(i, 0);
|
||||||
|
if(itemRouteName->text() == info.sRouteName){
|
||||||
|
int nMain = itemRouteName->data().toInt();
|
||||||
|
if(nMain == 1){ //读取并设置是否主线
|
||||||
|
ui->cb_lineType->setCurrentIndex(1);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
ui->cb_lineType->setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -234,6 +323,7 @@ void DiagramEditorBayDetailAddDlg::onSaveClicked()
|
||||||
QString sType = ui->cb_type->currentText();
|
QString sType = ui->cb_type->currentText();
|
||||||
int nType = ui->cb_type->currentData().toInt();
|
int nType = ui->cb_type->currentData().toInt();
|
||||||
QString sBindObj = ui->cb_bindObj->currentText();
|
QString sBindObj = ui->cb_bindObj->currentText();
|
||||||
|
int nBindType = ui->cb_bindObj->currentData().toInt();
|
||||||
|
|
||||||
if(_pParent){
|
if(_pParent){
|
||||||
auto pCompoModel = _pParent->getComponentModel();
|
auto pCompoModel = _pParent->getComponentModel();
|
||||||
|
|
@ -287,6 +377,7 @@ void DiagramEditorBayDetailAddDlg::onSaveClicked()
|
||||||
itemType->setText(sType);
|
itemType->setText(sType);
|
||||||
itemType->setData(nType);
|
itemType->setData(nType);
|
||||||
itemObj->setText(sBindObj);
|
itemObj->setText(sBindObj);
|
||||||
|
itemObj->setData(nBindType);
|
||||||
|
|
||||||
QList<QStandardItem*> lstItems;
|
QList<QStandardItem*> lstItems;
|
||||||
lstItems<<itemCate<<itemName<<itemType<<itemObj<<itemRoute;
|
lstItems<<itemCate<<itemName<<itemType<<itemObj<<itemRoute;
|
||||||
|
|
@ -297,7 +388,7 @@ void DiagramEditorBayDetailAddDlg::onSaveClicked()
|
||||||
void DiagramEditorBayDetailAddDlg::onOkClicked()
|
void DiagramEditorBayDetailAddDlg::onOkClicked()
|
||||||
{
|
{
|
||||||
QString sRoute = ui->le_routeName->text();
|
QString sRoute = ui->le_routeName->text();
|
||||||
auto& mapRoute = _pParent->getRouteMap();
|
auto& mapRoute = _pParent->getBayInfo().mapRoute;
|
||||||
QStringList lstName; //线路的设备列表
|
QStringList lstName; //线路的设备列表
|
||||||
DiagramEditorRouteInfo routeInfo;
|
DiagramEditorRouteInfo routeInfo;
|
||||||
routeInfo.sRouteName = sRoute;
|
routeInfo.sRouteName = sRoute;
|
||||||
|
|
@ -315,7 +406,9 @@ void DiagramEditorBayDetailAddDlg::onOkClicked()
|
||||||
QString sName = itemName->text();
|
QString sName = itemName->text();
|
||||||
QString sType = itemType->text();
|
QString sType = itemType->text();
|
||||||
QString sBind = itemBind->text();
|
QString sBind = itemBind->text();
|
||||||
|
int nBindType = itemBind->data().toInt();
|
||||||
QString sAllRoute = itemAllRoute->text();
|
QString sAllRoute = itemAllRoute->text();
|
||||||
|
QUuid uid = itemName->data(Qt::UserRole+3).toUuid();
|
||||||
|
|
||||||
int nCate = 0;
|
int nCate = 0;
|
||||||
if(sCate == "电气设备")
|
if(sCate == "电气设备")
|
||||||
|
|
@ -330,6 +423,8 @@ void DiagramEditorBayDetailAddDlg::onOkClicked()
|
||||||
compoInfo.sName = sName;
|
compoInfo.sName = sName;
|
||||||
compoInfo.nType = nType;
|
compoInfo.nType = nType;
|
||||||
compoInfo.sBindObj = sBind;
|
compoInfo.sBindObj = sBind;
|
||||||
|
compoInfo.nBindType = nBindType;
|
||||||
|
compoInfo.uid = uid;
|
||||||
compoInfo.sUsedRoute = sAllRoute.split(",");
|
compoInfo.sUsedRoute = sAllRoute.split(",");
|
||||||
|
|
||||||
routeInfo.lstCompo.append(compoInfo);
|
routeInfo.lstCompo.append(compoInfo);
|
||||||
|
|
@ -337,6 +432,17 @@ void DiagramEditorBayDetailAddDlg::onOkClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
QString strCompoNames = lstName.join(",");
|
QString strCompoNames = lstName.join(",");
|
||||||
|
int nMain = ui->cb_lineType->currentData().toInt(); //是否主线
|
||||||
|
if(nMain == 1){ //设本线路为主线,重置其他线路主线标志
|
||||||
|
auto pRoute = _pParent->getRouteModel();
|
||||||
|
int nCount = pRoute->rowCount();
|
||||||
|
for(int i = 0;i < rowCount;++i){
|
||||||
|
QStandardItem *itemRouteName = pRoute->item(i, 0);
|
||||||
|
if(itemRouteName)
|
||||||
|
itemRouteName->setData(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
routeInfo.bMainRoute = nMain;
|
||||||
|
|
||||||
if(_curMode == 0){
|
if(_curMode == 0){
|
||||||
if(mapRoute.contains(sRoute)){
|
if(mapRoute.contains(sRoute)){
|
||||||
|
|
@ -349,6 +455,7 @@ void DiagramEditorBayDetailAddDlg::onOkClicked()
|
||||||
QStandardItem *itemRoute = new QStandardItem();
|
QStandardItem *itemRoute = new QStandardItem();
|
||||||
QStandardItem *itemNames = new QStandardItem();
|
QStandardItem *itemNames = new QStandardItem();
|
||||||
itemRoute->setText(sRoute);
|
itemRoute->setText(sRoute);
|
||||||
|
itemRoute->setData(nMain);
|
||||||
itemNames->setText(strCompoNames);
|
itemNames->setText(strCompoNames);
|
||||||
|
|
||||||
QList<QStandardItem*> lstItems;
|
QList<QStandardItem*> lstItems;
|
||||||
|
|
@ -364,6 +471,7 @@ void DiagramEditorBayDetailAddDlg::onOkClicked()
|
||||||
for(int i = 0;i < rowCount;++i){
|
for(int i = 0;i < rowCount;++i){
|
||||||
QStandardItem *itemName = pRoute->item(i, 0);
|
QStandardItem *itemName = pRoute->item(i, 0);
|
||||||
if(itemName->text() == sRoute){
|
if(itemName->text() == sRoute){
|
||||||
|
itemName->setData(nMain);
|
||||||
QStandardItem *itemRoutes = pRoute->item(i, 1);
|
QStandardItem *itemRoutes = pRoute->item(i, 1);
|
||||||
itemRoutes->setText(strCompoNames);
|
itemRoutes->setText(strCompoNames);
|
||||||
break;
|
break;
|
||||||
|
|
@ -427,7 +535,7 @@ void DiagramEditorBayDetailAddDlg::onComponentDeleteClicked()
|
||||||
QString sName = indexName.data().toString();
|
QString sName = indexName.data().toString();
|
||||||
|
|
||||||
bool bUsed = false;
|
bool bUsed = false;
|
||||||
auto& mapRoute = _pParent->getRouteMap(); //检索所有路线,判断设备占用情况
|
auto& mapRoute = _pParent->getBayInfo().mapRoute; //检索所有路线,判断设备占用情况
|
||||||
for(auto& route:mapRoute){
|
for(auto& route:mapRoute){
|
||||||
QString sRoute = route.sRouteName;
|
QString sRoute = route.sRouteName;
|
||||||
for(auto& compo:route.lstCompo){
|
for(auto& compo:route.lstCompo){
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ DiagramEditorBayDetailSettingDlg::DiagramEditorBayDetailSettingDlg(QWidget *pare
|
||||||
,_routeModel(nullptr)
|
,_routeModel(nullptr)
|
||||||
,_pPreviewDlg(nullptr)
|
,_pPreviewDlg(nullptr)
|
||||||
,_pModel(nullptr)
|
,_pModel(nullptr)
|
||||||
|
,_pWizard(nullptr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||||
|
|
@ -48,6 +49,9 @@ void DiagramEditorBayDetailSettingDlg::initial()
|
||||||
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||||
ui->tableView->verticalHeader()->setVisible(false);
|
ui->tableView->verticalHeader()->setVisible(false);
|
||||||
|
|
||||||
|
ui->cb_layout->addItem("纵向",0);
|
||||||
|
ui->cb_layout->addItem("横向",1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramEditorBayDetailSettingDlg::refreshModel()
|
void DiagramEditorBayDetailSettingDlg::refreshModel()
|
||||||
|
|
@ -56,7 +60,7 @@ void DiagramEditorBayDetailSettingDlg::refreshModel()
|
||||||
_compoModel->clear();
|
_compoModel->clear();
|
||||||
_compoModel->setColumnCount(5);
|
_compoModel->setColumnCount(5);
|
||||||
_compoModel->setHorizontalHeaderLabels({"分类", "名称", "类型", "关联对象", "引用线路"});
|
_compoModel->setHorizontalHeaderLabels({"分类", "名称", "类型", "关联对象", "引用线路"});
|
||||||
auto mapComponent = _curOperateObj->getComponentMap();
|
auto mapComponent = _curOperateObj->getBayInfo().mapComponent;
|
||||||
for(auto& comp:mapComponent){
|
for(auto& comp:mapComponent){
|
||||||
DiagramEditorComponentInfo info = comp;
|
DiagramEditorComponentInfo info = comp;
|
||||||
QStandardItem *itemCate = new QStandardItem();
|
QStandardItem *itemCate = new QStandardItem();
|
||||||
|
|
@ -142,8 +146,10 @@ void DiagramEditorBayDetailSettingDlg::refreshModel()
|
||||||
_routeModel->clear();
|
_routeModel->clear();
|
||||||
_routeModel->setColumnCount(2);
|
_routeModel->setColumnCount(2);
|
||||||
_routeModel->setHorizontalHeaderLabels({"线路名", "包含设备"});
|
_routeModel->setHorizontalHeaderLabels({"线路名", "包含设备"});
|
||||||
auto mapRoute = _curOperateObj->getRouteInfoMap();
|
auto info = _curOperateObj->getBayInfo();
|
||||||
setRouteMap(mapRoute); //更新路径数据到本界面
|
setBayInfo(info);
|
||||||
|
auto mapRoute = info.mapRoute; //更新路径数据到本界面
|
||||||
|
|
||||||
for(auto& route:mapRoute){
|
for(auto& route:mapRoute){
|
||||||
QString sRoute = route.sRouteName;
|
QString sRoute = route.sRouteName;
|
||||||
QStringList lstComp;
|
QStringList lstComp;
|
||||||
|
|
@ -168,6 +174,10 @@ void DiagramEditorBayDetailSettingDlg::showDlg(DiagramEditorBayBlock* p)
|
||||||
{
|
{
|
||||||
show();
|
show();
|
||||||
_curOperateObj = p;
|
_curOperateObj = p;
|
||||||
|
if(p->getBayType() == BayType::busSectionBay) //分段间隔默认水平
|
||||||
|
ui->cb_layout->setCurrentIndex(1);
|
||||||
|
else
|
||||||
|
ui->cb_layout->setCurrentIndex(0);
|
||||||
refreshModel();
|
refreshModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -184,7 +194,6 @@ void DiagramEditorBayDetailSettingDlg::onOkClicked()
|
||||||
{
|
{
|
||||||
//将ui设置的参数更新到对应block
|
//将ui设置的参数更新到对应block
|
||||||
if(_curOperateObj){
|
if(_curOperateObj){
|
||||||
_curOperateObj->setRouteInfoMap(_mapRouteInfo);
|
|
||||||
|
|
||||||
QMap<QString,DiagramEditorComponentInfo> mapComponents;
|
QMap<QString,DiagramEditorComponentInfo> mapComponents;
|
||||||
int nRowCount = _compoModel->rowCount();
|
int nRowCount = _compoModel->rowCount();
|
||||||
|
|
@ -210,6 +219,7 @@ void DiagramEditorBayDetailSettingDlg::onOkClicked()
|
||||||
compoInfo.sName = itemName->text();
|
compoInfo.sName = itemName->text();
|
||||||
compoInfo.nType = itemType->data().toInt();
|
compoInfo.nType = itemType->data().toInt();
|
||||||
compoInfo.sBindObj = itemBind->text();
|
compoInfo.sBindObj = itemBind->text();
|
||||||
|
compoInfo.nBindType = itemBind->data().toInt();
|
||||||
compoInfo.sUsedRoute = itemRoute->text().split(",");
|
compoInfo.sUsedRoute = itemRoute->text().split(",");
|
||||||
compoInfo.nUsedDirection = nDir;
|
compoInfo.nUsedDirection = nDir;
|
||||||
compoInfo.deltaPos = deltaPos;
|
compoInfo.deltaPos = deltaPos;
|
||||||
|
|
@ -219,7 +229,10 @@ void DiagramEditorBayDetailSettingDlg::onOkClicked()
|
||||||
|
|
||||||
mapComponents.insert(compoInfo.sName,compoInfo);
|
mapComponents.insert(compoInfo.sName,compoInfo);
|
||||||
}
|
}
|
||||||
_curOperateObj->setComponentMap(mapComponents);
|
int nLayout = ui->cb_layout->currentData().toInt();
|
||||||
|
_curBayInfo.nLayout = nLayout;
|
||||||
|
_curBayInfo.mapComponent = mapComponents;
|
||||||
|
_curOperateObj->setBayInfo(_curBayInfo);
|
||||||
TopologyManager::instance().clearGlobalBlockData(_curOperateObj->getName());
|
TopologyManager::instance().clearGlobalBlockData(_curOperateObj->getName());
|
||||||
TopologyManager::instance().moveTempBlockData();
|
TopologyManager::instance().moveTempBlockData();
|
||||||
_curOperateObj = nullptr;
|
_curOperateObj = nullptr;
|
||||||
|
|
@ -268,7 +281,7 @@ void DiagramEditorBayDetailSettingDlg::onRouteDeleteClicked()
|
||||||
_routeModel->removeRow(row);
|
_routeModel->removeRow(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
_mapRouteInfo.remove(sName); //同步移除数据
|
_curBayInfo.mapRoute.remove(sName); //同步移除数据
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramEditorBayDetailSettingDlg::onRouteRbtnClicked(const QPoint &pos)
|
void DiagramEditorBayDetailSettingDlg::onRouteRbtnClicked(const QPoint &pos)
|
||||||
|
|
@ -313,12 +326,13 @@ void DiagramEditorBayDetailSettingDlg::onRouteEditClicked()
|
||||||
QModelIndex indexName = index.sibling(index.row(),0);
|
QModelIndex indexName = index.sibling(index.row(),0);
|
||||||
QString sName = indexName.data().toString();
|
QString sName = indexName.data().toString();
|
||||||
|
|
||||||
auto routeInfo = _mapRouteInfo.value(sName);
|
auto routeInfo = _curBayInfo.mapRoute.value(sName);
|
||||||
_pAddDlg->showDlg(routeInfo);
|
_pAddDlg->showDlg(routeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramEditorBayDetailSettingDlg::onPreviewClicked()
|
void DiagramEditorBayDetailSettingDlg::onPreviewClicked()
|
||||||
{
|
{
|
||||||
|
int nLayout = ui->cb_layout->currentData().toInt();
|
||||||
if(_pPreviewDlg == nullptr){
|
if(_pPreviewDlg == nullptr){
|
||||||
_pPreviewDlg = new DiagramEditorBayPreviewDlg(this);
|
_pPreviewDlg = new DiagramEditorBayPreviewDlg(this);
|
||||||
_pPreviewDlg->setParent(this);
|
_pPreviewDlg->setParent(this);
|
||||||
|
|
@ -326,7 +340,7 @@ void DiagramEditorBayDetailSettingDlg::onPreviewClicked()
|
||||||
_pModel->setCurBayRouteModel(_routeModel);
|
_pModel->setCurBayRouteModel(_routeModel);
|
||||||
}
|
}
|
||||||
if(!_pPreviewDlg->isVisible()){
|
if(!_pPreviewDlg->isVisible()){
|
||||||
_pPreviewDlg->showDlg();
|
_pPreviewDlg->showDlg(nLayout);
|
||||||
_pModel->generateTempBay();
|
_pModel->generateTempBay();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,20 @@ void DiagramEditorBayPreviewDlg::initial()
|
||||||
_pView->setScene(_pScene);
|
_pView->setScene(_pScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramEditorBayPreviewDlg::showDlg()
|
void DiagramEditorBayPreviewDlg::showDlg(int nLayout)
|
||||||
{
|
{
|
||||||
if(_pParent){
|
if(_pParent){
|
||||||
_pParent->getModel()->setCurPreviewScene(_pScene);
|
_pParent->getModel()->setCurPreviewScene(_pScene);
|
||||||
}
|
}
|
||||||
show();
|
show();
|
||||||
_pParent->getModel()->updateTarget(_pParent->getRouteMap(),41,0); //1下2右
|
int nDir = 0;
|
||||||
|
if(nLayout == 0){ //纵,下右
|
||||||
|
nDir = 41;
|
||||||
|
}
|
||||||
|
else if(nLayout == 1){ //横,右下
|
||||||
|
nDir = 14;
|
||||||
|
}
|
||||||
|
_pParent->getModel()->updateTarget(_pParent->getBayInfo().mapRoute,nDir,0);
|
||||||
//updateModelData();
|
//updateModelData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ void DiagramEditorBaySettingDlg::showDlg(int nLevel,DiagramEditorBayBlock* p)
|
||||||
for(auto& conId:lstCon){
|
for(auto& conId:lstCon){
|
||||||
if(_pWizard->getConnection().contains(conId)){
|
if(_pWizard->getConnection().contains(conId)){
|
||||||
auto con = _pWizard->getConnection().value(conId);
|
auto con = _pWizard->getConnection().value(conId);
|
||||||
QString sOpposite = con.getOppositeName(p->getName());
|
QString sOpposite = con.getOpposite(p->getName()).sName;
|
||||||
lst.append(sOpposite);
|
lst.append(sOpposite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ void DiagramEditorPreviewDlg::initial()
|
||||||
_pMainLayout = new QVBoxLayout(this);
|
_pMainLayout = new QVBoxLayout(this);
|
||||||
_pView = new EditView(this);
|
_pView = new EditView(this);
|
||||||
_pMainLayout->addWidget(_pView);
|
_pMainLayout->addWidget(_pView);
|
||||||
_pScene = new EditPreviewScene(this);
|
_pScene = new EditScene(this);
|
||||||
_pScene->setSceneRect(_pParent->getScene()->sceneRect()); //使用父窗口scene大小
|
_pScene->setSceneRect(_pParent->getScene()->sceneRect()); //使用父窗口scene大小
|
||||||
_pView->setScene(_pScene);
|
_pView->setScene(_pScene);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ void DiagramEditorTransSettingDlg::showDlg(DiagramEditorTransformerBlock* p)
|
||||||
for(auto& conId:lstCon){
|
for(auto& conId:lstCon){
|
||||||
if(_pWizard->getConnection().contains(conId)){
|
if(_pWizard->getConnection().contains(conId)){
|
||||||
auto con = _pWizard->getConnection().value(conId);
|
auto con = _pWizard->getConnection().value(conId);
|
||||||
QString sOpposite = con.getOppositeName(p->getName());
|
QString sOpposite = con.getOpposite(p->getName()).sName;
|
||||||
|
|
||||||
QString sPos;
|
QString sPos;
|
||||||
if(con.nPara == 0){
|
if(con.nPara == 0){
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,7 @@ void DiagramEditorWizard::flushTransPage()
|
||||||
for(auto& conId:lstCon){
|
for(auto& conId:lstCon){
|
||||||
if(_mapConnect.contains(conId)){
|
if(_mapConnect.contains(conId)){
|
||||||
auto con = _mapConnect.value(conId);
|
auto con = _mapConnect.value(conId);
|
||||||
QString sOpposite = con.getOppositeName(pItem->getName());
|
QString sOpposite = con.getOpposite(pItem->getName()).sName;
|
||||||
|
|
||||||
QString sPos;
|
QString sPos;
|
||||||
if(con.nPara == 0){
|
if(con.nPara == 0){
|
||||||
|
|
@ -903,7 +903,7 @@ bool DiagramEditorWizard::removeBlockByName(int nLevel,int nType,const QString&
|
||||||
QList<QUuid> lstUid = lst[i]->getConnect();
|
QList<QUuid> lstUid = lst[i]->getConnect();
|
||||||
for(auto uid:lstUid){ //删除对象前删除连接
|
for(auto uid:lstUid){ //删除对象前删除连接
|
||||||
auto con = _mapConnect.value(uid);
|
auto con = _mapConnect.value(uid);
|
||||||
QString sOppo = con.getOppositeName(sName); //删除相连的对象中连接信息
|
QString sOppo = con.getOpposite(sName).sName; //删除相连的对象中连接信息
|
||||||
auto pBlock = getBlockByName_all(sOppo);
|
auto pBlock = getBlockByName_all(sOppo);
|
||||||
if(pBlock){
|
if(pBlock){
|
||||||
pBlock->removeConnect(uid);
|
pBlock->removeConnect(uid);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include "diagramEditor/diagramEditorBayDetailSettingDlg.h"
|
#include "diagramEditor/diagramEditorBayDetailSettingDlg.h"
|
||||||
#include "diagramEditor/diagramEditorTransDetailSettingDlg.h"
|
#include "diagramEditor/diagramEditorTransDetailSettingDlg.h"
|
||||||
#include "graphicsDataModel/diagramEditorModel.h"
|
#include "graphicsDataModel/diagramEditorModel.h"
|
||||||
|
#include "diagramEditor/diagramEditorPreviewDlg.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
@ -27,6 +28,7 @@ EditPanel::EditPanel(QWidget *parent)
|
||||||
,_bayDetailSetting(nullptr)
|
,_bayDetailSetting(nullptr)
|
||||||
,_transDetailSetting(nullptr)
|
,_transDetailSetting(nullptr)
|
||||||
,_pModel(nullptr)
|
,_pModel(nullptr)
|
||||||
|
,_pPreview(nullptr)
|
||||||
{
|
{
|
||||||
_pModel = new DiagramEditorModel();
|
_pModel = new DiagramEditorModel();
|
||||||
_pModel->setPanel(this);
|
_pModel->setPanel(this);
|
||||||
|
|
@ -34,6 +36,7 @@ EditPanel::EditPanel(QWidget *parent)
|
||||||
_maxHeight = 0;
|
_maxHeight = 0;
|
||||||
_layout = new QVBoxLayout(this);
|
_layout = new QVBoxLayout(this);
|
||||||
m_pEditScene = new EditScene(this);
|
m_pEditScene = new EditScene(this);
|
||||||
|
m_pEditScene->setModel(_pModel);
|
||||||
//设置场景大小.前两个参数为scene的坐标远点,设置到view的中心点后,无论view如何缩放,secne的坐标原点都不会动,方便后续的位置计算
|
//设置场景大小.前两个参数为scene的坐标远点,设置到view的中心点后,无论view如何缩放,secne的坐标原点都不会动,方便后续的位置计算
|
||||||
//m_pEditScene->setSceneRect(-g_dGriaphicsScene_Width / 2, -g_dGriaphicsScene_Height / 2, g_dGriaphicsScene_Width, g_dGriaphicsScene_Height);
|
//m_pEditScene->setSceneRect(-g_dGriaphicsScene_Width / 2, -g_dGriaphicsScene_Height / 2, g_dGriaphicsScene_Width, g_dGriaphicsScene_Height);
|
||||||
m_pEditScene->setSceneRect(0, 0, g_dGriaphicsScene_Width*2, g_dGriaphicsScene_Height*2);
|
m_pEditScene->setSceneRect(0, 0, g_dGriaphicsScene_Width*2, g_dGriaphicsScene_Height*2);
|
||||||
|
|
@ -350,6 +353,14 @@ void EditPanel::initBlockConnection()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditPanel::showPreview()
|
||||||
|
{
|
||||||
|
if(!_pPreview){
|
||||||
|
_pPreview = new DiagramEditorPreviewDlg(this);
|
||||||
|
}
|
||||||
|
_pPreview->showDlg();
|
||||||
|
}
|
||||||
|
|
||||||
QList<EditBaseItem*> EditPanel::getBlockItems(EditorItemType typ)
|
QList<EditBaseItem*> EditPanel::getBlockItems(EditorItemType typ)
|
||||||
{
|
{
|
||||||
QList<EditBaseItem*> lst;
|
QList<EditBaseItem*> lst;
|
||||||
|
|
@ -410,6 +421,7 @@ void EditPanel::onItemDbClicked(QPointer<DiagramEditorBaseBlock> pBlock)
|
||||||
if(_bayDetailSetting == nullptr){
|
if(_bayDetailSetting == nullptr){
|
||||||
_bayDetailSetting = new DiagramEditorBayDetailSettingDlg(this);
|
_bayDetailSetting = new DiagramEditorBayDetailSettingDlg(this);
|
||||||
_bayDetailSetting->setModelDelegate(_pModel);
|
_bayDetailSetting->setModelDelegate(_pModel);
|
||||||
|
_bayDetailSetting->setWizard(_curWizard);
|
||||||
}
|
}
|
||||||
auto pBay = dynamic_cast<DiagramEditorBayBlock*>(pBlock.data());
|
auto pBay = dynamic_cast<DiagramEditorBayBlock*>(pBlock.data());
|
||||||
if(pBay)
|
if(pBay)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
#include "diagramEditor/editScene.h"
|
#include "diagramEditor/editScene.h"
|
||||||
|
#include <QGraphicsSceneContextMenuEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QAction>
|
||||||
|
#include "graphicsDataModel/diagramEditorModel.h"
|
||||||
|
|
||||||
EditBaseScene::EditBaseScene(QObject *parent)
|
EditBaseScene::EditBaseScene(QObject *parent)
|
||||||
: QGraphicsScene(parent)
|
: QGraphicsScene(parent)
|
||||||
|
|
@ -20,6 +24,21 @@ EditScene::~EditScene()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
|
{
|
||||||
|
QMenu menu;
|
||||||
|
QAction *previewAction = menu.addAction("预览");
|
||||||
|
QAction *generateAction = menu.addAction("生成");
|
||||||
|
QAction *selectedAction = menu.exec(event->screenPos());
|
||||||
|
if (selectedAction == previewAction) {
|
||||||
|
if(_pModel){
|
||||||
|
//_pModel->setCurPreviewScene(this);
|
||||||
|
_pModel->generatePreview();
|
||||||
|
}
|
||||||
|
} else if (selectedAction == generateAction) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
/************************预览*********************/
|
/************************预览*********************/
|
||||||
|
|
||||||
EditPreviewScene::EditPreviewScene(QObject *parent)
|
EditPreviewScene::EditPreviewScene(QObject *parent)
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ void WizardBayContentDlg::flushData(int nLevel)
|
||||||
for(auto& conId:lstCon){
|
for(auto& conId:lstCon){
|
||||||
if(_pWizard->getConnection().contains(conId)){
|
if(_pWizard->getConnection().contains(conId)){
|
||||||
auto con = _pWizard->getConnection().value(conId);
|
auto con = _pWizard->getConnection().value(conId);
|
||||||
QString sOpposite = con.getOppositeName(pItem->getName());
|
QString sOpposite = con.getOpposite(pItem->getName()).sName;
|
||||||
info.lstBindObj.append(sOpposite);
|
info.lstBindObj.append(sOpposite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,51 @@ void BaseModel::createTopoTerminalsByItem(GraphicsBaseItem* pItem,ModelFunctionT
|
||||||
|
|
||||||
QPointF BaseModel::calculateBusPortPos(GraphicsBaseItem* pBus,GraphicsBaseItem* item)
|
QPointF BaseModel::calculateBusPortPos(GraphicsBaseItem* pBus,GraphicsBaseItem* item)
|
||||||
{
|
{
|
||||||
return QPointF(item->pos().x(),pBus->pos().y());
|
//return QPointF(item->pos().x(),pBus->pos().y());
|
||||||
|
QRectF recBus = pBus->sceneBoundingRect();
|
||||||
|
QLineF busLine = QLineF(recBus.left(),recBus.y(),recBus.right(),recBus.y());
|
||||||
|
|
||||||
|
QPointF p1 = busLine.p1();
|
||||||
|
QPointF p2 = busLine.p2();
|
||||||
|
|
||||||
|
// 计算item的中心点在垂直于线段方向上的投影
|
||||||
|
QPointF itemCenter = item->pos() + QPointF(item->boundingRect().width()/2, item->boundingRect().height()/2);
|
||||||
|
|
||||||
|
// 计算投影点在线段上的位置
|
||||||
|
QPointF projection;
|
||||||
|
if (busLine.length() == 0) { // 如果线段长度为0,直接返回端点
|
||||||
|
projection = p1;
|
||||||
|
} else {
|
||||||
|
// 计算投影点
|
||||||
|
QPointF vec = p2 - p1;
|
||||||
|
QPointF relPos = itemCenter - p1;
|
||||||
|
qreal dot = QPointF::dotProduct(relPos, vec) / (busLine.length() * busLine.length());
|
||||||
|
|
||||||
|
// 限制投影点在线段范围内
|
||||||
|
dot = qBound(0.0, dot, 1.0);
|
||||||
|
projection = p1 + dot * vec;
|
||||||
|
}
|
||||||
|
|
||||||
|
return projection;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemPort* BaseModel::getClosestUnusedPort(QMap<QString,ItemPort*> mapPorts,GraphicsBaseItem* item,ModelFunctionType nType)
|
||||||
|
{
|
||||||
|
QMap<double,ItemPort*> mapDistance;
|
||||||
|
|
||||||
|
// 收集所有端口及其距离
|
||||||
|
for(auto& port: mapPorts) {
|
||||||
|
double dis = distanceBetweenItems(port, item);
|
||||||
|
mapDistance.insert(dis, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto& port:mapDistance){ //从小到大遍历
|
||||||
|
auto lst = TopologyManager::instance().getConnectionsForTerminal(port->getId(),nType);
|
||||||
|
if(lst.isEmpty()){ //没被占用
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TypeLine> void BaseModel::establishConnection(GraphicsBaseItem* pSrc,GraphicsBaseItem* pDest,TypeLine* pItem,ModelFunctionType nType,int nMode,int nParam)
|
template<typename TypeLine> void BaseModel::establishConnection(GraphicsBaseItem* pSrc,GraphicsBaseItem* pDest,TypeLine* pItem,ModelFunctionType nType,int nMode,int nParam)
|
||||||
|
|
@ -49,7 +93,7 @@ template<typename TypeLine> void BaseModel::establishConnection(GraphicsBaseItem
|
||||||
int nTypeSrc = pSrc->getProperty()->type();
|
int nTypeSrc = pSrc->getProperty()->type();
|
||||||
int nTypeDest = pDest->getProperty()->type();
|
int nTypeDest = pDest->getProperty()->type();
|
||||||
//if(pSrc->getItemType() == GIT_baseBus)
|
//if(pSrc->getItemType() == GIT_baseBus)
|
||||||
if((nTypeSrc == 1 || nTypeSrc == 0) && (nTypeDest != 1 && nTypeDest != 0)) //母线或节点
|
if((nTypeSrc == 1 || nTypeSrc == 0) && (nTypeDest != 1 && nTypeDest != 0)) //src是母线或节点
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if(nTypeSrc == 1 )
|
if(nTypeSrc == 1 )
|
||||||
|
|
@ -62,15 +106,17 @@ template<typename TypeLine> void BaseModel::establishConnection(GraphicsBaseItem
|
||||||
QMap<QString,ItemPort*> mapPorts = pDest->getPorts();
|
QMap<QString,ItemPort*> mapPorts = pDest->getPorts();
|
||||||
|
|
||||||
if(nMode == 0){
|
if(nMode == 0){
|
||||||
double minDis = 999;
|
/*double minDis = 999;
|
||||||
for(auto& port:mapPorts) //与母线或节点连接时,连接最近接线点
|
for(auto& port:mapPorts) //与母线或节点连接时,连接最近接线点
|
||||||
{
|
{
|
||||||
double dis = distanceBetweenItems(port,pDest);
|
double dis = distanceBetweenItems(port,pSrc);
|
||||||
if(dis < minDis){
|
if(dis < minDis){
|
||||||
minDis = dis;
|
minDis = dis;
|
||||||
pDestPort = port;
|
pDestPort = port;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
pDestPort = getClosestUnusedPort(mapPorts,pSrc,nType);
|
||||||
}
|
}
|
||||||
else if(nMode == 1){
|
else if(nMode == 1){
|
||||||
for(auto& port:mapPorts) //连接中性点
|
for(auto& port:mapPorts) //连接中性点
|
||||||
|
|
@ -110,7 +156,7 @@ template<typename TypeLine> void BaseModel::establishConnection(GraphicsBaseItem
|
||||||
QMap<QString,ItemPort*> mapPorts = pSrc->getPorts();
|
QMap<QString,ItemPort*> mapPorts = pSrc->getPorts();
|
||||||
|
|
||||||
if(nMode == 0){
|
if(nMode == 0){
|
||||||
double minDis = 999;
|
/*double minDis = 999;
|
||||||
for(auto& port:mapPorts) //与母线或节点连接时,连接最近接线点
|
for(auto& port:mapPorts) //与母线或节点连接时,连接最近接线点
|
||||||
{
|
{
|
||||||
double dis = distanceBetweenItems(port,pDest);
|
double dis = distanceBetweenItems(port,pDest);
|
||||||
|
|
@ -118,12 +164,9 @@ template<typename TypeLine> void BaseModel::establishConnection(GraphicsBaseItem
|
||||||
minDis = dis;
|
minDis = dis;
|
||||||
pSrcPort = port;
|
pSrcPort = port;
|
||||||
}
|
}
|
||||||
/*if(port->getType() == T_lineOut)
|
|
||||||
{
|
|
||||||
pSrcPort = port;
|
|
||||||
break;
|
|
||||||
}*/
|
}*/
|
||||||
}
|
|
||||||
|
pSrcPort = getClosestUnusedPort(mapPorts,pDest,nType);
|
||||||
}
|
}
|
||||||
else if(nMode == 1){
|
else if(nMode == 1){
|
||||||
for(auto& port:mapPorts) //连接中性点
|
for(auto& port:mapPorts) //连接中性点
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,9 @@ DiagramEditorModel::~DiagramEditorModel()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiagramEditorModel::addTempPreviewItem(QUuid uuid,GraphicsBaseModelItem* pItem)
|
bool DiagramEditorModel::addPreviewItem(QUuid uuid,GraphicsBaseModelItem* pItem,int mode)
|
||||||
{
|
{
|
||||||
|
if(mode == 0){
|
||||||
if(_tempItem.contains(uuid))
|
if(_tempItem.contains(uuid))
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
|
|
@ -40,11 +41,29 @@ bool DiagramEditorModel::addTempPreviewItem(QUuid uuid,GraphicsBaseModelItem* pI
|
||||||
_tempItem.insert(uuid,pItem);
|
_tempItem.insert(uuid,pItem);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if(mode == 1){
|
||||||
|
if(_previewItem.contains(uuid))
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_previewItem.insert(uuid,pItem);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiagramEditorItemProperty* DiagramEditorModel::addTempPreviewData(QUuid id,int type,QString name,QString metaName,QString sBlock)
|
DiagramEditorItemProperty* DiagramEditorModel::addPreviewData(QUuid id,int type,QString name,QString metaName,QString sBlock,int mode)
|
||||||
{
|
{
|
||||||
DiagramEditorItemProperty* pData = BasePropertyManager::instance().findTempEditorData(id); //已存在不不创建
|
DiagramEditorItemProperty* pData = nullptr;
|
||||||
|
if(mode == 0){
|
||||||
|
pData = BasePropertyManager::instance().findTempEditorData(id); //已存在不不创建
|
||||||
|
}
|
||||||
|
else if(mode == 1){
|
||||||
|
pData = BasePropertyManager::instance().findEditorData(id);
|
||||||
|
}
|
||||||
|
|
||||||
if(pData != nullptr)
|
if(pData != nullptr)
|
||||||
return pData;
|
return pData;
|
||||||
|
|
||||||
|
|
@ -59,8 +78,14 @@ DiagramEditorItemProperty* DiagramEditorModel::addTempPreviewData(QUuid id,int t
|
||||||
itemData->setName(name);
|
itemData->setName(name);
|
||||||
if(!sBlock.isEmpty())
|
if(!sBlock.isEmpty())
|
||||||
itemData->setBlock(sBlock);
|
itemData->setBlock(sBlock);
|
||||||
|
if(mode == 0){
|
||||||
BasePropertyManager::instance().insertTempEditorData(id,itemData);
|
BasePropertyManager::instance().insertTempEditorData(id,itemData);
|
||||||
}
|
}
|
||||||
|
else if(mode == 1){
|
||||||
|
BasePropertyManager::instance().insertEditorData(id,itemData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return itemData;
|
return itemData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,7 +125,7 @@ void DiagramEditorModel::generateTempBay()
|
||||||
generateItemByModel(_pCurBayRoute);
|
generateItemByModel(_pCurBayRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramEditorModel::generateTempComponent(QUuid uid,QString sName,int nCategory,int nType,QPoint pos,int nRotate)
|
GraphicsBaseModelItem* DiagramEditorModel::generateComponent(QUuid uid,QString sName,int nCategory,int nType,QPointF pos,int nRotate,int mode)
|
||||||
{
|
{
|
||||||
GraphicsBaseModelItem* pItem = nullptr;
|
GraphicsBaseModelItem* pItem = nullptr;
|
||||||
if(nCategory == 0)
|
if(nCategory == 0)
|
||||||
|
|
@ -196,42 +221,50 @@ void DiagramEditorModel::generateTempComponent(QUuid uid,QString sName,int nCate
|
||||||
if(pItem){
|
if(pItem){
|
||||||
pItem->setItemId(uid);
|
pItem->setItemId(uid);
|
||||||
pItem->setRotation(nRotate);
|
pItem->setRotation(nRotate);
|
||||||
PowerEntity* pEntityData = TopologyManager::instance().createEntity(EntityType::Component,uid.toString(),sName,ModelFunctionType::BlockEditorModel);
|
ModelFunctionType typ;
|
||||||
|
if(mode == 0){
|
||||||
|
typ = ModelFunctionType::BlockEditorModel;
|
||||||
|
}
|
||||||
|
else if(mode == 1){
|
||||||
|
typ = ModelFunctionType::EditorModel;
|
||||||
|
}
|
||||||
|
PowerEntity* pEntityData = TopologyManager::instance().createEntity(EntityType::Component,uid.toString(),sName,typ);
|
||||||
if(pEntityData)
|
if(pEntityData)
|
||||||
pItem->setEntity(pEntityData);
|
pItem->setEntity(pEntityData);
|
||||||
DiagramEditorItemProperty* pData = nullptr;
|
DiagramEditorItemProperty* pData = nullptr;
|
||||||
if(nCategory == 1){
|
if(nCategory == 1){
|
||||||
pData = addTempPreviewData(uid,0,sName,"node");
|
pData = addPreviewData(uid,0,sName,"node","",mode);
|
||||||
}
|
}
|
||||||
else if(nCategory == 0){ //设备
|
else if(nCategory == 0){ //设备
|
||||||
pData = addTempPreviewData(uid,nType,sName,DataBase::GetInstance()->ModelType()[nType].modelType);
|
pData = addPreviewData(uid,nType,sName,DataBase::GetInstance()->ModelType()[nType].modelType,"",mode);
|
||||||
pData->setGraphicsType(pItem->getItemType());
|
pData->setGraphicsType(pItem->getItemType());
|
||||||
}
|
}
|
||||||
if(pData)
|
if(pData)
|
||||||
{
|
{
|
||||||
pItem->setProperty(pData);
|
pItem->setProperty(pData);
|
||||||
createTopoTerminalsByItem(pItem,ModelFunctionType::BlockEditorModel);
|
createTopoTerminalsByItem(pItem,typ);
|
||||||
pData->setDataChanged(true); //数据状态改变
|
pData->setDataChanged(true); //数据状态改变
|
||||||
}
|
}
|
||||||
addTempPreviewItem(uid,pItem);
|
addPreviewItem(uid,pItem,mode);
|
||||||
_pCurPreviewScene->addItem(pItem);
|
_pCurPreviewScene->addItem(pItem);
|
||||||
pItem->setPos(pos);
|
pItem->setPos(pos);
|
||||||
}
|
}
|
||||||
|
return pItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElectricBaseModelLineItem* DiagramEditorModel::generateTempLine(QUuid uid,QString sName)
|
ElectricBaseModelLineItem* DiagramEditorModel::generateLine(QUuid uid,QString sName,int mode)
|
||||||
{
|
{
|
||||||
ElectricBaseModelLineItem* pLine = new ElectricBaseModelLineItem();
|
ElectricBaseModelLineItem* pLine = new ElectricBaseModelLineItem();
|
||||||
pLine->setItemId(uid);
|
pLine->setItemId(uid);
|
||||||
pLine->setItemType(GIT_baseLine);
|
pLine->setItemType(GIT_baseLine);
|
||||||
DiagramEditorItemProperty* pData = addTempPreviewData(uid,8,sName,DataBase::GetInstance()->ModelType()[4].modelType);
|
DiagramEditorItemProperty* pData = addPreviewData(uid,8,sName,DataBase::GetInstance()->ModelType()[4].modelType,"",mode);
|
||||||
pData->setGraphicsType(GIT_baseLine);
|
pData->setGraphicsType(GIT_baseLine);
|
||||||
if(pData)
|
if(pData)
|
||||||
{
|
{
|
||||||
pLine->setProperty(pData);
|
pLine->setProperty(pData);
|
||||||
pData->setDataChanged(true); //数据状态改变
|
pData->setDataChanged(true); //数据状态改变
|
||||||
}
|
}
|
||||||
addTempPreviewItem(uid,pLine);
|
addPreviewItem(uid,pLine,mode);
|
||||||
//establishConnection(pBreaker,pBus,pLine,ModelFunctionType::BaseModel);
|
//establishConnection(pBreaker,pBus,pLine,ModelFunctionType::BaseModel);
|
||||||
_pCurPreviewScene->addItem(pLine);
|
_pCurPreviewScene->addItem(pLine);
|
||||||
return pLine;
|
return pLine;
|
||||||
|
|
@ -280,7 +313,7 @@ void DiagramEditorModel::connectTransToNeutral(DiagramEditorTransformerBlock* bl
|
||||||
else if(typ == TransformerType::threeWinding){
|
else if(typ == TransformerType::threeWinding){
|
||||||
nT = 16;
|
nT = 16;
|
||||||
}
|
}
|
||||||
generateTempComponent(uid,sName,0,nT,QPoint(0,0),0);
|
generateComponent(uid,sName,0,nT,QPoint(0,0),0,1);
|
||||||
|
|
||||||
auto pTransItem = _tempItem.value(uid);
|
auto pTransItem = _tempItem.value(uid);
|
||||||
if(typ == TransformerType::twoWinding){
|
if(typ == TransformerType::twoWinding){
|
||||||
|
|
@ -323,7 +356,7 @@ void DiagramEditorModel::linkTransItem(GraphicsBaseModelItem* pTrans,QStandardIt
|
||||||
auto pLineData = TopologyManager::instance().ifConnection(uid1.toString(),uid2.toString()); //判断两个item是否有连接
|
auto pLineData = TopologyManager::instance().ifConnection(uid1.toString(),uid2.toString()); //判断两个item是否有连接
|
||||||
if(pLineData != nullptr){
|
if(pLineData != nullptr){
|
||||||
if(!_tempItem.contains(QUuid(pLineData->id()))){ //connectdata已存在,item未绘制
|
if(!_tempItem.contains(QUuid(pLineData->id()))){ //connectdata已存在,item未绘制
|
||||||
auto pLine = generateTempLine(QUuid(pLineData->id()),""); //重新绘制
|
auto pLine = generateLine(QUuid(pLineData->id()),"",1); //重新绘制
|
||||||
if(pLine)
|
if(pLine)
|
||||||
establishConnection(pItem,pTrans,pLine,ModelFunctionType::BlockEditorModel,1,nPos);
|
establishConnection(pItem,pTrans,pLine,ModelFunctionType::BlockEditorModel,1,nPos);
|
||||||
}
|
}
|
||||||
|
|
@ -331,7 +364,7 @@ void DiagramEditorModel::linkTransItem(GraphicsBaseModelItem* pTrans,QStandardIt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{ //connectdata不存在,新建
|
else{ //connectdata不存在,新建
|
||||||
auto pLine = generateTempLine(QUuid::createUuid(),"");
|
auto pLine = generateLine(QUuid::createUuid(),"",1);
|
||||||
if(pLine)
|
if(pLine)
|
||||||
establishConnection(pItem,pTrans,pLine,ModelFunctionType::BlockEditorModel,1,nPos);
|
establishConnection(pItem,pTrans,pLine,ModelFunctionType::BlockEditorModel,1,nPos);
|
||||||
}
|
}
|
||||||
|
|
@ -341,6 +374,51 @@ void DiagramEditorModel::linkTransItem(GraphicsBaseModelItem* pTrans,QStandardIt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiagramEditorModel::generatePreview()
|
||||||
|
{
|
||||||
|
if(_pPanel){
|
||||||
|
_pPanel->showPreview();
|
||||||
|
QList<EditBaseItem*> lst = _pPanel->getBlockItems();
|
||||||
|
for(auto item:lst){
|
||||||
|
if(item->getType() == EditorItemType::bus){ //首次循环生成母线
|
||||||
|
auto p = item->getBlockData(); //获取blockitem对应的data
|
||||||
|
if(p){
|
||||||
|
QUuid uid = p->getId();
|
||||||
|
QString name = p->getName();
|
||||||
|
|
||||||
|
QPointF pos = item->scenePos();
|
||||||
|
auto pItem = generateComponent(uid,name,0,1,pos,0,1);
|
||||||
|
pItem->setBoundingRect(item->boundingRect());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto item:lst){
|
||||||
|
if(item->getType() == EditorItemType::bay){ //第二次生成间隔,部分接线
|
||||||
|
auto p = item->getBlockData(); //获取blockitem对应的data
|
||||||
|
DiagramEditorBayBlock* pBay = dynamic_cast<DiagramEditorBayBlock*>(p.data());
|
||||||
|
if(pBay){
|
||||||
|
auto mapRoute = pBay->getBayInfo().mapRoute;
|
||||||
|
auto mapCompo = pBay->getBayInfo().mapComponent;
|
||||||
|
|
||||||
|
QRectF rect = item->boundingRect();
|
||||||
|
// 计算中心点(本地坐标系)
|
||||||
|
QPointF centerLocal = rect.center();
|
||||||
|
// 转换为场景坐标系
|
||||||
|
QPointF centerScene = item->mapToScene(centerLocal);
|
||||||
|
generateItemByInfo(mapRoute,mapCompo,centerScene);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto item:lst){
|
||||||
|
if(item->getType() == EditorItemType::trans){ //第三次生成变压器,部分接线
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QStandardItem* DiagramEditorModel::getNameItem(const QString& sName,int nFrom)
|
QStandardItem* DiagramEditorModel::getNameItem(const QString& sName,int nFrom)
|
||||||
{
|
{
|
||||||
QStandardItemModel* pModel = nullptr;
|
QStandardItemModel* pModel = nullptr;
|
||||||
|
|
@ -389,7 +467,7 @@ void DiagramEditorModel::generateItemByModel(QStandardItemModel* pModel,int nFro
|
||||||
pos += delta;
|
pos += delta;
|
||||||
QUuid uid = pItem->data(Qt::UserRole+3).toUuid();
|
QUuid uid = pItem->data(Qt::UserRole+3).toUuid();
|
||||||
if(!_tempItem.contains(uid))
|
if(!_tempItem.contains(uid))
|
||||||
generateTempComponent(uid,name,nCate,nType,pos,nRotate);
|
generateComponent(uid,name,nCate,nType,pos,nRotate,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -405,20 +483,20 @@ void DiagramEditorModel::generateItemByModel(QStandardItemModel* pModel,int nFro
|
||||||
if(_tempItem.contains(uid1) && _tempItem.contains(uid2)){
|
if(_tempItem.contains(uid1) && _tempItem.contains(uid2)){
|
||||||
GraphicsBaseModelItem* p1 = _tempItem.value(uid1);
|
GraphicsBaseModelItem* p1 = _tempItem.value(uid1);
|
||||||
GraphicsBaseModelItem* p2 = _tempItem.value(uid2);
|
GraphicsBaseModelItem* p2 = _tempItem.value(uid2);
|
||||||
auto pLineData = TopologyManager::instance().ifConnection(uid1.toString(),uid2.toString()); //判断两个item是否有连接
|
auto pLineData = TopologyManager::instance().ifConnection(uid1.toString(),uid2.toString(),ModelFunctionType::BlockEditorModel); //判断两个item是否有连接
|
||||||
if(pLineData != nullptr){
|
if(pLineData != nullptr){
|
||||||
if(!_tempItem.contains(QUuid(pLineData->id()))){ //connectdata已存在,item未绘制
|
if(!_tempItem.contains(QUuid(pLineData->id()))){ //connectdata已存在,item未绘制
|
||||||
auto pLine = generateTempLine(QUuid(pLineData->id()),""); //重新绘制
|
auto pLine = generateLine(QUuid(pLineData->id()),"",0); //重新绘制
|
||||||
if(pLine)
|
if(pLine)
|
||||||
establishConnection(p1,p2,pLine,ModelFunctionType::BaseModel);
|
establishConnection(p1,p2,pLine,ModelFunctionType::BlockEditorModel);
|
||||||
}
|
}
|
||||||
else{ //已绘制,略过
|
else{ //已绘制,略过
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{ //connectdata不存在,新建
|
else{ //connectdata不存在,新建
|
||||||
auto pLine = generateTempLine(QUuid::createUuid(),"");
|
auto pLine = generateLine(QUuid::createUuid(),"",0);
|
||||||
if(pLine)
|
if(pLine)
|
||||||
establishConnection(p1,p2,pLine,ModelFunctionType::BaseModel);
|
establishConnection(p1,p2,pLine,ModelFunctionType::BlockEditorModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -427,13 +505,85 @@ void DiagramEditorModel::generateItemByModel(QStandardItemModel* pModel,int nFro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagramEditorModel::generateItemByInfo(QMap<QString,DiagramEditorRouteInfo> mapRoute,QMap<QString,DiagramEditorComponentInfo> mapCompo,QPoint delta)
|
void DiagramEditorModel::generateItemByInfo(QMap<QString,DiagramEditorRouteInfo> mapRoute,QMap<QString,DiagramEditorComponentInfo> mapCompo,QPointF delta)
|
||||||
{
|
{
|
||||||
if(_pPanel){
|
QList<DiagramEditorComponentInfo> lstBind; //连接外部对象的component
|
||||||
QList<EditBaseItem*> lst = _pPanel->getBlockItems();
|
QString sMain;
|
||||||
for(auto item:lst){
|
for(auto& route:mapRoute){ //总路线中包含主路,首次生成主路
|
||||||
if(item->getType() == EditorItemType::bus){
|
if(route.bMainRoute == true){
|
||||||
|
sMain = route.sRouteName;
|
||||||
|
for(auto& compo:route.lstCompo){ //首先生成设备
|
||||||
|
auto info = mapCompo.value(compo.sName);
|
||||||
|
generateComponent(info.uid,info.sName,info.nCategory,info.nType,info.deltaPos+delta,info.nRotate,1);
|
||||||
|
if(!info.sBindObj.isEmpty() && info.sBindObj != QString::fromWCharArray(L"无")){ //非空且不是无
|
||||||
|
if(!lstBind.contains(info))
|
||||||
|
lstBind.append(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(route.lstCompo.size() > 1){
|
||||||
|
bulidAndLinkComponent(route.lstCompo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto &route:mapRoute){ //二次生成其他路线
|
||||||
|
if(route.bMainRoute == true){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for(auto &compo:route.lstOrder){ //生成正序设备
|
||||||
|
auto info = mapCompo.value(compo.sName);
|
||||||
|
generateComponent(info.uid,info.sName,info.nCategory,info.nType,info.deltaPos+delta,info.nRotate,1);
|
||||||
|
if(!info.sBindObj.isEmpty() && info.sBindObj != QString::fromWCharArray(L"无")){ //非空且不是无
|
||||||
|
if(!lstBind.contains(info))
|
||||||
|
lstBind.append(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto &compo:route.lstReverse){ //生成逆序设备
|
||||||
|
auto info = mapCompo.value(compo.sName);
|
||||||
|
generateComponent(info.uid,info.sName,info.nCategory,info.nType,info.deltaPos+delta,info.nRotate,1);
|
||||||
|
if(!info.sBindObj.isEmpty() && info.sBindObj != QString::fromWCharArray(L"无")){ //非空且不是无
|
||||||
|
if(!lstBind.contains(info))
|
||||||
|
lstBind.append(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(route.lstOrder.size() > 1){
|
||||||
|
bulidAndLinkComponent(route.lstOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(route.lstReverse.size() > 1){
|
||||||
|
bulidAndLinkComponent(route.lstReverse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto& compo:lstBind){ //遍历关联外部的item,进行连线
|
||||||
|
if(compo.nBindType == 1){ //关联的是母线 母线没有数据,获取绘制的母线item
|
||||||
|
for(auto& pItem:_previewItem){
|
||||||
|
auto pro = pItem->getProperty();
|
||||||
|
if(pro){
|
||||||
|
QString sName = pro->name();
|
||||||
|
if(sName == compo.sBindObj){
|
||||||
|
GraphicsBaseModelItem* pSrc = _previewItem.value(compo.uid);
|
||||||
|
GraphicsBaseModelItem* pTarget = pItem;
|
||||||
|
auto pLineData = TopologyManager::instance().ifConnection(pSrc->itemId().toString(),pTarget->itemId().toString(),ModelFunctionType::EditorModel); //判断两个item是否有连接
|
||||||
|
if(pLineData != nullptr){
|
||||||
|
if(!_previewItem.contains(QUuid(pLineData->id()))){ //connectdata已存在,item未绘制
|
||||||
|
auto pLine = generateLine(QUuid(pLineData->id()),"",1); //重新绘制
|
||||||
|
if(pLine)
|
||||||
|
establishConnection(pSrc,pTarget,pLine,ModelFunctionType::EditorModel);
|
||||||
|
}
|
||||||
|
else{ //已绘制,略过
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{ //connectdata不存在,新建
|
||||||
|
auto pLine = generateLine(QUuid::createUuid(),"",1);
|
||||||
|
if(pLine)
|
||||||
|
establishConnection(pSrc,pTarget,pLine,ModelFunctionType::EditorModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -443,6 +593,15 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
{
|
{
|
||||||
auto& mapRoute = data;
|
auto& mapRoute = data;
|
||||||
QString sMainRoute;
|
QString sMainRoute;
|
||||||
|
|
||||||
|
bool hasMain = false;
|
||||||
|
for(auto& route:mapRoute){
|
||||||
|
if(route.bMainRoute == true){
|
||||||
|
sMainRoute = route.sRouteName;
|
||||||
|
hasMain = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!hasMain){ //没设置主线将最长设为主线
|
||||||
int nCount = 0;
|
int nCount = 0;
|
||||||
for(auto& route:mapRoute){ //寻找包含设备最多的线路
|
for(auto& route:mapRoute){ //寻找包含设备最多的线路
|
||||||
if(nCount < route.lstCompo.count()){
|
if(nCount < route.lstCompo.count()){
|
||||||
|
|
@ -451,6 +610,7 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
route.bMainRoute = true;
|
route.bMainRoute = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
int nMainDir = nLayout/10; //主朝向倾向 8421上下左右
|
int nMainDir = nLayout/10; //主朝向倾向 8421上下左右
|
||||||
int nSubDir = nLayout%10; //次朝向倾向 8421
|
int nSubDir = nLayout%10; //次朝向倾向 8421
|
||||||
|
|
||||||
|
|
@ -483,11 +643,15 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
int nVal = pItemName->data().toInt();
|
int nVal = pItemName->data().toInt();
|
||||||
pItemName->setData(QString::number(nVal |= nDir)); //在公用模型中更新设备方向占用(重要)
|
pItemName->setData(QString::number(nVal |= nDir)); //在公用模型中更新设备方向占用(重要)
|
||||||
pItemName->setData(QPoint(0,deltaY),Qt::UserRole+2); //设置相对位置
|
pItemName->setData(QPoint(0,deltaY),Qt::UserRole+2); //设置相对位置
|
||||||
if(nMainDir == 4)
|
if(nMainDir == 4){
|
||||||
|
maoCompo[i].nRotate = 0;
|
||||||
pItemName->setData(0,Qt::UserRole+5);
|
pItemName->setData(0,Qt::UserRole+5);
|
||||||
else
|
}
|
||||||
|
else{
|
||||||
|
maoCompo[i].nRotate = 180;
|
||||||
pItemName->setData(180,Qt::UserRole+5);
|
pItemName->setData(180,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(nMainDir == 8)
|
if(nMainDir == 8)
|
||||||
nSegIndex -= 1;
|
nSegIndex -= 1;
|
||||||
else
|
else
|
||||||
|
|
@ -555,6 +719,7 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
pItem->setData(QString::number(nVal | 1));
|
pItem->setData(QString::number(nVal | 1));
|
||||||
pNextItem->setData(QString::number(nNextVal | 2)); //同时连接下个点的一侧占用
|
pNextItem->setData(QString::number(nNextVal | 2)); //同时连接下个点的一侧占用
|
||||||
nOrderPolarity = 1;
|
nOrderPolarity = 1;
|
||||||
|
route.lstOrder[i+1].nRotate = -90;
|
||||||
pNextItem->setData(-90,Qt::UserRole+5);
|
pNextItem->setData(-90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if((nVal & 1) == 1){
|
else if((nVal & 1) == 1){
|
||||||
|
|
@ -562,18 +727,21 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
pItem->setData(QString::number(nVal | 2));
|
pItem->setData(QString::number(nVal | 2));
|
||||||
pNextItem->setData(QString::number(nNextVal | 1));
|
pNextItem->setData(QString::number(nNextVal | 1));
|
||||||
nOrderPolarity = -1;
|
nOrderPolarity = -1;
|
||||||
|
route.lstOrder[i+1].nRotate = 90;
|
||||||
pNextItem->setData(90,Qt::UserRole+5);
|
pNextItem->setData(90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else{ //左右都没被占,放到倾向位置
|
else{ //左右都没被占,放到倾向位置
|
||||||
pItem->setData(QString::number(nVal | nSubDir));
|
pItem->setData(QString::number(nVal | nSubDir));
|
||||||
pNextItem->setData(QString::number(nNextVal | 3-nSubDir));
|
pNextItem->setData(QString::number(nNextVal | 3-nSubDir));
|
||||||
if(nSubDir == 1){
|
if(nSubDir == 1){
|
||||||
nOrderPolarity = -1;
|
nOrderPolarity = 1;
|
||||||
pNextItem->setData(90,Qt::UserRole+5);
|
route.lstOrder[i+1].nRotate = -90;
|
||||||
|
pNextItem->setData(-90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if(nSubDir == 2){
|
else if(nSubDir == 2){
|
||||||
nOrderPolarity = 1;
|
nOrderPolarity = -1;
|
||||||
pNextItem->setData(-90,Qt::UserRole+5);
|
route.lstOrder[i+1].nRotate = 90;
|
||||||
|
pNextItem->setData(90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int deltaX = nXOrderIndex*nOrderPolarity*g_nHDiagramSpacing;
|
int deltaX = nXOrderIndex*nOrderPolarity*g_nHDiagramSpacing;
|
||||||
|
|
@ -588,22 +756,26 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
//左被占用,右空
|
//左被占用,右空
|
||||||
pItem->setData(QString::number(nVal | 1));
|
pItem->setData(QString::number(nVal | 1));
|
||||||
pNextItem->setData(QString::number(nNextVal | 2)); //同时连接下个点的一侧占用
|
pNextItem->setData(QString::number(nNextVal | 2)); //同时连接下个点的一侧占用
|
||||||
|
route.lstOrder[i+1].nRotate = -90;
|
||||||
pNextItem->setData(-90,Qt::UserRole+5);
|
pNextItem->setData(-90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if((nVal & 1) == 1){
|
else if((nVal & 1) == 1){
|
||||||
//右被占用,左空
|
//右被占用,左空
|
||||||
pItem->setData(QString::number(nVal | 2));
|
pItem->setData(QString::number(nVal | 2));
|
||||||
pNextItem->setData(QString::number(nNextVal | 1));
|
pNextItem->setData(QString::number(nNextVal | 1));
|
||||||
|
route.lstOrder[i+1].nRotate = 90;
|
||||||
pNextItem->setData(90,Qt::UserRole+5);
|
pNextItem->setData(90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else{ //左右都没被占,放到设定位置
|
else{ //左右都没被占,放到设定位置
|
||||||
pItem->setData(QString::number(nVal | nSubDir));
|
pItem->setData(QString::number(nVal | nSubDir));
|
||||||
pNextItem->setData(QString::number(nNextVal | 3-nSubDir));
|
pNextItem->setData(QString::number(nNextVal | 3-nSubDir));
|
||||||
if(nSubDir == 1){
|
if(nSubDir == 1){
|
||||||
pNextItem->setData(90,Qt::UserRole+5);
|
route.lstOrder[i+1].nRotate = -90;
|
||||||
|
pNextItem->setData(-90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if(nSubDir == 2){
|
else if(nSubDir == 2){
|
||||||
pNextItem->setData(-90,Qt::UserRole+5);
|
route.lstOrder[i+1].nRotate = 90;
|
||||||
|
pNextItem->setData(90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int deltaX = nXOrderIndex*nOrderPolarity*g_nHDiagramSpacing;
|
int deltaX = nXOrderIndex*nOrderPolarity*g_nHDiagramSpacing;
|
||||||
|
|
@ -634,6 +806,7 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
pItem->setData(QString::number(nVal | 1));
|
pItem->setData(QString::number(nVal | 1));
|
||||||
pNextItem->setData(QString::number(nNextVal | 2)); //同时连接下个点的一侧占用
|
pNextItem->setData(QString::number(nNextVal | 2)); //同时连接下个点的一侧占用
|
||||||
nReversePolarity = 1;
|
nReversePolarity = 1;
|
||||||
|
route.lstReverse[i+1].nRotate = -90;
|
||||||
pNextItem->setData(-90,Qt::UserRole+5);
|
pNextItem->setData(-90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if((nVal & 1) == 1){
|
else if((nVal & 1) == 1){
|
||||||
|
|
@ -641,18 +814,21 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
pItem->setData(QString::number(nVal | 2));
|
pItem->setData(QString::number(nVal | 2));
|
||||||
pNextItem->setData(QString::number(nNextVal | 1));
|
pNextItem->setData(QString::number(nNextVal | 1));
|
||||||
nReversePolarity = -1;
|
nReversePolarity = -1;
|
||||||
|
route.lstReverse[i+1].nRotate = 90;
|
||||||
pNextItem->setData(90,Qt::UserRole+5);
|
pNextItem->setData(90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else{ //左右都没被占,放到倾向位置
|
else{ //左右都没被占,放到倾向位置
|
||||||
pItem->setData(QString::number(nVal | nSubDir));
|
pItem->setData(QString::number(nVal | nSubDir));
|
||||||
pNextItem->setData(QString::number(nNextVal | 3-nSubDir));
|
pNextItem->setData(QString::number(nNextVal | 3-nSubDir));
|
||||||
if(nSubDir == 1){
|
if(nSubDir == 1){
|
||||||
nOrderPolarity = -1;
|
nReversePolarity = 1;
|
||||||
pNextItem->setData(90,Qt::UserRole+5);
|
route.lstReverse[i+1].nRotate = -90;
|
||||||
|
pNextItem->setData(-90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if(nSubDir == 2){
|
else if(nSubDir == 2){
|
||||||
nOrderPolarity = 1;
|
nReversePolarity = -1;
|
||||||
pNextItem->setData(-90,Qt::UserRole+5);
|
route.lstReverse[i+1].nRotate = 90;
|
||||||
|
pNextItem->setData(90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int deltaX = nXReverseIndex*nReversePolarity*g_nHDiagramSpacing;
|
int deltaX = nXReverseIndex*nReversePolarity*g_nHDiagramSpacing;
|
||||||
|
|
@ -661,28 +837,32 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
}
|
}
|
||||||
|
|
||||||
if(((nVal & 2) == 1) && ((nVal & 1) == 1)){
|
if(((nVal & 2) == 1) && ((nVal & 1) == 1)){
|
||||||
qDebug()<<QString("point %1 full of connection").arg(route.lstOrder[i].sName);
|
qDebug()<<QString("point %1 full of connection").arg(route.lstReverse[i].sName);
|
||||||
}
|
}
|
||||||
else if((nVal & 2) == 1){
|
else if((nVal & 2) == 1){
|
||||||
//左被占用,右空
|
//左被占用,右空
|
||||||
pItem->setData(QString::number(nVal | 1));
|
pItem->setData(QString::number(nVal | 1));
|
||||||
pNextItem->setData(QString::number(nNextVal | 2)); //同时连接下个点的一侧占用
|
pNextItem->setData(QString::number(nNextVal | 2)); //同时连接下个点的一侧占用
|
||||||
|
route.lstReverse[i+1].nRotate = -90;
|
||||||
pNextItem->setData(-90,Qt::UserRole+5);
|
pNextItem->setData(-90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if((nVal & 1) == 1){
|
else if((nVal & 1) == 1){
|
||||||
//右被占用,左空
|
//右被占用,左空
|
||||||
pItem->setData(QString::number(nVal | 2));
|
pItem->setData(QString::number(nVal | 2));
|
||||||
pNextItem->setData(QString::number(nNextVal | 1));
|
pNextItem->setData(QString::number(nNextVal | 1));
|
||||||
|
route.lstReverse[i+1].nRotate = 90;
|
||||||
pNextItem->setData(90,Qt::UserRole+5);
|
pNextItem->setData(90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else{ //左右都没被占,放到设定位置
|
else{ //左右都没被占,放到设定位置
|
||||||
pItem->setData(QString::number(nVal | nSubDir));
|
pItem->setData(QString::number(nVal | nSubDir));
|
||||||
pNextItem->setData(QString::number(nNextVal | 3-nSubDir));
|
pNextItem->setData(QString::number(nNextVal | 3-nSubDir));
|
||||||
if(nSubDir == 1){
|
if(nSubDir == 1){
|
||||||
pNextItem->setData(90,Qt::UserRole+5);
|
route.lstReverse[i+1].nRotate = -90;
|
||||||
|
pNextItem->setData(-90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if(nSubDir == 2){
|
else if(nSubDir == 2){
|
||||||
pNextItem->setData(-90,Qt::UserRole+5);
|
route.lstReverse[i+1].nRotate = 90;
|
||||||
|
pNextItem->setData(90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int deltaX = nXReverseIndex*nReversePolarity*g_nHDiagramSpacing;
|
int deltaX = nXReverseIndex*nReversePolarity*g_nHDiagramSpacing;
|
||||||
|
|
@ -721,11 +901,15 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
int nVal = pItemName->data().toInt();
|
int nVal = pItemName->data().toInt();
|
||||||
pItemName->setData(QString::number(nVal |= nDir)); //在公用模型中更新设备方向占用(重要)
|
pItemName->setData(QString::number(nVal |= nDir)); //在公用模型中更新设备方向占用(重要)
|
||||||
pItemName->setData(QPoint(deltaX,0),Qt::UserRole+2); //设置相对位置
|
pItemName->setData(QPoint(deltaX,0),Qt::UserRole+2); //设置相对位置
|
||||||
if(nMainDir == 1)
|
if(nMainDir == 1){
|
||||||
|
maoCompo[i].nRotate = -90;
|
||||||
pItemName->setData(-90,Qt::UserRole+5); //转至水平
|
pItemName->setData(-90,Qt::UserRole+5); //转至水平
|
||||||
else
|
}
|
||||||
|
else{
|
||||||
|
maoCompo[i].nRotate = 90;
|
||||||
pItemName->setData(90,Qt::UserRole+5);
|
pItemName->setData(90,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(nMainDir == 2)
|
if(nMainDir == 2)
|
||||||
nSegIndex -= 1;
|
nSegIndex -= 1;
|
||||||
else
|
else
|
||||||
|
|
@ -793,6 +977,7 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
pItem->setData(QString::number(nVal | 4));
|
pItem->setData(QString::number(nVal | 4));
|
||||||
pNextItem->setData(QString::number(nNextVal | 8)); //同时连接下个点的一侧占用
|
pNextItem->setData(QString::number(nNextVal | 8)); //同时连接下个点的一侧占用
|
||||||
nOrderPolarity = 1;
|
nOrderPolarity = 1;
|
||||||
|
route.lstOrder[i+1].nRotate = 0;
|
||||||
pNextItem->setData(0,Qt::UserRole+5);
|
pNextItem->setData(0,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if((nVal & 4) == 1){
|
else if((nVal & 4) == 1){
|
||||||
|
|
@ -800,6 +985,7 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
pItem->setData(QString::number(nVal | 8));
|
pItem->setData(QString::number(nVal | 8));
|
||||||
pNextItem->setData(QString::number(nNextVal | 4));
|
pNextItem->setData(QString::number(nNextVal | 4));
|
||||||
nOrderPolarity = -1;
|
nOrderPolarity = -1;
|
||||||
|
route.lstOrder[i+1].nRotate = 180;
|
||||||
pNextItem->setData(180,Qt::UserRole+5);
|
pNextItem->setData(180,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else{ //上下都没占,放到设定位置
|
else{ //上下都没占,放到设定位置
|
||||||
|
|
@ -807,10 +993,12 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
pNextItem->setData(QString::number(nNextVal | 12-nSubDir));
|
pNextItem->setData(QString::number(nNextVal | 12-nSubDir));
|
||||||
if(nSubDir == 4){
|
if(nSubDir == 4){
|
||||||
nOrderPolarity = 1;
|
nOrderPolarity = 1;
|
||||||
|
route.lstOrder[i+1].nRotate = 0;
|
||||||
pNextItem->setData(0,Qt::UserRole+5);
|
pNextItem->setData(0,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if(nSubDir == 8){
|
else if(nSubDir == 8){
|
||||||
nOrderPolarity = -1;
|
nOrderPolarity = -1;
|
||||||
|
route.lstOrder[i+1].nRotate = 180;
|
||||||
pNextItem->setData(180,Qt::UserRole+5);
|
pNextItem->setData(180,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -838,11 +1026,13 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
pItem->setData(QString::number(nVal | nSubDir));
|
pItem->setData(QString::number(nVal | nSubDir));
|
||||||
pNextItem->setData(QString::number(nNextVal | 12-nSubDir));
|
pNextItem->setData(QString::number(nNextVal | 12-nSubDir));
|
||||||
if(nSubDir == 4){
|
if(nSubDir == 4){
|
||||||
nOrderPolarity = 1;
|
//nOrderPolarity = 1;
|
||||||
|
route.lstOrder[i+1].nRotate = 0;
|
||||||
pNextItem->setData(0,Qt::UserRole+5);
|
pNextItem->setData(0,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if(nSubDir == 8){
|
else if(nSubDir == 8){
|
||||||
nOrderPolarity = -1;
|
//nOrderPolarity = -1;
|
||||||
|
route.lstOrder[i+1].nRotate = 180;
|
||||||
pNextItem->setData(180,Qt::UserRole+5);
|
pNextItem->setData(180,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -874,6 +1064,7 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
pItem->setData(QString::number(nVal | 4));
|
pItem->setData(QString::number(nVal | 4));
|
||||||
pNextItem->setData(QString::number(nNextVal | 8)); //同时连接下个点的一侧占用
|
pNextItem->setData(QString::number(nNextVal | 8)); //同时连接下个点的一侧占用
|
||||||
nReversePolarity = 1;
|
nReversePolarity = 1;
|
||||||
|
route.lstReverse[i+1].nRotate = 0;
|
||||||
pNextItem->setData(0,Qt::UserRole+5);
|
pNextItem->setData(0,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if((nVal & 1) == 4){
|
else if((nVal & 1) == 4){
|
||||||
|
|
@ -881,17 +1072,20 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
pItem->setData(QString::number(nVal | 8));
|
pItem->setData(QString::number(nVal | 8));
|
||||||
pNextItem->setData(QString::number(nNextVal | 4));
|
pNextItem->setData(QString::number(nNextVal | 4));
|
||||||
nReversePolarity = -1;
|
nReversePolarity = -1;
|
||||||
|
route.lstReverse[i+1].nRotate = 180;
|
||||||
pNextItem->setData(180,Qt::UserRole+5);
|
pNextItem->setData(180,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else{ //上下都没被占,放到设定位置
|
else{ //上下都没被占,放到设定位置
|
||||||
pItem->setData(QString::number(nVal | nSubDir));
|
pItem->setData(QString::number(nVal | nSubDir));
|
||||||
pNextItem->setData(QString::number(nNextVal | 12-nSubDir));
|
pNextItem->setData(QString::number(nNextVal | 12-nSubDir));
|
||||||
if(nSubDir == 4){
|
if(nSubDir == 4){
|
||||||
nOrderPolarity = 1;
|
nReversePolarity = 1;
|
||||||
|
route.lstReverse[i+1].nRotate = 0;
|
||||||
pNextItem->setData(0,Qt::UserRole+5);
|
pNextItem->setData(0,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if(nSubDir == 8){
|
else if(nSubDir == 8){
|
||||||
nOrderPolarity = -1;
|
nReversePolarity = -1;
|
||||||
|
route.lstReverse[i+1].nRotate = 180;
|
||||||
pNextItem->setData(180,Qt::UserRole+5);
|
pNextItem->setData(180,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -907,23 +1101,27 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
//上被占用,下空
|
//上被占用,下空
|
||||||
pItem->setData(QString::number(nVal | 4));
|
pItem->setData(QString::number(nVal | 4));
|
||||||
pNextItem->setData(QString::number(nNextVal | 8)); //同时连接下个点的一侧占用
|
pNextItem->setData(QString::number(nNextVal | 8)); //同时连接下个点的一侧占用
|
||||||
|
route.lstReverse[i+1].nRotate = 0;
|
||||||
pNextItem->setData(0,Qt::UserRole+5);
|
pNextItem->setData(0,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if((nVal & 4) == 1){
|
else if((nVal & 4) == 1){
|
||||||
//下被占用,上空
|
//下被占用,上空
|
||||||
pItem->setData(QString::number(nVal | 8));
|
pItem->setData(QString::number(nVal | 8));
|
||||||
pNextItem->setData(QString::number(nNextVal | 4));
|
pNextItem->setData(QString::number(nNextVal | 4));
|
||||||
|
route.lstReverse[i+1].nRotate = 180;
|
||||||
pNextItem->setData(180,Qt::UserRole+5);
|
pNextItem->setData(180,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else{ //上下都没被占,默认放到下边
|
else{ //上下都没被占,默认放到下边
|
||||||
pItem->setData(QString::number(nVal | 4));
|
pItem->setData(QString::number(nVal | 4));
|
||||||
pNextItem->setData(QString::number(nNextVal | 8));
|
pNextItem->setData(QString::number(nNextVal | 8));
|
||||||
if(nSubDir == 4){
|
if(nSubDir == 4){
|
||||||
nOrderPolarity = 1;
|
//nReversePolarity = 1;
|
||||||
|
route.lstReverse[i+1].nRotate = 0;
|
||||||
pNextItem->setData(0,Qt::UserRole+5);
|
pNextItem->setData(0,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
else if(nSubDir == 8){
|
else if(nSubDir == 8){
|
||||||
nOrderPolarity = -1;
|
//nReversePolarity = -1;
|
||||||
|
route.lstReverse[i+1].nRotate = 180;
|
||||||
pNextItem->setData(180,Qt::UserRole+5);
|
pNextItem->setData(180,Qt::UserRole+5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -934,5 +1132,31 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiagramEditorModel::bulidAndLinkComponent(QList<DiagramEditorComponentInfo> lst)
|
||||||
|
{
|
||||||
|
for(int i = 0;i < lst.size()-1;++i){
|
||||||
|
auto item1 = lst[i];
|
||||||
|
auto item2 = lst[i+1];
|
||||||
|
if(_previewItem.contains(item1.uid) && _previewItem.contains(item2.uid)){
|
||||||
|
GraphicsBaseModelItem* p1 = _previewItem.value(item1.uid);
|
||||||
|
GraphicsBaseModelItem* p2 = _previewItem.value(item2.uid);
|
||||||
|
auto pLineData = TopologyManager::instance().ifConnection(item1.uid.toString(),item2.uid.toString(),ModelFunctionType::EditorModel); //判断两个item是否有连接
|
||||||
|
if(pLineData != nullptr){
|
||||||
|
if(!_previewItem.contains(QUuid(pLineData->id()))){ //connectdata已存在,item未绘制
|
||||||
|
auto pLine = generateLine(QUuid(pLineData->id()),"",1); //重新绘制
|
||||||
|
if(pLine)
|
||||||
|
establishConnection(p1,p2,pLine,ModelFunctionType::EditorModel);
|
||||||
|
}
|
||||||
|
else{ //已绘制,略过
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{ //connectdata不存在,新建
|
||||||
|
auto pLine = generateLine(QUuid::createUuid(),"",1);
|
||||||
|
if(pLine)
|
||||||
|
establishConnection(p1,p2,pLine,ModelFunctionType::EditorModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,16 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>间隔布局:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="cb_layout"/>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_3">
|
<spacer name="horizontalSpacer_3">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,11 @@ public:
|
||||||
DiagramEditorItemProperty* findTempEditorData(QUuid);
|
DiagramEditorItemProperty* findTempEditorData(QUuid);
|
||||||
void deleteTempEditorData(QUuid);
|
void deleteTempEditorData(QUuid);
|
||||||
QMap<QUuid,DiagramEditorItemProperty*> getTempEditorData() const;
|
QMap<QUuid,DiagramEditorItemProperty*> getTempEditorData() const;
|
||||||
|
|
||||||
|
void insertEditorData(QUuid,DiagramEditorItemProperty*); //预览对象数据
|
||||||
|
DiagramEditorItemProperty* findEditorData(QUuid);
|
||||||
|
void deleteEditorData(QUuid);
|
||||||
|
QMap<QUuid,DiagramEditorItemProperty*> getEditorData() const;
|
||||||
signals:
|
signals:
|
||||||
void dataCreated(QString uuid);
|
void dataCreated(QString uuid);
|
||||||
void dataChanged(QString uuid);
|
void dataChanged(QString uuid);
|
||||||
|
|
@ -51,5 +56,6 @@ private:
|
||||||
QMap<QUuid,BaseModelProperty*> m_baseEntityData; //基模实例元件数据
|
QMap<QUuid,BaseModelProperty*> m_baseEntityData; //基模实例元件数据
|
||||||
QMap<QUuid,BayProperty*> m_bayData; //间隔数据
|
QMap<QUuid,BayProperty*> m_bayData; //间隔数据
|
||||||
QMap<QUuid,DiagramEditorItemProperty*> m_editorTempData; //编辑时临时预览对象
|
QMap<QUuid,DiagramEditorItemProperty*> m_editorTempData; //编辑时临时预览对象
|
||||||
|
QMap<QUuid,DiagramEditorItemProperty*> m_editorData; //编辑时预览对象
|
||||||
};
|
};
|
||||||
#endif // BASEPROPERTYMANAGER_H
|
#endif // BASEPROPERTYMANAGER_H
|
||||||
|
|
|
||||||
|
|
@ -118,3 +118,27 @@ QMap<QUuid,DiagramEditorItemProperty*> BasePropertyManager::getTempEditorData()
|
||||||
{
|
{
|
||||||
return m_editorTempData;
|
return m_editorTempData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************预览数据*******************************/
|
||||||
|
void BasePropertyManager::insertEditorData(QUuid id,DiagramEditorItemProperty* p)
|
||||||
|
{
|
||||||
|
if(!m_editorData.contains(id))
|
||||||
|
m_editorData.insert(id,p);
|
||||||
|
}
|
||||||
|
|
||||||
|
DiagramEditorItemProperty* BasePropertyManager::findEditorData(QUuid id)
|
||||||
|
{
|
||||||
|
return m_editorData.value(id,nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasePropertyManager::deleteEditorData(QUuid id)
|
||||||
|
{
|
||||||
|
DiagramEditorItemProperty* pData = m_editorData.value(id,nullptr);
|
||||||
|
if(pData)
|
||||||
|
delete pData;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QUuid,DiagramEditorItemProperty*> BasePropertyManager::getEditorData() const
|
||||||
|
{
|
||||||
|
return m_editorData;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue