]> SALOME platform Git repositories - modules/gui.git/blob - src/SVTK/SVTK_NonIsometricDlg.cxx
Salome HOME
9596001ca7c00c0c7f3c72c0c0fa49bfde4f874d
[modules/gui.git] / src / SVTK / SVTK_NonIsometricDlg.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SALOME VTKViewer : build VTK viewer into Salome desktop
23 //  File   : 
24 //  Author : 
25 //  Module : SALOME
26 //  $Header$
27 //
28 #include "SVTK_NonIsometricDlg.h"
29 #include "SVTK_ViewWindow.h"
30 #include "SVTK_Renderer.h"
31
32 #include "QtxDoubleSpinBox.h"
33 #include "QtxAction.h"
34
35 #include <QGroupBox>
36 #include <QLabel>
37 #include <QPushButton>
38 #include <QGridLayout>
39
40 using namespace std;
41
42 /*!
43   Constructor
44 */
45 SVTK_NonIsometricDlg
46 ::SVTK_NonIsometricDlg(QtxAction* theAction,
47                        SVTK_ViewWindow* theParent,
48                        const char* theName):
49   SVTK_DialogBase(theAction,
50                   theParent, 
51                   theName),
52   m_MainWindow(theParent)
53 {
54   setWindowTitle(tr("DLG_TITLE"));
55   setSizeGripEnabled(TRUE);
56
57   // Create layout for this dialog
58   QGridLayout* layoutDlg = new QGridLayout (this);
59   layoutDlg->setSpacing(6);
60   layoutDlg->setMargin(11);
61
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);
68
69   // "X" scaling
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);
76
77   // "Y" scaling
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);
84
85   // "Z" scaling
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);
92
93   // Create <Reset> button
94   m_bReset = new QPushButton(tr("&Reset"), aGroupBox);
95   m_bReset->setObjectName("m_bReset");
96
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);
106
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);
125
126   // Layout buttons
127   aHBoxLayout2->addWidget(m_bOk);
128   aHBoxLayout2->addWidget(m_bApply);
129   aHBoxLayout2->addStretch();
130   aHBoxLayout2->addWidget(m_bCancel);
131
132   // Layout top level widgets
133   layoutDlg->addWidget(aGroupBox,0,0);
134   layoutDlg->addWidget(aGroupBox2,1,0);
135
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()));
141
142   this->resize(100, this->sizeHint().height());
143 }
144
145 /*
146  *  Destroys the object and frees any allocated resources
147  */
148 SVTK_NonIsometricDlg
149 ::~SVTK_NonIsometricDlg()
150 {
151   // no need to delete child widgets, Qt does it all for us
152 }
153
154 void 
155 SVTK_NonIsometricDlg
156 ::Update()
157 {
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]);
164 }
165
166 void 
167 SVTK_NonIsometricDlg
168 ::onClickOk()
169 {
170   //apply changes
171   onClickApply();
172   //Close dialog
173   accept();
174 }
175
176 void
177 SVTK_NonIsometricDlg
178 ::onClickApply()
179 {
180   double aScale[3] = {m_sbXcoeff->value(), m_sbYcoeff->value(), m_sbZcoeff->value()};
181   m_MainWindow->SetScale(aScale);
182 }
183
184 void
185 SVTK_NonIsometricDlg
186 ::onClickReset()
187 {
188   m_bReset->setFocus();
189   m_sbXcoeff->setValue(1.0);
190   m_sbYcoeff->setValue(1.0);
191   m_sbZcoeff->setValue(1.0);
192 }
193
194 void 
195 SVTK_NonIsometricDlg
196 ::onClickClose()
197 {
198   reject();
199 }