From: jfa Date: Mon, 3 Apr 2006 15:12:08 +0000 (+0000) Subject: Protect with SALOME_Event. X-Git-Tag: T3_2_0b1_pre1~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e5d5800343e0ac16eb95eb7bbb73d003cdd15711;p=modules%2Fgeom.git Protect with SALOME_Event. --- diff --git a/src/GEOMGUI/GeometryGUI_Swig.cxx b/src/GEOMGUI/GeometryGUI_Swig.cxx index 9cfc90129..22e3502b6 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.cxx +++ b/src/GEOMGUI/GeometryGUI_Swig.cxx @@ -59,21 +59,10 @@ #include "SALOMEDSClient.hxx" // OCCT Includes -//#include -//#include -//#include -//#include -//#include -//#include -//#include #include #include -//#include -//#include -//#include #include #include -//#include // IDL Headers #include @@ -286,7 +275,7 @@ const char* GEOM_Swig::getShapeTypeString(const char* IOR) const char* GEOM_Swig::getShapeTypeIcon(const char* IOR) { - GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen(); + GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen(); if ( CORBA::is_nil( Geom ) ) return "None"; @@ -322,75 +311,74 @@ const char* GEOM_Swig::getShapeTypeIcon(const char* IOR) void GEOM_Swig::setDisplayMode(const char* theEntry, int theMode) { - SUIT_Application* app = SUIT_Session::session()->activeApplication(); - if ( !app ) return; - - Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry, "GEOM", ""); - - class TEvent: public SALOME_Event{ - SUIT_Application* myApp; - Handle(SALOME_InteractiveObject) myIO; - int myParam; + class TEvent: public SALOME_Event { + std::string myEntry; + int myMode; public: - TEvent(SUIT_Application* theApp, const Handle(SALOME_InteractiveObject)& theIO, int theParam): - myApp(theApp), myIO(theIO), myParam(theParam) + TEvent(const char* theEntryArg, int theModeArg): + myEntry(theEntryArg), myMode(theModeArg) {} - virtual void Execute(){ - if(SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(myApp)){ + virtual void Execute() { + SUIT_Application* anApp = SUIT_Session::session()->activeApplication(); + if (!anApp) return; + + Handle(SALOME_InteractiveObject) anIO = + new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", ""); + + if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) { SVTK_View* aView = aViewWindow->getView(); - aView->SetDisplayMode(myIO,myParam); + aView->SetDisplayMode(anIO, myMode); aView->Repaint(); } - else if(OCCViewer_Viewer* occViewer = GetOCCViewer(myApp)) { - SOCC_Viewer* soccViewer = dynamic_cast( occViewer ); + else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) { + SOCC_Viewer* soccViewer = dynamic_cast(occViewer); if (soccViewer) - soccViewer->switchRepresentation(myIO,myParam); + soccViewer->switchRepresentation(anIO, myMode); } } }; - ProcessVoidEvent(new TEvent(app,anIO,theMode)); + ProcessVoidEvent(new TEvent (theEntry, theMode)); } void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue) { - SUIT_Application* app = SUIT_Session::session()->activeApplication(); - if ( !app ) return; - - Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry, "GEOM", ""); - - QColor aColor(red,green,blue); - - class TEvent: public SALOME_Event{ - SUIT_Application* myApp; - Handle(SALOME_InteractiveObject) myIO; - QColor myParam; + class TEvent: public SALOME_Event { + std::string myEntry; + int myRed; + int myGreen; + int myBlue; public: - TEvent(SUIT_Application* theApp, const Handle(SALOME_InteractiveObject)& theIO, const QColor& theParam): - myApp(theApp), myIO(theIO), myParam(theParam) + TEvent(const char* theEntryArg, int theR, int theG, int theB): + myEntry(theEntryArg), myRed(theR), myGreen(theG), myBlue(theB) {} - virtual void Execute(){ - if(SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(myApp)){ + virtual void Execute() { + SUIT_Application* anApp = SUIT_Session::session()->activeApplication(); + if (!anApp) return; + + Handle(SALOME_InteractiveObject) anIO = + new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", ""); + + if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)){ SVTK_View* aView = aViewWindow->getView(); - aView->SetColor(myIO,myParam); + QColor aColor (myRed, myGreen, myBlue); + aView->SetColor(anIO, aColor); aView->Repaint(); - }else if(OCCViewer_Viewer* occViewer = GetOCCViewer(myApp)){ + } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) { Handle(AIS_InteractiveContext) ic = occViewer->getAISContext(); AIS_ListOfInteractive List; ic->DisplayedObjects(List); - AIS_ListIteratorOfListOfInteractive ite(List); - for ( ; ite.More(); ite.Next() ) { + AIS_ListIteratorOfListOfInteractive ite (List); + for (; ite.More(); ite.Next()) { Handle(SALOME_InteractiveObject) anObj = - Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); - if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( myIO ) ) { - Quantity_Color CSFColor = Quantity_Color ( myParam.red() / 255., - myParam.green() / 255., - myParam.blue() / 255., - Quantity_TOC_RGB ); - ite.Value()->SetColor( CSFColor ); - if ( ite.Value()->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) - Handle(GEOM_AISShape)::DownCast( ite.Value() )->SetShadingColor( CSFColor ); - ite.Value()->Redisplay( Standard_True ); + Handle(SALOME_InteractiveObject)::DownCast(ite.Value()->GetOwner()); + if (!anObj.IsNull() && anObj->hasEntry() && anObj->isSame(anIO)) { + Quantity_Color CSFColor = + Quantity_Color(myRed/255., myGreen/255., myBlue/255., Quantity_TOC_RGB); + ite.Value()->SetColor(CSFColor); + if (ite.Value()->IsKind(STANDARD_TYPE(GEOM_AISShape))) + Handle(GEOM_AISShape)::DownCast(ite.Value())->SetShadingColor(CSFColor); + ite.Value()->Redisplay(Standard_True); occViewer->update(); break; } @@ -398,42 +386,51 @@ void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue) } } }; - ProcessVoidEvent(new TEvent(app,anIO,aColor)); + ProcessVoidEvent(new TEvent(theEntry, red, green, blue)); } void GEOM_Swig::setTransparency(const char* theEntry, float transp) { - SUIT_Application* app = SUIT_Session::session()->activeApplication(); - if ( !app ) return; - - Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry, "GEOM", ""); - - class TEvent: public SALOME_Event{ - SUIT_Application* myApp; - Handle(SALOME_InteractiveObject) myIO; + class TEvent: public SALOME_Event { + std::string myEntry; float myParam; public: - TEvent(SUIT_Application* theApp, const Handle(SALOME_InteractiveObject)& theIO, float theParam): - myApp(theApp), myIO(theIO), myParam(theParam) + TEvent(const char* theEntryArg, float theParam): + myEntry(theEntryArg), myParam(theParam) {} - virtual void Execute(){ - if(SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(myApp)){ + virtual void Execute() { + SUIT_Application* anApp = SUIT_Session::session()->activeApplication(); + if (!anApp) return; + + Handle(SALOME_InteractiveObject) anIO = + new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", ""); + + if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) { SVTK_View* aView = aViewWindow->getView(); - aView->SetTransparency(myIO,myParam); + aView->SetTransparency(anIO, myParam); aView->Repaint(); - }else if(OCCViewer_Viewer* occViewer = GetOCCViewer(myApp)) { - SOCC_Viewer* soccViewer = dynamic_cast( occViewer ); + } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) { + SOCC_Viewer* soccViewer = dynamic_cast(occViewer); if (soccViewer) - soccViewer->setTransparency(myIO,myParam); + soccViewer->setTransparency(anIO, myParam); } } }; - ProcessVoidEvent(new TEvent(app,anIO,transp)); + ProcessVoidEvent(new TEvent (theEntry, transp)); } +class TInitGeomGenEvent: public SALOME_Event { +public: + typedef bool TResult; + TResult myResult; + TInitGeomGenEvent() : myResult(false) {} + virtual void Execute() { + myResult = GeometryGUI::InitGeomGen(); + } +}; bool GEOM_Swig::initGeomGen() { - return GeometryGUI::InitGeomGen(); + return ProcessEvent(new TInitGeomGenEvent()); }