-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmove_option.cpp
More file actions
107 lines (90 loc) · 2.11 KB
/
Copy pathmove_option.cpp
File metadata and controls
107 lines (90 loc) · 2.11 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "move_option.h"
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <iostream>
#include <QtWidgets>
#include <QColor>
#include <QGraphicsItem>
#include <QString>
QRectF MoveOption::boundingRect() const
{
return QRectF(x_, y_, width_, height_);
}
QPainterPath MoveOption::shape() const
{
QPainterPath path;
path.addRect(x_, y_, width_, height_);
return path;
}
void MoveOption::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
if(is_occupied_){
painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(QPen(Qt::black,8));
painter->setOpacity(0.2);
painter->drawEllipse(this->x_ + 4, this->y_ + 4, 87, 87);
}
else{
painter->setRenderHint(QPainter::Antialiasing);
Q_UNUSED(widget);
QRect tile = QRect(this->x_ + 28, this->y_ + 28, this->width_/2.5, this->height_/2.5);
QPainterPath path;
path.addEllipse(tile);
painter->setOpacity(0.2);
painter->fillPath (path, QBrush (QColor ("black")));
}
}
int MoveOption::width() const
{
return width_;
}
void MoveOption::setWidth(int newWidth)
{
width_ = newWidth;
}
int MoveOption::height() const
{
return height_;
}
void MoveOption::setHeight(int newHeight)
{
height_ = newHeight;
}
int MoveOption::y() const
{
return y_;
}
void MoveOption::setY(int newY)
{
y_ = newY;
}
void MoveOption::setX(int newX)
{
x_ = newX;
}
bool MoveOption::is_occupied() const
{
return is_occupied_;
}
void MoveOption::setIs_occupied(bool newIs_occupied)
{
is_occupied_ = newIs_occupied;
}
int MoveOption::x() const
{
return x_;
}
MoveOption::MoveOption(int x, int y, int w, int h, bool o){
this->x_ = x;
this->y_ = y;
this->width_ = w;
this->height_ = h;
this->is_occupied_ = o;
};
//Emit the signal that our MainWindow can grab for moving a piece
void MoveOption::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event);
emit(MoveOptionSelected(this));
}