1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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
23 // SALOME VTKViewer : build VTK viewer into Salome desktop
27 #include "SVTK_NonIsometricDlg.h"
28 #include "SVTK_ViewWindow.h"
29 #include "SVTK_Renderer.h"
31 #include "QtxDoubleSpinBox.h"
32 #include "QtxAction.h"
36 #include <QPushButton>
37 #include <QGridLayout>
43 ::SVTK_NonIsometricDlg(QtxAction* theAction,
44 SVTK_ViewWindow* theParent,
46 ViewerTools_DialogBase(theAction,
49 m_MainWindow(theParent)
51 setWindowTitle(tr("DLG_TITLE"));
52 setSizeGripEnabled(TRUE);
54 // Create layout for this dialog
55 QGridLayout* layoutDlg = new QGridLayout (this);
56 layoutDlg->setSpacing(6);
57 layoutDlg->setMargin(11);
59 // Create croup box with grid layout
60 QGroupBox* aGroupBox = new QGroupBox(this);
61 aGroupBox->setObjectName("GroupBox");
62 QHBoxLayout* aHBoxLayout = new QHBoxLayout(aGroupBox);
63 aHBoxLayout->setMargin(11);
64 aHBoxLayout->setSpacing(6);
67 QLabel* TextLabelX = new QLabel (tr("LBL_X"), aGroupBox);
68 TextLabelX->setObjectName("TextLabelX");
69 TextLabelX->setFixedWidth(15);
70 m_sbXcoeff = new QtxDoubleSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, aGroupBox);
71 m_sbXcoeff->setMinimumWidth(80);
72 m_sbXcoeff->setValue(1.0);
75 QLabel* TextLabelY = new QLabel (tr("LBL_Y"), aGroupBox);
76 TextLabelY->setObjectName("TextLabelY");
77 TextLabelY->setFixedWidth(15);
78 m_sbYcoeff = new QtxDoubleSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, aGroupBox);
79 m_sbYcoeff->setMinimumWidth(80);
80 m_sbYcoeff->setValue(1.0);
83 QLabel* TextLabelZ = new QLabel (tr("LBL_Z"), aGroupBox);
84 TextLabelZ->setObjectName("TextLabelZ");
85 TextLabelZ->setFixedWidth(15);
86 m_sbZcoeff = new QtxDoubleSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, aGroupBox);
87 m_sbZcoeff->setMinimumWidth(80);
88 m_sbZcoeff->setValue(1.0);
90 // Create <Reset> button
91 m_bReset = new QPushButton(tr("&Reset"), aGroupBox);
92 m_bReset->setObjectName("m_bReset");
94 // Layout widgets in the group box
95 aHBoxLayout->addWidget(TextLabelX);
96 aHBoxLayout->addWidget(m_sbXcoeff);
97 aHBoxLayout->addWidget(TextLabelY);
98 aHBoxLayout->addWidget(m_sbYcoeff);
99 aHBoxLayout->addWidget(TextLabelZ);
100 aHBoxLayout->addWidget(m_sbZcoeff);
101 //aHBoxLayout->addStretch();
102 aHBoxLayout->addWidget(m_bReset);
104 // OK, CANCEL, Apply button
105 QGroupBox* aGroupBox2 = new QGroupBox(this);
106 QHBoxLayout* aHBoxLayout2 = new QHBoxLayout(aGroupBox2);
107 aHBoxLayout2->setMargin(11);
108 aHBoxLayout2->setSpacing(6);
109 // Create <OK> button
110 QPushButton* m_bOk = new QPushButton(tr("O&K"), aGroupBox2);
111 m_bOk->setObjectName("m_bOk");
112 m_bOk->setDefault(TRUE);
113 m_bOk->setAutoDefault(TRUE);
114 // Create <Apply> button
115 QPushButton* m_bApply = new QPushButton(tr("&Apply"), aGroupBox2);
116 m_bApply->setObjectName("m_bApply");
117 m_bApply->setAutoDefault(TRUE);
118 // Create <Cancel> button
119 QPushButton* m_bCancel = new QPushButton(tr("&Cancel"), aGroupBox2);
120 m_bCancel->setObjectName("m_bCancel");
121 m_bCancel->setAutoDefault(TRUE);
124 aHBoxLayout2->addWidget(m_bOk);
125 aHBoxLayout2->addWidget(m_bApply);
126 aHBoxLayout2->addStretch();
127 aHBoxLayout2->addWidget(m_bCancel);
129 // Layout top level widgets
130 layoutDlg->addWidget(aGroupBox,0,0);
131 layoutDlg->addWidget(aGroupBox2,1,0);
133 // signals and slots connections
134 connect(m_bCancel, SIGNAL(clicked()), this, SLOT(onClickClose()));
135 connect(m_bOk, SIGNAL(clicked()), this, SLOT(onClickOk()));
136 connect(m_bApply, SIGNAL(clicked()), this, SLOT(onClickApply()));
137 connect(m_bReset, SIGNAL(clicked()), this, SLOT(onClickReset()));
139 this->resize(100, this->sizeHint().height());
143 * Destroys the object and frees any allocated resources
146 ::~SVTK_NonIsometricDlg()
148 // no need to delete child widgets, Qt does it all for us
155 // Get values from the VTK view
156 double aScaleFactor[3];
157 m_MainWindow->GetScale(aScaleFactor);
158 m_sbXcoeff->setValue(aScaleFactor[0]);
159 m_sbYcoeff->setValue(aScaleFactor[1]);
160 m_sbZcoeff->setValue(aScaleFactor[2]);
177 double aScale[3] = {m_sbXcoeff->value(), m_sbYcoeff->value(), m_sbZcoeff->value()};
178 m_MainWindow->SetScale(aScale);
185 m_bReset->setFocus();
186 m_sbXcoeff->setValue(1.0);
187 m_sbYcoeff->setValue(1.0);
188 m_sbZcoeff->setValue(1.0);