1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : GeometryGUI_Swig.cxx
25 // Author : Nicolas REJNERI, Paul RASCLE
27 #include "GeometryGUI_Swig.hxx"
29 #include "GeometryGUI.h"
31 #include "SUIT_Desktop.h"
32 #include "SUIT_Session.h"
33 #include "SalomeApp_Application.h"
34 #include "SalomeApp_Study.h"
36 #include "OB_Browser.h"
38 #include "OCCViewer_ViewWindow.h"
39 #include "OCCViewer_ViewManager.h"
40 #include "SOCC_ViewModel.h"
43 #include "SVTK_ViewModel.h"
44 #include "SVTK_ViewWindow.h"
45 #include "SVTK_View.h"
46 #include "SVTK_Renderer.h"
49 #include "GEOM_Actor.h"
50 #include "GEOM_Client.hxx"
51 #include "GEOM_AISShape.hxx"
52 #include "GEOM_InteractiveObject.hxx"
53 #include "GEOM_Displayer.h"
54 #include "GEOM_Constants.h"
56 #include "SALOME_Event.h"
60 #include <TopoDS_Shape.hxx>
61 #include <AIS_ListOfInteractive.hxx>
62 #include <AIS_ListIteratorOfListOfInteractive.hxx>
63 #include <AIS_Drawer.hxx>
64 #include <Prs3d_IsoAspect.hxx>
65 #include <BRepTools.hxx>
68 #include <SALOMEconfig.h>
69 #include CORBA_SERVER_HEADER(GEOM_Gen)
71 #include <vtkRenderer.h>
73 static SHAPE_READER(ShapeReader);
75 inline OCCViewer_Viewer* GetOCCViewer(SUIT_Application* theApp){
76 SUIT_ViewWindow* window = theApp->desktop()->activeWindow();
77 if(window && window->getViewManager()->getType() == OCCViewer_Viewer::Type()){
78 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
80 OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( vw->getViewManager() );
82 return vm->getOCCViewer();
89 inline SVTK_ViewWindow* GetSVTKViewWindow(SUIT_Application* theApp){
90 SUIT_ViewWindow* window = theApp->desktop()->activeWindow();
91 if(window && window->getViewManager()->getType() == SVTK_Viewer::Type())
92 return dynamic_cast<SVTK_ViewWindow*>( window );
97 GEOM_Swig::GEOM_Swig()
99 // MESSAGE("Constructeur");
102 GEOM_Swig::~GEOM_Swig()
104 // MESSAGE("Destructeur");
107 void GEOM_Swig::createAndDisplayGO (const char* Entry, bool isUpdated)
109 class TEvent: public SALOME_Event
114 TEvent(const char* theEntry, bool toUpdateViewer):
116 myUpdateViewer(toUpdateViewer)
118 virtual void Execute()
120 SUIT_Application* app = SUIT_Session::session()->activeApplication();
123 SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
124 if (!ActiveStudy) return;
126 _PTR(Study) aStudy(ActiveStudy->studyDS());
127 _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
129 GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen();
130 if (CORBA::is_nil(Geom)) {
131 GeometryGUI::InitGeomGen();
132 Geom = GeometryGUI::GetGeomGen();
134 if (CORBA::is_nil(Geom))
137 std::string aFatherIOR;
138 _PTR(SComponent) father = aStudy->FindComponent("GEOM");
141 if (!father->ComponentIOR(aFatherIOR)) {
142 CORBA::String_var objStr = SalomeApp_Application::orb()->object_to_string(Geom);
143 aStudyBuilder->LoadWith(father, objStr.in());
144 father->ComponentIOR(aFatherIOR);
147 _PTR(SObject) obj = aStudy->FindObjectID(myEntry);
152 _PTR(GenericAttribute) anAttr;
153 if (!obj->FindAttribute(anAttr, "AttributeIOR"))
155 _PTR(AttributeIOR) anIOR(anAttr);
156 std::string anIORValue = anIOR->Value();
158 GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(anIORValue.c_str());
159 TopoDS_Shape Shape = ShapeReader.GetShape(Geom,aShape);
160 if (!Shape.IsNull()) {
161 if (obj->FindAttribute(anAttr, "AttributeName")) {
162 _PTR(AttributeName) aName (anAttr);
163 std::string aNameValue = aName->Value();
165 /*SUIT_Operation* op = new SalomeApp_ImportOperation (app);
168 _PTR(SObject) newObj1 = aStudyBuilder->NewObject(father);
169 aStudyBuilder->Addreference(newObj1, obj);
170 // commit transaction
172 Handle(GEOM_InteractiveObject) anIO =
173 new GEOM_InteractiveObject (const_cast<char*>(anIORValue.c_str()),
174 const_cast<char*>(aFatherIOR.c_str()),
176 const_cast<char*>( obj->GetID().c_str()));
178 GEOM_Displayer(ActiveStudy).Display(anIO, myUpdateViewer);
179 /*if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) {
180 SVTK_View* aView = aViewWindow->getView();
181 int aMode = aView->GetDisplayMode();
183 vtkActorCollection* theActors =
184 GEOM_AssemblyBuilder::BuildActors(Shape,0,aMode,true);
185 theActors->InitTraversal();
186 while (vtkActor* anActor = theActors->GetNextActor()) {
187 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor);
188 GActor->setName(const_cast<char*>(aNameValue.c_str()));
190 aView->Display(GActor);
193 } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app)) {
194 Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
195 Handle(GEOM_AISShape) aSh =
196 new GEOM_AISShape (Shape,const_cast<char*>(aNameValue.c_str()));
197 aSh->setName(const_cast<char*>(aNameValue.c_str()));
200 ic->AddOrRemoveCurrentObject(aSh,true);
202 // update object browser
203 SalomeApp_Application* app = NULL; //dynamic_cast<SalomeApp_Application*>(app);
205 CAM_Module* module = app->module("Geometry");
206 SalomeApp_Module* appMod = dynamic_cast<SalomeApp_Module*>(module);
208 appMod->updateObjBrowser(true);
215 // MESSAGE("createAndDisplayGO");
216 ProcessVoidEvent(new TEvent (Entry, isUpdated));
218 class TEventUpdateBrowser: public SALOME_Event
221 TEventUpdateBrowser() {}
222 virtual void Execute() {
223 SalomeApp_Application* app =
224 dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
226 CAM_Module* module = app->module("Geometry");
227 SalomeApp_Module* appMod = dynamic_cast<SalomeApp_Module*>(module);
228 if (appMod) appMod->updateObjBrowser(true);
234 ProcessVoidEvent(new TEventUpdateBrowser ());
237 void GEOM_Swig::createAndDisplayFitAllGO (const char* Entry)
239 class TEventFitAll: public SALOME_Event
243 virtual void Execute() {
244 SUIT_Application* app = SUIT_Session::session()->activeApplication();
247 if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app))
249 SVTK_View* aView = aViewWindow->getView();
250 aView->GetRenderer()->OnFitAll();
252 else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app))
254 Handle(V3d_Viewer) aViewer3d = occViewer->getViewer3d();
255 aViewer3d->InitActiveViews();
257 if (aViewer3d->MoreActiveViews())
258 aViewer3d->ActiveView()->FitAll();
263 createAndDisplayGO(Entry);
264 ProcessVoidEvent(new TEventFitAll());
267 void GEOM_Swig::UpdateViewer()
269 class TEventUpdateViewer: public SALOME_Event
272 TEventUpdateViewer() {}
273 virtual void Execute() {
274 SUIT_Application* app = SUIT_Session::session()->activeApplication();
276 SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
277 if (!ActiveStudy) return;
279 GEOM_Displayer(ActiveStudy).UpdateViewer();
283 ProcessVoidEvent(new TEventUpdateViewer());
286 int GEOM_Swig::getIndexTopology(const char* SubIOR, const char* IOR)
288 GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen();
289 if (CORBA::is_nil(aGeomGen))
292 GEOM::GEOM_Object_var aMainShape = aGeomGen->GetIORFromString(IOR);
293 GEOM::GEOM_Object_var aSubShape = aGeomGen->GetIORFromString(SubIOR);
294 if (CORBA::is_nil(aMainShape) || CORBA::is_nil(aSubShape))
297 GEOM::GEOM_IShapesOperations_var anIShapesOperations =
298 aGeomGen->GetIShapesOperations(aMainShape->GetStudyID());
299 if (CORBA::is_nil(anIShapesOperations))
302 return anIShapesOperations->GetTopologyIndex(aMainShape, aSubShape);
305 const char* GEOM_Swig::getShapeTypeString(const char* IOR)
307 TCollection_AsciiString aTypeName ("Shape of unknown type");
309 GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen();
310 if (!CORBA::is_nil(aGeomGen))
312 GEOM::GEOM_Object_var aShape = aGeomGen->GetIORFromString(IOR);
313 if (!CORBA::is_nil(aShape))
315 GEOM::GEOM_IShapesOperations_var anIShapesOperations =
316 aGeomGen->GetIShapesOperations(aShape->GetStudyID());
317 if (!CORBA::is_nil(anIShapesOperations))
319 aTypeName = anIShapesOperations->GetShapeTypeString(aShape);
324 return CORBA::string_dup(aTypeName.ToCString());
328 const char* GEOM_Swig::getShapeTypeIcon(const char* IOR)
330 GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen();
331 if ( CORBA::is_nil( Geom ) )
334 GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(IOR);
335 TopoDS_Shape shape = ShapeReader.GetShape(Geom, aShape);
337 if( shape.IsNull() ) {
341 switch (shape.ShapeType() )
343 case TopAbs_COMPOUND:
344 { return "ICON_OBJBROWSER_COMPOUND" ;}
345 case TopAbs_COMPSOLID:
346 { return "ICON_OBJBROWSER_COMPSOLID" ;}
348 { return "ICON_OBJBROWSER_SOLID" ;}
350 { return "ICON_OBJBROWSER_SHELL" ;}
352 { return "ICON_OBJBROWSER_FACE" ;}
354 { return "ICON_OBJBROWSER_WIRE" ;}
356 { return "ICON_OBJBROWSER_EDGE" ;}
358 { return "ICON_OBJBROWSER_VERTEX" ;}
364 void GEOM_Swig::setDisplayMode(const char* theEntry, int theMode, bool isUpdated)
366 class TEvent: public SALOME_Event {
371 TEvent(const char* theEntryArg, int theModeArg, bool theUpdated):
372 myEntry(theEntryArg), myMode(theModeArg), myUpdateViewer(theUpdated)
374 virtual void Execute() {
375 SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
378 Handle(SALOME_InteractiveObject) anIO =
379 new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
381 if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
382 SVTK_View* aView = aViewWindow->getView();
383 aView->SetDisplayMode(anIO, myMode);
387 else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
388 SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
390 soccViewer->switchRepresentation(anIO, myMode, myUpdateViewer);
395 ProcessVoidEvent(new TEvent (theEntry, theMode, isUpdated));
398 void GEOM_Swig::setVectorsMode(const char* theEntry, bool isOn, bool isUpdated)
400 class TEvent: public SALOME_Event {
405 TEvent(const char* theEntryArg, bool theOn, bool theUpdated):
406 myEntry(theEntryArg), myOn(theOn), myUpdateViewer(theUpdated)
408 virtual void Execute() {
409 SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
412 Handle(SALOME_InteractiveObject) anIO =
413 new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
415 if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
416 SVTK_View* aView = aViewWindow->getView();
417 SVTK_Viewer* stvkViewer = dynamic_cast<SVTK_Viewer*>(aViewWindow->getViewManager()->getViewModel());
418 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( stvkViewer->CreatePrs( myEntry.c_str() ) );
419 vtkActorCollection* anActors = vtkPrs->GetObjects();
420 anActors->InitTraversal();
421 while (vtkActor* anAct = anActors->GetNextActor()) {
422 GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(anAct);
423 aGeomActor->SetVectorMode(!aGeomActor->GetVectorMode());
428 else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
429 Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
430 SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
432 SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( soccViewer->CreatePrs( myEntry.c_str() ) );
433 if ( occPrs && !occPrs->IsNull() ) {
434 AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes );
435 AIS_ListIteratorOfListOfInteractive interIter( shapes );
436 for ( ; interIter.More(); interIter.Next() ) {
437 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
438 aSh->SetDisplayVectors(myOn);
439 ic->RecomputePrsOnly(interIter.Value());
447 ProcessVoidEvent(new TEvent (theEntry, isOn, isUpdated));
450 void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue, bool isUpdated)
452 class TEvent: public SALOME_Event {
459 TEvent(const char* theEntryArg, int theR, int theG, int theB, bool theUpdated):
460 myEntry(theEntryArg), myRed(theR), myGreen(theG), myBlue(theB), myUpdateViewer(theUpdated)
462 virtual void Execute() {
463 SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
466 Handle(SALOME_InteractiveObject) anIO =
467 new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
469 if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)){
470 SVTK_View* aView = aViewWindow->getView();
471 QColor aColor (myRed, myGreen, myBlue);
472 aView->SetColor(anIO, aColor);
475 } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
476 Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
477 SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
480 SALOME_Prs* prs= soccViewer->CreatePrs( myEntry.c_str() );
481 const SOCC_Prs* anOCCPrs = dynamic_cast<const SOCC_Prs*>( prs );
482 if ( !anOCCPrs || anOCCPrs->IsNull() )
485 // get objects to be displayed
486 AIS_ListOfInteractive anAISObjects;
487 anOCCPrs->GetObjects( anAISObjects );
488 AIS_ListIteratorOfListOfInteractive ite( anAISObjects );
489 Quantity_Color CSFColor = Quantity_Color(myRed/255., myGreen/255., myBlue/255., Quantity_TOC_RGB);
490 for ( ; ite.More(); ite.Next() )
492 if(!ic->IsDisplayed(ite.Value()))continue; //only displayed ais
493 ite.Value()->SetColor(CSFColor);
494 if (ite.Value()->IsKind(STANDARD_TYPE(GEOM_AISShape))) Handle(GEOM_AISShape)::DownCast(ite.Value())->SetShadingColor(CSFColor);
495 ite.Value()->Redisplay(Standard_True); // as in OnColor
497 if (myUpdateViewer) occViewer->update();
502 ProcessVoidEvent(new TEvent(theEntry, red, green, blue, isUpdated));
505 void GEOM_Swig::setIsos(const char* Entry, int nbU, int nbV, bool isUpdated )
507 class TEvent: public SALOME_Event {
512 TEvent(const char* theEntry, int theNbU, int theNbV, bool theUpdated):
513 myEntry(theEntry), myNbU(theNbU), myNbV(theNbV), myUpdateViewer(theUpdated)
515 virtual void Execute() {
516 SUIT_Application* app = SUIT_Session::session()->activeApplication();
518 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
521 Handle(SALOME_InteractiveObject) anIO =
522 new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
524 if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) {
525 SVTK_Viewer* aView = dynamic_cast<SVTK_Viewer*>(aViewWindow->getViewManager()->getViewModel());
526 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aView->CreatePrs( myEntry.c_str() ) );
528 vtkActorCollection* anActors = vtkPrs->GetObjects();
529 anActors->InitTraversal();
530 GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( anActors->GetNextActor() );
532 int aIsos[2]={myNbU,myNbV};
533 anActor->SetNbIsos(aIsos);
534 anActor->StoreIsoNumbers();
535 QString anIsos = QString("%1%2%3").arg(myNbU).arg(DIGIT_SEPARATOR).arg(myNbV);
536 int aMgrId = aView->getViewManager()->getGlobalId();
537 study->setObjectProperty(aMgrId, myEntry.c_str(), ISOS_PROP, anIsos);
544 else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app)) {
545 Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
546 SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
548 int aMgrId = soccViewer->getViewManager()->getGlobalId();
549 SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( soccViewer->CreatePrs( myEntry.c_str() ) );
550 if ( occPrs && !occPrs->IsNull() ) {
551 AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes );
552 AIS_ListIteratorOfListOfInteractive interIter( shapes );
553 for ( ; interIter.More(); interIter.Next() ) {
554 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
555 if ( !aSh.IsNull() ) {
556 Handle(AIS_Drawer) drawer = aSh->Attributes();
557 QVariant v = study->getObjectProperty( aMgrId, myEntry.c_str(), EDGE_WIDTH_PROP, QVariant() );
558 int width = v.isValid() ? v.toInt() : 1;
559 drawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width, myNbU) );
560 drawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width, myNbV) );
561 aSh->storeIsoNumbers();
562 ic->SetLocalAttributes(aSh, drawer);
564 QString anIsos = QString("%1%2%3").arg(myNbU).arg(DIGIT_SEPARATOR).arg(myNbV);
565 study->setObjectProperty(aMgrId, myEntry.c_str(), ISOS_PROP, anIsos);
574 ProcessVoidEvent(new TEvent (Entry, nbU, nbV, isUpdated));
577 void GEOM_Swig::setTransparency(const char* theEntry, float transp, bool isUpdated)
579 class TEvent: public SALOME_Event {
584 TEvent(const char* theEntryArg, float theParam, bool theUpdated):
585 myEntry(theEntryArg), myParam(theParam), myUpdateViewer(theUpdated)
587 virtual void Execute() {
588 SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
591 Handle(SALOME_InteractiveObject) anIO =
592 new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
594 if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
595 SVTK_View* aView = aViewWindow->getView();
596 aView->SetTransparency(anIO, myParam);
599 } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
600 SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
602 soccViewer->setTransparency(anIO, myParam, myUpdateViewer);
607 ProcessVoidEvent(new TEvent (theEntry, transp, isUpdated));
611 class TInitGeomGenEvent: public SALOME_Event {
613 typedef bool TResult;
615 TInitGeomGenEvent() : myResult(false) {}
616 virtual void Execute() {
617 myResult = GeometryGUI::InitGeomGen();
620 bool GEOM_Swig::initGeomGen()
622 return ProcessEvent(new TInitGeomGenEvent());
627 void GEOM_Swig::eraseGO (const char* Entry, bool allWindows)
629 class TEvent: public SALOME_Event
632 bool myFromAllWindows;
634 TEvent(const char* theEntry, bool fromAllWindows):
635 myEntry(theEntry), myFromAllWindows(fromAllWindows)
637 virtual void Execute()
639 SUIT_Application* app = SUIT_Session::session()->activeApplication();
641 SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
642 if (!ActiveStudy) return;
644 Handle (SALOME_InteractiveObject) aIO = new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
646 GEOM_Displayer(ActiveStudy).Erase(aIO, true);
647 /* if (myFromAllWindows) {
648 QPtrList<SUIT_ViewWindow> aWindows = app->desktop()->windows();
649 SUIT_ViewWindow* aWin = 0;
650 for (aWin = aWindows.first(); aWin; aWin = aWindows.next()) {
651 EraseObject(aWin, aIO);
654 SUIT_ViewWindow* aWin = app->desktop()->activeWindow();
656 EraseObject(aWin, aIO);
661 void EraseObject(SUIT_ViewWindow* theWin, Handle (SALOME_InteractiveObject) theIO)
663 if (theWin->getViewManager()->getType() == OCCViewer_Viewer::Type()){
664 OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( theWin );
666 OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( vw->getViewManager() );
668 SOCC_Viewer* aViewer = dynamic_cast<SOCC_Viewer*>(vm->getOCCViewer());
670 SALOME_Prs* aPrs = aViewer->CreatePrs(myEntry.c_str());
672 SALOME_OCCPrs* aOccPrs = dynamic_cast<SALOME_OCCPrs*>(aPrs);
674 aViewer->Erase(aOccPrs);
681 } else if (theWin->getViewManager()->getType() == SVTK_Viewer::Type()){
682 SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( theWin );
684 aViewWindow->Erase(theIO);
690 ProcessVoidEvent(new TEvent(Entry, allWindows));
695 void GEOM_Swig::setDeflection(const char* theEntry, float theDeflect)
697 class TEvent: public SALOME_Event {
701 TEvent(const char* theEntryArg, float theParam):
702 myEntry(theEntryArg), myParam(theParam)
704 virtual void Execute() {
705 SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
708 Handle(SALOME_InteractiveObject) anIO =
709 new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
711 if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
712 vtkActorCollection* aActors = aViewWindow->getRenderer()->GetActors();
713 aActors->InitTraversal();
714 while (vtkActor* aAct = aActors->GetNextActor()) {
715 if (GEOM_Actor* aGeomActor = dynamic_cast<GEOM_Actor*>(aAct)) {
716 if (aGeomActor->hasIO()) {
717 Handle(SALOME_InteractiveObject) aNextIO = aGeomActor->getIO();
718 if (aNextIO->isSame(anIO)) {
719 aGeomActor->setDeflection(myParam);
720 aViewWindow->Repaint();
726 // aView->SetTransparency(anIO, myParam);
728 } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
729 Handle(AIS_InteractiveContext) aContext = occViewer->getAISContext();
730 AIS_ListOfInteractive aAISList;
731 aContext->DisplayedObjects(aAISList);
732 AIS_ListIteratorOfListOfInteractive it(aAISList);
733 for (; it.More(); it.Next()) {
734 Handle(SALOME_InteractiveObject) aObj =
735 Handle(SALOME_InteractiveObject)::DownCast(it.Value()->GetOwner());
736 if ((!aObj.IsNull()) && aObj->hasEntry() && aObj->isSame(anIO)) {
737 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(it.Value());
738 if (!aShape.IsNull()) {
739 TopoDS_Shape aSh = aShape->Shape();
741 BRepTools::Clean(aSh);
743 aShape->SetOwnDeviationCoefficient( myParam );
744 aShape->SetOwnHLRDeviationAngle( 1.57 );
745 aContext->Redisplay(aShape);
754 ProcessVoidEvent(new TEvent (theEntry, theDeflect));