Back to index

salome-gui  6.5.0
SVTK_NonIsometricDlg.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME VTKViewer : build VTK viewer into Salome desktop
00024 //  File   : 
00025 //  Author : 
00026 
00027 #include "SVTK_NonIsometricDlg.h"
00028 #include "SVTK_ViewWindow.h"
00029 #include "SVTK_Renderer.h"
00030 
00031 #include "QtxDoubleSpinBox.h"
00032 #include "QtxAction.h"
00033 
00034 #include <QGroupBox>
00035 #include <QLabel>
00036 #include <QPushButton>
00037 #include <QGridLayout>
00038 
00042 SVTK_NonIsometricDlg
00043 ::SVTK_NonIsometricDlg(QtxAction* theAction,
00044                        SVTK_ViewWindow* theParent,
00045                        const char* theName):
00046   ViewerTools_DialogBase(theAction,
00047                          theParent, 
00048                          theName),
00049   m_MainWindow(theParent)
00050 {
00051   setWindowTitle(tr("DLG_TITLE"));
00052   setSizeGripEnabled(TRUE);
00053 
00054   // Create layout for this dialog
00055   QGridLayout* layoutDlg = new QGridLayout (this);
00056   layoutDlg->setSpacing(6);
00057   layoutDlg->setMargin(11);
00058 
00059   // Create croup box with grid layout
00060   QGroupBox* aGroupBox = new QGroupBox(this);
00061   aGroupBox->setObjectName("GroupBox");
00062   QHBoxLayout* aHBoxLayout = new QHBoxLayout(aGroupBox);
00063   aHBoxLayout->setMargin(11);
00064   aHBoxLayout->setSpacing(6);
00065 
00066   // "X" scaling
00067   QLabel* TextLabelX = new QLabel (tr("LBL_X"), aGroupBox);
00068   TextLabelX->setObjectName("TextLabelX");
00069   TextLabelX->setFixedWidth(15);
00070   m_sbXcoeff = new QtxDoubleSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, aGroupBox);
00071   m_sbXcoeff->setMinimumWidth(80);
00072   m_sbXcoeff->setValue(1.0);
00073 
00074   // "Y" scaling
00075   QLabel* TextLabelY = new QLabel (tr("LBL_Y"), aGroupBox);
00076   TextLabelY->setObjectName("TextLabelY");
00077   TextLabelY->setFixedWidth(15);
00078   m_sbYcoeff = new QtxDoubleSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, aGroupBox);
00079   m_sbYcoeff->setMinimumWidth(80);
00080   m_sbYcoeff->setValue(1.0);
00081 
00082   // "Z" scaling
00083   QLabel* TextLabelZ = new QLabel (tr("LBL_Z"), aGroupBox);
00084   TextLabelZ->setObjectName("TextLabelZ");
00085   TextLabelZ->setFixedWidth(15);
00086   m_sbZcoeff = new QtxDoubleSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, aGroupBox);
00087   m_sbZcoeff->setMinimumWidth(80);
00088   m_sbZcoeff->setValue(1.0);
00089 
00090   // Create <Reset> button
00091   m_bReset = new QPushButton(tr("&Reset"), aGroupBox);
00092   m_bReset->setObjectName("m_bReset");
00093 
00094   // Layout widgets in the group box
00095   aHBoxLayout->addWidget(TextLabelX);
00096   aHBoxLayout->addWidget(m_sbXcoeff);
00097   aHBoxLayout->addWidget(TextLabelY);
00098   aHBoxLayout->addWidget(m_sbYcoeff);
00099   aHBoxLayout->addWidget(TextLabelZ);
00100   aHBoxLayout->addWidget(m_sbZcoeff);
00101   //aHBoxLayout->addStretch();
00102   aHBoxLayout->addWidget(m_bReset);
00103 
00104   // OK, CANCEL, Apply button
00105   QGroupBox* aGroupBox2 = new QGroupBox(this);
00106   QHBoxLayout* aHBoxLayout2 = new QHBoxLayout(aGroupBox2);
00107   aHBoxLayout2->setMargin(11);
00108   aHBoxLayout2->setSpacing(6);
00109   // Create <OK> button
00110   QPushButton* m_bOk = new QPushButton(tr("O&K"), aGroupBox2);
00111   m_bOk->setObjectName("m_bOk");
00112   m_bOk->setDefault(TRUE);
00113   m_bOk->setAutoDefault(TRUE);
00114   // Create <Apply> button
00115   QPushButton* m_bApply = new QPushButton(tr("&Apply"), aGroupBox2);
00116   m_bApply->setObjectName("m_bApply");
00117   m_bApply->setAutoDefault(TRUE);
00118   // Create <Cancel> button
00119   QPushButton* m_bCancel = new QPushButton(tr("&Cancel"), aGroupBox2);
00120   m_bCancel->setObjectName("m_bCancel");
00121   m_bCancel->setAutoDefault(TRUE);
00122 
00123   // Layout buttons
00124   aHBoxLayout2->addWidget(m_bOk);
00125   aHBoxLayout2->addWidget(m_bApply);
00126   aHBoxLayout2->addStretch();
00127   aHBoxLayout2->addWidget(m_bCancel);
00128 
00129   // Layout top level widgets
00130   layoutDlg->addWidget(aGroupBox,0,0);
00131   layoutDlg->addWidget(aGroupBox2,1,0);
00132 
00133   // signals and slots connections
00134   connect(m_bCancel, SIGNAL(clicked()), this, SLOT(onClickClose()));
00135   connect(m_bOk,     SIGNAL(clicked()), this, SLOT(onClickOk()));
00136   connect(m_bApply,  SIGNAL(clicked()), this, SLOT(onClickApply()));
00137   connect(m_bReset,  SIGNAL(clicked()), this, SLOT(onClickReset()));
00138 
00139   this->resize(100, this->sizeHint().height());
00140 }
00141 
00142 /*
00143  *  Destroys the object and frees any allocated resources
00144  */
00145 SVTK_NonIsometricDlg
00146 ::~SVTK_NonIsometricDlg()
00147 {
00148   // no need to delete child widgets, Qt does it all for us
00149 }
00150 
00151 void 
00152 SVTK_NonIsometricDlg
00153 ::Update()
00154 {
00155   // Get values from the VTK view
00156   double aScaleFactor[3];
00157   m_MainWindow->GetScale(aScaleFactor);
00158   m_sbXcoeff->setValue(aScaleFactor[0]);
00159   m_sbYcoeff->setValue(aScaleFactor[1]);
00160   m_sbZcoeff->setValue(aScaleFactor[2]);
00161 }
00162 
00163 void 
00164 SVTK_NonIsometricDlg
00165 ::onClickOk()
00166 {
00167   //apply changes
00168   onClickApply();
00169   //Close dialog
00170   accept();
00171 }
00172 
00173 void
00174 SVTK_NonIsometricDlg
00175 ::onClickApply()
00176 {
00177   double aScale[3] = {m_sbXcoeff->value(), m_sbYcoeff->value(), m_sbZcoeff->value()};
00178   m_MainWindow->SetScale(aScale);
00179 }
00180 
00181 void
00182 SVTK_NonIsometricDlg
00183 ::onClickReset()
00184 {
00185   m_bReset->setFocus();
00186   m_sbXcoeff->setValue(1.0);
00187   m_sbYcoeff->setValue(1.0);
00188   m_sbZcoeff->setValue(1.0);
00189 }
00190 
00191 void 
00192 SVTK_NonIsometricDlg
00193 ::onClickClose()
00194 {
00195   reject();
00196 }