From 8de0df2005b3621533d8f1549fc382c253206a66 Mon Sep 17 00:00:00 2001 From: rnv Date: Fri, 29 Apr 2011 12:25:53 +0000 Subject: [PATCH] Fix for the bug "IPAL22425 TC6.3.0: Wrong Dump of Study". --- src/GEOMGUI/GEOM_Displayer.cxx | 17 +++----- src/GEOMGUI/GEOM_Displayer.h | 2 +- src/GEOMGUI/GeometryGUI.cxx | 77 ++++++++++++++++++++-------------- src/GEOM_I/GEOM_DumpPython.cc | 28 +++++++++++++ src/GEOM_SWIG/geompyDC.py | 16 +++++++ 5 files changed, 97 insertions(+), 43 deletions(-) diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index e3ad553b0..fdd905cac 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -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& 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 diff --git a/src/GEOMGUI/GEOM_Displayer.h b/src/GEOMGUI/GEOM_Displayer.h index b5fa013f9..6b42f4a99 100644 --- a/src/GEOMGUI/GEOM_Displayer.h +++ b/src/GEOMGUI/GEOM_Displayer.h @@ -160,7 +160,7 @@ public: static SALOMEDS::Color getUniqueColor( const QList& ); - static PropMap getDefaultPropepryMap(const QString& viewer_type); + static PropMap getDefaultPropertyMap(const QString& viewer_type); static bool MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault); diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 857028ac8..0669dfe8d 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -1704,7 +1704,7 @@ const char gDigitsSep = ':'; // character used to separate numeric parameter val void GeometryGUI::storeVisualParameters (int savePoint) { SalomeApp_Study* appStudy = dynamic_cast(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(); - 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(); + 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 * diff --git a/src/GEOM_I/GEOM_DumpPython.cc b/src/GEOM_I/GEOM_DumpPython.cc index f91628a26..b1d252599 100644 --- a/src/GEOM_I/GEOM_DumpPython.cc +++ b/src/GEOM_I/GEOM_DumpPython.cc @@ -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::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) { diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 68543eecc..af394ff65 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -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 -- 2.39.2