source: projectionDesigner/trunk/projdesigner/src/gui/QScreenWidget.cpp @ 373

Last change on this file since 373 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 7.8 KB
RevLine 
[4]1#include "Screen.h"
2#include "screen/ScreenDome.h"
3#include "screen/ScreenPlane.h"
4#include "screen/ScreenBox.h"
5#include "screen/ScreenModel.h"
6#include "gui/Defines.h"
7#include "gui/QScreenWidget.h"
8
9using namespace projection;
10
11QScreenWidget::QScreenWidget(QWidget* pParent, Qt::WFlags flags)
12    : QWidget(pParent, flags)
13{
14    ui.setupUi(this);
15
16    m_pScreen = NULL;
17}
18
19QScreenWidget::~QScreenWidget()
20{
21}
22
23void QScreenWidget::setScreen(Screen* pScreen)
24{
25    m_pScreen = pScreen;
26    ui.typeComboBox->clear();
27    for (unsigned int i=0; i<m_pScreen->getNumShapes(); ++i)
28        ui.typeComboBox->addItem(m_pScreen->getShapeName(i));
29
30    updateGUI();
31}
32
33void QScreenWidget::updateGUI()
34{
35    if (m_pScreen)
36    {
37        ui.transformWidget->setMatrix(m_pScreen->getMatrix());
38
39        if (m_pScreen->getCurrentShapeName() == "Dome")
40        {
41            ScreenDome* pScreenDome = (ScreenDome*)m_pScreen->getCurrentShape();
42            ui.domeRadiusEdit->setText(formatValue(pScreenDome->getRadius()));
43            ui.domeAzimResSpinBox->setValue(pScreenDome->getAzimResolution());
44            ui.domeElevResSpinBox->setValue(pScreenDome->getElevResolution());
45            ui.domeSubdivSpinBox->setValue(pScreenDome->getSubdivision());
46            ui.domeFullDomeCheckBox->setChecked(pScreenDome->getFullDome());
47        }
48        else if (m_pScreen->getCurrentShapeName() == "Plane")
49        {
50            ScreenPlane* pScreenPlane = (ScreenPlane*)m_pScreen->getCurrentShape();
51            ui.planeWidthEdit->setText(formatValue(pScreenPlane->getWidth()));
52            ui.planeHeightEdit->setText(formatValue(pScreenPlane->getHeight()));
53            ui.planeHorResSpinBox->setValue(pScreenPlane->getHorResolution());
54            ui.planeVertResSpinBox->setValue(pScreenPlane->getVertResolution());
55        }
56        else if (m_pScreen->getCurrentShapeName() == "Box")
57        {
58            ScreenBox* pScreenBox = (ScreenBox*)m_pScreen->getCurrentShape();
59            ui.boxWidthEdit->setText(formatValue(pScreenBox->getWidth()));
60            ui.boxHeightEdit->setText(formatValue(pScreenBox->getHeight()));
61            ui.boxDepthEdit->setText(formatValue(pScreenBox->getDepth()));
62            ui.boxHorResSpinBox->setValue(pScreenBox->getHorResolution());
63            ui.boxVertResSpinBox->setValue(pScreenBox->getVertResolution());
64            ui.boxDepthResSpinBox->setValue(pScreenBox->getDepthResolution());
65        }
66        else if (m_pScreen->getCurrentShapeName() == "Model")
67        {
68            ScreenModel* pScreenModel = (ScreenModel*)m_pScreen->getCurrentShape();
69            ui.modelFileNameEdit->setText(pScreenModel->getFileName());
70        }
71        ui.frameCheckBox->setChecked(m_pScreen->getShowFrame());
72        ui.frameLineWidthSpinBox->setValue(m_pScreen->getFrameLineWidth());
73
74        ui.typeComboBox->setCurrentIndex(ui.typeComboBox->findText(m_pScreen->getCurrentShapeName()));
75        ui.stackedWidget->setCurrentIndex(ui.typeComboBox->currentIndex());
76    }
77}
78
79void QScreenWidget::on_typeComboBox_activated(int)
80{
81    if (m_pScreen)
82    {
83        m_pScreen->setCurrentShape(ui.typeComboBox->currentText());
84        updateGUI();
85    }
86}
87
88void QScreenWidget::on_transformWidget_matrixChanged(const TransformMatrix& matrix)
89{
90    if (m_pScreen && m_pScreen->getMatrix() != matrix)
91    {
92        m_pScreen->setMatrix(matrix);
93        updateGUI();
94    }
95}
96
97void QScreenWidget::on_domeRadiusEdit_editingFinished()
98{
99    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Dome")
100        ((ScreenDome*)m_pScreen->getCurrentShape())->setRadius(ui.domeRadiusEdit->text().toDouble());
101}
102
103void QScreenWidget::on_domeAzimResSpinBox_valueChanged(int value)
104{
105    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Dome")
106        ((ScreenDome*)m_pScreen->getCurrentShape())->setAzimResolution(value);
107}
108
109void QScreenWidget::on_domeElevResSpinBox_valueChanged(int value)
110{
111    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Dome")
112        ((ScreenDome*)m_pScreen->getCurrentShape())->setElevResolution(value);
113}
114
115void QScreenWidget::on_domeSubdivSpinBox_valueChanged(int value)
116{
117    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Dome")
118        ((ScreenDome*)m_pScreen->getCurrentShape())->setSubdivision(value);
119}
120
121void QScreenWidget::on_domeFullDomeCheckBox_toggled(bool checked)
122{
123    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Dome")
124        ((ScreenDome*)m_pScreen->getCurrentShape())->setFullDome(checked);
125}
126
127void QScreenWidget::on_planeWidthEdit_editingFinished()
128{
129    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Plane")
130        ((ScreenPlane*)m_pScreen->getCurrentShape())->setWidth(ui.planeWidthEdit->text().toDouble());
131}
132
133void QScreenWidget::on_planeHeightEdit_editingFinished()
134{
135    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Plane")
136        ((ScreenPlane*)m_pScreen->getCurrentShape())->setHeight(ui.planeHeightEdit->text().toDouble());
137}
138
139void QScreenWidget::on_planeHorResSpinBox_valueChanged(int value)
140{
141    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Plane")
142        ((ScreenPlane*)m_pScreen->getCurrentShape())->setHorResolution(value);
143}
144
145void QScreenWidget::on_planeVertResSpinBox_valueChanged(int value)
146{
147    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Plane")
148        ((ScreenPlane*)m_pScreen->getCurrentShape())->setVertResolution(value);
149}
150
151void QScreenWidget::on_boxWidthEdit_editingFinished()
152{
153    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Box")
154        ((ScreenBox*)m_pScreen->getCurrentShape())->setWidth(ui.boxWidthEdit->text().toDouble());
155}
156
157void QScreenWidget::on_boxHeightEdit_editingFinished()
158{
159    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Box")
160        ((ScreenBox*)m_pScreen->getCurrentShape())->setHeight(ui.boxHeightEdit->text().toDouble());
161}
162
163void QScreenWidget::on_boxDepthEdit_editingFinished()
164{
165    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Box")
166        ((ScreenBox*)m_pScreen->getCurrentShape())->setDepth(ui.boxDepthEdit->text().toDouble());
167}
168
169void QScreenWidget::on_boxHorResSpinBox_valueChanged(int value)
170{
171    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Box")
172        ((ScreenBox*)m_pScreen->getCurrentShape())->setHorResolution(value);
173}
174
175void QScreenWidget::on_boxVertResSpinBox_valueChanged(int value)
176{
177    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Box")
178        ((ScreenBox*)m_pScreen->getCurrentShape())->setVertResolution(value);
179}
180
181void QScreenWidget::on_boxDepthResSpinBox_valueChanged(int value)
182{
183    if (m_pScreen && m_pScreen->getCurrentShapeName() == "Box")
184        ((ScreenBox*)m_pScreen->getCurrentShape())->setDepthResolution(value);
185}
186
187void QScreenWidget::on_modelFileNameEdit_editingFinished()
188{
189        if (m_pScreen && m_pScreen->getCurrentShapeName() == "Model" && ui.modelFileNameEdit->text() != "" )
190        {
191                if (QFile::exists(ui.modelFileNameEdit->text()))
192                {
193                        ((ScreenModel*)m_pScreen->getCurrentShape())->setFileName(ui.modelFileNameEdit->text());
194                        //QMessageBox::information(this,"moep!",".");
195                }
196                else
197                {
198                        QMessageBox::warning(this,"Filename not Found!","Filename not Found!<br><br>Your selection will be cleared.");
199                        ui.modelFileNameEdit->clear();
200                }
201        }
202}
203
204void QScreenWidget::on_modelBrowseButton_clicked()
205{
206    QString fileName = QFileDialog::getOpenFileName(this, "Choose a file to open", ui.modelFileNameEdit->text(), "Model files (*.obj)");
207    if (!fileName.isEmpty()) {
208        ui.modelFileNameEdit->setText(fileName);
209        on_modelFileNameEdit_editingFinished();
210    }
211}
212
213void QScreenWidget::on_frameCheckBox_toggled(bool checked)
214{
215    if (m_pScreen)
216        m_pScreen->setShowFrame(checked);
217}
218
219void QScreenWidget::on_frameLineWidthSpinBox_valueChanged(int value)
220{
221    if (m_pScreen)
222        m_pScreen->setFrameLineWidth(value);
223}
Note: See TracBrowser for help on using the repository browser.