source: projectionDesigner/tag/ProjectionDesigner_1.1.5/projdesignerplugins/defaultplugin/DefaultCubemapSceneWidget.cpp @ 2

Last change on this file since 2 was 2, checked in by Torben Dannhauer, 10 years ago
File size: 6.0 KB
Line 
1#include "DefaultCubemapSceneWidget.h"
2
3
4/**
5 * Default constructor.
6 *
7 */
8DefaultCubemapSceneWidget::DefaultCubemapSceneWidget(SceneInterface *plugin, QWidget* pParent, Qt::WFlags flag): SceneWidget(plugin, pParent, flag), m_content(plugin)
9{
10    setupUi (this);
11    updateGUI();
12}
13
14
15/**
16 * Destructor.
17 *
18 */
19DefaultCubemapSceneWidget::~DefaultCubemapSceneWidget()
20{
21}
22
23
24/**
25 * Updates the widget.
26 *
27 * This method can be used it two ways: to force a refresh or to update the
28 * data of the widget.
29 *
30 * @param content A const pointer on the contents to be used for the widget.
31 *                This contents will be duplicated in the widget. If content
32 *                is NULL, the current content are used and the refresh is
33 *                forced. If no content are given, NULL is used.
34 *
35 */
36void DefaultCubemapSceneWidget::updateGUI(const SceneContent* _content)
37{
38    if (_content)
39    {
40        const DefaultCubemapSceneContent *content = static_cast<const DefaultCubemapSceneContent*>(_content);
41        Q_ASSERT(NULL!=content); // <-- Assume that the conversion was successful
42        m_content.copy_from(*content);
43    }
44    // From now, we will only use m_content
45    frontFileNameEdit->setText(m_content.getTexture(CUBEMAP_FACE_FRONT));
46    backFileNameEdit->setText(m_content.getTexture(CUBEMAP_FACE_BACK));
47    leftFileNameEdit->setText(m_content.getTexture(CUBEMAP_FACE_LEFT));
48    rightFileNameEdit->setText(m_content.getTexture(CUBEMAP_FACE_RIGHT));
49    topFileNameEdit->setText(m_content.getTexture(CUBEMAP_FACE_TOP));
50    bottomFileNameEdit->setText(m_content.getTexture(CUBEMAP_FACE_BOTTOM));
51}
52
53
54/**
55 * [private slot] Called when the "front file" field is edited.
56 *
57 */
58void DefaultCubemapSceneWidget::on_frontFileNameEdit_editingFinished()
59{
60    if (frontFileNameEdit->text()!=m_content.getTexture(CUBEMAP_FACE_FRONT))
61    {
62        m_content.setTexture(CUBEMAP_FACE_FRONT, frontFileNameEdit->text());
63        emit dataChanged(m_content);
64    }
65}
66
67
68/**
69 * [private slot] Called when the "front file" button is pressed.
70 *
71 */
72void DefaultCubemapSceneWidget::on_frontBrowseButton_clicked()
73{
74    QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a file to open"), frontFileNameEdit->text(), tr("Image files (*.*)"));
75    if (!fileName.isEmpty()) {
76        frontFileNameEdit->setText(fileName);
77        on_frontFileNameEdit_editingFinished();
78    }
79}
80
81
82/**
83 * [private slot] Called when the "back file" field is edited.
84 *
85 */
86void DefaultCubemapSceneWidget::on_backFileNameEdit_editingFinished()
87{
88    if (backFileNameEdit->text()!=m_content.getTexture(CUBEMAP_FACE_BACK))
89    {
90        m_content.setTexture(CUBEMAP_FACE_BACK, backFileNameEdit->text());
91        emit dataChanged(m_content);
92    }
93}
94
95
96/**
97 * [private slot] Called when the "back file" button is pressed.
98 *
99 */
100void DefaultCubemapSceneWidget::on_backBrowseButton_clicked()
101{
102    QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a file to open"), backFileNameEdit->text(), tr("Image files (*.*)"));
103    if (!fileName.isEmpty()) {
104        backFileNameEdit->setText(fileName);
105        on_backFileNameEdit_editingFinished();
106    }
107}
108
109
110/**
111 * [private slot] Called when the "left file" field is edited.
112 *
113 */
114void DefaultCubemapSceneWidget::on_leftFileNameEdit_editingFinished()
115{
116    if (leftFileNameEdit->text()!=m_content.getTexture(CUBEMAP_FACE_LEFT))
117    {
118        m_content.setTexture(CUBEMAP_FACE_LEFT, leftFileNameEdit->text());
119        emit dataChanged(m_content);
120    }
121}
122
123
124/**
125 * [private slot] Called when the "left file" button is pressed.
126 *
127 */
128void DefaultCubemapSceneWidget::on_leftBrowseButton_clicked()
129{
130    QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a file to open"), leftFileNameEdit->text(), tr("Image files (*.*)"));
131    if (!fileName.isEmpty()) {
132        leftFileNameEdit->setText(fileName);
133        on_leftFileNameEdit_editingFinished();
134    }
135}
136
137
138/**
139 * [private slot] Called when the "right file" field is edited.
140 *
141 */
142void DefaultCubemapSceneWidget::on_rightFileNameEdit_editingFinished()
143{
144    if (rightFileNameEdit->text()!=m_content.getTexture(CUBEMAP_FACE_RIGHT))
145    {
146        m_content.setTexture(CUBEMAP_FACE_RIGHT, rightFileNameEdit->text());
147        emit dataChanged(m_content);
148    }
149}
150
151
152/**
153 * [private slot] Called when the "right file" button is pressed.
154 *
155 */
156void DefaultCubemapSceneWidget::on_rightBrowseButton_clicked()
157{
158    QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a file to open"), rightFileNameEdit->text(), tr("Image files (*.*)"));
159    if (!fileName.isEmpty()) {
160        rightFileNameEdit->setText(fileName);
161        on_rightFileNameEdit_editingFinished();
162    }
163}
164
165
166/**
167 * [private slot] Called when the "top file" field is edited.
168 *
169 */
170void DefaultCubemapSceneWidget::on_topFileNameEdit_editingFinished()
171{
172    if (topFileNameEdit->text()!=m_content.getTexture(CUBEMAP_FACE_TOP))
173    {
174        m_content.setTexture(CUBEMAP_FACE_TOP, topFileNameEdit->text());
175        emit dataChanged(m_content);
176    }
177}
178
179
180/**
181 * [private slot] Called when the "top file" button is pressed.
182 *
183 */
184void DefaultCubemapSceneWidget::on_topBrowseButton_clicked()
185{
186    QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a file to open"), topFileNameEdit->text(), tr("Image files (*.*)"));
187    if (!fileName.isEmpty()) {
188        topFileNameEdit->setText(fileName);
189        on_topFileNameEdit_editingFinished();
190    }
191}
192
193
194/**
195 * [private slot] Called when the "bottom file" field is edited.
196 *
197 */
198void DefaultCubemapSceneWidget::on_bottomFileNameEdit_editingFinished()
199{
200    if (bottomFileNameEdit->text()!=m_content.getTexture(CUBEMAP_FACE_BOTTOM))
201    {
202        m_content.setTexture(CUBEMAP_FACE_BOTTOM, bottomFileNameEdit->text());
203        emit dataChanged(m_content);
204    }
205}
206
207
208/**
209 * [private slot] Called when the "bottom file" button is pressed.
210 *
211 */
212void DefaultCubemapSceneWidget::on_bottomBrowseButton_clicked()
213{
214    QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a file to open"), bottomFileNameEdit->text(), tr("Image files (*.*)"));
215    if (!fileName.isEmpty()) {
216        bottomFileNameEdit->setText(fileName);
217        on_bottomFileNameEdit_editingFinished();
218    }
219}
Note: See TracBrowser for help on using the repository browser.