-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpNode.cpp
More file actions
55 lines (43 loc) · 1.14 KB
/
Copy pathSpNode.cpp
File metadata and controls
55 lines (43 loc) · 1.14 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
#include "SpNode.h"
using namespace std;
SpNode::SpNode(QPointF pos, QPointF tan_1, QPointF tan_2){
radius = 7;
position = pos;
lef = new SpHook(tan_1,1);
rig = new SpHook(tan_2,2);
this->addToGroup(lef);
this->addToGroup(rig);
this->setPos(position);
color = Qt::red;
}
SpNode::~SpNode(){
}
QRectF SpNode::boundingRect() const{
return QRectF(0, 0, 10, 10);
}
void SpNode::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
painter->setRenderHint(QPainter::Antialiasing);
painter->setBrush(Qt::black);
painter->drawLine(QPointF(0,0), lef->GetPosition());
painter->drawLine(QPointF(0,0), rig->GetPosition());
painter->setBrush(color);
painter->drawEllipse(-radius/2, -radius/2, radius, radius);
}
QPointF SpNode::GetPosition(){
return position;
}
void SpNode::SetPosition(QPointF pos){
position = pos;
}
SpHook * SpNode::getLef(){
return lef;
}
SpHook * SpNode::getRig(){
return rig;
}
void SpNode::mouseHoverEvent(QGraphicsSceneMouseEvent * event){
color = Qt::yellow;
}
void SpNode::mouseLeaveEvent(QGraphicsSceneMouseEvent * event){
color = Qt::red;
}