]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
PAL13555: CutLines; Option to see the length as abscissa
authorepa <epa@opencascade.com>
Fri, 20 Oct 2006 06:56:46 +0000 (06:56 +0000)
committerepa <epa@opencascade.com>
Fri, 20 Oct 2006 06:56:46 +0000 (06:56 +0000)
idl/VISU_Gen.idl
resources/SalomeApp.xml
src/VISUGUI/VISU_msg_en.po
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_CutLinesDlg.cxx
src/VISUGUI/VisuGUI_CutLinesDlg.h
src/VISU_I/VISU_CutLines_i.cc
src/VISU_I/VISU_CutLines_i.hh

index 2f1d27f9c008597788b7deadc7c690724a4c0ff7..6939b00842afb50cfc7ca204dc392a6a6795e409 100644 (file)
@@ -964,6 +964,25 @@ module VISU {
      * Gets the number of cut lines.
      */
     long GetNbLines();
+
+    /*! Invert all curves of corresponding table
+     * \param theInvert - Invert all curves, if value is TRUE, else not.
+     */
+    void SetAllCurvesInverted(in boolean theInvert);
+
+    /*! Checks the orientation of all curves
+     * \retval TRUE - if all curves are inverted, else FALSE
+     */
+    boolean IsAllCurvesInverted();
+
+    /*! Sets values which cutlines would be shown: aboslute or relative values
+     * \param theAbsLength - boolean value, TRUE or false.
+     */
+    void SetUseAbsoluteLength(in boolean theAbsLength);
+
+    /*! Checks values of cutlines: using aboslute or relative values
+     */
+    boolean IsUseAbsoluteLength();
   };
 
   /*! \brief Interface of the stream lines representation
index 5488527cc80116efb353ae8fe1f2964896c0c2cb..53be7b25dd1c5787962196382c28ffb621f889ce 100644 (file)
@@ -4,6 +4,11 @@
     <parameter name="name" value="Post-Pro"/>
     <parameter name="icon" value="ModuleVisu.png"/>
     <!-- Other module preferences -->
+    <parameter name="show_preview" value="false"/>
+    <parameter name="invert_all_curves" value="false"/>
+    <parameter name="use_absolute_length" value="false"/>
+    <parameter name="generate_data_table" value="true"/>
+    <parameter name="generate_curves" value="true"/>
     <parameter name="use_build_progress" value="false"/>
     <parameter name="full_med_loading"   value="false"/>
     <parameter name="mesh_represent"           value="2"/>
index 2cc01cee4729ea6a45eb69d6e6e13c0a697dd1bf..b51fcdeaceb99d5b0ce9f8f3020635ca17df6c61 100644 (file)
@@ -174,6 +174,9 @@ msgstr "Number of cycles"
 msgid "VISU_NB_STEPS"
 msgstr "Number of steps"
 
+msgid "VISU_CUTLINE_PREF"
+msgstr "CutLine preferences"
+
 msgid "VISU_PREF_MED_IMPORT"
 msgstr "MED files import"
 
@@ -478,6 +481,9 @@ msgstr "minimal and maximal"
 msgid "VisuGUI_CutLinesDlg::LBL_INVERT_CURVES"
 msgstr "Invert all curves"
 
+msgid "VisuGUI_CutLinesDlg::LBL_ABSOLUTE_LENGTH"
+msgstr "Use absolute length"
+
 msgid "VisuGUI_CutLinesDlg::LBL_GENERATE_CURVES"
 msgstr "Generate Curves"
 
@@ -2117,4 +2123,4 @@ msgid "VISU_PLOT3D"
 msgstr "Plot3D"
 
 msgid "VISU_SCALAR_MAP_ON_DEFORMED_SHAPE"
-msgstr "Scalar Map on Def. Shape"
\ No newline at end of file
+msgstr "Scalar Map on Def. Shape"
index aadd869dd0946964eb6998c711b2c7daffe5c8a2..df34877dbc41ffce7eefa53efbd6c46145f73b89 100644 (file)
@@ -3071,6 +3071,16 @@ void VisuGUI::createPreferences()
   setPreferenceProperty( nbcycles, "max",  100  );
   setPreferenceProperty( nbsteps,  "max",  200  );  
 
+  // group: "CutLines preferences"
+  int cutLineTab = addPreference( tr( "CutLines" ) );
+  int cutLineGr = addPreference( tr( "VISU_CUTLINE_PREF" ), cutLineTab );
+  setPreferenceProperty( cutLineGr, "columns", 1 );
+  addPreference( tr( "Show preview" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "show_preview" );
+  addPreference( tr( "Invert all curves" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "invert_all_curves" );
+  addPreference( tr( "Use absolute length" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "use_absolute_length" );
+  addPreference( tr( "Generate data table" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "generate_data_table" );
+  addPreference( tr( "Generate curves" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "generate_curves" );
+
   // group: "MED files import"
   int importGr = addPreference( tr( "MED files import" ), srangeTab );
   setPreferenceProperty( importGr, "columns", 1 );
index d189683ffedef1ed5f16db779633026331f91bb8..39a0c9fc8da4cb8f569799337cfdf82a2283e6be 100644 (file)
@@ -62,9 +62,6 @@
 
 using namespace std;
 
-bool VisuGUI_CutLinesDlg::MYGenerateTable = true;
-bool VisuGUI_CutLinesDlg::MYGenerateCurve = true;
-
 VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule)
      : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutLinesDlg", false,
                WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
@@ -135,8 +132,12 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule)
   myAllCurvesInvertedCheck->setChecked(false);
   aPlaneLayout->addWidget(myAllCurvesInvertedCheck);
 
+  myUseAbsoluteLengthCheck = new QCheckBox(tr("LBL_ABSOLUTE_LENGTH"), aPlanePane);
+  myUseAbsoluteLengthCheck->setChecked(false);
+  aPlaneLayout->addWidget(myUseAbsoluteLengthCheck);
+
   myCreateTable = new QCheckBox (tr("LBL_GENERATE_TABLE"), aPlanePane);
-  myCreateTable->setChecked(MYGenerateTable);
+  myCreateTable->setChecked(true);
   aPlaneLayout->addWidget( myCreateTable );
 
   QHBox* aCheckPane = new QHBox(aPlanePane);
@@ -144,8 +145,8 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule)
   aCheckPane->setStretchFactor(aLbl, 0);
   myCurvesCheck = new QCheckBox(tr("LBL_GENERATE_CURVES"), aCheckPane);
   aCheckPane->setStretchFactor(aCheckPane, 0);
-  myCurvesCheck->setChecked(MYGenerateCurve);
-  myCurvesCheck->setEnabled(MYGenerateTable);
+  myCurvesCheck->setChecked(true);
+  myCurvesCheck->setEnabled(true);
   QLabel* aLbl2 = new QLabel("   ", aCheckPane);
   aCheckPane->setStretchFactor(aLbl2, 1);
   aPlaneLayout->addWidget( aCheckPane );
@@ -289,6 +290,12 @@ void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::CutLines_i* thePrs)
   myPrs = thePrs;
   myScalarPane->initFromPrsObject(thePrs);
 
+  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+  myPreviewCheck->setChecked( aResourceMgr->booleanValue("VISU", "show_preview", false) );
+  myCreateTable->setChecked( aResourceMgr->booleanValue("VISU", "generate_data_table", true) );
+  myCurvesCheck->setChecked( aResourceMgr->booleanValue("VISU", "generate_curves", true) );
+  myCurvesCheck->setEnabled( aResourceMgr->booleanValue("VISU", "generate_curves", true) );
+
   myRotXSpn->setValue(thePrs->GetRotateX()*180./PI);
   myRotYSpn->setValue(thePrs->GetRotateY()*180./PI);
   myPosSpn->setValue(thePrs->GetDisplacement());
@@ -303,8 +310,8 @@ void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::CutLines_i* thePrs)
   hasInit = true;
   myCutLines = new VISU::CutLines_i(thePrs->GetResult(),false);
   myCutLines->SameAs(thePrs);
-  myCutLines->CopyCurvesInverted(thePrs->GetCurvesInverted());
-  if (myCutLines->IsAllCurvesInverted()) myAllCurvesInvertedCheck->setChecked(true);
+  myAllCurvesInvertedCheck->setChecked(myCutLines->IsAllCurvesInverted());
+  myUseAbsoluteLengthCheck->setChecked(myCutLines->IsUseAbsoluteLength());
   myBasePlanePos->setText( QString::number(myCutLines->GetBasePlanePosition()) );
   myCBSetDef->setChecked(thePrs->IsDefault());
   DrawTable();
@@ -342,6 +349,8 @@ int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::CutLines_i* thePrs)
   }
   if (myAllCurvesInvertedCheck->isChecked())
     thePrs->SetAllCurvesInverted(true);
+
+  thePrs->SetUseAbsoluteLength(myUseAbsoluteLengthCheck->isChecked());
   return 1;
 }
 
@@ -751,93 +760,9 @@ void VisuGUI_CutLinesDlg::onValueChanged (int theRow, int theCol)
 
 void VisuGUI_CutLinesDlg::accept()
 {
-  //if ( !VisuGUI::CheckActiveStudyLock() ) {
-  //  reject();
-  //  return;
-  //}
-  MYGenerateTable = myCreateTable->isChecked();
-  MYGenerateCurve = myCurvesCheck->isChecked();
-  //  if (myScalarPane->check()) {
-    /*jfa tmp:((QWidget*)sender())->setDisabled(true);
-    storeToPrsObject(myPrs);
-    if (myIsCreation) {
-      if (isGenerateTable()) {
-       visuGUI->GetVisuGen()->CreateTable(myPrs->GetEntry());
-       if (isGenerateCurves()) {
-         SALOMEDSClient_Study* aStudy = study()->studyDS();
-         SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrs->GetEntry());
-         if( aSObject ) {
-           SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
-           SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
-           for ( ;aIter->More(); aIter->Next()) {
-             SALOMEDSClient_SObject* aTblObj = aIter->Value();
-             if ( aTblObj ) {
-               SALOMEDSClient_GenericAttribute* anAttr;
-               if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
-                 visuGUI->CreatePlot(aTblObj);
-               }
-             }
-           }
-         }
-       }
-      }
-      if (GET_VTK_VIEWWINDOW(myMgr)) {
-       try {
-         visuGUI->CreateActor(myPrs);
-       } catch (...) {
-         reject();
-         return;
-       }
-       GET_VTK_VIEWWINDOW(myMgr)->onFitAll();
-      }
-    } else {
-      visuGUI->RecreateActor(myPrs);
-      if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) {
-       if (vf->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
-         vf->getRenderer()->ResetCameraClippingRange();
-         vf->Repaint();
-       }
-      }
-      // Remove old Table
-      SALOMEDSClient_Study* aStudy = study()->studyDS();
-      SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrs->GetEntry());
-      if( aSObject ) {
-       SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
-       SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
-       for ( ;aIter->More(); aIter->Next()) {
-         SALOMEDSClient_SObject* aTblObj = aIter->Value();
-         if ( aTblObj ) {
-           SALOMEDSClient_GenericAttribute* anAttr;
-           if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
-             aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
-             break;
-           }
-         }
-       }
-       if (isGenerateTable()) {
-         visuGUI->GetVisuGen()->CreateTable(aSObject->GetID().c_str());
-         if (isGenerateCurves()) {
-           SALOMEDSClient_Study* aStudy = study()->studyDS();
-           SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
-           SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
-           for ( ;aIter->More(); aIter->Next()) {
-             SALOMEDSClient_SObject* aTblObj = aIter->Value();
-             if ( aTblObj ) {
-               SALOMEDSClient_GenericAttribute* anAttr;
-               if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
-                 visuGUI->CreatePlot(aTblObj);
-               }
-             }
-           }
-         }
-       }
-      }
-    }
-    VisuGUI::application()->objectBrowser()->updateTree();*/
     myScalarPane->deletePreview();
     deletePlanes();
     QDialog::accept();
-    //  }
 }
 
 void VisuGUI_CutLinesDlg::reject()
index 8b0e1da4b3cab9fac9aa897d4984c24223de7606..85139515e71cdeab08cd57aa83e890660295d6cb 100644 (file)
@@ -110,6 +110,7 @@ private:
   SALOME_Actor* myPreviewActorGlyphs;
   QCheckBox* myPreviewCheck;
   QCheckBox* myAllCurvesInvertedCheck;
+  QCheckBox* myUseAbsoluteLengthCheck;
 
   VISU::CutLines_i* myPrs;
 
index a44b5216b7274eb92ac8c2745cb447cf854a5442..e650bda06998c911a1ffc4de18bcdfa013f98bf6 100644 (file)
@@ -67,7 +67,8 @@ CutLines_i(Result_i* theResult,
   Prs3d_i(theResult,theAddToStudy),
   ColoredPrs3d_i(theResult,theAddToStudy),
   ScalarMap_i(theResult,theAddToStudy),
-  myCutLinesPL(NULL)
+  myCutLinesPL(NULL),
+  myUseAbsLength(false)
 {}
 
 
@@ -78,7 +79,8 @@ CutLines_i(Result_i* theResult,
   Prs3d_i(theResult,theSObject),
   ColoredPrs3d_i(theResult,theSObject),
   ScalarMap_i(theResult,theSObject),
-  myCutLinesPL(NULL)
+  myCutLinesPL(NULL),
+  myUseAbsLength(false)
 {
 }
 
@@ -93,7 +95,12 @@ void VISU::CutLines_i::CopyCurvesInverted(const TCurvesInv& theCurves){
 VISU::Storable* VISU::CutLines_i::Create(const char* theMeshName, VISU::Entity theEntity, 
                                         const char* theFieldName, int theIteration)
 {
-  return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration);
+  TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
+  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+  SetAllCurvesInverted( aResourceMgr->booleanValue("VISU", "invert_all_curves", false) );
+  SetUseAbsoluteLength( aResourceMgr->booleanValue("VISU", "use_absolute_length", false) );
+
+  return this;
 }
 
 
@@ -110,6 +117,8 @@ VISU::Storable* VISU::CutLines_i::Restore(const Storable::TRestoringMap& theMap)
   SetOrientation2(CutPlanes::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane[1]").toInt()),
                  Storable::FindValue(theMap,"aRot[1][0]").toDouble(),
                  Storable::FindValue(theMap,"aRot[1][1]").toDouble());
+  SetUseAbsoluteLength(VISU::Storable::FindValue(theMap,"myUseAbsLength").toInt());
+
   if (VISU::Storable::FindValue(theMap,"myBasePlaneCondition").toInt())
     SetDefault();
   else
@@ -161,8 +170,10 @@ void VISU::CutLines_i::ToStream(std::ostringstream& theStr){
     aStrPos.append(QString::number(GetLinePosition(i)) + "|");
     aStrCon.append(QString::number(IsDefaultPosition(i)) + "|");
   }
+
   Storable::DataToStream( theStr, "myLinePosition",  aStrPos.latin1());
   Storable::DataToStream( theStr, "myLineCondition", aStrCon.latin1());
+  Storable::DataToStream( theStr,"myUseAbsLength", IsUseAbsoluteLength());
 
   // Storing the map - \a myMapCurvesInverted
   QString aStrCurvesInverted;
@@ -284,6 +295,13 @@ void VISU::CutLines_i::SetCurveInverted(CORBA::Long theCurveNumber,CORBA::Boolea
   myMapCurvesInverted[theCurveNumber] = theInvert;
 }
 
+/*! It control the way the length of cutlines is shown: using aboslute or relative values
+* \param theAbsLength - boolean value, TRUE or false.
+*/
+void VISU::CutLines_i::SetUseAbsoluteLength(CORBA::Boolean theAbsLength){
+  myUseAbsLength = theAbsLength;
+}
+
 /*! Checks orientation of curve.
  * \param theCurveNumber - integer value, number of cut line.
  * \retval TRUE - if line in the table is inverted, else FALSE.
@@ -369,7 +387,11 @@ void VISU::CutLines_i::BuildTableOfReal(SALOMEDS::SObject_ptr theSObject){
       if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal iLine = "<<iLine<<"; aNbPoints = "<<aNbPoints);
       aLineIdCont[iLine] = jLine++;
       TXYMap& aXYMap = aXYMapCont[iLine];
-      vtkFloatingPointType aPnt[3], aVect[3], aDist;
+      vtkFloatingPointType aPnt[3], aVect[3], aDist, aTopBnd;
+      aTopBnd = aBoundPrjLn[2];
+      if( !IsUseAbsoluteLength() ){
+        aTopBnd = 1.0;
+      }
       for(int i = 0; i < aNbPoints; i++){
        aDataSet->GetPoint(i,aPnt);
        Sub(aPnt,aBasePnt,aVect);
@@ -377,10 +399,10 @@ void VISU::CutLines_i::BuildTableOfReal(SALOMEDS::SObject_ptr theSObject){
          aDist = 0.5;
        else
          {
-           aDist = vtkMath::Dot(aVect,aDirLn) / aBoundPrjLn[2];
+           aDist = vtkMath::Dot(aVect,aDirLn)/aTopBnd; 
            // the workaround
            if(aDist < 0.0) aDist = 0.0; 
-           if(aDist > 1.0) aDist = 1.0;
+           if(aDist > aTopBnd) aDist = aTopBnd;
          }
        aXYMap[aDist] = aScalars->GetTuple1(i);
       }
@@ -502,3 +524,13 @@ void VISU::CutLines_i::BuildTableOfReal(SALOMEDS::SObject_ptr theSObject){
     INFOS("Unknown exception was occured !!!");
   }
 }
+
+void VISU::CutLines_i::SameAs(const Prs3d_i* theOrigin){
+  TSuperClass::SameAs(theOrigin);
+  if(const CutLines_i* aPrs3d = dynamic_cast<const CutLines_i*>(theOrigin)){
+    CutLines_i* anOrigin = const_cast<CutLines_i*>(aPrs3d);
+    myUseAbsLength = anOrigin->IsUseAbsoluteLength();
+    CopyCurvesInverted(anOrigin->GetCurvesInverted());
+  }
+}
+
index 6464d210f074838a299d6fe1edb4c6a37d9b0c25..92b74b9b79f2ef4d22c246fa76ede05d18f1627a 100644 (file)
@@ -89,6 +89,9 @@ namespace VISU{
     virtual void SetCurveInverted(CORBA::Long theCurveNumber,CORBA::Boolean theInvert);
     virtual CORBA::Boolean IsCurveInverted(CORBA::Long theCurveNumber);
 
+    virtual void SetUseAbsoluteLength(CORBA::Boolean theAbsLength);
+    virtual CORBA::Boolean IsUseAbsoluteLength() {return myUseAbsLength;}
+
     virtual void SetNbLines(CORBA::Long theNb);
     virtual CORBA::Long GetNbLines();
     typedef VISU::CutLines TInterface;
@@ -103,6 +106,7 @@ namespace VISU{
 
     VISU_CutLinesPL *myCutLinesPL;
     TCurvesInv myMapCurvesInverted;
+    CORBA::Boolean myUseAbsLength;
 
   public:
     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
@@ -113,6 +117,7 @@ namespace VISU{
     virtual void ToStream(std::ostringstream& theStr);
 
     virtual Storable* Restore(const Storable::TRestoringMap& theMap);
+    virtual void SameAs( const Prs3d_i* Origin );
 
     virtual 
     VISU_Actor*