-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent.cpp
More file actions
123 lines (100 loc) · 3.35 KB
/
Copy pathevent.cpp
File metadata and controls
123 lines (100 loc) · 3.35 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "event.h"
#include <QDebug>
Event::Event()
{
attributes = new AttributeList();
Attribute* newName = new Attribute(Attribute::STRING, "name");
newName->setData(std::string("New Event"));
connect(newName, SIGNAL(VisualDataUpdated()), this, SLOT(updateEventLabel()));
Attribute* newColor = new Attribute(Attribute::COLOR, "color");
newColor->setData(Qt::green);
connect(newName, SIGNAL(VisualDataUpdated()), this, SLOT(updateEventLabel()));
attributes->Push(newName);
attributes->Push(newColor);
}
Event::~Event()
{
}
void Event::setName(std::string nameInput)
{
attributes->Get("name")->setData(std::string(nameInput));
}
std::string Event::getName()
{
return attributes->Get("name")->GetText();
}
QLabel* Event::DrawEvent(QFrame* parent)
{
//load the image into a pixmap
QPixmap* pix = new QPixmap(150,100);
pix->fill(Qt::transparent);
QPainter painter;
painter.begin(pix);
painter.setBrush(Qt::green);
painter.drawRect(0,0,150,100);
painter.drawText(pix->rect(),Qt::AlignCenter, QString::fromStdString(getName()));
painter.end();
//make it viewable
QLabel* newLabel = new QLabel(parent);
newLabel->setPixmap(*pix);
newLabel->setAlignment(Qt::AlignCenter);
newLabel->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
newLabel->setAttribute(Qt::WA_DeleteOnClose);
newLabel->show();
delete pix;
label = newLabel;
return newLabel;
}
void Event::updateEventLabel()
{
//load the image into a pixmap
QPixmap* pix = new QPixmap(150,100);
pix->fill(Qt::transparent);
QPainter painter;
painter.begin(pix);
painter.setBrush(Qt::green);
painter.drawRect(0,0,150,100);
painter.drawText(pix->rect(),Qt::AlignCenter, QString::fromStdString(getName()));
painter.end();
label->setPixmap(*pix);
label->show();
}
std::vector<QPoint*> Event::getMolLabelPoints()
{
std::vector<QPoint*> ret = inputs.GetLabelPoints();
std::vector<QPoint*> add = outputs.GetLabelPoints();
ret.insert(std::end(ret), std::begin(add), std::end(add));
return ret;
}
void Event::Edit(QFrame* parent){
editor = new VisualEditor(parent, attributes);
}
void Event::processDragAction(QLabel* startPtr, QPoint endPoint, QFrame* parent)
{
if(startPtr->pos().y() < parent->frameRect().height()/2 && endPoint.y() < parent->frameRect().height()/2)
{
//movement in input
inputs.Move(startPtr, endPoint);
}
else if(startPtr->pos().y() < parent->frameRect().height()/2 && endPoint.y() > parent->frameRect().height()/2)
{
//input to output
int destination = outputs.PositionToVector(endPoint);
outputs.Insert(inputs.Get(startPtr), destination);
inputs.Pop(startPtr);
}
else if(startPtr->pos().y() > parent->frameRect().height()/2 && endPoint.y() < parent->frameRect().height()/2)
{
//output to input
int destination = inputs.PositionToVector(endPoint);
inputs.Insert(outputs.Get(startPtr), destination);
outputs.Pop(startPtr);
}
else if(startPtr->pos().y() > parent->frameRect().height()/2 && endPoint.y() > parent->frameRect().height()/2)
{
//movement in output
outputs.Move(startPtr, endPoint);
}
inputs.DrawMoleculeList();
outputs.DrawMoleculeList();
}