#include "DefaultProjectorWidget.h" /** * Format the value in a QString. * * This procedure is implemented for convenience, because it was used in the original Projection Designer. * * @param value The value to format. * * @return The formatted QString. * */ static QString formatValue(double value) { return QString::number(value, 'f', 4); } /** * Default constructor fot the DefaultProjectorWidget. * */ DefaultProjectorWidget::DefaultProjectorWidget(ProjectorInterface *plugin, QWidget* pParent, Qt::WFlags flag): ProjectorWidget(plugin, pParent, flag), m_data(plugin) { setupUi (this); updateGUI(); } /** * Destructor fot the DefaultProjectorWidget. * */ DefaultProjectorWidget::~DefaultProjectorWidget() { } /** * Updates the widget. * * This method can be used it two ways: to force a refresh or to update the * data of the widget. * * @param data A const pointer on the data to be used for the widget. This * data will be duplicated in the widget. If data is NULL, the * current data are used and the refresh is forced. * */ void DefaultProjectorWidget::updateGUI(const ProjectorData* data) { if (NULL!=data) m_data.copy_from(*data); fovEdit->setText(formatValue(m_data.fov())); aspectRatioEdit->setText(QString::number(m_data.aspectRatio(), 'g')); nearEdit->setText(QString::number(m_data.nearDist(), 'g')); farEdit->setText(QString::number(m_data.farDist(), 'g')); offaxisXEdit->setText(formatValue(m_data.offaxisX())); offaxisYEdit->setText(formatValue(m_data.offaxisY())); } /** * 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 DefaultProjectorWidget::clear(void) { fovEdit->setText(""); aspectRatioEdit->setText(""); nearEdit->setText(""); farEdit->setText(""); offaxisXEdit->setText(""); offaxisYEdit->setText(""); } /** * [private slot] Called when the Fov changes. * */ void DefaultProjectorWidget::on_fovEdit_editingFinished() { m_data.setFov(fovEdit->text().toFloat()); updateGUI(); emit dataChanged(m_data); } /** * [private slot] Called when the Aspect Ratio changes. * */ void DefaultProjectorWidget::on_aspectRatioEdit_editingFinished() { m_data.setAspectRatio(aspectRatioEdit->text().toFloat()); updateGUI(); emit dataChanged(m_data); } /** * [private slot] Called when the Near changes. * */ void DefaultProjectorWidget::on_nearEdit_editingFinished() { m_data.setNearDist(nearEdit->text().toFloat()); updateGUI(); emit dataChanged(m_data); } /** * [private slot] Called when the Far changes. * */ void DefaultProjectorWidget::on_farEdit_editingFinished() { m_data.setFarDist(farEdit->text().toFloat()); updateGUI(); emit dataChanged(m_data); } /** * [private slot] Called when the OffAxis-X changes. * */ void DefaultProjectorWidget::on_offaxisXEdit_editingFinished() { m_data.setOffaxisX(offaxisXEdit->text().toFloat()); updateGUI(); emit dataChanged(m_data); } /** * [private slot] Called when the OffAxis-Y changes. * */ void DefaultProjectorWidget::on_offaxisYEdit_editingFinished() { m_data.setOffaxisY(offaxisYEdit->text().toFloat()); updateGUI(); emit dataChanged(m_data); }