-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlabpage.cpp
More file actions
70 lines (62 loc) · 1.88 KB
/
Copy pathlabpage.cpp
File metadata and controls
70 lines (62 loc) · 1.88 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
#include "labpage.h"
#include "ui_labpage.h"
#include "dfam.h"
#include "turm.h"
labpage::labpage(QWidget *parent) :
QWidget(parent),
ui(new Ui::labpage)
{
ui->setupUi(this);
selectedvertex1=NULL;
selectedvertex2=NULL;
switchofvertex =1;
}
void labpage::paintEvent(QPaintEvent *event)
{
QPainter * painter =new QPainter (this);//vazifeye draw
painter->setRenderHint(QPainter::Antialiasing,true);//saaf konande khat
painter->fillRect(0,0,861,591,Qt::white);//rasm safhe
dmach->draw(painter);//chandrikhti
delete painter;
}
void labpage::createlab()
{
dmach=new AL::dfam;
selectedobject =NULL;
}
void labpage::mousePressEvent(QMouseEvent * event)
{
auto p = mapFromGlobal(QCursor::pos());//return position of click
selectedobject = dmach->getselectedobject(AL::vectorr (p.x(),p.y()));
//pointofpress = mapFromGlobal(QCursor::pos());
//selectedvertex = dmach->getselectedvertex(AL::vectorr (p.x(),p.y()));
if(switchofvertex==1 )//yaani alan nobat avvali mibashad . pas avval avvali baad dovvomi
{
pointofpress1 = mapFromGlobal(QCursor::pos());
selectedvertex1 = dmach->getselectedvertex(AL::vectorr (p.x(),p.y()));
switchofvertex=2;
}
else
{
if (switchofvertex==2)//yaani alan nobat dovvomi mibashad . pas avval dovvomi baad avvali
{
pointofpress2 = mapFromGlobal(QCursor::pos());//noqte press shode
selectedvertex2 = dmach->getselectedvertex(AL::vectorr (p.x(),p.y()));//agar vertex select shode bood asign mishavad
switchofvertex=1;
}
}
}
void labpage::mouseMoveEvent(QMouseEvent *event)
{
if(selectedobject)
{
auto p = mapFromGlobal(QCursor::pos());//return position of click
selectedobject->setposition(AL::vectorr(p.x(),p.y()));
update();
}
}
labpage::~labpage()
{
delete ui;
delete dmach;
}