Protect with SALOME_Event.

This commit is contained in:
jfa 2006-04-03 15:12:08 +00:00
parent e6be9c5634
commit e5d5800343

View File

@ -59,21 +59,10 @@
#include "SALOMEDSClient.hxx" #include "SALOMEDSClient.hxx"
// OCCT Includes // OCCT Includes
//#include <TopExp_Explorer.hxx>
//#include <TopTools_MapOfShape.hxx>
//#include <TopTools_ListOfShape.hxx>
//#include <TopTools_ListIteratorOfListOfShape.hxx>
//#include <GeomAbs_CurveType.hxx>
//#include <GeomAbs_SurfaceType.hxx>
//#include <TopoDS.hxx>
#include <TopAbs.hxx> #include <TopAbs.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
//#include <TopoDS_Edge.hxx>
//#include <TopoDS_Face.hxx>
//#include <TopoDS_Iterator.hxx>
#include <AIS_ListOfInteractive.hxx> #include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx> #include <AIS_ListIteratorOfListOfInteractive.hxx>
//#include <V3d_Viewer.hxx>
// IDL Headers // IDL Headers
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
@ -286,7 +275,7 @@ const char* GEOM_Swig::getShapeTypeString(const char* IOR)
const char* GEOM_Swig::getShapeTypeIcon(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 ) ) if ( CORBA::is_nil( Geom ) )
return "None"; return "None";
@ -322,75 +311,74 @@ const char* GEOM_Swig::getShapeTypeIcon(const char* IOR)
void GEOM_Swig::setDisplayMode(const char* theEntry, int theMode) void GEOM_Swig::setDisplayMode(const char* theEntry, int theMode)
{ {
SUIT_Application* app = SUIT_Session::session()->activeApplication(); class TEvent: public SALOME_Event {
if ( !app ) return; std::string myEntry;
int myMode;
Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry, "GEOM", "");
class TEvent: public SALOME_Event{
SUIT_Application* myApp;
Handle(SALOME_InteractiveObject) myIO;
int myParam;
public: public:
TEvent(SUIT_Application* theApp, const Handle(SALOME_InteractiveObject)& theIO, int theParam): TEvent(const char* theEntryArg, int theModeArg):
myApp(theApp), myIO(theIO), myParam(theParam) myEntry(theEntryArg), myMode(theModeArg)
{} {}
virtual void Execute(){ virtual void Execute() {
if(SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(myApp)){ 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(); SVTK_View* aView = aViewWindow->getView();
aView->SetDisplayMode(myIO,myParam); aView->SetDisplayMode(anIO, myMode);
aView->Repaint(); aView->Repaint();
} }
else if(OCCViewer_Viewer* occViewer = GetOCCViewer(myApp)) { else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>( occViewer ); SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
if (soccViewer) 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) void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue)
{ {
SUIT_Application* app = SUIT_Session::session()->activeApplication(); class TEvent: public SALOME_Event {
if ( !app ) return; std::string myEntry;
int myRed;
Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry, "GEOM", ""); int myGreen;
int myBlue;
QColor aColor(red,green,blue);
class TEvent: public SALOME_Event{
SUIT_Application* myApp;
Handle(SALOME_InteractiveObject) myIO;
QColor myParam;
public: public:
TEvent(SUIT_Application* theApp, const Handle(SALOME_InteractiveObject)& theIO, const QColor& theParam): TEvent(const char* theEntryArg, int theR, int theG, int theB):
myApp(theApp), myIO(theIO), myParam(theParam) myEntry(theEntryArg), myRed(theR), myGreen(theG), myBlue(theB)
{} {}
virtual void Execute(){ virtual void Execute() {
if(SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(myApp)){ 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(); SVTK_View* aView = aViewWindow->getView();
aView->SetColor(myIO,myParam); QColor aColor (myRed, myGreen, myBlue);
aView->SetColor(anIO, aColor);
aView->Repaint(); aView->Repaint();
}else if(OCCViewer_Viewer* occViewer = GetOCCViewer(myApp)){ } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
Handle(AIS_InteractiveContext) ic = occViewer->getAISContext(); Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
AIS_ListOfInteractive List; AIS_ListOfInteractive List;
ic->DisplayedObjects(List); ic->DisplayedObjects(List);
AIS_ListIteratorOfListOfInteractive ite(List); AIS_ListIteratorOfListOfInteractive ite (List);
for ( ; ite.More(); ite.Next() ) { for (; ite.More(); ite.Next()) {
Handle(SALOME_InteractiveObject) anObj = Handle(SALOME_InteractiveObject) anObj =
Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); Handle(SALOME_InteractiveObject)::DownCast(ite.Value()->GetOwner());
if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( myIO ) ) { if (!anObj.IsNull() && anObj->hasEntry() && anObj->isSame(anIO)) {
Quantity_Color CSFColor = Quantity_Color ( myParam.red() / 255., Quantity_Color CSFColor =
myParam.green() / 255., Quantity_Color(myRed/255., myGreen/255., myBlue/255., Quantity_TOC_RGB);
myParam.blue() / 255., ite.Value()->SetColor(CSFColor);
Quantity_TOC_RGB ); if (ite.Value()->IsKind(STANDARD_TYPE(GEOM_AISShape)))
ite.Value()->SetColor( CSFColor ); Handle(GEOM_AISShape)::DownCast(ite.Value())->SetShadingColor(CSFColor);
if ( ite.Value()->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) ite.Value()->Redisplay(Standard_True);
Handle(GEOM_AISShape)::DownCast( ite.Value() )->SetShadingColor( CSFColor );
ite.Value()->Redisplay( Standard_True );
occViewer->update(); occViewer->update();
break; 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) void GEOM_Swig::setTransparency(const char* theEntry, float transp)
{ {
SUIT_Application* app = SUIT_Session::session()->activeApplication(); class TEvent: public SALOME_Event {
if ( !app ) return; std::string myEntry;
Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry, "GEOM", "");
class TEvent: public SALOME_Event{
SUIT_Application* myApp;
Handle(SALOME_InteractiveObject) myIO;
float myParam; float myParam;
public: public:
TEvent(SUIT_Application* theApp, const Handle(SALOME_InteractiveObject)& theIO, float theParam): TEvent(const char* theEntryArg, float theParam):
myApp(theApp), myIO(theIO), myParam(theParam) myEntry(theEntryArg), myParam(theParam)
{} {}
virtual void Execute(){ virtual void Execute() {
if(SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(myApp)){ 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(); SVTK_View* aView = aViewWindow->getView();
aView->SetTransparency(myIO,myParam); aView->SetTransparency(anIO, myParam);
aView->Repaint(); aView->Repaint();
}else if(OCCViewer_Viewer* occViewer = GetOCCViewer(myApp)) { } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>( occViewer ); SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
if (soccViewer) 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() bool GEOM_Swig::initGeomGen()
{ {
return GeometryGUI::InitGeomGen(); return ProcessEvent(new TInitGeomGenEvent());
} }