From: Konstantin Leontev Date: Wed, 30 Oct 2024 11:30:31 +0000 (+0000) Subject: [bos #43299][FORUM] geom.GetColor() does not give the good result. Fixed set color... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Ftlpr%2F29%2Fhead;p=modules%2Fgeom.git [bos #43299][FORUM] geom.GetColor() does not give the good result. Fixed set color for geom object. --- diff --git a/src/GEOMBase/GEOMBase.cxx b/src/GEOMBase/GEOMBase.cxx index 7ab1fa152..d3371cf1f 100644 --- a/src/GEOMBase/GEOMBase.cxx +++ b/src/GEOMBase/GEOMBase.cxx @@ -488,6 +488,32 @@ void GEOMBase::ConvertListOfIOInListOfGO( const SALOME_ListIO& IObjects, } } +//======================================================================= +// function : GetObjectFromEntry() +// purpose : Get the GEOM_Object from the study entry. +//======================================================================= +GEOM::GEOM_Object_ptr GEOMBase::GetObjectFromEntry(const char* entry) +{ + GEOM::GEOM_Object_var object; + + if (entry) + { + SalomeApp_Study* study = dynamic_cast(SUIT_Session::session()->activeApplication()->activeStudy()); + if (study) + { + _PTR(Study) studyDS = study->studyDS(); + _PTR(SObject) obj = studyDS->FindObjectID(entry); + if (GeometryGUI::IsInGeomComponent(obj)) + { + CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(obj); + object = GEOM::GEOM_Object::_narrow(corbaObj); + } + } + } + + return object._retn(); +} + //================================================================================= // function : CreateArrowForLinearEdge() // purpose : Create a cone topology to be used to display an arrow in the middle diff --git a/src/GEOMBase/GEOMBase.h b/src/GEOMBase/GEOMBase.h index 8d35354df..c23fe71b2 100644 --- a/src/GEOMBase/GEOMBase.h +++ b/src/GEOMBase/GEOMBase.h @@ -95,6 +95,8 @@ public : static QString GetIORFromObject( GEOM::GEOM_Object_ptr object ); + static GEOM::GEOM_Object_ptr GetObjectFromEntry(const char* entry); + /* Geometry */ static bool VertexToPoint( const TopoDS_Shape& shape, gp_Pnt& point ); diff --git a/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.cxx b/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.cxx index 65571632c..099c641b2 100644 --- a/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.cxx +++ b/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.cxx @@ -31,6 +31,7 @@ #include "GEOM_Swig_LocalSelector.h" #include "GEOMGUI_OCCSelector.h" #include "OCCViewer_ViewManager.h" +#include "GEOMBase.h" #include #include @@ -430,6 +431,19 @@ void GEOM_Swig::setNameMode( const char* theEntry, bool theOn, bool theUpdateVie */ void GEOM_Swig::setColor( const char* theEntry, int theRed, int theGreen, int theBlue, bool theUpdateViewer ) { + // Update geom object color + GEOM::GEOM_Object_var GeomObject = GEOMBase::GetObjectFromEntry(theEntry); + if (!CORBA::is_nil(GeomObject)) + { + SALOMEDS::Color aSColor; + aSColor.R = theRed / 255.0; + aSColor.G = theGreen / 255.0; + aSColor.B = theBlue / 255.0; + + GeomObject->SetColor(aSColor); + } + + // Update a color property stored in LightApp_Study view manager map ProcessVoidEvent( new TSetPropertyEvent( theEntry, GEOM::propertyName( GEOM::Color ), QColor( theRed, theGreen, theBlue ), theUpdateViewer ) ); }