-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmainwindow.cpp
56 lines (51 loc) · 1.72 KB
/
mainwindow.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
//copyright (c) Evgenii Lezhnin <[email protected]>, 2014
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "pointgraphicsview.h"
#include "pointgraphicsscene.h"
#include "pointitem.h"
#include <QToolBar>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow), lastPointItem_(NULL)
{
ui->setupUi(this);
QHBoxLayout *box = new QHBoxLayout();
PointGraphicsView *view = new PointGraphicsView(this);
box->addWidget(view);
scene_ = static_cast<PointGraphicsScene*>(view->scene());
ui->dummy_widget->setLayout(box);
createToolbar();
connect(ui->drawButton,SIGNAL(clicked()),this,SLOT(apply()));
connect(ui->drawButton,SIGNAL(clicked()),scene_,SLOT(updateLines()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::changeSettings_slot(PointItem *p)
{
if (lastPointItem_) {
apply();
disconnect(lastPointItem_,SLOT(setParams_slot(double,double,double)));
}
ui->bias_edit->setEnabled(1);
ui->cont_edit->setEnabled(1);
ui->tens_edit->setEnabled(1);
ui->bias_edit->setValue(p->bias());
ui->cont_edit->setValue(p->continuity());
ui->tens_edit->setValue(p->tension());
connect(this,SIGNAL(setParams(double,double,double)),p,SLOT(setParams_slot(double,double,double)));
lastPointItem_ = p;
}
void MainWindow::apply()
{
setParams(ui->bias_edit->value(),ui->cont_edit->value(),ui->tens_edit->value());
}
void MainWindow::createToolbar() {
QAction *pointAct = new QAction(tr("&Add Point"),this);
connect(pointAct,SIGNAL(triggered(bool)),scene_,SLOT(change_point_mode(bool)));
pointAct->setCheckable(1);
QToolBar *toolbar = addToolBar(tr("&Add Control Point"));
toolbar->addAction(pointAct);
}