Salome HOME
Fix for the IPAL22822: Changes of plots in hexa8
[modules/visu.git] / src / VISUGUI / VisuGUI_CutPlanesDlg.cxx
index 5b48ab40fe390edbeb225477f19e0a84b24e94fc..09a7266fac8ba453c700c0c1890ccf606abed56e 100644 (file)
@@ -1,30 +1,29 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
 //  VISU VISUGUI : GUI of VISU component
 //  File   : VisuGUI_CutPlanesDlg.cxx
 //  Author : Laurent CORNABE & Hubert ROLLAND
 //  Module : VISU
-//  $Header$
-//
+
 #include "VisuGUI_CutPlanesDlg.h"
 
 #include "VISU_ColoredPrs3dFactory.hh"
 
 //#include "OB_Browser.h"
 
-#include "VisuGUI_TableDlg.h"
+#include "VISU_TableDlg.h"
 
 #include "SVTK_ViewWindow.h"
 
 #include "LightApp_Application.h"
 
+#include <SalomeApp_IntSpinBox.h>
+#include <SalomeApp_DoubleSpinBox.h>
+
 #include "SUIT_Application.h"
 #include "SUIT_Desktop.h"
 #include "SUIT_ViewWindow.h"
@@ -64,7 +66,6 @@
 #include <QLineEdit>
 #include <QTabWidget>
 #include <QKeyEvent>
-#include <QSpinBox>
 #include <QRadioButton>
 #include <QTableWidget>
 #include <QGroupBox>
@@ -114,7 +115,8 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent)
 
   QLabel* LabelPosi_3 = new QLabel (tr("LBL_NB_PLANS"), this);
 
-  nbPlan = new QSpinBox( this );
+  nbPlan = new SalomeApp_IntSpinBox( this );
+  nbPlan->setAcceptNames( false );
   nbPlan->setMinimum( 1 );
   nbPlan->setMaximum(100);
   nbPlan->setSingleStep( 1 );
@@ -152,7 +154,8 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent)
   LabelRot1 = new QLabel (tr("LBL_ROT_X"), GBrot );
   GBrotLayout->addWidget( LabelRot1, 0, 0 );
 
-  Rot1 = new QtxDoubleSpinBox( -180, 180, 10, GBrot );
+  Rot1 = new SalomeApp_DoubleSpinBox( GBrot );
+  VISU::initSpinBox( Rot1, -180., 180., 10., "angle_precision" );  
   Rot1->setValue( 0 );
   Rot1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
   connect( Rot1, SIGNAL( valueChanged( double )), this, SLOT( onRotation( double ) ) );
@@ -161,14 +164,16 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent)
   LabelRot2 = new QLabel (tr("LBL_ROT_Y"), GBrot );
   GBrotLayout->addWidget( LabelRot2, 1, 0 );
 
-  Rot2 = new QtxDoubleSpinBox( -180, 180, 10, GBrot );
+  Rot2 = new SalomeApp_DoubleSpinBox( GBrot );
+  VISU::initSpinBox( Rot2, -180., 180., 10., "angle_precision" );
   Rot2->setValue( 0 );
   Rot2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
   connect( Rot2, SIGNAL( valueChanged( double )), this, SLOT( onRotation( double ) ) );
   GBrotLayout->addWidget( Rot2, 1, 1 );
 
   QLabel* aPosLbl = new QLabel(tr( "LBL_POS" ), this);
-  myPosSpn = new QtxDoubleSpinBox( 0, 1, 0.1, this );
+  myPosSpn = new SalomeApp_DoubleSpinBox( this );
+  VISU::initSpinBox( myPosSpn, 0., 1., .1, "parametric_precision" );
 
   GDeformation = new QGroupBox(tr("LBL_DEFORMATION"), this);
   GDeformation->setCheckable(true);
@@ -184,12 +189,10 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent)
   myVectorialFieldCombo = new QComboBox (GDeformation);
   GDeformationLayout->addWidget( myVectorialFieldCombo, 0, 1 );
 
-  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
-  int aPrecision = aResourceMgr->integerValue( "VISU", "floating_point_precision", 0 );
-  
   QLabel* LabelDeformation2 = new QLabel (tr("LBL_DEFROMATION_SCALE"), GDeformation);
   GDeformationLayout->addWidget( LabelDeformation2, 1, 0 );
-  myScaleSpn = new QtxDoubleSpinBox (0, 1.0E+38, 0.1, aPrecision*(-1), 38, GDeformation);
+  myScaleSpn = new SalomeApp_DoubleSpinBox (GDeformation);
+  VISU::initSpinBox( myScaleSpn, 0., 1.0E+38, 0.1, "visual_data_precision" );
   myScaleSpn->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
   GDeformationLayout->addWidget( myScaleSpn, 1, 1 );
   connect(myVectorialFieldCombo,     SIGNAL(activated(int)), this, SLOT(onVectorialFieldChanged(int)));
@@ -236,7 +239,7 @@ VisuGUI_CutPlanesPane::~VisuGUI_CutPlanesPane()
 void VisuGUI_CutPlanesPane::initFromPrsObject (VISU::CutPlanes_i* thePrs)
 {
   setNbPlanes(thePrs->GetNbPlanes());
-  setRotation(thePrs->GetRotateX()*180./PI, thePrs->GetRotateY()*180./PI);
+  setRotation(thePrs->GetRotateX()*180./M_PI, thePrs->GetRotateY()*180./M_PI);
   setPlanePos(thePrs->GetOrientationType());
   myPosSpn->setValue(thePrs->GetDisplacement());
   InitEntity2VectorialFieldsMap(thePrs);
@@ -352,7 +355,7 @@ void VisuGUI_CutPlanesPane::createPlanes()
 
 int VisuGUI_CutPlanesPane::storeToPrsObject (VISU::CutPlanes_i* thePrs)
 {
-  thePrs->SetOrientation(getOrientaion(), getRotation1()*PI/180., getRotation2()*PI/180.);
+  thePrs->SetOrientation(getOrientaion(), getRotation1()*M_PI/180., getRotation2()*M_PI/180.);
   thePrs->SetNbPlanes(getNbPlanes());
   thePrs->SetDisplacement(myPosSpn->value());
   for (int i = 0; i < getNbPlanes(); ++i) {
@@ -507,7 +510,7 @@ void VisuGUI_CutPlanesPane::DrawTable()
   int aNbRows = myPosTable->rowCount();
   int aNbPlanes = getNbPlanes();
 
-  myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.);
+  myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*M_PI/180.,getRotation2()*M_PI/180.);
   myCutPlanes->SetNbPlanes(aNbPlanes);
   myCutPlanes->SetDisplacement(myPosSpn->value());
   myCutPlanes->SetScale(getScaleFactor());
@@ -728,7 +731,7 @@ void VisuGUI_CutPlanesPane::onRotation (double theValue)
   if (!(bool)myCutPlanes) return;
   if (myPreviewCheck->isChecked()) {
     if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
-      myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.);
+      myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*M_PI/180.,getRotation2()*M_PI/180.);
       myCutPlanes->GetPipeLine()->Update();
       deletePlanes();
       createPlanes();
@@ -744,9 +747,10 @@ void VisuGUI_CutPlanesPane::onPreviewCheck (bool thePreview)
       storeToPrsObject(myCutPlanes);
       myCutPlanes->GetPipeLine()->Update();
       createPlanes();
-      if(VISU::GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)) {
-        vf->onFitAll();
-      }
+      if(VISU::GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false))
+        vf->onFitAll(); // Repaint() is called inside
+      else
+        vf->Repaint();
     } else {
       deletePlanes();
       vf->Repaint();