-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransition.cpp
42 lines (36 loc) · 968 Bytes
/
transition.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QPainter>
#include <QStyleOption>
#include "arc.h"
#include "transition.h"
#include "graphwidget.h"
Transition::Transition(GraphWidget *graphWidget, char *lbl) : PItem(graphWidget,true,lbl)
{
rot = 0;
}
QRectF Transition::boundingRect() const
{
qreal adjust = 3;
return QRectF(-3,-10.5,6.3,21.3);
}
QPainterPath Transition::shape() const
{
QPainterPath path;
path.addRect(-3,-10.5,6.3,21.3);
return path;
}
void Transition::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
painter->fillRect(-2.5,-10,5,20,Qt::black);
if(!this->selected) painter->setPen(QPen(Qt::black, 0));
else painter->setPen(QPen(Qt::red, 1));
painter->drawRect(-2.5, -10, 5, 20);
}
void Transition::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
rot += 90;
if (rot == 180) rot = 0;
this->setRotation(rot);
this->update();
}