From 7e11ca9dab2b13ba03f464e7c1e9b235cba3505d Mon Sep 17 00:00:00 2001 From: mzn Date: Wed, 8 Nov 2006 12:56:40 +0000 Subject: [PATCH] Provide icons for presentations in Object Browser tree. --- src/VISUGUI/VISU_images.po | 76 ++++++++++++++++++- src/VISUGUI/VisuGUI_Tools.cxx | 3 + src/VISU_I/VISU_ColoredPrs3d_i.cc | 13 ++++ src/VISU_I/VISU_ColoredPrs3d_i.hh | 4 + src/VISU_I/VISU_CutLines_i.cc | 10 +++ src/VISU_I/VISU_CutLines_i.hh | 2 + src/VISU_I/VISU_CutPlanes_i.cc | 10 +++ src/VISU_I/VISU_CutPlanes_i.hh | 2 + src/VISU_I/VISU_DeformedShape_i.cc | 11 +++ src/VISU_I/VISU_DeformedShape_i.hh | 2 + src/VISU_I/VISU_GaussPoints_i.hh | 4 + src/VISU_I/VISU_IsoSurfaces_i.cc | 9 +++ src/VISU_I/VISU_IsoSurfaces_i.hh | 2 + src/VISU_I/VISU_Mesh_i.cc | 13 ++++ src/VISU_I/VISU_Plot3D_i.cc | 10 +++ src/VISU_I/VISU_Plot3D_i.hh | 2 + src/VISU_I/VISU_PrsMerger_i.cc | 58 ++++++++++++++ src/VISU_I/VISU_PrsMerger_i.hh | 2 + src/VISU_I/VISU_Result_i.cc | 13 +++- src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc | 10 +++ src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh | 4 + src/VISU_I/VISU_StreamLines_i.cc | 9 +++ src/VISU_I/VISU_StreamLines_i.hh | 3 + src/VISU_I/VISU_Table_i.cc | 30 +++++++- src/VISU_I/VISU_Vectors_i.cc | 11 +++ src/VISU_I/VISU_Vectors_i.hh | 3 + 26 files changed, 313 insertions(+), 3 deletions(-) diff --git a/src/VISUGUI/VISU_images.po b/src/VISUGUI/VISU_images.po index 9d204076..15dc4652 100644 --- a/src/VISUGUI/VISU_images.po +++ b/src/VISUGUI/VISU_images.po @@ -54,7 +54,7 @@ msgid "ICON_ISO_SURFACES" msgstr "Visu_isosurfaces.png" msgid "ICON_CUT_PLANES" -msgstr "Visu_cutplane.png" +msgstr "Visu_cutplanes.png" msgid "ICON_CUT_LINES" msgstr "Visu_cutlines.png" @@ -65,6 +65,80 @@ msgstr "Visu_streamlines.png" msgid "ICON_PLOT2D" msgstr "Visu_plot2d.png" +# Tree icons for presentations + +msgid "ICON_TREE_RESULT" +msgstr "Visu_tree_result.png" + +msgid "ICON_TREE_TABLE" +msgstr "Visu_tree_table.png" + +msgid "ICON_TREE_CURVE" +msgstr "Visu_tree_curve.png" + +msgid "ICON_TREE_CONTAINER" +msgstr "Visu_tree_container.png" + +msgid "ICON_TREE_MESH" +msgstr "Visu_tree_mesh.png" + +msgid "ICON_TREE_SCALAR_MAP" +msgstr "Visu_tree_scalars.png" + +msgid "ICON_TREE_SCALAR_MAP_GROUPS" +msgstr "Visu_tree_scalars_gr.png" + +msgid "ICON_TREE_DEFORMED_SHAPE" +msgstr "Visu_tree_deformed.png" + +msgid "ICON_TREE_DEFORMED_SHAPE_GROUPS" +msgstr "Visu_tree_deformed_gr.png" + +msgid "ICON_TREE_SCALAR_MAP_ON_DEFORMED_SHAPE" +msgstr "Visu_tree_scalarmapondeformedshape.png" + +msgid "ICON_TREE_SCALAR_MAP_ON_DEFORMED_SHAPE_GROUPS" +msgstr "Visu_tree_scalarmapondeformedshape_gr.png" + +msgid "ICON_TREE_VECTORS" +msgstr "Visu_tree_vectors.png" + +msgid "ICON_TREE_VECTORS_GROUPS" +msgstr "Visu_tree_vectors_gr.png" + +msgid "ICON_TREE_ISO_SURFACES" +msgstr "Visu_tree_isosurfaces.png" + +msgid "ICON_TREE_ISO_SURFACES_GROUPS" +msgstr "Visu_tree_isosurfaces_gr.png" + +msgid "ICON_TREE_CUT_PLANES" +msgstr "Visu_tree_cutplanes.png" + +msgid "ICON_TREE_CUT_PLANES_GROUPS" +msgstr "Visu_tree_cutplanes_gr.png" + +msgid "ICON_TREE_CUT_LINES" +msgstr "Visu_tree_cutlines.png" + +msgid "ICON_TREE_CUT_LINES_GROUPS" +msgstr "Visu_tree_cutlines_gr.png" + +msgid "ICON_TREE_STREAM_LINES" +msgstr "Visu_tree_streamlines.png" + +msgid "ICON_TREE_STREAM_LINES_GROUPS" +msgstr "Visu_tree_streamlines_gr.png" + +msgid "ICON_TREE_PLOT_3D" +msgstr "Visu_tree_plot3d.png" + +msgid "ICON_TREE_PLOT_3D_GROUPS" +msgstr "Visu_tree_plot3d_gr.png" + +msgid "ICON_TREE_GAUSS_POINTS" +msgstr "Visu_tree_gauss_points.png" + # Representation menu msgid "ICON_POINTS" diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 763de11a..5538c0d5 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -1121,6 +1121,9 @@ namespace VISU } } + SalomeApp_Module* aModule = (SalomeApp_Module*)theModule; + UpdateObjBrowser(aModule, false, aResultSObj); + theModule->application()->putInfo(QObject::tr("INF_DONE")); // Make "Save" button active theModule->getApp()->updateActions(); diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 275d3e2e..b45ccbe2 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -659,6 +659,8 @@ VISU::ColoredPrs3d_i } //---------------------------------------------------------------------------- + + VISU::Storable* VISU::ColoredPrs3d_i ::Build(int theRestoring) @@ -695,6 +697,17 @@ VISU::ColoredPrs3d_i CORBA::String_var anIOR = GetID(); CreateAttributes(myStudy,anEntry.c_str(),aRefFatherEntry.c_str(),anIOR,myName.c_str(),"",aComment.latin1(),true); mySObject = myStudy->FindObjectIOR(anIOR); + + // Set icon + if (GetIconName() != 0) + { + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + anAttr = aStudyBuilder->FindOrCreateAttribute( mySObject, "AttributePixMap" ); + aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); + aPixmap ->SetPixMap(GetIconName()); + } } #ifndef _DEXCEPT_ }catch(std::exception& exc){ diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index b5417b22..7e692efe 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -305,6 +305,10 @@ namespace VISU virtual void DoHook(); + + virtual + const char* + GetIconName() = 0; }; } diff --git a/src/VISU_I/VISU_CutLines_i.cc b/src/VISU_I/VISU_CutLines_i.cc index 5115bbb8..1e84dc02 100644 --- a/src/VISU_I/VISU_CutLines_i.cc +++ b/src/VISU_I/VISU_CutLines_i.cc @@ -309,6 +309,16 @@ void VISU::CutLines_i::DoHook(){ TSuperClass::DoHook(); } +const char* +VISU::CutLines_i +::GetIconName() +{ + if (!GetNumberOfGeom()) + return "ICON_TREE_CUT_LINES"; + else + return "ICON_TREE_CUT_LINES_GROUPS"; +} + VISU_Actor* VISU::CutLines_i ::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) diff --git a/src/VISU_I/VISU_CutLines_i.hh b/src/VISU_I/VISU_CutLines_i.hh index 2c56f044..41a3b39d 100644 --- a/src/VISU_I/VISU_CutLines_i.hh +++ b/src/VISU_I/VISU_CutLines_i.hh @@ -101,6 +101,8 @@ namespace VISU{ protected: virtual void DoHook(); + virtual const char* GetIconName(); + VISU_CutLinesPL *myCutLinesPL; TCurvesInv myMapCurvesInverted; diff --git a/src/VISU_I/VISU_CutPlanes_i.cc b/src/VISU_I/VISU_CutPlanes_i.cc index 21afcb42..300957a4 100644 --- a/src/VISU_I/VISU_CutPlanes_i.cc +++ b/src/VISU_I/VISU_CutPlanes_i.cc @@ -187,6 +187,16 @@ void VISU::CutPlanes_i::DoHook(){ TSuperClass::DoHook(); } +const char* +VISU::CutPlanes_i +::GetIconName() +{ + if (!GetNumberOfGeom()) + return "ICON_TREE_CUT_PLANES"; + else + return "ICON_TREE_CUT_PLANES_GROUPS"; +} + VISU_Actor* VISU::CutPlanes_i ::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) diff --git a/src/VISU_I/VISU_CutPlanes_i.hh b/src/VISU_I/VISU_CutPlanes_i.hh index e4a86664..fb149343 100644 --- a/src/VISU_I/VISU_CutPlanes_i.hh +++ b/src/VISU_I/VISU_CutPlanes_i.hh @@ -77,6 +77,8 @@ namespace VISU{ protected: virtual void DoHook(); + virtual const char* GetIconName(); + VISU_CutPlanesPL *myCutPlanesPL; public: diff --git a/src/VISU_I/VISU_DeformedShape_i.cc b/src/VISU_I/VISU_DeformedShape_i.cc index ec2a1750..eea75028 100644 --- a/src/VISU_I/VISU_DeformedShape_i.cc +++ b/src/VISU_I/VISU_DeformedShape_i.cc @@ -164,6 +164,17 @@ void VISU::DeformedShape_i::DoHook(){ } +const char* +VISU::DeformedShape_i +::GetIconName() +{ + if (!GetNumberOfGeom()) + return "ICON_TREE_DEFORMED_SHAPE"; + else + return "ICON_TREE_DEFORMED_SHAPE_GROUPS"; +} + + void VISU::DeformedShape_i::SetMapScale(double theMapScale){ myDeformedShapePL->SetMapScale(theMapScale); } diff --git a/src/VISU_I/VISU_DeformedShape_i.hh b/src/VISU_I/VISU_DeformedShape_i.hh index 5cbaee01..0e8586e6 100644 --- a/src/VISU_I/VISU_DeformedShape_i.hh +++ b/src/VISU_I/VISU_DeformedShape_i.hh @@ -67,6 +67,8 @@ namespace VISU{ protected: virtual void DoHook(); + + virtual const char* GetIconName(); VISU_DeformedShapePL *myDeformedShapePL; SALOMEDS::Color myColor; diff --git a/src/VISU_I/VISU_GaussPoints_i.hh b/src/VISU_I/VISU_GaussPoints_i.hh index c80ef747..5b613f6f 100644 --- a/src/VISU_I/VISU_GaussPoints_i.hh +++ b/src/VISU_I/VISU_GaussPoints_i.hh @@ -255,6 +255,10 @@ namespace VISU void DoHook(); + virtual + const char* + GetIconName() {return "ICON_TREE_GAUSS_POINTS";} + virtual VISU_PipeLine* GetPipeLine(); diff --git a/src/VISU_I/VISU_IsoSurfaces_i.cc b/src/VISU_I/VISU_IsoSurfaces_i.cc index 9b7cf0bf..03559ba3 100644 --- a/src/VISU_I/VISU_IsoSurfaces_i.cc +++ b/src/VISU_I/VISU_IsoSurfaces_i.cc @@ -140,6 +140,15 @@ void VISU::IsoSurfaces_i::DoHook(){ TSuperClass::DoHook(); } +const char* +VISU::IsoSurfaces_i +::GetIconName() +{ + if (!GetNumberOfGeom()) + return "ICON_TREE_ISO_SURFACES"; + else + return "ICON_TREE_ISO_SURFACES_GROUPS"; +} VISU_Actor* VISU::IsoSurfaces_i diff --git a/src/VISU_I/VISU_IsoSurfaces_i.hh b/src/VISU_I/VISU_IsoSurfaces_i.hh index a71601d6..96b87ddd 100644 --- a/src/VISU_I/VISU_IsoSurfaces_i.hh +++ b/src/VISU_I/VISU_IsoSurfaces_i.hh @@ -64,6 +64,8 @@ namespace VISU{ protected: virtual void DoHook(); + virtual const char* GetIconName(); + VISU_IsoSurfacesPL* myIsoSurfacesPL; public: diff --git a/src/VISU_I/VISU_Mesh_i.cc b/src/VISU_I/VISU_Mesh_i.cc index ababd507..c10839bf 100644 --- a/src/VISU_I/VISU_Mesh_i.cc +++ b/src/VISU_I/VISU_Mesh_i.cc @@ -96,6 +96,10 @@ void VISU::Mesh_i::RemoveFromStudy() } }; + // Unset icon + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + aStudyBuilder->RemoveAttribute(GetSObject(), "AttributePixMap"); + ProcessVoidEvent(new TRemoveFromStudy(this)); } @@ -294,6 +298,15 @@ VISU::Storable* VISU::Mesh_i::Build (int theRestoring) CORBA::String_var aString = GetID(); anIOR->SetValue(aString); } + + // Set icon + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + anAttr = aStudyBuilder->FindOrCreateAttribute( mySObject, "AttributePixMap" ); + aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); + aPixmap->SetPixMap("ICON_TREE_MESH"); + }catch(std::exception& exc){ INFOS("Follow exception was occured :\n"< #include #include @@ -191,6 +196,8 @@ void VISU::PrsMerger_i::RemoveAllGeom() { clearMeshList(); myPrsMergerPL->RemoveAllGeom(); + + UpdateIcon(); } @@ -256,6 +263,8 @@ SetMeshOnGroup(const char* theMeshName, } else aTmpMesh->Delete(); + + UpdateIcon(); } CORBA::Long @@ -284,6 +293,8 @@ AddMeshOnGroup(const char* theMeshName, if (MYDEBUG) MESSAGE("AddMeshOnGroup nbGeoms after ="<GetNbGeometry()); + UpdateIcon(); + return aRetVal; } @@ -405,6 +416,52 @@ VISU::PrsMerger_i TSuperClass::DoHook(); } +const char* +VISU::PrsMerger_i +::GetIconName() +{ + if (!GetNumberOfGeom()) + return "ICON_TREE_SCALAR_MAP"; + else + return "ICON_TREE_SCALAR_MAP_GROUPS"; +} + +void VISU::PrsMerger_i +::UpdateIcon() +{ + if (mySObject->_is_nil()) + return; + + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + + // Check if the icon needs to be updated, update if necessary + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + anAttr = aStudyBuilder->FindOrCreateAttribute( mySObject, "AttributePixMap" ); + aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); + + if ( aPixmap->GetPixMap() != (std::string)GetIconName() ) + aPixmap->SetPixMap(GetIconName()); + + // Update Object Browser + SUIT_Session* aSession = SUIT_Session::session(); + QPtrList anApplications = aSession->applications(); + QPtrListIterator anIter (anApplications); + while (SUIT_Application* aSApp = anIter.current()) { + SalomeApp_Application* anApp = dynamic_cast(aSApp); + if (!anApp) return; + SalomeApp_Study* aStudy = dynamic_cast(anApp->activeStudy()); + if (!aStudy) return; + if (_PTR(Study) aCStudy = aStudy->studyDS()) { + if (myStudy->StudyId() == aCStudy->StudyId()) { + anApp->updateObjectBrowser(); + break; + } + } + } +} + CORBA::Long VISU::PrsMerger_i ::GetNumberOfGeom() @@ -481,3 +538,4 @@ VISU::PrsMerger_i if (MYDEBUG) MESSAGE("return="<NewBuilder(); + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + anAttr = aStudyBuilder->FindOrCreateAttribute( mySObject, "AttributePixMap" ); + aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); + aPixmap ->SetPixMap("ICON_TREE_RESULT"); + if(theIsBuildAll) return BuildAll(); return true; } - + return false; } diff --git a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc index 12a430e1..244879cc 100644 --- a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc +++ b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc @@ -226,6 +226,16 @@ void VISU::ScalarMapOnDeformedShape_i::DoHook() TSuperClass::DoHook(); } +const char* +VISU::ScalarMapOnDeformedShape_i +::GetIconName() +{ + if (!GetNumberOfGeom()) + return "ICON_TREE_SCALAR_MAP_ON_DEFORMED_SHAPE"; + else + return "ICON_TREE_SCALAR_MAP_ON_DEFORMED_SHAPE_GROUPS"; +} + VISU_Actor* VISU::ScalarMapOnDeformedShape_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) { if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::CreateActor:"<<__LINE__<NewObject( mySObj ); //Builder->Addreference( refSO, SO ); - } + } + + // Set icon + SALOMEDS::AttributePixMap_var aPixmap; + + anAttr = Builder->FindOrCreateAttribute( mySObj, "AttributePixMap" ); + aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); + aPixmap->SetPixMap("ICON_TREE_TABLE"); + return this; } return NULL; @@ -385,6 +393,16 @@ VISU::Storable* VISU::Curve_i::Build(int theRestoring ) true ); // create SObject referenced to real table object mySObj = SALOMEDS::SObject::_duplicate(myStudy->FindObjectID(anEntry.c_str())); + + // Set icon + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + anAttr = aStudyBuilder->FindOrCreateAttribute( mySObj, "AttributePixMap" ); + aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); + aPixmap ->SetPixMap("ICON_TREE_CURVE"); } return this; } @@ -897,6 +915,16 @@ VISU::Storable* VISU::Container_i::Build( int theRestoring ) aComment.latin1(), true ); mySObj = SALOMEDS::SObject::_duplicate(myStudy->FindObjectID(anEntry.c_str())); + + // Set icon + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + anAttr = aStudyBuilder->FindOrCreateAttribute( mySObj, "AttributePixMap" ); + aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); + aPixmap ->SetPixMap("ICON_TREE_CONTAINER"); } return this; } diff --git a/src/VISU_I/VISU_Vectors_i.cc b/src/VISU_I/VISU_Vectors_i.cc index 99fc94dd..e4408f5e 100644 --- a/src/VISU_I/VISU_Vectors_i.cc +++ b/src/VISU_I/VISU_Vectors_i.cc @@ -180,6 +180,17 @@ void VISU::Vectors_i::DoHook(){ } +const char* +VISU::Vectors_i +::GetIconName() +{ + if (!GetNumberOfGeom()) + return "ICON_TREE_VECTORS"; + else + return "ICON_TREE_VECTORS_GROUPS"; +} + + VISU_PipeLine* VISU::Vectors_i::GetPipeLine(){ VISU_PipeLine* aPipeLine = VISU_VectorsPL::New(); aPipeLine->SetIDMapper(myPipeLine->GetIDMapper()); diff --git a/src/VISU_I/VISU_Vectors_i.hh b/src/VISU_I/VISU_Vectors_i.hh index 9177228d..873820df 100644 --- a/src/VISU_I/VISU_Vectors_i.hh +++ b/src/VISU_I/VISU_Vectors_i.hh @@ -67,6 +67,9 @@ namespace VISU{ protected: virtual void DoHook(); + + virtual const char* GetIconName(); + virtual VISU_PipeLine* GetPipeLine(); VISU_VectorsPL *myVectorsPL; -- 2.39.2