From 30919b026f04d6ad7908a44bf2812acb92dd60e8 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 31 Aug 2012 08:03:50 +0000 Subject: [PATCH] 0021828: [CEA 651] TUI method to specify the number of Isos to show for an object Add setIsos() command to the Python API of Geometry GUI (SWIG interface). --- src/GEOMGUI/GeometryGUI_Swig.cxx | 74 ++++++++++++++++++++++++++++++++ src/GEOMGUI/GeometryGUI_Swig.hxx | 1 + src/GEOMGUI/GeometryGUI_Swig.i | 1 + 3 files changed, 76 insertions(+) diff --git a/src/GEOMGUI/GeometryGUI_Swig.cxx b/src/GEOMGUI/GeometryGUI_Swig.cxx index 59410211f..2c4529085 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.cxx +++ b/src/GEOMGUI/GeometryGUI_Swig.cxx @@ -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 #include #include +#include #include // 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(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(aViewWindow->getViewManager()->getViewModel()); + SVTK_Prs* vtkPrs = dynamic_cast( 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(occViewer); + if (soccViewer) { + int aMgrId = soccViewer->getViewManager()->getGlobalId(); + SOCC_Prs* occPrs = dynamic_cast( 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 { diff --git a/src/GEOMGUI/GeometryGUI_Swig.hxx b/src/GEOMGUI/GeometryGUI_Swig.hxx index 0f93ab727..3ddb4b6da 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.hxx +++ b/src/GEOMGUI/GeometryGUI_Swig.hxx @@ -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); diff --git a/src/GEOMGUI/GeometryGUI_Swig.i b/src/GEOMGUI/GeometryGUI_Swig.i index d5bdfdf1a..e9a4339ba 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.i +++ b/src/GEOMGUI/GeometryGUI_Swig.i @@ -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); -- 2.39.2