DiagramDesigner/diagramCavas/source/graphicsItem/electricSvgGroupCT.cpp

95 lines
2.3 KiB
C++
Raw Normal View History

2025-10-11 18:51:33 +08:00
#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);
}
2025-11-14 19:31:09 +08:00
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);
_nType = obj._nType;
_nSize = obj._nSize;
}
2025-10-11 18:51:33 +08:00
ElectricSvgGroupCT::~ElectricSvgGroupCT()
{
}
2025-11-14 19:31:09 +08:00
ElectricSvgGroupCT* ElectricSvgGroupCT::clone() const
{
return new ElectricSvgGroupCT(*this);
}
2025-10-17 18:14:44 +08:00
void ElectricSvgGroupCT::setupFinish(QVariant var)
2025-10-11 18:51:33 +08:00
{
2025-10-17 18:14:44 +08:00
if(var.canConvert<QPair<int,int>>()){
QPair<int,int> pair = var.value<QPair<int,int>>();
_nType = pair.first;
_nSize = pair.second;
}
2025-10-11 18:51:33 +08:00
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);
2025-10-17 18:14:44 +08:00
p->loadSvg(m_mapSvg["ct"]);
2025-10-11 18:51:33 +08:00
addSvgItem(p);
}
}
else if(_nType == 0){
ElectricSvgItemCT* p = new ElectricSvgItemCT(rec);
p->setItemType(_nType);
p->setMoveable(false);
2025-10-17 18:14:44 +08:00
p->loadSvg(m_mapSvg["zsct"]);
2025-10-11 18:51:33 +08:00
addSvgItem(p);
}
updateTerPos();
}