#include "SALOME_Exception.idl"
#include "SALOME_Component.idl"
#include "SALOMEDS.idl"
+#include "SALOMEDS_Attributes.idl"
#include "SALOME_GenericObj.idl"
*/
string GetName();
+ /*!
+ * Set color of the object.
+ * \param theColor is a color of the object.
+ */
+ void SetColor(in SALOMEDS::Color theColor);
+
+ /*!
+ * Get color of the object.
+ */
+ SALOMEDS::Color GetColor();
+
+ /*!
+ * Toggle auto color mode on the object.
+ * \param theAtoColor is a flag which toggles auto color mode.
+ */
+ void SetAutoColor(in boolean theAutoColor);
+
+ /*!
+ * Get flag of object's auto color mode.
+ */
+ boolean GetAutoColor();
+
/*!
* Set a Study entry where this object was published.
*/
if(aDoc.IsNull()) return TCollection_AsciiString("def RebuildData(theStudy): pass\n");
aScript = "import geompy\n";
- aScript += "import math\n\n";
+ aScript += "import math\n";
+ aScript += "import SALOMEDS\n\n";
aScript += "def RebuildData(theStudy):";
aScript += "\n\tgeompy.init_geom(theStudy)";
//Add final part of the script
if(aLen && aSeq->Value(aLen) < aScriptLength) anUpdatedScript += aScript.SubString(aSeq->Value(aLen)+1, aScriptLength); // mkr : IPAL11865
+ // ouv : NPAL12872
+ for (anEntryToNameIt.Initialize( theObjectNames );
+ anEntryToNameIt.More();
+ anEntryToNameIt.Next())
+ {
+ const TCollection_AsciiString& aEntry = anEntryToNameIt.Key();
+ const TCollection_AsciiString& aName = anEntryToNameIt.Value();
+
+ TDF_Label L;
+ TDF_Tool::Label( aDoc->GetData(), aEntry, L );
+ if ( L.IsNull() )
+ continue;
+
+ Handle(GEOM_Object) obj = GEOM_Object::GetObject( L );
+ if ( obj.IsNull() )
+ continue;
+
+ bool anAutoColor = obj->GetAutoColor();
+ if ( anAutoColor )
+ {
+ TCollection_AsciiString aCommand( "\n\t" );
+ aCommand += aName + ".SetAutoColor(1)";
+ anUpdatedScript += aCommand.ToCString();
+ }
+
+ SALOMEDS::Color aColor = obj->GetColor();
+ if ( aColor.R > 0 || aColor.G > 0 || aColor.B > 0 )
+ {
+ TCollection_AsciiString aCommand( "\n\t" );
+ aCommand += aName + ".SetColor(SALOMEDS.Color(" + aColor.R + "," + aColor.G + "," + aColor.B + "))";
+ anUpdatedScript += aCommand.ToCString();
+ }
+ }
+
// Make script to publish in study
if ( isPublished )
{
#include <TDataStd_UAttribute.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_Comment.hxx>
+#include <TDataStd_RealArray.hxx>
+#include <TColStd_HArray1OfReal.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#define TYPE_LABEL 2
#define FREE_LABEL 3
#define TIC_LABEL 4
+#define COLOR_LABEL 5
+#define AUTO_COLOR_LABEL 6
//=======================================================================
//function : GetObjectID
return strdup(aName.ToCString());
}
+//=============================================================================
+/*!
+ * SetColor
+ */
+//=============================================================================
+void GEOM_Object::SetColor(const SALOMEDS::Color& theColor)
+{
+ Handle(TDataStd_RealArray) anArray = new TDataStd_RealArray();
+ anArray->Init( 1, 3 );
+ anArray->SetValue( 1, theColor.R );
+ anArray->SetValue( 2, theColor.G );
+ anArray->SetValue( 3, theColor.B );
+
+ Handle(TDataStd_RealArray) anAttr =
+ TDataStd_RealArray::Set(_label.FindChild(COLOR_LABEL), anArray->Lower(), anArray->Upper());
+ anAttr->ChangeArray(anArray->Array());
+}
+
+//=============================================================================
+/*!
+ * GetColor
+ */
+//=============================================================================
+SALOMEDS::Color GEOM_Object::GetColor()
+{
+ Handle(TDataStd_RealArray) anArray;
+ bool isFound = _label.FindChild(COLOR_LABEL).FindAttribute(TDataStd_RealArray::GetID(), anArray);
+
+ SALOMEDS::Color aColor;
+ aColor.R = isFound ? anArray->Value( 1 ) : 0.f;
+ aColor.G = isFound ? anArray->Value( 2 ) : 0.f;
+ aColor.B = isFound ? anArray->Value( 3 ) : 0.f;
+
+ return aColor;
+}
+
+//=============================================================================
+/*!
+ * SetAutoColor
+ */
+//=============================================================================
+void GEOM_Object::SetAutoColor(CORBA::Boolean theAutoColor)
+{
+ TDataStd_Integer::Set(_label.FindChild(AUTO_COLOR_LABEL), (int)theAutoColor);
+}
+
+//=============================================================================
+/*!
+ * GetAutoColor
+ */
+//=============================================================================
+CORBA::Boolean GEOM_Object::GetAutoColor()
+{
+ Handle(TDataStd_Integer) anAutoColor;
+ if(!_label.FindChild(AUTO_COLOR_LABEL).FindAttribute(TDataStd_Integer::GetID(), anAutoColor)) return false;
+
+ return anAutoColor->Get();
+}
+
//=============================================================================
/*!
* SetAuxData
#include <TCollection_AsciiString.hxx>
#endif
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
class Handle_TColStd_HSequenceOfTransient;
class Standard_Transient;
class Handle_Standard_Type;
//Returns a name of this GEOM_Object
Standard_EXPORT char* GetName();
+ //Sets a color of this GEOM_Object
+ Standard_EXPORT void SetColor(const SALOMEDS::Color& theColor);
+
+ //Returns a color of this GEOM_Object
+ Standard_EXPORT SALOMEDS::Color GetColor();
+
+ //Toggles an auto color mode on this GEOM_Object
+ Standard_EXPORT void SetAutoColor(CORBA::Boolean theAutoColor);
+
+ //Returns a flag of auto color mode of this GEOM_Object
+ Standard_EXPORT CORBA::Boolean GetAutoColor();
+
//Sets an auxiliary data
Standard_EXPORT void SetAuxData(const char* theData);
return QtxValue( typeName( ind ) );
else if ( p == "displaymode" )
return QtxValue( displayMode( ind ) );
+ else if ( p == "isAutoColor" )
+ return QtxValue( isAutoColor( ind ) );
else
return LightApp_Selection::param( ind, p );
}
return false;
}
+bool GEOMGUI_Selection::isAutoColor( const int index ) const
+{
+ GEOM::GEOM_Object_var obj = getObject( index );
+ if ( !CORBA::is_nil( obj ) )
+ return obj->GetAutoColor();
+ return false;
+}
+
QString GEOMGUI_Selection::displayMode( const int index ) const
{
SALOME_View* view = GEOM_Displayer::GetActiveView();
private:
bool isVisible( const int ) const;
+ bool isAutoColor( const int ) const;
QString typeName( const int ) const;
QString displayMode( const int ) const;
QString selectionMode() const;
AISShape->setIO( anObj );
AISShape->SetOwner( anObj );
}
+
+ // Get color from GEOM_Object
+ SUIT_Session* session = SUIT_Session::session();
+ SUIT_Application* app = session->activeApplication();
+ if ( app )
+ {
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if ( study )
+ {
+ Handle( SALOME_InteractiveObject ) anIO = AISShape->getIO();
+ if ( !anIO.IsNull() )
+ {
+ _PTR(SObject) SO ( study->studyDS()->FindObjectID( anIO->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 );
+ if ( !aGeomObject->_is_nil() )
+ {
+ SALOMEDS::Color aSColor = aGeomObject->GetColor();
+ bool hasColor = aSColor.R > 0 || aSColor.G > 0 || aSColor.B > 0;
+ if( !hasColor && aGeomObject->GetType() == GEOM_GROUP ) // auto color for group
+ {
+ GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen();
+ GEOM::GEOM_IGroupOperations_var anOperations = aGeomGen->GetIGroupOperations( study->id() );
+ GEOM::GEOM_Object_var aMainObject = anOperations->GetMainShape( aGeomObject );
+ if ( !aMainObject->_is_nil() && aMainObject->GetAutoColor() )
+ {
+ QValueList<SALOMEDS::Color> aReservedColors;
+
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( app );
+ CORBA::String_var IOR = app->orb()->object_to_string( aMainObject );
+ if ( strcmp(IOR.in(), "") != 0 )
+ {
+ _PTR(Study) aStudy = study->studyDS();
+ _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( string(IOR) ) );
+ _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) );
+ for( ; it->More(); it->Next() )
+ {
+ _PTR(SObject) aChildSObject( it->Value() );
+ GEOM::GEOM_Object_var aChildObject =
+ GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
+ if( CORBA::is_nil( aChildObject ) )
+ continue;
+
+ if( aChildObject->GetType() != GEOM_GROUP )
+ continue;
+
+ SALOMEDS::Color aReservedColor = aChildObject->GetColor();
+ aReservedColors.append( aReservedColor );
+ }
+ }
+
+ aSColor = getUniqueColor( aReservedColors );
+ hasColor = true;
+ }
+ }
+
+ if( hasColor )
+ {
+ Quantity_Color aQuanColor( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
+ AISShape->SetColor( aQuanColor );
+ AISShape->SetShadingColor( aQuanColor );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
// AISShape->SetName(???); ??? necessary to set name ???
occPrs->AddObject( AISShape );
myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 );
return aPrevMode;
}
+
+SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QValueList<SALOMEDS::Color>& theReservedColors )
+{
+ int aHue = -1;
+ int aTolerance = 64;
+ int anIterations = 0;
+ int aPeriod = 5;
+
+ while( 1 )
+ {
+ anIterations++;
+ if( anIterations % aPeriod == 0 )
+ {
+ aTolerance /= 2;
+ if( aTolerance < 1 )
+ break;
+ }
+ //cout << "Iteration N" << anIterations << " (tolerance=" << aTolerance << ")"<< endl;
+
+ aHue = (int)( 360.0 * rand() / RAND_MAX );
+ //cout << "Hue = " << aHue << endl;
+
+ //cout << "Auto colors : ";
+ bool ok = true;
+ QValueList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
+ QValueList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
+ for( ; it != itEnd; ++it )
+ {
+ SALOMEDS::Color anAutoColor = *it;
+ QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
+
+ int h, s, v;
+ aQColor.getHsv( &h, &s, &v );
+ //cout << h << " ";
+ if( abs( h - aHue ) < aTolerance )
+ {
+ ok = false;
+ //cout << "break (diff = " << abs( h - aHue ) << ")";
+ break;
+ }
+ }
+ //cout << endl;
+
+ if( ok )
+ break;
+ }
+
+ //cout << "Hue of the returned color = " << aHue << endl;
+ QColor aColor;
+ aColor.setHsv( aHue, 255, 255 );
+
+ SALOMEDS::Color aSColor;
+ aSColor.R = (double)aColor.red() / 255.0;
+ aSColor.G = (double)aColor.green() / 255.0;
+ aSColor.B = (double)aColor.blue() / 255.0;
+
+ return aSColor;
+}
#include <LightApp_Displayer.h>
#include <Aspect_TypeOfMarker.hxx>
+#include <qvaluelist.h>
+
#include <list>
#include <SALOMEconfig.h>
SalomeApp_Study* getStudy() const;
+ static SALOMEDS::Color getUniqueColor( const QValueList<SALOMEDS::Color>& );
+
protected:
/* internal methods */
/* Builds presentation accordint to the current viewer type */
msgid "STB_POP_SHADING"
msgstr "Shading"
+msgid "TOP_POP_AUTO_COLOR"
+msgstr "Auto color"
+
+msgid "MEN_POP_AUTO_COLOR"
+msgstr "Auto color"
+
+msgid "STB_POP_AUTO_COLOR"
+msgstr "Auto color"
+
+msgid "TOP_POP_DISABLE_AUTO_COLOR"
+msgstr "Disable auto color"
+
+msgid "MEN_POP_DISABLE_AUTO_COLOR"
+msgstr "Disable auto color"
+
+msgid "STB_POP_DISABLE_AUTO_COLOR"
+msgstr "Disable auto color"
+
msgid "TOP_POP_COLOR"
msgstr "Color"
id == 8032 || // POPUP VIEWER - COLOR
id == 8033 || // POPUP VIEWER - TRANSPARENCY
id == 8034 || // POPUP VIEWER - ISOS
+ id == 8035 || // POPUP VIEWER - AUTO COLOR
+ id == 8036 || // POPUP VIEWER - DISABLE AUTO COLOR
id == 804 || // POPUP VIEWER - ADD IN STUDY
id == 901 || // OBJECT BROWSER - RENAME
id == 9024 ) { // OBJECT BROWSER - OPEN
createGeomAction( 8032, "POP_COLOR" );
createGeomAction( 8033, "POP_TRANSPARENCY" );
createGeomAction( 8034, "POP_ISOS" );
+ createGeomAction( 8035, "POP_AUTO_COLOR" );
+ createGeomAction( 8036, "POP_DISABLE_AUTO_COLOR" );
createGeomAction( 8001, "POP_CREATE_GROUP" );
// make wireframe-shading items to be exclusive (only one at a time is selected)
QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
+ QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
+ QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
+
+ QString autoColorPrefix =
+ "(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
+
QtxPopupMgr* mgr = popupMgr();
mgr->insert( action( 901 ), -1, -1 ); // rename
mgr->setRule( action( 901 ), "$type in {'Shape' 'Group'} and selcount=1", true );
mgr->setRule( action( 80312 ), clientOCCorVTK + " and displaymode='Shading'", false );
mgr->insert( separator(), -1, -1 ); // -----------
mgr->insert( action( 8032 ), -1, -1 ); // color
- mgr->setRule( action( 8032 ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", true );
+ mgr->setRule( action( 8032 ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", true );
mgr->insert( action( 8033 ), -1, -1 ); // transparency
mgr->setRule( action( 8033 ), clientOCCorVTK_AndSomeVisible, true );
mgr->insert( action( 8034 ), -1, -1 ); // isos
mgr->setRule( action( 8034 ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", true );
mgr->insert( separator(), -1, -1 ); // -----------
+ mgr->insert( action( 8035 ), -1, -1 ); // auto color
+ mgr->setRule( action( 8035 ), autoColorPrefix + " and isAutoColor=false", true );
+ mgr->insert( action( 8036 ), -1, -1 ); // disable auto color
+ mgr->setRule( action( 8036 ), autoColorPrefix + " and isAutoColor=true", true );
+ mgr->insert( separator(), -1, -1 ); // -----------
QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
OnNbIsos();
break;
}
+ case 8035: // AUTO COLOR - POPUP VIEWER
+ {
+ OnAutoColor();
+ break;
+ }
+ case 8036: // DISABLE AUTO COLOR - POPUP VIEWER
+ {
+ OnDisableAutoColor();
+ break;
+ }
case 9024 : // OPEN - OBJBROSER POPUP
{
OnOpen();
void OnCheckGeometry();
// Popup commands
+ void OnAutoColor();
+ void OnDisableAutoColor();
void OnColor();
void OnTransparency();
void OnNbIsos();
bool CheckSubObjectInUse(_PTR(SObject) checkobj,
_PTR(SObject) remobj,
_PTR(Study) aStudy);
-
};
#endif
#include "SALOME_ListIO.hxx"
#include "SALOME_ListIteratorOfListIO.hxx"
+#include <SOCC_Prs.h>
+
+#include <SVTK_Prs.h>
#include <SVTK_ViewModel.h>
#include <SVTK_ViewWindow.h>
#include <SVTK_View.h>
#include <LightApp_SelectionMgr.h>
#include <LightApp_NameDlg.h>
+#include <GEOMImpl_Types.hxx>
+
#include "SALOMEDSClient.hxx"
#include "utilities.h"
#include <qcolordialog.h>
#include <qspinbox.h>
#include <qapplication.h>
+#include <qptrlist.h>
using namespace std;
pyConsole->exec("from GEOM_usinggeom import *");
}
+void GEOMToolsGUI::OnAutoColor()
+{
+ QPtrList<SALOME_Prs> aListOfGroups;
+
+ SALOME_ListIO selected;
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ if( !app )
+ return;
+
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if( !aSelMgr || !appStudy )
+ return;
+
+ aSelMgr->selectedObjects( selected );
+ if( selected.IsEmpty() )
+ return;
+
+ Handle(SALOME_InteractiveObject) anIObject = selected.First();
+
+ _PTR(Study) aStudy = appStudy->studyDS();
+ _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
+ GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
+ if( CORBA::is_nil( aMainObject ) )
+ return;
+
+ aMainObject->SetAutoColor( true );
+
+ QValueList<SALOMEDS::Color> aReservedColors;
+
+ GEOM_Displayer aDisp (appStudy);
+
+ SALOME_View* vf = aDisp.GetActiveView();
+
+ SUIT_ViewWindow* window = app->desktop()->activeWindow();
+ bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
+ bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
+
+ for( _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); it->More(); it->Next() )
+ {
+ _PTR(SObject) aChildSObject( it->Value() );
+ GEOM::GEOM_Object_var aChildObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
+ if( CORBA::is_nil( aChildObject ) )
+ continue;
+
+ if( aChildObject->GetType() != GEOM_GROUP )
+ continue;
+
+ cout << "Group : " << aChildObject->GetName() << endl;
+
+ SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors );
+ cout << "Color : " << aColor.R << " " << aColor.G << " " << aColor.B << endl;
+
+ aChildObject->SetColor( aColor );
+ aReservedColors.append( aColor );
+
+ QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) );
+
+ SALOME_Prs* aPrs = vf->CreatePrs( aChildSObject->GetID().c_str() );
+
+ if ( isVTK )
+ {
+ SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
+ if ( !vtkVW )
+ return;
+ SVTK_View* aView = vtkVW->getView();
+ SUIT_OverrideCursor();
+ for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
+ aView->SetColor( It.Value(), c );
+ }
+ else if ( isOCC )
+ {
+ OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
+ Handle(AIS_InteractiveContext) ic = vm->getAISContext();
+
+ SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
+ if( !anOCCPrs )
+ continue;
+
+ AIS_ListOfInteractive aList;
+ anOCCPrs->GetObjects( aList );
+ if( !aList.Extent() )
+ continue;
+
+ Handle(AIS_InteractiveObject) io = aList.First();
+ if( io.IsNull() )
+ continue;
+
+ Quantity_Color aQuanColor( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
+
+ // Set color for a point
+ Handle(AIS_Drawer) aCurDrawer = io->Attributes();
+ Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
+ Quantity_Color aCurColor;
+ Standard_Real aCurScale;
+ Aspect_TypeOfMarker aCurTypeOfMarker;
+ aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
+ aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aQuanColor, aCurScale) );
+ ic->SetLocalAttributes( io, aCurDrawer );
+
+ io->SetColor( aQuanColor );
+ if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
+ Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aQuanColor );
+
+ io->Redisplay( Standard_True );
+ }
+ }
+
+ app->updateActions(); //SRN: To update a Save button in the toolbar
+}
+
+void GEOMToolsGUI::OnDisableAutoColor()
+{
+ SALOME_ListIO selected;
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ if( !app )
+ return;
+
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if( !aSelMgr || !appStudy )
+ return;
+
+ aSelMgr->selectedObjects( selected );
+ if( selected.IsEmpty() )
+ return;
+
+ Handle(SALOME_InteractiveObject) anIObject = selected.First();
+
+ _PTR(Study) aStudy = appStudy->studyDS();
+ _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
+ GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
+ if( CORBA::is_nil( aMainObject ) )
+ return;
+
+ aMainObject->SetAutoColor( false );
+
+}
+
void GEOMToolsGUI::OnColor()
{
SALOME_ListIO selected;
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
- if ( app ) {
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if ( app && appStudy ) {
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
if ( aSelMgr ) {
aSelMgr->selectedObjects( selected );
Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aColor );
io->Redisplay( Standard_True );
+
+ // store color to GEOM_Object
+ _PTR(Study) aStudy = appStudy->studyDS();
+ _PTR(SObject) aSObject( aStudy->FindObjectID( It.Value()->getEntry() ) );
+ GEOM::GEOM_Object_var anObject =
+ GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
+
+ SALOMEDS::Color aSColor;
+ aSColor.R = (double)c.red() / 255.0;
+ aSColor.G = (double)c.green() / 255.0;
+ aSColor.B = (double)c.blue() / 255.0;
+ anObject->SetColor( aSColor );
+ anObject->SetAutoColor( false );
}
}
} // if c.isValid()
return strdup("");
}
+//=============================================================================
+/*!
+ * SetColor
+ */
+//=============================================================================
+void GEOM_Object_i::SetColor(const SALOMEDS::Color& theColor)
+{
+ _impl->SetColor(theColor);
+}
+
+
+//=============================================================================
+/*!
+ * GetColor
+ */
+//=============================================================================
+SALOMEDS::Color GEOM_Object_i::GetColor()
+{
+ return _impl->GetColor();
+}
+
+
+//=============================================================================
+/*!
+ * SetAutoColor
+ */
+//=============================================================================
+void GEOM_Object_i::SetAutoColor(CORBA::Boolean theAutoColor)
+{
+ _impl->SetAutoColor(theAutoColor);
+}
+
+
+//=============================================================================
+/*!
+ * GetAutoColor
+ */
+//=============================================================================
+CORBA::Boolean GEOM_Object_i::GetAutoColor()
+{
+ return _impl->GetAutoColor();
+}
+
+
//=============================================================================
/*!
* SetStudyEntry
virtual char* GetName();
+ virtual void SetColor(const SALOMEDS::Color& theColor);
+
+ virtual SALOMEDS::Color GetColor();
+
+ virtual void SetAutoColor(CORBA::Boolean theAutoColor);
+
+ virtual CORBA::Boolean GetAutoColor();
+
virtual void SetStudyEntry(const char* theEntry);
virtual char* GetStudyEntry();