forked from magnocube/POV-Globe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
customimage.cpp
89 lines (60 loc) · 2.11 KB
/
customimage.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "customimage.h"
CustomImage::CustomImage()
{
x_location =0;
y_location =0;
width =50;
height =50;
color = Qt::green;
rotation =0;
lineColor = Qt::black;
lineThickness =1;
setFlag(ItemIsSelectable);
setFlag(ItemIsMovable);
}
QRectF CustomImage::boundingRect() const
{
return QRectF(x_location,y_location,width,height);
}
void CustomImage::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
painter->rotate(rotation);
QRectF rec = boundingRect();
// QBrush brush(color);
// QPen pen(lineColor);
// pen.setWidth(lineThickness);
// painter->setPen(pen);
// painter->setBrush(brush);
// painter->drawRect(rec);
painter->drawImage(rec,resisedImage);
}
void CustomImage::resize(int w, int h)
{
width = w;
height = h;
}
void CustomImage::setImage(QImage image)
{
originalImage = image;
resisedImage = originalImage.scaled(width, height, Qt::IgnoreAspectRatio);
}
void CustomImage::newProperties(int width, int height, int lineThichness, int rotation, QColor backColor, QColor lineColor, int borderRadius)
{
qDebug() << width << " " << height << " " << lineThichness << " " << rotation << " " << backColor.name() << " " << lineColor.name() << " " << borderRadius;
this->width = width;
this->height = height;
this->lineThickness = lineThichness;
this->rotation = rotation;
this->color = backColor;
this->lineColor = lineColor;
this->borderRadius = borderRadius;
resisedImage = originalImage.scaled(width, height, Qt::IgnoreAspectRatio);
emit updateGraphics();
}
void CustomImage::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e)
{
CustomImage_Editor * myEditor = new CustomImage_Editor(width,height,color,lineColor,lineThickness,rotation,borderRadius); //dont forget to delete this pointer from the heap when the wondow closes
connect(myEditor,SIGNAL(propertyChanged(int,int,int,int,QColor,QColor,int)),this,SLOT(newProperties(int,int,int,int,QColor,QColor,int)));
myEditor->show();
//Todo,,, find a solution to removing the windows
}