]> SALOME platform Git repositories - modules/geom.git/blob - src/DisplayGUI/DisplayGUI.cxx
Salome HOME
0ef6fcdfe14d03599d0bf493f0826012f7dbd1c0
[modules/geom.git] / src / DisplayGUI / DisplayGUI.cxx
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DisplayGUI.cxx
25 //  Author : Damien COQUERET
26 //  Module : GEOM
27 //  $Header: 
28
29 #include "DisplayGUI.h"
30
31 #include "QAD_RightFrame.h"
32 #include "GEOM_AssemblyBuilder.h"
33 #include "VTKViewer_ViewFrame.h"
34 #include "OCCViewer_ViewFrame.h"
35 #include "OCCViewer_Viewer3d.h"
36 #include "SALOMEGUI_ImportOperation.h"
37 #include "SALOME_ListIteratorOfListIO.hxx"
38
39 #include <AIS_ListIteratorOfListOfInteractive.hxx>
40
41 #include "utilities.h"
42
43 using namespace std;
44
45 //=======================================================================
46 // function : DisplayGUI()
47 // purpose  : Constructor
48 //=======================================================================
49 DisplayGUI::DisplayGUI() :
50   QObject()
51 {
52   myGeomBase = new GEOMBase();
53   myGeomGUI = GEOMContext::GetGeomGUI();
54   myGeom = myGeomGUI->myComponentGeom;
55 }
56
57
58 //=======================================================================
59 // function : ~DisplayGUI()
60 // purpose  : Destructor
61 //=======================================================================
62 DisplayGUI::~DisplayGUI()
63 {
64 }
65
66
67 //=======================================================================
68 // function : OnGUIEvent()
69 // purpose  : 
70 //=======================================================================
71 bool DisplayGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
72 {
73   DisplayGUI* myDisplayGUI = new DisplayGUI();
74
75   switch (theCommandID)
76     {
77     case 211: // MENU VIEW - WIREFRAME/SHADING
78       {
79         if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
80           QApplication::setOverrideCursor(waitCursor);
81
82           VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
83
84           int themode = myRenderInter->GetDisplayMode();
85           if(themode==0) {
86             myRenderInter->SetDisplayMode(1);
87             QAD_Application::getDesktop()->menuBar()->changeItem(211, tr("GEOM_MEN_WIREFRAME"));
88           } 
89           else {
90             myRenderInter->SetDisplayMode(0);
91             QAD_Application::getDesktop()->menuBar()->changeItem(211, tr("GEOM_MEN_SHADING"));
92           }
93
94           QApplication::restoreOverrideCursor();          
95         } 
96         else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
97           QApplication::setOverrideCursor(Qt::waitCursor);
98
99           OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
100           Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
101           AIS_DisplayMode mode = (AIS_DisplayMode)ic->DisplayMode();
102           AIS_DisplayMode newmode = (mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame);
103
104           AIS_ListOfInteractive List;
105           ic->DisplayedObjects(List);
106           AIS_ListOfInteractive List1;
107           ic->ObjectsInCollector(List1);
108           List.Append(List1);
109           
110           AIS_ListIteratorOfListOfInteractive ite(List);
111           while(ite.More()) {
112             if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
113               Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
114               ic->SetDisplayMode(aSh,Standard_Integer(newmode),true);
115             }
116             ite.Next();
117           }
118
119           ic->SetDisplayMode(newmode, Standard_False);
120           if(newmode == 1)
121             QAD_Application::getDesktop()->menuBar()->changeItem(211, tr("GEOM_MEN_WIREFRAME"));
122           else
123             QAD_Application::getDesktop()->menuBar()->changeItem(211, tr("GEOM_MEN_SHADING"));
124           
125           QApplication::restoreOverrideCursor();
126         }
127         break;
128       }
129     case 212: // MENU VIEW - DISPLAY ALL
130       {
131         myDisplayGUI->OnDisplayAll();
132         break;
133       }
134     case 213: // MENU VIEW - DISPLAY ONLY
135       {
136         if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
137           myDisplayGUI->OnVTKDisplayOnly();
138         else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC)
139           myDisplayGUI->OnDisplayOnly();        
140         break;
141       }
142     case 214: // MENU VIEW - ERASE ALL
143       {
144         if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
145           ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->EraseAll();
146         else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
147           OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
148           Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
149
150           ic->EraseAll(Standard_True, Standard_False);
151           ic->Display(v3d->getTrihedron());
152         }
153         break;
154       }
155     case 215: // MENU VIEW - ERASE ONLY
156       {
157         myDisplayGUI->OnErase();
158         break;
159       }
160     case 8031: // POPUP VIEWER - WIREFRAME/SHADING
161       {
162         if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
163           // VTK
164           VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
165           
166           SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
167           SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
168           
169           QApplication::setOverrideCursor(Qt::waitCursor);
170           for(;It.More();It.Next()) {
171             Handle(SALOME_InteractiveObject) IOS = It.Value();
172             myRenderInter->SwitchRepresentation(IOS, false);
173           }
174           myRenderInter->Render();
175           QApplication::restoreOverrideCursor();
176         }
177         else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
178           QApplication::setOverrideCursor(Qt::waitCursor);
179           SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
180           OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
181           Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
182           SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
183           for(;It.More();It.Next()) {
184             Handle(SALOME_InteractiveObject) IObject = It.Value();
185             Standard_Boolean found;
186             Handle(GEOM_AISShape) Shape = myDisplayGUI->myGeomBase->ConvertIOinGEOMAISShape(IObject, found, true);
187             if(!Shape.IsNull()) {
188               AIS_DisplayMode mode = (AIS_DisplayMode)Shape->DisplayMode();
189               if(mode == -1)
190                 mode = (AIS_DisplayMode)ic->DisplayMode();
191
192               ic->SetDisplayMode(Shape, mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame, false);
193             }
194           }
195           ic->UpdateCurrentViewer();
196         }
197         QApplication::restoreOverrideCursor();
198         break;
199       }
200     default:
201       {
202         parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
203         break;
204       }
205     }
206   return true;
207 }
208
209
210 //=================================================================================
211 // function : BuildPresentation()
212 // purpose  : static
213 //=================================================================================
214 void DisplayGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
215 {
216   DisplayGUI* myDisplayGUI = new DisplayGUI();
217
218   SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
219   SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
220   
221   OCCViewer_Viewer3d* v3d;
222   Handle(AIS_InteractiveContext) ic;
223   vtkRenderer* Renderer;
224
225   if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
226     v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
227     ic = v3d->getAISContext();
228   } 
229   else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
230     Renderer = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
231   } 
232   else
233     return;
234
235   if(theIO.IsNull())
236     MESSAGE("BuildPresentation(): null SALOME_InteractiveObject passed")
237
238   Standard_Boolean testResult;
239   GEOM::GEOM_Shape_var myGeomShape = myDisplayGUI->myGeomBase->ConvertIOinGEOMShape(theIO, testResult);
240   if(!testResult)
241     return;
242
243   if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
244     // VTK
245           
246     SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry());
247             
248     SALOMEDS::SObject_var obj = aStudy->FindObjectID(theIO->getEntry());
249
250     VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
251
252     SALOMEDS::GenericAttribute_var anAttr;
253     SALOMEDS::AttributeName_var aName;
254     SALOMEDS::AttributeIOR_var anIOR;
255          
256     if(myRenderInter->isInViewer(theIO)) {
257       myRenderInter->Display(theIO, false);
258     }
259     else {
260       // Create new actor
261       if(!obj->_is_nil()) {
262         if(obj->FindAttribute(anAttr, "AttributeIOR")) {
263           // this SObject may be GEOM module root SObject
264
265           bool useSubItems = false;
266           SALOMEDS::ChildIterator_var anIter = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->NewChildIterator(obj);
267           if(myDisplayGUI->myGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) {
268             while (anIter->More() && !useSubItems) {
269               SALOMEDS::SObject_var subobj = anIter->Value();
270               SALOMEDS::GenericAttribute_var aTmpAttr;
271               if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
272                 if (!myDisplayGUI->myGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) {
273                   anAttr = aTmpAttr;
274                   obj = subobj;
275                   useSubItems = true;
276                 } 
277                 else 
278                   anIter->Next();
279               } 
280               else 
281                 anIter->Next();
282             }
283           }
284
285           while(useSubItems?anIter->More():!anAttr->_is_nil()) { 
286             anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
287             GEOM::GEOM_Shape_var aShape = myDisplayGUI->myGeom->GetIORFromString(anIOR->Value());
288             TopoDS_Shape Shape = myDisplayGUI->myGeomGUI->GetShapeReader().GetShape(myDisplayGUI->myGeom,aShape);
289             
290             if(obj->FindAttribute(anAttr, "AttributeName")) {
291               aName = SALOMEDS::AttributeName::_narrow(anAttr);
292               
293               vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
294               vtkActorCollection* theAllActors = theRenderer->GetActors();
295               theAllActors->InitTraversal();
296               vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
297               Handle(SALOME_InteractiveObject) anIObj;
298               // don't create new study object if it already exists
299               bool isDisplayed = false;
300               while(!(actor==NULL)) {
301                 SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
302                 if(Gactor!=NULL) {
303                   if(Gactor->hasIO()) {
304                     if(strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
305                       isDisplayed = true;
306                       anIObj = Gactor->getIO();
307                       if(!anIObj.IsNull()) myRenderInter->Display(anIObj, false);
308                     }
309                   }
310                 }
311                 actor=(vtkActor*)(theAllActors->GetNextActor());
312               }
313               if(!isDisplayed) {
314                 // open transaction
315                 QAD_Operation* op = new SALOMEGUI_ImportOperation( QAD_Application::getDesktop()->getActiveStudy() );
316                 op->start();
317                 
318                 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
319                 aStudyBuilder->Addreference(newObj1, obj);
320                 // commit transaction
321                 op->finish();
322                 
323                 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
324                 int themode = myRenderInter->GetDisplayMode();
325                 
326                 vtkActorCollection* theActors = 
327                   GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
328                 theActors->InitTraversal();
329                 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
330                 while(!(anActor==NULL)) {
331                   GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor);
332                   Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), myDisplayGUI->myGeomGUI->GetFatherior(),"GEOM");
333                   IO->setEntry(obj->GetID());
334                   GActor->setIO(IO);
335                   GActor->setName(theIO->getName());
336                   
337                   theRenderer->AddActor(GActor);
338                   //              renWin->Render();
339                   anActor = (vtkActor*)theActors->GetNextActor();
340                 }
341               }
342             }
343             // next item iteration
344             if(useSubItems) {
345               anIter->Next();
346               anAttr = SALOMEDS::GenericAttribute::_nil();
347               while(anIter->More() && anAttr->_is_nil()) {
348                 SALOMEDS::SObject_var subobject = anIter->Value();
349                 SALOMEDS::GenericAttribute_var aTmpAttribute;
350                 if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
351                   anAttr = aTmpAttribute;
352                   obj = subobject;
353                 } 
354                 else
355                   anIter->Next();
356               }
357             } 
358             else
359               anAttr = SALOMEDS::GenericAttribute::_nil();
360           }
361         }
362       }
363     }
364     // No viewer update should be done here!
365     //myRenderInter->Render();
366     //QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser( true );
367   } 
368   else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
369     SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry());
370     SALOMEDS::GenericAttribute_var anAttr;
371     SALOMEDS::AttributeName_var aName;
372     SALOMEDS::AttributeIOR_var anIOR;
373
374     if(v3d->isInViewer(theIO, true)) {
375       Standard_Boolean found;
376       Handle(GEOM_AISShape) aSh = myDisplayGUI->myGeomBase->ConvertIOinGEOMAISShape(theIO, found, true);
377       if(found) {
378         ic->Display(aSh, false);
379         ic->AddOrRemoveCurrentObject(aSh, false);
380       }
381       
382     } 
383     else {
384       SALOMEDS::SObject_var obj = aStudy->FindObjectID(theIO->getEntry());            
385       if(!obj->_is_nil()) {
386         MESSAGE("BuildPresentation(): SObject not null")
387         if(obj->FindAttribute(anAttr, "AttributeIOR")) {
388           MESSAGE("BuildPresentation(): SObject has IOR")
389           // this SObject may be GEOM module root SObject
390
391           bool useSubItems = false;
392           SALOMEDS::ChildIterator_var anIter = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->NewChildIterator(obj);
393           if(myDisplayGUI->myGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) {
394             while(anIter->More() && !useSubItems) {
395               SALOMEDS::SObject_var subobj = anIter->Value();
396               SALOMEDS::GenericAttribute_var aTmpAttr;
397               if(subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
398                 if(!myDisplayGUI->myGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) {
399                   anAttr = aTmpAttr;
400                   obj = subobj;
401                   useSubItems = true;
402                 } 
403                 else
404                   anIter->Next();
405               } 
406               else 
407                 anIter->Next();
408             }
409           }
410
411           while(useSubItems?anIter->More():!anAttr->_is_nil()) { 
412             anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
413             GEOM::GEOM_Shape_var aShape = myDisplayGUI->myGeom->GetIORFromString(anIOR->Value());
414             TopoDS_Shape Shape = myDisplayGUI->myGeomGUI->GetShapeReader().GetShape(myDisplayGUI->myGeom,aShape);
415             if(Shape.IsNull())
416               MESSAGE("BuildPresentation(): TopoDS_Shape is null!")
417             if(obj->FindAttribute(anAttr, "AttributeName")) {
418               MESSAGE("BuildPresentation(): SObject has Name")
419               aName = SALOMEDS::AttributeName::_narrow(anAttr);
420               // searchin for already displayed objects with the same shape
421               AIS_ListOfInteractive aDisplayed;
422               ic->DisplayedObjects(aDisplayed);
423               AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
424               Handle(AIS_Shape) anAISShape;
425               for(;anIObjects.More();anIObjects.Next()) {
426                 anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
427                 if(!anAISShape.IsNull()) {
428                   if(anAISShape->Shape().IsSame(Shape)) 
429                     break;
430                   anAISShape.Nullify();
431                 }
432               }
433               if(!anAISShape.IsNull()) {
434                 if(!ic->IsDisplayed(anAISShape)) 
435                   ic->Display(anAISShape, false);
436               } 
437               else {
438                 if(!useSubItems) {
439                   // open transaction
440                   QAD_Operation* op = new SALOMEGUI_ImportOperation( QAD_Application::getDesktop()->getActiveStudy() );
441                   op->start();
442                   if (fatherSF->_is_nil())
443                     MESSAGE("BuildPresentation(): fatherSF is nil!")
444                   SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
445                   aStudyBuilder->Addreference(newObj1, obj);
446                   // commit transaction
447                   op->finish();
448                 }
449                 Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
450                 aSh->SetShadingColor(myDisplayGUI->myGeomBase->myShadingColor);
451                 aSh->SetInfiniteState(Shape.Infinite());
452                 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), myDisplayGUI->myGeomGUI->GetFatherior(), "GEOM");
453                 IO->setEntry(obj->GetID());
454                 aSh->setIO(IO);
455                 aSh->setName(aName->Value());
456                 ic->Display(aSh, false);
457                 if(!useSubItems) 
458                   ic->AddOrRemoveCurrentObject(aSh, false);
459               }
460             }
461             // next item iteration
462             if(useSubItems) {
463               anIter->Next();
464               anAttr=SALOMEDS::GenericAttribute::_nil();
465               while (anIter->More() && anAttr->_is_nil()) {
466                 SALOMEDS::SObject_var subobject = anIter->Value();
467                 SALOMEDS::GenericAttribute_var aTmpAttribute;
468                 if(subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
469                   anAttr = aTmpAttribute;
470                   obj = subobject;
471                 } 
472                 else 
473                   anIter->Next();
474               }
475             } 
476             else 
477               anAttr = SALOMEDS::GenericAttribute::_nil();
478           }
479         }
480       }
481     }
482     // No viewer update should be done here!
483     //QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser( true );
484     //ic->UpdateCurrentViewer();
485   }
486 }
487
488
489 //=====================================================================================
490 // function : OnDisplayAll()
491 // purpose  :
492 //=====================================================================================
493 void DisplayGUI::OnDisplayAll(bool onlyPreviousDisplayedObject)
494 {
495   if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
496     OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
497     Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
498
499     //myContext->Display(v3d->getTrihedron());
500
501     if(!onlyPreviousDisplayedObject) {
502       SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
503       SALOMEDS::SComponent_var SC = aStudy->FindComponent("GEOM");
504       SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SC);
505       for(; it->More();it->Next()) {
506         SALOMEDS::SObject_var CSO = it->Value();
507         SALOMEDS::AttributeIOR_var anIOR;
508         SALOMEDS::GenericAttribute_var anAttr;
509         if(CSO->FindAttribute(anAttr, "AttributeIOR")) {
510           anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
511           Standard_Boolean testResult;
512           Handle(GEOM_AISShape) aSh = myGeomBase->ConvertIORinGEOMAISShape(anIOR->Value(), testResult);
513           if(testResult)
514             myContext->Display(aSh);
515           else {
516             GEOM::GEOM_Shape_ptr aShape = myGeom->GetIORFromString(anIOR->Value());
517             bool AddInSt = myGeomBase->mySettings_AddInStudy;
518             myGeomBase->mySettings_AddInStudy = false;
519             myGeomBase->Display(aShape);
520             myGeomBase->mySettings_AddInStudy = AddInSt;
521           }
522         }
523       }
524     }
525     else {
526       AIS_ListOfInteractive aListDisplayedObject;
527       myContext->DisplayedObjects(aListDisplayedObject);
528       AIS_ListIteratorOfListOfInteractive ite(aListDisplayedObject);
529       while(ite.More()) {
530         if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
531           Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
532           if (aSh->hasIO()) {
533             Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
534             if (v3d->isInViewer(GIO,true))
535               myContext->Display(aSh);
536           }
537         }
538         ite.Next();
539       }
540     }
541   }
542   else if (QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
543     SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
544     SALOMEDS::SComponent_var SC = aStudy->FindComponent("GEOM");
545     SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SC);
546     for(; it->More();it->Next()) {
547       SALOMEDS::SObject_var CSO = it->Value();
548       SALOMEDS::AttributeIOR_var anIOR;
549       SALOMEDS::GenericAttribute_var anAttr;
550       if(CSO->FindAttribute(anAttr, "AttributeIOR")) {
551         anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
552         Standard_Boolean testResult;
553         GEOM_Actor* aSh = myGeomBase->ConvertIORinGEOMActor(anIOR->Value(), testResult);
554         if(testResult) {
555           Handle(SALOME_InteractiveObject) IObject = aSh->getIO();
556           ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->Display(IObject);
557         }
558         else {
559           GEOM::GEOM_Shape_ptr aShape = myGeom->GetIORFromString(anIOR->Value());
560           bool AddInSt = myGeomBase->mySettings_AddInStudy;
561           myGeomBase->mySettings_AddInStudy = false;
562           myGeomBase->Display(aShape);
563           myGeomBase->mySettings_AddInStudy = AddInSt;
564         }
565       }
566     }
567   }
568   return;
569 }
570
571
572 //=====================================================================================
573 // function : OnVTKDisplayOnly()
574 // purpose  :
575 //=====================================================================================
576 void DisplayGUI::OnVTKDisplayOnly()
577 {
578   QApplication::setOverrideCursor(Qt::waitCursor);
579
580   // Erase all not selected actors
581   vtkRenderer* aren = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
582   vtkActorCollection* theActors = aren->GetActors();
583   theActors->InitTraversal();
584   vtkActor *ac = theActors->GetNextActor();
585   while(!(ac==NULL)) {
586     if(ac->IsA("SALOME_Actor")) {
587       SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(ac);
588       if(!anActor->isHighlighted())
589         anActor->VisibilityOff();
590     }
591     ac = theActors->GetNextActor();
592   }
593
594   // Display selection
595   SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
596   SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
597   SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry());
598   SALOMEDS::GenericAttribute_var anAttr;
599   SALOMEDS::AttributeName_var aName;
600   SALOMEDS::AttributeIOR_var anIOR;
601
602   SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
603   SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
604           
605   for(;It.More();It.Next()) {
606     Handle(SALOME_InteractiveObject) IObject = It.Value();
607     SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
608
609     VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
610
611     if(myRenderInter->isInViewer(IObject)) {
612       myRenderInter->Display(IObject);
613     }
614     else {
615       // Create new actor
616       if(!obj->_is_nil()) {
617         if(!obj->FindAttribute(anAttr, "AttributeIOR")) 
618           break;
619         // If selected object contains displayable subobjects, then do nothing
620         SALOMEDS::ChildIterator_var anIter = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->NewChildIterator(obj);
621         SALOMEDS::GenericAttribute_var aTmpAttr;
622         
623         anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
624         GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(anIOR->Value());
625         if(CORBA::is_nil(aShape)) continue;
626         TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape);
627
628         if(obj->FindAttribute(anAttr, "AttributeName")) {
629           aName = SALOMEDS::AttributeName::_narrow(anAttr);
630           // open transaction
631           QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy());
632           op->start();
633
634           SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
635           aStudyBuilder->Addreference(newObj1, obj);
636           // commit transaction
637           op->finish();
638                   
639           vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
640           int themode = myRenderInter->GetDisplayMode();
641           vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(Shape, 0, themode, Standard_True);
642           theActors->InitTraversal();
643           vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
644           while(!(anActor==NULL)) {
645             GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor);
646             GActor->setIO(IObject);
647             GActor->setName(IObject->getName());
648                     
649             theRenderer->AddActor(GActor);
650             vtkRenderWindow *renWin = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()->GetRenderWindow();
651             renWin->Render();
652             anActor = (vtkActor*)theActors->GetNextActor();
653           }
654         }
655       }
656     }
657   }
658   QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser(true);
659
660   QApplication::restoreOverrideCursor();
661   return;                      
662 }    
663
664
665 //=====================================================================================
666 // function : OnDisplayOnly()
667 // purpose  :
668 //=====================================================================================
669 void DisplayGUI::OnDisplayOnly()
670 {
671   if (QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
672     return;
673
674   OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
675   SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
676   Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
677
678   AIS_ListOfInteractive List;
679   ic->DisplayedObjects(List);
680   AIS_ListIteratorOfListOfInteractive ite(List);
681   while(ite.More()) {
682     if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
683       Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
684       if (!ic->IsSelected( aSh )) {
685         ic->Erase(aSh, Standard_True, Standard_True);
686       }
687     }
688     ite.Next();
689   }
690
691   SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
692   SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
693
694   SALOME_ListIteratorOfListIO It1(Sel->StoredIObjects());
695   for(;It1.More();It1.Next()) {
696     Handle(SALOME_InteractiveObject) IObject = It1.Value();
697
698     SALOMEDS::SObject_var fatherSF = 
699       aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry());
700     if(v3d->isInViewer(IObject, true)) {
701       AIS_ListOfInteractive List1;
702       ic->ObjectsInCollector(List1);
703       AIS_ListIteratorOfListOfInteractive ite1(List1);
704       while(ite1.More()) {
705         if(ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
706           Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value());
707           if (aSh->hasIO()) {
708             Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
709             if (IObject->isSame(GIO)) {
710               ic->Display(aSh);
711               ic->AddOrRemoveCurrentObject(aSh, true);
712               break;
713             }
714           }
715         }
716         ite1.Next();
717       }
718     }
719     else {
720       if (IObject->hasEntry()) {
721         SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry());
722         SALOMEDS::GenericAttribute_var anAttr;
723         SALOMEDS::AttributeName_var aName;
724         SALOMEDS::AttributeIOR_var anIOR;
725         if (!obj->_is_nil()) {
726           if (obj->FindAttribute(anAttr, "AttributeIOR")) {
727             // this SObject may be GEOM module root SObject
728
729             anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
730             GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(anIOR->Value());
731             if(CORBA::is_nil(aShape)) continue;
732             TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape);
733             
734             if(obj->FindAttribute(anAttr, "AttributeName")) {
735               aName = SALOMEDS::AttributeName::_narrow(anAttr);
736               // open transaction
737               QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy());
738               op->start();
739               
740               SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
741               aStudyBuilder->Addreference(newObj1, obj);
742               // commit transaction
743               op->finish();
744             }
745             
746             Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
747             Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), myGeomGUI->GetFatherior(),"GEOM");
748                 
749             IO->setEntry(obj->GetID());
750             aSh->setIO(IO);
751             aSh->setName(aName->Value());
752             ic->Display(aSh);
753             ic->AddOrRemoveCurrentObject(aSh, true);
754           }
755         }  
756       }
757     }
758   }
759 }
760
761
762 //=====================================================================================
763 // function : OnErase()
764 // purpose  :
765 //=====================================================================================
766 void DisplayGUI::OnErase()
767 {
768   SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
769   SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
770   if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
771     // VTK
772     SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
773     Handle(SALOME_InteractiveObject) anIObject;
774     for(;It.More();It.Next()) {
775       anIObject = It.Value();
776       VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
777
778       if(myRenderInter->isInViewer(anIObject)) {
779         myRenderInter->Erase(anIObject);
780       } 
781       else {
782         SALOMEDS::SObject_var obj = aStudy->FindObjectID(anIObject->getEntry());
783         SALOMEDS::GenericAttribute_var anAttr;
784         SALOMEDS::AttributeIOR_var anIOR;
785         if(!obj->_is_nil()) {
786           if(obj->FindAttribute(anAttr, "AttributeIOR")) {
787             // this SObject may be GEOM module root SObject
788             SALOMEDS::ChildIterator_var anIter = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->NewChildIterator(obj);
789             bool useSubItems = false;
790             while(anIter->More() && !useSubItems) {
791               SALOMEDS::SObject_var subobj = anIter->Value();
792               SALOMEDS::GenericAttribute_var aTmpAttr;
793               if(subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
794                 anAttr = aTmpAttr;
795                 obj = subobj;
796                 useSubItems = true;
797               } 
798               else
799                 anIter->Next();
800             }
801
802             while(useSubItems?anIter->More():!anAttr->_is_nil()) { 
803               anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
804               GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(anIOR->Value());
805               TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape);
806               if(obj->FindAttribute(anAttr, "AttributeName")) {
807                 // searchin for already displayed objects with the same shape
808                 vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
809                 vtkActorCollection* theAllActors = theRenderer->GetActors();
810                 theAllActors->InitTraversal();
811                 vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
812                 Handle(SALOME_InteractiveObject) anIObj;
813                 // don't create new study object if it already exists
814                 bool isDisplayed = false;
815                 while(!(actor==NULL)) {
816                   SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
817                   if(Gactor!=NULL) {
818                     if(Gactor->hasIO()) {
819                       if(strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
820                         isDisplayed = true;
821                         anIObj = Gactor->getIO();
822                         if(!anIObj.IsNull())
823                           myRenderInter->Erase(anIObj);
824                       }
825                     }
826                   }
827                   actor=(vtkActor*)(theAllActors->GetNextActor());
828                 }
829               }
830               if(useSubItems) {
831                 anIter->Next();
832                 anAttr=SALOMEDS::GenericAttribute::_nil();
833                 while(anIter->More() && anAttr->_is_nil()) {
834                   SALOMEDS::SObject_var subobject = anIter->Value();
835                   SALOMEDS::GenericAttribute_var aTmpAttribute;
836                   if(subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
837                     anAttr = aTmpAttribute;
838                     obj = subobject;
839                   }
840                   else
841                     anIter->Next();
842                 }
843               } 
844               else
845                 anAttr = SALOMEDS::GenericAttribute::_nil();
846             } 
847           }
848         }
849       }
850     }
851   }
852   else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
853     // OCC
854     OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
855     Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
856     SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
857     Handle(SALOME_InteractiveObject) anIObject;
858     for(;It.More();It.Next()) {
859       anIObject = It.Value();
860       if(v3d->isInViewer(anIObject, true)) {
861         Standard_Boolean found;
862         Handle(GEOM_AISShape) aSh = myGeomBase->ConvertIOinGEOMAISShape(anIObject, found, true);
863         if(found) {
864           ic->Erase(aSh);
865           ic->AddOrRemoveCurrentObject(aSh, true);
866         }
867       } 
868       else {
869         SALOMEDS::SObject_var obj = aStudy->FindObjectID(anIObject->getEntry());
870         SALOMEDS::GenericAttribute_var anAttr;
871         SALOMEDS::AttributeIOR_var anIOR;
872         if(!obj->_is_nil()) {
873           if(obj->FindAttribute(anAttr, "AttributeIOR")) {
874             // this SObject may be GEOM module root SObject
875             SALOMEDS::ChildIterator_var anIter = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->NewChildIterator(obj);
876             bool useSubItems = false;
877             while(anIter->More() && !useSubItems) {
878               SALOMEDS::SObject_var subobj = anIter->Value();
879               SALOMEDS::GenericAttribute_var aTmpAttr;
880               if(subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
881                 anAttr = aTmpAttr;
882                 obj = subobj;
883                 useSubItems = true;
884               } 
885               else
886                 anIter->Next();
887             }
888
889             while(useSubItems?anIter->More():!anAttr->_is_nil()) { 
890               anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
891               GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(anIOR->Value());
892               TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape);
893               if(obj->FindAttribute(anAttr, "AttributeName")) {
894                 // searchin for already displayed objects with the same shape
895                 AIS_ListOfInteractive aDisplayed;
896                 ic->DisplayedObjects(aDisplayed);
897                 AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
898                 Handle(AIS_Shape) anAISShape;
899                 for(;anIObjects.More();anIObjects.Next()) {
900                   anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
901                   if(!anAISShape.IsNull()) {
902                     if(anAISShape->Shape().IsSame(Shape))
903                       break;
904                     anAISShape.Nullify();
905                   }
906                 }
907                 if(!anAISShape.IsNull()) {
908                   if(ic->IsDisplayed(anAISShape)) 
909                     ic->Erase(anAISShape);
910                 }
911               }
912               if(useSubItems) {
913                 anIter->Next();
914                 anAttr=SALOMEDS::GenericAttribute::_nil();
915                 while(anIter->More() && anAttr->_is_nil()) {
916                   SALOMEDS::SObject_var subobject = anIter->Value();
917                   SALOMEDS::GenericAttribute_var aTmpAttribute;
918                   if(subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
919                     anAttr = aTmpAttribute;
920                     obj = subobject;
921                   }
922                   else
923                     anIter->Next();
924                 }
925               }
926               else
927                 anAttr = SALOMEDS::GenericAttribute::_nil();
928             }
929           }
930         }
931       }
932     }
933   }
934   Sel->ClearIObjects();
935 }
936
937
938 //=====================================================================================
939 // function : PrepareSubShapeSelection()
940 // purpose  : (localContextId of the method is opened and defined here)
941 //=====================================================================================
942 bool DisplayGUI::PrepareSubShapeSelection(const int SubShapeType, Standard_Integer& returnLocalContextId)
943 {
944   //* Test the type of viewer */
945   if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
946     return false;
947   
948   OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
949   Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
950   
951   /* local context opening */
952   //myGeomBase->SetDisplayedObjectList();
953   this->OnDisplayOnly();
954
955   returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False);
956   SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
957   SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
958   for(;It.More();It.Next()) {
959     Handle(SALOME_InteractiveObject) IObject = It.Value();
960     Standard_Boolean found;
961     Handle(GEOM_AISShape) Shape = myGeomBase->ConvertIOinGEOMAISShape(IObject, found);
962     if(found && SubShapeType >= Shape->Shape().ShapeType()) {
963       ic->Load(Shape, (8 - SubShapeType), Standard_True);
964       ic->HilightWithColor(Shape, Quantity_NOC_RED);
965     }
966   }
967   QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SELECT_SUBSHAPES"));
968   return true;
969 }
970
971
972 //=====================================================================================
973 // function : PrepareSubShapeSelectionArgumentShape()
974 // purpose  : ( localContextId of the method is opened and defined here )
975 //=====================================================================================
976 bool DisplayGUI::PrepareSubShapeSelectionArgumentShape(const TopoDS_Shape& aShape,const int SubShapeType, Standard_Integer& returnLocalContextId)
977 {
978   //* Test the type of viewer */
979   if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
980     return false;
981   
982   if(aShape.IsNull())
983     return false ;
984   
985   OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
986   Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
987   
988   /* local context opening */
989   //myGeomBase->SetDisplayedObjectList();
990   this->OnDisplayOnly();
991   
992   returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ;
993   
994   Handle(GEOM_AISShape) Shape = new GEOM_AISShape(aShape, "");  
995   ic->Display(Shape, 0, (8 - SubShapeType));
996
997   //  Not Load(...) but Display(...)
998   //  ic->Load(Shape, (8 - SubShapeType), Standard_True);
999   ic->HilightWithColor(Shape, Quantity_NOC_RED);
1000   
1001   QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SELECT_SUBSHAPES"));
1002   return true;
1003 }
1004
1005
1006 //=====================================================================================
1007 // EXPORTED METHODS
1008 //=====================================================================================
1009 extern "C"
1010 {
1011   bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
1012   {return DisplayGUI::OnGUIEvent(theCommandID, parent);}
1013   
1014   void BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
1015   {return DisplayGUI::BuildPresentation(theIO);}
1016 }