1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SALOME VTKViewer : build VTK viewer into Salome desktop
28 #include "SVTK_NonIsometricDlg.h"
29 #include "SVTK_ViewWindow.h"
30 #include "SVTK_Renderer.h"
32 #include "QtxDoubleSpinBox.h"
33 #include "QtxAction.h"
37 #include <QPushButton>
38 #include <QGridLayout>
46 ::SVTK_NonIsometricDlg(QtxAction* theAction,
47 SVTK_ViewWindow* theParent,
49 SVTK_DialogBase(theAction,
52 m_MainWindow(theParent)
54 setWindowTitle(tr("DLG_TITLE"));
55 setSizeGripEnabled(TRUE);
57 // Create layout for this dialog
58 QGridLayout* layoutDlg = new QGridLayout (this);
59 layoutDlg->setSpacing(6);
60 layoutDlg->setMargin(11);
62 // Create croup box with grid layout
63 QGroupBox* aGroupBox = new QGroupBox(this);
64 aGroupBox->setObjectName("GroupBox");
65 QHBoxLayout* aHBoxLayout = new QHBoxLayout(aGroupBox);
66 aHBoxLayout->setMargin(11);
67 aHBoxLayout->setSpacing(6);
70 QLabel* TextLabelX = new QLabel (tr("LBL_X"), aGroupBox);
71 TextLabelX->setObjectName("TextLabelX");
72 TextLabelX->setFixedWidth(15);
73 m_sbXcoeff = new QtxDoubleSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, aGroupBox);
74 m_sbXcoeff->setMinimumWidth(80);
75 m_sbXcoeff->setValue(1.0);
78 QLabel* TextLabelY = new QLabel (tr("LBL_Y"), aGroupBox);
79 TextLabelY->setObjectName("TextLabelY");
80 TextLabelY->setFixedWidth(15);
81 m_sbYcoeff = new QtxDoubleSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, aGroupBox);
82 m_sbYcoeff->setMinimumWidth(80);
83 m_sbYcoeff->setValue(1.0);
86 QLabel* TextLabelZ = new QLabel (tr("LBL_Z"), aGroupBox);
87 TextLabelZ->setObjectName("TextLabelZ");
88 TextLabelZ->setFixedWidth(15);
89 m_sbZcoeff = new QtxDoubleSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, aGroupBox);
90 m_sbZcoeff->setMinimumWidth(80);
91 m_sbZcoeff->setValue(1.0);
93 // Create <Reset> button
94 m_bReset = new QPushButton(tr("&Reset"), aGroupBox);
95 m_bReset->setObjectName("m_bReset");
97 // Layout widgets in the group box
98 aHBoxLayout->addWidget(TextLabelX);
99 aHBoxLayout->addWidget(m_sbXcoeff);
100 aHBoxLayout->addWidget(TextLabelY);
101 aHBoxLayout->addWidget(m_sbYcoeff);
102 aHBoxLayout->addWidget(TextLabelZ);
103 aHBoxLayout->addWidget(m_sbZcoeff);
104 //aHBoxLayout->addStretch();
105 aHBoxLayout->addWidget(m_bReset);
107 // OK, CANCEL, Apply button
108 QGroupBox* aGroupBox2 = new QGroupBox(this);
109 QHBoxLayout* aHBoxLayout2 = new QHBoxLayout(aGroupBox2);
110 aHBoxLayout2->setMargin(11);
111 aHBoxLayout2->setSpacing(6);
112 // Create <OK> button
113 QPushButton* m_bOk = new QPushButton(tr("O&K"), aGroupBox2);
114 m_bOk->setObjectName("m_bOk");
115 m_bOk->setDefault(TRUE);
116 m_bOk->setAutoDefault(TRUE);
117 // Create <Apply> button
118 QPushButton* m_bApply = new QPushButton(tr("&Apply"), aGroupBox2);
119 m_bApply->setObjectName("m_bApply");
120 m_bApply->setAutoDefault(TRUE);
121 // Create <Cancel> button
122 QPushButton* m_bCancel = new QPushButton(tr("&Cancel"), aGroupBox2);
123 m_bCancel->setObjectName("m_bCancel");
124 m_bCancel->setAutoDefault(TRUE);
127 aHBoxLayout2->addWidget(m_bOk);
128 aHBoxLayout2->addWidget(m_bApply);
129 aHBoxLayout2->addStretch();
130 aHBoxLayout2->addWidget(m_bCancel);
132 // Layout top level widgets
133 layoutDlg->addWidget(aGroupBox,0,0);
134 layoutDlg->addWidget(aGroupBox2,1,0);
136 // signals and slots connections
137 connect(m_bCancel, SIGNAL(clicked()), this, SLOT(onClickClose()));
138 connect(m_bOk, SIGNAL(clicked()), this, SLOT(onClickOk()));
139 connect(m_bApply, SIGNAL(clicked()), this, SLOT(onClickApply()));
140 connect(m_bReset, SIGNAL(clicked()), this, SLOT(onClickReset()));
142 this->resize(100, this->sizeHint().height());
146 * Destroys the object and frees any allocated resources
149 ::~SVTK_NonIsometricDlg()
151 // no need to delete child widgets, Qt does it all for us
158 // Get values from the VTK view
159 double aScaleFactor[3];
160 m_MainWindow->GetScale(aScaleFactor);
161 m_sbXcoeff->setValue(aScaleFactor[0]);
162 m_sbYcoeff->setValue(aScaleFactor[1]);
163 m_sbZcoeff->setValue(aScaleFactor[2]);
180 double aScale[3] = {m_sbXcoeff->value(), m_sbYcoeff->value(), m_sbZcoeff->value()};
181 m_MainWindow->SetScale(aScale);
188 m_bReset->setFocus();
189 m_sbXcoeff->setValue(1.0);
190 m_sbYcoeff->setValue(1.0);
191 m_sbZcoeff->setValue(1.0);