add image property to propertyEditor
This commit is contained in:
parent
f1dcea6308
commit
6c093ad8d3
|
|
@ -1,39 +1,100 @@
|
|||
import QtQuick;
|
||||
import QtQuick.Controls;
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Dialogs
|
||||
import QtQuick.Layouts
|
||||
import QtCore
|
||||
import ColorPalette
|
||||
|
||||
Item{
|
||||
Item {
|
||||
id: control
|
||||
property var value
|
||||
implicitHeight: 25
|
||||
signal asValueChanged(text:var)
|
||||
|
||||
function setValue(newValue:var){
|
||||
if(newValue !== value){
|
||||
// 属性接口
|
||||
property var value
|
||||
property string fileFilter: "所有文件 (*.*)" // 文件过滤器
|
||||
property bool selectMultiple: false // 是否多选
|
||||
|
||||
implicitHeight: fileBox.implicitHeight
|
||||
signal asValueChanged(text: var)
|
||||
|
||||
function setValue(newValue: var) {
|
||||
if (newValue !== value) {
|
||||
value = newValue
|
||||
fileBox.value = value
|
||||
asValueChanged(value)
|
||||
}
|
||||
}
|
||||
Button{
|
||||
anchors.margins: 2
|
||||
anchors.fill: parent
|
||||
palette {
|
||||
button: value
|
||||
}
|
||||
|
||||
LineTextBox {
|
||||
id: fileBox
|
||||
value: control.value
|
||||
anchors.left: parent.left
|
||||
anchors.right: button.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
onValueChanged: {
|
||||
control.setValue(value)
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
id: button
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 30
|
||||
height: 25
|
||||
text: "..."
|
||||
palette.buttonText: ColorPalette.theme.textPrimary
|
||||
background: Rectangle {
|
||||
color: value
|
||||
color: ColorPalette.theme.buttonBackground
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
colorDialog.open()
|
||||
fileDialog.open()
|
||||
}
|
||||
}
|
||||
ColorDialog {
|
||||
id: colorDialog
|
||||
selectedColor: value
|
||||
|
||||
FileDialog {
|
||||
id: fileDialog
|
||||
title: control.selectMultiple ? "选择多个文件" : "选择文件"
|
||||
fileMode: control.selectMultiple ? FileDialog.OpenFiles : FileDialog.OpenFile
|
||||
|
||||
// 设置文件过滤器
|
||||
nameFilters: {
|
||||
if (control.fileFilter) {
|
||||
return control.fileFilter.split(";;")
|
||||
}
|
||||
return ["所有文件 (*.*)"]
|
||||
}
|
||||
|
||||
onAccepted: {
|
||||
control.setValue(selectedColor)
|
||||
if (control.selectMultiple) {
|
||||
// 多选模式
|
||||
var filePaths = []
|
||||
|
||||
for (var i = 0; i < selectedFiles.length; i++) {
|
||||
var filePath = selectedFiles[i].toString()
|
||||
filePath = removeFileProtocol(filePath)
|
||||
filePaths.push(filePath)
|
||||
}
|
||||
|
||||
// 多个文件用分号分隔
|
||||
control.setValue(filePaths.join(";"))
|
||||
} else {
|
||||
// 单选模式
|
||||
var filePath = selectedFile.toString()
|
||||
filePath = removeFileProtocol(filePath)
|
||||
control.setValue(filePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 辅助函数:移除文件协议前缀
|
||||
function removeFileProtocol(path) {
|
||||
if (path.startsWith("file:///")) {
|
||||
return path.substring(8)
|
||||
} else if (path.startsWith("file://")) {
|
||||
return path.substring(7)
|
||||
}
|
||||
return path
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -417,4 +417,52 @@ void QQuickDetailsViewManager::RegisterBasicTypeEditor() {
|
|||
connect(handle, SIGNAL(asRequestRollback(QVariant)), valueEditor, SLOT(setValue(QVariant)));
|
||||
return valueEditor;
|
||||
});
|
||||
|
||||
QMetaType::registerConverterFunction(
|
||||
[](const void* src, void* target) -> bool {
|
||||
const QFileInfo& file = *static_cast<const QFileInfo*>(src);
|
||||
QString& str = *static_cast<QString*>(target);
|
||||
str = file.fileName();
|
||||
return true;
|
||||
},
|
||||
QMetaType::fromType<QFileInfo>(),
|
||||
QMetaType::fromType<QString>()
|
||||
);
|
||||
|
||||
QMetaType::registerConverterFunction(
|
||||
[](const void* src, void* target) -> bool {
|
||||
const QString& str = *static_cast<const QString*>(src);
|
||||
QFileInfo& file = *static_cast<QFileInfo*>(target);
|
||||
file = QFileInfo(str);
|
||||
return true;
|
||||
},
|
||||
QMetaType::fromType<QString>(),
|
||||
QMetaType::fromType<QFileInfo>()
|
||||
);
|
||||
|
||||
registerTypeEditor(QMetaType::fromType<QFileInfo>(), [](QPropertyHandle* handle, QQuickItem* parent)->QQuickItem* {
|
||||
QQmlEngine* engine = qmlEngine(parent);
|
||||
QQmlContext* context = qmlContext(parent);
|
||||
QQmlComponent comp(engine);
|
||||
comp.setData(R"(
|
||||
import QtQuick;
|
||||
import QtQuick.Controls;
|
||||
import "qrc:/resources/Qml/ValueEditor"
|
||||
FileSelector{
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: parent.width
|
||||
}
|
||||
)", QUrl());
|
||||
QVariantMap initialProperties;
|
||||
initialProperties["parent"] = QVariant::fromValue(parent);
|
||||
auto valueEditor = qobject_cast<QQuickItem*>(comp.createWithInitialProperties(initialProperties, context));
|
||||
if (!comp.errors().isEmpty()) {
|
||||
qDebug() << comp.errorString();
|
||||
}
|
||||
valueEditor->setParentItem(parent);
|
||||
valueEditor->setProperty("value", handle->getVar());
|
||||
connect(valueEditor, SIGNAL(asValueChanged(QVariant)), handle, SLOT(setVar(QVariant)));
|
||||
connect(handle, SIGNAL(asRequestRollback(QVariant)), valueEditor, SLOT(setValue(QVariant)));
|
||||
return valueEditor;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public:
|
|||
|
||||
void insertProjectModelName(QString,QString); //插入工程模类型(生成工程模时调用)
|
||||
void showProjectIconSettingDlg(GraphicsProjectModelItem*); //显示工程模图标设置(设置使用图标)
|
||||
void updateItemIcon(QString sMeta,QString sModel); //更新指定模型的图标
|
||||
void updateItemIcon(QString sMeta,QString sModel,QMap<QString,QByteArray>,QString sIndex = ""); //更新指定模型的图标 sIndex:索引下标,为空全部更新
|
||||
/********************baseModel相关**********************/
|
||||
QMap<QUuid,GraphicsBaseModelItem*>& allBaseItems(); //获取所有基模对象
|
||||
QVector<Connection> allBaseConnections();
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public:
|
|||
void updateCoordinate() override;
|
||||
void move(const QPointF&) override;
|
||||
virtual void addSvgItem(ElectricSvgItem* item);
|
||||
virtual void updateMapSvg(QMap<QString,QByteArray> map); //工程模property不含图片,额外存储
|
||||
virtual void updateMapSvg(QMap<QString,QByteArray> map,QString sIndex = ""); //工程模property不含图片,额外存储
|
||||
virtual void setMonitorDisplayInfo(QMap<monitorItemStateStruct,monitorItemDisplayInfo> info) override; //将显示数据更新到子item中
|
||||
protected:
|
||||
virtual QPainterPath shape() override;
|
||||
|
|
|
|||
|
|
@ -15,8 +15,11 @@ public:
|
|||
virtual void updateItem() override;
|
||||
void setCtType(int n){_nType = n;}
|
||||
void setCtSize(int n){_nSize = n;}
|
||||
virtual void setImage_1(QFileInfo) override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
private:
|
||||
void initial();
|
||||
protected:
|
||||
int _nType = 0; //Ct类型 1三相0零相
|
||||
int _nSize = 0; //ct个数
|
||||
|
|
|
|||
|
|
@ -15,8 +15,11 @@ public:
|
|||
virtual void updateItem() override;
|
||||
virtual void updateLayout() override;
|
||||
QList<int>& getLstType() {return m_lstType;}
|
||||
virtual void setImage_1(QFileInfo) override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
private:
|
||||
void initial();
|
||||
protected:
|
||||
QList<int> m_lstType; //绕组类型 1星型 0三角
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public:
|
|||
void move(const QPointF&) override;
|
||||
virtual void loadSvg(){};
|
||||
virtual void loadSvg(QByteArray); //第二种load直接加载图片
|
||||
virtual void updateMapSvg(QMap<QString,QByteArray> map);
|
||||
virtual void updateMapSvg(QMap<QString,QByteArray> map,QString sIndex = ""); //index:空全部更新
|
||||
virtual void updateCurState(monitorItemState e) override;
|
||||
protected:
|
||||
virtual QPainterPath shape() override;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public:
|
|||
ElectricSvgItem2wTransformer(const ElectricSvgItem2wTransformer&);
|
||||
virtual ~ElectricSvgItem2wTransformer();
|
||||
virtual ElectricSvgItem2wTransformer* clone() const override;
|
||||
|
||||
virtual void setImage_1(QFileInfo) override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public:
|
|||
ElectricSvgItem3wTransformer(const ElectricSvgItem3wTransformer&);
|
||||
virtual ~ElectricSvgItem3wTransformer();
|
||||
virtual ElectricSvgItem3wTransformer* clone() const override;
|
||||
|
||||
virtual void setImage_1(QFileInfo) override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#define ELECTRICSVGITEMBUS_H
|
||||
|
||||
#include "electricSvgItem.h"
|
||||
#include "baseProperty.h"
|
||||
|
||||
class ElectricSvgItemBus :public ElectricSvgItem
|
||||
{
|
||||
|
|
@ -12,7 +11,7 @@ public:
|
|||
ElectricSvgItemBus(const ElectricSvgItemBus&);
|
||||
virtual ~ElectricSvgItemBus();
|
||||
virtual ElectricSvgItemBus* clone() const override;
|
||||
|
||||
virtual void setImage_1(QFileInfo) override;
|
||||
void addPort();
|
||||
public:
|
||||
virtual void updateConnectData() override;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public:
|
|||
ElectricSvgItemCableEnd(const ElectricSvgItemCableEnd&);
|
||||
virtual ~ElectricSvgItemCableEnd();
|
||||
virtual ElectricSvgItemCableEnd* clone() const override;
|
||||
|
||||
virtual void setImage_1(QFileInfo) override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public:
|
|||
ElectricSvgItemCableTer(const ElectricSvgItemCableTer&);
|
||||
virtual ~ElectricSvgItemCableTer();
|
||||
virtual ElectricSvgItemCableTer* clone() const override;
|
||||
|
||||
virtual void setImage_1(QFileInfo) override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public:
|
|||
ElectricSvgItemDS(const ElectricSvgItemDS&);
|
||||
virtual ~ElectricSvgItemDS();
|
||||
virtual ElectricSvgItemDS* clone() const override;
|
||||
|
||||
virtual void setImage_1(QFileInfo) override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public:
|
|||
ElectricSvgItemDTEDS(const ElectricSvgItemDTEDS&);
|
||||
virtual ~ElectricSvgItemDTEDS();
|
||||
virtual ElectricSvgItemDTEDS* clone() const override;
|
||||
|
||||
virtual void setImage_1(QFileInfo) override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public:
|
|||
ElectricSvgItemES(const ElectricSvgItemES&);
|
||||
virtual ~ElectricSvgItemES();
|
||||
virtual ElectricSvgItemES* clone() const override;
|
||||
|
||||
virtual void setImage_1(QFileInfo) override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public:
|
|||
ElectricSvgItemFES(const ElectricSvgItemFES&);
|
||||
virtual ~ElectricSvgItemFES();
|
||||
virtual ElectricSvgItemFES* clone() const override;
|
||||
|
||||
virtual void setImage_1(QFileInfo) override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public:
|
|||
ElectricSvgItemLA(const ElectricSvgItemLA&);
|
||||
virtual ~ElectricSvgItemLA();
|
||||
virtual ElectricSvgItemLA* clone() const override;
|
||||
|
||||
virtual void setImage_1(QFileInfo) override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public:
|
|||
ElectricSvgItemPI(const ElectricSvgItemPI&);
|
||||
virtual ~ElectricSvgItemPI();
|
||||
virtual ElectricSvgItemPI* clone() const override;
|
||||
|
||||
virtual void setImage_1(QFileInfo) override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public:
|
|||
ElectricSvgItemRect(const ElectricSvgItemRect&);
|
||||
virtual ~ElectricSvgItemRect();
|
||||
virtual ElectricSvgItemRect* clone() const override;
|
||||
|
||||
virtual void setImage_1(QFileInfo) override;
|
||||
protected:
|
||||
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
|
||||
virtual void updateHandles() override;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <QGraphicsSvgItem>
|
||||
#include <QUuid>
|
||||
#include <QJsonObject>
|
||||
#include <QFileInfo>
|
||||
#include "propertyType/dataSourceType.h"
|
||||
//#include "graphicsItem/itemPort.h"
|
||||
|
||||
|
|
@ -186,6 +187,7 @@ public:
|
|||
Q_PROPERTY(QPointF Position READ getPosition WRITE setPosition)
|
||||
Q_PROPERTY(QRectF Size READ getSize WRITE setSize)
|
||||
Q_PROPERTY(RotateAngle Rotation READ getRotateAngle WRITE setRotateAngle)
|
||||
Q_PROPERTY(QFileInfo Image READ getImage_1 WRITE setImage_1)
|
||||
public:
|
||||
GraphicsBaseItem(QGraphicsItem *parent);
|
||||
GraphicsBaseItem(const GraphicsBaseItem&);
|
||||
|
|
@ -202,6 +204,8 @@ public:
|
|||
virtual void setSize(QRectF);
|
||||
virtual RotateAngle getRotateAngle() const;
|
||||
virtual void setRotateAngle(RotateAngle);
|
||||
virtual QFileInfo getImage_1() const;
|
||||
virtual void setImage_1(QFileInfo);
|
||||
public:
|
||||
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); //移动可动点
|
||||
|
|
@ -232,6 +236,9 @@ public:
|
|||
virtual void setDynamicLayoutRadius(qreal radius);
|
||||
virtual QMap<QString,HandleText*> getDynamicText() {return m_mapDynamicText;}
|
||||
void setHandle(FixedPortsModel* p){_pHandle = p;}
|
||||
virtual void img_1_selected(QString sMeta,QString sModel,QByteArray img){};
|
||||
virtual void img_2_selected(QString sMeta,QString sModel,QByteArray img){};
|
||||
virtual void img_3_selected(QString sMeta,QString sModel,QByteArray img){};
|
||||
|
||||
int collidesWithHandle(const QPointF& point)
|
||||
{
|
||||
|
|
@ -530,6 +537,8 @@ protected:
|
|||
QRectF m_boundingRect_selected; //选中矩形框
|
||||
bool _posChanged = false; //位置移动标志
|
||||
bool _bMove = true; //是否允许移动
|
||||
QString m_bgImagePath; //选定的背景图路径
|
||||
QStringList _itemImgIndex; //item图形索引列表
|
||||
|
||||
private:
|
||||
qreal m_layoutRadius; // 布局半径 (动态数据使用)
|
||||
|
|
|
|||
|
|
@ -603,7 +603,8 @@ void DiagramCavas::resizeEvent(QResizeEvent* event)
|
|||
|
||||
void DiagramCavas::onTargetSelected(QObject* obj)
|
||||
{
|
||||
emit selectTarget(obj);
|
||||
if(obj)
|
||||
emit selectTarget(obj);
|
||||
}
|
||||
|
||||
/*******************************************************/
|
||||
|
|
|
|||
|
|
@ -1634,7 +1634,8 @@ void FixedPortsModel::onSelectionChanged()
|
|||
QList<QGraphicsItem*> selectedItems = _scene->selectedItems();
|
||||
if(_cavas){
|
||||
if(selectedItems.count() != 1) {
|
||||
_cavas->onTargetSelected(_widget->getPropertyProxy());
|
||||
if(_widget)
|
||||
_cavas->onTargetSelected(_widget->getPropertyProxy());
|
||||
return;
|
||||
}
|
||||
GraphicsBaseItem *item = static_cast<GraphicsBaseItem*>(selectedItems.first());
|
||||
|
|
@ -1955,8 +1956,14 @@ void FixedPortsModel::showProjectIconSettingDlg(GraphicsProjectModelItem* pItem)
|
|||
m_projectIconSettingDlg->showDlg(pItem);
|
||||
}
|
||||
|
||||
void FixedPortsModel::updateItemIcon(QString sMeta,QString sModel)
|
||||
void FixedPortsModel::updateItemIcon(QString sMeta,QString sModel,QMap<QString,QByteArray> mapData,QString sIndex)
|
||||
{
|
||||
if(sIndex.isEmpty())
|
||||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg = mapData;
|
||||
else{
|
||||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg[sIndex] = mapData[sIndex];
|
||||
}
|
||||
|
||||
for(auto &pItem:_nodeItem){
|
||||
auto pro = pItem->getProperty();
|
||||
QString sMe = pro->metaModelName();
|
||||
|
|
@ -1965,10 +1972,10 @@ void FixedPortsModel::updateItemIcon(QString sMeta,QString sModel)
|
|||
auto pI = dynamic_cast<ElectricSvgItem*>(pItem);
|
||||
auto pG = dynamic_cast<ElectricSvgGroup*>(pItem);
|
||||
if(pI){
|
||||
pI->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg);
|
||||
pI->updateMapSvg(mapData,sIndex);
|
||||
}
|
||||
if(pG){
|
||||
pG->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg);
|
||||
pG->updateMapSvg(mapData,sIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2563,14 +2570,21 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
|||
else if(type == GIT_baseCT)
|
||||
{
|
||||
QByteArray svg;
|
||||
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
||||
QByteArray svg2;
|
||||
QMap<QString,QByteArray> mapSvg = pBase->getModelProperty().modelSetting.mapSvg;
|
||||
if(mapSvg.isEmpty()){
|
||||
svg = DataBase::GetInstance()->ModelType()[5].icon;
|
||||
svg2 = svg;
|
||||
}
|
||||
else{
|
||||
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
||||
svg = mapSvg.first();
|
||||
if(mapSvg.size() > 1){
|
||||
auto it = mapSvg.constBegin();
|
||||
svg2 = (++it).value();
|
||||
}
|
||||
}
|
||||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["ct"] = svg;
|
||||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["zsct"] = svg;
|
||||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["zsct"] = svg2;
|
||||
QRectF rec = pBaseItem->boundingRect();
|
||||
auto pCtGroup = new ElectricSvgGroupCT(rec.toRect());
|
||||
pCtGroup->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg);
|
||||
|
|
@ -2582,14 +2596,22 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
|||
else if(type == GIT_basePT)
|
||||
{
|
||||
QByteArray svg;
|
||||
QByteArray svg2;
|
||||
QMap<QString,QByteArray> mapSvg = pBase->getModelProperty().modelSetting.mapSvg;
|
||||
if(pBase->getModelProperty().modelSetting.mapSvg.isEmpty()){
|
||||
svg = DataBase::GetInstance()->ModelType()[6].icon;
|
||||
svg2 = svg;
|
||||
}
|
||||
else{
|
||||
svg = pBase->getModelProperty().modelSetting.mapSvg.first();
|
||||
svg = mapSvg.first();
|
||||
if(mapSvg.size() > 1){
|
||||
auto it = mapSvg.constBegin();
|
||||
svg2 = (++it).value();
|
||||
}
|
||||
}
|
||||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["y"] = svg;
|
||||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["z"] = svg;
|
||||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["z"] = svg2;
|
||||
QRectF rec = pBaseItem->boundingRect();
|
||||
auto pPtGroup = new ElectricSvgGroupPT(rec.toRect());
|
||||
pPtGroup->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg);
|
||||
|
|
@ -2627,6 +2649,7 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
|||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["ds"] = svg;
|
||||
QRectF rec = pBaseItem->boundingRect();
|
||||
auto pDs = new ElectricSvgItemDS(rec.toRect());
|
||||
pDs->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg);
|
||||
pDs->loadSvg(svg);
|
||||
pProItem = pDs;
|
||||
pProItem->setItemType(GIT_DS);
|
||||
|
|
@ -2643,6 +2666,7 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
|||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["fes"] = svg;
|
||||
QRectF rec = pBaseItem->boundingRect();
|
||||
auto pFes = new ElectricSvgItemFES(rec.toRect());
|
||||
pFes->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg);
|
||||
pFes->loadSvg(svg);
|
||||
pProItem = pFes;
|
||||
pProItem->setItemType(GIT_FES);
|
||||
|
|
@ -2659,6 +2683,7 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
|||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["dteds"] = svg;
|
||||
QRectF rec = pBaseItem->boundingRect();
|
||||
auto pDteds = new ElectricSvgItemDTEDS(rec.toRect());
|
||||
pDteds->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg);
|
||||
pDteds->loadSvg(svg);
|
||||
pProItem = pDteds;
|
||||
pProItem->setItemType(GIT_DTEDS);
|
||||
|
|
@ -2675,6 +2700,7 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
|||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["potential_indicator"] = svg;
|
||||
QRectF rec = pBaseItem->boundingRect();
|
||||
auto pPi = new ElectricSvgItemPI(rec.toRect());
|
||||
pPi->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg);
|
||||
pPi->loadSvg(svg);
|
||||
pProItem = pPi;
|
||||
pProItem->setItemType(GIT_PI);
|
||||
|
|
@ -2691,6 +2717,7 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
|||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["lightning_arrester"] = svg;
|
||||
QRectF rec = pBaseItem->boundingRect();
|
||||
auto pLa = new ElectricSvgItemLA(rec.toRect());
|
||||
pLa->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg);
|
||||
pLa->loadSvg(svg);
|
||||
pProItem = pLa;
|
||||
pProItem->setItemType(GIT_LA);
|
||||
|
|
@ -2707,6 +2734,7 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
|||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["cable_termination"] = svg;
|
||||
QRectF rec = pBaseItem->boundingRect();
|
||||
auto pCt = new ElectricSvgItemCableTer(rec.toRect());
|
||||
pCt->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg);
|
||||
pCt->loadSvg(svg);
|
||||
pProItem = pCt;
|
||||
pProItem->setItemType(GIT_cableTer);
|
||||
|
|
@ -2723,6 +2751,7 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
|||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["cable_end"] = svg;
|
||||
QRectF rec = pBaseItem->boundingRect();
|
||||
auto pCe = new ElectricSvgItemCableEnd(rec.toRect());
|
||||
pCe->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg);
|
||||
pCe->loadSvg(svg);
|
||||
pProItem = pCe;
|
||||
pProItem->setItemType(GIT_cableEnd);
|
||||
|
|
@ -2739,6 +2768,7 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
|||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["transformer_2w"] = svg;
|
||||
QRectF rec = pBaseItem->boundingRect();
|
||||
auto p2w = new ElectricSvgItem2wTransformer(rec.toRect());
|
||||
p2w->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg);
|
||||
p2w->loadSvg(svg);
|
||||
pProItem = p2w;
|
||||
pProItem->setItemType(GIT_2wTransformer);
|
||||
|
|
@ -2755,6 +2785,7 @@ void FixedPortsModel::addProjectItemByBaseData(DrawingPanel* pPanel,GraphicsBase
|
|||
ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg["transformer_3w"] = svg;
|
||||
QRectF rec = pBaseItem->boundingRect();
|
||||
auto p3w = new ElectricSvgItem3wTransformer(rec.toRect());
|
||||
p3w->updateMapSvg(ProjectModelManager::instance().getData()[sMeta][sModel].modelSetting.mapUsedSvg);
|
||||
p3w->loadSvg(svg);
|
||||
pProItem = p3w;
|
||||
pProItem->setItemType(GIT_3wTransformer);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "graphicsItem/electricSvgGroup.h"
|
||||
#include "graphicsItem/electricSvgItem.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
|
|
@ -129,9 +130,14 @@ void ElectricSvgGroup::move(const QPointF& point)
|
|||
moveBy(point.x(), point.y());
|
||||
}
|
||||
|
||||
void ElectricSvgGroup::updateMapSvg(QMap<QString,QByteArray> map)
|
||||
void ElectricSvgGroup::updateMapSvg(QMap<QString,QByteArray> map,QString sIndex)
|
||||
{
|
||||
m_mapSvg = map;
|
||||
if(sIndex.isEmpty())
|
||||
m_mapSvg = map;
|
||||
else{
|
||||
m_mapSvg[sIndex] = map[sIndex];
|
||||
}
|
||||
updateItem();
|
||||
}
|
||||
|
||||
void ElectricSvgGroup::setMonitorDisplayInfo(QMap<monitorItemStateStruct,monitorItemDisplayInfo> info)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "graphicsItem/electricSvgGroupCT.h"
|
||||
#include "graphicsItem/electricSvgItemCT.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "baseProperty.h"
|
||||
#include "global.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
|
@ -10,24 +12,13 @@
|
|||
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);
|
||||
initial();
|
||||
}
|
||||
|
||||
ElectricSvgGroupCT::ElectricSvgGroupCT(const ElectricSvgGroupCT& obj)
|
||||
:ElectricSvgGroup(obj)
|
||||
{
|
||||
setHandleIfShow(H_textCaption,false);
|
||||
setHandleIfShow(H_textCurrent,false);
|
||||
setHandleIfShow(h_textVoltage,false);
|
||||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
|
||||
initial();
|
||||
_nType = obj._nType;
|
||||
_nSize = obj._nSize;
|
||||
}
|
||||
|
|
@ -42,6 +33,37 @@ ElectricSvgGroupCT* ElectricSvgGroupCT::clone() const
|
|||
return new ElectricSvgGroupCT(*this);
|
||||
}
|
||||
|
||||
void ElectricSvgGroupCT::setImage_1(QFileInfo info)
|
||||
{
|
||||
QByteArray svgData;
|
||||
QFile svgFile(info.absoluteFilePath());
|
||||
|
||||
if (svgFile.open(QIODevice::ReadOnly)) {
|
||||
svgData = svgFile.readAll();
|
||||
svgFile.close();
|
||||
} else {
|
||||
qDebug() << "can't open imgfile" << svgFile.errorString();
|
||||
}
|
||||
|
||||
QMap<QString,QByteArray> mapData;
|
||||
if(!svgData.isEmpty()){
|
||||
mapData["ct"] = svgData;
|
||||
updateMapSvg(mapData,"ct");
|
||||
updateItem();
|
||||
}
|
||||
QString sMeta;
|
||||
QString sModel;
|
||||
if(_property){
|
||||
sMeta = _property->metaModelName();
|
||||
sModel = _property->modelName();
|
||||
}
|
||||
|
||||
if(_pHandle && !sMeta.isEmpty() && !sModel.isEmpty())
|
||||
_pHandle->updateItemIcon(sMeta,sModel,mapData,"ct");
|
||||
GraphicsBaseItem::setImage_1(info);
|
||||
}
|
||||
|
||||
|
||||
void ElectricSvgGroupCT::setupFinish(QVariant var)
|
||||
{
|
||||
if(var.canConvert<QPair<int,int>>()){
|
||||
|
|
@ -64,6 +86,20 @@ void ElectricSvgGroupCT::paint(QPainter* painter, const QStyleOptionGraphicsItem
|
|||
}
|
||||
}
|
||||
|
||||
void ElectricSvgGroupCT::initial()
|
||||
{
|
||||
setHandleIfShow(H_textCaption,false);
|
||||
setHandleIfShow(H_textCurrent,false);
|
||||
setHandleIfShow(h_textVoltage,false);
|
||||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
if(!_itemImgIndex.contains("ct"))
|
||||
_itemImgIndex.append("ct");
|
||||
if(!_itemImgIndex.contains("zsct"))
|
||||
_itemImgIndex.append("zsct");
|
||||
}
|
||||
|
||||
void ElectricSvgGroupCT::updateItem()
|
||||
{
|
||||
for(auto pItem:m_childItems){
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "graphicsItem/electricSvgGroupPT.h"
|
||||
#include "graphicsItem/electricSvgItemPT.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "baseProperty.h"
|
||||
#include "global.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
|
@ -10,19 +12,13 @@
|
|||
ElectricSvgGroupPT::ElectricSvgGroupPT(const QRect &rect, QGraphicsItem *parent)
|
||||
: ElectricSvgGroup(rect,parent)
|
||||
{
|
||||
setHandleIfShow(H_textCaption,false);
|
||||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
initial();
|
||||
}
|
||||
|
||||
ElectricSvgGroupPT::ElectricSvgGroupPT(const ElectricSvgGroupPT& obj)
|
||||
: ElectricSvgGroup(obj)
|
||||
{
|
||||
setHandleIfShow(H_textCaption,false);
|
||||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
initial();
|
||||
m_lstType = obj.m_lstType;
|
||||
}
|
||||
|
||||
|
|
@ -36,6 +32,36 @@ ElectricSvgGroupPT* ElectricSvgGroupPT::clone() const
|
|||
return new ElectricSvgGroupPT(*this);
|
||||
}
|
||||
|
||||
void ElectricSvgGroupPT::setImage_1(QFileInfo info)
|
||||
{
|
||||
QByteArray svgData;
|
||||
QFile svgFile(info.absoluteFilePath());
|
||||
|
||||
if (svgFile.open(QIODevice::ReadOnly)) {
|
||||
svgData = svgFile.readAll();
|
||||
svgFile.close();
|
||||
} else {
|
||||
qDebug() << "can't open imgfile" << svgFile.errorString();
|
||||
}
|
||||
|
||||
QMap<QString,QByteArray> mapData;
|
||||
if(!svgData.isEmpty()){
|
||||
mapData["pt"] = svgData;
|
||||
updateMapSvg(mapData,"pt");
|
||||
updateItem();
|
||||
}
|
||||
QString sMeta;
|
||||
QString sModel;
|
||||
if(_property){
|
||||
sMeta = _property->metaModelName();
|
||||
sModel = _property->modelName();
|
||||
}
|
||||
|
||||
if(_pHandle && !sMeta.isEmpty() && !sModel.isEmpty())
|
||||
_pHandle->updateItemIcon(sMeta,sModel,mapData,"pt");
|
||||
GraphicsBaseItem::setImage_1(info);
|
||||
}
|
||||
|
||||
void ElectricSvgGroupPT::setupFinish(QVariant var)
|
||||
{
|
||||
if(var.canConvert<QList<int>>()){
|
||||
|
|
@ -57,6 +83,18 @@ void ElectricSvgGroupPT::paint(QPainter* painter, const QStyleOptionGraphicsItem
|
|||
}
|
||||
}
|
||||
|
||||
void ElectricSvgGroupPT::initial()
|
||||
{
|
||||
setHandleIfShow(H_textCaption,false);
|
||||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
if(!_itemImgIndex.contains("y"))
|
||||
_itemImgIndex.append("y");
|
||||
if(!_itemImgIndex.contains("z"))
|
||||
_itemImgIndex.append("z");
|
||||
}
|
||||
|
||||
void ElectricSvgGroupPT::updateItem()
|
||||
{
|
||||
for(auto pItem:m_childItems){
|
||||
|
|
|
|||
|
|
@ -184,9 +184,15 @@ void ElectricSvgItem::loadSvg(QByteArray b)
|
|||
update();
|
||||
}
|
||||
|
||||
void ElectricSvgItem::updateMapSvg(QMap<QString,QByteArray> map)
|
||||
void ElectricSvgItem::updateMapSvg(QMap<QString,QByteArray> map,QString sIndex)
|
||||
{
|
||||
m_mapSvg = map;
|
||||
if(sIndex.isEmpty())
|
||||
m_mapSvg = map;
|
||||
else{
|
||||
m_mapSvg[sIndex] = map[sIndex];
|
||||
}
|
||||
if(!m_mapSvg.isEmpty())
|
||||
loadSvg(m_mapSvg.first());
|
||||
}
|
||||
|
||||
void ElectricSvgItem::editShape(int nHandle,const QPointF& ptMouse)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "graphicsItem/electricSvgItem2wTransformer.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "baseProperty.h"
|
||||
#include "global.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
|
@ -28,6 +30,39 @@ ElectricSvgItem2wTransformer* ElectricSvgItem2wTransformer::clone() const
|
|||
return new ElectricSvgItem2wTransformer(*this);
|
||||
}
|
||||
|
||||
void ElectricSvgItem2wTransformer::setImage_1(QFileInfo info)
|
||||
{
|
||||
QByteArray svgData;
|
||||
QFile svgFile(info.absoluteFilePath());
|
||||
|
||||
if (svgFile.open(QIODevice::ReadOnly)) {
|
||||
svgData = svgFile.readAll();
|
||||
svgFile.close();
|
||||
} else {
|
||||
qDebug() << "can't open imgfile" << svgFile.errorString();
|
||||
}
|
||||
|
||||
QMap<QString,QByteArray> mapData;
|
||||
if(!svgData.isEmpty()){
|
||||
mapData["transformer_2w"] = svgData;
|
||||
updateMapSvg(mapData,"transformer_2w");
|
||||
loadSvg(svgData);
|
||||
updateItem();
|
||||
}
|
||||
|
||||
QString sMeta;
|
||||
QString sModel;
|
||||
if(_property){
|
||||
sMeta = _property->metaModelName();
|
||||
sModel = _property->modelName();
|
||||
}
|
||||
|
||||
if(_pHandle && !sMeta.isEmpty() && !sModel.isEmpty())
|
||||
_pHandle->updateItemIcon(sMeta,sModel,mapData,"transformer_2w");
|
||||
|
||||
GraphicsBaseItem::setImage_1(info);
|
||||
}
|
||||
|
||||
void ElectricSvgItem2wTransformer::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
ElectricSvgItem::paint(painter,option,widget);
|
||||
|
|
@ -39,4 +74,6 @@ void ElectricSvgItem2wTransformer::initial()
|
|||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
if(!_itemImgIndex.contains("transformer_2w"))
|
||||
_itemImgIndex.append("transformer_2w");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "graphicsItem/electricSvgItem3wTransformer.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "baseProperty.h"
|
||||
#include "global.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
|
@ -28,6 +30,39 @@ ElectricSvgItem3wTransformer* ElectricSvgItem3wTransformer::clone() const
|
|||
return new ElectricSvgItem3wTransformer(*this);
|
||||
}
|
||||
|
||||
void ElectricSvgItem3wTransformer::setImage_1(QFileInfo info)
|
||||
{
|
||||
QByteArray svgData;
|
||||
QFile svgFile(info.absoluteFilePath());
|
||||
|
||||
if (svgFile.open(QIODevice::ReadOnly)) {
|
||||
svgData = svgFile.readAll();
|
||||
svgFile.close();
|
||||
} else {
|
||||
qDebug() << "can't open imgfile" << svgFile.errorString();
|
||||
}
|
||||
|
||||
QMap<QString,QByteArray> mapData;
|
||||
if(!svgData.isEmpty()){
|
||||
mapData["transformer_3w"] = svgData;
|
||||
updateMapSvg(mapData,"transformer_3w");
|
||||
loadSvg(svgData);
|
||||
updateItem();
|
||||
}
|
||||
|
||||
QString sMeta;
|
||||
QString sModel;
|
||||
if(_property){
|
||||
sMeta = _property->metaModelName();
|
||||
sModel = _property->modelName();
|
||||
}
|
||||
|
||||
if(_pHandle && !sMeta.isEmpty() && !sModel.isEmpty())
|
||||
_pHandle->updateItemIcon(sMeta,sModel,mapData,"transformer_3w");
|
||||
|
||||
GraphicsBaseItem::setImage_1(info);
|
||||
}
|
||||
|
||||
void ElectricSvgItem3wTransformer::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
ElectricSvgItem::paint(painter,option,widget);
|
||||
|
|
@ -39,5 +74,7 @@ void ElectricSvgItem3wTransformer::initial()
|
|||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
if(!_itemImgIndex.contains("transformer_3w"))
|
||||
_itemImgIndex.append("transformer_3w");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include "graphicsItem/electricSvgItemBus.h"
|
||||
#include "graphicsItem/itemControlHandle.h"
|
||||
#include "graphicsItem/itemPort.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "baseProperty.h"
|
||||
|
||||
#include <QSvgRenderer>
|
||||
#include <QPainter>
|
||||
|
|
@ -29,6 +31,39 @@ ElectricSvgItemBus* ElectricSvgItemBus::clone() const
|
|||
return new ElectricSvgItemBus(*this);
|
||||
}
|
||||
|
||||
void ElectricSvgItemBus::setImage_1(QFileInfo info)
|
||||
{
|
||||
QByteArray svgData;
|
||||
QFile svgFile(info.absoluteFilePath());
|
||||
|
||||
if (svgFile.open(QIODevice::ReadOnly)) {
|
||||
svgData = svgFile.readAll();
|
||||
svgFile.close();
|
||||
} else {
|
||||
qDebug() << "can't open imgfile" << svgFile.errorString();
|
||||
}
|
||||
|
||||
QMap<QString,QByteArray> mapData;
|
||||
if(!svgData.isEmpty()){
|
||||
mapData["bus"] = svgData;
|
||||
updateMapSvg(mapData,"bus");
|
||||
loadSvg(svgData);
|
||||
updateItem();
|
||||
}
|
||||
|
||||
QString sMeta;
|
||||
QString sModel;
|
||||
if(_property){
|
||||
sMeta = _property->metaModelName();
|
||||
sModel = _property->modelName();
|
||||
}
|
||||
|
||||
if(_pHandle && !sMeta.isEmpty() && !sModel.isEmpty())
|
||||
_pHandle->updateItemIcon(sMeta,sModel,mapData,"bus");
|
||||
|
||||
GraphicsBaseItem::setImage_1(info);
|
||||
}
|
||||
|
||||
void ElectricSvgItemBus::updateHandles()
|
||||
{
|
||||
ElectricSvgItem::updateHandles();
|
||||
|
|
@ -75,4 +110,6 @@ void ElectricSvgItemBus::initial()
|
|||
setFunctionHandleEnaable(false);
|
||||
setHandleEnaable(H_right,true);
|
||||
setHandleEnaable(H_left,true);
|
||||
if(!_itemImgIndex.contains("bus"))
|
||||
_itemImgIndex.append("bus");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "graphicsItem/electricSvgItemCableEnd.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "baseProperty.h"
|
||||
#include "global.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
|
@ -28,6 +30,39 @@ ElectricSvgItemCableEnd* ElectricSvgItemCableEnd::clone() const
|
|||
return new ElectricSvgItemCableEnd(*this);
|
||||
}
|
||||
|
||||
void ElectricSvgItemCableEnd::setImage_1(QFileInfo info)
|
||||
{
|
||||
QByteArray svgData;
|
||||
QFile svgFile(info.absoluteFilePath());
|
||||
|
||||
if (svgFile.open(QIODevice::ReadOnly)) {
|
||||
svgData = svgFile.readAll();
|
||||
svgFile.close();
|
||||
} else {
|
||||
qDebug() << "can't open imgfile" << svgFile.errorString();
|
||||
}
|
||||
|
||||
QMap<QString,QByteArray> mapData;
|
||||
if(!svgData.isEmpty()){
|
||||
mapData["cable_end"] = svgData;
|
||||
updateMapSvg(mapData,"cable_end");
|
||||
loadSvg(svgData);
|
||||
updateItem();
|
||||
}
|
||||
|
||||
QString sMeta;
|
||||
QString sModel;
|
||||
if(_property){
|
||||
sMeta = _property->metaModelName();
|
||||
sModel = _property->modelName();
|
||||
}
|
||||
|
||||
if(_pHandle && !sMeta.isEmpty() && !sModel.isEmpty())
|
||||
_pHandle->updateItemIcon(sMeta,sModel,mapData,"cable_end");
|
||||
|
||||
GraphicsBaseItem::setImage_1(info);
|
||||
}
|
||||
|
||||
void ElectricSvgItemCableEnd::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
ElectricSvgItem::paint(painter,option,widget);
|
||||
|
|
@ -39,5 +74,7 @@ void ElectricSvgItemCableEnd::initial()
|
|||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
if(!_itemImgIndex.contains("cable_end"))
|
||||
_itemImgIndex.append("cable_end");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "graphicsItem/electricSvgItemCableTer.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "baseProperty.h"
|
||||
#include "global.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
|
@ -28,6 +30,39 @@ ElectricSvgItemCableTer* ElectricSvgItemCableTer::clone() const
|
|||
return new ElectricSvgItemCableTer(*this);
|
||||
}
|
||||
|
||||
void ElectricSvgItemCableTer::setImage_1(QFileInfo info)
|
||||
{
|
||||
QByteArray svgData;
|
||||
QFile svgFile(info.absoluteFilePath());
|
||||
|
||||
if (svgFile.open(QIODevice::ReadOnly)) {
|
||||
svgData = svgFile.readAll();
|
||||
svgFile.close();
|
||||
} else {
|
||||
qDebug() << "can't open imgfile" << svgFile.errorString();
|
||||
}
|
||||
|
||||
QMap<QString,QByteArray> mapData;
|
||||
if(!svgData.isEmpty()){
|
||||
mapData["cable_termination"] = svgData;
|
||||
updateMapSvg(mapData,"cable_termination");
|
||||
loadSvg(svgData);
|
||||
updateItem();
|
||||
}
|
||||
|
||||
QString sMeta;
|
||||
QString sModel;
|
||||
if(_property){
|
||||
sMeta = _property->metaModelName();
|
||||
sModel = _property->modelName();
|
||||
}
|
||||
|
||||
if(_pHandle && !sMeta.isEmpty() && !sModel.isEmpty())
|
||||
_pHandle->updateItemIcon(sMeta,sModel,mapData,"cable_termination");
|
||||
|
||||
GraphicsBaseItem::setImage_1(info);
|
||||
}
|
||||
|
||||
void ElectricSvgItemCableTer::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
ElectricSvgItem::paint(painter,option,widget);
|
||||
|
|
@ -39,4 +74,6 @@ void ElectricSvgItemCableTer::initial()
|
|||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
if(!_itemImgIndex.contains("cable_termination"))
|
||||
_itemImgIndex.append("cable_termination");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "graphicsItem/electricSvgItemDS.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "baseProperty.h"
|
||||
#include "global.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
|
@ -28,6 +30,39 @@ ElectricSvgItemDS* ElectricSvgItemDS::clone() const
|
|||
return new ElectricSvgItemDS(*this);
|
||||
}
|
||||
|
||||
void ElectricSvgItemDS::setImage_1(QFileInfo info)
|
||||
{
|
||||
QByteArray svgData;
|
||||
QFile svgFile(info.absoluteFilePath());
|
||||
|
||||
if (svgFile.open(QIODevice::ReadOnly)) {
|
||||
svgData = svgFile.readAll();
|
||||
svgFile.close();
|
||||
} else {
|
||||
qDebug() << "can't open imgfile" << svgFile.errorString();
|
||||
}
|
||||
|
||||
QMap<QString,QByteArray> mapData;
|
||||
if(!svgData.isEmpty()){
|
||||
mapData["ds"] = svgData;
|
||||
updateMapSvg(mapData,"ds");
|
||||
loadSvg(svgData);
|
||||
updateItem();
|
||||
}
|
||||
|
||||
QString sMeta;
|
||||
QString sModel;
|
||||
if(_property){
|
||||
sMeta = _property->metaModelName();
|
||||
sModel = _property->modelName();
|
||||
}
|
||||
|
||||
if(_pHandle && !sMeta.isEmpty() && !sModel.isEmpty())
|
||||
_pHandle->updateItemIcon(sMeta,sModel,mapData,"ds");
|
||||
|
||||
GraphicsBaseItem::setImage_1(info);
|
||||
}
|
||||
|
||||
void ElectricSvgItemDS::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
ElectricSvgItem::paint(painter,option,widget);
|
||||
|
|
@ -39,5 +74,7 @@ void ElectricSvgItemDS::initial()
|
|||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
if(!_itemImgIndex.contains("ds"))
|
||||
_itemImgIndex.append("ds");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "graphicsItem/electricSvgItemDTEDS.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "baseProperty.h"
|
||||
#include "global.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
|
@ -28,6 +30,39 @@ ElectricSvgItemDTEDS* ElectricSvgItemDTEDS::clone() const
|
|||
return new ElectricSvgItemDTEDS(*this);
|
||||
}
|
||||
|
||||
void ElectricSvgItemDTEDS::setImage_1(QFileInfo info)
|
||||
{
|
||||
QByteArray svgData;
|
||||
QFile svgFile(info.absoluteFilePath());
|
||||
|
||||
if (svgFile.open(QIODevice::ReadOnly)) {
|
||||
svgData = svgFile.readAll();
|
||||
svgFile.close();
|
||||
} else {
|
||||
qDebug() << "can't open imgfile" << svgFile.errorString();
|
||||
}
|
||||
|
||||
QMap<QString,QByteArray> mapData;
|
||||
if(!svgData.isEmpty()){
|
||||
mapData["dteds"] = svgData;
|
||||
updateMapSvg(mapData,"dteds");
|
||||
loadSvg(svgData);
|
||||
updateItem();
|
||||
}
|
||||
|
||||
QString sMeta;
|
||||
QString sModel;
|
||||
if(_property){
|
||||
sMeta = _property->metaModelName();
|
||||
sModel = _property->modelName();
|
||||
}
|
||||
|
||||
if(_pHandle && !sMeta.isEmpty() && !sModel.isEmpty())
|
||||
_pHandle->updateItemIcon(sMeta,sModel,mapData,"dteds");
|
||||
|
||||
GraphicsBaseItem::setImage_1(info);
|
||||
}
|
||||
|
||||
void ElectricSvgItemDTEDS::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
ElectricSvgItem::paint(painter,option,widget);
|
||||
|
|
@ -39,5 +74,7 @@ void ElectricSvgItemDTEDS::inital()
|
|||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
if(!_itemImgIndex.contains("dteds"))
|
||||
_itemImgIndex.append("dteds");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "graphicsItem/electricSvgItemES.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "baseProperty.h"
|
||||
#include "global.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
|
@ -28,6 +30,40 @@ ElectricSvgItemES* ElectricSvgItemES::clone() const
|
|||
return new ElectricSvgItemES(*this);
|
||||
}
|
||||
|
||||
void ElectricSvgItemES::setImage_1(QFileInfo info)
|
||||
{
|
||||
QByteArray svgData;
|
||||
QFile svgFile(info.absoluteFilePath());
|
||||
|
||||
if (svgFile.open(QIODevice::ReadOnly)) {
|
||||
svgData = svgFile.readAll();
|
||||
svgFile.close();
|
||||
} else {
|
||||
qDebug() << "can't open imgfile" << svgFile.errorString();
|
||||
}
|
||||
|
||||
QMap<QString,QByteArray> mapData;
|
||||
if(!svgData.isEmpty()){
|
||||
mapData["es"] = svgData;
|
||||
updateMapSvg(mapData,"es");
|
||||
loadSvg(svgData);
|
||||
updateItem();
|
||||
}
|
||||
|
||||
QString sMeta;
|
||||
QString sModel;
|
||||
if(_property){
|
||||
sMeta = _property->metaModelName();
|
||||
sModel = _property->modelName();
|
||||
}
|
||||
|
||||
if(_pHandle && !sMeta.isEmpty() && !sModel.isEmpty())
|
||||
_pHandle->updateItemIcon(sMeta,sModel,mapData,"es");
|
||||
|
||||
GraphicsBaseItem::setImage_1(info);
|
||||
}
|
||||
|
||||
|
||||
void ElectricSvgItemES::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
ElectricSvgItem::paint(painter,option,widget);
|
||||
|
|
@ -39,5 +75,7 @@ void ElectricSvgItemES::initial()
|
|||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
if(!_itemImgIndex.contains("es"))
|
||||
_itemImgIndex.append("es");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "graphicsItem/electricSvgItemFES.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "baseProperty.h"
|
||||
#include "global.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
|
@ -28,6 +30,39 @@ ElectricSvgItemFES* ElectricSvgItemFES::clone() const
|
|||
return new ElectricSvgItemFES(*this);
|
||||
}
|
||||
|
||||
void ElectricSvgItemFES::setImage_1(QFileInfo info)
|
||||
{
|
||||
QByteArray svgData;
|
||||
QFile svgFile(info.absoluteFilePath());
|
||||
|
||||
if (svgFile.open(QIODevice::ReadOnly)) {
|
||||
svgData = svgFile.readAll();
|
||||
svgFile.close();
|
||||
} else {
|
||||
qDebug() << "can't open imgfile" << svgFile.errorString();
|
||||
}
|
||||
|
||||
QMap<QString,QByteArray> mapData;
|
||||
if(!svgData.isEmpty()){
|
||||
mapData["fes"] = svgData;
|
||||
updateMapSvg(mapData,"fes");
|
||||
loadSvg(svgData);
|
||||
updateItem();
|
||||
}
|
||||
|
||||
QString sMeta;
|
||||
QString sModel;
|
||||
if(_property){
|
||||
sMeta = _property->metaModelName();
|
||||
sModel = _property->modelName();
|
||||
}
|
||||
|
||||
if(_pHandle && !sMeta.isEmpty() && !sModel.isEmpty())
|
||||
_pHandle->updateItemIcon(sMeta,sModel,mapData,"fes");
|
||||
|
||||
GraphicsBaseItem::setImage_1(info);
|
||||
}
|
||||
|
||||
void ElectricSvgItemFES::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
ElectricSvgItem::paint(painter,option,widget);
|
||||
|
|
@ -39,4 +74,6 @@ void ElectricSvgItemFES::initial()
|
|||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
if(!_itemImgIndex.contains("fes"))
|
||||
_itemImgIndex.append("fes");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "graphicsItem/electricSvgItemLA.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "baseProperty.h"
|
||||
#include "global.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
|
@ -28,6 +30,39 @@ ElectricSvgItemLA* ElectricSvgItemLA::clone() const
|
|||
return new ElectricSvgItemLA(*this);
|
||||
}
|
||||
|
||||
void ElectricSvgItemLA::setImage_1(QFileInfo info)
|
||||
{
|
||||
QByteArray svgData;
|
||||
QFile svgFile(info.absoluteFilePath());
|
||||
|
||||
if (svgFile.open(QIODevice::ReadOnly)) {
|
||||
svgData = svgFile.readAll();
|
||||
svgFile.close();
|
||||
} else {
|
||||
qDebug() << "can't open imgfile" << svgFile.errorString();
|
||||
}
|
||||
|
||||
QMap<QString,QByteArray> mapData;
|
||||
if(!svgData.isEmpty()){
|
||||
mapData["lightning_arrester"] = svgData;
|
||||
updateMapSvg(mapData,"lightning_arrester");
|
||||
loadSvg(svgData);
|
||||
updateItem();
|
||||
}
|
||||
|
||||
QString sMeta;
|
||||
QString sModel;
|
||||
if(_property){
|
||||
sMeta = _property->metaModelName();
|
||||
sModel = _property->modelName();
|
||||
}
|
||||
|
||||
if(_pHandle && !sMeta.isEmpty() && !sModel.isEmpty())
|
||||
_pHandle->updateItemIcon(sMeta,sModel,mapData,"lightning_arrester");
|
||||
|
||||
GraphicsBaseItem::setImage_1(info);
|
||||
}
|
||||
|
||||
void ElectricSvgItemLA::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
ElectricSvgItem::paint(painter,option,widget);
|
||||
|
|
@ -39,5 +74,7 @@ void ElectricSvgItemLA::initial()
|
|||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
if(!_itemImgIndex.contains("lightning_arrester"))
|
||||
_itemImgIndex.append("lightning_arrester");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "graphicsItem/electricSvgItemPI.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "baseProperty.h"
|
||||
#include "global.h"
|
||||
|
||||
#include <QSvgRenderer>
|
||||
|
|
@ -29,6 +31,39 @@ ElectricSvgItemPI* ElectricSvgItemPI::clone() const
|
|||
return new ElectricSvgItemPI(*this);
|
||||
}
|
||||
|
||||
void ElectricSvgItemPI::setImage_1(QFileInfo info)
|
||||
{
|
||||
QByteArray svgData;
|
||||
QFile svgFile(info.absoluteFilePath());
|
||||
|
||||
if (svgFile.open(QIODevice::ReadOnly)) {
|
||||
svgData = svgFile.readAll();
|
||||
svgFile.close();
|
||||
} else {
|
||||
qDebug() << "can't open imgfile" << svgFile.errorString();
|
||||
}
|
||||
|
||||
QMap<QString,QByteArray> mapData;
|
||||
if(!svgData.isEmpty()){
|
||||
mapData["potential_indicator"] = svgData;
|
||||
updateMapSvg(mapData,"potential_indicator");
|
||||
loadSvg(svgData);
|
||||
updateItem();
|
||||
}
|
||||
|
||||
QString sMeta;
|
||||
QString sModel;
|
||||
if(_property){
|
||||
sMeta = _property->metaModelName();
|
||||
sModel = _property->modelName();
|
||||
}
|
||||
|
||||
if(_pHandle && !sMeta.isEmpty() && !sModel.isEmpty())
|
||||
_pHandle->updateItemIcon(sMeta,sModel,mapData,"potential_indicator");
|
||||
|
||||
GraphicsBaseItem::setImage_1(info);
|
||||
}
|
||||
|
||||
void ElectricSvgItemPI::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
ElectricSvgItem::paint(painter,option,widget);
|
||||
|
|
@ -40,5 +75,7 @@ void ElectricSvgItemPI::initial()
|
|||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
if(!_itemImgIndex.contains("potential_indicator"))
|
||||
_itemImgIndex.append("potential_indicator");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "graphicsItem/electricSvgItemRect.h"
|
||||
#include "graphicsItem/itemPort.h"
|
||||
#include "graphicsDataModel/fixedPortsModel.h"
|
||||
#include "baseProperty.h"
|
||||
#include "global.h"
|
||||
|
||||
#include <QSvgRenderer>
|
||||
|
|
@ -30,6 +31,40 @@ ElectricSvgItemRect* ElectricSvgItemRect::clone() const
|
|||
return new ElectricSvgItemRect(*this);
|
||||
}
|
||||
|
||||
void ElectricSvgItemRect::setImage_1(QFileInfo info)
|
||||
{
|
||||
QByteArray svgData;
|
||||
QFile svgFile(info.absoluteFilePath());
|
||||
|
||||
if (svgFile.open(QIODevice::ReadOnly)) {
|
||||
svgData = svgFile.readAll();
|
||||
svgFile.close();
|
||||
} else {
|
||||
qDebug() << "can't open imgfile" << svgFile.errorString();
|
||||
}
|
||||
|
||||
QMap<QString,QByteArray> mapData;
|
||||
if(!svgData.isEmpty()){
|
||||
mapData["cb"] = svgData;
|
||||
updateMapSvg(mapData,"cb");
|
||||
loadSvg(svgData);
|
||||
updateItem();
|
||||
}
|
||||
|
||||
QString sMeta;
|
||||
QString sModel;
|
||||
if(_property){
|
||||
sMeta = _property->metaModelName();
|
||||
sModel = _property->modelName();
|
||||
}
|
||||
|
||||
if(_pHandle && !sMeta.isEmpty() && !sModel.isEmpty())
|
||||
_pHandle->updateItemIcon(sMeta,sModel,mapData,"cb");
|
||||
|
||||
GraphicsBaseItem::setImage_1(info);
|
||||
}
|
||||
|
||||
|
||||
void ElectricSvgItemRect::updateHandles()
|
||||
{
|
||||
ElectricSvgItem::updateHandles();
|
||||
|
|
@ -48,4 +83,6 @@ void ElectricSvgItemRect::initial()
|
|||
setHandleVisible(false);
|
||||
setFunctionHandleIfShow(false);
|
||||
setFunctionHandleEnaable(false);
|
||||
if(!_itemImgIndex.contains("cb"))
|
||||
_itemImgIndex.append("cb");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <QGraphicsScene>
|
||||
#include <QJsonArray>
|
||||
#include <QPainter>
|
||||
#include <QDir>
|
||||
|
||||
|
||||
GraphicsBaseItem::GraphicsBaseItem(QGraphicsItem *parent)
|
||||
|
|
@ -43,7 +44,6 @@ GraphicsBaseItem::GraphicsBaseItem(const GraphicsBaseItem& obj)
|
|||
|
||||
m_lastPoint = obj.m_lastPoint;
|
||||
m_touched = obj.m_touched;
|
||||
m_boundingRect_selected = obj.m_boundingRect_selected;
|
||||
|
||||
PortState tpe;
|
||||
if(m_Itemtype == GIT_baseNode || m_Itemtype == GIT_baseBus || m_Itemtype == GIT_node || m_Itemtype == GIT_bus){
|
||||
|
|
@ -134,6 +134,16 @@ void GraphicsBaseItem::setRotateAngle(RotateAngle angle)
|
|||
emit itemRotated(this);
|
||||
}
|
||||
|
||||
QFileInfo GraphicsBaseItem::getImage_1() const
|
||||
{
|
||||
return QFileInfo(m_bgImagePath);
|
||||
}
|
||||
|
||||
void GraphicsBaseItem::setImage_1(QFileInfo info)
|
||||
{
|
||||
m_bgImagePath = info.absoluteFilePath();
|
||||
}
|
||||
|
||||
int GraphicsBaseItem::addPort(PortState typ,QPointF vec,QString id,HandleType hType,PortPos pos,double dXPercent,double dYPercent)
|
||||
{
|
||||
int ntagId = -1;
|
||||
|
|
|
|||
|
|
@ -127,8 +127,7 @@ void ProjectIconSetting::onOkClicked()
|
|||
}
|
||||
}
|
||||
}
|
||||
ProjectModelManager::instance().getData()[_sMetaModel][_sModel].modelSetting.mapUsedSvg = mapUsedSvg;
|
||||
_controller->updateItemIcon(_sMetaModel,_sModel);
|
||||
_controller->updateItemIcon(_sMetaModel,_sModel,mapUsedSvg);
|
||||
hide();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue