add project model ct setting
This commit is contained in:
parent
5acf00d037
commit
8e968e7845
|
|
@ -36,7 +36,20 @@ enum GraphicsItemType
|
||||||
GIT_itemRect = QGraphicsItem::UserType + 51,
|
GIT_itemRect = QGraphicsItem::UserType + 51,
|
||||||
GIT_itemTri = QGraphicsItem::UserType + 52,
|
GIT_itemTri = QGraphicsItem::UserType + 52,
|
||||||
GIT_link= QGraphicsItem::UserType + 53,
|
GIT_link= QGraphicsItem::UserType + 53,
|
||||||
GIT_bay= QGraphicsItem::UserType + 54, //间隔
|
GIT_ctItem= QGraphicsItem::UserType + 54,
|
||||||
|
GIT_ctGroup= QGraphicsItem::UserType + 55,
|
||||||
|
GIT_ES= QGraphicsItem::UserType + 56,
|
||||||
|
GIT_DS= QGraphicsItem::UserType + 57,
|
||||||
|
GIT_FES= QGraphicsItem::UserType + 58,
|
||||||
|
GIT_DTEDS= QGraphicsItem::UserType + 59,
|
||||||
|
GIT_PI= QGraphicsItem::UserType + 60,
|
||||||
|
GIT_LA= QGraphicsItem::UserType + 61,
|
||||||
|
GIT_cableTer= QGraphicsItem::UserType + 62,
|
||||||
|
GIT_cableEnd= QGraphicsItem::UserType + 63,
|
||||||
|
GIT_2wTransformer= QGraphicsItem::UserType + 64,
|
||||||
|
GIT_3wTransformer= QGraphicsItem::UserType + 65,
|
||||||
|
GIT_node= QGraphicsItem::UserType + 79,
|
||||||
|
GIT_bay= QGraphicsItem::UserType + 80, //间隔
|
||||||
//======================================
|
//======================================
|
||||||
GIT_baseNode = QGraphicsItem::UserType + 199,
|
GIT_baseNode = QGraphicsItem::UserType + 199,
|
||||||
GIT_baseBus = QGraphicsItem::UserType + 200,
|
GIT_baseBus = QGraphicsItem::UserType + 200,
|
||||||
|
|
@ -44,11 +57,16 @@ enum GraphicsItemType
|
||||||
GIT_baseBreaker = QGraphicsItem::UserType + 202,
|
GIT_baseBreaker = QGraphicsItem::UserType + 202,
|
||||||
GIT_baseCT = QGraphicsItem::UserType + 203,
|
GIT_baseCT = QGraphicsItem::UserType + 203,
|
||||||
GIT_basePT = QGraphicsItem::UserType + 204,
|
GIT_basePT = QGraphicsItem::UserType + 204,
|
||||||
GIT_baseDS = QGraphicsItem::UserType + 205,
|
GIT_baseDS = QGraphicsItem::UserType + 205, //隔离开关
|
||||||
GIT_baseES = QGraphicsItem::UserType + 206,
|
GIT_baseES = QGraphicsItem::UserType + 206, //接地开关
|
||||||
GIT_basePI = QGraphicsItem::UserType + 207, //带电指示器
|
GIT_baseFES = QGraphicsItem::UserType + 207, //快速接地
|
||||||
GIT_base2wTransformer = QGraphicsItem::UserType + 208, //两绕阻变压器
|
GIT_baseDTEDS = QGraphicsItem::UserType + 208, //双掷接地隔离开关
|
||||||
GIT_base3wTransformer = QGraphicsItem::UserType + 209, //三绕组变压器
|
GIT_basePI = QGraphicsItem::UserType + 209, //带电指示器
|
||||||
|
GIT_baseLightningArrester = QGraphicsItem::UserType + 210, //避雷器
|
||||||
|
GIT_baseCableTer = QGraphicsItem::UserType + 211, //电缆出线套筒
|
||||||
|
GIT_baseCableEnd = QGraphicsItem::UserType + 212,
|
||||||
|
GIT_base2wTransformer = QGraphicsItem::UserType + 213, //两绕阻变压器
|
||||||
|
GIT_base3wTransformer = QGraphicsItem::UserType + 214, //三绕组变压器
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AbstractItemType //工程模关联的对象类型
|
enum AbstractItemType //工程模关联的对象类型
|
||||||
|
|
@ -844,6 +862,12 @@ struct bayInfo
|
||||||
QList<QUuid> components;
|
QList<QUuid> components;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct itemPageInfo //page中保存的item信息(大小,位置etc)
|
||||||
|
{
|
||||||
|
QPointF pos;
|
||||||
|
double dWidth = 0.0;
|
||||||
|
double dHeight = 0.0;
|
||||||
|
};
|
||||||
|
|
||||||
/*struct busStability
|
/*struct busStability
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,5 @@ const QMap<AbstractItemType,GraphicsItemType> linkType = {
|
||||||
};
|
};
|
||||||
//类型转换
|
//类型转换
|
||||||
const QMap<int,GraphicsItemType> typeToProGraphic = {
|
const QMap<int,GraphicsItemType> typeToProGraphic = {
|
||||||
{1,GIT_bus},{3,GIT_itemRect},{8,GIT_link}
|
{0,GIT_node},{1,GIT_bus},{3,GIT_itemRect},{4,GIT_ctGroup},{6,GIT_ES},{7,GIT_FES},{8,GIT_link},{9,GIT_DS},{10,GIT_DTEDS},{11,GIT_PI},{12,GIT_LA},{13,GIT_cableTer},{14,GIT_cableEnd},{15,GIT_2wTransformer},{16,GIT_3wTransformer}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,20 @@ set(DIAGRAMCAVAS_HEADER_FILES
|
||||||
include/graphicsItem/itemControlHandle.h
|
include/graphicsItem/itemControlHandle.h
|
||||||
include/graphicsItem/itemPort.h
|
include/graphicsItem/itemPort.h
|
||||||
include/graphicsItem/electricBayItem.h
|
include/graphicsItem/electricBayItem.h
|
||||||
|
include/graphicsItem/electricPortItem.h
|
||||||
|
include/graphicsItem/electricSvgGroup.h
|
||||||
|
include/graphicsItem/electricSvgGroupCT.h
|
||||||
|
include/graphicsItem/electricSvgItemCT.h
|
||||||
|
include/graphicsItem/electricSvgItemES.h
|
||||||
|
include/graphicsItem/electricSvgItemDS.h
|
||||||
|
include/graphicsItem/electricSvgItemFES.h
|
||||||
|
include/graphicsItem/electricSvgItemDTEDS.h
|
||||||
|
include/graphicsItem/electricSvgItemPI.h
|
||||||
|
include/graphicsItem/electricSvgItemLA.h
|
||||||
|
include/graphicsItem/electricSvgItemCableTer.h
|
||||||
|
include/graphicsItem/electricSvgItemCableEnd.h
|
||||||
|
include/graphicsItem/electricSvgItem2wTransformer.h
|
||||||
|
include/graphicsItem/electricSvgItem3wTransformer.h
|
||||||
include/baseModelItem/electricBaseModelSvgItem.h
|
include/baseModelItem/electricBaseModelSvgItem.h
|
||||||
include/baseModelItem/electricBaseModelLineItem.h
|
include/baseModelItem/electricBaseModelLineItem.h
|
||||||
include/baseModelItem/electricBaseModelSvgBus.h
|
include/baseModelItem/electricBaseModelSvgBus.h
|
||||||
|
|
@ -154,6 +168,20 @@ set(DIAGRAMCAVAS_SOURCE_FILES
|
||||||
source/graphicsItem/itemControlHandle.cpp
|
source/graphicsItem/itemControlHandle.cpp
|
||||||
source/graphicsItem/itemPort.cpp
|
source/graphicsItem/itemPort.cpp
|
||||||
source/graphicsItem/electricBayItem.cpp
|
source/graphicsItem/electricBayItem.cpp
|
||||||
|
source/graphicsItem/electricPortItem.cpp
|
||||||
|
source/graphicsItem/electricSvgGroup.cpp
|
||||||
|
source/graphicsItem/electricSvgGroupCT.cpp
|
||||||
|
source/graphicsItem/electricSvgItemCT.cpp
|
||||||
|
source/graphicsItem/electricSvgItemES.cpp
|
||||||
|
source/graphicsItem/electricSvgItemDS.cpp
|
||||||
|
source/graphicsItem/electricSvgItemFES.cpp
|
||||||
|
source/graphicsItem/electricSvgItemDTEDS.cpp
|
||||||
|
source/graphicsItem/electricSvgItemPI.cpp
|
||||||
|
source/graphicsItem/electricSvgItemLA.cpp
|
||||||
|
source/graphicsItem/electricSvgItemCableTer.cpp
|
||||||
|
source/graphicsItem/electricSvgItemCableEnd.cpp
|
||||||
|
source/graphicsItem/electricSvgItem2wTransformer.cpp
|
||||||
|
source/graphicsItem/electricSvgItem3wTransformer.cpp
|
||||||
source/baseModelItem/electricBaseModelSvgItem.cpp
|
source/baseModelItem/electricBaseModelSvgItem.cpp
|
||||||
source/baseModelItem/electricBaseModelLineItem.cpp
|
source/baseModelItem/electricBaseModelLineItem.cpp
|
||||||
source/baseModelItem/electricBaseModelSvgBus.cpp
|
source/baseModelItem/electricBaseModelSvgBus.cpp
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ public:
|
||||||
void saveNodes(int pageId); //保存到数据库
|
void saveNodes(int pageId); //保存到数据库
|
||||||
|
|
||||||
DesignerScene* getScene() {return m_pGraphicsScene;}
|
DesignerScene* getScene() {return m_pGraphicsScene;}
|
||||||
|
DesignerView* getView() {return m_pGraphicsView;}
|
||||||
signals:
|
signals:
|
||||||
void panelDelete(const QString&);
|
void panelDelete(const QString&);
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ class GraphicsNonStandardItem;
|
||||||
class BayProperty;
|
class BayProperty;
|
||||||
class BayManagerDlg;
|
class BayManagerDlg;
|
||||||
class ModelProperty;
|
class ModelProperty;
|
||||||
|
struct itemPageInfo;
|
||||||
|
|
||||||
class FixedPortsModel : public BaseModel, public Serializable
|
class FixedPortsModel : public BaseModel, public Serializable
|
||||||
{
|
{
|
||||||
|
|
@ -36,11 +37,11 @@ public:
|
||||||
FixedPortsModel(PowerEntity*);
|
FixedPortsModel(PowerEntity*);
|
||||||
~FixedPortsModel();
|
~FixedPortsModel();
|
||||||
public:
|
public:
|
||||||
QMap<QUuid,QPointF> allNodePos() const;
|
QMap<QUuid,itemPageInfo> allNodePos() const;
|
||||||
QVector<ModelProperty*> allConnectionProperty();
|
QVector<ModelProperty*> allConnectionProperty();
|
||||||
QMap<QUuid,GraphicsProjectModelItem*>& allItems();
|
QMap<QUuid,GraphicsProjectModelItem*>& allItems();
|
||||||
bool addNodeItem(QUuid uuid,GraphicsProjectModelItem*);
|
bool addNodeItem(QUuid uuid,GraphicsProjectModelItem*);
|
||||||
void addNodeItem(QUuid id,QPointF pos);
|
void addNodeItem(QUuid id,QPointF pos,double width = 0,double height = 0);
|
||||||
GraphicsProjectModelItem* nodeItem(QUuid uuid);
|
GraphicsProjectModelItem* nodeItem(QUuid uuid);
|
||||||
BaseProperty* addNodeData(QUuid id,int type,QString name,QString modelName); //对应component数据,一个data可对应多个item(id,类型,名称,工程模名)
|
BaseProperty* addNodeData(QUuid id,int type,QString name,QString modelName); //对应component数据,一个data可对应多个item(id,类型,名称,工程模名)
|
||||||
void loadNodeDataFromDataBase(); //从数据库加载数据
|
void loadNodeDataFromDataBase(); //从数据库加载数据
|
||||||
|
|
@ -104,6 +105,8 @@ public Q_SLOTS:
|
||||||
void onSignal_generateDiagram(const QString&); //生成工程组态信号
|
void onSignal_generateDiagram(const QString&); //生成工程组态信号
|
||||||
void onSignal_openBayManager();
|
void onSignal_openBayManager();
|
||||||
private:
|
private:
|
||||||
|
void addPortsToItem_json(PortState,QJsonArray,GraphicsProjectModelItem*); //将json格式的port添加到item
|
||||||
|
private:
|
||||||
|
|
||||||
QMap<QUuid,GraphicsProjectModelItem*> _nodeItem; //工程模对象
|
QMap<QUuid,GraphicsProjectModelItem*> _nodeItem; //工程模对象
|
||||||
QMap<QUuid,GraphicsBaseModelItem*> _baseItem; //基模对象
|
QMap<QUuid,GraphicsBaseModelItem*> _baseItem; //基模对象
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef ELECTRICPORTITEM_H
|
||||||
|
#define ELECTRICPORTITEM_H
|
||||||
|
|
||||||
|
#include "graphicsItem/graphicsBaseItem.h"
|
||||||
|
|
||||||
|
class ElectricPortItem :public GraphicsProjectModelItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ElectricPortItem(QGraphicsItem *parent = 0);
|
||||||
|
virtual ~ElectricPortItem();
|
||||||
|
|
||||||
|
void addPort();
|
||||||
|
public:
|
||||||
|
virtual void updateConnectData();
|
||||||
|
protected:
|
||||||
|
virtual QRectF boundingRect() const override;
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef ELECTRICSVGGROUP_H
|
||||||
|
#define ELECTRICSVGGROUP_H
|
||||||
|
|
||||||
|
#include "graphicsBaseItem.h"
|
||||||
|
#include <QGraphicsSvgItem>
|
||||||
|
|
||||||
|
class ElectricSvgItem;
|
||||||
|
|
||||||
|
class ElectricSvgGroup :public GraphicsProjectModelGroup
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ElectricSvgGroup(const QRect &rect,QGraphicsItem *parent = 0);
|
||||||
|
virtual ~ElectricSvgGroup();
|
||||||
|
void resize(int,double, double, const QPointF&);
|
||||||
|
void updateCoordinate();
|
||||||
|
void move(const QPointF&);
|
||||||
|
virtual void loadSvg(const QByteArray& data);
|
||||||
|
virtual void addSvgItem(ElectricSvgItem* item);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual QPainterPath shape();
|
||||||
|
virtual void editShape(int, const QPointF&);
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
|
protected:
|
||||||
|
QRectF m_lastBoudingRect; //记录上一时刻的boundingRect
|
||||||
|
QByteArray m_curSvg; //当前存储的svg
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef ELECTRICSVGGROUPCT_H
|
||||||
|
#define ELECTRICSVGGROUPCT_H
|
||||||
|
|
||||||
|
#include "graphicsItem/electricSvgGroup.h"
|
||||||
|
|
||||||
|
class ElectricSvgGroupCT :public ElectricSvgGroup
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ElectricSvgGroupCT(const QRect &rect,QGraphicsItem *parent = 0);
|
||||||
|
virtual ~ElectricSvgGroupCT();
|
||||||
|
virtual void setupFinish(int nType,int nSize) override;
|
||||||
|
virtual void updateItem() override;
|
||||||
|
void setCtType(int n){_nType = n;}
|
||||||
|
void setCtSize(int n){_nSize = n;}
|
||||||
|
protected:
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||||
|
protected:
|
||||||
|
int _nType = 0; //Ct类型 1三相0零相
|
||||||
|
int _nSize = 0; //ct个数
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef ELECTRICSVGITEM2WTRANSFORMER_H
|
||||||
|
#define ELECTRICSVGITEM2WTRANSFORMER_H
|
||||||
|
|
||||||
|
/*************两绕组变压器***********/
|
||||||
|
#include "electricSvgItem.h"
|
||||||
|
|
||||||
|
class ElectricSvgItem2wTransformer :public ElectricSvgItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ElectricSvgItem2wTransformer(const QRect &rect,QGraphicsItem *parent = 0);
|
||||||
|
virtual ~ElectricSvgItem2wTransformer();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef ELECTRICSVGITEM3WTRANSFORMER_H
|
||||||
|
#define ELECTRICSVGITEM3WTRANSFORMER_H
|
||||||
|
|
||||||
|
/*************三绕组变压器***********/
|
||||||
|
#include "electricSvgItem.h"
|
||||||
|
|
||||||
|
class ElectricSvgItem3wTransformer :public ElectricSvgItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ElectricSvgItem3wTransformer(const QRect &rect,QGraphicsItem *parent = 0);
|
||||||
|
virtual ~ElectricSvgItem3wTransformer();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef ELECTRICSVGITEMCT_H
|
||||||
|
#define ELECTRICSVGITEMCT_H
|
||||||
|
|
||||||
|
#include "electricSvgItem.h"
|
||||||
|
|
||||||
|
class ElectricSvgItemCT :public ElectricSvgItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ElectricSvgItemCT(const QRect &rect,QGraphicsItem *parent = 0);
|
||||||
|
virtual ~ElectricSvgItemCT();
|
||||||
|
void setItemType(int n){_itemType = n;}
|
||||||
|
protected:
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
|
|
||||||
|
int _itemType = 0; //1三相0零相
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef ELECTRICSVGITEMCABLEEND_H
|
||||||
|
#define ELECTRICSVGITEMCABLEEND_H
|
||||||
|
|
||||||
|
/*****************电缆端*******************/
|
||||||
|
#include "electricSvgItem.h"
|
||||||
|
|
||||||
|
class ElectricSvgItemCableEnd :public ElectricSvgItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ElectricSvgItemCableEnd(const QRect &rect,QGraphicsItem *parent = 0);
|
||||||
|
virtual ~ElectricSvgItemCableEnd();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef ELECTRICSVGITEMCABLETER_H
|
||||||
|
#define ELECTRICSVGITEMCABLETER_H
|
||||||
|
|
||||||
|
/*****************电缆出线套筒*******************/
|
||||||
|
#include "electricSvgItem.h"
|
||||||
|
|
||||||
|
class ElectricSvgItemCableTer :public ElectricSvgItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ElectricSvgItemCableTer(const QRect &rect,QGraphicsItem *parent = 0);
|
||||||
|
virtual ~ElectricSvgItemCableTer();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef ELECTRICSVGITEMDS_H
|
||||||
|
#define ELECTRICSVGITEMDS_H
|
||||||
|
|
||||||
|
#include "electricSvgItem.h"
|
||||||
|
|
||||||
|
class ElectricSvgItemDS :public ElectricSvgItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ElectricSvgItemDS(const QRect &rect,QGraphicsItem *parent = 0);
|
||||||
|
virtual ~ElectricSvgItemDS();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef ELECTRICSVGITEMDTEDS_H
|
||||||
|
#define ELECTRICSVGITEMDTEDS_H
|
||||||
|
|
||||||
|
/**********双掷接地隔离开关*********/
|
||||||
|
#include "electricSvgItem.h"
|
||||||
|
|
||||||
|
class ElectricSvgItemDTEDS:public ElectricSvgItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ElectricSvgItemDTEDS(const QRect &rect,QGraphicsItem *parent = 0);
|
||||||
|
virtual ~ElectricSvgItemDTEDS();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef ELECTRICSVGITEMES_H
|
||||||
|
#define ELECTRICSVGITEMES_H
|
||||||
|
|
||||||
|
#include "electricSvgItem.h"
|
||||||
|
|
||||||
|
class ElectricSvgItemES :public ElectricSvgItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ElectricSvgItemES(const QRect &rect,QGraphicsItem *parent = 0);
|
||||||
|
virtual ~ElectricSvgItemES();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef ELECTRICSVGITEMFES_H
|
||||||
|
#define ELECTRICSVGITEMFES_H
|
||||||
|
|
||||||
|
#include "electricSvgItem.h"
|
||||||
|
|
||||||
|
class ElectricSvgItemFES :public ElectricSvgItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ElectricSvgItemFES(const QRect &rect,QGraphicsItem *parent = 0);
|
||||||
|
virtual ~ElectricSvgItemFES();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef ELECTRICSVGITEMLA_H
|
||||||
|
#define ELECTRICSVGITEMLA_H
|
||||||
|
|
||||||
|
/***********避雷器************/
|
||||||
|
#include "electricSvgItem.h"
|
||||||
|
|
||||||
|
class ElectricSvgItemLA :public ElectricSvgItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ElectricSvgItemLA(const QRect &rect,QGraphicsItem *parent = 0);
|
||||||
|
virtual ~ElectricSvgItemLA();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef ELECTRICSVGITEMPI_H
|
||||||
|
#define ELECTRICSVGITEMPI_H
|
||||||
|
|
||||||
|
/*************带点指示器***************/
|
||||||
|
#include "electricSvgItem.h"
|
||||||
|
|
||||||
|
class ElectricSvgItemPI :public ElectricSvgItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ElectricSvgItemPI(const QRect &rect,QGraphicsItem *parent = 0);
|
||||||
|
virtual ~ElectricSvgItemPI();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -175,7 +175,7 @@ class GraphicsBaseItem :public QObject, public AbstractShapeType<QGraphicsItem>
|
||||||
virtual ~GraphicsBaseItem();
|
virtual ~GraphicsBaseItem();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual int addPort(PortState typ,QPointF vec,QString id = "",HandleType hType = T_lineInOut,PortPos pos = P_top); //新建,返回-1失败
|
virtual int addPort(PortState typ,QPointF vec,QString id = "",HandleType hType = T_lineInOut,PortPos pos = P_top,double dXPercent = 0,double dYPercent = 0); //新建,返回-1失败
|
||||||
virtual void movePort(QString id,QPointF vec); //移动可动点
|
virtual void movePort(QString id,QPointF vec); //移动可动点
|
||||||
virtual void setEntity(PowerEntity*); //设置当前图元的拓扑数据
|
virtual void setEntity(PowerEntity*); //设置当前图元的拓扑数据
|
||||||
virtual PowerEntity* entity();
|
virtual PowerEntity* entity();
|
||||||
|
|
@ -195,6 +195,8 @@ public:
|
||||||
virtual void setTouched(bool b){m_touched = b;}
|
virtual void setTouched(bool b){m_touched = b;}
|
||||||
virtual void setPosChanged(bool b){_posChanged = b;}
|
virtual void setPosChanged(bool b){_posChanged = b;}
|
||||||
virtual bool getPosChanged() {return _posChanged;}
|
virtual bool getPosChanged() {return _posChanged;}
|
||||||
|
virtual void setMoveable(bool b){_bMove = b;}
|
||||||
|
virtual bool getMoveable(){return _bMove;}
|
||||||
|
|
||||||
int collidesWithHandle(const QPointF& point)
|
int collidesWithHandle(const QPointF& point)
|
||||||
{
|
{
|
||||||
|
|
@ -484,6 +486,7 @@ protected:
|
||||||
bool m_touched; //被触碰状态
|
bool m_touched; //被触碰状态
|
||||||
QRectF m_boundingRect_selected; //选中矩形框
|
QRectF m_boundingRect_selected; //选中矩形框
|
||||||
bool _posChanged = false; //位置移动标志
|
bool _posChanged = false; //位置移动标志
|
||||||
|
bool _bMove = true; //是否允许移动
|
||||||
};
|
};
|
||||||
|
|
||||||
class GraphicsBaseModelItem : public GraphicsBaseItem //基模item
|
class GraphicsBaseModelItem : public GraphicsBaseItem //基模item
|
||||||
|
|
@ -502,6 +505,23 @@ protected:
|
||||||
bool _stateMask = true; //状态遮罩
|
bool _stateMask = true; //状态遮罩
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GraphicsBaseModelGroup : public GraphicsBaseModelItem //基模group
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
GraphicsBaseModelGroup(QGraphicsItem *parent);
|
||||||
|
GraphicsBaseModelGroup(const GraphicsBaseModelGroup&);
|
||||||
|
virtual ~GraphicsBaseModelGroup();
|
||||||
|
virtual GraphicsBaseModelGroup* clone() const override;
|
||||||
|
virtual void addItem(GraphicsBaseModelItem* item);
|
||||||
|
virtual void updateLayout();
|
||||||
|
virtual QRectF boundingRect() const override;
|
||||||
|
virtual void setLayout(int n) {_layout = n;}
|
||||||
|
protected:
|
||||||
|
QList<GraphicsBaseItem*> m_childItems;
|
||||||
|
int _layout = 0; //组内布局,0横1纵
|
||||||
|
};
|
||||||
|
|
||||||
class GraphicsProjectModelItem : public GraphicsBaseItem //工程模item
|
class GraphicsProjectModelItem : public GraphicsBaseItem //工程模item
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -536,6 +556,9 @@ public:
|
||||||
virtual void updateConnectData(); //更新连接关系数据
|
virtual void updateConnectData(); //更新连接关系数据
|
||||||
virtual void setModelName(QString sName){_modelName = sName;}
|
virtual void setModelName(QString sName){_modelName = sName;}
|
||||||
virtual QString getModelName() const {return _modelName;}
|
virtual QString getModelName() const {return _modelName;}
|
||||||
|
virtual void setupFinish(int nType,int nSize){} //设置完成后调用(如ct,pt)
|
||||||
|
virtual void updateItem(){}; //更新自身(如ct,pt)
|
||||||
|
virtual void updateTerPos(); //ct,pt等item大小变动后重新计算端点位置
|
||||||
protected:
|
protected:
|
||||||
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange, const QVariant&);
|
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange, const QVariant&);
|
||||||
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*);
|
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*);
|
||||||
|
|
@ -551,4 +574,29 @@ protected:
|
||||||
QString _modelName; //当前图元使用的模型名,用来在model中检索属性信息
|
QString _modelName; //当前图元使用的模型名,用来在model中检索属性信息
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GraphicsProjectModelGroup : public GraphicsProjectModelItem //工程模group
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
GraphicsProjectModelGroup(QGraphicsItem *parent);
|
||||||
|
virtual ~GraphicsProjectModelGroup();
|
||||||
|
virtual void addItem(GraphicsProjectModelItem* item);
|
||||||
|
virtual void updateLayout();
|
||||||
|
//virtual QRectF boundingRect() const override;
|
||||||
|
virtual void setLayout(int n) {m_direction = n;}
|
||||||
|
virtual void setGroupType(int n) {_groupType = n;}
|
||||||
|
virtual int getGroupType() {return _groupType;}
|
||||||
|
virtual void setSpacing(qreal spacing) {
|
||||||
|
if (m_spacing != spacing) {
|
||||||
|
m_spacing = spacing;
|
||||||
|
updateLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QRectF updateBoundRect();
|
||||||
|
protected:
|
||||||
|
QList<GraphicsBaseItem*> m_childItems;
|
||||||
|
int m_direction = 0; //组内布局,0横1纵
|
||||||
|
int m_spacing = 0; //间距
|
||||||
|
int _groupType = 0; //组类型,0联合(子item独立连接),1聚合(子item仅作展示)
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,10 @@ public:
|
||||||
QString getName() const {return _name;}
|
QString getName() const {return _name;}
|
||||||
void setSourcePortId(const QString& id) {_sourcePortId = id;}
|
void setSourcePortId(const QString& id) {_sourcePortId = id;}
|
||||||
QString getSourcePortId() {return _sourcePortId;}
|
QString getSourcePortId() {return _sourcePortId;}
|
||||||
|
void setXPercent(double d) {_dXPercent = d;}
|
||||||
|
void setYPercent(double d) {_dYPercent = d;}
|
||||||
|
double getXPercent(){return _dXPercent;}
|
||||||
|
double getYPercent(){return _dYPercent;}
|
||||||
protected:
|
protected:
|
||||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||||
|
|
||||||
|
|
@ -35,6 +39,8 @@ private:
|
||||||
PortPos _pos;
|
PortPos _pos;
|
||||||
ElectricConnectLineItem* _ptr;
|
ElectricConnectLineItem* _ptr;
|
||||||
QString _sourcePortId; //被哪个port生成
|
QString _sourcePortId; //被哪个port生成
|
||||||
|
double _dXPercent = 0.0; //横向相对位置(0-1)固定端点
|
||||||
|
double _dYPercent = 0.0; //纵向相对位置(0-1)固定端点
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,9 @@ public:
|
||||||
for (PowerTerminal* terminal : m_terminals) {
|
for (PowerTerminal* terminal : m_terminals) {
|
||||||
auto pTer = TopologyManager::instance().getTerminal(terminal->id(),ModelFunctionType::BaseModel);
|
auto pTer = TopologyManager::instance().getTerminal(terminal->id(),ModelFunctionType::BaseModel);
|
||||||
if(pTer == nullptr){ //BaseModel中不存在则拷贝
|
if(pTer == nullptr){ //BaseModel中不存在则拷贝
|
||||||
TopologyManager::instance().createTerminal(m_id,terminal->type(),terminal->name(),terminal->relativePosition(),terminal->id(),ModelFunctionType::BaseModel);
|
double dX = terminal->getPerX();
|
||||||
|
double dY = terminal->getPerY();
|
||||||
|
TopologyManager::instance().createTerminal(m_id,terminal->type(),terminal->name(),terminal->relativePosition(),terminal->id(),ModelFunctionType::BaseModel,dX,dY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ public:
|
||||||
const QString& name,
|
const QString& name,
|
||||||
const QPointF& relativePos = QPointF(),
|
const QPointF& relativePos = QPointF(),
|
||||||
const QString& uuid = "",
|
const QString& uuid = "",
|
||||||
|
const double dPerX = 0.0,
|
||||||
|
const double dPerY = 0.0,
|
||||||
QObject* parent = nullptr);
|
QObject* parent = nullptr);
|
||||||
|
|
||||||
// 属性访问
|
// 属性访问
|
||||||
|
|
@ -43,6 +45,11 @@ public:
|
||||||
|
|
||||||
void setGenerateBy(const QString& sName) {m_generateBy = sName;}
|
void setGenerateBy(const QString& sName) {m_generateBy = sName;}
|
||||||
QString getGenerateBy() {return m_generateBy;}
|
QString getGenerateBy() {return m_generateBy;}
|
||||||
|
|
||||||
|
void setPerX(double d) {m_dPerX = d;}
|
||||||
|
double getPerX() {return m_dPerX;}
|
||||||
|
void setPerY(double d) {m_dPerY = d;}
|
||||||
|
double getPerY() {return m_dPerY;}
|
||||||
signals:
|
signals:
|
||||||
void positionChanged(const QPointF& newPosition);
|
void positionChanged(const QPointF& newPosition);
|
||||||
|
|
||||||
|
|
@ -53,5 +60,8 @@ private:
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QPointF m_relativePosition;
|
QPointF m_relativePosition;
|
||||||
QString m_generateBy; //被哪个Terminal生成
|
QString m_generateBy; //被哪个Terminal生成
|
||||||
|
double m_dPerX = 0.0; //横向百分比位置
|
||||||
|
double m_dPerY = 0.0; //纵向百分比位置
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif //POWERTERMINAL_H
|
#endif //POWERTERMINAL_H
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public:
|
||||||
const QString& name,
|
const QString& name,
|
||||||
const QPointF& relPos = QPointF(),
|
const QPointF& relPos = QPointF(),
|
||||||
const QString& uuid = "",
|
const QString& uuid = "",
|
||||||
ModelFunctionType tpe = ModelFunctionType::ProjectModel);
|
ModelFunctionType tpe = ModelFunctionType::ProjectModel,double dPerX = 0.0,double dPerY = 0.0);
|
||||||
bool deleteTerminal(const QString& terminalId,ModelFunctionType tpe = ModelFunctionType::ProjectModel);
|
bool deleteTerminal(const QString& terminalId,ModelFunctionType tpe = ModelFunctionType::ProjectModel);
|
||||||
PowerTerminal* getTerminal(const QString& terminalId,ModelFunctionType tpe = ModelFunctionType::ProjectModel) const;
|
PowerTerminal* getTerminal(const QString& terminalId,ModelFunctionType tpe = ModelFunctionType::ProjectModel) const;
|
||||||
QList<PowerTerminal*> getTerminalsForEntity(const QString& entityId,ModelFunctionType tpe = ModelFunctionType::ProjectModel) const;
|
QList<PowerTerminal*> getTerminalsForEntity(const QString& entityId,ModelFunctionType tpe = ModelFunctionType::ProjectModel) const;
|
||||||
|
|
|
||||||
|
|
@ -42,42 +42,42 @@ QMap<QString,propertyStateInfo> CtExtraInfoDlg::getPropertyValue(BaseProperty* p
|
||||||
propertyStateInfo info;
|
propertyStateInfo info;
|
||||||
info.type = pro.proType;
|
info.type = pro.proType;
|
||||||
info.name = pro.proName;
|
info.name = pro.proName;
|
||||||
if(info.name == "额定电流") //此处应为类型名
|
if(info.name == "额定电流(A)" || info.name == "in_a") //此处应为类型名
|
||||||
{
|
{
|
||||||
info.defaultValue = ui->le_ratedCurrent->text();
|
info.defaultValue = ui->le_ratedCurrent->text();
|
||||||
}
|
}
|
||||||
else if(info.name == "工频耐压")
|
else if(info.name == "工频耐压(V/1min)" || info.name == "uac_v_1min")
|
||||||
{
|
{
|
||||||
info.defaultValue = ui->le_pfwv_ct->text();
|
info.defaultValue = ui->le_pfwv_ct->text();
|
||||||
}
|
}
|
||||||
else if(info.name == "冲击耐压")
|
else if(info.name == "冲击耐压(V)" || info.name == "uimp_v")
|
||||||
{
|
{
|
||||||
info.defaultValue = ui->le_iwv_ct->text();
|
info.defaultValue = ui->le_iwv_ct->text();
|
||||||
}
|
}
|
||||||
else if(info.name == "动稳定电流")
|
else if(info.name == "动稳定电流(A)" || info.name == "dsc_a")
|
||||||
{
|
{
|
||||||
info.defaultValue = ui->le_dsc_ct->text();
|
info.defaultValue = ui->le_dsc_ct->text();
|
||||||
}
|
}
|
||||||
else if(info.name == "仪表保安系数")
|
else if(info.name == "仪表保安系数" || info.name == "fs")
|
||||||
{
|
{
|
||||||
info.defaultValue = ui->le_isf->text();
|
info.defaultValue = ui->le_isf->text();
|
||||||
}
|
}
|
||||||
else if(info.name == "短时热电流")
|
else if(info.name == "热稳定电流(A)" || info.name == "ith_a")
|
||||||
{
|
{
|
||||||
info.defaultValue = ui->le_sttc->text();
|
info.defaultValue = ui->le_sttc->text();
|
||||||
}
|
}
|
||||||
else if(info.name == "额定频率")
|
else if(info.name == "额定频率(Hz)" || info.name == "fn_hz")
|
||||||
{
|
{
|
||||||
info.defaultValue = ui->le_rf_ct->text();
|
info.defaultValue = ui->le_rf_ct->text();
|
||||||
}
|
}
|
||||||
else if(info.name == "相数")
|
else if(info.name == "相数" || info.name == "phase_num")
|
||||||
{
|
{
|
||||||
if(ui->rb_tpt_ct->isChecked())
|
if(ui->rb_tpt_ct->isChecked())
|
||||||
info.defaultValue = 1;
|
info.defaultValue = 1;
|
||||||
else
|
else
|
||||||
info.defaultValue = 0;
|
info.defaultValue = 0;
|
||||||
}
|
}
|
||||||
else if(info.name == "ct绕组")
|
else if(info.name == "CT绕组" || info.name == "ct_winding")
|
||||||
{
|
{
|
||||||
QJsonObject object;
|
QJsonObject object;
|
||||||
QJsonArray arr;
|
QJsonArray arr;
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include "baseProperty.h"
|
#include "baseProperty.h"
|
||||||
#include "diagramEditor/editPanel.h"
|
#include "diagramEditor/editPanel.h"
|
||||||
#include "graphicsDataModel/diagramEditorModel.h"
|
#include "graphicsDataModel/diagramEditorModel.h"
|
||||||
|
#include "designerView.h"
|
||||||
#include "basePropertyManager.h"
|
#include "basePropertyManager.h"
|
||||||
|
|
||||||
DiagramCavas::DiagramCavas(QWidget *parent)
|
DiagramCavas::DiagramCavas(QWidget *parent)
|
||||||
|
|
@ -409,6 +410,7 @@ void DiagramCavas::onSignal_wizardFinished(QString sName,QMap<QUuid,GraphicsBase
|
||||||
if(BasePropertyManager::instance().findBaseEntityData(pro->uuid()) == nullptr){ //拷贝editor数据到basemodel中
|
if(BasePropertyManager::instance().findBaseEntityData(pro->uuid()) == nullptr){ //拷贝editor数据到basemodel中
|
||||||
auto pPro = pPanel->getModelController()->addBaseNodeData(pro->uuid(),pro->type(),pro->name(),pro->metaModelName(),pro->getBlock());
|
auto pPro = pPanel->getModelController()->addBaseNodeData(pro->uuid(),pro->type(),pro->name(),pro->metaModelName(),pro->getBlock());
|
||||||
pPro->setConnection(pro->getConnection());
|
pPro->setConnection(pro->getConnection());
|
||||||
|
pPro->setGraphicsType(pro->graphicsType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//pPanel->getModelController()->addTestData();
|
//pPanel->getModelController()->addTestData();
|
||||||
|
|
@ -419,6 +421,10 @@ void DiagramCavas::onSignal_wizardFinished(QString sName,QMap<QUuid,GraphicsBase
|
||||||
if(pPro){
|
if(pPro){
|
||||||
cloneItem->setProperty(pPro);
|
cloneItem->setProperty(pPro);
|
||||||
pPanel->getScene()->addItem(cloneItem);
|
pPanel->getScene()->addItem(cloneItem);
|
||||||
|
cloneItem->setPos(pItem->pos());
|
||||||
|
pPanel->getModelController()->addBaseItem(cloneItem->itemId(),cloneItem);
|
||||||
|
pPro->setDataChanged(true);
|
||||||
|
|
||||||
if(pPro->type() != 8){
|
if(pPro->type() != 8){
|
||||||
PowerEntity* pEntity = TopologyManager::instance().findEntity(pPro->uuid().toString(),ModelFunctionType::BaseModel);
|
PowerEntity* pEntity = TopologyManager::instance().findEntity(pPro->uuid().toString(),ModelFunctionType::BaseModel);
|
||||||
if(pEntity)
|
if(pEntity)
|
||||||
|
|
@ -429,6 +435,22 @@ void DiagramCavas::onSignal_wizardFinished(QString sName,QMap<QUuid,GraphicsBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QGraphicsItem*> items = pPanel->getScene()->items();
|
||||||
|
|
||||||
|
if (items.isEmpty()) {
|
||||||
|
return; // 没有 items 时返回
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算所有 items 的联合包围盒
|
||||||
|
QRectF totalBoundingRect;
|
||||||
|
foreach (QGraphicsItem *item, items) {
|
||||||
|
totalBoundingRect |= item->sceneBoundingRect();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算中心点
|
||||||
|
QPointF center = totalBoundingRect.center();
|
||||||
|
pPanel->getView()->centerOn(center);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*******************bay************************/
|
/*******************bay************************/
|
||||||
|
|
|
||||||
|
|
@ -493,7 +493,7 @@ void DiagramEditorWizard::onAddBayFinished(DiagramEditorWizardBayInfo info)
|
||||||
pBlock->addConnect(uid);
|
pBlock->addConnect(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(info.nType == BayType::busSectionBay){
|
if(info.nType == BayType::busSectionBay){ //分段间隔
|
||||||
|
|
||||||
auto pC1 = getContainerByBlock(curIndex,1,info.lstBindObj.first());
|
auto pC1 = getContainerByBlock(curIndex,1,info.lstBindObj.first());
|
||||||
auto pC2 = getContainerByBlock(curIndex,1,info.lstBindObj.last());
|
auto pC2 = getContainerByBlock(curIndex,1,info.lstBindObj.last());
|
||||||
|
|
@ -557,7 +557,7 @@ void DiagramEditorWizard::onAddBayFinished(DiagramEditorWizardBayInfo info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(info.nType == BayType::outcomingBay){ //出线间隔
|
else if(info.nType == BayType::incomingBay || info.nType == BayType::ptBay){ //进线间隔和pt间隔在上边
|
||||||
auto pContainer = getContainerByBlock(curIndex,1,info.lstBindObj.first());
|
auto pContainer = getContainerByBlock(curIndex,1,info.lstBindObj.first());
|
||||||
pContainer->insertBlock(0,pBlock);
|
pContainer->insertBlock(0,pBlock);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -316,10 +316,10 @@ void EditPanel::initBlockConnection()
|
||||||
TransformerType typTrans = pTrans->getTransType();
|
TransformerType typTrans = pTrans->getTransType();
|
||||||
BayType typBay = pBay->getBayType();
|
BayType typBay = pBay->getBayType();
|
||||||
if(typTrans == TransformerType::twoWinding){ //两绕组
|
if(typTrans == TransformerType::twoWinding){ //两绕组
|
||||||
if(typBay == BayType::incomingBay){ //进线间隔,在高压侧
|
if(typBay == BayType::outcomingBay){ //进线间隔,在低压侧
|
||||||
center2 += QPointF(0,pItem2->boundingRect().height());
|
center2 += QPointF(0,pItem2->boundingRect().height());
|
||||||
}
|
}
|
||||||
else if(typBay == BayType::outcomingBay){ //出线间隔,在低压侧
|
else if(typBay == BayType::incomingBay){ //出线间隔,在高压侧
|
||||||
center1 += QPointF(0,pItem1->boundingRect().height());
|
center1 += QPointF(0,pItem1->boundingRect().height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ DrawingPanel::DrawingPanel(PowerEntity* pEntity,QWidget *parent,DiagramMode mode
|
||||||
m_pSelectorManager = new SelectorManager(_pModel,this);
|
m_pSelectorManager = new SelectorManager(_pModel,this);
|
||||||
m_pGraphicsScene = new DesignerScene(_pModel,this);
|
m_pGraphicsScene = new DesignerScene(_pModel,this);
|
||||||
//设置场景大小.前两个参数为scene的坐标远点,设置到view的中心点后,无论view如何缩放,secne的坐标原点都不会动,方便后续的位置计算
|
//设置场景大小.前两个参数为scene的坐标远点,设置到view的中心点后,无论view如何缩放,secne的坐标原点都不会动,方便后续的位置计算
|
||||||
m_pGraphicsScene->setSceneRect(-g_dGriaphicsScene_Width, -g_dGriaphicsScene_Height, g_dGriaphicsScene_Width*2, g_dGriaphicsScene_Height*2);
|
m_pGraphicsScene->setSceneRect(0,0, g_dGriaphicsScene_Width*4, g_dGriaphicsScene_Height*4);
|
||||||
m_pGraphicsScene->setGridVisible(true);
|
m_pGraphicsScene->setGridVisible(true);
|
||||||
|
|
||||||
m_pGraphicsView = new DesignerView(this);
|
m_pGraphicsView = new DesignerView(this);
|
||||||
|
|
@ -184,13 +184,15 @@ QJsonObject DrawingPanel::getDiagramInfo() const
|
||||||
QJsonArray arr;
|
QJsonArray arr;
|
||||||
if(_pModel)
|
if(_pModel)
|
||||||
{
|
{
|
||||||
QMap<QUuid,QPointF> map = _pModel->allNodePos();
|
QMap<QUuid,itemPageInfo> map = _pModel->allNodePos();
|
||||||
for(auto iter = map.begin();iter != map.end();++iter)
|
for(auto iter = map.begin();iter != map.end();++iter)
|
||||||
{
|
{
|
||||||
QJsonObject node;
|
QJsonObject node;
|
||||||
node["id"] = iter.key().toString();
|
node["id"] = iter.key().toString();
|
||||||
node["x"] = iter.value().x();
|
node["x"] = iter.value().pos.x();
|
||||||
node["y"] = iter.value().y();
|
node["y"] = iter.value().pos.y();
|
||||||
|
node["width"] = iter.value().dWidth;
|
||||||
|
node["height"] = iter.value().dHeight;
|
||||||
arr.append(node);
|
arr.append(node);
|
||||||
}
|
}
|
||||||
obj["nodes"] = arr;
|
obj["nodes"] = arr;
|
||||||
|
|
@ -236,11 +238,13 @@ void DrawingPanel::loadNodes(QJsonObject obj)
|
||||||
QString uuid = node["id"].toString();
|
QString uuid = node["id"].toString();
|
||||||
double dX = node["x"].toDouble();
|
double dX = node["x"].toDouble();
|
||||||
double dY = node["y"].toDouble();
|
double dY = node["y"].toDouble();
|
||||||
|
double dWidth = node["width"].toDouble();
|
||||||
|
double dHeight = node["height"].toDouble();
|
||||||
|
|
||||||
//componentInfo info =DataBase::GetInstance()->getComponentInfoByUuid(uuid);
|
//componentInfo info =DataBase::GetInstance()->getComponentInfoByUuid(uuid);
|
||||||
if(_pModel)
|
if(_pModel)
|
||||||
{
|
{
|
||||||
_pModel->addNodeItem(QUuid(uuid)/*,info.type*/,QPointF(dX,dY));
|
_pModel->addNodeItem(QUuid(uuid)/*,info.type*/,QPointF(dX,dY),dWidth,dHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ QPointF BaseModel::calculateBusPortPos(GraphicsBaseItem* pBus,GraphicsBaseItem*
|
||||||
QPointF p2 = busLine.p2();
|
QPointF p2 = busLine.p2();
|
||||||
|
|
||||||
// 计算item的中心点在垂直于线段方向上的投影
|
// 计算item的中心点在垂直于线段方向上的投影
|
||||||
QPointF itemCenter = item->pos() + QPointF(item->boundingRect().width()/2, item->boundingRect().height()/2);
|
QPointF itemCenter = item->pos();// + QPointF(item->boundingRect().width()/2, item->boundingRect().height()/2);
|
||||||
|
|
||||||
// 计算投影点在线段上的位置
|
// 计算投影点在线段上的位置
|
||||||
QPointF projection;
|
QPointF projection;
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ void DiagramEditorModel::createTopoTerminalsByItem(GraphicsBaseItem* pItem,Model
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
QPointF f = port->pos();
|
QPointF f = port->pos();
|
||||||
TopologyManager::instance().createTerminal(pEntity->id(),terType,"",port->pos(),port->getId(),funType);
|
TopologyManager::instance().createTerminal(pEntity->id(),terType,"",port->pos(),port->getId(),funType,port->getXPercent(),port->getYPercent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -137,6 +137,7 @@ QRectF DiagramEditorModel::generateTempBay()
|
||||||
GraphicsBaseModelItem* DiagramEditorModel::generateComponent(QUuid uid,QString sName,int nCategory,int nType,QPointF pos,int nRotate,int mode)
|
GraphicsBaseModelItem* DiagramEditorModel::generateComponent(QUuid uid,QString sName,int nCategory,int nType,QPointF pos,int nRotate,int mode)
|
||||||
{
|
{
|
||||||
GraphicsBaseModelItem* pItem = nullptr;
|
GraphicsBaseModelItem* pItem = nullptr;
|
||||||
|
int componentType = -1; //对应的componentType
|
||||||
if(nCategory == 0)
|
if(nCategory == 0)
|
||||||
{
|
{
|
||||||
QByteArray byte;
|
QByteArray byte;
|
||||||
|
|
@ -146,8 +147,10 @@ GraphicsBaseModelItem* DiagramEditorModel::generateComponent(QUuid uid,QString s
|
||||||
pBus->loadSvg(byte);
|
pBus->loadSvg(byte);
|
||||||
pItem = pBus;
|
pItem = pBus;
|
||||||
pItem->setItemType(GIT_baseBus);
|
pItem->setItemType(GIT_baseBus);
|
||||||
|
componentType = 1;
|
||||||
}
|
}
|
||||||
else if(nType == 2){ //异步电动机
|
else if(nType == 2){ //异步电动机
|
||||||
|
componentType = 2;
|
||||||
}
|
}
|
||||||
else if(nType == 3){ //断路器
|
else if(nType == 3){ //断路器
|
||||||
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
||||||
|
|
@ -155,9 +158,11 @@ GraphicsBaseModelItem* DiagramEditorModel::generateComponent(QUuid uid,QString s
|
||||||
pBreaker->loadSvg(byte);
|
pBreaker->loadSvg(byte);
|
||||||
pItem = pBreaker;
|
pItem = pBreaker;
|
||||||
pItem->setItemType(GIT_baseBreaker);
|
pItem->setItemType(GIT_baseBreaker);
|
||||||
pItem->initialPortsByDatabase(3);
|
componentType = 3;
|
||||||
|
pItem->initialPortsByDatabase(componentType);
|
||||||
}
|
}
|
||||||
else if(nType == 4){ //电缆
|
else if(nType == 4){ //电缆
|
||||||
|
componentType = 8;
|
||||||
}
|
}
|
||||||
else if(nType == 5){ //电流互感器
|
else if(nType == 5){ //电流互感器
|
||||||
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
||||||
|
|
@ -165,7 +170,8 @@ GraphicsBaseModelItem* DiagramEditorModel::generateComponent(QUuid uid,QString s
|
||||||
pCt->loadSvg(byte);
|
pCt->loadSvg(byte);
|
||||||
pItem = pCt;
|
pItem = pCt;
|
||||||
pItem->setItemType(GIT_baseCT);
|
pItem->setItemType(GIT_baseCT);
|
||||||
pItem->initialPortsByDatabase(4);
|
componentType = 4;
|
||||||
|
pItem->initialPortsByDatabase(componentType);
|
||||||
}
|
}
|
||||||
else if(nType == 6){ //电压互感器
|
else if(nType == 6){ //电压互感器
|
||||||
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
||||||
|
|
@ -173,7 +179,8 @@ GraphicsBaseModelItem* DiagramEditorModel::generateComponent(QUuid uid,QString s
|
||||||
pPt->loadSvg(byte);
|
pPt->loadSvg(byte);
|
||||||
pItem = pPt;
|
pItem = pPt;
|
||||||
pItem->setItemType(GIT_basePT);
|
pItem->setItemType(GIT_basePT);
|
||||||
pItem->initialPortsByDatabase(5);
|
componentType = 5;
|
||||||
|
pItem->initialPortsByDatabase(componentType);
|
||||||
}
|
}
|
||||||
else if(nType == 7){ //隔离开关
|
else if(nType == 7){ //隔离开关
|
||||||
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
||||||
|
|
@ -181,13 +188,35 @@ GraphicsBaseModelItem* DiagramEditorModel::generateComponent(QUuid uid,QString s
|
||||||
pDs->loadSvg(byte);
|
pDs->loadSvg(byte);
|
||||||
pItem = pDs;
|
pItem = pDs;
|
||||||
pItem->setItemType(GIT_baseDS);
|
pItem->setItemType(GIT_baseDS);
|
||||||
pItem->initialPortsByDatabase(9);
|
componentType = 9;
|
||||||
|
pItem->initialPortsByDatabase(componentType);
|
||||||
}
|
}
|
||||||
else if(nType == 8){ //接地开关
|
else if(nType == 8){ //接地开关
|
||||||
|
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
||||||
|
auto pEs = new ElectricBaseModelSvgItem(QRect(-15, -30, 30, 60));
|
||||||
|
pEs->loadSvg(byte);
|
||||||
|
pItem = pEs;
|
||||||
|
pItem->setItemType(GIT_baseES);
|
||||||
|
componentType = 6;
|
||||||
|
pItem->initialPortsByDatabase(componentType);
|
||||||
}
|
}
|
||||||
else if(nType == 9){ //快速接地开关
|
else if(nType == 9){ //快速接地开关
|
||||||
|
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
||||||
|
auto pFEs = new ElectricBaseModelSvgItem(QRect(-15, -30, 30, 60));
|
||||||
|
pFEs->loadSvg(byte);
|
||||||
|
pItem = pFEs;
|
||||||
|
pItem->setItemType(GIT_baseFES);
|
||||||
|
componentType = 7;
|
||||||
|
pItem->initialPortsByDatabase(componentType);
|
||||||
}
|
}
|
||||||
else if(nType == 10){ //双掷接地隔离开关
|
else if(nType == 10){ //双掷接地隔离开关
|
||||||
|
byte = DataBase::GetInstance()->ModelType()[nType].icon;
|
||||||
|
auto pDtedes = new ElectricBaseModelSvgItem(QRect(-30, -15, 60, 30));
|
||||||
|
pDtedes->loadSvg(byte);
|
||||||
|
pItem = pDtedes;
|
||||||
|
pItem->setItemType(GIT_baseDTEDS);
|
||||||
|
componentType = 10;
|
||||||
|
pItem->initialPortsByDatabase(componentType);
|
||||||
}
|
}
|
||||||
else if(nType == 11){ //带电指示器
|
else if(nType == 11){ //带电指示器
|
||||||
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
||||||
|
|
@ -195,13 +224,29 @@ GraphicsBaseModelItem* DiagramEditorModel::generateComponent(QUuid uid,QString s
|
||||||
pPi->loadSvg(byte);
|
pPi->loadSvg(byte);
|
||||||
pItem = pPi;
|
pItem = pPi;
|
||||||
pItem->setItemType(GIT_basePI);
|
pItem->setItemType(GIT_basePI);
|
||||||
pItem->initialPortsByDatabase(11);
|
componentType = 11;
|
||||||
|
pItem->initialPortsByDatabase(componentType);
|
||||||
}
|
}
|
||||||
else if(nType == 12){ //避雷器
|
else if(nType == 12){ //避雷器
|
||||||
|
byte = DataBase::GetInstance()->ModelType()[nType].icon;
|
||||||
|
auto pPi = new ElectricBaseModelSvgItem(QRect(-15, -30, 30, 60));
|
||||||
|
pPi->loadSvg(byte);
|
||||||
|
pItem = pPi;
|
||||||
|
pItem->setItemType(GIT_baseLightningArrester);
|
||||||
|
componentType = 12;
|
||||||
|
pItem->initialPortsByDatabase(componentType);
|
||||||
}
|
}
|
||||||
else if(nType == 13){ //电缆出线套筒
|
else if(nType == 13){ //电缆出线套筒
|
||||||
|
componentType = 13;
|
||||||
}
|
}
|
||||||
else if(nType == 14){ //电缆端
|
else if(nType == 14){ //电缆端
|
||||||
|
byte = DataBase::GetInstance()->ModelType()[nType].icon;
|
||||||
|
auto pCableEnd = new ElectricBaseModelSvgItem(QRect(-10, -10, 20, 20));
|
||||||
|
pCableEnd->loadSvg(byte);
|
||||||
|
pItem = pCableEnd;
|
||||||
|
pItem->setItemType(GIT_baseCableEnd);
|
||||||
|
componentType = 14;
|
||||||
|
pItem->initialPortsByDatabase(componentType);
|
||||||
}
|
}
|
||||||
else if(nType == 15){ //两绕组变压器
|
else if(nType == 15){ //两绕组变压器
|
||||||
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
||||||
|
|
@ -209,7 +254,8 @@ GraphicsBaseModelItem* DiagramEditorModel::generateComponent(QUuid uid,QString s
|
||||||
p2W->loadSvg(byte);
|
p2W->loadSvg(byte);
|
||||||
pItem = p2W;
|
pItem = p2W;
|
||||||
pItem->setItemType(GIT_base2wTransformer);
|
pItem->setItemType(GIT_base2wTransformer);
|
||||||
pItem->initialPortsByDatabase(15);
|
componentType = 15;
|
||||||
|
pItem->initialPortsByDatabase(componentType);
|
||||||
}
|
}
|
||||||
else if(nType == 16){ //三绕组变压器
|
else if(nType == 16){ //三绕组变压器
|
||||||
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
byte = DataBase::GetInstance()->ModelType()[nType].icon; //注意modelType表与componentType表不一致!
|
||||||
|
|
@ -217,7 +263,8 @@ GraphicsBaseModelItem* DiagramEditorModel::generateComponent(QUuid uid,QString s
|
||||||
p3W->loadSvg(byte);
|
p3W->loadSvg(byte);
|
||||||
pItem = p3W;
|
pItem = p3W;
|
||||||
pItem->setItemType(GIT_base3wTransformer);
|
pItem->setItemType(GIT_base3wTransformer);
|
||||||
pItem->initialPortsByDatabase(16);
|
componentType = 16;
|
||||||
|
pItem->initialPortsByDatabase(componentType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(nCategory == 1){
|
else if(nCategory == 1){
|
||||||
|
|
@ -243,9 +290,10 @@ GraphicsBaseModelItem* DiagramEditorModel::generateComponent(QUuid uid,QString s
|
||||||
DiagramEditorItemProperty* pData = nullptr;
|
DiagramEditorItemProperty* pData = nullptr;
|
||||||
if(nCategory == 1){
|
if(nCategory == 1){
|
||||||
pData = addPreviewData(uid,0,sName,"node","",mode);
|
pData = addPreviewData(uid,0,sName,"node","",mode);
|
||||||
|
pData->setGraphicsType(pItem->getItemType());
|
||||||
}
|
}
|
||||||
else if(nCategory == 0){ //设备
|
else if(nCategory == 0){ //设备
|
||||||
pData = addPreviewData(uid,nType,sName,DataBase::GetInstance()->ModelType()[nType].modelType,"",mode);
|
pData = addPreviewData(uid,componentType,sName,DataBase::GetInstance()->ModelType()[nType].modelType,"",mode);
|
||||||
pData->setGraphicsType(pItem->getItemType());
|
pData->setGraphicsType(pItem->getItemType());
|
||||||
}
|
}
|
||||||
if(pData)
|
if(pData)
|
||||||
|
|
@ -638,7 +686,7 @@ void DiagramEditorModel::calculateBlockPos()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dDeltaX = 50;
|
dDeltaX = 150; //首个变压器位置
|
||||||
if(iter.key() == 0){ //若设置了变压器,直接插入到第一行下方
|
if(iter.key() == 0){ //若设置了变压器,直接插入到第一行下方
|
||||||
if(!mapTotal.value(g_transformerLevel).empty()){
|
if(!mapTotal.value(g_transformerLevel).empty()){
|
||||||
auto lstCon = mapTotal.value(g_transformerLevel);
|
auto lstCon = mapTotal.value(g_transformerLevel);
|
||||||
|
|
@ -661,7 +709,7 @@ void DiagramEditorModel::calculateBlockPos()
|
||||||
double dWidth = pCon->getWidth();
|
double dWidth = pCon->getWidth();
|
||||||
pCon->setStartY(deltaY-dHeight*0.5);
|
pCon->setStartY(deltaY-dHeight*0.5);
|
||||||
pCon->setStartX(dDeltaX);
|
pCon->setStartX(dDeltaX);
|
||||||
dDeltaX += dWidth+100;
|
dDeltaX += dWidth+200;
|
||||||
|
|
||||||
auto mapBlocks = pCon->getBlockMap();
|
auto mapBlocks = pCon->getBlockMap();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,18 @@
|
||||||
#include "graphicsItem/electricSvgItemRect.h"
|
#include "graphicsItem/electricSvgItemRect.h"
|
||||||
#include "graphicsItem/electricSvgItemTriangle.h"
|
#include "graphicsItem/electricSvgItemTriangle.h"
|
||||||
#include "graphicsItem/electricConnectLineItem.h"
|
#include "graphicsItem/electricConnectLineItem.h"
|
||||||
|
#include "graphicsItem/electricPortItem.h"
|
||||||
|
#include "graphicsItem/electricSvgGroupCT.h"
|
||||||
|
#include "graphicsItem/electricSvgItemDS.h"
|
||||||
|
#include "graphicsItem/electricSvgItemES.h"
|
||||||
|
#include "graphicsItem/electricSvgItemFES.h"
|
||||||
|
#include "graphicsItem/electricSvgItemDTEDS.h"
|
||||||
|
#include "graphicsItem/electricSvgItemPI.h"
|
||||||
|
#include "graphicsItem/electricSvgItemLA.h"
|
||||||
|
#include "graphicsItem/electricSvgItemCableTer.h"
|
||||||
|
#include "graphicsItem/electricSvgItemCableEnd.h"
|
||||||
|
#include "graphicsItem/electricSvgItem2wTransformer.h"
|
||||||
|
#include "graphicsItem/electricSvgItem3wTransformer.h"
|
||||||
#include "baseModelItem/electricBaseModelLineItem.h"
|
#include "baseModelItem/electricBaseModelLineItem.h"
|
||||||
#include "baseModelItem/electricBaseModelSvgItem.h"
|
#include "baseModelItem/electricBaseModelSvgItem.h"
|
||||||
#include "baseModelItem/electricBaseModelSvgBus.h"
|
#include "baseModelItem/electricBaseModelSvgBus.h"
|
||||||
|
|
@ -56,13 +68,20 @@ FixedPortsModel::~FixedPortsModel()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QUuid,QPointF> FixedPortsModel::allNodePos() const
|
QMap<QUuid,itemPageInfo> FixedPortsModel::allNodePos() const
|
||||||
{
|
{
|
||||||
QMap<QUuid,QPointF> map;
|
QMap<QUuid,itemPageInfo> map;
|
||||||
for(auto pItem:_nodeItem)
|
for(auto pItem:_nodeItem)
|
||||||
{
|
{
|
||||||
if(pItem->getItemType() != GIT_link)
|
if(pItem->getItemType() != GIT_link){
|
||||||
map.insert(pItem->itemId(),pItem->pos());
|
itemPageInfo info;
|
||||||
|
double dWidth = pItem->boundingRect().width();
|
||||||
|
double dHeight = pItem->boundingRect().height();
|
||||||
|
info.pos = pItem->scenePos()/*+QPointF(dWidth*0.5,dHeight*0.5)*/;
|
||||||
|
info.dWidth = dWidth;
|
||||||
|
info.dHeight = dHeight;
|
||||||
|
map.insert(pItem->itemId(),info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
@ -110,7 +129,7 @@ bool FixedPortsModel::addNodeItem(QUuid uuid,GraphicsProjectModelItem* pItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos)
|
void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos,double width,double height)
|
||||||
{
|
{
|
||||||
//todo:load图形时必有拓扑实体,关联到对应的entity
|
//todo:load图形时必有拓扑实体,关联到对应的entity
|
||||||
BaseProperty* pro = nullptr;
|
BaseProperty* pro = nullptr;
|
||||||
|
|
@ -126,12 +145,10 @@ void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos)
|
||||||
return;
|
return;
|
||||||
QString sMeta = pro->metaModelName();
|
QString sMeta = pro->metaModelName();
|
||||||
QString sProModel = pro->modelName();
|
QString sProModel = pro->modelName();
|
||||||
if(type == GIT_itemTri)
|
|
||||||
{
|
double dX = 0.0;
|
||||||
item = new ElectricSvgItemTriangle(QRect(-15, -15, 30, 30));
|
double dY = 0.0;
|
||||||
item->setItemType(GIT_itemTri);
|
if(type == GIT_itemRect)
|
||||||
}
|
|
||||||
else if(type == GIT_itemRect)
|
|
||||||
{
|
{
|
||||||
PropertyModel model = ProjectModelManager::instance().getData()[sMeta][sProModel];
|
PropertyModel model = ProjectModelManager::instance().getData()[sMeta][sProModel];
|
||||||
QByteArray svg;
|
QByteArray svg;
|
||||||
|
|
@ -142,12 +159,21 @@ void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos)
|
||||||
svg = model.modelSetting.mapSvg.first();
|
svg = model.modelSetting.mapSvg.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pCb = new ElectricSvgItemRect(QRect(-15, -15, 30, 30),false);
|
if(width == 0 && height == 0){
|
||||||
|
dX = 30;
|
||||||
|
dY = 30;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dX = width;
|
||||||
|
dY = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pCb = new ElectricSvgItemRect(QRect(0, 0, dX, dY),false);
|
||||||
pCb->setItemType(GIT_itemRect);
|
pCb->setItemType(GIT_itemRect);
|
||||||
pCb->loadSvg(svg);
|
pCb->loadSvg(svg);
|
||||||
item = pCb;
|
item = pCb;
|
||||||
QJsonArray portArr = pro->context()["port"].toArray();
|
QJsonArray portArr = pro->context()["port"].toArray();
|
||||||
for(QJsonValueRef portJson:portArr)
|
/*for(QJsonValueRef portJson:portArr)
|
||||||
{
|
{
|
||||||
QJsonObject portObj = portJson.toObject();
|
QJsonObject portObj = portJson.toObject();
|
||||||
QString portId = portObj["portId"].toString();
|
QString portId = portObj["portId"].toString();
|
||||||
|
|
@ -156,7 +182,25 @@ void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos)
|
||||||
HandleType tye = HandleType(portObj["portType"].toInt());
|
HandleType tye = HandleType(portObj["portType"].toInt());
|
||||||
PortPos locate = PortPos(portObj["locate"].toInt());
|
PortPos locate = PortPos(portObj["locate"].toInt());
|
||||||
item->addPort(P_const,QPointF(x,y),portId,tye,locate);
|
item->addPort(P_const,QPointF(x,y),portId,tye,locate);
|
||||||
}
|
}*/
|
||||||
|
addPortsToItem_json(P_const,portArr,item);
|
||||||
|
}
|
||||||
|
else if(type == GIT_node)
|
||||||
|
{
|
||||||
|
auto pNode = new ElectricPortItem();
|
||||||
|
pNode->setItemType(GIT_node);
|
||||||
|
item = pNode;
|
||||||
|
|
||||||
|
QJsonArray portArr = pro->context()["port"].toArray();
|
||||||
|
/*for(QJsonValueRef portJson:portArr)
|
||||||
|
{
|
||||||
|
QJsonObject portObj = portJson.toObject();
|
||||||
|
QString portId = portObj["portId"].toString();
|
||||||
|
int x = portObj["x"].toInt();
|
||||||
|
int y = portObj["y"].toInt();
|
||||||
|
item->addPort(p_movable,QPointF(x,y),portId);
|
||||||
|
}*/
|
||||||
|
addPortsToItem_json(p_movable,portArr,item);
|
||||||
}
|
}
|
||||||
else if(type == GIT_bus)
|
else if(type == GIT_bus)
|
||||||
{
|
{
|
||||||
|
|
@ -169,21 +213,284 @@ void FixedPortsModel::addNodeItem(QUuid id/*,int type*/,QPointF pos)
|
||||||
svg = model.modelSetting.mapSvg.first();
|
svg = model.modelSetting.mapSvg.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pBus = new ElectricSvgItemBus(QRect(-100, -3, 200, 6));
|
if(width == 0 && height == 0){
|
||||||
|
dX = 200;
|
||||||
|
dY = 6;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dX = width;
|
||||||
|
dY = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pBus = new ElectricSvgItemBus(QRect(0, 0, dX, dY));
|
||||||
pBus->setItemType(GIT_bus);
|
pBus->setItemType(GIT_bus);
|
||||||
pBus->loadSvg(svg);
|
pBus->loadSvg(svg);
|
||||||
item = pBus;
|
item = pBus;
|
||||||
|
|
||||||
QJsonArray portArr = pro->context()["port"].toArray();
|
QJsonArray portArr = pro->context()["port"].toArray();
|
||||||
for(QJsonValueRef portJson:portArr)
|
/*for(QJsonValueRef portJson:portArr)
|
||||||
{
|
{
|
||||||
QJsonObject portObj = portJson.toObject();
|
QJsonObject portObj = portJson.toObject();
|
||||||
QString portId = portObj["portId"].toString();
|
QString portId = portObj["portId"].toString();
|
||||||
int x = portObj["x"].toInt();
|
int x = portObj["x"].toInt();
|
||||||
int y = portObj["y"].toInt();
|
int y = portObj["y"].toInt();
|
||||||
item->addPort(p_movable,QPointF(x,y),portId);
|
item->addPort(p_movable,QPointF(x,y),portId);
|
||||||
}
|
}*/
|
||||||
|
addPortsToItem_json(p_movable,portArr,item);
|
||||||
}
|
}
|
||||||
|
else if(type == GIT_ctGroup)
|
||||||
|
{
|
||||||
|
PropertyModel model = ProjectModelManager::instance().getData()[sMeta][sProModel];
|
||||||
|
QByteArray svg;
|
||||||
|
if(model.modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[5].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = model.modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(width == 0 && height == 0){
|
||||||
|
dX = 20;
|
||||||
|
dY = 20;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dX = width;
|
||||||
|
dY = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pCt = new ElectricSvgGroupCT(QRect(0, 0, dX, dY));
|
||||||
|
pCt->setItemType(GIT_ctGroup);
|
||||||
|
pCt->loadSvg(svg);
|
||||||
|
item = pCt;
|
||||||
|
QJsonArray portArr = pro->context()["port"].toArray();
|
||||||
|
|
||||||
|
addPortsToItem_json(P_const,portArr,item);
|
||||||
|
}
|
||||||
|
else if(type == GIT_DS)
|
||||||
|
{
|
||||||
|
PropertyModel model = ProjectModelManager::instance().getData()[sMeta][sProModel];
|
||||||
|
QByteArray svg;
|
||||||
|
if(model.modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[7].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = model.modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(width == 0 && height == 0){
|
||||||
|
dX = 30;
|
||||||
|
dY = 30;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dX = width;
|
||||||
|
dY = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pDs = new ElectricSvgItemDS(QRect(0, 0, dX, dY));
|
||||||
|
pDs->setItemType(GIT_DS);
|
||||||
|
pDs->loadSvg(svg);
|
||||||
|
item = pDs;
|
||||||
|
QJsonArray portArr = pro->context()["port"].toArray();
|
||||||
|
|
||||||
|
addPortsToItem_json(P_const,portArr,item);
|
||||||
|
}
|
||||||
|
else if(type == GIT_ES)
|
||||||
|
{
|
||||||
|
PropertyModel model = ProjectModelManager::instance().getData()[sMeta][sProModel];
|
||||||
|
QByteArray svg;
|
||||||
|
if(model.modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[8].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = model.modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(width == 0 && height == 0){
|
||||||
|
dX = 30;
|
||||||
|
dY = 60;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dX = width;
|
||||||
|
dY = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pEs = new ElectricSvgItemES(QRect(0, 0, dX, dY));
|
||||||
|
pEs->setItemType(GIT_ES);
|
||||||
|
pEs->loadSvg(svg);
|
||||||
|
item = pEs;
|
||||||
|
QJsonArray portArr = pro->context()["port"].toArray();
|
||||||
|
|
||||||
|
addPortsToItem_json(P_const,portArr,item);
|
||||||
|
}
|
||||||
|
else if(type == GIT_FES)
|
||||||
|
{
|
||||||
|
PropertyModel model = ProjectModelManager::instance().getData()[sMeta][sProModel];
|
||||||
|
QByteArray svg;
|
||||||
|
if(model.modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[9].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = model.modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(width == 0 && height == 0){
|
||||||
|
dX = 30;
|
||||||
|
dY = 60;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dX = width;
|
||||||
|
dY = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pFes = new ElectricSvgItemFES(QRect(0, 0, dX, dY));
|
||||||
|
pFes->setItemType(GIT_FES);
|
||||||
|
pFes->loadSvg(svg);
|
||||||
|
item = pFes;
|
||||||
|
QJsonArray portArr = pro->context()["port"].toArray();
|
||||||
|
|
||||||
|
addPortsToItem_json(P_const,portArr,item);
|
||||||
|
}
|
||||||
|
else if(type == GIT_DTEDS)
|
||||||
|
{
|
||||||
|
PropertyModel model = ProjectModelManager::instance().getData()[sMeta][sProModel];
|
||||||
|
QByteArray svg;
|
||||||
|
if(model.modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[10].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = model.modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(width == 0 && height == 0){
|
||||||
|
dX = 60;
|
||||||
|
dY = 30;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dX = width;
|
||||||
|
dY = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pDteds = new ElectricSvgItemDTEDS(QRect(0, 0, dX, dY));
|
||||||
|
pDteds->setItemType(GIT_DTEDS);
|
||||||
|
pDteds->loadSvg(svg);
|
||||||
|
item = pDteds;
|
||||||
|
QJsonArray portArr = pro->context()["port"].toArray();
|
||||||
|
|
||||||
|
addPortsToItem_json(P_const,portArr,item);
|
||||||
|
}
|
||||||
|
else if(type == GIT_PI)
|
||||||
|
{
|
||||||
|
PropertyModel model = ProjectModelManager::instance().getData()[sMeta][sProModel];
|
||||||
|
QByteArray svg;
|
||||||
|
if(model.modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[11].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = model.modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(width == 0 && height == 0){
|
||||||
|
dX = 30;
|
||||||
|
dY = 60;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dX = width;
|
||||||
|
dY = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pPi = new ElectricSvgItemPI(QRect(0, 0, dX, dY));
|
||||||
|
pPi->setItemType(GIT_PI);
|
||||||
|
pPi->loadSvg(svg);
|
||||||
|
item = pPi;
|
||||||
|
QJsonArray portArr = pro->context()["port"].toArray();
|
||||||
|
|
||||||
|
addPortsToItem_json(P_const,portArr,item);
|
||||||
|
}
|
||||||
|
else if(type == GIT_LA)
|
||||||
|
{
|
||||||
|
PropertyModel model = ProjectModelManager::instance().getData()[sMeta][sProModel];
|
||||||
|
QByteArray svg;
|
||||||
|
if(model.modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[12].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = model.modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(width == 0 && height == 0){
|
||||||
|
dX = 30;
|
||||||
|
dY = 60;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dX = width;
|
||||||
|
dY = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pLa = new ElectricSvgItemLA(QRect(0, 0, dX, dY));
|
||||||
|
pLa->setItemType(GIT_LA);
|
||||||
|
pLa->loadSvg(svg);
|
||||||
|
item = pLa;
|
||||||
|
QJsonArray portArr = pro->context()["port"].toArray();
|
||||||
|
|
||||||
|
addPortsToItem_json(P_const,portArr,item);
|
||||||
|
}
|
||||||
|
else if(type == GIT_cableTer)
|
||||||
|
{
|
||||||
|
PropertyModel model = ProjectModelManager::instance().getData()[sMeta][sProModel];
|
||||||
|
QByteArray svg;
|
||||||
|
if(model.modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[13].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = model.modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(width == 0 && height == 0){
|
||||||
|
dX = 20;
|
||||||
|
dY = 20;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dX = width;
|
||||||
|
dY = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pCt = new ElectricSvgItemCableTer(QRect(0, 0, dX, dY));
|
||||||
|
pCt->setItemType(GIT_cableTer);
|
||||||
|
pCt->loadSvg(svg);
|
||||||
|
item = pCt;
|
||||||
|
QJsonArray portArr = pro->context()["port"].toArray();
|
||||||
|
|
||||||
|
addPortsToItem_json(P_const,portArr,item);
|
||||||
|
}
|
||||||
|
else if(type == GIT_cableEnd)
|
||||||
|
{
|
||||||
|
PropertyModel model = ProjectModelManager::instance().getData()[sMeta][sProModel];
|
||||||
|
QByteArray svg;
|
||||||
|
if(model.modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[14].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = model.modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(width == 0 && height == 0){
|
||||||
|
dX = 20;
|
||||||
|
dY = 20;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dX = width;
|
||||||
|
dY = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pCe = new ElectricSvgItemCableEnd(QRect(0, 0, dX, dY));
|
||||||
|
pCe->setItemType(GIT_cableEnd);
|
||||||
|
pCe->loadSvg(svg);
|
||||||
|
item = pCe;
|
||||||
|
QJsonArray portArr = pro->context()["port"].toArray();
|
||||||
|
|
||||||
|
addPortsToItem_json(P_const,portArr,item);
|
||||||
|
}
|
||||||
|
|
||||||
if(item)
|
if(item)
|
||||||
{
|
{
|
||||||
item->setItemId(id);
|
item->setItemId(id);
|
||||||
|
|
@ -710,6 +1017,25 @@ void FixedPortsModel::startHttpRequest()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FixedPortsModel::addPortsToItem_json(PortState sta,QJsonArray jArr,GraphicsProjectModelItem* pItem)
|
||||||
|
{
|
||||||
|
for(QJsonValueRef portJson:jArr)
|
||||||
|
{
|
||||||
|
QJsonObject portObj = portJson.toObject();
|
||||||
|
QString portId = portObj["portId"].toString();
|
||||||
|
int x = portObj["x"].toInt();
|
||||||
|
int y = portObj["y"].toInt();
|
||||||
|
if(sta == P_const){
|
||||||
|
HandleType tye = HandleType(portObj["portType"].toInt());
|
||||||
|
PortPos locate = PortPos(portObj["locate"].toInt());
|
||||||
|
pItem->addPort(P_const,QPointF(x,y),portId,tye,locate);
|
||||||
|
}
|
||||||
|
else if(sta == p_movable){
|
||||||
|
pItem->addPort(p_movable,QPointF(x,y),portId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QWidget* FixedPortsModel::getTopWidget()
|
QWidget* FixedPortsModel::getTopWidget()
|
||||||
{
|
{
|
||||||
return dynamic_cast<QWidget*>(_widget);
|
return dynamic_cast<QWidget*>(_widget);
|
||||||
|
|
@ -940,7 +1266,8 @@ void FixedPortsModel::generateProjectModel(const QString& sPageName,QList<Graphi
|
||||||
{
|
{
|
||||||
BaseModelProperty* pBase = dynamic_cast<BaseModelProperty*>(pBaseItem->getProperty());
|
BaseModelProperty* pBase = dynamic_cast<BaseModelProperty*>(pBaseItem->getProperty());
|
||||||
if(pBase->type() == 8){ //电缆
|
if(pBase->type() == 8){ //电缆
|
||||||
QUuid id = QUuid::createUuid();
|
//QUuid id = QUuid::createUuid();
|
||||||
|
QUuid id = pBase->uuid();
|
||||||
BaseProperty* pData = pProPanel->getModelController()->addNodeData(id,pBase->type(),pBase->name(),pBase->modelName());
|
BaseProperty* pData = pProPanel->getModelController()->addNodeData(id,pBase->type(),pBase->name(),pBase->modelName());
|
||||||
if(pData)
|
if(pData)
|
||||||
{
|
{
|
||||||
|
|
@ -982,7 +1309,13 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
||||||
pPro->setSourceItemId(pBaseItem->itemId().toString()); //设置被哪个对象生成
|
pPro->setSourceItemId(pBaseItem->itemId().toString()); //设置被哪个对象生成
|
||||||
pPro->setMetaModelName(pBase->metaModelName()); //传递基模名
|
pPro->setMetaModelName(pBase->metaModelName()); //传递基模名
|
||||||
int type = pBase->graphicsType();
|
int type = pBase->graphicsType();
|
||||||
if(type == GIT_baseBus)
|
if(type == GIT_baseNode)
|
||||||
|
{
|
||||||
|
auto pNode = new ElectricPortItem();
|
||||||
|
pProItem = pNode;
|
||||||
|
pProItem->setItemType(GIT_node);
|
||||||
|
}
|
||||||
|
else if(type == GIT_baseBus)
|
||||||
{
|
{
|
||||||
QByteArray svg;
|
QByteArray svg;
|
||||||
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
||||||
|
|
@ -992,7 +1325,7 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
||||||
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
||||||
}
|
}
|
||||||
QRectF rec = pBaseItem->boundingRect();
|
QRectF rec = pBaseItem->boundingRect();
|
||||||
auto pBus = new ElectricSvgItemRect(rec.toRect());
|
auto pBus = new ElectricSvgItemBus(rec.toRect());
|
||||||
pBus->loadSvg(svg);
|
pBus->loadSvg(svg);
|
||||||
pProItem = pBus;
|
pProItem = pBus;
|
||||||
pProItem->setItemType(GIT_bus);
|
pProItem->setItemType(GIT_bus);
|
||||||
|
|
@ -1012,6 +1345,173 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
||||||
pProItem = pBreaker;
|
pProItem = pBreaker;
|
||||||
pProItem->setItemType(GIT_itemRect);
|
pProItem->setItemType(GIT_itemRect);
|
||||||
}
|
}
|
||||||
|
else if(type == GIT_baseCT)
|
||||||
|
{
|
||||||
|
QByteArray svg;
|
||||||
|
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[5].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
QRectF rec = pBaseItem->boundingRect();
|
||||||
|
auto pCtGroup = new ElectricSvgGroupCT(rec.toRect());
|
||||||
|
pCtGroup->setGroupType(1);
|
||||||
|
pCtGroup->setLayout(1);
|
||||||
|
pCtGroup->loadSvg(svg);
|
||||||
|
pProItem = pCtGroup;
|
||||||
|
pProItem->setItemType(GIT_ctGroup);
|
||||||
|
}
|
||||||
|
else if(type == GIT_baseES)
|
||||||
|
{
|
||||||
|
QByteArray svg;
|
||||||
|
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[8].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
QRectF rec = pBaseItem->boundingRect();
|
||||||
|
auto pEs = new ElectricSvgItemES(rec.toRect());
|
||||||
|
pEs->loadSvg(svg);
|
||||||
|
pProItem = pEs;
|
||||||
|
pProItem->setItemType(GIT_ES);
|
||||||
|
}
|
||||||
|
else if(type == GIT_baseDS)
|
||||||
|
{
|
||||||
|
QByteArray svg;
|
||||||
|
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[7].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
QRectF rec = pBaseItem->boundingRect();
|
||||||
|
auto pDs = new ElectricSvgItemDS(rec.toRect());
|
||||||
|
pDs->loadSvg(svg);
|
||||||
|
pProItem = pDs;
|
||||||
|
pProItem->setItemType(GIT_DS);
|
||||||
|
}
|
||||||
|
else if(type == GIT_baseFES)
|
||||||
|
{
|
||||||
|
QByteArray svg;
|
||||||
|
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[9].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
QRectF rec = pBaseItem->boundingRect();
|
||||||
|
auto pFes = new ElectricSvgItemFES(rec.toRect());
|
||||||
|
pFes->loadSvg(svg);
|
||||||
|
pProItem = pFes;
|
||||||
|
pProItem->setItemType(GIT_FES);
|
||||||
|
}
|
||||||
|
else if(type == GIT_baseDTEDS)
|
||||||
|
{
|
||||||
|
QByteArray svg;
|
||||||
|
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[10].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
QRectF rec = pBaseItem->boundingRect();
|
||||||
|
auto pDteds = new ElectricSvgItemDTEDS(rec.toRect());
|
||||||
|
pDteds->loadSvg(svg);
|
||||||
|
pProItem = pDteds;
|
||||||
|
pProItem->setItemType(GIT_DTEDS);
|
||||||
|
}
|
||||||
|
else if(type == GIT_basePI)
|
||||||
|
{
|
||||||
|
QByteArray svg;
|
||||||
|
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[11].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
QRectF rec = pBaseItem->boundingRect();
|
||||||
|
auto pPi = new ElectricSvgItemPI(rec.toRect());
|
||||||
|
pPi->loadSvg(svg);
|
||||||
|
pProItem = pPi;
|
||||||
|
pProItem->setItemType(GIT_PI);
|
||||||
|
}
|
||||||
|
else if(type == GIT_baseLightningArrester)
|
||||||
|
{
|
||||||
|
QByteArray svg;
|
||||||
|
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[12].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
QRectF rec = pBaseItem->boundingRect();
|
||||||
|
auto pLa = new ElectricSvgItemLA(rec.toRect());
|
||||||
|
pLa->loadSvg(svg);
|
||||||
|
pProItem = pLa;
|
||||||
|
pProItem->setItemType(GIT_LA);
|
||||||
|
}
|
||||||
|
else if(type == GIT_baseCableTer)
|
||||||
|
{
|
||||||
|
QByteArray svg;
|
||||||
|
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[13].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
QRectF rec = pBaseItem->boundingRect();
|
||||||
|
auto pCt = new ElectricSvgItemCableTer(rec.toRect());
|
||||||
|
pCt->loadSvg(svg);
|
||||||
|
pProItem = pCt;
|
||||||
|
pProItem->setItemType(GIT_cableTer);
|
||||||
|
}
|
||||||
|
else if(type == GIT_baseCableEnd)
|
||||||
|
{
|
||||||
|
QByteArray svg;
|
||||||
|
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[14].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
QRectF rec = pBaseItem->boundingRect();
|
||||||
|
auto pCe = new ElectricSvgItemCableEnd(rec.toRect());
|
||||||
|
pCe->loadSvg(svg);
|
||||||
|
pProItem = pCe;
|
||||||
|
pProItem->setItemType(GIT_cableEnd);
|
||||||
|
}
|
||||||
|
else if(type == GIT_base2wTransformer)
|
||||||
|
{
|
||||||
|
QByteArray svg;
|
||||||
|
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[15].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
QRectF rec = pBaseItem->boundingRect();
|
||||||
|
auto p2w = new ElectricSvgItem2wTransformer(rec.toRect());
|
||||||
|
p2w->loadSvg(svg);
|
||||||
|
pProItem = p2w;
|
||||||
|
pProItem->setItemType(GIT_2wTransformer);
|
||||||
|
}
|
||||||
|
else if(type == GIT_base3wTransformer)
|
||||||
|
{
|
||||||
|
QByteArray svg;
|
||||||
|
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
||||||
|
svg = DataBase::GetInstance()->ModelType()[16].icon;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
||||||
|
}
|
||||||
|
QRectF rec = pBaseItem->boundingRect();
|
||||||
|
auto p3w = new ElectricSvgItem3wTransformer(rec.toRect());
|
||||||
|
p3w->loadSvg(svg);
|
||||||
|
pProItem = p3w;
|
||||||
|
pProItem->setItemType(GIT_3wTransformer);
|
||||||
|
}
|
||||||
else if(type == GIT_baseLine)
|
else if(type == GIT_baseLine)
|
||||||
{
|
{
|
||||||
pProItem = new ElectricConnectLineItem();
|
pProItem = new ElectricConnectLineItem();
|
||||||
|
|
@ -1027,7 +1527,9 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
||||||
for(auto& baseTer:lstBase)
|
for(auto& baseTer:lstBase)
|
||||||
{
|
{
|
||||||
QUuid uid = QUuid::createUuid();
|
QUuid uid = QUuid::createUuid();
|
||||||
PowerTerminal* proTer = TopologyManager::instance().createTerminal(pEntity->id(),baseTer->type(),"",baseTer->relativePosition(),uid.toString(),ModelFunctionType::ProjectModel);
|
double dPerX = baseTer->getPerX();
|
||||||
|
double dPerY = baseTer->getPerY();
|
||||||
|
PowerTerminal* proTer = TopologyManager::instance().createTerminal(pEntity->id(),baseTer->type(),"",baseTer->relativePosition(),uid.toString(),ModelFunctionType::ProjectModel,dPerX,dPerY);
|
||||||
proTer->setGenerateBy(baseTer->id());
|
proTer->setGenerateBy(baseTer->id());
|
||||||
if(proTer->type() == TerminalType::PowerConnect)
|
if(proTer->type() == TerminalType::PowerConnect)
|
||||||
{
|
{
|
||||||
|
|
@ -1062,7 +1564,7 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
||||||
{
|
{
|
||||||
locate = P_top;
|
locate = P_top;
|
||||||
}
|
}
|
||||||
pProItem->addPort(P_const,pos,proTer->id(),typ,locate);
|
pProItem->addPort(P_const,pos,proTer->id(),typ,locate,dPerX,dPerY);
|
||||||
|
|
||||||
ItemPort* pPort = pProItem->getPortById(proTer->id());
|
ItemPort* pPort = pProItem->getPortById(proTer->id());
|
||||||
pPort->setSourcePortId(baseTer->id());
|
pPort->setSourcePortId(baseTer->id());
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
#include "graphicsItem/electricPortItem.h"
|
||||||
|
#include "graphicsItem/itemPort.h"
|
||||||
|
#include "baseProperty.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QJsonArray>
|
||||||
|
|
||||||
|
ElectricPortItem::ElectricPortItem(QGraphicsItem *parent)
|
||||||
|
: GraphicsProjectModelItem(parent)
|
||||||
|
{
|
||||||
|
m_boundingRect = QRectF(-1,-1,2,2);
|
||||||
|
m_pen = QPen(Qt::black);
|
||||||
|
m_brush = QBrush(Qt::black);
|
||||||
|
setHandleVisible(false);
|
||||||
|
setFunctionHandleIfShow(false);
|
||||||
|
setFunctionHandleEnaable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElectricPortItem::~ElectricPortItem()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF ElectricPortItem::boundingRect() const
|
||||||
|
{
|
||||||
|
return m_boundingRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricPortItem::updateConnectData()
|
||||||
|
{
|
||||||
|
QJsonObject obj;
|
||||||
|
QJsonArray arr;
|
||||||
|
if(_property)
|
||||||
|
{
|
||||||
|
for(auto ptr:m_mapPort)
|
||||||
|
{
|
||||||
|
//if(ptr->connected())
|
||||||
|
{
|
||||||
|
QJsonObject port;
|
||||||
|
port["portId"] = ptr->getId();
|
||||||
|
auto pLine = ptr->getConnectPtr();
|
||||||
|
port["x"] = ptr->pos().x();
|
||||||
|
port["y"] = ptr->pos().y();
|
||||||
|
port["portType"] = ptr->getType();
|
||||||
|
arr.push_back(port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
obj["port"] = arr;
|
||||||
|
obj["metaModel"] = _property->metaModelName();
|
||||||
|
_property->setContext(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricPortItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
painter->setBrush(m_brush);
|
||||||
|
painter->drawEllipse(m_boundingRect);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,134 @@
|
||||||
|
#include "graphicsItem/electricSvgGroup.h"
|
||||||
|
#include "graphicsItem/electricSvgItem.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
ElectricSvgGroup::ElectricSvgGroup(const QRect &rect,QGraphicsItem *parent)
|
||||||
|
: GraphicsProjectModelGroup(parent)
|
||||||
|
{
|
||||||
|
m_lastBoudingRect = rect;
|
||||||
|
m_boundingRect = rect;
|
||||||
|
m_dWidth = rect.width();
|
||||||
|
m_dHeight = rect.height();
|
||||||
|
}
|
||||||
|
|
||||||
|
ElectricSvgGroup::~ElectricSvgGroup()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QPainterPath ElectricSvgGroup::shape()
|
||||||
|
{
|
||||||
|
QPainterPath path;
|
||||||
|
path.addRect(m_boundingRect);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgGroup::updateCoordinate() //当执行了resie和editShape函数后,boundingRect发生了变换,需要将item的原点(以中心点为原点)校准至boundingRect.center()
|
||||||
|
{
|
||||||
|
if (!parentItem())
|
||||||
|
{
|
||||||
|
QPointF pt1, pt2, delta;
|
||||||
|
pt1 = mapToScene(QPointF(0, 0));
|
||||||
|
pt2 = mapToScene(m_boundingRect.center());
|
||||||
|
delta = pt1 - pt2;
|
||||||
|
|
||||||
|
prepareGeometryChange();
|
||||||
|
//将boundingRect设置成中心点和原点(也是默认变换原点),这样三点重合,有助于简化计算
|
||||||
|
m_boundingRect = QRectF(-m_dWidth / 2, -m_dHeight / 2, m_dWidth, m_dHeight);
|
||||||
|
//setTransformOriginPoint(m_boundingRect.center()); //变换中心默认为item的(0,0)点,所以不执行这句话也没有问题
|
||||||
|
//更新bouondingRect后重回会显示位置会有变化,需要做对应的移动
|
||||||
|
moveBy(-delta.x(), -delta.y());
|
||||||
|
updateHandles();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_lastBoudingRect = m_boundingRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgGroup::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
painter->setPen(m_pen);
|
||||||
|
painter->setBrush(m_brush);
|
||||||
|
if(m_state == S_prepareConnect)
|
||||||
|
{
|
||||||
|
painter->setPen(QPen(QColor(255,51,153,180)));
|
||||||
|
painter->drawLine(m_beginConnectPoint,m_endConnectPoint);
|
||||||
|
}
|
||||||
|
if(m_touched)
|
||||||
|
{
|
||||||
|
painter->setPen(QPen(QColor(238,58,140,220)));
|
||||||
|
painter->drawRect(m_boundingRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (option->state & QStyle::State_Selected) //是选中状态,绘制选中框
|
||||||
|
{
|
||||||
|
renderSelectBackground(painter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgGroup::resize(int nHandle,double dSX, double dSY, const QPointF& basePoint)
|
||||||
|
{
|
||||||
|
switch (nHandle)
|
||||||
|
{
|
||||||
|
case H_left:
|
||||||
|
case H_right:
|
||||||
|
dSY = 1; //拖拽的是左点右点,为水平缩放,忽略垂直变化
|
||||||
|
break;
|
||||||
|
case H_top:
|
||||||
|
case H_bottom:
|
||||||
|
dSX = 1; //拖拽的是顶点底点,为垂直缩放,忽略水平变化
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTransform trans;
|
||||||
|
//缩放是以图元原点(中心)位置为基准,所以每帧都先移动移动到想要的基准点,缩放之后再移回
|
||||||
|
trans.translate(basePoint.x(), basePoint.y());
|
||||||
|
trans.scale(dSX, dSY);
|
||||||
|
trans.translate(-basePoint.x(), -basePoint.y());
|
||||||
|
|
||||||
|
prepareGeometryChange();
|
||||||
|
m_boundingRect = trans.mapRect(m_lastBoudingRect);
|
||||||
|
m_dWidth = m_boundingRect.width();
|
||||||
|
m_dHeight = m_boundingRect.height();
|
||||||
|
updateHandles();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgGroup::move(const QPointF& point)
|
||||||
|
{
|
||||||
|
moveBy(point.x(), point.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgGroup::loadSvg(const QByteArray& data)
|
||||||
|
{
|
||||||
|
if(_groupType == 0){ //联合
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(_groupType == 1){ //聚合
|
||||||
|
m_curSvg = data; //保存图片到组
|
||||||
|
for(auto pItem:m_childItems){
|
||||||
|
auto pSvg = dynamic_cast<ElectricSvgItem*>(pItem);
|
||||||
|
if(pSvg){
|
||||||
|
pSvg->loadSvg(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgGroup::addSvgItem(ElectricSvgItem* item)
|
||||||
|
{
|
||||||
|
item->setParentItem(this); // 关键:设置父项
|
||||||
|
m_childItems.append(item);
|
||||||
|
if(!m_curSvg.isEmpty())
|
||||||
|
item->loadSvg(m_curSvg);
|
||||||
|
updateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgGroup::editShape(int nHandle,const QPointF& ptMouse)
|
||||||
|
{
|
||||||
|
prepareGeometryChange();
|
||||||
|
updateHandles();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
#include "graphicsItem/electricSvgGroupCT.h"
|
||||||
|
#include "graphicsItem/electricSvgItemCT.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
ElectricSvgGroupCT::ElectricSvgGroupCT(const QRect &rect, QGraphicsItem *parent)
|
||||||
|
: ElectricSvgGroup(rect,parent)
|
||||||
|
{
|
||||||
|
setHandleIfShow(H_textCaption,false);
|
||||||
|
setHandleIfShow(H_textCurrent,false);
|
||||||
|
setHandleIfShow(h_textVoltage,false);
|
||||||
|
setHandleVisible(false);
|
||||||
|
setFunctionHandleIfShow(false);
|
||||||
|
setFunctionHandleEnaable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElectricSvgGroupCT::~ElectricSvgGroupCT()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgGroupCT::setupFinish(int nType,int nSize)
|
||||||
|
{
|
||||||
|
_nType = nType;
|
||||||
|
_nSize = nSize;
|
||||||
|
updateItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgGroupCT::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
ElectricSvgGroup::paint(painter,option,widget);
|
||||||
|
|
||||||
|
if(m_childItems.isEmpty()){ //无对象时绘制提示框
|
||||||
|
QPen pen(Qt::darkYellow);
|
||||||
|
pen.setStyle(Qt::DotLine);
|
||||||
|
painter->setPen(pen);
|
||||||
|
painter->drawRect(m_boundingRect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgGroupCT::updateItem()
|
||||||
|
{
|
||||||
|
for(auto pItem:m_childItems){
|
||||||
|
delete pItem;
|
||||||
|
}
|
||||||
|
m_childItems.clear();
|
||||||
|
|
||||||
|
QRect rec(0,0,90,30);
|
||||||
|
|
||||||
|
if(_nType == 1){
|
||||||
|
for(int i = 0;i < _nSize;++i){
|
||||||
|
ElectricSvgItemCT* p = new ElectricSvgItemCT(rec);
|
||||||
|
p->setItemType(_nType);
|
||||||
|
p->setMoveable(false);
|
||||||
|
addSvgItem(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(_nType == 0){
|
||||||
|
ElectricSvgItemCT* p = new ElectricSvgItemCT(rec);
|
||||||
|
p->setItemType(_nType);
|
||||||
|
p->setMoveable(false);
|
||||||
|
addSvgItem(p);
|
||||||
|
}
|
||||||
|
updateTerPos();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -13,6 +13,11 @@ ElectricSvgItem::ElectricSvgItem(const QRect &rect, bool autoGenPort,QGraphicsIt
|
||||||
m_boundingRect = rect;
|
m_boundingRect = rect;
|
||||||
m_dWidth = rect.width();
|
m_dWidth = rect.width();
|
||||||
m_dHeight = rect.height();
|
m_dHeight = rect.height();
|
||||||
|
|
||||||
|
setHandleIfShow(H_textCaption,false);
|
||||||
|
setHandleVisible(false);
|
||||||
|
setFunctionHandleIfShow(false);
|
||||||
|
setFunctionHandleEnaable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ElectricSvgItem::~ElectricSvgItem()
|
ElectricSvgItem::~ElectricSvgItem()
|
||||||
|
|
@ -23,8 +28,6 @@ ElectricSvgItem::~ElectricSvgItem()
|
||||||
QPainterPath ElectricSvgItem::shape()
|
QPainterPath ElectricSvgItem::shape()
|
||||||
{
|
{
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
double dHandleX = 0.0;
|
|
||||||
double dHandleY = 0.0;
|
|
||||||
path.addRect(m_boundingRect);
|
path.addRect(m_boundingRect);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "graphicsItem/electricSvgItem2wTransformer.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
ElectricSvgItem2wTransformer::ElectricSvgItem2wTransformer(const QRect &rect, QGraphicsItem *parent)
|
||||||
|
: ElectricSvgItem(rect,parent)
|
||||||
|
{
|
||||||
|
setHandleIfShow(H_textCaption,false);
|
||||||
|
setHandleVisible(false);
|
||||||
|
setFunctionHandleIfShow(false);
|
||||||
|
setFunctionHandleEnaable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElectricSvgItem2wTransformer::~ElectricSvgItem2wTransformer()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgItem2wTransformer::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
ElectricSvgItem::paint(painter,option,widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "graphicsItem/electricSvgItem3wTransformer.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
ElectricSvgItem3wTransformer::ElectricSvgItem3wTransformer(const QRect &rect, QGraphicsItem *parent)
|
||||||
|
: ElectricSvgItem(rect,parent)
|
||||||
|
{
|
||||||
|
setHandleIfShow(H_textCaption,false);
|
||||||
|
setHandleVisible(false);
|
||||||
|
setFunctionHandleIfShow(false);
|
||||||
|
setFunctionHandleEnaable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElectricSvgItem3wTransformer::~ElectricSvgItem3wTransformer()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgItem3wTransformer::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
ElectricSvgItem::paint(painter,option,widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
#include "graphicsItem/electricSvgItemCT.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#include <QSvgRenderer>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
ElectricSvgItemCT::ElectricSvgItemCT(const QRect &rect, QGraphicsItem *parent)
|
||||||
|
: ElectricSvgItem(rect,parent)
|
||||||
|
{
|
||||||
|
/*setHandleIfShow(H_textCaption,false);
|
||||||
|
setHandleIfShow(H_textCurrent,false);
|
||||||
|
setHandleIfShow(h_textVoltage,false);
|
||||||
|
setHandleVisible(false);
|
||||||
|
setFunctionHandleIfShow(false);
|
||||||
|
setFunctionHandleEnaable(false);*/
|
||||||
|
|
||||||
|
setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||||
|
setFlag(QGraphicsItem::ItemIsFocusable, false);
|
||||||
|
setAcceptedMouseButtons(Qt::NoButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElectricSvgItemCT::~ElectricSvgItemCT()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgItemCT::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
if (!m_pRender || !m_pRender->isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 计算每个图形的宽度
|
||||||
|
qreal singleWidth = m_boundingRect.width() / 3.0;
|
||||||
|
|
||||||
|
// 绘制第一个图形
|
||||||
|
if(_itemType == 1){
|
||||||
|
QRectF rect1(m_boundingRect.x(), m_boundingRect.y(), singleWidth, m_boundingRect.height());
|
||||||
|
m_pRender->render(painter, rect1);
|
||||||
|
|
||||||
|
// 绘制第二个图形
|
||||||
|
QRectF rect2(m_boundingRect.x() + singleWidth, m_boundingRect.y(), singleWidth, m_boundingRect.height());
|
||||||
|
m_pRender->render(painter, rect2);
|
||||||
|
|
||||||
|
// 绘制第三个图形
|
||||||
|
QRectF rect3(m_boundingRect.x() + 2 * singleWidth, m_boundingRect.y(), singleWidth, m_boundingRect.height());
|
||||||
|
m_pRender->render(painter, rect3);
|
||||||
|
}
|
||||||
|
else if(_itemType == 0){
|
||||||
|
QRectF rect(m_boundingRect.x() + singleWidth, m_boundingRect.y(), singleWidth, m_boundingRect.height());
|
||||||
|
m_pRender->render(painter, rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "graphicsItem/electricSvgItemCableEnd.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
ElectricSvgItemCableEnd::ElectricSvgItemCableEnd(const QRect &rect, QGraphicsItem *parent)
|
||||||
|
: ElectricSvgItem(rect,parent)
|
||||||
|
{
|
||||||
|
setHandleIfShow(H_textCaption,false);
|
||||||
|
setHandleVisible(false);
|
||||||
|
setFunctionHandleIfShow(false);
|
||||||
|
setFunctionHandleEnaable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElectricSvgItemCableEnd::~ElectricSvgItemCableEnd()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgItemCableEnd::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
ElectricSvgItem::paint(painter,option,widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "graphicsItem/electricSvgItemCableTer.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
ElectricSvgItemCableTer::ElectricSvgItemCableTer(const QRect &rect, QGraphicsItem *parent)
|
||||||
|
: ElectricSvgItem(rect,parent)
|
||||||
|
{
|
||||||
|
setHandleIfShow(H_textCaption,false);
|
||||||
|
setHandleVisible(false);
|
||||||
|
setFunctionHandleIfShow(false);
|
||||||
|
setFunctionHandleEnaable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElectricSvgItemCableTer::~ElectricSvgItemCableTer()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgItemCableTer::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
ElectricSvgItem::paint(painter,option,widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "graphicsItem/electricSvgItemDS.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
ElectricSvgItemDS::ElectricSvgItemDS(const QRect &rect, QGraphicsItem *parent)
|
||||||
|
: ElectricSvgItem(rect,parent)
|
||||||
|
{
|
||||||
|
setHandleIfShow(H_textCaption,false);
|
||||||
|
setHandleVisible(false);
|
||||||
|
setFunctionHandleIfShow(false);
|
||||||
|
setFunctionHandleEnaable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElectricSvgItemDS::~ElectricSvgItemDS()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgItemDS::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
ElectricSvgItem::paint(painter,option,widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "graphicsItem/electricSvgItemDTEDS.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
ElectricSvgItemDTEDS::ElectricSvgItemDTEDS(const QRect &rect, QGraphicsItem *parent)
|
||||||
|
: ElectricSvgItem(rect,parent)
|
||||||
|
{
|
||||||
|
setHandleIfShow(H_textCaption,false);
|
||||||
|
setHandleVisible(false);
|
||||||
|
setFunctionHandleIfShow(false);
|
||||||
|
setFunctionHandleEnaable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElectricSvgItemDTEDS::~ElectricSvgItemDTEDS()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgItemDTEDS::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
ElectricSvgItem::paint(painter,option,widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "graphicsItem/electricSvgItemES.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
ElectricSvgItemES::ElectricSvgItemES(const QRect &rect, QGraphicsItem *parent)
|
||||||
|
: ElectricSvgItem(rect,parent)
|
||||||
|
{
|
||||||
|
setHandleIfShow(H_textCaption,false);
|
||||||
|
setHandleVisible(false);
|
||||||
|
setFunctionHandleIfShow(false);
|
||||||
|
setFunctionHandleEnaable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElectricSvgItemES::~ElectricSvgItemES()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgItemES::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
ElectricSvgItem::paint(painter,option,widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "graphicsItem/electricSvgItemFES.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
ElectricSvgItemFES::ElectricSvgItemFES(const QRect &rect, QGraphicsItem *parent)
|
||||||
|
: ElectricSvgItem(rect,parent)
|
||||||
|
{
|
||||||
|
setHandleIfShow(H_textCaption,false);
|
||||||
|
setHandleVisible(false);
|
||||||
|
setFunctionHandleIfShow(false);
|
||||||
|
setFunctionHandleEnaable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElectricSvgItemFES::~ElectricSvgItemFES()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgItemFES::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
ElectricSvgItem::paint(painter,option,widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "graphicsItem/electricSvgItemLA.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
ElectricSvgItemLA::ElectricSvgItemLA(const QRect &rect, QGraphicsItem *parent)
|
||||||
|
: ElectricSvgItem(rect,parent)
|
||||||
|
{
|
||||||
|
setHandleIfShow(H_textCaption,false);
|
||||||
|
setHandleVisible(false);
|
||||||
|
setFunctionHandleIfShow(false);
|
||||||
|
setFunctionHandleEnaable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElectricSvgItemLA::~ElectricSvgItemLA()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgItemLA::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
ElectricSvgItem::paint(painter,option,widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
#include "graphicsItem/electricSvgItemPI.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
#include <QSvgRenderer>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
|
ElectricSvgItemPI::ElectricSvgItemPI(const QRect &rect, QGraphicsItem *parent)
|
||||||
|
: ElectricSvgItem(rect,parent)
|
||||||
|
{
|
||||||
|
setHandleIfShow(H_textCaption,false);
|
||||||
|
setHandleVisible(false);
|
||||||
|
setFunctionHandleIfShow(false);
|
||||||
|
setFunctionHandleEnaable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ElectricSvgItemPI::~ElectricSvgItemPI()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElectricSvgItemPI::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
|
{
|
||||||
|
ElectricSvgItem::paint(painter,option,widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -28,12 +28,28 @@ GraphicsBaseItem::GraphicsBaseItem(const GraphicsBaseItem& obj)
|
||||||
,_property(nullptr)
|
,_property(nullptr)
|
||||||
,_pEntity(nullptr)
|
,_pEntity(nullptr)
|
||||||
{
|
{
|
||||||
|
m_type = T_item;
|
||||||
|
_itemChanged = false;
|
||||||
|
m_touched = false;
|
||||||
|
|
||||||
|
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
|
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
|
|
||||||
m_lastPoint = obj.m_lastPoint;
|
m_lastPoint = obj.m_lastPoint;
|
||||||
m_touched = obj.m_touched;
|
m_touched = obj.m_touched;
|
||||||
m_boundingRect_selected = obj.m_boundingRect_selected;
|
m_boundingRect_selected = obj.m_boundingRect_selected;
|
||||||
|
|
||||||
|
PortState tpe;
|
||||||
|
if(m_Itemtype == GIT_baseNode || m_Itemtype == GIT_baseBus){
|
||||||
|
tpe = p_movable;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
tpe = P_const;
|
||||||
|
}
|
||||||
|
|
||||||
for(auto& port:obj.m_mapPort){
|
for(auto& port:obj.m_mapPort){
|
||||||
addPort(p_movable,port->pos(),port->getId(),port->getType(),port->portPos());
|
addPort(tpe,port->pos(),port->getId(),port->getType(),port->portPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,7 +66,7 @@ GraphicsBaseItem::~GraphicsBaseItem()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int GraphicsBaseItem::addPort(PortState typ,QPointF vec,QString id,HandleType hType,PortPos pos)
|
int GraphicsBaseItem::addPort(PortState typ,QPointF vec,QString id,HandleType hType,PortPos pos,double dXPercent,double dYPercent)
|
||||||
{
|
{
|
||||||
int ntagId = -1;
|
int ntagId = -1;
|
||||||
for(ntagId = H_connect;ntagId < 999;++ntagId) //添加到未占用位置
|
for(ntagId = H_connect;ntagId < 999;++ntagId) //添加到未占用位置
|
||||||
|
|
@ -75,11 +91,13 @@ int GraphicsBaseItem::addPort(PortState typ,QPointF vec,QString id,HandleType hT
|
||||||
{
|
{
|
||||||
pPort->setType(hType);
|
pPort->setType(hType);
|
||||||
pPort->setPortPos(pos);
|
pPort->setPortPos(pos);
|
||||||
|
pPort->setXPercent(dXPercent);
|
||||||
|
pPort->setYPercent(dYPercent);
|
||||||
}
|
}
|
||||||
pPort->setTag(ntagId);
|
pPort->setTag(ntagId);
|
||||||
m_vecHanle.insert(ntagId,pPort);
|
m_vecHanle.insert(ntagId,pPort);
|
||||||
pPort->setPos(vec);
|
|
||||||
pPort->setParent(this);
|
pPort->setParent(this);
|
||||||
|
pPort->setPos(vec);
|
||||||
|
|
||||||
m_mapPort.insert(pPort->getId(),pPort);
|
m_mapPort.insert(pPort->getId(),pPort);
|
||||||
return ntagId;
|
return ntagId;
|
||||||
|
|
@ -202,7 +220,7 @@ void GraphicsBaseItem::initialPortsByDatabase(int nComponentTypeId)
|
||||||
int portType = node["portType"].toInt();
|
int portType = node["portType"].toInt();
|
||||||
int portLocate = node["portLocate"].toInt();
|
int portLocate = node["portLocate"].toInt();
|
||||||
|
|
||||||
addPort(PortState(movable),QPointF(boundingRect().left() + boundingRect().width() * dX, boundingRect().top()+boundingRect().height() *dY),QUuid::createUuid().toString(),HandleType(portType),PortPos(portLocate));
|
addPort(PortState(movable),QPointF(boundingRect().left() + boundingRect().width() * dX, boundingRect().top()+boundingRect().height() *dY),QUuid::createUuid().toString(),HandleType(portType),PortPos(portLocate),dX,dY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -245,6 +263,53 @@ QVariant GraphicsBaseModelItem::itemChange(QGraphicsItem::GraphicsItemChange cha
|
||||||
return QGraphicsItem::itemChange(change, value);
|
return QGraphicsItem::itemChange(change, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/********************************基模组*************************************/
|
||||||
|
|
||||||
|
GraphicsBaseModelGroup::GraphicsBaseModelGroup(QGraphicsItem *parent)
|
||||||
|
:GraphicsBaseModelItem(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
GraphicsBaseModelGroup::GraphicsBaseModelGroup(const GraphicsBaseModelGroup& obj)
|
||||||
|
:GraphicsBaseModelItem(obj)
|
||||||
|
{
|
||||||
|
_layout = obj._layout;
|
||||||
|
}
|
||||||
|
GraphicsBaseModelGroup::~GraphicsBaseModelGroup()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GraphicsBaseModelGroup* GraphicsBaseModelGroup::clone() const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicsBaseModelGroup::addItem(GraphicsBaseModelItem* item)
|
||||||
|
{
|
||||||
|
item->setParentItem(this); // 关键:设置父项
|
||||||
|
m_childItems.append(item);
|
||||||
|
updateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF GraphicsBaseModelGroup::boundingRect() const
|
||||||
|
{
|
||||||
|
QRectF rect;
|
||||||
|
for (auto* child : childItems()) {
|
||||||
|
rect |= child->boundingRect().translated(child->pos());
|
||||||
|
}
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
void GraphicsBaseModelGroup::updateLayout()
|
||||||
|
{
|
||||||
|
if(_layout == 0){ //横
|
||||||
|
|
||||||
|
}
|
||||||
|
else{ //纵
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/********************************工程模**************************************/
|
/********************************工程模**************************************/
|
||||||
|
|
||||||
GraphicsProjectModelItem::GraphicsProjectModelItem(QGraphicsItem *parent)
|
GraphicsProjectModelItem::GraphicsProjectModelItem(QGraphicsItem *parent)
|
||||||
|
|
@ -271,13 +336,13 @@ GraphicsProjectModelItem::GraphicsProjectModelItem(QGraphicsItem *parent)
|
||||||
HandleText* pHandle = new HandleText(this);
|
HandleText* pHandle = new HandleText(this);
|
||||||
pHandle->setType(T_text);
|
pHandle->setType(T_text);
|
||||||
pHandle->setTag(H_textCaption);
|
pHandle->setTag(H_textCaption);
|
||||||
pHandle->setText(QString("uname"));
|
//pHandle->setText(QString("uname"));
|
||||||
pHandle->setPos(30,-30);
|
pHandle->setPos(30,-30);
|
||||||
pHandle->setParent(this);
|
pHandle->setParent(this);
|
||||||
m_vecHanle.insert(H_textCaption,pHandle);
|
m_vecHanle.insert(H_textCaption,pHandle);
|
||||||
connect(pHandle,&HandleText::editFinish,this,&GraphicsProjectModelItem::onEditNameFinish);
|
connect(pHandle,&HandleText::editFinish,this,&GraphicsProjectModelItem::onEditNameFinish);
|
||||||
|
|
||||||
HandleText* pCurrent = new HandleText(this); //电流
|
/*HandleText* pCurrent = new HandleText(this); //电流
|
||||||
pCurrent->setEditable(false);
|
pCurrent->setEditable(false);
|
||||||
pCurrent->setType(T_text);
|
pCurrent->setType(T_text);
|
||||||
pCurrent->setTag(H_textCurrent);
|
pCurrent->setTag(H_textCurrent);
|
||||||
|
|
@ -292,7 +357,7 @@ GraphicsProjectModelItem::GraphicsProjectModelItem(QGraphicsItem *parent)
|
||||||
pVoltage->setText(QString("V:"));
|
pVoltage->setText(QString("V:"));
|
||||||
pVoltage->setPos(-30,30);
|
pVoltage->setPos(-30,30);
|
||||||
pVoltage->setParent(this);
|
pVoltage->setParent(this);
|
||||||
m_vecHanle.insert(h_textVoltage,pVoltage);
|
m_vecHanle.insert(h_textVoltage,pVoltage);*/
|
||||||
|
|
||||||
setFlag(QGraphicsItem::ItemIsMovable, true);
|
setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
|
|
@ -461,3 +526,98 @@ void GraphicsProjectModelItem::onEditNameFinish(const QString& str)
|
||||||
emit ifExist(m_itemId,str,m_Itemtype,this);
|
emit ifExist(m_itemId,str,m_Itemtype,this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphicsProjectModelItem::updateTerPos()
|
||||||
|
{
|
||||||
|
for(auto &pPort:m_mapPort){
|
||||||
|
double dX = pPort->getXPercent();
|
||||||
|
double dY = pPort->getYPercent();
|
||||||
|
QPointF pos(boundingRect().left() + boundingRect().width() * dX, boundingRect().top()+boundingRect().height() *dY);
|
||||||
|
pPort->setPos(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************工程模组*************************************/
|
||||||
|
|
||||||
|
GraphicsProjectModelGroup::GraphicsProjectModelGroup(QGraphicsItem *parent)
|
||||||
|
:GraphicsProjectModelItem(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GraphicsProjectModelGroup::~GraphicsProjectModelGroup()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GraphicsProjectModelGroup::addItem(GraphicsProjectModelItem* item)
|
||||||
|
{
|
||||||
|
item->setParentItem(this); // 关键:设置父项
|
||||||
|
m_childItems.append(item);
|
||||||
|
updateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*QRectF GraphicsProjectModelGroup::boundingRect() const
|
||||||
|
{
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
QRectF GraphicsProjectModelGroup::updateBoundRect()
|
||||||
|
{
|
||||||
|
QRectF rect;
|
||||||
|
if(m_childItems.size()){
|
||||||
|
for (auto* child : m_childItems) {
|
||||||
|
rect |= child->boundingRect().translated(child->pos());
|
||||||
|
}
|
||||||
|
|
||||||
|
m_boundingRect = rect;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return m_boundingRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateHandles();
|
||||||
|
//qDebug()<<rect;
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicsProjectModelGroup::updateLayout()
|
||||||
|
{
|
||||||
|
if (m_childItems.isEmpty()) return;
|
||||||
|
|
||||||
|
// 计算所有子项的总尺寸
|
||||||
|
qreal totalSize = 0;
|
||||||
|
QList<qreal> childSizes;
|
||||||
|
|
||||||
|
for (GraphicsBaseItem *child : m_childItems) {
|
||||||
|
QRectF childRect = child->boundingRect();
|
||||||
|
qreal size = (m_direction == 0) ? childRect.width() : childRect.height();
|
||||||
|
childSizes.append(size);
|
||||||
|
totalSize += size;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算总间距
|
||||||
|
qreal totalSpacing = m_spacing * (m_childItems.size() - 1);
|
||||||
|
|
||||||
|
// 计算起始位置(相对于父项中心)
|
||||||
|
qreal startPos = -(totalSize + totalSpacing) / 2;
|
||||||
|
|
||||||
|
// 定位每个子项
|
||||||
|
qreal currentPos = startPos;
|
||||||
|
for (int i = 0; i < m_childItems.size(); ++i) {
|
||||||
|
GraphicsBaseItem *child = m_childItems[i];
|
||||||
|
QRectF childRect = child->boundingRect();
|
||||||
|
|
||||||
|
if (m_direction == 0) {
|
||||||
|
// 水平布局:x坐标变化,y坐标保持中心对齐
|
||||||
|
child->setPos(currentPos, -childRect.height() / 2);
|
||||||
|
currentPos += childSizes[i] + m_spacing;
|
||||||
|
} else {
|
||||||
|
// 垂直布局:y坐标变化,x坐标保持中心对齐
|
||||||
|
child->setPos(-childRect.width() / 2, currentPos);
|
||||||
|
currentPos += childSizes[i] + m_spacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateBoundRect();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QJsonArray>
|
||||||
#include "itemPropertyDlg.h"
|
#include "itemPropertyDlg.h"
|
||||||
#include "propertyContentDlg.h"
|
#include "propertyContentDlg.h"
|
||||||
#include "dataManager.h"
|
#include "dataManager.h"
|
||||||
|
|
@ -79,12 +80,35 @@ void ItemPropertyDlg::onOkClicked()
|
||||||
}
|
}
|
||||||
QMap<QString, QWidget*>::Iterator iter;
|
QMap<QString, QWidget*>::Iterator iter;
|
||||||
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(curUuid_);
|
BaseProperty* pPro = BasePropertyManager::instance().findEntityData(curUuid_);
|
||||||
|
int nType = pPro->type(); //操作的对象类型
|
||||||
for(iter = groupViews_.begin();iter != groupViews_.end();++iter)
|
for(iter = groupViews_.begin();iter != groupViews_.end();++iter)
|
||||||
{
|
{
|
||||||
BaseContentDlg* pDlg = qobject_cast<BaseContentDlg*>(iter.value());
|
BaseContentDlg* pDlg = qobject_cast<BaseContentDlg*>(iter.value());
|
||||||
QMap<QString,propertyStateInfo> mapPro = pDlg->getPropertyValue(pPro);
|
QMap<QString,propertyStateInfo> mapPro = pDlg->getPropertyValue(pPro);
|
||||||
if(!mapPro.empty())
|
if(!mapPro.empty())
|
||||||
DataManager::instance().updateModelData(_curModel,curUuid_,iter.key(),mapPro);
|
DataManager::instance().updateModelData(_curModel,curUuid_,iter.key(),mapPro);
|
||||||
|
|
||||||
|
|
||||||
|
if(nType == 4){ //ct
|
||||||
|
int nCtSize = 0; //ct设置的个数
|
||||||
|
int nCtType = 0; //ct类型 1三相0零相
|
||||||
|
if(mapPro.contains("ct_winding")){
|
||||||
|
propertyStateInfo val = mapPro.value("ct_winding");
|
||||||
|
QJsonObject obj = val.defaultValue.toJsonObject();
|
||||||
|
if(obj.contains("winding")){
|
||||||
|
QJsonArray arr = obj["winding"].toArray();
|
||||||
|
nCtSize = arr.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mapPro.contains("phase_num")){
|
||||||
|
propertyStateInfo val = mapPro.value("phase_num");
|
||||||
|
nCtType = val.defaultValue.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_curItem){
|
||||||
|
_curItem->setupFinish(nCtType,nCtSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,17 @@ PowerTerminal::PowerTerminal(const QString& parentEntityId,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
const QPointF& relativePos,
|
const QPointF& relativePos,
|
||||||
const QString& uuid,
|
const QString& uuid,
|
||||||
|
const double dPerX,
|
||||||
|
const double dPerY,
|
||||||
QObject* parent)
|
QObject* parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_id(uuid),
|
m_id(uuid),
|
||||||
m_parentEntityId(parentEntityId),
|
m_parentEntityId(parentEntityId),
|
||||||
m_type(type),
|
m_type(type),
|
||||||
m_name(name),
|
m_name(name),
|
||||||
m_relativePosition(relativePos)
|
m_relativePosition(relativePos),
|
||||||
|
m_dPerX(dPerX),
|
||||||
|
m_dPerY(dPerY)
|
||||||
{
|
{
|
||||||
if(m_id.isEmpty())
|
if(m_id.isEmpty())
|
||||||
m_id = QUuid::createUuid().toString();
|
m_id = QUuid::createUuid().toString();
|
||||||
|
|
@ -43,7 +47,7 @@ PowerTerminal* PowerTerminal::fromJson(const QJsonObject& json, QObject* parent)
|
||||||
qreal x = json["relX"].toDouble();
|
qreal x = json["relX"].toDouble();
|
||||||
qreal y = json["relY"].toDouble();
|
qreal y = json["relY"].toDouble();
|
||||||
|
|
||||||
PowerTerminal* term = new PowerTerminal(parentId, type, name, QPointF(x, y),id, parent);
|
PowerTerminal* term = new PowerTerminal(parentId, type, name, QPointF(x, y),id,0,0, parent); //***不再使用***
|
||||||
term->m_id = id; // 注意:需要修改m_id为可写,或使用其他机制保持ID一致
|
term->m_id = id; // 注意:需要修改m_id为可写,或使用其他机制保持ID一致
|
||||||
return term;
|
return term;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "dataBase.h"
|
#include "dataBase.h"
|
||||||
|
#include "designerScene.h"
|
||||||
|
|
||||||
ProjectModelSetting::ProjectModelSetting(QWidget *parent)
|
ProjectModelSetting::ProjectModelSetting(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
|
|
@ -332,12 +333,14 @@ void ProjectModelSetting::onSaveClicked()
|
||||||
{
|
{
|
||||||
ModelProperty* p = item->getProperty();
|
ModelProperty* p = item->getProperty();
|
||||||
BaseModelProperty* pro = dynamic_cast<BaseModelProperty*>(p);
|
BaseModelProperty* pro = dynamic_cast<BaseModelProperty*>(p);
|
||||||
|
QString sModel = _curItemData->modelName();
|
||||||
if(pro){
|
if(pro){
|
||||||
if(pro->metaModelName() == _curItemData->metaModelName()){ //将相同基模item的工程模名称都置为相同(改一个全变)
|
if(pro->metaModelName() == _curItemData->metaModelName()){ //将相同基模item的工程模名称都置为相同(改一个全变)
|
||||||
pro->setModelName(_curItemData->modelName());
|
pro->setModelName(sModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//_controller->getScene()->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,38 +42,38 @@ QMap<QString,propertyStateInfo> PtExtraInfoDlg::getPropertyValue(BaseProperty* p
|
||||||
propertyStateInfo info;
|
propertyStateInfo info;
|
||||||
info.type = pro.proType;
|
info.type = pro.proType;
|
||||||
info.name = pro.proName;
|
info.name = pro.proName;
|
||||||
if(info.name == "额定电压") //此处应为类型名
|
if(info.name == "额定电压(V)" || info.name == "un_v") //此处应为类型名
|
||||||
{
|
{
|
||||||
info.defaultValue = ui->le_ratedVol->text();
|
info.defaultValue = ui->le_ratedVol->text();
|
||||||
}
|
}
|
||||||
else if(info.name == "工频耐压")
|
else if(info.name == "工频耐压(V/1min)" || info.name == "uac_v_1min")
|
||||||
{
|
{
|
||||||
info.defaultValue = ui->le_pfwv_pt->text();
|
info.defaultValue = ui->le_pfwv_pt->text();
|
||||||
}
|
}
|
||||||
else if(info.name == "冲击耐压")
|
else if(info.name == "冲击耐压(V)" || info.name == "uimp_v")
|
||||||
{
|
{
|
||||||
info.defaultValue = ui->le_iwv_pt->text();
|
info.defaultValue = ui->le_iwv_pt->text();
|
||||||
}
|
}
|
||||||
else if(info.name == "额定电压因数")
|
else if(info.name == "额定电压因数" || info.name == "rvf")
|
||||||
{
|
{
|
||||||
info.defaultValue = ui->le_ratedVolFactor->text();
|
info.defaultValue = ui->le_ratedVolFactor->text();
|
||||||
}
|
}
|
||||||
else if(info.name == "一次绕组接线接地方式")
|
else if(info.name == "一次绕组接线接地方式" || info.name == "pwcc")
|
||||||
{
|
{
|
||||||
info.defaultValue = ui->le_pwwgm->text();
|
info.defaultValue = ui->le_pwwgm->text();
|
||||||
}
|
}
|
||||||
else if(info.name == "额定频率")
|
else if(info.name == "额定频率(Hz)" || info.name == "fn_hz")
|
||||||
{
|
{
|
||||||
info.defaultValue = ui->le_rf_pt->text();
|
info.defaultValue = ui->le_rf_pt->text();
|
||||||
}
|
}
|
||||||
else if(info.name == "相数")
|
else if(info.name == "相数" || info.name == "phase_num")
|
||||||
{
|
{
|
||||||
if(ui->rb_tpt_pt->isChecked())
|
if(ui->rb_tpt_pt->isChecked())
|
||||||
info.defaultValue = 1;
|
info.defaultValue = 1;
|
||||||
else
|
else
|
||||||
info.defaultValue = 0;
|
info.defaultValue = 0;
|
||||||
}
|
}
|
||||||
else if(info.name == "pt绕组")
|
else if(info.name == "PT二次绕组" || info.name == "pt_sec_winding")
|
||||||
{
|
{
|
||||||
QJsonObject object;
|
QJsonObject object;
|
||||||
QJsonArray arr;
|
QJsonArray arr;
|
||||||
|
|
|
||||||
|
|
@ -817,11 +817,13 @@ PowerTerminal* TopologyManager::createTerminal(const QString& parentEntityId,
|
||||||
const QString& name,
|
const QString& name,
|
||||||
const QPointF& relPos,
|
const QPointF& relPos,
|
||||||
const QString& uuid,
|
const QString& uuid,
|
||||||
ModelFunctionType funType) {
|
ModelFunctionType funType,
|
||||||
|
double dPerX,
|
||||||
|
double dPerY) {
|
||||||
if(funType == ModelFunctionType::ProjectModel){
|
if(funType == ModelFunctionType::ProjectModel){
|
||||||
if (!m_entities.contains(parentEntityId)) return nullptr;
|
if (!m_entities.contains(parentEntityId)) return nullptr;
|
||||||
|
|
||||||
PowerTerminal* term = new PowerTerminal(parentEntityId, type, name, relPos, uuid);
|
PowerTerminal* term = new PowerTerminal(parentEntityId, type, name, relPos, uuid, dPerX, dPerY);
|
||||||
m_allTerminals[term->id()] = term;
|
m_allTerminals[term->id()] = term;
|
||||||
m_terminalsByEntity[parentEntityId].append(term);
|
m_terminalsByEntity[parentEntityId].append(term);
|
||||||
|
|
||||||
|
|
@ -835,7 +837,7 @@ PowerTerminal* TopologyManager::createTerminal(const QString& parentEntityId,
|
||||||
else if(funType == ModelFunctionType::BaseModel){
|
else if(funType == ModelFunctionType::BaseModel){
|
||||||
if (!m_baseEntities.contains(parentEntityId)) return nullptr;
|
if (!m_baseEntities.contains(parentEntityId)) return nullptr;
|
||||||
|
|
||||||
PowerTerminal* term = new PowerTerminal(parentEntityId, type, name, relPos, uuid);
|
PowerTerminal* term = new PowerTerminal(parentEntityId, type, name, relPos, uuid, dPerX, dPerY);
|
||||||
m_baseAllTerminals[term->id()] = term;
|
m_baseAllTerminals[term->id()] = term;
|
||||||
m_baseTerminalsByEntity[parentEntityId].append(term);
|
m_baseTerminalsByEntity[parentEntityId].append(term);
|
||||||
|
|
||||||
|
|
@ -849,7 +851,7 @@ PowerTerminal* TopologyManager::createTerminal(const QString& parentEntityId,
|
||||||
else if(funType == ModelFunctionType::EditorModel){
|
else if(funType == ModelFunctionType::EditorModel){
|
||||||
if (!m_editorEntities.contains(parentEntityId)) return nullptr;
|
if (!m_editorEntities.contains(parentEntityId)) return nullptr;
|
||||||
|
|
||||||
PowerTerminal* term = new PowerTerminal(parentEntityId, type, name, relPos, uuid);
|
PowerTerminal* term = new PowerTerminal(parentEntityId, type, name, relPos, uuid, dPerX, dPerY);
|
||||||
m_editorAllTerminals[term->id()] = term;
|
m_editorAllTerminals[term->id()] = term;
|
||||||
m_editorTerminalsByEntity[parentEntityId].append(term);
|
m_editorTerminalsByEntity[parentEntityId].append(term);
|
||||||
|
|
||||||
|
|
@ -863,7 +865,7 @@ PowerTerminal* TopologyManager::createTerminal(const QString& parentEntityId,
|
||||||
else if(funType == ModelFunctionType::BlockEditorModel){
|
else if(funType == ModelFunctionType::BlockEditorModel){
|
||||||
if (!m_blockEntities.contains(parentEntityId)) return nullptr;
|
if (!m_blockEntities.contains(parentEntityId)) return nullptr;
|
||||||
|
|
||||||
PowerTerminal* term = new PowerTerminal(parentEntityId, type, name, relPos, uuid);
|
PowerTerminal* term = new PowerTerminal(parentEntityId, type, name, relPos, uuid, dPerX, dPerY);
|
||||||
m_blockAllTerminals[term->id()] = term;
|
m_blockAllTerminals[term->id()] = term;
|
||||||
m_blockTerminalsByEntity[parentEntityId].append(term);
|
m_blockTerminalsByEntity[parentEntityId].append(term);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,12 @@ void MovingSelector::mouseMoveEvent(QGraphicsSceneMouseEvent* event, DesignerSce
|
||||||
QList<QGraphicsItem *> items = scene->selectedItems();
|
QList<QGraphicsItem *> items = scene->selectedItems();
|
||||||
for(int n = 0; n < items.size(); n++)
|
for(int n = 0; n < items.size(); n++)
|
||||||
{
|
{
|
||||||
AbstractShape* item = qgraphicsitem_cast<AbstractShape*>(items.at(n));
|
GraphicsBaseItem* item = qgraphicsitem_cast<GraphicsBaseItem*>(items.at(n));
|
||||||
if(item)
|
if(item){
|
||||||
item->moveOperationCopy(ms_ptMouseLast - ms_ptMouseDown);
|
if(item->getMoveable()){
|
||||||
|
item->moveOperationCopy(ms_ptMouseLast - ms_ptMouseDown);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue