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

Last change on this file since 2 was 2, checked in by Torben Dannhauer, 10 years ago
File size: 2.3 KB
Line 
1#include "DefaultTeapotSceneWidget.h"
2
3
4/**
5 * Default constructor.
6 *
7 */
8DefaultTeapotSceneWidget::DefaultTeapotSceneWidget(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 */
19DefaultTeapotSceneWidget::~DefaultTeapotSceneWidget()
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 * contents 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 contents are used and the refresh is
33 *                forced. If no content is given, NULL is used.
34 *
35 */
36void DefaultTeapotSceneWidget::updateGUI(const SceneContent* _content)
37{
38    if (_content)
39    {
40        const DefaultTeapotSceneContent *content = static_cast<const DefaultTeapotSceneContent*>(_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    if (m_content.wireframe())
46    {
47        wireframeCheckBox->setCheckState(Qt::Checked);
48        widthSpinBox->setValue(m_content.width());
49    }
50    else
51    {
52        wireframeCheckBox->setCheckState(Qt::Unchecked);
53    }
54}
55
56
57/**
58 * Clears the fields of the widget.
59 *
60 * This method is typically used when the widget will be disabled (if no
61 * channel is specified in Projection Designer, the widget is visible but
62 * disabled: fields must be empty).
63 *
64 */
65void DefaultTeapotSceneWidget::clear(void)
66{
67    widthSpinBox->clear();
68    wireframeCheckBox->setCheckState(Qt::Unchecked);
69}
70
71
72/**
73 * [private slot] Called when the wireframe checkbox state changes.
74 *
75 */
76void DefaultTeapotSceneWidget::on_wireframeCheckBox_stateChanged(int state)
77{
78    bool wireframe=(Qt::Checked==state);
79    widthSpinBox->setEnabled(wireframe);
80    widthLabel->setEnabled(wireframe);
81    if (wireframe!=m_content.wireframe())
82    {
83        m_content.setWireframe(wireframe);
84        emit dataChanged(m_content);
85    }
86}
87
88
89/**
90 * [private slot] Called when the width changes.
91 *
92 */
93void DefaultTeapotSceneWidget::on_widthSpinBox_valueChanged(int width)
94{
95    if (width!=m_content.width())
96    {
97        m_content.setWidth(width);
98        emit dataChanged(m_content);
99    }
100}
101
Note: See TracBrowser for help on using the repository browser.