source: projectionDesigner/trunk/projdesigner/src/gui/QProjectionMatrixWidget.cpp @ 92

Last change on this file since 92 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 2.3 KB
RevLine 
[4]1#include "gui/Defines.h"
2#include "gui/QProjectionMatrixWidget.h"
3
4using namespace projection;
5
6QProjectionMatrixWidget::QProjectionMatrixWidget(QWidget* pParent, Qt::WFlags flags)
7    : QWidget(pParent, flags)
8{
9    ui.setupUi(this);
10    m_bStopSlot = false;
11}
12
13QProjectionMatrixWidget::~QProjectionMatrixWidget()
14{
15}
16
17void QProjectionMatrixWidget::setMatrix(const ProjectionMatrix& matrix)
18{
19    if (m_bStopSlot) return;
20
21    ui.fovEdit->setText(formatValue(matrix.getFOV()));
22        ui.aspectRatioEdit->setText(QString::number(matrix.getAspectRatio(), 'g'));
23    ui.nearEdit->setText(QString::number(matrix.getNear(), 'g'));
24    ui.farEdit->setText(QString::number(matrix.getFar(), 'g'));
25    ui.offaxisXEdit->setText(formatValue(matrix.getOffaxisX()));
26    ui.offaxisYEdit->setText(formatValue(matrix.getOffaxisY()));
27
28//    checkValueChanged();
29    m_matrix = matrix;
30}
31
32ProjectionMatrix QProjectionMatrixWidget::getMatrix() const
33{
34    return m_matrix;
35}
36
37void QProjectionMatrixWidget::clear()
38{
39    ui.fovEdit->setText("");
40    ui.aspectRatioEdit->setText("");
41    ui.nearEdit->setText("");
42    ui.farEdit->setText("");
43    ui.offaxisXEdit->setText("");
44    ui.offaxisYEdit->setText("");
45    m_matrix = ProjectionMatrix();
46}
47
48void QProjectionMatrixWidget::checkValueChanged()
49{
50    ProjectionMatrix matrix;
51
52    matrix.setFOV(ui.fovEdit->text().toFloat());
53    matrix.setAspectRatio(ui.aspectRatioEdit->text().toFloat());
54    matrix.setNear(ui.nearEdit->text().toFloat());
55    matrix.setFar(ui.farEdit->text().toFloat());
56    matrix.setOffaxisX(ui.offaxisXEdit->text().toFloat());
57    matrix.setOffaxisY(ui.offaxisYEdit->text().toFloat());
58
59    if (m_matrix != matrix)
60    {
61        m_matrix = matrix;
62        m_bStopSlot = true;
63        emit matrixChanged(m_matrix);
64        m_bStopSlot = false;
65    }
66}
67
68void QProjectionMatrixWidget::on_fovEdit_editingFinished()
69{
70    checkValueChanged();
71}
72
73void QProjectionMatrixWidget::on_aspectRatioEdit_editingFinished()
74{
75    checkValueChanged();
76}
77
78void QProjectionMatrixWidget::on_nearEdit_editingFinished()
79{
80    checkValueChanged();
81}
82
83void QProjectionMatrixWidget::on_farEdit_editingFinished()
84{
85    checkValueChanged();
86}
87
88void QProjectionMatrixWidget::on_offaxisXEdit_editingFinished()
89{
90    checkValueChanged();
91}
92
93void QProjectionMatrixWidget::on_offaxisYEdit_editingFinished()
94{
95    checkValueChanged();
96}
Note: See TracBrowser for help on using the repository browser.