: position(parent)
{
setAcceptHoverEvents(true);
this->StatusState=Status::deselected;
this->rotCenter=0;
this->fillQColor= (Qt::transparent);
this->setFrameEnumXXType(type::Xarea);
this->wide =128;
this->high =128;
}
QRectF frameX
::boundingRect() const {
return QRectF(0,
0,this
->wide,this
->high
);
}
{
path.addPolygon(polygonType);
return path;
}
{
Q_UNUSED(option);
Q_UNUSED(widget);
pen.setWidth(4);
pen.setColor(Qt::black);
pen.setJoinStyle(Qt::RoundJoin);
brush.setColor(this->fillQColor);
brush.setStyle(Qt::SolidPattern);
painterPath.addPolygon(this->polygonType);
painter->setPen(pen);
painter->drawPolygon(this->polygonType);
painter->fillPath(painterPath,brush);
}
if(event->button() == Qt::RightButton){
qDebug()<< "right button";
}
else if(event->button() == Qt::LeftButton){
//qDebug()<< "right button";
if (getFrameStatus()== Status::selected){
setFrameStatus(Status::deselected);
}
else{
setFrameStatus(Status::selected);
}
}
else{
qDebug()<< "wheel button";
}
}
{
Q_UNUSED(event);
/**hover enter event, place text here*/
// setToolTip(QString(QObject::tr(("example"))));
}
void frameX::setFrame(qreal xPos, qreal yPos, qreal rotCenter, type::frames frameType)
{
setFrameEnumXXType(frameType);
this->rotCenter=rotCenter;
this->xPos=xPos;
this->yPos=yPos;
this->centerX = this->wide/2;
this->centerY = this->high/2;
setPos(this->xPos-(this->centerX),this->yPos-(this->centerY));
this->transform.translate(this->centerX,this->centerY);
this->transform.rotate(this->rotCenter);
this->transform.translate(-(this->centerX),-(this->centerY));
setTransform(this->transform);
}
void frameX::setFrameStatus(Status::frameState myFrameState)
{
switch(myFrameState)
{
case Status::selected:
this->StatusState = Status::selected;
qDebug() << "umbrella selected";
this
->fillQColor
= (QColor(0,
0,
255,
70));
break;
case Status::approved:
this->StatusState = Status::approved;
qDebug() << "selection approved";
this
->fillQColor
= (QColor(0,
255,
0,
70));
break;
case Status::deselected:
this->StatusState = Status::deselected;
qDebug() << "umbrella deselected";
this->fillQColor = (Qt::transparent);
break;
default:
qDebug() << "requested fill color" << myFrameState << "not avaliable";
break;
}
update();
}
int frameX::getFrameStatus() const
{
return this->StatusState;
}
frameX::frameX(QGraphicsItem *parent)
: position(parent)
{
setAcceptHoverEvents(true);
this->StatusState=Status::deselected;
this->rotCenter=0;
this->fillQColor= (Qt::transparent);
this->setFrameEnumXXType(type::Xarea);
this->wide =128;
this->high =128;
}
QRectF frameX::boundingRect() const
{
return QRectF(0,0,this->wide,this->high);
}
QPainterPath frameX::shape() const
{
QPainterPath path;
path.addPolygon(polygonType);
return path;
}
void frameX::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
QPen pen;
QBrush brush;
QPainterPath painterPath;
pen.setWidth(4);
pen.setColor(Qt::black);
pen.setJoinStyle(Qt::RoundJoin);
brush.setColor(this->fillQColor);
brush.setStyle(Qt::SolidPattern);
painterPath.addPolygon(this->polygonType);
painter->setPen(pen);
painter->drawPolygon(this->polygonType);
painter->fillPath(painterPath,brush);
}
void frameX::mousePressEvent(QGraphicsSceneMouseEvent *event){
if(event->button() == Qt::RightButton){
qDebug()<< "right button";
}
else if(event->button() == Qt::LeftButton){
//qDebug()<< "right button";
if (getFrameStatus()== Status::selected){
setFrameStatus(Status::deselected);
}
else{
setFrameStatus(Status::selected);
}
}
else{
qDebug()<< "wheel button";
}
}
void frameX::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
/**hover enter event, place text here*/
// setToolTip(QString(QObject::tr(("example"))));
}
void frameX::setFrame(qreal xPos, qreal yPos, qreal rotCenter, type::frames frameType)
{
setFrameEnumXXType(frameType);
this->rotCenter=rotCenter;
this->xPos=xPos;
this->yPos=yPos;
this->centerX = this->wide/2;
this->centerY = this->high/2;
setPos(this->xPos-(this->centerX),this->yPos-(this->centerY));
this->transform.translate(this->centerX,this->centerY);
this->transform.rotate(this->rotCenter);
this->transform.translate(-(this->centerX),-(this->centerY));
setTransform(this->transform);
}
void frameX::setFrameStatus(Status::frameState myFrameState)
{
switch(myFrameState)
{
case Status::selected:
this->StatusState = Status::selected;
qDebug() << "umbrella selected";
this->fillQColor = (QColor(0,0,255,70));
break;
case Status::approved:
this->StatusState = Status::approved;
qDebug() << "selection approved";
this->fillQColor = (QColor(0,255,0,70));
break;
case Status::deselected:
this->StatusState = Status::deselected;
qDebug() << "umbrella deselected";
this->fillQColor = (Qt::transparent);
break;
default:
qDebug() << "requested fill color" << myFrameState << "not avaliable";
break;
}
update();
}
int frameX::getFrameStatus() const
{
return this->StatusState;
}
To copy to clipboard, switch view to plain text mode
Bookmarks