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