]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Issue 0020336: [CEA 339] specifying a cut line with 2 points V5_1_main_20090928
authorouv <ouv@opencascade.com>
Fri, 25 Sep 2009 12:13:27 +0000 (12:13 +0000)
committerouv <ouv@opencascade.com>
Fri, 25 Sep 2009 12:13:27 +0000 (12:13 +0000)
src/VISU_I/VISU_CutLinesBase_i.cc
src/VISU_I/VISU_CutLinesBase_i.hh
src/VISU_I/VISU_PointMap3d_i.cc
src/VISU_I/VISU_Table_i.cc

index 946db55d97ec5b772c7d9ae63b6a1df807acb4c9..7a43b3fec86b7ccdd37f45538cd7949a02e7de07 100644 (file)
@@ -274,7 +274,7 @@ VISU::CutLinesBase_i
 //---------------------------------------------------------------
 void
 VISU::CutLinesBase_i
-::BuildTableOfReal(SALOMEDS::SObject_var theSObject)
+::BuildTableOfReal(SALOMEDS::SObject_var theSObject, bool theIsCutSegment)
 {
   try{
     if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal");
@@ -422,12 +422,25 @@ VISU::CutLinesBase_i
     int iEnd = aXCont.size();
     aTableOfReal->SetNbColumns(iEnd);
     TXCont::const_iterator aXContIter = aXCont.begin();
+    vtkFloatingPointType aMinDist = *aXContIter;
+    aXContIter = aXCont.end();
+    aXContIter--;
+    vtkFloatingPointType aMaxDist = *aXContIter;
+    if(aMaxDist <= aMinDist)
+      throw std::runtime_error("CutPlanes_i::BuildTableOfReal aMaxDist <= aMinDist !!!");
+    aXContIter = aXCont.begin();
     for(long i = 0; aXContIter != aXCont.end(); aXContIter++, i++){
       vtkFloatingPointType aDist = *aXContIter; 
-      aTableOfReal->PutValue(aDist,1,i+1);
+      vtkFloatingPointType aXVal = aDist;
+      if(theIsCutSegment){
+        aXVal -= aMinDist;
+        if(!IsUseAbsoluteLength())
+          aXVal /= (aMaxDist - aMinDist);
+      }
+      aTableOfReal->PutValue(aXVal,1,i+1);
       aString.sprintf("%d",i);
       aTableOfReal->SetColumnTitle(i+1,(const char*)aString.toLatin1());
-      if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal aDist = "<<aDist);
+      if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal aDist = "<<aDist<<" aXVal = "<<aXVal);
       TXYMapCont::const_iterator aXYMapContIter = aXYMapCont.begin();
       for(; aXYMapContIter != aXYMapCont.end(); aXYMapContIter++){
         long iLine = aXYMapContIter->first;
index db1535a021d941f8ec59da493e5838a94374a2ee..1371023e704ba989a1bfe5df52d84c07bdc3080d 100644 (file)
@@ -133,7 +133,8 @@ namespace VISU
     void
     SameAs(const Prs3d_i* theOrigin);
 
-    void BuildTableOfReal(SALOMEDS::SObject_var theSObject);
+    void BuildTableOfReal(SALOMEDS::SObject_var theSObject,
+                          bool theIsCutSegment = false);
   };
 }
 
index a846c3d8e453811d384ee3f10e78b2ce084e9d7c..12df95c6652bd570e937cf155f46729aeb03ef16 100644 (file)
@@ -27,6 +27,7 @@
 #include "VISU_PointMap3d_i.hh"
 
 #include "VISU_CutLinesBase_i.hh"
+#include "VISU_CutSegment_i.hh"
 #include "VISU_Result_i.hh"
 #include "VISU_ViewManager_i.hh"
 #include "VISU_ScalarBarActor.hxx"
@@ -492,53 +493,54 @@ VISU::Storable* VISU::PointMap3d_i::Build( int theRestoring )
     if(!CORBA::is_nil(anObj)){
       VISU::CutLinesBase_var aCutLines = VISU::CutLinesBase::_narrow(anObj);
       if(!aCutLines->_is_nil())
-       pCutLines = dynamic_cast<CutLinesBase_i*>(GetServant(aCutLines).in());
+        pCutLines = dynamic_cast<CutLinesBase_i*>(GetServant(aCutLines).in());
     }
     SALOMEDS::Study_var aStudy = GetStudyDocument();
     SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
     SALOMEDS::GenericAttribute_var anAttr;
     // look for component
     if ( !theRestoring ) {
-       SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() );
-       // create SObject and set attributes
-       QString aComment;
-       if(pCutLines)
-         aComment.sprintf("myComment=%s;mySourceId=CutLines",GetComment());
-       else{
-         aComment.sprintf("myComment=%s;mySourceId=TableAttr",GetComment());
-         SALOMEDS::SObject_var aFatherSObject = SO->GetFather();
-         if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){
-           SALOMEDS::AttributeString_var aCommentAttr =
-             SALOMEDS::AttributeString::_narrow(anAttr);
-           CORBA::String_var aValue = aCommentAttr->Value();
-           Storable::TRestoringMap aMap;
-           Storable::StringToMap(aValue.in(),aMap);
-           bool anIsExist;
-           QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
-           if(anIsExist){
-             if(aMethodName == "ImportTables"){
-               aComment.sprintf("myComment=%s;mySourceId=TableFile",GetComment());
-             }
-           }
-         }
-       }
-
-       string anEntry = CreateAttributes( GetStudyDocument(),
-                                         SO->GetID(),//SComponent->GetID(),
-                                         "ICON_TREE_TABLE",
-                                         GetID(),
-                                         GetName(),
-                                         "",
-                                         aComment.toLatin1().constData(),
-                                         pCutLines );
-       // create SObject referenced to real table object
-       mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID( anEntry.c_str() ));
-       if(pCutLines) {
-         pCutLines->BuildTableOfReal(mySObj);
-       }
-       // mpv (PAL5357): reference attributes are unnecessary now
-       //SALOMEDS::SObject_var refSO = Builder->NewObject( mySObj );
-       //Builder->Addreference( refSO, SO );
+      SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() );
+      // create SObject and set attributes
+      QString aComment;
+      if(pCutLines)
+        aComment.sprintf("myComment=%s;mySourceId=CutLines",GetComment());
+      else{
+        aComment.sprintf("myComment=%s;mySourceId=TableAttr",GetComment());
+        SALOMEDS::SObject_var aFatherSObject = SO->GetFather();
+        if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){
+          SALOMEDS::AttributeString_var aCommentAttr =
+            SALOMEDS::AttributeString::_narrow(anAttr);
+          CORBA::String_var aValue = aCommentAttr->Value();
+          Storable::TRestoringMap aMap;
+          Storable::StringToMap(aValue.in(),aMap);
+          bool anIsExist;
+          QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
+          if(anIsExist){
+            if(aMethodName == "ImportTables"){
+              aComment.sprintf("myComment=%s;mySourceId=TableFile",GetComment());
+            }
+          }
+        }
+      }
+
+      string anEntry = CreateAttributes( GetStudyDocument(),
+                                         SO->GetID(),//SComponent->GetID(),
+                                         "ICON_TREE_TABLE",
+                                         GetID(),
+                                         GetName(),
+                                         "",
+                                         aComment.toLatin1().constData(),
+                                         pCutLines );
+      // create SObject referenced to real table object
+      mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID( anEntry.c_str() ));
+      if(pCutLines) {
+        bool isCutSegment = dynamic_cast<CutSegment_i*>(pCutLines);
+        pCutLines->BuildTableOfReal(mySObj, isCutSegment);
+      }
+      // mpv (PAL5357): reference attributes are unnecessary now
+      //SALOMEDS::SObject_var refSO = Builder->NewObject( mySObj );
+      //Builder->Addreference( refSO, SO );
     }
 
     return this;
index cf044b28977f5ccb4b5d399ff43a41f82a2c16bc..80a3a4848466d393cb81927226c5493ab2207a92 100644 (file)
@@ -27,6 +27,7 @@
 #include "VISU_Table_i.hh"
 
 #include "VISU_CutLinesBase_i.hh"
+#include "VISU_CutSegment_i.hh"
 #include "VISU_Result_i.hh"
 #include "VISU_ViewManager_i.hh"
 
@@ -214,52 +215,53 @@ VISU::Storable* VISU::Table_i::Build( int theRestoring )
     if(!CORBA::is_nil(anObj)){
       VISU::CutLinesBase_var aCutLines = VISU::CutLinesBase::_narrow(anObj);
       if(!aCutLines->_is_nil())
-       pCutLines = dynamic_cast<CutLinesBase_i*>(GetServant(aCutLines).in());
+        pCutLines = dynamic_cast<CutLinesBase_i*>(GetServant(aCutLines).in());
     }
     SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
     SALOMEDS::GenericAttribute_var anAttr;
     // look for component
     if ( !theRestoring ) {
-       SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() );
-       // create SObject and set attributes
-       QString aComment;
-       if(pCutLines)
-         aComment.sprintf("myComment=%s;mySourceId=CutLines",GetComment());
-       else{
-         aComment.sprintf("myComment=%s;mySourceId=TableAttr",GetComment());
-         SALOMEDS::SObject_var aFatherSObject = SO->GetFather();
-         if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){
-           SALOMEDS::AttributeString_var aCommentAttr =
-             SALOMEDS::AttributeString::_narrow(anAttr);
-           CORBA::String_var aValue = aCommentAttr->Value();
-           Storable::TRestoringMap aMap;
-           Storable::StringToMap(aValue.in(),aMap);
-           bool anIsExist;
-           QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
-           if(anIsExist){
-             if( aMethodName == "ImportTables" ){
-               aComment.sprintf("myComment=%s;mySourceId=TableFile",GetComment());
-             }
-           }
-         }
-       }
+      SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() );
+      // create SObject and set attributes
+      QString aComment;
+      if(pCutLines)
+        aComment.sprintf("myComment=%s;mySourceId=CutLines",GetComment());
+      else{
+        aComment.sprintf("myComment=%s;mySourceId=TableAttr",GetComment());
+        SALOMEDS::SObject_var aFatherSObject = SO->GetFather();
+        if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){
+          SALOMEDS::AttributeString_var aCommentAttr =
+            SALOMEDS::AttributeString::_narrow(anAttr);
+          CORBA::String_var aValue = aCommentAttr->Value();
+          Storable::TRestoringMap aMap;
+          Storable::StringToMap(aValue.in(),aMap);
+          bool anIsExist;
+          QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
+          if(anIsExist){
+            if( aMethodName == "ImportTables" ){
+              aComment.sprintf("myComment=%s;mySourceId=TableFile",GetComment());
+            }
+          }
+        }
+      }
 
-       string anEntry = CreateAttributes( GetStudyDocument(),
-                                         SO->GetID(),//SComponent->GetID(),
-                                         "ICON_TREE_TABLE",
-                                         GetID(),
-                                         GetName(),
-                                         "",
-                                         aComment.toLatin1().data(),
-                                         pCutLines );
-       // create SObject referenced to real table object
-       mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID( anEntry.c_str() ));
-       if(pCutLines) {
-         pCutLines->BuildTableOfReal(mySObj);
-       }
-       // mpv (PAL5357): reference attributes are unnecessary now
-       //SALOMEDS::SObject_var refSO = Builder->NewObject( mySObj );
-       //Builder->Addreference( refSO, SO );
+      string anEntry = CreateAttributes( GetStudyDocument(),
+                                         SO->GetID(),//SComponent->GetID(),
+                                         "ICON_TREE_TABLE",
+                                         GetID(),
+                                         GetName(),
+                                         "",
+                                         aComment.toLatin1().data(),
+                                         pCutLines );
+      // create SObject referenced to real table object
+      mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID( anEntry.c_str() ));
+      if(pCutLines) {
+        bool isCutSegment = dynamic_cast<CutSegment_i*>(pCutLines);
+        pCutLines->BuildTableOfReal(mySObj, isCutSegment);
+      }
+      // mpv (PAL5357): reference attributes are unnecessary now
+      //SALOMEDS::SObject_var refSO = Builder->NewObject( mySObj );
+      //Builder->Addreference( refSO, SO );
     }
 
     return this;