Salome HOME
Update copyright information
[modules/visu.git] / src / VISUGUI / VisuGUI_DeformedShapeAndScalarMapDlg.cxx
index 4d65681c26e235f3edcbd27e6816991b2674da4f..91b1dc5819d1399048d445fd3130677948a357f5 100644 (file)
@@ -1,24 +1,22 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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
+// 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
 //
-//  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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  VISU VISUGUI : GUI of VISU component
 //  File   : VisuGUI_DeformedShapeAndScalarMapDlg.cxx
 //  Author : Eugeny Nikolaev
 
 #include "VISU_Convertor.hxx"
 
-#include <QtxDoubleSpinBox.h>
+#include <SalomeApp_DoubleSpinBox.h>
 #include <SalomeApp_Module.h>
 #include <LightApp_Application.h>
 #include <LightApp_SelectionMgr.h>
 #include <SUIT_Desktop.h>
-#include <SUIT_ResourceMgr.h>
 #include <SUIT_Session.h>
 #include <SUIT_MessageBox.h>
 
@@ -99,10 +96,8 @@ VisuGUI_DeformedShapeAndScalarMapDlg::VisuGUI_DeformedShapeAndScalarMapDlg (Salo
   QLabel* ScaleLabel = new QLabel (tr("SCALE_FACTOR"), TopGroup);
   TopGroupLayout->addWidget(ScaleLabel, 0, 0);
 
-  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
-  int aPrecision = aResourceMgr->integerValue( "VISU", "floating_point_precision", 0 );
-
-  ScalFact = new QtxDoubleSpinBox (0, 1.0E+38, 0.1, aPrecision*(-1), 32, TopGroup);
+  ScalFact = new SalomeApp_DoubleSpinBox (TopGroup);
+  VISU::initSpinBox( ScalFact, 0., 1.0E+38, .1, "visual_data_precision" );  
   ScalFact->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
   ScalFact->setValue(0.1);
   TopGroupLayout->addWidget(ScalFact, 0, 1);
@@ -168,7 +163,7 @@ VisuGUI_DeformedShapeAndScalarMapDlg::~VisuGUI_DeformedShapeAndScalarMapDlg()
 }
 
 void VisuGUI_DeformedShapeAndScalarMapDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
-                                                             bool theInit )
+                                                              bool theInit )
 {
   if( theInit )
     myPrsCopy = VISU::TSameAsFactory<VISU::TDEFORMEDSHAPEANDSCALARMAP>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
@@ -177,8 +172,8 @@ void VisuGUI_DeformedShapeAndScalarMapDlg::initFromPrsObject( VISU::ColoredPrs3d
 
   CORBA::String_var aFieldName(myPrsCopy->GetScalarFieldName());
   QString aIteration = GetFloatValueOfTimeStamp(myPrsCopy->GetScalarEntity(),
-                                               aFieldName.in(),
-                                               myPrsCopy->GetScalarTimeStampNumber());
+                                                aFieldName.in(),
+                                                myPrsCopy->GetScalarTimeStampNumber());
   if (myEntity2Fields.size() == 0)
   {
     // find all fields and time stamps on it
@@ -189,42 +184,42 @@ void VisuGUI_DeformedShapeAndScalarMapDlg::initFromPrsObject( VISU::ColoredPrs3d
     if (selected.Extent() > 0) {
       Handle(SALOME_InteractiveObject) aIO = selected.First();
       if (aIO->hasEntry()) {
-       _PTR(SObject) aSObject = aActiveStudy->FindObjectID(aIO->getEntry());
-       VISU::VISUType aType = VISU::Storable::SObject2Type( aSObject );
-       switch(aType){
-       case VISU::TTIMESTAMP: {
-         aSObject = aSObject->GetFather();
-         aSObject = aSObject->GetFather();
-         break;
-       }
-       case VISU::TFIELD: {
-         _PTR(SObject) newSObject;
-         if(aSObject->ReferencedObject(newSObject)) aSObject = newSObject;
-         aSObject = aSObject->GetFather();
-         break;
-       }
-       case VISU::TANIMATION: {
-         _PTR(ChildIterator) aTmpIter = aActiveStudy->NewChildIterator(aSObject);
-         for (aTmpIter->InitEx(true); aTmpIter->More(); aTmpIter->Next()) {
-           _PTR(SObject) aTmpChildSObj = aTmpIter->Value();
-           _PTR(SObject) newSObject;
-           if(aTmpChildSObj->ReferencedObject(newSObject)){
-             aSObject = newSObject;
-             aSObject->GetFather();
-             break;
-           }
-         }
-         break;
-       }}
-       
-       aSObject = aSObject->GetFather();
-       aSObject = aSObject->GetFather();
-
-       mySelectionObj = aSObject;
-       CORBA::Object_var anObject = VISU::ClientSObjectToObject(mySelectionObj);
-       if (CORBA::is_nil(anObject)) {
-         mySelectionObj = mySelectionObj->GetFather();
-       }
+        _PTR(SObject) aSObject = aActiveStudy->FindObjectID(aIO->getEntry());
+        VISU::VISUType aType = VISU::Storable::SObject2Type( aSObject );
+        switch(aType){
+        case VISU::TTIMESTAMP: {
+          aSObject = aSObject->GetFather();
+          aSObject = aSObject->GetFather();
+          break;
+        }
+        case VISU::TFIELD: {
+          _PTR(SObject) newSObject;
+          if(aSObject->ReferencedObject(newSObject)) aSObject = newSObject;
+          aSObject = aSObject->GetFather();
+          break;
+        }
+        case VISU::TANIMATION: {
+          _PTR(ChildIterator) aTmpIter = aActiveStudy->NewChildIterator(aSObject);
+          for (aTmpIter->InitEx(true); aTmpIter->More(); aTmpIter->Next()) {
+            _PTR(SObject) aTmpChildSObj = aTmpIter->Value();
+            _PTR(SObject) newSObject;
+            if(aTmpChildSObj->ReferencedObject(newSObject)){
+              aSObject = newSObject;
+              aSObject->GetFather();
+              break;
+            }
+          }
+          break;
+        }}
+        
+        aSObject = aSObject->GetFather();
+        aSObject = aSObject->GetFather();
+
+        mySelectionObj = aSObject;
+        CORBA::Object_var anObject = VISU::ClientSObjectToObject(mySelectionObj);
+        if (CORBA::is_nil(anObject)) {
+          mySelectionObj = mySelectionObj->GetFather();
+        }
       }
     }
 
@@ -233,31 +228,31 @@ void VisuGUI_DeformedShapeAndScalarMapDlg::initFromPrsObject( VISU::ColoredPrs3d
 
       for (aIter->InitEx(true); aIter->More(); aIter->Next()) {
         _PTR(SObject) aChildSObj = aIter->Value();
-       VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aChildSObj);
+        VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aChildSObj);
         if (!aRestoringMap.empty()) {
-         VISU::VISUType aType = VISU::Storable::RestoringMap2Type(aRestoringMap);
-         if (aType == VISU::TTIMESTAMP) {
-           QString aMeshName = aRestoringMap["myMeshName"];
-           CORBA::String_var aName = myPrsCopy->GetMeshName();
-           if (aMeshName != aName.in())
-             continue;
-           QString aFieldName = aRestoringMap["myFieldName"];
-           QString aTimeIter  = aRestoringMap["myTimeStampId"];
-           QString aEntity    = aRestoringMap["myEntityId"];
-           VISU::Entity anEntity;
-           switch (aEntity.toInt()) {
-           case 0: anEntity = VISU::NODE; break;
-           case 1: anEntity = VISU::EDGE; break;
-           case 2: anEntity = VISU::FACE; break;
-           case 3: anEntity = VISU::CELL; break;
-           }
-           TFieldName2TimeStamps& aFieldName2TimeStamps = myEntity2Fields[anEntity];
-           TTimeStampNumber2Time& aTimeStampNumber2Time = aFieldName2TimeStamps[aFieldName];
-           aTimeStampNumber2Time[aTimeIter.toInt()] = 
-             GetFloatValueOfTimeStamp(anEntity,
-                                      aFieldName.toLatin1().constData(),
-                                      aTimeIter.toInt());
-         }
+          VISU::VISUType aType = VISU::Storable::RestoringMap2Type(aRestoringMap);
+          if (aType == VISU::TTIMESTAMP) {
+            QString aMeshName = aRestoringMap["myMeshName"];
+            CORBA::String_var aName = myPrsCopy->GetMeshName();
+            if (aMeshName != aName.in())
+              continue;
+            QString aFieldName = aRestoringMap["myFieldName"];
+            QString aTimeIter  = aRestoringMap["myTimeStampId"];
+            QString aEntity    = aRestoringMap["myEntityId"];
+            VISU::Entity anEntity;
+            switch (aEntity.toInt()) {
+            case 0: anEntity = VISU::NODE; break;
+            case 1: anEntity = VISU::EDGE; break;
+            case 2: anEntity = VISU::FACE; break;
+            case 3: anEntity = VISU::CELL; break;
+            }
+            TFieldName2TimeStamps& aFieldName2TimeStamps = myEntity2Fields[anEntity];
+            TTimeStampNumber2Time& aTimeStampNumber2Time = aFieldName2TimeStamps[aFieldName];
+            aTimeStampNumber2Time[aTimeIter.toInt()] = 
+              GetFloatValueOfTimeStamp(anEntity,
+                                       aFieldName.toLatin1().constData(),
+                                       aTimeIter.toInt());
+          }
         }
       }
     }
@@ -324,8 +319,8 @@ VisuGUI_DeformedShapeAndScalarMapDlg
   myPrsCopy->SetScale(getFactor());
 
   myPrsCopy->SetScalarField(myPrsCopy->GetScalarEntity(),
-                           getCurrentScalarFieldName().toLatin1().constData(),
-                           myTimeStampID[ myTimeStampsCombo->currentIndex() ]);
+                            getCurrentScalarFieldName().toLatin1().constData(),
+                            myTimeStampID[ myTimeStampsCombo->currentIndex() ]);
 
   if(myUpdateScalars) 
     SetScalarField( false );
@@ -359,8 +354,8 @@ VisuGUI_DeformedShapeAndScalarMapDlg
     for(; aFieldIter != aFieldName2TimeStamps.end(); aFieldIter++){
       const QString& aFieldName = aFieldIter->first;
       if (aFieldName == myFieldsCombo->currentText()) {
-       anEntity = anIter->first;
-       break;
+        anEntity = anIter->first;
+        break;
       }
     }
   }
@@ -374,8 +369,8 @@ void VisuGUI_DeformedShapeAndScalarMapDlg::SetScalarField( const bool save_scala
 void
 VisuGUI_DeformedShapeAndScalarMapDlg
 ::SetScalarField(int theIter,
-                QString theFieldName, 
-                const bool save_scalar_pane )
+                 QString theFieldName, 
+                 const bool save_scalar_pane )
 {
   QApplication::setOverrideCursor(Qt::WaitCursor);
 
@@ -393,8 +388,8 @@ VisuGUI_DeformedShapeAndScalarMapDlg
   
   try {
     myPrsCopy->SetScalarField(anEntity,
-                             aFieldName.toLatin1().constData(),
-                             theIter);
+                              aFieldName.toLatin1().constData(),
+                              theIter);
     if( save_scalar_pane )
       UpdateScalarField();
     myIsScalarFieldValid = true;
@@ -444,7 +439,7 @@ void VisuGUI_DeformedShapeAndScalarMapDlg::AddAllTimes(const QString& theFieldNa
     for(; aFieldIter != aFieldName2TimeStamps.end(); aFieldIter++){
       const QString& aFieldName = aFieldIter->first;
       if(theFieldName != aFieldName) 
-       continue;
+        continue;
 
       myTimeStampID.clear();
       myTimeStampsCombo->clear();
@@ -452,11 +447,11 @@ void VisuGUI_DeformedShapeAndScalarMapDlg::AddAllTimes(const QString& theFieldNa
       const TTimeStampNumber2Time& aTimeStampNumber2Time = aFieldIter->second;
       TTimeStampNumber2Time::const_iterator aTimeStampIter = aTimeStampNumber2Time.begin();
       for(; aTimeStampIter != aTimeStampNumber2Time.end(); aTimeStampIter++){
-       int aTimeStampNumber = aTimeStampIter->first;
-       myTimeStampID.push_back(aTimeStampNumber);
+        int aTimeStampNumber = aTimeStampIter->first;
+        myTimeStampID.push_back(aTimeStampNumber);
 
-       QString aTimeStampTime = aTimeStampIter->second;
-       myTimeStampsCombo->addItem(aTimeStampTime);
+        QString aTimeStampTime = aTimeStampIter->second;
+        myTimeStampsCombo->addItem(aTimeStampTime);
       }
       if(currentTimeStampId >= myTimeStampID.size())
         currentTimeStampId = myTimeStampID.size()-1;
@@ -484,16 +479,16 @@ void VisuGUI_DeformedShapeAndScalarMapDlg::UpdateScalarField(){
 QString 
 VisuGUI_DeformedShapeAndScalarMapDlg
 ::GetFloatValueOfTimeStamp(VISU::Entity theEntity,
-                          const std::string& theFieldName,
-                          int theTimeStampNumber)
+                           const std::string& theFieldName,
+                           int theTimeStampNumber)
 {
   QString aTime("");
   VISU::TEntity anEntity = VISU::TEntity(theEntity);
   VISU::Result_i* theResult = myPrsCopy->GetCResult();
   VISU::Result_i::PInput anInput = theResult->GetInput();
   VISU::PField aField = anInput->GetField(myPrsCopy->GetCMeshName(),
-                                         anEntity,
-                                         theFieldName);
+                                          anEntity,
+                                          theFieldName);
   if(!aField) 
     return aTime;