source: projectionDesigner/trunk/projdesignerplugins/defaultplugin/DefaultModelSceneWidget.cpp @ 361

Last change on this file since 361 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 2.7 KB
Line 
1#include "DefaultModelSceneWidget.h"
2
3
4/**
5 * Default constructor.
6 *
7 */
8DefaultModelSceneWidget::DefaultModelSceneWidget(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 */
19DefaultModelSceneWidget::~DefaultModelSceneWidget()
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 DefaultModelSceneWidget::updateGUI(const SceneContent* _content)
37{
38    if (_content)
39    {
40        const DefaultModelSceneContent *content = static_cast<const DefaultModelSceneContent*>(_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    modelFileNameEdit->setText(m_content.fileName());
46    modelCullingCheckBox->setChecked(m_content.backFaceCulling());
47    modelSmoothingCheckBox->setChecked(m_content.smoothing());
48}
49
50
51/**
52 * [private slot] Called when the "filename" field is edited.
53 *
54 */
55void DefaultModelSceneWidget::on_modelFileNameEdit_editingFinished()
56{
57    QString fileName = modelFileNameEdit->text();
58    if (fileName!=m_content.fileName())
59    {
60        m_content.setFileName(fileName);
61        emit dataChanged(m_content);
62    }
63}
64
65
66/**
67 * [private slot] Called when the "browse" button is pressed.
68 *
69 */
70void DefaultModelSceneWidget::on_modelBrowseButton_clicked()
71{
72    QString fileName = QFileDialog::getOpenFileName(this, "Choose a file to open", modelFileNameEdit->text(), "Model files (*.obj)");
73    if (!fileName.isEmpty()) {
74        modelFileNameEdit->setText(fileName);
75        on_modelFileNameEdit_editingFinished();
76    }
77}
78
79
80/**
81 * [private slot] Called when the culling checkbox state changes.
82 *
83 * @param checked true if the checkbox is checked.
84 *
85 */
86void DefaultModelSceneWidget::on_modelCullingCheckBox_toggled(bool checked)
87{
88    if (checked!=m_content.backFaceCulling())
89    {
90        m_content.setBackFaceCulling(checked);
91        emit dataChanged(m_content);
92    }
93}
94
95
96/**
97 * [private slot] Called when the smooth checkbox state changes.
98 *
99 * @param checked true if the checkbox is checked.
100 *
101 */
102void DefaultModelSceneWidget::on_modelSmoothingCheckBox_toggled(bool checked)
103{
104    if (checked!=m_content.smoothing())
105    {
106        m_content.setSmoothing(checked);
107        emit dataChanged(m_content);
108    }
109}
Note: See TracBrowser for help on using the repository browser.