]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Fix for the bug "IPAL22425 TC6.3.0: Wrong Dump of Study".
authorrnv <rnv@opencascade.com>
Fri, 29 Apr 2011 12:25:53 +0000 (12:25 +0000)
committerrnv <rnv@opencascade.com>
Fri, 29 Apr 2011 12:25:53 +0000 (12:25 +0000)
src/GEOMGUI/GEOM_Displayer.cxx
src/GEOMGUI/GEOM_Displayer.h
src/GEOMGUI/GeometryGUI.cxx
src/GEOM_I/GEOM_DumpPython.cc
src/GEOM_SWIG/geompyDC.py

index e3ad553b06d381988d7eb2d4d3c2d4f1c880c28a..fdd905cac9aad6282fb0f6af42d2049bab9bafa8 100644 (file)
@@ -615,11 +615,8 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
        
        if(useStudy){
          aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry);
-         aDefPropMap = getDefaultPropepryMap(SOCC_Viewer::Type());
-         bool isDiff = MergePropertyMaps(aPropMap, aDefPropMap);
-                    
-         if(isDiff)
-           aStudy->setObjectPropMap(aMgrId,anEntry,aPropMap);
+         aDefPropMap = getDefaultPropertyMap(SOCC_Viewer::Type());
+         MergePropertyMaps(aPropMap, aDefPropMap);
        }
 
         //Handle(GEOM_AISShape) AISShape = new GEOM_AISShape( myShape, "" );
@@ -984,7 +981,7 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
     theActors->AddItem( aTrh );
   }
   else {
-    PropMap aDefPropMap = getDefaultPropepryMap(SVTK_Viewer::Type());
+    PropMap aDefPropMap = getDefaultPropertyMap(SVTK_Viewer::Type());
 
     QString anEntry;
     if(!myIO.IsNull()) {
@@ -1000,11 +997,9 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
     theActors->AddItem(aGeomActor);
     aGeomActor->Delete();
     
-    if(useStudy){
+    if(useStudy) {
       aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry);
-      bool isDiff = MergePropertyMaps(aPropMap, aDefPropMap);
-      if(isDiff)
-       aStudy->setObjectPropMap(aMgrId,anEntry,aPropMap);
+      MergePropertyMaps(aPropMap, aDefPropMap);
     }
   }
 
@@ -1689,7 +1684,7 @@ SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QList<SALOMEDS::Color>& th
 
 
 
-PropMap GEOM_Displayer::getDefaultPropepryMap(const QString& viewer_type){
+PropMap GEOM_Displayer::getDefaultPropertyMap(const QString& viewer_type) {
   PropMap aDefaultMap;
   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();    
   //1. Visibility 
index b5fa013f9fed37d48a510511bf9aeb06ec3e3be7..6b42f4a99debb4f76d5fc1357f77f83c20b40103 100644 (file)
@@ -160,7 +160,7 @@ public:
 
   static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
 
-  static PropMap getDefaultPropepryMap(const QString& viewer_type);
+  static PropMap getDefaultPropertyMap(const QString& viewer_type);
   
   static bool MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault);
   
index 857028ac84ed74241f6b0ad0fcca8191d2ea4526..0669dfe8dd4cbd4785fb8c1a083067623f436873 100644 (file)
@@ -1704,7 +1704,7 @@ const char gDigitsSep = ':'; // character used to separate numeric parameter val
 void GeometryGUI::storeVisualParameters (int savePoint)
 {
   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
-  if (!appStudy || !appStudy->studyDS())
+  if ( !appStudy || !appStudy->studyDS() )
     return;
   _PTR(Study) studyDS = appStudy->studyDS();
 
@@ -1739,7 +1739,7 @@ void GeometryGUI::storeVisualParameters (int savePoint)
 
         //Check that object exists in the study
         _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
-        if ( !obj )
+        if ( !obj || !(aProps.count() > 0))
           continue;
         // entry is "encoded" = it does NOT contain component adress, since it is a
         // subject to change on next component loading
@@ -1750,52 +1750,67 @@ void GeometryGUI::storeVisualParameters (int savePoint)
         if( !obj->FindAttribute(anAttr, "AttributeIOR"))
           continue;
 
-        std::string param, occParam = vType.toLatin1().data();
+        std::string param,occParam = vType.toLatin1().data();
         occParam += NAME_SEPARATOR;
         occParam += QString::number(aMgrId).toLatin1().data();
         occParam += NAME_SEPARATOR;
 
-        param = occParam + VISIBILITY_PROP;
-        ip->setParameter(entry, param, aProps.value(VISIBILITY_PROP).toInt() == 1 ? "On" : "Off");
-
-        param = occParam + DISPLAY_MODE_PROP;
-
-        ip->setParameter(entry, param, QString::number(aProps.value(DISPLAY_MODE_PROP).toInt()).toLatin1().data());
-
-        QColor c = aProps.value(COLOR_PROP).value<QColor>();
-        QString colorStr = QString::number(c.red()/255.);
-        colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.green()/255.);
-        colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.blue()/255.);
-        param = occParam + COLOR_PROP;
-        ip->setParameter(entry, param, colorStr.toLatin1().data());
+       if(aProps.contains(VISIBILITY_PROP)) {
+         param = occParam + VISIBILITY_PROP;
+         ip->setParameter(entry, param, aProps.value(VISIBILITY_PROP).toInt() == 1 ? "On" : "Off");
+       }
+
+       if(aProps.contains(DISPLAY_MODE_PROP)) {
+         param = occParam + DISPLAY_MODE_PROP;
+         ip->setParameter(entry, param, QString::number(aProps.value(DISPLAY_MODE_PROP).toInt()).toLatin1().data());
+       }
+       
+       if(aProps.contains(COLOR_PROP)) {
+         QColor c = aProps.value(COLOR_PROP).value<QColor>();
+         QString colorStr = QString::number(c.red()/255.);
+         colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.green()/255.);
+         colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.blue()/255.);
+         param = occParam + COLOR_PROP;
+         ip->setParameter(entry, param, colorStr.toLatin1().data());
+       }
 
         if(vType == SVTK_Viewer::Type()) {
-          param = occParam + OPACITY_PROP;
-          ip->setParameter(entry, param, QString::number(1. - aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
+         if(aProps.contains(OPACITY_PROP)) {
+           param = occParam + OPACITY_PROP;
+           ip->setParameter(entry, param, QString::number(1. - aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
+         }
         } else if (vType == SOCC_Viewer::Type()) {
-          param = occParam + TRANSPARENCY_PROP;
-          ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
+         if(aProps.contains(TRANSPARENCY_PROP)) {
+           param = occParam + TRANSPARENCY_PROP;
+           ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
+         }
         }
 
-        param = occParam + ISOS_PROP;
-        ip->setParameter(entry, param, aProps.value(ISOS_PROP).toString().toLatin1().data());
-
-        param = occParam + VECTOR_MODE_PROP;
-        ip->setParameter(entry, param, QString::number(aProps.value(VECTOR_MODE_PROP).toInt()).toLatin1().data());
-
-        param = occParam + DEFLECTION_COEFF_PROP;
-        ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data());
-
+       if(aProps.contains(ISOS_PROP)) {
+         param = occParam + ISOS_PROP;
+         ip->setParameter(entry, param, aProps.value(ISOS_PROP).toString().toLatin1().data());
+       }
+
+       if(aProps.contains(VECTOR_MODE_PROP)) {
+         param = occParam + VECTOR_MODE_PROP;
+         ip->setParameter(entry, param, QString::number(aProps.value(VECTOR_MODE_PROP).toInt()).toLatin1().data());
+       }
+
+       if(aProps.contains(DEFLECTION_COEFF_PROP)) {
+         param = occParam + DEFLECTION_COEFF_PROP;
+         ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data());
+       }
+       
         //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
         if(aProps.contains(MARKER_TYPE_PROP)) {
           param = occParam + MARKER_TYPE_PROP;
           ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data());
-        }
-
+        }      
       } // object iterator
     } // for (views)
   } // for (viewManagers)
 }
+
 /*!
  * \brief Restore visual parameters
  *
index f91628a264c9bc215f3c805bb0638b175ca448c1..b1d2525994377be1d659d529495b744dbf71eff9 100644 (file)
@@ -132,6 +132,34 @@ Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
 
   if (isPublished)
   {
+
+    SALOMEDS::AttributeParameter_var ap = aStudy->GetModuleParameters("Interface Applicative", 
+                                                                     ComponentDataType(),
+                                                                     -1);
+    if(!CORBA::is_nil(ap)) {
+      //Add the id parameter of the object
+      std::vector<TObjectData>::iterator it = objectDataVec.begin();
+      for( ;it != objectDataVec.end(); it++ ) {
+      
+       //1. Encode entry 
+       std::string tail( (*it)._studyEntry.ToCString(), 6, (*it)._studyEntry.Length()-1 );
+       std::string newEntry(ComponentDataType());
+       newEntry+=("_"+tail);
+       
+       CORBA::String_var anEntry = CORBA::string_dup(newEntry.c_str());
+       
+       if( ap->IsSet(anEntry, 6) ) { //6 Means string array, see SALOMEDS_Attributes.idl AttributeParameter interface
+         std::string idCommand = std::string("geompy.getObjectID(") + GetDumpName((*it)._studyEntry.ToCString()) + std::string(")");
+         SALOMEDS::StringSeq_var aSeq= ap->GetStrArray(anEntry);
+         int oldLenght = aSeq->length();       
+         aSeq->length(oldLenght+2);
+         aSeq[oldLenght] = CORBA::string_dup("_PT_OBJECT_ID_");
+         aSeq[oldLenght + 1] = CORBA::string_dup(idCommand.c_str());
+         ap->SetStrArray( anEntry, aSeq );
+       }        
+      }
+    }
+  
     //Output the script that sets up the visual parameters.
     char* script = aStudy->GetDefaultScript(ComponentDataType(), "\t");
     if (script && strlen(script) > 0) {
index 68543eecc59b37f9494ae86641884235ca811cec..af394ff657f10cb6bbb5674d6535b19fbc3ffee7 100644 (file)
@@ -4694,6 +4694,22 @@ class geompyDC(GEOM._objref_GEOM_Gen):
             RaiseIfFailed("LoadTexture", self.InsertOp)
             return ID
 
+        ## Get entry of the object
+        #  @param obj geometry object
+        #  @return unique object identifier
+        #  @ingroup l1_geompy_auxiliary
+        def getObjectID(self, obj):
+            ID = ""
+            entry = salome.ObjectToID(obj)
+            if entry is not None:
+                lst = entry.split(":")
+                if len(lst) > 0:
+                    ID = lst[-1] # -1 means last item in the list            
+                    return "GEOM_" + ID
+            return ID
+                
+            
+
         ## Add marker texture. @a Width and @a Height parameters
         #  specify width and height of the texture in pixels.
         #  If @a RowData is @c True, @a Texture parameter should represent texture data