source: projectionDesigner/trunk/projdesignerplugins/defaultplugin/DefaultProjectorWidget.cpp @ 322

Last change on this file since 322 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 3.3 KB
Line 
1#include "DefaultProjectorWidget.h"
2
3
4/**
5 * Format the value in a QString.
6 *
7 * This procedure is implemented for convenience, because it was used in the original Projection Designer.
8 *
9 * @param value The value to format.
10 *
11 * @return The formatted QString.
12 *
13 */
14static QString formatValue(double value)
15{
16    return QString::number(value, 'f', 4);
17}
18
19
20/**
21 * Default constructor fot the DefaultProjectorWidget.
22 *
23 */
24DefaultProjectorWidget::DefaultProjectorWidget(ProjectorInterface *plugin, QWidget* pParent, Qt::WFlags flag): ProjectorWidget(plugin, pParent, flag), m_data(plugin)
25{
26    setupUi (this);
27    updateGUI();
28}
29
30
31/**
32 * Destructor fot the DefaultProjectorWidget.
33 *
34 */
35DefaultProjectorWidget::~DefaultProjectorWidget()
36{
37}
38
39
40/**
41 * Updates the widget.
42 *
43 * This method can be used it two ways: to force a refresh or to update the
44 * data of the widget.
45 *
46 * @param data A const pointer on the data to be used for the widget. This
47 *             data will be duplicated in the widget. If data is NULL, the
48 *             current data are used and the refresh is forced.
49 *
50 */
51void DefaultProjectorWidget::updateGUI(const ProjectorData* data)
52{
53    if (NULL!=data) m_data.copy_from(*data);
54    fovEdit->setText(formatValue(m_data.fov()));
55    aspectRatioEdit->setText(QString::number(m_data.aspectRatio(), 'g'));
56    nearEdit->setText(QString::number(m_data.nearDist(), 'g'));
57    farEdit->setText(QString::number(m_data.farDist(), 'g'));
58    offaxisXEdit->setText(formatValue(m_data.offaxisX()));
59    offaxisYEdit->setText(formatValue(m_data.offaxisY()));
60}
61
62
63/**
64 * Clears the fields of the widget.
65 *
66 * This method is typically used when the widget will be disabled (if no
67 * channel is specified in Projection Designer, the widget is visible but
68 * disabled: fields must be empty).
69 *
70 */
71void DefaultProjectorWidget::clear(void)
72{
73    fovEdit->setText("");
74    aspectRatioEdit->setText("");
75    nearEdit->setText("");
76    farEdit->setText("");
77    offaxisXEdit->setText("");
78    offaxisYEdit->setText("");
79}
80
81
82/**
83 * [private slot] Called when the Fov changes.
84 *
85 */
86void DefaultProjectorWidget::on_fovEdit_editingFinished()
87{
88    m_data.setFov(fovEdit->text().toFloat());
89    updateGUI();
90    emit dataChanged(m_data);
91}
92
93
94/**
95 * [private slot] Called when the Aspect Ratio changes.
96 *
97 */
98void DefaultProjectorWidget::on_aspectRatioEdit_editingFinished()
99{
100    m_data.setAspectRatio(aspectRatioEdit->text().toFloat());
101    updateGUI();
102    emit dataChanged(m_data);
103}
104
105
106/**
107 * [private slot] Called when the Near changes.
108 *
109 */
110void DefaultProjectorWidget::on_nearEdit_editingFinished()
111{
112    m_data.setNearDist(nearEdit->text().toFloat());
113    updateGUI();
114    emit dataChanged(m_data);
115}
116
117
118/**
119 * [private slot] Called when the Far changes.
120 *
121 */
122void DefaultProjectorWidget::on_farEdit_editingFinished()
123{
124    m_data.setFarDist(farEdit->text().toFloat());
125    updateGUI();
126    emit dataChanged(m_data);
127}
128
129
130/**
131 * [private slot] Called when the OffAxis-X changes.
132 *
133 */
134void DefaultProjectorWidget::on_offaxisXEdit_editingFinished()
135{
136    m_data.setOffaxisX(offaxisXEdit->text().toFloat());
137    updateGUI();
138    emit dataChanged(m_data);
139}
140
141
142/**
143 * [private slot] Called when the OffAxis-Y changes.
144 *
145 */
146void DefaultProjectorWidget::on_offaxisYEdit_editingFinished()
147{
148    m_data.setOffaxisY(offaxisYEdit->text().toFloat());
149    updateGUI();
150    emit dataChanged(m_data);
151}
152
153
Note: See TracBrowser for help on using the repository browser.