-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove.cpp
70 lines (59 loc) · 1.85 KB
/
move.cpp
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 <QtGui>
#include <QWidget>
#include <QLabel>
#include <QDialogButtonBox>
#include "move.h"
#include "arrows.h"
#include "plot.h"
#include "curve.h"
#include "cselect.h"
MoveDialog::MoveDialog(const QList<Curve*> curves, QWidget *parent):
QDialog(parent)
{
setWindowTitle(tr("Shift pattern"));
QVBoxLayout *vlayout = new QVBoxLayout(this);
QLabel *sel = new QLabel(tr("Select patterns to shift"),this);
vlayout->addWidget(sel);
list = new CurveSelector(curves,this);
vlayout->addWidget(list);
QHBoxLayout *hlayout = new QHBoxLayout();
vlayout->addLayout(hlayout);
QLabel *label = new QLabel(tr("Move by:"),this);
edit = new QLineEdit(tr("0"),this);
edit->selectAll();
// FIXME: Add QValidator
hlayout->addWidget(label);
hlayout->addWidget(edit);
Arrows *arrows = new Arrows(this);
vlayout->addWidget(arrows);
connect(arrows,SIGNAL(clicked(Qt::ArrowType)),this,
SLOT(arrow_click(Qt::ArrowType)));
QDialogButtonBox *buttons = new QDialogButtonBox(this);
QPushButton *closeButton = buttons->addButton(QDialogButtonBox::Close);
vlayout->addWidget(buttons);
connect(closeButton,SIGNAL(clicked()),this,SLOT(close()));
}
void MoveDialog::arrow_click(Qt::ArrowType t)
{
double s = edit->text().toDouble();
foreach (Curve* m, list->selected())
{
switch (t)
{
case Qt::UpArrow:
m->move(0.0,s);
break;
case Qt::DownArrow:
m->move(0.0,-1.0*s);
break;
case Qt::LeftArrow:
m->move(-1.0*s,0.0);
break;
case Qt::RightArrow:
m->move(s,0.0);
break;
default:
;
}
}
}