source: projectionDesigner/trunk/projdesigner/src/gui/QPreferenceDialog.cpp @ 287

Last change on this file since 287 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 5.2 KB
Line 
1#include "ProjectionModel.h"
2#include "Scene.h"
3#include "Screen.h"
4#include "RSync.h"
5#include "Exporter.h"
6#include "GUIControler.h"
7#include "gui/Defines.h"
8#include "gui/QDesignViewWindow.h"
9#include "gui/QDesignViewWidget.h"
10#include "gui/QPreferenceDialog.h"
11
12using namespace projection;
13
14QPreferenceDialog::QPreferenceDialog(QWidget* pParent, Qt::WFlags flags)
15    : QDialog(pParent, flags)
16{
17    ui.setupUi(this);
18    setFixedSize(sizeHint());
19
20    m_pModel = NULL;
21}
22
23QPreferenceDialog::~QPreferenceDialog()
24{
25}
26
27void QPreferenceDialog::setModel(ProjectionModel* pModel)
28{
29    m_pModel = pModel;
30    if (m_pModel->getRSync()->isServer())
31        m_pDesignView = ((QDesignViewWindow*)m_pModel->getGUI()->getMainWindow())->getDesignView();
32
33    updateGUI();
34}
35
36void QPreferenceDialog::updateGUI()
37{
38    if (m_pModel)
39    {
40        ui.gridSizeEdit->setText(formatValue(m_pDesignView->gridSize()));
41        ui.gridSubdivSpinBox->setValue(m_pDesignView->gridSubdivision());
42
43        ui.bufferWidthComboBox->setCurrentIndex(ui.bufferWidthComboBox->findText(QString::number(m_pModel->getScreen()->getBufferWidth())));
44        ui.bufferHeightComboBox->setCurrentIndex(ui.bufferHeightComboBox->findText(QString::number(m_pModel->getScreen()->getBufferHeight())));
45
46                // If the export_width is not in the combo, we add the item.
47                int index_width = ui.exportWidthComboBox->findText(QString::number(m_pModel->getExporter()->getExportWidth()));
48                if (-1==index_width)
49                {
50                    int nb_items=ui.exportWidthComboBox->count();
51                        ui.exportWidthComboBox->insertItem (nb_items, QString::number(m_pModel->getExporter()->getExportWidth()));
52                ui.exportWidthComboBox->setCurrentIndex(nb_items);
53                }
54                else
55                {
56                    ui.exportWidthComboBox->setCurrentIndex(index_width);
57                }
58
59                // Same thing for the export_heith: if it is not in the combo, we add the item.
60                int index_height = ui.exportHeightComboBox->findText(QString::number(m_pModel->getExporter()->getExportHeight()));
61                if (-1==index_height)
62                {
63                        int nb_items=ui.exportHeightComboBox->count();
64                        ui.exportHeightComboBox->insertItem (nb_items, QString::number(m_pModel->getExporter()->getExportHeight()));
65                        ui.exportHeightComboBox->setCurrentIndex(nb_items);
66                }
67                else
68                {
69                        ui.exportHeightComboBox->setCurrentIndex(index_height);
70        }
71
72        ui.softEdgeCheckBox->setChecked(m_pModel->getExporter()->getSoftEdge());
73        ui.blendEdgeWidthSpinBox->setValue(m_pModel->getExporter()->getBlendEdgeWidth());
74        ui.blendEdgeExponentEdit->setText(QString::number(m_pModel->getExporter()->getBlendEdgeExponent()));
75        ui.exportDistortMapPatternEdit->setText(m_pModel->getExporter()->getDistortMapFileNamePattern());
76        ui.exportBlendMapPatternEdit->setText(m_pModel->getExporter()->getBlendMapFileNamePattern());
77        ui.exportViewMatrixPatternEdit->setText(m_pModel->getExporter()->getViewMatrixFileNamePattern());
78    }
79}
80
81void QPreferenceDialog::on_gridSizeEdit_editingFinished()
82{
83    if (m_pModel && m_pDesignView->gridSize() != ui.gridSizeEdit->text().toFloat()) {
84                m_pDesignView->setGridSize(ui.gridSizeEdit->text().toFloat());
85        m_pDesignView->updateGL();
86    }
87}
88
89void QPreferenceDialog::on_gridSubdivSpinBox_valueChanged(int value)
90{
91    if (m_pModel && m_pDesignView->gridSubdivision() != value) {
92                m_pDesignView->setGridSubdivision(value);
93        m_pDesignView->updateGL();
94    }
95}
96
97void QPreferenceDialog::on_bufferWidthComboBox_activated(int)
98{
99    if (m_pModel)
100        m_pModel->getScreen()->setBufferSize(ui.bufferWidthComboBox->currentText().toInt(),
101                                             ui.bufferHeightComboBox->currentText().toInt());
102}
103
104void QPreferenceDialog::on_bufferHeightComboBox_activated(int)
105{
106    if (m_pModel)
107        m_pModel->getScreen()->setBufferSize(ui.bufferWidthComboBox->currentText().toInt(),
108                                             ui.bufferHeightComboBox->currentText().toInt());
109}
110
111void QPreferenceDialog::on_exportWidthComboBox_activated(int)
112{
113        if (m_pModel)
114                m_pModel->getExporter()->setExportWidth(ui.exportWidthComboBox->currentText().toInt());
115}
116
117void QPreferenceDialog::on_exportHeightComboBox_activated(int)
118{
119        if (m_pModel)
120                m_pModel->getExporter()->setExportHeight(ui.exportHeightComboBox->currentText().toInt());
121}
122
123void QPreferenceDialog::on_softEdgeCheckBox_toggled(bool checked)
124{
125        if (m_pModel)
126                m_pModel->getExporter()->setSoftEdge(checked);
127}
128
129void QPreferenceDialog::on_blendEdgeWidthSpinBox_valueChanged(int value)
130{
131        if (m_pModel)
132                m_pModel->getExporter()->setBlendEdgeWidth(value);
133}
134
135void QPreferenceDialog::on_blendEdgeExponentEdit_editingFinished()
136{
137        if (m_pModel)
138                m_pModel->getExporter()->setBlendEdgeExponent(ui.blendEdgeExponentEdit->text().toFloat());
139}
140
141void QPreferenceDialog::on_exportDistortMapPatternEdit_editingFinished()
142{
143    if (m_pModel)
144        m_pModel->getExporter()->setDistortMapFileNamePattern(ui.exportDistortMapPatternEdit->text());
145}
146
147void QPreferenceDialog::on_exportBlendMapPatternEdit_editingFinished()
148{
149    if (m_pModel)
150        m_pModel->getExporter()->setBlendMapFileNamePattern(ui.exportBlendMapPatternEdit->text());
151}
152
153void QPreferenceDialog::on_exportViewMatrixPatternEdit_editingFinished()
154{
155    if (m_pModel)
156        m_pModel->getExporter()->setViewMatrixFileNamePattern(ui.exportViewMatrixPatternEdit->text());
157}
Note: See TracBrowser for help on using the repository browser.