-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbricks.cpp
More file actions
33 lines (27 loc) · 727 Bytes
/
Copy pathbricks.cpp
File metadata and controls
33 lines (27 loc) · 727 Bytes
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
#include "bricks.h"
#include "constants.h"
#include <QPainter>
Bricks::Bricks(QPointF P, int length, int width):
length(length),
width(width)
{
setPos(P);
setAcceptDrops(true);
}
void Bricks::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *){
painter->save();
painter->setBrush(Qt::black);
painter->drawRect(QRectF(0,0,length*block,width*block));
painter->restore();
}
QRectF Bricks::boundingRect() const{
return QRectF(0,0,length*block,width*block);
}
bool Bricks::contains(const QPointF &t) const{
QPointF tl = this->scenePos();
QRectF r(tl.x(),tl.y(),length*block,width*block);
if(r.contains(t))
return true;
else
return false;
}