]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
setDeflection added
authorvsv <vsv@opencascade.com>
Thu, 11 May 2006 14:50:32 +0000 (14:50 +0000)
committervsv <vsv@opencascade.com>
Thu, 11 May 2006 14:50:32 +0000 (14:50 +0000)
src/GEOMGUI/GeometryGUI_Swig.cxx
src/GEOMGUI/GeometryGUI_Swig.hxx
src/GEOMGUI/GeometryGUI_Swig.i

index 57b0f8659fc44692565e2f4673509b900e2725f4..5c05f3f5f71f393f08654cb0545b4d3bf541a276 100644 (file)
 #include <TopoDS_Shape.hxx>
 #include <AIS_ListOfInteractive.hxx>
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_Drawer.hxx>
 
 // IDL Headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(GEOM_Gen)
 
+#include <vtkRenderer.h>
+
 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<GEOM_Actor*>(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;
index 04ebb27d9aa9fba2626379eddd194d05214613db..1d96ef78ebd00945504a4f28260183e5f0aca16b 100644 (file)
@@ -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);
index 516ffd4b3f843de521eda7b35d7c0bc63624a1f9..b37885b1435e8780fe74b1e7f69c87aa092d3016 100644 (file)
@@ -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();