#include "DefaultTeapotSceneWidget.h" /** * Default constructor. * */ DefaultTeapotSceneWidget::DefaultTeapotSceneWidget(SceneInterface *plugin, QWidget* pParent, Qt::WFlags flag): SceneWidget(plugin, pParent, flag), m_content(plugin) { setupUi (this); updateGUI(); } /** * Destructor. * */ DefaultTeapotSceneWidget::~DefaultTeapotSceneWidget() { } /** * Updates the widget. * * This method can be used it two ways: to force a refresh or to update the * contents of the widget. * * @param content A const pointer on the contents to be used for the widget. * This contents will be duplicated in the widget. If content * is NULL, the current contents are used and the refresh is * forced. If no content is given, NULL is used. * */ void DefaultTeapotSceneWidget::updateGUI(const SceneContent* _content) { if (_content) { const DefaultTeapotSceneContent *content = static_cast(_content); Q_ASSERT(NULL!=content); // <-- Assume that the conversion was successful m_content.copy_from(*content); } // From now, we will only use m_content if (m_content.wireframe()) { wireframeCheckBox->setCheckState(Qt::Checked); widthSpinBox->setValue(m_content.width()); } else { wireframeCheckBox->setCheckState(Qt::Unchecked); } } /** * Clears the fields of the widget. * * This method is typically used when the widget will be disabled (if no * channel is specified in Projection Designer, the widget is visible but * disabled: fields must be empty). * */ void DefaultTeapotSceneWidget::clear(void) { widthSpinBox->clear(); wireframeCheckBox->setCheckState(Qt::Unchecked); } /** * [private slot] Called when the wireframe checkbox state changes. * */ void DefaultTeapotSceneWidget::on_wireframeCheckBox_stateChanged(int state) { bool wireframe=(Qt::Checked==state); widthSpinBox->setEnabled(wireframe); widthLabel->setEnabled(wireframe); if (wireframe!=m_content.wireframe()) { m_content.setWireframe(wireframe); emit dataChanged(m_content); } } /** * [private slot] Called when the width changes. * */ void DefaultTeapotSceneWidget::on_widthSpinBox_valueChanged(int width) { if (width!=m_content.width()) { m_content.setWidth(width); emit dataChanged(m_content); } }