]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0021828: [CEA 651] TUI method to specify the number of Isos to show for an object
authorvsr <vsr@opencascade.com>
Fri, 31 Aug 2012 08:03:50 +0000 (08:03 +0000)
committervsr <vsr@opencascade.com>
Fri, 31 Aug 2012 08:03:50 +0000 (08:03 +0000)
Add setIsos() command to the Python API of Geometry GUI (SWIG interface).

src/GEOMGUI/GeometryGUI_Swig.cxx
src/GEOMGUI/GeometryGUI_Swig.hxx
src/GEOMGUI/GeometryGUI_Swig.i

index 59410211f8fc196646a317a15ac325ec2b9be2c8..2c4529085cb43ff26ad740aa29d610daaefa1d73 100644 (file)
@@ -51,6 +51,7 @@
 #include "GEOM_AISShape.hxx"
 #include "GEOM_InteractiveObject.hxx"
 #include "GEOM_Displayer.h"
+#include "GEOM_Constants.h"
 
 #include "SALOME_Event.h"
 
@@ -60,6 +61,7 @@
 #include <AIS_ListOfInteractive.hxx>
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
 #include <AIS_Drawer.hxx>
+#include <Prs3d_IsoAspect.hxx>
 #include <BRepTools.hxx>
 
 // IDL Headers
@@ -500,6 +502,78 @@ void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue, boo
   ProcessVoidEvent(new TEvent(theEntry, red, green, blue, isUpdated));
 }
 
+void GEOM_Swig::setIsos(const char* Entry, int nbU, int nbV, bool isUpdated )
+{
+  class TEvent: public SALOME_Event {
+    std::string myEntry;
+    int myNbU, myNbV;
+    bool myUpdateViewer;
+  public:
+    TEvent(const char* theEntry, int theNbU, int theNbV, bool theUpdated):
+      myEntry(theEntry), myNbU(theNbU), myNbV(theNbV), myUpdateViewer(theUpdated)
+    {}
+    virtual void Execute() {
+      SUIT_Application* app = SUIT_Session::session()->activeApplication();
+      if (!app) return;
+      SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+      if (!study) return;
+
+      Handle(SALOME_InteractiveObject) anIO =
+        new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
+
+      if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) {
+        SVTK_Viewer* aView = dynamic_cast<SVTK_Viewer*>(aViewWindow->getViewManager()->getViewModel());
+       SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aView->CreatePrs( myEntry.c_str() ) );
+       if ( vtkPrs ) {
+         vtkActorCollection* anActors = vtkPrs->GetObjects();
+         anActors->InitTraversal();
+         GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( anActors->GetNextActor() );
+         if ( anActor ) {
+           int aIsos[2]={myNbU,myNbV};
+           anActor->SetNbIsos(aIsos);
+           anActor->StoreIsoNumbers();
+           QString anIsos = QString("%1%2%3").arg(myNbU).arg(DIGIT_SEPARATOR).arg(myNbV);
+           int aMgrId = aView->getViewManager()->getGlobalId();
+           study->setObjectProperty(aMgrId, myEntry.c_str(), ISOS_PROP, anIsos);
+         }
+       }
+       
+       if (myUpdateViewer)
+          aView->Repaint();
+      }
+      else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app)) {
+        Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
+        SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
+        if (soccViewer) {
+         int aMgrId = soccViewer->getViewManager()->getGlobalId();
+          SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( soccViewer->CreatePrs( myEntry.c_str() ) );
+          if ( occPrs && !occPrs->IsNull() ) {
+            AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes );
+            AIS_ListIteratorOfListOfInteractive interIter( shapes );
+            for ( ; interIter.More(); interIter.Next() ) {
+              Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
+             if ( !aSh.IsNull() ) {
+               Handle(AIS_Drawer) drawer = aSh->Attributes();
+               QVariant v = study->getObjectProperty( aMgrId, myEntry.c_str(), EDGE_WIDTH_PROP, QVariant() );
+               int width = v.isValid() ? v.toInt() : 1;
+               drawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width, myNbU) );
+               drawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width, myNbV) );
+               aSh->storeIsoNumbers();
+                ic->SetLocalAttributes(aSh, drawer);
+               ic->Redisplay(aSh);
+               QString anIsos = QString("%1%2%3").arg(myNbU).arg(DIGIT_SEPARATOR).arg(myNbV);
+               study->setObjectProperty(aMgrId, myEntry.c_str(), ISOS_PROP, anIsos);
+             }
+            }
+          }
+        }
+      }
+    }
+  };
+
+  ProcessVoidEvent(new TEvent (Entry, nbU, nbV, isUpdated));
+}
+
 void GEOM_Swig::setTransparency(const char* theEntry, float transp, bool isUpdated)
 {
   class TEvent: public SALOME_Event {
index 0f93ab727153c48a4ddb5cbf758b3d90fbf44abe..3ddb4b6da2202becf5f4f825e219453368e03d88 100644 (file)
@@ -49,6 +49,7 @@ public:
   void setVectorsMode(const char* Entry, bool isSet, bool isUpdated = true);
   void setColor(const char* Entry, int red, int green, int blue, bool isUpdated = true);
   void setTransparency(const char* Entry, float transp, bool isUpdated = true);
+  void setIsos(const char* Entry, int nbU, int nbV, bool isUpdated =true);
   void setDeflection(const char* Entry, float deflect);
 
   int  getIndexTopology(const char *SubEntry, const char *Entry);
index d5bdfdf1a2522b7ed3ff1ba6ad91fd7d73dd60a5..e9a4339ba3c64dfb0c0e5e4b98a52374d6189aec 100644 (file)
@@ -65,6 +65,7 @@ class GEOM_Swig
   void setVectorsMode(const char* Entry, bool isSet, bool isUpdated =true);
   void setColor(const char* Entry, int red, int green, int blue, bool isUpdated =true);
   void setTransparency(const char* Entry, float transp, bool isUpdated =true);
+  void setIsos(const char* Entry, int nbU, int nbV, bool isUpdated =true);
   void setDeflection(const char* Entry, float deflect);
   const char* getShapeTypeIcon(const char *Ior);