-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyCentralRectRadiousItem.cpp
31 lines (28 loc) · 1.17 KB
/
MyCentralRectRadiousItem.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
#include "MyCentralRectRadiousItem.h"
#include "MyDropGraphicsScene.h"
#include "MainWindow.h"
#include <QPen>
#include <QPainter>
MyCentralRectRadiousItem::MyCentralRectRadiousItem(const QRectF & rect, QGraphicsItem * parent)
: MyCentralGraphicsItem(rect, parent){
setAcceptHoverEvents(true);
}
void MyCentralRectRadiousItem::paint(QPainter * painter,
const QStyleOptionGraphicsItem * option, QWidget * widget){
painter->setPen(*(MyCentralGraphicsItem::pen));
painter->setRenderHint(QPainter::Antialiasing);
QBrush brush(Qt::white);
painter->setBrush(brush);
painter->drawRoundedRect(boundingRect(), 45,45,Qt::RelativeSize);
MyCentralGraphicsItem::paint(painter, option, widget);
}
void MyCentralRectRadiousItem::mousePressEvent(QGraphicsSceneMouseEvent * event){
MyGraphicsView* myView = dynamic_cast<MyGraphicsView*>(scene()->views().at(0));
MainWindow* window = dynamic_cast<MainWindow*>(myView->parent());
if(window->painterCursorActivated()){
MyDropGraphicsScene* scene = dynamic_cast<MyDropGraphicsScene*>(this->scene());
MyCentralGraphicsItem::pen->setColor(scene->painterColor());
this->update(boundingRect());
}
MyCentralGraphicsItem::mousePressEvent(event);
}