-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcursor.cpp
More file actions
75 lines (63 loc) · 1.63 KB
/
cursor.cpp
File metadata and controls
75 lines (63 loc) · 1.63 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
#include "cursor.h"
Cursor::Cursor(const QRectF &Window):ancho(Window.width()),alto(Window.height())
{
EjeX.setLine(0,alto/2,ancho,alto/2);
EjeY.setLine(ancho/2,0,ancho/2,alto);
CursorDrawMode=true;
qDebug()<<"Constructor de cursor en: "<<Window.width()<<" , "<<Window.height();
}
void Cursor::mover(QPointF punto)
{
EjeX.setLine(0,punto.y(),ancho,punto.y());
EjeY.setLine(punto.x(),0,punto.x(),alto);
SquareSelect.setRect(punto.x()-4,punto.y()-4,8,8);
update();
}
void Cursor::setMode(bool mode)
{
CursorDrawMode = mode;
if (mode==false)
{
qDebug()<<"Modo edicion: ";
}
else
{
qDebug()<<"Modo dibujo";
}
}
QRectF Cursor::boundingRect() const
{
return QRectF (0,0,ancho,alto);
}
void Cursor::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
painter->setPen(Qt::white);
if (CursorDrawMode==true)
{
painter->drawLine(EjeX);
painter->drawLine(EjeY);
}
else
{
painter->drawRect(SquareSelect);
}
}
void Cursor::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
}
void Cursor::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
EjeX.setLine(0,event->pos().y(),ancho,event->pos().y());
EjeY.setLine(event->pos().x(),0,event->pos().x(),alto);
SquareSelect.setRect(event->pos().x()-5,event->pos().y()-5,10,10);
qDebug()<<event->pos().x()<<"-"<<event->pos().y();
update();
}
void Cursor::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
}
void Cursor::resize(QRectF rec)
{
EjeX.setLine(0,rec.x()/2,rec.y(),rec.x()/2);
EjeY.setLine(rec.x()/2,0,rec.x()/2,rec.y());
}