update diagram data structure
This commit is contained in:
parent
6a6d407da7
commit
5acf00d037
|
|
@ -101,6 +101,8 @@ public:
|
|||
virtual void setMetaModelName(QString sName) {sMetaName = sName;}
|
||||
virtual QString metaModelName() const {return sMetaName;}
|
||||
virtual void notifyUpdate(){emit updateData();}
|
||||
virtual void setBay(QString s){sBay = s;}
|
||||
virtual QString getBay(){return sBay;}
|
||||
|
||||
void setPrepareDelete(bool b) {_prepareDelete = b;}
|
||||
bool prepareDelete() const {return _prepareDelete;}
|
||||
|
|
@ -116,6 +118,7 @@ protected:
|
|||
int nGraphicsType;
|
||||
QString sModelName; //模型名
|
||||
QString sMetaName; //元模型名
|
||||
QString sBay; //所属间隔
|
||||
|
||||
bool _dataChanged; //数据状态,为真则写入库
|
||||
bool _prepareDelete; //状态,为真准备删除
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ set(DIAGRAMCAVAS_HEADER_FILES
|
|||
include/diagramEditor/diagramEditorTransDetailSettingDlg.h
|
||||
include/diagramEditor/diagramEditorTransPreviewDlg.h
|
||||
include/diagramEditor/diagramEditorPreviewDlg.h
|
||||
include/diagramEditor/confirmEditorDlg.h
|
||||
include/graphicsDataModel/baseModel.h
|
||||
include/graphicsDataModel/fixedPortsModel.h
|
||||
include/graphicsDataModel/diagramEditorModel.h
|
||||
|
|
@ -135,6 +136,7 @@ set(DIAGRAMCAVAS_SOURCE_FILES
|
|||
source/diagramEditor/diagramEditorTransDetailSettingDlg.cpp
|
||||
source/diagramEditor/diagramEditorTransPreviewDlg.cpp
|
||||
source/diagramEditor/diagramEditorPreviewDlg.cpp
|
||||
source/diagramEditor/confirmEditorDlg.cpp
|
||||
source/graphicsDataModel/baseModel.cpp
|
||||
source/graphicsDataModel/fixedPortsModel.cpp
|
||||
source/graphicsDataModel/diagramEditorModel.cpp
|
||||
|
|
@ -192,6 +194,7 @@ set(UI_FILES
|
|||
ui/diagramEditorBayDetailAddDlg.ui
|
||||
ui/diagramEditorTransDetailSettingDlg.ui
|
||||
ui/diagramEditorTransDetailAddDlg.ui
|
||||
ui/confirmEditorDlg.ui
|
||||
)
|
||||
|
||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
|
|
|
|||
|
|
@ -11,15 +11,14 @@ class ElectricBaseModelLineItem : public GraphicsBaseModelItem
|
|||
{
|
||||
public:
|
||||
ElectricBaseModelLineItem(QGraphicsItem *parent = 0);
|
||||
ElectricBaseModelLineItem(const ElectricBaseModelLineItem&);
|
||||
virtual ~ElectricBaseModelLineItem();
|
||||
|
||||
virtual ElectricBaseModelLineItem* clone() const override;
|
||||
void setStartPoint(const QPointF& p);
|
||||
void setEndPoint(const QPointF& p);
|
||||
QPainterPath getPoints(void) const { return m_points; }
|
||||
|
||||
void calculatePath();
|
||||
void resetCurLine(){_curLine = QPoint();}
|
||||
|
||||
protected:
|
||||
virtual QPainterPath shape() const override;
|
||||
virtual QRectF boundingRect() const override;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ class ElectricBaseModelPortItem :public GraphicsBaseModelItem
|
|||
Q_OBJECT
|
||||
public:
|
||||
ElectricBaseModelPortItem(QGraphicsItem *parent = 0);
|
||||
ElectricBaseModelPortItem(const ElectricBaseModelPortItem&);
|
||||
virtual ElectricBaseModelPortItem* clone() const override;
|
||||
virtual ~ElectricBaseModelPortItem();
|
||||
|
||||
void addPort();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ class ElectricBaseModelSvgItem :public GraphicsBaseModelItem
|
|||
Q_OBJECT
|
||||
public:
|
||||
ElectricBaseModelSvgItem(const QRect &rect, QGraphicsItem *parent = 0); //genNewPort生成新接线点
|
||||
ElectricBaseModelSvgItem(const ElectricBaseModelSvgItem&);
|
||||
virtual ElectricBaseModelSvgItem* clone() const override;
|
||||
virtual ~ElectricBaseModelSvgItem();
|
||||
void updateCoordinate();
|
||||
void move(const QPointF&);
|
||||
|
|
@ -22,6 +24,7 @@ protected:
|
|||
protected:
|
||||
QRectF m_lastBoudingRect; //记录上一时刻的boundingRect
|
||||
QSvgRenderer* m_pRender;
|
||||
QByteArray m_icon;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class DrawingPanel;
|
|||
class PowerEntity;
|
||||
class DiagramEditorWizard;
|
||||
class EditPanel;
|
||||
class GraphicsBaseModelItem;
|
||||
|
||||
class DIAGRAM_DESIGNER_PUBLIC DiagramCavas : public QMdiArea
|
||||
{
|
||||
|
|
@ -53,7 +54,7 @@ public slots:
|
|||
void onSignal_createEditPanel(QString);
|
||||
EditPanel* onSignal_addEditPanel(QString);
|
||||
void onSignal_addEditWizard(QString);
|
||||
void onSignal_wizardFinished();
|
||||
void onSignal_wizardFinished(QString,QMap<QUuid,GraphicsBaseModelItem*>);
|
||||
/*********************************间隔**************************************/
|
||||
void onSignl_openCurrentBay();
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef CONFIRMEDITORDLG_H
|
||||
#define CONFIRMEDITORDLG_H
|
||||
//确认生成接线
|
||||
#include <QDialog>
|
||||
#include <QPointer>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class confirmEditorDlg; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class DiagramEditorModel;
|
||||
|
||||
class ConfirmEditorDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConfirmEditorDlg(QWidget *parent = nullptr);
|
||||
~ConfirmEditorDlg();
|
||||
|
||||
void setModelDelegate(QPointer<DiagramEditorModel> p){_pModel = p;}
|
||||
QPointer<DiagramEditorModel> getModel() {return _pModel;}
|
||||
void initial();
|
||||
void showDlg(QString sName,QString sTime);
|
||||
signals:
|
||||
void onConfirmEditor(QString,QString);
|
||||
public slots:
|
||||
void onOkClicked();
|
||||
void onCancelClicked();
|
||||
private:
|
||||
Ui::confirmEditorDlg *ui;
|
||||
QPointer<DiagramEditorModel> _pModel;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -31,6 +31,8 @@ public:
|
|||
virtual QRectF getRecSize() {return recSize;}
|
||||
virtual void setSeceneDelta(QPointF p){sceneDelta = p;}
|
||||
virtual QPointF getSceneDelta() {return sceneDelta;}
|
||||
virtual void setEditState(bool b){bEditState = b;}
|
||||
virtual bool getEditState(){return bEditState;}
|
||||
protected:
|
||||
QString sName;
|
||||
int nType; //1母线,2间隔,3变压器
|
||||
|
|
@ -40,6 +42,7 @@ protected:
|
|||
QRectF recSize; //当前大小(根据内容确定)
|
||||
QPointF sceneDelta; //block中心相对位移(计算布局位置
|
||||
DiagramEditorStructContainer* _curContainer; //当前所处的容器
|
||||
bool bEditState; //详细编辑状态
|
||||
};
|
||||
|
||||
/***************************划分后的分段bus单元****************************/
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include "global.h"
|
||||
|
||||
class EditView;
|
||||
class EditScene;
|
||||
class EditPreviewScene;
|
||||
class EditPanel;
|
||||
|
||||
class DiagramEditorPreviewDlg : public QDialog
|
||||
|
|
@ -22,7 +22,7 @@ public:
|
|||
void setParent(EditPanel* p) {_pParent = p;}
|
||||
private:
|
||||
EditView* _pView;
|
||||
EditScene* _pScene;
|
||||
EditPreviewScene* _pScene;
|
||||
QVBoxLayout* _pMainLayout;
|
||||
EditPanel* _pParent;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ public:
|
|||
virtual QRectF boundingRect() const {return m_boundingRect;}
|
||||
virtual void setBlockData(QPointer<DiagramEditorBaseBlock> p){_pBlock = p;}
|
||||
virtual QPointer<DiagramEditorBaseBlock> getBlockData(){return _pBlock;}
|
||||
virtual QString getShowType(){return QString();} //获取显示类别
|
||||
virtual QString getEditState(); //获取详细编辑状态
|
||||
signals:
|
||||
void itemDbClicked(QPointer<DiagramEditorBaseBlock>);
|
||||
protected:
|
||||
|
|
@ -54,6 +56,7 @@ class EditBayItem: public EditBaseItem
|
|||
public:
|
||||
EditBayItem(QGraphicsItem *parent = nullptr);
|
||||
virtual ~EditBayItem();
|
||||
virtual QString getShowType() override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
};
|
||||
|
|
@ -65,6 +68,7 @@ class EditTransItem: public EditBaseItem
|
|||
public:
|
||||
EditTransItem(QGraphicsItem *parent = nullptr);
|
||||
virtual ~EditTransItem();
|
||||
virtual QString getShowType() override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class DiagramEditorBayDetailSettingDlg;
|
|||
class DiagramEditorTransDetailSettingDlg;
|
||||
class DiagramEditorModel;
|
||||
class DiagramEditorPreviewDlg;
|
||||
class ConfirmEditorDlg;
|
||||
|
||||
class EditPanel : public QWidget
|
||||
{
|
||||
|
|
@ -33,10 +34,14 @@ public:
|
|||
void initBlockConnection(); //初始化block之间的连接信息
|
||||
void setOperateWizard(QPointer<DiagramEditorWizard> p) {_curWizard = p;}
|
||||
void showPreview(); //展示预览
|
||||
void showConfirmDlg(); //展示确认对话框
|
||||
|
||||
DiagramEditorModel* getModel() {return _pModel;}
|
||||
EditScene* getScene() {return m_pEditScene;}
|
||||
QList<EditBaseItem*> getBlockItems(EditorItemType typ = EditorItemType::none); //返回block对应的item,如母线,间隔,变压器, none返回所有类型
|
||||
|
||||
void setProjectName(const QString& s){_projectName = s;};
|
||||
QString getProjectName(){return _projectName;}
|
||||
public slots:
|
||||
void onWidthChanged(int width);
|
||||
void onContainerSizeChanged(EditContainerItem*); //容器大小改变时调整内部大小
|
||||
|
|
@ -62,6 +67,8 @@ private:
|
|||
QPointer<DiagramEditorWizard> _curWizard;
|
||||
DiagramEditorModel* _pModel;
|
||||
DiagramEditorPreviewDlg* _pPreview;
|
||||
ConfirmEditorDlg* _confirmEditor;
|
||||
QString _projectName;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ class ElectricBaseModelLineItem;
|
|||
class DiagramEditorTransformerBlock;
|
||||
class EditPanel;
|
||||
class DiagramEditorWizard;
|
||||
class DiagramCavas;
|
||||
|
||||
int const g_nHorizontalBlockSpacing = 100; //间隔横向间距
|
||||
|
||||
|
|
@ -32,10 +33,16 @@ public:
|
|||
ElectricBaseModelLineItem* generateLine(QUuid uid,QString sName,int mode); //生成连线 mode 0局部1整体
|
||||
void clearCurPreview();
|
||||
void setPanel(EditPanel* p) {_pPanel = p;}
|
||||
EditPanel* getPanel(){return _pPanel;}
|
||||
void setWizard(QPointer<DiagramEditorWizard> p){_pWizard = p;}
|
||||
void setCavas(QPointer<DiagramCavas> p){_pCavas = p;}
|
||||
QPointer<DiagramCavas> getCavas(){return _pCavas;}
|
||||
QMap<QUuid,GraphicsBaseModelItem*> getPreviewItem(){return _previewItem;};
|
||||
|
||||
void generatePreview(); //生成预览
|
||||
void calculateBlockPos(); //重新计算block位置
|
||||
void setItemInBlockPos(); //设置block中的item位置
|
||||
void refreshConnection(); //刷新连接线
|
||||
|
||||
void setCurBayRouteModel(QStandardItemModel* p) {_pCurBayRoute = p;}
|
||||
QStandardItemModel* getCurBayRouteModel() {return _pCurBayRoute;}
|
||||
|
|
@ -52,7 +59,7 @@ public:
|
|||
void generateItemByModel(QStandardItemModel* pModel,int nFrom = 0,QPoint delta = QPoint(0,0)); //0间隔1变压器
|
||||
QList<DiagramEditorComponentInfo> generateItemByInfo(QMap<QString,DiagramEditorRouteInfo> mapRoute,QMap<QString,DiagramEditorComponentInfo> mapCompo,QPointF delta = QPointF(0,0)); //根据data生成item
|
||||
void generateOutConnection(QList<DiagramEditorComponentInfo>,int nTypeTransCon,int nPos = 0); //生成外部连接(手动bind的连接) nTypeTransCon变压器连线类型,1中性点连接2外部连接,nPos中性点连接时的位置
|
||||
void updateTarget(QMap<QString,DiagramEditorRouteInfo>&,int nLayout,int nSource); //更新位置 nLayout主次朝向:8421,8421 上下左右,上下左右 nSource:0间隔1变压器
|
||||
QRectF updateTarget(QMap<QString,DiagramEditorRouteInfo>&,QMap<QString,DiagramEditorComponentInfo>&,int nLayout,int nSource,bool regenerate = true,bool saveToModel = true); //更新位置 nLayout主次朝向:8421,8421 上下左右,上下左右 nSource:0间隔1变压器 regenerate重新生成标志 saveToModel:生成到模型或map
|
||||
private:
|
||||
void bulidAndLinkComponent(QList<DiagramEditorComponentInfo>,QMap<QString,DiagramEditorComponentInfo>); //生成并连接线路上的设备 lst,mapComponents(从map中获取正确数据)
|
||||
//DiagramEditorComponentInfo getCompoDataFromName(const QString&,QMap<QString,DiagramEditorComponentInfo>); //根据名称获取数据
|
||||
|
|
@ -67,5 +74,6 @@ private:
|
|||
EditBaseScene* _pCurPreviewScene; //当前预览scene
|
||||
EditPanel* _pPanel; //主界面
|
||||
QPointer<DiagramEditorWizard> _pWizard; //向导界面数据
|
||||
QPointer<DiagramCavas> _pCavas; //顶层界面容器
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public:
|
|||
QMap<QUuid,QPointF> allBaseNodePos() const;
|
||||
|
||||
bool addBaseItem(QUuid uuid,GraphicsBaseModelItem*);
|
||||
BaseModelProperty* addBaseNodeData(QUuid id,int type,QString name,QString metaName); //添加图元基模数据
|
||||
BaseModelProperty* addBaseNodeData(QUuid id,int type,QString name,QString metaName,QString bay = QString()); //添加图元基模数据
|
||||
|
||||
void showProjectModelSettingDlg(GraphicsBaseModelItem*); //在基模拓扑图上打开工程模设置对话框
|
||||
void generateProjectModel(const QString&,QList<GraphicsBaseModelItem*>,QList<GraphicsNonStandardItem*>); //由基模生成工程模
|
||||
|
|
|
|||
|
|
@ -43,6 +43,26 @@ public:
|
|||
m_dSyncRotationByParent = 0.0;
|
||||
}
|
||||
|
||||
AbstractShapeType(const AbstractShapeType& obj)
|
||||
{
|
||||
m_type = T_undefined;
|
||||
m_pen = QPen(Qt::NoPen);
|
||||
m_brush = QBrush(QColor(rand() % 32 * 8, rand() % 32 * 8, rand() % 32 * 8));
|
||||
m_dWidth = m_dHeight = 0;
|
||||
m_pOperationCopy = nullptr;
|
||||
m_dSyncRotationByParent = 0.0;
|
||||
|
||||
m_itemId = obj.m_itemId;
|
||||
m_type = obj.m_type;
|
||||
m_pen = obj.m_pen;
|
||||
m_brush = obj.m_brush;
|
||||
m_dWidth = obj.m_dWidth;
|
||||
m_dHeight = obj.m_dHeight;
|
||||
m_boundingRect = obj.m_boundingRect;
|
||||
m_Itemtype = obj.m_Itemtype;
|
||||
m_movingIniPos = obj.m_movingIniPos;
|
||||
}
|
||||
|
||||
virtual ~AbstractShapeType()
|
||||
{
|
||||
|
||||
|
|
@ -151,9 +171,12 @@ class GraphicsBaseItem :public QObject, public AbstractShapeType<QGraphicsItem>
|
|||
Q_OBJECT
|
||||
public:
|
||||
GraphicsBaseItem(QGraphicsItem *parent);
|
||||
GraphicsBaseItem(const GraphicsBaseItem&);
|
||||
virtual ~GraphicsBaseItem();
|
||||
|
||||
public:
|
||||
virtual int addPort(PortState typ,QPointF vec,QString id = "",HandleType hType = T_lineInOut,PortPos pos = P_top); //新建,返回-1失败
|
||||
virtual void movePort(QString id,QPointF vec); //移动可动点
|
||||
virtual void setEntity(PowerEntity*); //设置当前图元的拓扑数据
|
||||
virtual PowerEntity* entity();
|
||||
virtual void setProperty(ModelProperty* p);
|
||||
|
|
@ -170,6 +193,8 @@ public:
|
|||
virtual void initialPortsByDatabase(int nComponentTypeId); //从数据库初始化port信息,component_type中的id
|
||||
virtual void setLastPoint(QPointF p) {m_lastPoint = p;}
|
||||
virtual void setTouched(bool b){m_touched = b;}
|
||||
virtual void setPosChanged(bool b){_posChanged = b;}
|
||||
virtual bool getPosChanged() {return _posChanged;}
|
||||
|
||||
int collidesWithHandle(const QPointF& point)
|
||||
{
|
||||
|
|
@ -458,6 +483,7 @@ protected:
|
|||
QPointF m_lastPoint; //鼠标上次点击位置
|
||||
bool m_touched; //被触碰状态
|
||||
QRectF m_boundingRect_selected; //选中矩形框
|
||||
bool _posChanged = false; //位置移动标志
|
||||
};
|
||||
|
||||
class GraphicsBaseModelItem : public GraphicsBaseItem //基模item
|
||||
|
|
@ -465,10 +491,15 @@ class GraphicsBaseModelItem : public GraphicsBaseItem //基模item
|
|||
Q_OBJECT
|
||||
public:
|
||||
GraphicsBaseModelItem(QGraphicsItem *parent);
|
||||
GraphicsBaseModelItem(const GraphicsBaseModelItem&);
|
||||
virtual ~GraphicsBaseModelItem();
|
||||
virtual GraphicsBaseModelItem* clone() const = 0;
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
virtual void setMask(bool b){_stateMask = b;}
|
||||
virtual bool getMask(){return _stateMask;}
|
||||
protected:
|
||||
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange, const QVariant&) override;
|
||||
bool _stateMask = true; //状态遮罩
|
||||
};
|
||||
|
||||
class GraphicsProjectModelItem : public GraphicsBaseItem //工程模item
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class PowerConnection : public QObject {
|
|||
public:
|
||||
PowerConnection(const QString& uuid,const QString& fromTerminalId,const QString& toTerminalId,const QString& fromId,const QString& toId,QObject* parent = nullptr);
|
||||
|
||||
PowerConnection* clone();
|
||||
QString id() const {return m_uuid;}
|
||||
QString fromTerminalId() const { return m_fromTerminal; }
|
||||
QString toTerminalId() const { return m_toTerminal; }
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
* *************************/
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include "powerTerminal.h"
|
||||
#include "topologyManager.h"
|
||||
#include "global.h"
|
||||
|
||||
class PowerTerminal;
|
||||
|
|
@ -20,6 +22,35 @@ public:
|
|||
//qDeleteAll(m_children);
|
||||
}
|
||||
|
||||
virtual PowerEntity* clone(){
|
||||
// 1. 检查是否已经拷贝过
|
||||
if (TopologyManager::instance().findEntity(this->m_id,ModelFunctionType::BaseModel)) { //拷贝的子项也加入到clonedMap
|
||||
return TopologyManager::instance().findEntity(this->m_id,ModelFunctionType::BaseModel);
|
||||
}
|
||||
|
||||
// 2. 创建当前对象的新副本
|
||||
PowerEntity* newEntity = TopologyManager::instance().createEntity(m_type,m_id,m_name,ModelFunctionType::BaseModel);
|
||||
|
||||
// 3. 清空子列表(避免浅拷贝)
|
||||
newEntity->m_children.clear();
|
||||
newEntity->m_terminals.clear();
|
||||
|
||||
// 4. 递归克隆子项
|
||||
for (PowerEntity* child : m_children) {
|
||||
newEntity->addChild(child->clone());
|
||||
}
|
||||
|
||||
// 5. 深拷贝所有 PowerTerminal
|
||||
for (PowerTerminal* terminal : m_terminals) {
|
||||
auto pTer = TopologyManager::instance().getTerminal(terminal->id(),ModelFunctionType::BaseModel);
|
||||
if(pTer == nullptr){ //BaseModel中不存在则拷贝
|
||||
TopologyManager::instance().createTerminal(m_id,terminal->type(),terminal->name(),terminal->relativePosition(),terminal->id(),ModelFunctionType::BaseModel);
|
||||
}
|
||||
}
|
||||
|
||||
return newEntity;
|
||||
}
|
||||
|
||||
// 添加/删除子元素
|
||||
void addChild(PowerEntity* child) {
|
||||
if (child == this || getAllDescendants().contains(this)) {
|
||||
|
|
|
|||
|
|
@ -21,10 +21,13 @@ public:
|
|||
PowerEntity* createEntity(EntityType type,const QString& uuid,const QString& name,ModelFunctionType tpe = ModelFunctionType::ProjectModel,const QString& block = QString());
|
||||
PowerEntity* findEntity(const QString& id,ModelFunctionType = ModelFunctionType::ProjectModel) const;
|
||||
bool deleteEntity(const QString& id,ModelFunctionType = ModelFunctionType::ProjectModel);
|
||||
|
||||
QList<PowerEntity*> getEntitiesByBlock(const QString&); //通过名称返回entity中的实体(blockEditor中)
|
||||
void moveTempBlockData(); //blockEditor中将临时数据转为全局数据
|
||||
void clearGlobalBlockData(const QString&); //清除全局数据中的blockdata(block修改时)
|
||||
|
||||
void cloneEditorToBase(); //将editor中的数据深拷贝到base中
|
||||
|
||||
// 连接管理
|
||||
PowerConnection* createConnection(const QString& uuid,const QString& fromTerId, const QString& toTerId,const QString& fromId,const QString& toId,ModelFunctionType tpe = ModelFunctionType::ProjectModel);
|
||||
QList<PowerConnection*> getConnectionsForTerminal(const QString& terminalId,ModelFunctionType tpe = ModelFunctionType::ProjectModel) const;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,27 @@ ElectricBaseModelLineItem::~ElectricBaseModelLineItem()
|
|||
{
|
||||
}
|
||||
|
||||
ElectricBaseModelLineItem::ElectricBaseModelLineItem(const ElectricBaseModelLineItem& obj)
|
||||
:GraphicsBaseModelItem(obj)
|
||||
{
|
||||
m_pen = QPen(Qt::black);
|
||||
m_brush = QBrush(Qt::NoBrush);
|
||||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
|
||||
m_points = obj.m_points;
|
||||
m_pointsBoundingRect = obj.m_pointsBoundingRect; //包裹点的矩形集合
|
||||
m_lstPoints = obj.m_lstPoints;
|
||||
_curLine = obj._curLine;
|
||||
}
|
||||
|
||||
ElectricBaseModelLineItem* ElectricBaseModelLineItem::clone() const
|
||||
{
|
||||
ElectricBaseModelLineItem* newItem = new ElectricBaseModelLineItem(*this);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
void ElectricBaseModelLineItem::setStartPoint(const QPointF& p)
|
||||
{
|
||||
int n = m_lstPoints.size();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,22 @@ ElectricBaseModelPortItem::ElectricBaseModelPortItem(QGraphicsItem *parent)
|
|||
setFunctionHandleEnaable(false);
|
||||
}
|
||||
|
||||
ElectricBaseModelPortItem::ElectricBaseModelPortItem(const ElectricBaseModelPortItem& obj)
|
||||
:GraphicsBaseModelItem(obj)
|
||||
{
|
||||
m_boundingRect = QRectF(-1,-1,2,2);
|
||||
m_pen = QPen(Qt::black);
|
||||
m_brush = QBrush(Qt::black);
|
||||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
}
|
||||
|
||||
ElectricBaseModelPortItem* ElectricBaseModelPortItem::clone() const
|
||||
{
|
||||
return new ElectricBaseModelPortItem(*this);
|
||||
}
|
||||
|
||||
ElectricBaseModelPortItem::~ElectricBaseModelPortItem()
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,19 @@ ElectricBaseModelSvgItem::ElectricBaseModelSvgItem(const QRect &rect, QGraphicsI
|
|||
m_dHeight = rect.height();
|
||||
}
|
||||
|
||||
ElectricBaseModelSvgItem::ElectricBaseModelSvgItem(const ElectricBaseModelSvgItem& obj)
|
||||
:GraphicsBaseModelItem(obj)
|
||||
{
|
||||
m_lastBoudingRect = obj.m_lastBoudingRect;
|
||||
m_icon = obj.m_icon;
|
||||
m_pRender = new QSvgRenderer(m_icon);
|
||||
}
|
||||
|
||||
ElectricBaseModelSvgItem* ElectricBaseModelSvgItem::clone() const
|
||||
{
|
||||
return new ElectricBaseModelSvgItem(*this);
|
||||
}
|
||||
|
||||
ElectricBaseModelSvgItem::~ElectricBaseModelSvgItem()
|
||||
{
|
||||
|
||||
|
|
@ -72,7 +85,10 @@ void ElectricBaseModelSvgItem::paint(QPainter* painter, const QStyleOptionGraphi
|
|||
|
||||
void ElectricBaseModelSvgItem::loadSvg(const QByteArray& data)
|
||||
{
|
||||
if(m_pRender == nullptr){
|
||||
m_icon = data;
|
||||
m_pRender = new QSvgRenderer(data);
|
||||
}
|
||||
}
|
||||
|
||||
void ElectricBaseModelSvgItem::move(const QPointF& point)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
#include <QStandardItem>
|
||||
#include "drawingPanel.h"
|
||||
#include "diagramCavas.h"
|
||||
//#include "mainwindow.h"
|
||||
#include "dataBase.h"
|
||||
#include "graphicsItem/graphicsBaseItem.h"
|
||||
#include "topologyManager.h"
|
||||
|
|
@ -14,6 +13,7 @@
|
|||
#include "baseProperty.h"
|
||||
#include "diagramEditor/editPanel.h"
|
||||
#include "graphicsDataModel/diagramEditorModel.h"
|
||||
#include "basePropertyManager.h"
|
||||
|
||||
DiagramCavas::DiagramCavas(QWidget *parent)
|
||||
: QMdiArea(parent)
|
||||
|
|
@ -365,6 +365,7 @@ void DiagramCavas::onSignal_createEditPanel(QString sName)
|
|||
EditPanel* DiagramCavas::onSignal_addEditPanel(QString sName)
|
||||
{
|
||||
EditPanel* pPanel = new EditPanel(this);
|
||||
pPanel->setProjectName(sName);
|
||||
pPanel->setWindowTitle(_curPage);
|
||||
|
||||
QMdiSubWindow* pSub = this->addSubWindow(pPanel);
|
||||
|
|
@ -380,17 +381,55 @@ void DiagramCavas::onSignal_addEditWizard(QString name)
|
|||
EditPanel* pPanel = onSignal_addEditPanel(name);
|
||||
pPanel->setOperateWizard(_pEditorWizard);
|
||||
auto pModel = pPanel->getModel();
|
||||
if(pModel)
|
||||
if(pModel){
|
||||
pModel->setWizard(_pEditorWizard);
|
||||
pModel->setCavas(this);
|
||||
}
|
||||
pPanel->initByWizardInfo();
|
||||
});
|
||||
}
|
||||
_pEditorWizard->show();
|
||||
}
|
||||
|
||||
void DiagramCavas::onSignal_wizardFinished()
|
||||
void DiagramCavas::onSignal_wizardFinished(QString sName,QMap<QUuid,GraphicsBaseModelItem*> mapItem)
|
||||
{
|
||||
PowerEntity* pEntity;
|
||||
QUuid id = QUuid::createUuid();
|
||||
pEntity = TopologyManager::instance().findDiagram(id.toString());
|
||||
if(!pEntity) //不存在创建
|
||||
{
|
||||
pEntity = TopologyManager::instance().createDiagram(id.toString(),sName);
|
||||
|
||||
onSignal_addDrawingPanel(pEntity,DM_baseModel);
|
||||
DrawingPanel* pPanel = getPanel(pEntity->name());
|
||||
TopologyManager::instance().cloneEditorToBase(); //拷贝拓扑结构
|
||||
|
||||
QMap<QUuid,DiagramEditorItemProperty*> mapEditor = BasePropertyManager::instance().getEditorData();
|
||||
for(auto& pro:mapEditor){
|
||||
if(BasePropertyManager::instance().findBaseEntityData(pro->uuid()) == nullptr){ //拷贝editor数据到basemodel中
|
||||
auto pPro = pPanel->getModelController()->addBaseNodeData(pro->uuid(),pro->type(),pro->name(),pro->metaModelName(),pro->getBlock());
|
||||
pPro->setConnection(pro->getConnection());
|
||||
}
|
||||
}
|
||||
//pPanel->getModelController()->addTestData();
|
||||
|
||||
for(auto pItem:mapItem){
|
||||
auto cloneItem = pItem->clone();
|
||||
BaseModelProperty* pPro = BasePropertyManager::instance().findBaseEntityData(cloneItem->itemId());
|
||||
if(pPro){
|
||||
cloneItem->setProperty(pPro);
|
||||
pPanel->getScene()->addItem(cloneItem);
|
||||
if(pPro->type() != 8){
|
||||
PowerEntity* pEntity = TopologyManager::instance().findEntity(pPro->uuid().toString(),ModelFunctionType::BaseModel);
|
||||
if(pEntity)
|
||||
cloneItem->setEntity(pEntity);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*******************bay************************/
|
||||
void DiagramCavas::onSignl_openCurrentBay()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
#include "ui_confirmEditorDlg.h"
|
||||
#include "diagramEditor/confirmEditorDlg.h"
|
||||
#include <QDateTime>
|
||||
|
||||
ConfirmEditorDlg::ConfirmEditorDlg(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::confirmEditorDlg)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||
this->setWindowModality(Qt::WindowModal);
|
||||
initial();
|
||||
}
|
||||
|
||||
ConfirmEditorDlg::~ConfirmEditorDlg()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ConfirmEditorDlg::initial()
|
||||
{
|
||||
connect(ui->btn_ok,&QPushButton::clicked,this,&ConfirmEditorDlg::onOkClicked);
|
||||
connect(ui->btn_cancel,&QPushButton::clicked,this,&ConfirmEditorDlg::onCancelClicked);
|
||||
}
|
||||
|
||||
void ConfirmEditorDlg::showDlg(QString sName,QString sTime)
|
||||
{
|
||||
show();
|
||||
ui->le_name->setText(sName);
|
||||
ui->le_time->setText(sTime);
|
||||
}
|
||||
|
||||
void ConfirmEditorDlg::onOkClicked()
|
||||
{
|
||||
// 获取当前日期和时间
|
||||
QDateTime currentDateTime = QDateTime::currentDateTime();
|
||||
|
||||
// 将日期和时间格式化为字符串
|
||||
QString dateTimeString = currentDateTime.toString("yyyy-MM-dd hh:mm:ss");
|
||||
|
||||
emit onConfirmEditor(ui->le_name->text(),dateTimeString);
|
||||
hide();
|
||||
}
|
||||
|
||||
void ConfirmEditorDlg::onCancelClicked()
|
||||
{
|
||||
hide();
|
||||
}
|
||||
|
||||
|
|
@ -6,6 +6,7 @@ DiagramEditorBaseBlock::DiagramEditorBaseBlock(QObject *parent)
|
|||
{
|
||||
nType = 0;
|
||||
nContainerLevel = 0;
|
||||
bEditState = false;
|
||||
}
|
||||
DiagramEditorBaseBlock::~DiagramEditorBaseBlock()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -69,13 +69,9 @@ void DiagramEditorBayDetailSettingDlg::refreshModel()
|
|||
QStandardItem *itemObj = new QStandardItem();
|
||||
QStandardItem *itemRoute = new QStandardItem();
|
||||
QString sCategory;
|
||||
QString sType;
|
||||
if(info.nCategory == 0){
|
||||
sCategory = "设备";
|
||||
}
|
||||
else if(info.nCategory == 1){
|
||||
sCategory = "连接关系";
|
||||
}
|
||||
QString sType;
|
||||
if(info.nType == 1)
|
||||
{
|
||||
sType = "母线";
|
||||
|
|
@ -132,10 +128,28 @@ void DiagramEditorBayDetailSettingDlg::refreshModel()
|
|||
{
|
||||
sType = "电缆端";
|
||||
}
|
||||
}
|
||||
else if(info.nCategory == 1){
|
||||
sCategory = "连接关系";
|
||||
if(info.nType == 1){
|
||||
sType = "连接点";
|
||||
}
|
||||
}
|
||||
|
||||
itemCate->setText(sCategory);
|
||||
itemCate->setData(info.nCategory);
|
||||
itemName->setText(info.sName);
|
||||
itemName->setData(info.nUsedDirection);
|
||||
itemName->setData(info.deltaPos,Qt::UserRole+2);
|
||||
itemName->setData(info.uid,Qt::UserRole+3);
|
||||
itemName->setData(info.nFlag,Qt::UserRole+4);
|
||||
itemName->setData(info.nRotate,Qt::UserRole+5);
|
||||
itemType->setText(sType);
|
||||
itemType->setData(info.nType);
|
||||
itemObj->setText(info.sBindObj);
|
||||
itemObj->setData(info.nBindType);
|
||||
itemObj->setData(info.nBindPara,Qt::UserRole+2);
|
||||
itemObj->setData(info.sBindParent,Qt::UserRole+3);
|
||||
itemRoute->setText(info.sUsedRoute.join("、"));
|
||||
|
||||
QList<QStandardItem*> lstItems;
|
||||
|
|
@ -234,9 +248,22 @@ void DiagramEditorBayDetailSettingDlg::onOkClicked()
|
|||
int nLayout = ui->cb_layout->currentData().toInt();
|
||||
_curBayInfo.nLayout = nLayout;
|
||||
_curBayInfo.mapComponent = mapComponents;
|
||||
|
||||
int nDir = 0;
|
||||
if(nLayout == 0){ //纵,下右
|
||||
nDir = 41;
|
||||
}
|
||||
else if(nLayout == 1){ //横,右下
|
||||
nDir = 14;
|
||||
}
|
||||
QRectF recBounding = getModel()->updateTarget(_curBayInfo.mapRoute,_curBayInfo.mapComponent,nDir,0,true,false);
|
||||
if(_curOperateObj->getRecSize().isEmpty())
|
||||
_curOperateObj->setRecSize(recBounding);
|
||||
_curOperateObj->setBayInfo(_curBayInfo);
|
||||
|
||||
TopologyManager::instance().clearGlobalBlockData(_curOperateObj->getName());
|
||||
TopologyManager::instance().moveTempBlockData();
|
||||
_curOperateObj->setEditState(true);
|
||||
_curOperateObj = nullptr;
|
||||
}
|
||||
hide();
|
||||
|
|
|
|||
|
|
@ -45,219 +45,6 @@ void DiagramEditorBayPreviewDlg::showDlg(int nLayout)
|
|||
else if(nLayout == 1){ //横,右下
|
||||
nDir = 14;
|
||||
}
|
||||
_pParent->getModel()->updateTarget(_pParent->getBayInfo().mapRoute,nDir,0);
|
||||
//updateModelData();
|
||||
_pParent->getModel()->updateTarget(_pParent->getBayInfo().mapRoute,_pParent->getBayInfo().mapComponent,nDir,0);
|
||||
}
|
||||
|
||||
/*void DiagramEditorBayPreviewDlg::updateModelData()
|
||||
{
|
||||
auto& mapRoute = _pParent->getRouteMap();
|
||||
QString sMainRoute;
|
||||
int nCount = 0;
|
||||
for(auto& route:mapRoute){ //寻找包含设备最多的线路
|
||||
if(nCount < route.lstCompo.count()){
|
||||
nCount = route.lstCompo.count();
|
||||
sMainRoute = route.sRouteName;
|
||||
route.bMainRoute = true;
|
||||
}
|
||||
}
|
||||
|
||||
auto& maoCompo = mapRoute[sMainRoute].lstCompo; //假设竖直情况下,上下等分为nSeg段 假设主线路水平居中
|
||||
int nSeg = maoCompo.size()*0.5;
|
||||
int nSegIndex = -nSeg; //计数器,计算deltaY
|
||||
for(int i = 0;i < maoCompo.size();++i){ //优先遍历主线路,构建主体结构
|
||||
int nDir = 0;
|
||||
if(i == 0){ //队首
|
||||
maoCompo[i].nUsedDirection |= 4; //默认向下,队首单向下(单线路记录,不可作为跨线判断依据)
|
||||
nDir = 4;
|
||||
}
|
||||
else if(i == maoCompo.size()-1){
|
||||
maoCompo[i].nUsedDirection |= 8; //队尾单向上(单线路记录,不可作为跨线判断依据)
|
||||
nDir = 8;
|
||||
}
|
||||
else{
|
||||
maoCompo[i].nUsedDirection |= 12; //其余向上向下都被占用(单线路记录,不可作为跨线判断依据)
|
||||
nDir = 12;
|
||||
}
|
||||
int deltaY = nSegIndex*g_nVDiagramSpacing;
|
||||
|
||||
auto pItemName = _pParent->getModel()->getNameItem(maoCompo[i].sName);
|
||||
if(pItemName){
|
||||
int nVal = pItemName->data().toInt();
|
||||
pItemName->setData(QString::number(nVal |= nDir)); //在公用模型中更新设备方向占用(重要)
|
||||
pItemName->setData(QPoint(0,deltaY),Qt::UserRole+2); //设置相对位置
|
||||
}
|
||||
nSegIndex += 1;
|
||||
}
|
||||
|
||||
for(auto& route:mapRoute){ //遍历主线路之外的线路
|
||||
if(route.sRouteName == sMainRoute){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!route.lstCompo.isEmpty()){ //拆分线路为以节点为首
|
||||
auto pItemFirst = _pParent->getModel()->getNameItem(route.lstCompo.first().sName);
|
||||
int nFirstVal = pItemFirst->data().toInt();
|
||||
auto pItemLast = _pParent->getModel()->getNameItem(route.lstCompo.last().sName);
|
||||
int nLastVal = pItemLast->data().toInt();
|
||||
if(nFirstVal != 0){ //首位为节点
|
||||
route.lstOrder = route.lstCompo;
|
||||
}
|
||||
else if(nLastVal != 0){ //末位为节点
|
||||
for (auto it = route.lstCompo.rbegin(); it != route.lstCompo.rend(); ++it) {
|
||||
route.lstReverse.append(*it);
|
||||
}
|
||||
}
|
||||
else{ //节点在中间
|
||||
int nIndex = 0;
|
||||
for(int i = 0;i < route.lstCompo.size();++i){
|
||||
auto pItem = _pParent->getModel()->getNameItem(route.lstCompo[i].sName);
|
||||
if(pItem){
|
||||
int nVal = pItem->data().toInt();
|
||||
if(nVal != 0){
|
||||
nIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = nIndex;i >= 0;--i){
|
||||
route.lstReverse.append(route.lstCompo[i]);
|
||||
}
|
||||
|
||||
for(int i = nIndex;i < route.lstCompo.size();++i){
|
||||
route.lstOrder.append(route.lstCompo[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int nOrderFirstDeltaY = 0; //首节点y偏移量(假设后续节点与头节点水平)
|
||||
int nXOrderIndex = 1; //横向计数
|
||||
int nOrderPolarity = 1; //方向 1右 -1左
|
||||
if(route.lstOrder.size() > 1){
|
||||
for(int i = 0;i < route.lstOrder.size()-1;++i){ //遍历以节点为首的队列
|
||||
auto pItem = _pParent->getModel()->getNameItem(route.lstOrder[i].sName);
|
||||
int nVal = pItem->data().toInt();
|
||||
QPoint deltaP = pItem->data(Qt::UserRole+2).toPoint();
|
||||
auto pNextItem = _pParent->getModel()->getNameItem(route.lstOrder[i+1].sName); //下一个item
|
||||
nOrderFirstDeltaY = deltaP.y();
|
||||
int nNextVal = pNextItem->data().toInt();
|
||||
if(i == 0){ //首节点
|
||||
if(((nVal & 2) == 1) && ((nVal & 1) == 1)){
|
||||
qDebug()<<QString("point %1 full of connection").arg(route.lstOrder[i].sName);
|
||||
}
|
||||
else if((nVal & 2) == 1){
|
||||
//左被占用,右空
|
||||
pItem->setData(QString::number(nVal | 1));
|
||||
pNextItem->setData(QString::number(nNextVal | 2)); //同时连接下个点的一侧占用
|
||||
nOrderPolarity = 1;
|
||||
pNextItem->setData(-90,Qt::UserRole+5);
|
||||
}
|
||||
else if((nVal & 1) == 1){
|
||||
//右被占用,左空
|
||||
pItem->setData(QString::number(nVal | 2));
|
||||
pNextItem->setData(QString::number(nNextVal | 1));
|
||||
nOrderPolarity = -1;
|
||||
pNextItem->setData(90,Qt::UserRole+5);
|
||||
}
|
||||
else{ //左右都没被占,默认放到左边
|
||||
pItem->setData(QString::number(nVal | 1));
|
||||
pNextItem->setData(QString::number(nNextVal | 2));
|
||||
nOrderPolarity = 1;
|
||||
pNextItem->setData(-90,Qt::UserRole+5);
|
||||
}
|
||||
int deltaX = nXOrderIndex*nOrderPolarity*g_nHDiagramSpacing;
|
||||
pNextItem->setData(QPoint(deltaX,nOrderFirstDeltaY),Qt::UserRole + 2);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(((nVal & 2) == 1) && ((nVal & 1) == 1)){
|
||||
qDebug()<<QString("point %1 full of connection").arg(route.lstOrder[i].sName);
|
||||
}
|
||||
else if((nVal & 2) == 1){
|
||||
//左被占用,右空
|
||||
pItem->setData(QString::number(nVal | 1));
|
||||
pNextItem->setData(QString::number(nNextVal | 2)); //同时连接下个点的一侧占用
|
||||
}
|
||||
else if((nVal & 1) == 1){
|
||||
//右被占用,左空
|
||||
pItem->setData(QString::number(nVal | 2));
|
||||
pNextItem->setData(QString::number(nNextVal | 1));
|
||||
}
|
||||
else{ //左右都没被占,默认放到左边
|
||||
pItem->setData(QString::number(nVal | 1));
|
||||
pNextItem->setData(QString::number(nNextVal | 2));
|
||||
}
|
||||
int deltaX = nXOrderIndex*nOrderPolarity*g_nHDiagramSpacing;
|
||||
pNextItem->setData(QPoint(deltaX,nOrderFirstDeltaY),Qt::UserRole + 2);
|
||||
nXOrderIndex += 1;
|
||||
}
|
||||
}
|
||||
|
||||
int nReverseFirstDeltaY = 0; //首节点y偏移量(假设后续节点与头节点水平)
|
||||
int nXReverseIndex = 1; //横向计数
|
||||
int nReversePolarity = 1; //方向 1右 -1左
|
||||
if(route.lstReverse.size() > 1){
|
||||
for(int i = 0;i < route.lstReverse.size()-1;++i){ //遍历以节点为首的队列
|
||||
auto pItem = _pParent->getModel()->getNameItem(route.lstReverse[i].sName);
|
||||
int nVal = pItem->data().toInt();
|
||||
QPoint deltaP = pItem->data(Qt::UserRole+2).toPoint();
|
||||
|
||||
auto pNextItem = _pParent->getModel()->getNameItem(route.lstReverse[i+1].sName); //下一个item
|
||||
nReverseFirstDeltaY = deltaP.y();
|
||||
|
||||
int nNextVal = pNextItem->data().toInt();
|
||||
if(i == 0){ //首节点
|
||||
if(((nVal & 2) == 1) && ((nVal & 1) == 1)){
|
||||
qDebug()<<QString("point %1 full of connection").arg(route.lstReverse[i].sName);
|
||||
}
|
||||
else if((nVal & 2) == 1){
|
||||
//左被占用,右空
|
||||
pItem->setData(QString::number(nVal | 1));
|
||||
pNextItem->setData(QString::number(nNextVal | 2)); //同时连接下个点的一侧占用
|
||||
nReversePolarity = 1;
|
||||
pNextItem->setData(-90,Qt::UserRole+5);
|
||||
}
|
||||
else if((nVal & 1) == 1){
|
||||
//右被占用,左空
|
||||
pItem->setData(QString::number(nVal | 2));
|
||||
pNextItem->setData(QString::number(nNextVal | 1));
|
||||
nReversePolarity = -1;
|
||||
pNextItem->setData(90,Qt::UserRole+5);
|
||||
}
|
||||
else{ //左右都没被占,默认放到左边
|
||||
pItem->setData(QString::number(nVal | 1));
|
||||
pNextItem->setData(QString::number(nNextVal | 2));
|
||||
nReversePolarity = 1;
|
||||
pNextItem->setData(-90,Qt::UserRole+5);
|
||||
}
|
||||
int deltaX = nXReverseIndex*nReversePolarity*g_nHDiagramSpacing;
|
||||
pNextItem->setData(QPoint(deltaX,nReverseFirstDeltaY),Qt::UserRole + 2);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(((nVal & 2) == 1) && ((nVal & 1) == 1)){
|
||||
qDebug()<<QString("point %1 full of connection").arg(route.lstOrder[i].sName);
|
||||
}
|
||||
else if((nVal & 2) == 1){
|
||||
//左被占用,右空
|
||||
pItem->setData(QString::number(nVal | 1));
|
||||
pNextItem->setData(QString::number(nNextVal | 2)); //同时连接下个点的一侧占用
|
||||
}
|
||||
else if((nVal & 1) == 1){
|
||||
//右被占用,左空
|
||||
pItem->setData(QString::number(nVal | 2));
|
||||
pNextItem->setData(QString::number(nNextVal | 1));
|
||||
}
|
||||
else{ //左右都没被占,默认放到左边
|
||||
pItem->setData(QString::number(nVal | 1));
|
||||
pNextItem->setData(QString::number(nNextVal | 2));
|
||||
}
|
||||
int deltaX = nXReverseIndex*nReversePolarity*g_nHDiagramSpacing;
|
||||
pNextItem->setData(QPoint(deltaX,nReverseFirstDeltaY),Qt::UserRole + 2);
|
||||
nXReverseIndex += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ void DiagramEditorPreviewDlg::initial()
|
|||
_pMainLayout = new QVBoxLayout(this);
|
||||
_pView = new EditView(this);
|
||||
_pMainLayout->addWidget(_pView);
|
||||
_pScene = new EditScene(this);
|
||||
_pScene = new EditPreviewScene(this);
|
||||
_pScene->setSceneRect(_pParent->getScene()->sceneRect()); //使用父窗口scene大小
|
||||
_pView->setScene(_pScene);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,9 +158,19 @@ void DiagramEditorTransDetailSettingDlg::refreshModel()
|
|||
sType = "电缆端";
|
||||
}
|
||||
itemCate->setText(sCategory);
|
||||
itemCate->setData(info.nCategory);
|
||||
itemName->setText(info.sName);
|
||||
itemName->setData(info.nUsedDirection);
|
||||
itemName->setData(info.deltaPos,Qt::UserRole+2);
|
||||
itemName->setData(info.uid,Qt::UserRole+3);
|
||||
itemName->setData(info.nFlag,Qt::UserRole+4);
|
||||
itemName->setData(info.nRotate,Qt::UserRole+5);
|
||||
itemType->setText(sType);
|
||||
itemType->setData(info.nType);
|
||||
itemObj->setText(info.sBindObj);
|
||||
itemObj->setData(info.nBindType);
|
||||
itemObj->setData(info.nBindPara,Qt::UserRole+2);
|
||||
itemObj->setData(info.sBindParent,Qt::UserRole+3);
|
||||
itemRoute->setText(info.sUsedRoute.join("、"));
|
||||
|
||||
QList<QStandardItem*> lstItems;
|
||||
|
|
@ -261,21 +271,41 @@ void DiagramEditorTransDetailSettingDlg::onOkClicked()
|
|||
}
|
||||
//_curOperateObj->setComponentMap(mapComponents);
|
||||
_transInfo.mapComponent = mapComponents;
|
||||
QRectF rec1;
|
||||
QRectF rec2;
|
||||
QRectF rec3;
|
||||
QRectF result;
|
||||
if(_transInfo.mapNeutral.contains(0)){
|
||||
QPointF delta = QPointF(100,-25);
|
||||
_transInfo.mapNeutral[0].nType = 0;
|
||||
_transInfo.mapNeutral[0].delPoint = QPointF(100,-100);
|
||||
_transInfo.mapNeutral[0].delPoint = delta;
|
||||
rec1 = getModel()->updateTarget(_transInfo.mapNeutral[0].mapRoute,_transInfo.mapComponent,18,1,true,false); //1右2上
|
||||
rec1.translate(delta); //相对trans偏移
|
||||
result = result.united(rec1);
|
||||
}
|
||||
if(_transInfo.mapNeutral.contains(1)){
|
||||
QPointF delta = QPointF(-150,0);
|
||||
_transInfo.mapNeutral[1].nType = 1;
|
||||
_transInfo.mapNeutral[1].delPoint = QPointF(-100,-50);
|
||||
_transInfo.mapNeutral[1].delPoint = delta;
|
||||
rec2 = getModel()->updateTarget(_transInfo.mapNeutral[1].mapRoute,_transInfo.mapComponent,14,1,true,false); //1右2下
|
||||
rec2.translate(delta);
|
||||
result = result.united(rec2);
|
||||
}
|
||||
if(_transInfo.mapNeutral.contains(2)){
|
||||
QPointF delta = QPointF(100,25);
|
||||
_transInfo.mapNeutral[2].nType = 2;
|
||||
_transInfo.mapNeutral[2].delPoint = QPointF(100,0);
|
||||
_transInfo.mapNeutral[2].delPoint = delta;
|
||||
rec3 = getModel()->updateTarget(_transInfo.mapNeutral[2].mapRoute,_transInfo.mapComponent,24,1,true,false); //1左2下
|
||||
rec3.translate(delta);
|
||||
result = result.united(rec3);
|
||||
}
|
||||
|
||||
if(_curOperateObj->getRecSize().isEmpty())
|
||||
_curOperateObj->setRecSize(result);
|
||||
_curOperateObj->setTransInfo(_transInfo);
|
||||
TopologyManager::instance().clearGlobalBlockData(_curOperateObj->getName());
|
||||
TopologyManager::instance().moveTempBlockData();
|
||||
_curOperateObj->setEditState(true);
|
||||
_curOperateObj = nullptr;
|
||||
}
|
||||
hide();
|
||||
|
|
|
|||
|
|
@ -44,11 +44,11 @@ void DiagramEditorTransPreviewDlg::showDlg(int nType)
|
|||
void DiagramEditorTransPreviewDlg::updateModelData(int nType)
|
||||
{
|
||||
if(nType == 0 || nType == 1 || nType == 2){
|
||||
_pParent->getModel()->updateTarget(_pParent->getTransInfo().mapNeutral[nType].mapRoute,14,1); //1右2下
|
||||
_pParent->getModel()->updateTarget(_pParent->getTransInfo().mapNeutral[nType].mapRoute,_pParent->getTransInfo().mapComponent,14,1); //1右2下
|
||||
}
|
||||
else if(nType == 3){ //整个变压器
|
||||
_pParent->getModel()->updateTarget(_pParent->getTransInfo().mapNeutral[0].mapRoute,18,1); //1右2上
|
||||
_pParent->getModel()->updateTarget(_pParent->getTransInfo().mapNeutral[1].mapRoute,14,1); //1右2下
|
||||
_pParent->getModel()->updateTarget(_pParent->getTransInfo().mapNeutral[2].mapRoute,24,1); //1左2下
|
||||
_pParent->getModel()->updateTarget(_pParent->getTransInfo().mapNeutral[0].mapRoute,_pParent->getTransInfo().mapComponent,18,1); //1右2上
|
||||
_pParent->getModel()->updateTarget(_pParent->getTransInfo().mapNeutral[1].mapRoute,_pParent->getTransInfo().mapComponent,14,1); //1右2下
|
||||
_pParent->getModel()->updateTarget(_pParent->getTransInfo().mapNeutral[2].mapRoute,_pParent->getTransInfo().mapComponent,24,1); //1左2下
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -484,6 +484,7 @@ void DiagramEditorWizard::onAddBayFinished(DiagramEditorWizardBayInfo info)
|
|||
}
|
||||
|
||||
DiagramEditorBayBlock* pBlock = new DiagramEditorBayBlock(this);
|
||||
pBlock->setId(QUuid::createUuid());
|
||||
pBlock->setName(info.sName);
|
||||
pBlock->setType(2);
|
||||
pBlock->setBayType(info.nType);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,19 @@ EditBaseItem::~EditBaseItem()
|
|||
|
||||
}
|
||||
|
||||
QString EditBaseItem::getEditState()
|
||||
{
|
||||
QString str;
|
||||
if(_pBlock){
|
||||
bool state = _pBlock->getEditState();
|
||||
if(state)
|
||||
str = "已编辑";
|
||||
else
|
||||
str = "未编辑";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
QPainterPath EditBaseItem::shape()
|
||||
{
|
||||
QPainterPath path;
|
||||
|
|
@ -63,11 +76,62 @@ EditBayItem::~EditBayItem()
|
|||
|
||||
}
|
||||
|
||||
QString EditBayItem::getShowType()
|
||||
{
|
||||
QString str;
|
||||
if(_pBlock){
|
||||
auto pBay = dynamic_cast<DiagramEditorBayBlock*>(_pBlock.data());
|
||||
if(pBay){
|
||||
BayType tpe = pBay->getBayType();
|
||||
switch (tpe) {
|
||||
case BayType::busSectionBay:
|
||||
str = "分段间隔";
|
||||
break;
|
||||
case BayType::busCouplerBay:
|
||||
str = "母联间隔";
|
||||
break;
|
||||
case BayType::ptBay:
|
||||
str = "PT间隔";
|
||||
break;
|
||||
case BayType::incomingBay:
|
||||
str = "进线间隔";
|
||||
break;
|
||||
case BayType::outcomingBay:
|
||||
str = "出线间隔";
|
||||
break;
|
||||
case BayType::compensationBay:
|
||||
str = "无功补偿间隔";
|
||||
break;
|
||||
case BayType::bypassBay:
|
||||
str = "旁路间隔";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
void EditBayItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setPen(QColor(220,220,230));
|
||||
painter->drawRect(m_boundingRect);
|
||||
painter->drawText(QPointF(-10,0),sName);
|
||||
|
||||
painter->setFont(QFont("Arial", 12));
|
||||
painter->setPen(Qt::cyan);
|
||||
|
||||
QString str1 = "类型:"+getShowType();
|
||||
QString str2 = "状态:"+getEditState();
|
||||
QString text = str1+"\n"+str2;
|
||||
|
||||
QTextOption op;
|
||||
op.setAlignment(Qt::AlignCenter);
|
||||
painter->drawText(boundingRect(), text, op);
|
||||
}
|
||||
|
||||
/********************trans*********************/
|
||||
|
|
@ -82,11 +146,47 @@ EditTransItem::~EditTransItem()
|
|||
|
||||
}
|
||||
|
||||
QString EditTransItem::getShowType()
|
||||
{
|
||||
QString str;
|
||||
if(_pBlock){
|
||||
auto pTrans = dynamic_cast<DiagramEditorTransformerBlock*>(_pBlock.data());
|
||||
if(pTrans){
|
||||
TransformerType tpe = pTrans->getTransType();
|
||||
switch (tpe) {
|
||||
case TransformerType::twoWinding:
|
||||
str = "两绕组变压器";
|
||||
break;
|
||||
case TransformerType::threeWinding:
|
||||
str = "三绕组变压器";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
void EditTransItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setPen(QColor(180,235,155));
|
||||
painter->drawRect(m_boundingRect);
|
||||
painter->drawText(QPointF(-10,0),sName);
|
||||
|
||||
painter->setFont(QFont("Arial", 12));
|
||||
painter->setPen(Qt::cyan);
|
||||
|
||||
QString str1 = "类型:"+getShowType();
|
||||
QString str2 = "状态:"+getEditState();
|
||||
QString text = str1+"\n"+str2;
|
||||
|
||||
QTextOption op;
|
||||
op.setAlignment(Qt::AlignCenter);
|
||||
painter->drawText(boundingRect(), text, op);
|
||||
}
|
||||
|
||||
/********************连线*********************/
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
#include "diagramEditor/diagramEditorTransDetailSettingDlg.h"
|
||||
#include "graphicsDataModel/diagramEditorModel.h"
|
||||
#include "diagramEditor/diagramEditorPreviewDlg.h"
|
||||
#include "diagramEditor/confirmEditorDlg.h"
|
||||
#include "diagramCavas.h"
|
||||
#include "global.h"
|
||||
#include <QDebug>
|
||||
|
||||
|
|
@ -29,6 +31,7 @@ EditPanel::EditPanel(QWidget *parent)
|
|||
,_transDetailSetting(nullptr)
|
||||
,_pModel(nullptr)
|
||||
,_pPreview(nullptr)
|
||||
,_confirmEditor(nullptr)
|
||||
{
|
||||
_pModel = new DiagramEditorModel();
|
||||
_pModel->setPanel(this);
|
||||
|
|
@ -39,7 +42,7 @@ EditPanel::EditPanel(QWidget *parent)
|
|||
m_pEditScene->setModel(_pModel);
|
||||
//设置场景大小.前两个参数为scene的坐标远点,设置到view的中心点后,无论view如何缩放,secne的坐标原点都不会动,方便后续的位置计算
|
||||
//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*4, g_dGriaphicsScene_Height*4);
|
||||
|
||||
m_pEditView = new EditView(this);
|
||||
m_pEditView->setScene(m_pEditScene);
|
||||
|
|
@ -361,6 +364,22 @@ void EditPanel::showPreview()
|
|||
_pPreview->showDlg();
|
||||
}
|
||||
|
||||
void EditPanel::showConfirmDlg()
|
||||
{
|
||||
if(!_confirmEditor){
|
||||
_confirmEditor = new ConfirmEditorDlg(this);
|
||||
_confirmEditor->setModelDelegate(_pModel);
|
||||
|
||||
connect(_confirmEditor,&ConfirmEditorDlg::onConfirmEditor,this,[&](QString sAuthor,QString sTime){
|
||||
auto pCavas = _pModel->getCavas();
|
||||
if(pCavas){
|
||||
pCavas->onSignal_wizardFinished(_projectName,_pModel->getPreviewItem());
|
||||
}
|
||||
});
|
||||
}
|
||||
_confirmEditor->show();
|
||||
}
|
||||
|
||||
QList<EditBaseItem*> EditPanel::getBlockItems(EditorItemType typ)
|
||||
{
|
||||
QList<EditBaseItem*> lst;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include "graphicsDataModel/diagramEditorModel.h"
|
||||
#include "diagramEditor/editPanel.h"
|
||||
|
||||
EditBaseScene::EditBaseScene(QObject *parent)
|
||||
: QGraphicsScene(parent)
|
||||
|
|
@ -34,9 +35,12 @@ void EditScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
if(_pModel){
|
||||
//_pModel->setCurPreviewScene(this);
|
||||
_pModel->generatePreview();
|
||||
_pModel->calculateBlockPos();
|
||||
_pModel->setItemInBlockPos();
|
||||
_pModel->refreshConnection();
|
||||
}
|
||||
} else if (selectedAction == generateAction) {
|
||||
|
||||
_pModel->getPanel()->showConfirmDlg();
|
||||
}
|
||||
}
|
||||
/************************预览*********************/
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ DrawingPanel::DrawingPanel(PowerEntity* pEntity,QWidget *parent,DiagramMode mode
|
|||
m_pSelectorManager = new SelectorManager(_pModel,this);
|
||||
m_pGraphicsScene = new DesignerScene(_pModel,this);
|
||||
//设置场景大小.前两个参数为scene的坐标远点,设置到view的中心点后,无论view如何缩放,secne的坐标原点都不会动,方便后续的位置计算
|
||||
m_pGraphicsScene->setSceneRect(-g_dGriaphicsScene_Width / 2, -g_dGriaphicsScene_Height / 2, g_dGriaphicsScene_Width, g_dGriaphicsScene_Height);
|
||||
m_pGraphicsScene->setSceneRect(-g_dGriaphicsScene_Width, -g_dGriaphicsScene_Height, g_dGriaphicsScene_Width*2, g_dGriaphicsScene_Height*2);
|
||||
m_pGraphicsScene->setGridVisible(true);
|
||||
|
||||
m_pGraphicsView = new DesignerView(this);
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ bool DiagramEditorModel::addPreviewItem(QUuid uuid,GraphicsBaseModelItem* pItem,
|
|||
return false;
|
||||
else
|
||||
{
|
||||
pItem->setMask(false);
|
||||
_tempItem.insert(uuid,pItem);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -49,6 +50,7 @@ bool DiagramEditorModel::addPreviewItem(QUuid uuid,GraphicsBaseModelItem* pItem,
|
|||
return false;
|
||||
else
|
||||
{
|
||||
pItem->setMask(false);
|
||||
_previewItem.insert(uuid,pItem);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -313,6 +315,7 @@ void DiagramEditorModel::generateTempTrans(int nType,DiagramEditorTransformerBlo
|
|||
|
||||
if(_pCurPreviewScene){
|
||||
QRectF itemsRect = _pCurPreviewScene->itemsBoundingRect();
|
||||
if(block->getRecSize().isEmpty())
|
||||
block->setRecSize(itemsRect);
|
||||
}
|
||||
}
|
||||
|
|
@ -426,6 +429,8 @@ void DiagramEditorModel::generatePreview()
|
|||
QRectF rec = item->boundingRect();
|
||||
|
||||
QPointF pos = item->scenePos();
|
||||
if(_previewItem.contains(uid))
|
||||
continue;
|
||||
auto pItem = generateComponent(uid,name,0,1,pos,0,1);
|
||||
if(nMaxLen > rec.width())
|
||||
rec.setWidth(nMaxLen);
|
||||
|
|
@ -501,8 +506,6 @@ void DiagramEditorModel::generatePreview()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
calculateBlockPos();
|
||||
}
|
||||
|
||||
void DiagramEditorModel::calculateBlockPos()
|
||||
|
|
@ -520,6 +523,8 @@ void DiagramEditorModel::calculateBlockPos()
|
|||
for(auto &pCon:iter.value()){ //首次循环遍历每行container,计算最大上空间高度,最大下空间高度,容器宽度
|
||||
auto mapBlocks = pCon->getBlockMap();
|
||||
auto lstBlockUp = mapBlocks.value(0);
|
||||
auto lstBus1 = mapBlocks.value(1); //1母
|
||||
auto lstBus2 = mapBlocks.value(2); //2母
|
||||
auto lstBlockDown = mapBlocks.value(3);
|
||||
double dConWidth = 0;
|
||||
|
||||
|
|
@ -532,6 +537,7 @@ void DiagramEditorModel::calculateBlockPos()
|
|||
dMaxUp = dHeight;
|
||||
dWidthUp += g_nHorizontalBlockSpacing+dWidth;
|
||||
}
|
||||
dMaxUp += g_dEditorItem_Height;
|
||||
|
||||
double dWidthDown = 0;
|
||||
for(auto pBlock:lstBlockDown){
|
||||
|
|
@ -542,12 +548,32 @@ void DiagramEditorModel::calculateBlockPos()
|
|||
dMaxDown = dHeight;
|
||||
dWidthDown = g_nHorizontalBlockSpacing+dWidth;
|
||||
}
|
||||
dMaxDown += g_dEditorItem_Height;
|
||||
|
||||
int nBusLen = 0;
|
||||
if(!lstBus1.empty()){
|
||||
nBusLen = lstBus1.first()->getRecSize().width();
|
||||
}
|
||||
|
||||
if(!lstBus2.empty()){
|
||||
int nLen = lstBus2.first()->getRecSize().width();
|
||||
if(nBusLen < nLen)
|
||||
nBusLen = nLen;
|
||||
}
|
||||
|
||||
dConWidth = dWidthUp > dWidthDown ? dWidthUp : dWidthDown;
|
||||
if(dConWidth < nBusLen)
|
||||
dConWidth = nBusLen;
|
||||
pCon->setWidth(dConWidth);
|
||||
}
|
||||
|
||||
double dDeltaX = 0; //每行横向偏移
|
||||
if(dMaxUp == 0){
|
||||
dMaxUp = g_dEditorItem_Height;
|
||||
}
|
||||
if(dMaxDown == 0){
|
||||
dMaxDown = g_dEditorItem_Height;
|
||||
}
|
||||
double dDeltaX = 50; //每行横向偏移
|
||||
for(auto &pCon:iter.value()){ //第二次循环赋值,计算位置(首先确定母线位置)
|
||||
pCon->setMaxUpH(dMaxUp);
|
||||
pCon->setMaxDownH(dMaxDown);
|
||||
|
|
@ -555,10 +581,18 @@ void DiagramEditorModel::calculateBlockPos()
|
|||
if(iter == mapTotal.begin()){ //首行 deltaY = 首行dMaxUpH
|
||||
deltaY = pCon->getMaxUpH();
|
||||
}
|
||||
else if(iter == std::next(mapTotal.begin())){ //第二行
|
||||
if(!mapTotal.value(g_transformerLevel).empty()){ //有变压器
|
||||
deltaY = deltaY + pCon->getMaxUpH();
|
||||
}
|
||||
else
|
||||
deltaY = deltaY + 50 + lastMaxDownH + pCon->getMaxUpH();
|
||||
}
|
||||
else //其他行 deltaY = deltaY+母线高度+上行dMaxDownH+本行dMaxUpH
|
||||
{
|
||||
deltaY = deltaY + 50 + lastMaxDownH + pCon->getMaxUpH();
|
||||
}
|
||||
|
||||
lastMaxDownH = pCon->getMaxDownH();
|
||||
}
|
||||
pCon->setMidUpY(deltaY);
|
||||
|
|
@ -579,18 +613,18 @@ void DiagramEditorModel::calculateBlockPos()
|
|||
QPointF center;
|
||||
if(pBlock->getType() == 1){ //母线
|
||||
if(it.key() == 1){ //1母
|
||||
center = QPointF(pStartX+recBlock.width()*0.5,dMiddleUpY+recBlock.height()*0.5);
|
||||
center = QPointF(pStartX/*+recBlock.width()*0.5*/,dMiddleUpY+recBlock.height()*0.5);
|
||||
}
|
||||
else if(it.key() == 2){ //2母
|
||||
center = QPointF(pStartX+recBlock.width()*0.5,dMiddleDownY-recBlock.height()*0.5);
|
||||
center = QPointF(pStartX/*+recBlock.width()*0.5*/,dMiddleDownY-recBlock.height()*0.5);
|
||||
}
|
||||
}
|
||||
else if(pBlock->getType() == 2){ //间隔
|
||||
if(it.key() == 0){ //容器最上层
|
||||
center = QPointF(deltaX+recBlock.width()*0.5,dMiddleUpY-recBlock.height()*0.5);
|
||||
center = QPointF(deltaX+recBlock.width()*0.5,dMiddleUpY-recBlock.height()*0.5-g_dEditorItem_Height*0.5);
|
||||
}
|
||||
else if(it.key() == 3){ //容器最下层
|
||||
center = QPointF(deltaX+recBlock.width()*0.5,dMiddleDownY+recBlock.height()*0.5);
|
||||
center = QPointF(deltaX+recBlock.width()*0.5,dMiddleDownY+recBlock.height()*0.5+g_dEditorItem_Height*0.5);
|
||||
}
|
||||
deltaX += recBlock.width();
|
||||
}
|
||||
|
|
@ -599,14 +633,16 @@ void DiagramEditorModel::calculateBlockPos()
|
|||
|
||||
if(!center.isNull())
|
||||
pBlock->setSeceneDelta(center);
|
||||
//qDebug()<<pBlock->getName()<<":"<<center<<"-"<<recBlock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dDeltaX = 0;
|
||||
dDeltaX = 50;
|
||||
if(iter.key() == 0){ //若设置了变压器,直接插入到第一行下方
|
||||
if(!mapTotal.value(g_transformerLevel).empty()){
|
||||
for(auto &pCon:iter.value()){ //首次计算变压器大小
|
||||
auto lstCon = mapTotal.value(g_transformerLevel);
|
||||
for(auto &pCon:lstCon){ //首次计算变压器大小
|
||||
auto mapBlocks = pCon->getBlockMap();
|
||||
auto lstBlock = mapBlocks.value(1);
|
||||
for(auto &pb:lstBlock){
|
||||
|
|
@ -616,14 +652,16 @@ void DiagramEditorModel::calculateBlockPos()
|
|||
}
|
||||
}
|
||||
|
||||
for(auto &pCon:iter.value()){ //计算位置
|
||||
if(pCon == iter.value().first()){
|
||||
for(auto &pCon:lstCon){ //计算位置
|
||||
if(pCon == lstCon.first()){
|
||||
//只在每行第一次改变deltaY
|
||||
deltaY += pCon->getHeight();
|
||||
deltaY = deltaY + 50 + lastMaxDownH + pCon->getHeight();
|
||||
}
|
||||
pCon->setStartY(deltaY-pCon->getHeight());
|
||||
double dHeight = pCon->getHeight();
|
||||
double dWidth = pCon->getWidth();
|
||||
pCon->setStartY(deltaY-dHeight*0.5);
|
||||
pCon->setStartX(dDeltaX);
|
||||
dDeltaX += pCon->getWidth();
|
||||
dDeltaX += dWidth+100;
|
||||
|
||||
auto mapBlocks = pCon->getBlockMap();
|
||||
|
||||
|
|
@ -632,6 +670,7 @@ void DiagramEditorModel::calculateBlockPos()
|
|||
QRectF recBlock = pBlock->getRecSize();
|
||||
QPointF center = QPointF(pCon->getStartX()+recBlock.width()*0.5,pCon->getStartY()+recBlock.height()*0.5);
|
||||
pBlock->setSeceneDelta(center);
|
||||
qDebug()<<pBlock->getName()<<":"<<center<<"-"<<recBlock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -654,6 +693,8 @@ void DiagramEditorModel::setItemInBlockPos()
|
|||
if(pItem){
|
||||
QPointF pPos = p->getSceneDelta();
|
||||
pItem->setPos(pPos);
|
||||
pItem->setPosChanged(true);
|
||||
//qDebug()<<pItem->sceneBoundingRect()<<pItem->boundingRect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -672,6 +713,7 @@ void DiagramEditorModel::setItemInBlockPos()
|
|||
if(pItem){
|
||||
QPointF pos = info.deltaPos+pBay->getSceneDelta();
|
||||
pItem->setPos(pos);
|
||||
pItem->setPosChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -682,6 +724,11 @@ void DiagramEditorModel::setItemInBlockPos()
|
|||
if(pTrans){
|
||||
auto transInfo = pTrans->getTranInfo();
|
||||
auto mapCompo = transInfo.mapComponent;
|
||||
//item->setPos(pTrans->getSceneDelta());
|
||||
auto transItem = _previewItem.value(pTrans->getId());
|
||||
if(transItem){
|
||||
transItem->setPos(pTrans->getSceneDelta());
|
||||
}
|
||||
|
||||
for(auto &neuInfo:transInfo.mapNeutral){
|
||||
auto mapRoute = neuInfo.mapRoute;
|
||||
|
|
@ -690,8 +737,56 @@ void DiagramEditorModel::setItemInBlockPos()
|
|||
for(auto& info:lst){
|
||||
auto pItem = _previewItem.value(info.uid);
|
||||
if(pItem){
|
||||
QPointF pos = info.deltaPos+(pTrans->getSceneDelta()-info.deltaPos);
|
||||
QPointF pos = info.deltaPos+transItem->mapToScene(neuInfo.delPoint);
|
||||
pItem->setPos(pos);
|
||||
pItem->setPosChanged(true);
|
||||
//qDebug()<<pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DiagramEditorModel::refreshConnection()
|
||||
{
|
||||
for(auto& item:_previewItem){
|
||||
auto pData = item->getProperty();
|
||||
if(pData){
|
||||
int nType = pData->type();
|
||||
QUuid uid = pData->uuid();
|
||||
if(nType == 8){ //是电缆
|
||||
auto pLine = dynamic_cast<ElectricBaseModelLineItem*>(item);
|
||||
if(pLine){
|
||||
PowerConnection* pCon = TopologyManager::instance().connection(uid.toString(),ModelFunctionType::EditorModel);
|
||||
if(pCon){
|
||||
QString fromTerId = pCon->fromTerminalId();
|
||||
QString toTerId = pCon->toTerminalId();
|
||||
QString fromId = pCon->fromComponent();
|
||||
QString toId = pCon->toComponent();
|
||||
|
||||
GraphicsBaseModelItem* pFromItem = _previewItem.value(QUuid(fromId));
|
||||
GraphicsBaseModelItem* pToItem = _previewItem.value(QUuid(toId));
|
||||
|
||||
auto pFromData = pFromItem->getProperty();
|
||||
auto pToData = pToItem->getProperty();
|
||||
if(pFromData->type() == 1){ //from是母线
|
||||
pFromItem->movePort(fromTerId,pFromItem->mapFromScene(calculateBusPortPos(pFromItem,pToItem)));
|
||||
}
|
||||
else if(pToData->type() == 1){ //to是母线
|
||||
pToItem->movePort(toTerId,pToItem->mapFromScene(calculateBusPortPos(pToItem,pFromItem)));
|
||||
}
|
||||
|
||||
auto portsFrom = pFromItem->getPorts();
|
||||
auto portsTo = pToItem->getPorts();
|
||||
|
||||
ItemPort* pFrom = portsFrom.value(fromTerId);
|
||||
ItemPort* pTo = portsTo.value(toTerId);
|
||||
if(pFrom && pTo){ //更新连线起点终点位置
|
||||
pLine->setStartPoint(pFrom->scenePos());
|
||||
pLine->setEndPoint(pTo->scenePos());
|
||||
pLine->calculatePath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -795,6 +890,8 @@ QList<DiagramEditorComponentInfo> DiagramEditorModel::generateItemByInfo(QMap<QS
|
|||
sMain = route.sRouteName;
|
||||
for(auto& compo:route.lstCompo){ //首先生成设备
|
||||
auto info = mapCompo.value(compo.sName);
|
||||
if(_previewItem.contains(info.uid))
|
||||
continue;
|
||||
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))
|
||||
|
|
@ -814,6 +911,8 @@ QList<DiagramEditorComponentInfo> DiagramEditorModel::generateItemByInfo(QMap<QS
|
|||
}
|
||||
for(auto &compo:route.lstOrder){ //生成正序设备
|
||||
auto info = mapCompo.value(compo.sName);
|
||||
if(_previewItem.contains(info.uid))
|
||||
continue;
|
||||
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))
|
||||
|
|
@ -823,6 +922,8 @@ QList<DiagramEditorComponentInfo> DiagramEditorModel::generateItemByInfo(QMap<QS
|
|||
|
||||
for(auto &compo:route.lstReverse){ //生成逆序设备
|
||||
auto info = mapCompo.value(compo.sName);
|
||||
if(_previewItem.contains(info.uid))
|
||||
continue;
|
||||
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))
|
||||
|
|
@ -910,11 +1011,47 @@ void DiagramEditorModel::generateOutConnection(QList<DiagramEditorComponentInfo>
|
|||
}
|
||||
}
|
||||
|
||||
void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data,int nLayout,int nSource)
|
||||
QRectF DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data,QMap<QString,DiagramEditorComponentInfo>& compos,int nLayout,int nSource,bool regenerate,bool saveToModel)
|
||||
{
|
||||
QRectF recBounding; //包含所有元件的矩形
|
||||
auto& mapRoute = data;
|
||||
QString sMainRoute;
|
||||
|
||||
if(regenerate){ //清空方位数据
|
||||
if(saveToModel){
|
||||
for(auto &routeInfo:data){
|
||||
routeInfo.lstOrder.clear();
|
||||
routeInfo.lstReverse.clear();
|
||||
for(auto &compo:routeInfo.lstCompo){
|
||||
compo.nUsedDirection = 0;
|
||||
|
||||
auto pItemName = getNameItem(compo.sName,nSource);
|
||||
if(pItemName){ //手动清空item数据
|
||||
int nVal = pItemName->data().toInt();
|
||||
pItemName->setData(QString::number(0)); //在公用模型中更新设备方向占用(重要)
|
||||
//pItemName->setData(QPoint(0,0),Qt::UserRole+2); //设置相对位置
|
||||
pItemName->setData(0,Qt::UserRole+5); //旋转
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(auto &routeInfo:data){
|
||||
routeInfo.lstOrder.clear();
|
||||
routeInfo.lstReverse.clear();
|
||||
for(auto &compo:routeInfo.lstCompo){
|
||||
compo.nUsedDirection = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for(auto &compoInfo:compos){
|
||||
compoInfo.nUsedDirection = 0;
|
||||
compoInfo.nRotate = 0;
|
||||
//compoInfo.deltaPos = QPoint(0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool hasMain = false;
|
||||
for(auto& route:mapRoute){
|
||||
if(route.bMainRoute == true){
|
||||
|
|
@ -959,20 +1096,32 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
|||
}
|
||||
int deltaY = nSegIndex*g_nVDiagramSpacing;
|
||||
|
||||
int rotate = 0;
|
||||
if(nMainDir == 4)
|
||||
rotate = 0;
|
||||
else
|
||||
rotate = 180;
|
||||
|
||||
if(saveToModel){
|
||||
auto pItemName = getNameItem(maoCompo[i].sName,nSource);
|
||||
if(pItemName){
|
||||
int nVal = pItemName->data().toInt();
|
||||
pItemName->setData(QString::number(nVal |= nDir)); //在公用模型中更新设备方向占用(重要)
|
||||
pItemName->setData(QPoint(0,deltaY),Qt::UserRole+2); //设置相对位置
|
||||
if(nMainDir == 4){
|
||||
maoCompo[i].nRotate = 0;
|
||||
pItemName->setData(0,Qt::UserRole+5);
|
||||
maoCompo[i].nRotate = rotate;
|
||||
pItemName->setData(rotate,Qt::UserRole+5);
|
||||
}
|
||||
}
|
||||
else{
|
||||
maoCompo[i].nRotate = 180;
|
||||
pItemName->setData(180,Qt::UserRole+5);
|
||||
if(compos.contains(maoCompo[i].sName)){
|
||||
auto &compInfo = compos[maoCompo[i].sName];
|
||||
compInfo.nUsedDirection |= nDir;
|
||||
compInfo.deltaPos = QPoint(0,deltaY);
|
||||
maoCompo[i].nRotate = rotate;
|
||||
compInfo.nRotate = rotate;
|
||||
}
|
||||
}
|
||||
|
||||
if(nMainDir == 8)
|
||||
nSegIndex -= 1;
|
||||
else
|
||||
|
|
@ -985,6 +1134,7 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
|||
}
|
||||
|
||||
if(!route.lstCompo.isEmpty()){ //拆分线路为以节点为首
|
||||
if(saveToModel){
|
||||
auto pItemFirst = getNameItem(route.lstCompo.first().sName,nSource);
|
||||
int nFirstVal = pItemFirst->data().toInt();
|
||||
auto pItemLast = getNameItem(route.lstCompo.last().sName,nSource);
|
||||
|
|
@ -1019,12 +1169,52 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
|||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(compos.contains(route.lstCompo.first().sName) && compos.contains(route.lstCompo.last().sName)){
|
||||
auto compoFirst = compos[route.lstCompo.first().sName];
|
||||
int nFirstVal = compoFirst.nUsedDirection;
|
||||
auto compoLast = compos[route.lstCompo.last().sName];
|
||||
int nLastVal = compoLast.nUsedDirection;
|
||||
|
||||
if(nFirstVal != 0){ //首位为节点
|
||||
route.lstOrder = route.lstCompo;
|
||||
}
|
||||
else if(nLastVal != 0){ //末位为节点
|
||||
for (auto it = route.lstCompo.rbegin(); it != route.lstCompo.rend(); ++it) {
|
||||
route.lstReverse.append(*it);
|
||||
}
|
||||
}
|
||||
else{ //节点在中间
|
||||
int nIndex = 0;
|
||||
for(int i = 0;i < route.lstCompo.size();++i){
|
||||
if(compos.contains(route.lstCompo[i].sName)){
|
||||
auto compo = compos[route.lstCompo[i].sName];
|
||||
int nVal = compo.nUsedDirection;
|
||||
if(nVal != 0){
|
||||
nIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = nIndex;i >= 0;--i){
|
||||
route.lstReverse.append(route.lstCompo[i]);
|
||||
}
|
||||
|
||||
for(int i = nIndex;i < route.lstCompo.size();++i){
|
||||
route.lstOrder.append(route.lstCompo[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int nOrderFirstDeltaY = 0; //首节点y偏移量(假设后续节点与头节点水平)
|
||||
int nXOrderIndex = 1; //横向计数
|
||||
int nOrderPolarity = 1; //方向 1右 -1左
|
||||
if(route.lstOrder.size() > 1){
|
||||
for(int i = 0;i < route.lstOrder.size()-1;++i){ //遍历以节点为首的队列
|
||||
if(saveToModel){
|
||||
auto pItem = getNameItem(route.lstOrder[i].sName,nSource);
|
||||
int nVal = pItem->data().toInt();
|
||||
QPoint deltaP = pItem->data(Qt::UserRole+2).toPoint();
|
||||
|
|
@ -1103,6 +1293,89 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
|||
pNextItem->setData(QPoint(deltaX,nOrderFirstDeltaY),Qt::UserRole + 2);
|
||||
nXOrderIndex += 1;
|
||||
}
|
||||
else{
|
||||
if(compos.contains(route.lstOrder[i].sName) && compos.contains(route.lstOrder[i+1].sName)){
|
||||
auto &compo = compos[route.lstOrder[i].sName];
|
||||
auto &compoNext = compos[route.lstOrder[i+1].sName];
|
||||
int nVal = compo.nUsedDirection;
|
||||
QPoint deltaP = compo.deltaPos;
|
||||
nOrderFirstDeltaY = deltaP.y();
|
||||
int nNextVal = compoNext.nUsedDirection;
|
||||
|
||||
if(i == 0){ //首节点
|
||||
if(((nVal & 2) == 1) && ((nVal & 1) == 1)){
|
||||
qDebug()<<QString("point %1 full of connection").arg(route.lstOrder[i].sName);
|
||||
}
|
||||
else if((nVal & 2) == 1){
|
||||
//左被占用,右空
|
||||
compo.nUsedDirection |= 1;
|
||||
compoNext.nUsedDirection |= 2; //同时连接下个点的一侧占用
|
||||
nOrderPolarity = 1;
|
||||
route.lstOrder[i+1].nRotate = -90;
|
||||
compoNext.nRotate = -90;
|
||||
}
|
||||
else if((nVal & 1) == 1){
|
||||
//右被占用,左空
|
||||
compo.nUsedDirection |= 2;
|
||||
compoNext.nUsedDirection |= 1;
|
||||
nOrderPolarity = -1;
|
||||
route.lstOrder[i+1].nRotate = 90;
|
||||
compoNext.nRotate = 90;
|
||||
}
|
||||
else{ //左右都没被占,放到倾向位置
|
||||
compo.nUsedDirection |= nSubDir;
|
||||
compoNext.nUsedDirection |= 3-nSubDir;
|
||||
if(nSubDir == 1){
|
||||
nOrderPolarity = 1;
|
||||
route.lstOrder[i+1].nRotate = -90;
|
||||
compoNext.nRotate = -90;
|
||||
}
|
||||
else if(nSubDir == 2){
|
||||
nOrderPolarity = -1;
|
||||
route.lstOrder[i+1].nRotate = 90;
|
||||
compoNext.nRotate = 90;
|
||||
}
|
||||
}
|
||||
int deltaX = nXOrderIndex*nOrderPolarity*g_nHDiagramSpacing;
|
||||
compoNext.deltaPos = QPoint(deltaX,nOrderFirstDeltaY);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(((nVal & 2) == 1) && ((nVal & 1) == 1)){
|
||||
qDebug()<<QString("point %1 full of connection").arg(route.lstOrder[i].sName);
|
||||
}
|
||||
else if((nVal & 2) == 1){
|
||||
//左被占用,右空
|
||||
compo.nUsedDirection |= 1;
|
||||
compoNext.nUsedDirection |= 2; //同时连接下个点的一侧占用
|
||||
route.lstOrder[i+1].nRotate = -90;
|
||||
compoNext.nRotate = -90;
|
||||
}
|
||||
else if((nVal & 1) == 1){
|
||||
//右被占用,左空
|
||||
compo.nUsedDirection |= 2;
|
||||
compoNext.nUsedDirection |= 1;
|
||||
route.lstOrder[i+1].nRotate = 90;
|
||||
compoNext.nRotate = 90;
|
||||
}
|
||||
else{ //左右都没被占,放到设定位置
|
||||
compo.nUsedDirection |= nSubDir;
|
||||
compoNext.nUsedDirection |= 3-nSubDir;
|
||||
if(nSubDir == 1){
|
||||
route.lstOrder[i+1].nRotate = -90;
|
||||
compoNext.nRotate = -90;
|
||||
}
|
||||
else if(nSubDir == 2){
|
||||
route.lstOrder[i+1].nRotate = 90;
|
||||
compoNext.nRotate = 90;
|
||||
}
|
||||
}
|
||||
int deltaX = nXOrderIndex*nOrderPolarity*g_nHDiagramSpacing;
|
||||
compoNext.deltaPos = QPoint(deltaX,nOrderFirstDeltaY);
|
||||
nXOrderIndex += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int nReverseFirstDeltaY = 0; //首节点y偏移量(假设后续节点与头节点水平)
|
||||
|
|
@ -1110,6 +1383,7 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
|||
int nReversePolarity = 1; //方向 1右 -1左
|
||||
if(route.lstReverse.size() > 1){
|
||||
for(int i = 0;i < route.lstReverse.size()-1;++i){ //遍历以节点为首的队列
|
||||
if(saveToModel){
|
||||
auto pItem = getNameItem(route.lstReverse[i].sName,nSource);
|
||||
int nVal = pItem->data().toInt();
|
||||
QPoint deltaP = pItem->data(Qt::UserRole+2).toPoint();
|
||||
|
|
@ -1190,6 +1464,89 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
|||
pNextItem->setData(QPoint(deltaX,nReverseFirstDeltaY),Qt::UserRole + 2);
|
||||
nXReverseIndex += 1;
|
||||
}
|
||||
else{
|
||||
if(compos.contains(route.lstReverse[i].sName) && compos.contains(route.lstReverse[i+1].sName)){
|
||||
auto &compo = compos[route.lstReverse[i].sName];
|
||||
auto &compoNext = compos[route.lstReverse[i+1].sName];
|
||||
int nVal = compo.nUsedDirection;
|
||||
QPoint deltaP = compo.deltaPos;
|
||||
nReverseFirstDeltaY = deltaP.y();
|
||||
int nNextVal = compoNext.nUsedDirection;
|
||||
|
||||
if(i == 0){ //首节点
|
||||
if(((nVal & 2) == 1) && ((nVal & 1) == 1)){
|
||||
qDebug()<<QString("point %1 full of connection").arg(route.lstReverse[i].sName);
|
||||
}
|
||||
else if((nVal & 2) == 1){
|
||||
//左被占用,右空
|
||||
compo.nUsedDirection |= 1;
|
||||
compoNext.nUsedDirection |= 2; //同时连接下个点的一侧占用
|
||||
nReversePolarity = 1;
|
||||
route.lstReverse[i+1].nRotate = -90;
|
||||
compoNext.nRotate = -90;
|
||||
}
|
||||
else if((nVal & 1) == 1){
|
||||
//右被占用,左空
|
||||
compo.nUsedDirection |= 2;
|
||||
compoNext.nUsedDirection |= 1;
|
||||
nReversePolarity = -1;
|
||||
route.lstReverse[i+1].nRotate = 90;
|
||||
compoNext.nRotate = 90;
|
||||
}
|
||||
else{ //左右都没被占,放到倾向位置
|
||||
compo.nUsedDirection |= nSubDir;
|
||||
compoNext.nUsedDirection |= 3-nSubDir;
|
||||
if(nSubDir == 1){
|
||||
nReversePolarity = 1;
|
||||
route.lstReverse[i+1].nRotate = -90;
|
||||
compoNext.nRotate = -90;
|
||||
}
|
||||
else if(nSubDir == 2){
|
||||
nReversePolarity = -1;
|
||||
route.lstReverse[i+1].nRotate = 90;
|
||||
compoNext.nRotate = 90;
|
||||
}
|
||||
}
|
||||
int deltaX = nXReverseIndex*nReversePolarity*g_nHDiagramSpacing;
|
||||
compoNext.deltaPos = QPoint(deltaX,nOrderFirstDeltaY);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(((nVal & 2) == 1) && ((nVal & 1) == 1)){
|
||||
qDebug()<<QString("point %1 full of connection").arg(route.lstReverse[i].sName);
|
||||
}
|
||||
else if((nVal & 2) == 1){
|
||||
//左被占用,右空
|
||||
compo.nUsedDirection |= 1;
|
||||
compoNext.nUsedDirection |= 2; //同时连接下个点的一侧占用
|
||||
route.lstReverse[i+1].nRotate = -90;
|
||||
compoNext.nRotate = -90;
|
||||
}
|
||||
else if((nVal & 1) == 1){
|
||||
//右被占用,左空
|
||||
compo.nUsedDirection |= 2;
|
||||
compoNext.nUsedDirection |= 1;
|
||||
route.lstReverse[i+1].nRotate = 90;
|
||||
compoNext.nRotate = 90;
|
||||
}
|
||||
else{ //左右都没被占,放到设定位置
|
||||
compo.nUsedDirection |= nSubDir;
|
||||
compoNext.nUsedDirection |= 3-nSubDir;
|
||||
if(nSubDir == 1){
|
||||
route.lstReverse[i+1].nRotate = -90;
|
||||
compoNext.nRotate = -90;
|
||||
}
|
||||
else if(nSubDir == 2){
|
||||
route.lstReverse[i+1].nRotate = 90;
|
||||
compoNext.nRotate = 90;
|
||||
}
|
||||
}
|
||||
int deltaX = nXReverseIndex*nReversePolarity*g_nHDiagramSpacing;
|
||||
compoNext.deltaPos = QPoint(deltaX,nOrderFirstDeltaY);
|
||||
nXReverseIndex += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1216,21 +1573,32 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
|||
nDir = 3;
|
||||
}
|
||||
int deltaX = nSegIndex*g_nHDiagramSpacing;
|
||||
int rotate = 0;
|
||||
if(nMainDir == 1)
|
||||
rotate = -90;
|
||||
else
|
||||
rotate = 90;
|
||||
|
||||
if(saveToModel){
|
||||
auto pItemName = getNameItem(maoCompo[i].sName,nSource);
|
||||
if(pItemName){
|
||||
int nVal = pItemName->data().toInt();
|
||||
pItemName->setData(QString::number(nVal |= nDir)); //在公用模型中更新设备方向占用(重要)
|
||||
pItemName->setData(QPoint(deltaX,0),Qt::UserRole+2); //设置相对位置
|
||||
if(nMainDir == 1){
|
||||
maoCompo[i].nRotate = -90;
|
||||
pItemName->setData(-90,Qt::UserRole+5); //转至水平
|
||||
maoCompo[i].nRotate = rotate;
|
||||
pItemName->setData(rotate,Qt::UserRole+5);
|
||||
}
|
||||
}
|
||||
else{
|
||||
maoCompo[i].nRotate = 90;
|
||||
pItemName->setData(90,Qt::UserRole+5);
|
||||
if(compos.contains(maoCompo[i].sName)){
|
||||
auto &compInfo = compos[maoCompo[i].sName];
|
||||
compInfo.nUsedDirection |= nDir;
|
||||
compInfo.deltaPos = QPoint(deltaX,0);
|
||||
maoCompo[i].nRotate = rotate;
|
||||
compInfo.nRotate = rotate;
|
||||
}
|
||||
}
|
||||
|
||||
if(nMainDir == 2)
|
||||
nSegIndex -= 1;
|
||||
else
|
||||
|
|
@ -1243,6 +1611,40 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
|||
}
|
||||
|
||||
if(!route.lstCompo.isEmpty()){ //拆分线路为以节点为首
|
||||
/*auto pItemFirst = getNameItem(route.lstCompo.first().sName,nSource);
|
||||
int nFirstVal = pItemFirst->data().toInt();
|
||||
auto pItemLast = getNameItem(route.lstCompo.last().sName,nSource);
|
||||
int nLastVal = pItemLast->data().toInt();
|
||||
if(nFirstVal != 0){ //首位为节点
|
||||
route.lstOrder = route.lstCompo;
|
||||
}
|
||||
else if(nLastVal != 0){ //末位为节点
|
||||
for (auto it = route.lstCompo.rbegin(); it != route.lstCompo.rend(); ++it) {
|
||||
route.lstReverse.append(*it);
|
||||
}
|
||||
}
|
||||
else{ //节点在中间
|
||||
int nIndex = 0;
|
||||
for(int i = 0;i < route.lstCompo.size();++i){
|
||||
auto pItem = getNameItem(route.lstCompo[i].sName,nSource);
|
||||
if(pItem){
|
||||
int nVal = pItem->data().toInt();
|
||||
if(nVal != 0){
|
||||
nIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = nIndex;i >= 0;--i){
|
||||
route.lstReverse.append(route.lstCompo[i]);
|
||||
}
|
||||
|
||||
for(int i = nIndex;i < route.lstCompo.size();++i){
|
||||
route.lstOrder.append(route.lstCompo[i]);
|
||||
}
|
||||
}*/
|
||||
if(saveToModel){
|
||||
auto pItemFirst = getNameItem(route.lstCompo.first().sName,nSource);
|
||||
int nFirstVal = pItemFirst->data().toInt();
|
||||
auto pItemLast = getNameItem(route.lstCompo.last().sName,nSource);
|
||||
|
|
@ -1277,12 +1679,52 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
|||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(compos.contains(route.lstCompo.first().sName) && compos.contains(route.lstCompo.last().sName)){
|
||||
auto compoFirst = compos[route.lstCompo.first().sName];
|
||||
int nFirstVal = compoFirst.nUsedDirection;
|
||||
auto compoLast = compos[route.lstCompo.last().sName];
|
||||
int nLastVal = compoLast.nUsedDirection;
|
||||
|
||||
if(nFirstVal != 0){ //首位为节点
|
||||
route.lstOrder = route.lstCompo;
|
||||
}
|
||||
else if(nLastVal != 0){ //末位为节点
|
||||
for (auto it = route.lstCompo.rbegin(); it != route.lstCompo.rend(); ++it) {
|
||||
route.lstReverse.append(*it);
|
||||
}
|
||||
}
|
||||
else{ //节点在中间
|
||||
int nIndex = 0;
|
||||
for(int i = 0;i < route.lstCompo.size();++i){
|
||||
if(compos.contains(route.lstCompo[i].sName)){
|
||||
auto compo = compos[route.lstCompo[i].sName];
|
||||
int nVal = compo.nUsedDirection;
|
||||
if(nVal != 0){
|
||||
nIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = nIndex;i >= 0;--i){
|
||||
route.lstReverse.append(route.lstCompo[i]);
|
||||
}
|
||||
|
||||
for(int i = nIndex;i < route.lstCompo.size();++i){
|
||||
route.lstOrder.append(route.lstCompo[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int nOrderFirstDeltaX = 0; //首节点x偏移量(假设后续节点与头节点水平相同,纵向分布)
|
||||
int nYOrderIndex = 1; //总向计数
|
||||
int nOrderPolarity = 1; //方向 1下 -1上
|
||||
if(route.lstOrder.size() > 1){
|
||||
for(int i = 0;i < route.lstOrder.size()-1;++i){ //遍历以节点为首的队列
|
||||
if(saveToModel){
|
||||
auto pItem = getNameItem(route.lstOrder[i].sName,nSource);
|
||||
int nVal = pItem->data().toInt();
|
||||
QPoint deltaP = pItem->data(Qt::UserRole+2).toPoint();
|
||||
|
|
@ -1361,6 +1803,87 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
|||
pNextItem->setData(QPoint(nOrderFirstDeltaX,deltaY),Qt::UserRole + 2);
|
||||
nYOrderIndex += 1;
|
||||
}
|
||||
else{
|
||||
if(compos.contains(route.lstOrder[i].sName) && compos.contains(route.lstOrder[i+1].sName)){
|
||||
auto &compo = compos[route.lstOrder[i].sName];
|
||||
auto &compoNext = compos[route.lstOrder[i+1].sName];
|
||||
int nVal = compo.nUsedDirection;
|
||||
QPoint deltaP = compo.deltaPos;
|
||||
nOrderFirstDeltaX = deltaP.x();
|
||||
int nNextVal = compoNext.nUsedDirection;
|
||||
|
||||
if(i == 0){ //首节点
|
||||
if(((nVal & 8) == 1) && ((nVal & 4) == 1)){
|
||||
qDebug()<<QString("point %1 full of connection").arg(route.lstOrder[i].sName);
|
||||
}
|
||||
else if((nVal & 8) == 1){
|
||||
//上被占用,下空
|
||||
compo.nUsedDirection |= 4;
|
||||
compoNext.nUsedDirection |= 8; //同时连接下个点的一侧占用
|
||||
nOrderPolarity = 1;
|
||||
route.lstOrder[i+1].nRotate = 0;
|
||||
compoNext.nRotate = 0;
|
||||
}
|
||||
else if((nVal & 4) == 1){
|
||||
//下被占用,上空
|
||||
compo.nUsedDirection |= 8;
|
||||
compoNext.nUsedDirection |= 4;
|
||||
nOrderPolarity = -1;
|
||||
route.lstOrder[i+1].nRotate = 180;
|
||||
compoNext.nRotate = 180;
|
||||
}
|
||||
else{ //上下都没占,放到设定位置
|
||||
compo.nUsedDirection |= nSubDir;
|
||||
compoNext.nUsedDirection |= 12-nSubDir;
|
||||
if(nSubDir == 4){
|
||||
nOrderPolarity = 1;
|
||||
route.lstOrder[i+1].nRotate = 0;
|
||||
compoNext.nRotate = 0;
|
||||
}
|
||||
else if(nSubDir == 8){
|
||||
nOrderPolarity = -1;
|
||||
route.lstOrder[i+1].nRotate = 180;
|
||||
compoNext.nRotate = 180;
|
||||
}
|
||||
}
|
||||
int deltaY = nYOrderIndex*nOrderPolarity*g_nVDiagramSpacing;
|
||||
compoNext.deltaPos = QPoint(nOrderFirstDeltaX,deltaY);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(((nVal & 8) == 1) && ((nVal & 4) == 1)){
|
||||
qDebug()<<QString("point %1 full of connection").arg(route.lstOrder[i].sName);
|
||||
}
|
||||
else if((nVal & 8) == 1){
|
||||
//上被占用,下空
|
||||
compo.nUsedDirection |= 4;
|
||||
compoNext.nUsedDirection |= 8; //同时连接下个点的一侧占用
|
||||
compoNext.nRotate = 0;
|
||||
}
|
||||
else if((nVal & 4) == 1){
|
||||
//下被占用,上空
|
||||
compo.nUsedDirection |= 8;
|
||||
compoNext.nUsedDirection |= 4;
|
||||
compoNext.nRotate = 180;
|
||||
}
|
||||
else{ //上下都没被占,放到设定位置
|
||||
compo.nUsedDirection |= nSubDir;
|
||||
compoNext.nUsedDirection |= 12-nSubDir;
|
||||
if(nSubDir == 4){
|
||||
route.lstOrder[i+1].nRotate = 0;
|
||||
compoNext.nRotate = 0;
|
||||
}
|
||||
else if(nSubDir == 8){
|
||||
route.lstOrder[i+1].nRotate = 180;
|
||||
compoNext.nRotate = 180;
|
||||
}
|
||||
}
|
||||
int deltaY = nYOrderIndex*nOrderPolarity*g_nVDiagramSpacing;
|
||||
compoNext.deltaPos = QPoint(nOrderFirstDeltaX,deltaY);
|
||||
nYOrderIndex += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int nReverseFirstDeltaX = 0; //首节点X偏移量(假设后续节点与头节点垂直分布)
|
||||
|
|
@ -1368,6 +1891,7 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
|||
int nReversePolarity = 1; //方向 1下 -1上
|
||||
if(route.lstReverse.size() > 1){
|
||||
for(int i = 0;i < route.lstReverse.size()-1;++i){ //遍历以节点为首的队列
|
||||
if(saveToModel){
|
||||
auto pItem = getNameItem(route.lstReverse[i].sName,nSource);
|
||||
int nVal = pItem->data().toInt();
|
||||
QPoint deltaP = pItem->data(Qt::UserRole+2).toPoint();
|
||||
|
|
@ -1433,8 +1957,8 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
|||
pNextItem->setData(180,Qt::UserRole+5);
|
||||
}
|
||||
else{ //上下都没被占,默认放到下边
|
||||
pItem->setData(QString::number(nVal | 4));
|
||||
pNextItem->setData(QString::number(nNextVal | 8));
|
||||
pItem->setData(QString::number(nVal | nSubDir));
|
||||
pNextItem->setData(QString::number(nNextVal | 12-nSubDir));
|
||||
if(nSubDir == 4){
|
||||
//nReversePolarity = 1;
|
||||
route.lstReverse[i+1].nRotate = 0;
|
||||
|
|
@ -1450,9 +1974,122 @@ void DiagramEditorModel::updateTarget(QMap<QString,DiagramEditorRouteInfo>& data
|
|||
pNextItem->setData(QPoint(nReverseFirstDeltaX,deltaY),Qt::UserRole + 2);
|
||||
nYReverseIndex += 1;
|
||||
}
|
||||
else{
|
||||
if(compos.contains(route.lstReverse[i].sName) && compos.contains(route.lstReverse[i+1].sName)){
|
||||
auto &compo = compos[route.lstReverse[i].sName];
|
||||
auto &compoNext = compos[route.lstReverse[i+1].sName];
|
||||
int nVal = compo.nUsedDirection;
|
||||
QPoint deltaP = compo.deltaPos;
|
||||
nReverseFirstDeltaX = deltaP.x();
|
||||
int nNextVal = compoNext.nUsedDirection;
|
||||
|
||||
if(i == 0){ //首节点
|
||||
if(((nVal & 8) == 1) && ((nVal & 4) == 1)){
|
||||
qDebug()<<QString("point %1 full of connection").arg(route.lstReverse[i].sName);
|
||||
}
|
||||
else if((nVal & 8) == 1){
|
||||
//上被占用,下空
|
||||
compo.nUsedDirection |= 4;
|
||||
compoNext.nUsedDirection |= 8; //同时连接下个点的一侧占用
|
||||
nReversePolarity = 1;
|
||||
route.lstReverse[i+1].nRotate = 0;
|
||||
compoNext.nRotate = 0;
|
||||
}
|
||||
else if((nVal & 1) == 4){
|
||||
//下被占用,上空
|
||||
compo.nUsedDirection |= 8;
|
||||
compoNext.nUsedDirection |= 4;
|
||||
nReversePolarity = -1;
|
||||
route.lstReverse[i+1].nRotate = 180;
|
||||
compoNext.nRotate = 180;
|
||||
}
|
||||
else{ //上下都没被占,放到设定位置
|
||||
compo.nUsedDirection |= nSubDir;
|
||||
compoNext.nUsedDirection |= 12-nSubDir;
|
||||
if(nSubDir == 4){
|
||||
nReversePolarity = 1;
|
||||
route.lstReverse[i+1].nRotate = 0;
|
||||
compoNext.nRotate = 0;
|
||||
}
|
||||
else if(nSubDir == 8){
|
||||
nReversePolarity = -1;
|
||||
route.lstReverse[i+1].nRotate = 180;
|
||||
compoNext.nRotate = 180;
|
||||
}
|
||||
}
|
||||
int deltaY = nYReverseIndex*nReversePolarity*g_nVDiagramSpacing;
|
||||
compoNext.deltaPos = QPoint(nReverseFirstDeltaX,deltaY);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(((nVal & 8) == 1) && ((nVal & 4) == 1)){
|
||||
qDebug()<<QString("point %1 full of connection").arg(route.lstOrder[i].sName);
|
||||
}
|
||||
else if((nVal & 8) == 1){
|
||||
//上被占用,下空
|
||||
compo.nUsedDirection |= 4;
|
||||
compoNext.nUsedDirection |= 8; //同时连接下个点的一侧占用
|
||||
route.lstReverse[i+1].nRotate = 0;
|
||||
compoNext.nRotate = 0;
|
||||
}
|
||||
else if((nVal & 4) == 1){
|
||||
//下被占用,上空
|
||||
compo.nUsedDirection |= 8;
|
||||
compoNext.nUsedDirection |= 4;
|
||||
route.lstReverse[i+1].nRotate = 180;
|
||||
compoNext.nRotate = 180;
|
||||
}
|
||||
else{ //上下都没被占,默认放到下边
|
||||
compo.nUsedDirection |= nSubDir;
|
||||
compoNext.nUsedDirection |= 12-nSubDir;
|
||||
if(nSubDir == 4){
|
||||
//nReversePolarity = 1;
|
||||
route.lstReverse[i+1].nRotate = 0;
|
||||
compoNext.nRotate = 0;
|
||||
}
|
||||
else if(nSubDir == 8){
|
||||
//nReversePolarity = -1;
|
||||
route.lstReverse[i+1].nRotate = 180;
|
||||
compoNext.nRotate = 180;
|
||||
}
|
||||
}
|
||||
int deltaY = nYReverseIndex*nReversePolarity*g_nVDiagramSpacing;
|
||||
compoNext.deltaPos = QPoint(nReverseFirstDeltaX,deltaY);
|
||||
nYReverseIndex += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!saveToModel){ //保存到模型时由scene获取recBounding
|
||||
|
||||
QList<QPointF> points;
|
||||
for(auto &info:compos){
|
||||
if(info.nUsedDirection != 0){ //该元件被使用
|
||||
QPointF pDelta = info.deltaPos; //todo:考虑元件宽度
|
||||
points.append(pDelta);
|
||||
}
|
||||
}
|
||||
|
||||
if(!points.empty()){
|
||||
qreal minX = points[0].x();
|
||||
qreal maxX = points[0].x();
|
||||
qreal minY = points[0].y();
|
||||
qreal maxY = points[0].y();
|
||||
|
||||
for (const QPointF& point : points) {
|
||||
minX = qMin(minX, point.x());
|
||||
maxX = qMax(maxX, point.x());
|
||||
minY = qMin(minY, point.y());
|
||||
maxY = qMax(maxY, point.y());
|
||||
}
|
||||
|
||||
recBounding = QRectF(QPointF(minX, minY), QPointF(maxX, maxY));
|
||||
}
|
||||
}
|
||||
return recBounding;
|
||||
}
|
||||
|
||||
void DiagramEditorModel::bulidAndLinkComponent(QList<DiagramEditorComponentInfo> lst,QMap<QString,DiagramEditorComponentInfo> components)
|
||||
|
|
@ -1467,6 +2104,8 @@ void DiagramEditorModel::bulidAndLinkComponent(QList<DiagramEditorComponentInfo>
|
|||
GraphicsBaseModelItem* p2 = _previewItem.value(info2.uid);
|
||||
auto pLineData = TopologyManager::instance().ifConnection(info1.uid.toString(),info2.uid.toString(),ModelFunctionType::EditorModel); //判断两个item是否有连接
|
||||
if(pLineData != nullptr){
|
||||
if(_previewItem.contains(QUuid(pLineData->id()))) //已绘制
|
||||
continue;
|
||||
if(!_previewItem.contains(QUuid(pLineData->id()))){ //connectdata已存在,item未绘制
|
||||
auto pLine = generateLine(QUuid(pLineData->id()),"",1); //重新绘制
|
||||
if(pLine)
|
||||
|
|
|
|||
|
|
@ -891,7 +891,7 @@ bool FixedPortsModel::addBaseItem(QUuid uuid,GraphicsBaseModelItem* pItem)
|
|||
}
|
||||
}
|
||||
|
||||
BaseModelProperty* FixedPortsModel::addBaseNodeData(QUuid id,int type,QString name,QString metaName)
|
||||
BaseModelProperty* FixedPortsModel::addBaseNodeData(QUuid id,int type,QString name,QString metaName,QString bay)
|
||||
{
|
||||
BaseModelProperty* pData = BasePropertyManager::instance().findBaseEntityData(id); //已存在不不创建
|
||||
if(pData != nullptr)
|
||||
|
|
@ -906,6 +906,8 @@ BaseModelProperty* FixedPortsModel::addBaseNodeData(QUuid id,int type,QString na
|
|||
item->setType(type);
|
||||
item->setTag(name);
|
||||
item->setName(name);
|
||||
if(!bay.isEmpty())
|
||||
item->setBay(bay);
|
||||
BasePropertyManager::instance().insertBaseEntityData(id,item);
|
||||
}
|
||||
return item;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,20 @@ GraphicsBaseItem::GraphicsBaseItem(QGraphicsItem *parent)
|
|||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
GraphicsBaseItem::GraphicsBaseItem(const GraphicsBaseItem& obj)
|
||||
:AbstractShapeType<QGraphicsItem>(obj)
|
||||
,_property(nullptr)
|
||||
,_pEntity(nullptr)
|
||||
{
|
||||
m_lastPoint = obj.m_lastPoint;
|
||||
m_touched = obj.m_touched;
|
||||
m_boundingRect_selected = obj.m_boundingRect_selected;
|
||||
|
||||
for(auto& port:obj.m_mapPort){
|
||||
addPort(p_movable,port->pos(),port->getId(),port->getType(),port->portPos());
|
||||
}
|
||||
}
|
||||
|
||||
GraphicsBaseItem::~GraphicsBaseItem()
|
||||
{
|
||||
foreach (int key, m_vecHanle.keys())
|
||||
|
|
@ -71,6 +85,14 @@ int GraphicsBaseItem::addPort(PortState typ,QPointF vec,QString id,HandleType hT
|
|||
return ntagId;
|
||||
}
|
||||
|
||||
void GraphicsBaseItem::movePort(QString id,QPointF vec)
|
||||
{
|
||||
if(m_mapPort.contains(id)){
|
||||
auto pPort = m_mapPort.value(id);
|
||||
pPort->setPos(vec);
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsBaseItem::setEntity(PowerEntity* pEntity)
|
||||
{
|
||||
_pEntity = pEntity;
|
||||
|
|
@ -190,6 +212,13 @@ GraphicsBaseModelItem::GraphicsBaseModelItem(QGraphicsItem *parent)
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
GraphicsBaseModelItem::GraphicsBaseModelItem(const GraphicsBaseModelItem& obj)
|
||||
:GraphicsBaseItem(obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GraphicsBaseModelItem::~GraphicsBaseModelItem()
|
||||
{
|
||||
|
||||
|
|
@ -197,12 +226,14 @@ GraphicsBaseModelItem::~GraphicsBaseModelItem()
|
|||
|
||||
void GraphicsBaseModelItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
if(_stateMask){
|
||||
if(getProperty()->modelName().isEmpty())
|
||||
{
|
||||
painter->setPen(QColor(255,0,0,80));
|
||||
painter->setBrush(QColor(255,0,0,80));
|
||||
painter->drawRoundedRect(m_boundingRect,10,10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QVariant GraphicsBaseModelItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,13 @@
|
|||
PowerConnection::PowerConnection(const QString& uuid,const QString& fromTerminal, const QString& toTerminal,const QString& fromId,const QString& toId, QObject* parent)
|
||||
: QObject(parent),m_uuid(uuid), m_fromTerminal(fromTerminal), m_toTerminal(toTerminal),m_fromComponent(fromId),m_toComponent(toId) {}
|
||||
|
||||
|
||||
PowerConnection* PowerConnection::clone()
|
||||
{
|
||||
PowerConnection* newCon = new PowerConnection(m_uuid,m_fromTerminal,m_toTerminal,m_fromComponent,m_toComponent);
|
||||
return newCon;
|
||||
}
|
||||
|
||||
QJsonObject PowerConnection::toJson() const {
|
||||
QJsonObject obj;
|
||||
obj["id"] = m_uuid;
|
||||
|
|
|
|||
|
|
@ -281,6 +281,18 @@ void TopologyManager::clearGlobalBlockData(const QString& sName)
|
|||
}
|
||||
}
|
||||
|
||||
void TopologyManager::cloneEditorToBase()
|
||||
{
|
||||
for(auto& editorEntity:m_editorEntities){
|
||||
editorEntity->clone();
|
||||
}
|
||||
|
||||
for(auto& con:m_editorConnections){
|
||||
if(connection(con->id(),ModelFunctionType::BaseModel) == nullptr)
|
||||
createConnection(con->id(),con->fromTerminalId(),con->toTerminalId(),con->fromComponent(),con->toComponent(),ModelFunctionType::BaseModel);
|
||||
}
|
||||
}
|
||||
|
||||
PowerConnection* TopologyManager::createConnection(const QString& connId,const QString& fromTerId, const QString& toTerId,const QString& fromId,const QString& toId,ModelFunctionType funType)
|
||||
{
|
||||
PowerConnection* conn = nullptr;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,222 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>confirmEditorDlg</class>
|
||||
<widget class="QDialog" name="confirmEditorDlg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>390</width>
|
||||
<height>276</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Microsoft YaHei UI</family>
|
||||
<pointsize>12</pointsize>
|
||||
<italic>false</italic>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(255, 255, 255);
|
||||
color: rgb(0, 0, 0);
|
||||
font: 12pt "Microsoft YaHei UI";</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="4">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(193, 193, 193);</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Microsoft YaHei UI</family>
|
||||
<pointsize>12</pointsize>
|
||||
<italic>false</italic>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(0, 0, 0);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>生成接线</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>323</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>67</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>106</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="verticalSpacing">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>用户签名:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="le_time">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_name">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>上次修改:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>105</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>78</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_ok">
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_cancel">
|
||||
<property name="text">
|
||||
<string>取消</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Loading…
Reference in New Issue