1 // SALOME VTKViewer : build VTK viewer into Salome desktop
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
29 #include "SVTK_NonIsometricDlg.h"
30 #include "SVTK_MainWindow.h"
31 #include "SVTK_Renderer.h"
33 #include "QtxDblSpinBox.h"
34 #include "QtxAction.h"
36 #include <qgroupbox.h>
38 #include <qpushbutton.h>
47 ::SVTK_NonIsometricDlg(SVTK_MainWindow* theParent,
49 QtxAction* theAction):
53 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ),
54 m_MainWindow(theParent),
57 setCaption(tr("DLG_TITLE"));
58 setSizeGripEnabled(TRUE);
60 // Create layout for this dialog
61 QGridLayout* layoutDlg = new QGridLayout (this);
62 layoutDlg->setSpacing(6);
63 layoutDlg->setMargin(11);
65 // Create croup box with grid layout
66 QGroupBox* GroupBox = new QGroupBox(this, "GroupBox");
67 QGridLayout* glGroupBox = new QGridLayout(GroupBox);
68 glGroupBox->setMargin(11);
69 glGroupBox->setSpacing(6);
72 QLabel* TextLabelX = new QLabel (tr("LBL_X"), GroupBox, "TextLabelX");
73 m_sbXcoeff = new QtxDblSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, GroupBox);
74 m_sbXcoeff->setMinimumWidth(80);
75 m_sbXcoeff->setValue(1.0);
78 QLabel* TextLabelY = new QLabel (tr("LBL_Y"), GroupBox, "TextLabelY");
79 m_sbYcoeff = new QtxDblSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, GroupBox);
80 m_sbYcoeff->setMinimumWidth(80);
81 m_sbYcoeff->setValue(1.0);
84 QLabel* TextLabelZ = new QLabel (tr("LBL_Z"), GroupBox, "TextLabelZ");
85 m_sbZcoeff = new QtxDblSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, GroupBox);
86 m_sbZcoeff->setMinimumWidth(80);
87 m_sbZcoeff->setValue(1.0);
89 // Create <Reset> button
90 m_bReset = new QPushButton(tr("&Reset"), GroupBox, "m_bReset");
92 // Layout widgets in the group box
93 glGroupBox->addWidget(TextLabelX, 0, 0);
94 glGroupBox->addWidget(m_sbXcoeff, 0, 1);
95 glGroupBox->addWidget(TextLabelY, 0, 2);
96 glGroupBox->addWidget(m_sbYcoeff, 0, 3);
97 glGroupBox->addWidget(TextLabelZ, 0, 4);
98 glGroupBox->addWidget(m_sbZcoeff, 0, 5);
99 glGroupBox->addWidget(m_bReset, 0, 6);
101 // OK, CANCEL, Apply button
102 QGroupBox* aWgt = new QGroupBox(this);
103 QHBoxLayout* aHBoxLayout = new QHBoxLayout(aWgt);
104 aHBoxLayout->setMargin(11);
105 aHBoxLayout->setSpacing(6);
106 // Create <OK> button
107 QPushButton* m_bOk = new QPushButton(tr("O&K"), aWgt, "m_bOk");
108 m_bOk->setDefault(TRUE);
109 m_bOk->setAutoDefault(TRUE);
110 // Create <Apply> button
111 QPushButton* m_bApply = new QPushButton(tr("&Apply"), aWgt, "m_bApply");
112 m_bApply->setAutoDefault(TRUE);
113 // Create <Cancel> button
114 QPushButton* m_bCancel = new QPushButton(tr("&Cancel"), aWgt, "m_bCancel");
115 m_bCancel->setAutoDefault(TRUE);
118 aHBoxLayout->addWidget(m_bOk);
119 aHBoxLayout->addWidget(m_bApply);
120 aHBoxLayout->addStretch();
121 aHBoxLayout->addWidget(m_bCancel);
123 // Layout top level widgets
124 layoutDlg->addWidget(GroupBox,0,0);
125 layoutDlg->addWidget(aWgt,1,0);
127 // signals and slots connections
128 connect(m_bCancel, SIGNAL(clicked()), this, SLOT(onClickClose()));
129 connect(m_bOk, SIGNAL(clicked()), this, SLOT(onClickOk()));
130 connect(m_bApply, SIGNAL(clicked()), this, SLOT(onClickApply()));
131 connect(m_bReset, SIGNAL(clicked()), this, SLOT(onClickReset()));
133 this->resize(100, this->sizeHint().height());
137 * Destroys the object and frees any allocated resources
140 ::~SVTK_NonIsometricDlg()
142 // no need to delete child widgets, Qt does it all for us
149 // Get values from the VTK view
150 double aScaleFactor[3];
151 m_MainWindow->GetScale(aScaleFactor);
152 m_sbXcoeff->setValue(aScaleFactor[0]);
153 m_sbYcoeff->setValue(aScaleFactor[1]);
154 m_sbZcoeff->setValue(aScaleFactor[2]);
171 double aScale[3] = {m_sbXcoeff->value(), m_sbYcoeff->value(), m_sbZcoeff->value()};
172 m_MainWindow->SetScale(aScale);
179 m_bReset->setFocus();
180 m_sbXcoeff->setValue(1.0);
181 m_sbYcoeff->setValue(1.0);
182 m_sbZcoeff->setValue(1.0);
191 m_Action->setOn( false );
198 m_Action->setOn( false );