95 lines
2.3 KiB
C++
95 lines
2.3 KiB
C++
#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(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;
|
|
}
|
|
|
|
ElectricSvgGroupCT::~ElectricSvgGroupCT()
|
|
{
|
|
|
|
}
|
|
|
|
ElectricSvgGroupCT* ElectricSvgGroupCT::clone() const
|
|
{
|
|
return new ElectricSvgGroupCT(*this);
|
|
}
|
|
|
|
void ElectricSvgGroupCT::setupFinish(QVariant var)
|
|
{
|
|
if(var.canConvert<QPair<int,int>>()){
|
|
QPair<int,int> pair = var.value<QPair<int,int>>();
|
|
_nType = pair.first;
|
|
_nSize = pair.second;
|
|
}
|
|
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);
|
|
p->loadSvg(m_mapSvg["ct"]);
|
|
addSvgItem(p);
|
|
}
|
|
}
|
|
else if(_nType == 0){
|
|
ElectricSvgItemCT* p = new ElectricSvgItemCT(rec);
|
|
p->setItemType(_nType);
|
|
p->setMoveable(false);
|
|
p->loadSvg(m_mapSvg["zsct"]);
|
|
addSvgItem(p);
|
|
}
|
|
updateTerPos();
|
|
}
|
|
|