From: vsv Date: Thu, 11 May 2006 14:50:32 +0000 (+0000) Subject: setDeflection added X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=04d5e7f09ad4eff95172dcebbe8c988a29b7865c;p=modules%2Fgeom.git setDeflection added --- diff --git a/src/GEOMGUI/GeometryGUI_Swig.cxx b/src/GEOMGUI/GeometryGUI_Swig.cxx index 57b0f8659..5c05f3f5f 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.cxx +++ b/src/GEOMGUI/GeometryGUI_Swig.cxx @@ -63,11 +63,14 @@ #include #include #include +#include // IDL Headers #include #include CORBA_SERVER_HEADER(GEOM_Gen) +#include + using namespace std; @@ -483,6 +486,69 @@ void GEOM_Swig::setTransparency(const char* theEntry, float transp) } +void GEOM_Swig::setDeflection(const char* theEntry, float theDeflect) +{ + class TEvent: public SALOME_Event { + std::string myEntry; + float myParam; + public: + TEvent(const char* theEntryArg, float theParam): + myEntry(theEntryArg), myParam(theParam) + {} + 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)) { + vtkActorCollection* aActors = aViewWindow->getRenderer()->GetActors(); + aActors->InitTraversal(); + while (vtkActor* aAct = aActors->GetNextActor()) { + if (GEOM_Actor* aGeomActor = dynamic_cast(aAct)) { + if (aGeomActor->hasIO()) { + Handle(SALOME_InteractiveObject) aNextIO = aGeomActor->getIO(); + if (aNextIO->isSame(anIO)) { + aGeomActor->setDeflection(myParam); + aViewWindow->Repaint(); + return; + } + } + } + } + // aView->SetTransparency(anIO, myParam); + //aView->Repaint(); + } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) { + Handle(AIS_InteractiveContext) aContext = occViewer->getAISContext(); + AIS_ListOfInteractive aAISList; + aContext->DisplayedObjects(aAISList); + AIS_ListIteratorOfListOfInteractive it(aAISList); + for (; it.More(); it.Next()) { + Handle(SALOME_InteractiveObject) aObj = + Handle(SALOME_InteractiveObject)::DownCast(it.Value()->GetOwner()); + if ((!aObj.IsNull()) && aObj->hasEntry() && aObj->isSame(anIO)) { + Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(it.Value()); + if (!aShape.IsNull()) { + Handle(AIS_Drawer) aDrawer = aShape->Attributes(); + if (aDrawer.IsNull()) + aDrawer = new AIS_Drawer(); + aDrawer->SetDeviationCoefficient(myParam); + aShape->SetAttributes(aDrawer); + aContext->Redisplay(aShape, true, true); + aContext->UpdateCurrentViewer(); + return; + } + } + } + } + } + }; + + ProcessVoidEvent(new TEvent (theEntry, theDeflect)); +} + + class TInitGeomGenEvent: public SALOME_Event { public: typedef bool TResult; diff --git a/src/GEOMGUI/GeometryGUI_Swig.hxx b/src/GEOMGUI/GeometryGUI_Swig.hxx index 04ebb27d9..1d96ef78e 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.hxx +++ b/src/GEOMGUI/GeometryGUI_Swig.hxx @@ -54,6 +54,7 @@ public: void setDisplayMode(const char* Entry, int mode); void setColor(const char* Entry, int red, int green, int blue); void setTransparency(const char* Entry, float transp); + void setDeflection(const char* Entry, float deflect); int getIndexTopology(const char *SubEntry, const char *Entry); const char* getShapeTypeString(const char *Entry); diff --git a/src/GEOMGUI/GeometryGUI_Swig.i b/src/GEOMGUI/GeometryGUI_Swig.i index 516ffd4b3..b37885b14 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.i +++ b/src/GEOMGUI/GeometryGUI_Swig.i @@ -44,6 +44,7 @@ class GEOM_Swig void setDisplayMode(const char* Entry, int mode); void setColor(const char* Entry, int red, int green, int blue); void setTransparency(const char* Entry, float transp); + void setDeflection(const char* Entry, float deflect); const char* getShapeTypeIcon(const char *Ior); bool initGeomGen();