]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Fix for the "0021580: GEOM EDF: SetColor does not work" issue.
authorana <ana@opencascade.com>
Thu, 17 May 2012 13:43:49 +0000 (13:43 +0000)
committerana <ana@opencascade.com>
Thu, 17 May 2012 13:43:49 +0000 (13:43 +0000)
src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx

index e7a6bcc6b6548d0d562b40be32dfe374ab6b9cb0..9ee86323d81411efaae9b4ec875a9573c0d20ade 100644 (file)
@@ -262,17 +262,32 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
     if ( selected.Extent() > 0 ) {
       Handle(SALOME_InteractiveObject) io = selected.First();
       if ( !io.IsNull() ) {
-       SUIT_ViewWindow* window = app->desktop()->activeWindow();
-       if ( window ) {
-         int mgrId = window->getViewManager()->getGlobalId();
-         PropMap propMap = study->getObjectPropMap( mgrId, io->getEntry() );
-         QString matProp = propMap.value(MATERIAL_PROP).toString();        
-         if ( !matProp.isEmpty() )
-           myCurrentModel.fromProperties( matProp );
-         QColor c = propMap.value(COLOR_PROP).value<QColor>();
-         if ( c.isValid() )
-           myColor->setColor( c );
-       }
+        SUIT_ViewWindow* window = app->desktop()->activeWindow();
+        if ( window ) {
+          int mgrId = window->getViewManager()->getGlobalId();
+          PropMap propMap = study->getObjectPropMap( mgrId, io->getEntry() );
+          QString matProp = propMap.value(MATERIAL_PROP).toString();       
+          if ( !matProp.isEmpty() )
+            myCurrentModel.fromProperties( matProp );
+          QColor c;
+          if(propMap.contains(COLOR_PROP)) 
+            c = propMap.value(COLOR_PROP).value<QColor>();
+          else {
+            _PTR(SObject) SO ( study->studyDS()->FindObjectID( io->getEntry() ) );
+            if ( SO ) {
+              // get CORBA reference to data object
+              CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
+              if ( !CORBA::is_nil( object ) ) {
+                // downcast to GEOM object
+                GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( object );
+                SALOMEDS::Color aSColor = aGeomObject->GetColor();
+                c.setRgb( 255.*aSColor.R, 255.*aSColor.G, 255.*aSColor.B );
+              }
+            }
+          }
+          if ( c.isValid() )
+            myColor->setColor( c );
+        }
       }
     }
   }