-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
59 lines (45 loc) · 1.93 KB
/
mainwindow.cpp
File metadata and controls
59 lines (45 loc) · 1.93 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
#include "mainwindow.h"
static const int MIN_WIDTH = 550;
static const int MIN_HEIGHT = 600;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
// set minimum window size and load default plant
setMinimumSize(MIN_WIDTH, MIN_HEIGHT);
Plant::activePlant = PersistenceManager::readPlant("default.plant");
// define a QGLFormat with multisampling and alpha blending
QGLFormat fmt;
fmt.setAlpha(true);
fmt.setSampleBuffers(true);
fmt.setSamples(8);
// apply default format before creation of the QGLWidget (done in the ui setup)
QGLFormat::setDefaultFormat(fmt);
ui->setupUi(this);
// load a scene to display
Scene::activeScene = new Scene(ui->panelGL);
// set window title and statusbar message
ui->statusBar->showMessage("Left-click to rotate model - right-click to move model - move mousewheel to zoom model.");
setWindowTitle("OpenGL-Plants");
// some buttons for the button box
btnQuit = new QPushButton("Quit");
btnOptions = new QPushButton("Options");
ui->buttonBox->addButton(btnOptions, QDialogButtonBox::ActionRole);
ui->buttonBox->addButton(btnQuit, QDialogButtonBox::RejectRole);
// a reject action for the quit button
connect(btnQuit, SIGNAL(clicked()), this, SLOT(close()));
connect(btnOptions, SIGNAL(clicked()), this, SLOT(showOptionsDialog()));
// prepare a tabbed Options Dialog
tabs = new TabbedOptionsDialog;
// connect glpanel and optionsformlayout, and the other way around
connect(ui->panelGL, SIGNAL(cameraChanged(int,int,int)), tabs, SLOT(changeCamera(int,int,int)));
connect(tabs, SIGNAL(cameraChanged(int,int,int)), ui->panelGL, SLOT(changeCamera(int,int,int)));
connect(ui->panelGL, SIGNAL(renderingDone()), tabs, SLOT(updateCounts()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::showOptionsDialog() {
tabs->isVisible() ? tabs->hide() : tabs->show();
}