Salome HOME
IPAL9285,9292,9314
[modules/visu.git] / src / VISUGUI / VisuGUI_Tools.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2005  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   : VisuGUI_Tools.cxx
25 //  Author : Sergey Anikin
26 //  Module : VISU
27
28
29 #include "VisuGUI_Tools.h"
30
31 #include "VISU_Gen_i.hh"
32 #include "VISU_Prs3d_i.hh"
33 #include "VISU_Result_i.hh"
34 #include "VISU_Table_i.hh"
35 #include "VISU_Mesh_i.hh"
36 #include "VISU_ViewManager_i.hh"
37
38 #include "VISU_Actor.h"
39
40 #include "SalomeApp_Module.h"
41 #include "SalomeApp_Study.h"
42 #include "SalomeApp_Application.h"
43 #include "SalomeApp_SelectionMgr.h"
44
45 #include "SALOME_ListIO.hxx"
46 #include "SALOME_ListIteratorOfListIO.hxx"
47
48 #include "SVTK_ViewWindow.h"
49 #include "SVTK_ViewModel.h"
50 #include "SVTK_Functor.h"
51
52 #include "VTKViewer_Algorithm.h"
53
54 #include "SPlot2d_ViewModel.h"
55 #include "Plot2d_ViewFrame.h"
56
57 #include "SUIT_Session.h"
58 #include "SUIT_MessageBox.h"
59
60 #include <vtkRenderer.h>
61 #include <vtkActorCollection.h>
62
63
64 //=============================================================================
65 namespace VISU
66 {
67   SUIT_Desktop*
68   GetDesktop(const CAM_Module* theModule)
69   {
70     return theModule->application()->desktop();
71   }
72
73   SalomeApp_SelectionMgr*
74   GetSelectionMgr(const SalomeApp_Module* theModule)
75   {
76     return theModule->getApp()->selectionMgr();
77   }
78
79   SalomeApp_Study*
80   GetAppStudy(const CAM_Module* theModule)
81   {
82     return
83       dynamic_cast<SalomeApp_Study*>(theModule->application()->activeStudy());
84   }
85
86   _PTR(Study)
87   GetCStudy(const SalomeApp_Study* theStudy)
88   {
89     return theStudy->studyDS();
90   }
91
92   SALOMEDS::StudyManager_var
93   GetStudyManager()
94   {
95     static SALOMEDS::StudyManager_var aStudyManager;
96     if(CORBA::is_nil(aStudyManager)){
97       SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
98       CORBA::Object_var anObject = aNamingService->Resolve("/myStudyManager");
99       aStudyManager = SALOMEDS::StudyManager::_narrow(anObject);
100     }
101     return aStudyManager;
102   }
103
104   bool
105   IsStudyLocked( _PTR(Study) theStudy )
106   {
107     if( theStudy )
108       return theStudy->GetProperties()->IsLocked();
109     return true;
110   }
111
112   bool
113   CheckLock( _PTR(Study) theStudy )
114   {
115     if(IsStudyLocked(theStudy))
116       throw std::runtime_error(QObject::tr("WRN_STUDY_LOCKED").latin1());
117     return false;
118   }
119
120   VISU_Gen_i*
121   GetVisuGen(const CAM_Module* theModule)
122   {
123     static VISU_Gen_i* aGen = NULL;
124     if(!aGen){
125       SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
126       Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","VISU");
127       VISU_Gen_var aVISU = VISU_Gen::_narrow(aComponent);
128       if(!CORBA::is_nil(aVISU)){
129         aGen = VISU_Gen_i::GetVisuGenImpl();
130         aGen->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(theModule))));
131       }
132     }
133     if(!aGen)
134       throw std::runtime_error(QObject::tr("ERR_CANT_FIND_VISU_COMPONENT").latin1());
135     return aGen;
136   }
137
138   SALOME_MED::MED_Gen_var
139   GetMEDEngine()
140   {
141     static SALOME_MED::MED_Gen_var aGen;
142     if(CORBA::is_nil(aGen)){
143       SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
144       Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","MED");
145       aGen = SALOME_MED::MED_Gen::_narrow(aComponent);
146     }
147     if(CORBA::is_nil(aGen))
148       throw std::runtime_error(QObject::tr("ERR_CANT_FIND_MED_COMPONENT").latin1());
149     return aGen;
150   }
151
152   VISU::Storable::TRestoringMap
153   getMapOfValue(SALOMEDS::SObject_var theSObject)
154   {
155     VISU::Storable::TRestoringMap aMap;
156     if(!theSObject->_is_nil()){
157       SALOMEDS::GenericAttribute_var anAttr;
158       if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
159         SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
160         CORBA::String_var aValue = aComment->Value();
161         QString aString(aValue.in());
162         VISU::Storable::StrToMap(aString,aMap);
163       }
164     }
165     return aMap;
166   }
167
168   QString
169   getValue(SALOMEDS::SObject_var theSObject,
170            QString theKey)
171   {
172     QString aStr("");
173     VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
174     if(!aMap.empty())
175       aStr = VISU::Storable::FindValue(aMap,theKey.latin1());
176     return aStr;
177   }
178
179   VISU::Storable::TRestoringMap getMapOfValue (_PTR(SObject) theSObject)
180   {
181     VISU::Storable::TRestoringMap aMap;
182     if (theSObject) {
183       _PTR(GenericAttribute) anAttr;
184       if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
185         _PTR(AttributeComment) aComment (anAttr);
186         std::string aValue = aComment->Value();
187         QString aString (aValue.c_str());
188         VISU::Storable::StrToMap(aString, aMap);
189       }
190     }
191     return aMap;
192   }
193
194   QString getValue (_PTR(SObject) theSObject, QString theKey)
195   {
196     QString aStr("");
197     VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
198     if (!aMap.empty())
199       aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
200     return aStr;
201   }
202
203   //************************************************************
204   // Selection
205   CORBA::Object_var
206   GetSelectedObj(const SalomeApp_Study* theStudy,
207                  const QString& theEntry,
208                  VISU::Storable::TRestoringMap* theMap)
209   {
210     if ( !theStudy || theEntry.isEmpty() )
211       return CORBA::Object::_nil();
212
213     SALOMEDS::Study_var aStudy = GetDSStudy(GetCStudy( theStudy ));
214     SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( theEntry.latin1() );
215     if(!aSObject->_is_nil()){
216       SALOMEDS::GenericAttribute_var anAttr;
217       if(theMap && aSObject->FindAttribute(anAttr,"AttributeComment")){
218         SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
219         std::string aValue = aComment->Value();
220         QString aString(aValue.c_str());
221         VISU::Storable::StrToMap(aString,*theMap);
222       }
223       return VISU::SObjectToObject(aSObject);
224     }
225     return CORBA::Object::_nil();
226   }
227
228   CORBA::Object_var
229   GetSelectedObj(const SalomeApp_Module* theModule,
230                  Handle(SALOME_InteractiveObject)* theIO,
231                  VISU::Storable::TRestoringMap* theMap)
232   {
233     SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
234     SALOME_ListIO aListIO;
235     aSelectionMgr->selectedObjects(aListIO);
236     SALOME_ListIteratorOfListIO anIter(aListIO);
237     if(anIter.More()){
238       Handle(SALOME_InteractiveObject) anIO = anIter.Value();
239       if(theIO)
240         *theIO = anIO;
241       if(anIO->hasEntry())
242         return GetSelectedObj( GetAppStudy(theModule), anIO->getEntry(), theMap );
243     }
244     return CORBA::Object::_nil();
245   }
246
247   void
248   Add(SalomeApp_SelectionMgr* theSelectionMgr,
249       const Handle(SALOME_InteractiveObject)& theIO)
250   {
251     SALOME_ListIO aListIO;
252     theSelectionMgr->selectedObjects(aListIO);
253     aListIO.Append(theIO);
254     theSelectionMgr->setSelectedObjects(aListIO);
255   }
256
257   void
258   Remove(SalomeApp_SelectionMgr* theSelectionMgr,
259          const Handle(SALOME_InteractiveObject)& theIO)
260   {
261     if (theIO.IsNull()) return;
262     SALOME_ListIO aListIO, aNewListIO;
263     theSelectionMgr->selectedObjects(aListIO);
264     SALOME_ListIteratorOfListIO anIter (aListIO);
265     for (; anIter.More(); anIter.Next()) {
266       Handle(SALOME_InteractiveObject) anIO = anIter.Value();
267       if (!anIO->isSame(theIO)) {
268         aNewListIO.Append(theIO);
269       }
270     }
271     theSelectionMgr->setSelectedObjects(aNewListIO);
272   }
273
274   /*!
275    * \brief Check, if "Delete" popup-menu can be put on current selection
276    *
277    * \param theModule - is used to access SelectionManager, Study and VISU_Gen
278    * \retval bool - returns TRUE if all currently selected objects are removable
279    */
280   bool
281   IsRemovableSelected (const SalomeApp_Module* theModule)
282   {
283     SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
284     SALOME_ListIO aListIO;
285     aSelectionMgr->selectedObjects(aListIO);
286
287     if (aListIO.Extent() < 1)
288       return false;
289
290     _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
291     if (!aStudy) return false;
292
293     // In some cases single selection can have its own popup-menu item for deletion
294     if (aListIO.Extent() == 1) {
295       Handle(SALOME_InteractiveObject) anIO = aListIO.First();
296       _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
297       if (aSObject) {
298         VISU::VISUType aType = (VISU::VISUType)getValue(aSObject, "myType").toInt();
299         if (aType == VISU::TVIEW3D) {
300           return false; // special case
301         }
302       }
303     }
304
305     SALOME_ListIteratorOfListIO anIter (aListIO);
306     for (; anIter.More(); anIter.Next()) {
307       Handle(SALOME_InteractiveObject) anIO = anIter.Value();
308       if (anIO->hasEntry()) {
309         _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
310         VISU::Storable::TRestoringMap pMap;
311         if (aSObject) {
312           CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
313           if (!CORBA::is_nil(aCORBAObject)) {
314             VISU::RemovableObject_var aRemovableObj = VISU::RemovableObject::_narrow(aCORBAObject);
315             if (CORBA::is_nil(aRemovableObj)) {
316               // Not removable CORBA object
317               return false;
318             }
319           } else {
320             // Can be removed, if lays directly under VISU
321             // (first sub-level) or is a child of such an object
322             string aNAME, aVisuNAME = GetVisuGen(theModule)->ComponentDataType();
323             _PTR(GenericAttribute) anAttr;
324             _PTR(AttributeComment) aComment;
325
326             bool isUnderVISU = false;
327             _PTR(SObject) aFatherSObject = aSObject->GetFather();
328             if (aFatherSObject->FindAttribute(anAttr, "AttributeComment")) {
329               _PTR(AttributeComment) aComment (anAttr);
330               aNAME = aComment->Value();
331               if (aNAME == aVisuNAME) {
332                 isUnderVISU = true;
333               }
334             }
335             if (!isUnderVISU) {
336               // Not directly under VISU component, check father
337               aCORBAObject = VISU::ClientSObjectToObject(aFatherSObject);
338               if (!CORBA::is_nil(aCORBAObject)) {
339                 // Father has IOR
340                 return false;
341               }
342
343               isUnderVISU = false;
344               aFatherSObject = aFatherSObject->GetFather();
345               if (aFatherSObject->FindAttribute(anAttr, "AttributeComment")) {
346                 _PTR(AttributeComment) aComment (anAttr);
347                 aNAME = aComment->Value();
348                 if (aNAME == aVisuNAME) {
349                   isUnderVISU = true;
350                 }
351               }
352               if (!isUnderVISU) {
353                 // Father is not directly under VISU component
354                 return false;
355               }
356             }
357           }
358         }
359       }
360     }
361     return true;
362   }
363
364   //************************************************************
365   // Display/Erase
366
367   void
368   ErasePrs (const SalomeApp_Module* theModule,
369             CORBA::Object_ptr theObject, bool theUpdate)
370   {
371     if (!CORBA::is_nil(theObject)) {
372       VISU::Base_var aBase = VISU::Base::_narrow(theObject);
373       if (CORBA::is_nil(aBase)) return;
374       VISU::VISUType aType = aBase->GetType();
375       switch (aType) {
376       case VISU::TCURVE:
377         {
378           if (VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aBase).in()))
379             PlotCurve(theModule, aCurve, VISU::eErase );
380           break;
381         }
382       case VISU::TCONTAINER:
383         {
384           if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aBase).in()))
385             PlotContainer(theModule, aContainer, VISU::eErase );
386           break;
387         }
388       case VISU::TTABLE:
389         {
390           if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aBase).in()))
391             PlotTable(theModule, aTable, VISU::eErase );
392           break;
393         }
394       default:
395         {
396           if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())) {
397             ErasePrs3d(theModule, aPrsObject);
398             if (theUpdate) {
399               if (SVTK_ViewWindow* vw = GetViewWindow(theModule))
400                 vw->Repaint();
401             }
402           }
403         }
404       } // switch (aType)
405     }
406   }
407
408   void
409   DeleteSObject (SalomeApp_Module* theModule,
410                  SALOMEDS::Study_ptr theStudy,
411                  SALOMEDS::SObject_ptr theSObject)
412   {
413     SALOMEDS::ChildIterator_var aChildIter = theStudy->NewChildIterator(theSObject);
414     for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
415       SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
416       CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
417       ErasePrs(theModule, aChildObj);
418     }
419
420     CORBA::Object_var anObj = VISU::SObjectToObject(theSObject);
421     if (!CORBA::is_nil(anObj)) {
422       VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObj);
423       if (!CORBA::is_nil(aRemovableObject)) {
424         aRemovableObject->RemoveFromStudy();
425       }
426     } else {
427       // Remove aSObject together with all its sub-objects
428       VISU::RemoveFromStudy(theSObject,
429                             false,  // remove not only IOR attribute, but Object With Children
430                             false); // not Destroy() sub-objects
431     }
432   }
433
434   void
435   DeletePrs3d(SalomeApp_Module* theModule,
436               VISU::Prs3d_i* thePrs,
437               const Handle(SALOME_InteractiveObject)& theIO)
438   {
439     if(!thePrs)
440       return;
441     if(CheckLock(GetCStudy(GetAppStudy(theModule))))
442       return;
443     SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
444     CORBA::String_var anEntry = aSObject->GetID();
445     SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
446     Remove(aSelectionMgr,theIO);
447     TViewWindows aViewWindows = GetViews(theModule);
448     for(int i = 0, iEnd = aViewWindows.size(); i < iEnd; i++){
449       SVTK_ViewWindow* aView = aViewWindows[i];
450       if(VISU_Actor* anActor = FindActor(aView,anEntry.in())){
451         aView->RemoveActor(anActor);
452         anActor->Delete();
453       }
454     }
455     thePrs->RemoveFromStudy();
456     theModule->updateObjBrowser(); //update Object browser
457   }
458
459   void
460   ErasePrs3d(const SalomeApp_Module* theModule,
461              VISU::Prs3d_i* thePrs)
462   {
463     if ( SVTK_ViewWindow* vw = GetViewWindow( theModule ) ){
464       VISU_Actor* anVISUActor = FindActor( vw, thePrs );
465       if (anVISUActor) {
466         anVISUActor->VisibilityOff();
467       }
468     }
469   }
470
471   //************************************************************
472   // Presentation management
473
474   void
475   ChangeRepresentation (const SalomeApp_Module* theModule,
476                         VISU::PresentationType  theType)
477   {
478     SUIT_ViewWindow* aView = GetActiveView(theModule, VTKViewer_Viewer::Type());
479     if (!aView) return;
480     SVTK_ViewWindow* vw  = (SVTK_ViewWindow*) aView;
481
482     Handle(SALOME_InteractiveObject) anIO;
483     CORBA::Object_var anObject = GetSelectedObj(theModule, &anIO);
484     if (CORBA::is_nil(anObject)) return;
485     PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
486     if (!aServant.in()) return;
487
488     VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
489     if (aPrs3d) {
490       if (VISU_Actor* anActor = GetActor(aPrs3d, vw)) {
491         switch (theType) {
492         case VISU::SHRINK:
493           if (anActor->IsShrunk())
494             anActor->UnShrink();
495           else
496             anActor->SetShrink();
497           break;
498         default:
499           if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
500             aMesh->SetPresentationType(theType);
501             RecreateActor(theModule, aMesh);
502           } else {
503             anActor->SetRepresentation(theType);
504           }
505         }
506         vw->Repaint();
507       }
508     }
509   }
510
511   //************************************************************
512   // SObject type
513
514   bool
515   CheckTimeStamp(const SalomeApp_Module* theModule,
516                  SALOMEDS::SObject_var& theSObject,
517                  Handle(SALOME_InteractiveObject)* theIO)
518   {
519     Handle(SALOME_InteractiveObject) anIO;
520     CORBA::Object_var anObject = GetSelectedObj(theModule,&anIO);
521     if(theIO)
522       *theIO = anIO;
523     if(!anIO.IsNull() && anIO->hasEntry()){
524       SALOMEDS::Study_var aStudy = GetDSStudy(GetCStudy(GetAppStudy(theModule)));
525       theSObject = aStudy->FindObjectID(anIO->getEntry());
526       QString aValue = getValue(theSObject,"myType");
527       if(aValue.toInt() == int(VISU::TTIMESTAMP))
528         return true;
529     }
530     SUIT_MessageBox::warn1(GetDesktop(theModule),
531                            QObject::tr("WRN_VISU"),
532                            QObject::tr("WRN_NO_AVAILABLE_DATA"),
533                            QObject::tr("BUT_OK") );
534     return false;
535   }
536
537
538   VISU::Result_i*
539   CheckResult(const SalomeApp_Module* theModule,
540               SALOMEDS::SObject_var theSource,
541               VISU::Result_var& theResult)
542   {
543     SALOMEDS::SObject_var aSObj;
544
545     aSObj = theSource->GetFather();
546     if (CORBA::is_nil(aSObj))
547       return NULL;
548
549     aSObj = aSObj->GetFather();
550     if (CORBA::is_nil(aSObj))
551       return NULL;
552
553     aSObj = aSObj->GetFather();
554     if (CORBA::is_nil(aSObj))
555       return NULL;
556
557     CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
558     if (CORBA::is_nil(anObject)) {
559       aSObj = aSObj->GetFather();
560       if (CORBA::is_nil(aSObj))
561         return NULL;
562       anObject = VISU::SObjectToObject(aSObj);
563     }
564
565     if (CORBA::is_nil(anObject))
566       return NULL;
567
568     theResult = VISU::Result::_narrow(anObject);
569     VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
570     if(pResult == NULL)
571       SUIT_MessageBox::warn1(GetDesktop(theModule),
572                              QObject::tr("WRN_VISU"),
573                              QObject::tr("WRN_NO_AVAILABLE_DATA"),
574                              QObject::tr("BUT_OK"));
575     return pResult;
576   }
577
578   //************************************************************
579   // Views
580
581   SUIT_ViewWindow* GetActiveView(const SalomeApp_Module* theModule, QString theType)
582   {
583     if(SalomeApp_Application* anApp = theModule->getApp()){
584       if(SUIT_ViewManager* aViewManager = anApp->activeViewManager()){
585         if (!theType.isNull()) {
586           if (aViewManager->getType() != theType)
587             return 0;
588         }
589         return aViewManager->getActiveView();
590       }
591     }
592     return 0;
593   }
594
595   //************************************************************
596   // VTK View
597
598   TViewWindows
599   GetViews(const SalomeApp_Module* theModule)
600   {
601     TViewWindows aViewWindows;
602     if(SalomeApp_Application* anApp = theModule->getApp()){
603       ViewManagerList aViewManagerList;
604       anApp->viewManagers(SVTK_Viewer::Type(),aViewManagerList);
605       QPtrListIterator<SUIT_ViewManager> anIter(aViewManagerList);
606       while(SUIT_ViewManager* aViewManager = anIter.current()){
607         QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
608         for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
609           if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
610             if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))
611               aViewWindows.push_back(aView);
612         }
613         ++anIter;
614       }
615     }
616     return aViewWindows;
617   }
618
619   SVTK_ViewWindow*
620   GetViewWindow(const SalomeApp_Module* theModule, const bool theCreate )
621   {
622     if(SalomeApp_Application* anApp = theModule->getApp()){
623       if(SUIT_ViewManager* aViewManager = anApp->getViewManager( SVTK_Viewer::Type(), theCreate )){
624         if(SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()){
625           return dynamic_cast<SVTK_ViewWindow*>(aViewWindow);
626         }
627       }
628     }
629     return NULL;
630   }
631
632
633   SVTK_ViewWindow*
634   GetViewWindow()
635   {
636     SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
637       (SUIT_Session::session()->activeApplication());
638     if (anApp) {
639       if (SUIT_ViewManager* aViewManager = anApp->activeViewManager()) {
640         if (aViewManager->getType() == SVTK_Viewer::Type()) {
641           if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) {
642             return dynamic_cast<SVTK_ViewWindow*>(aViewWindow);
643           }
644         }
645       }
646     }
647     return NULL;
648   }
649
650   VISU_Actor*
651   PublishInView(const SalomeApp_Module* theModule,
652                 VISU::Prs3d_i* thePrs)
653   {
654     VISU_Actor* aActor = NULL;
655     if(!thePrs)
656       return aActor;
657     if(SVTK_ViewWindow* aView = GetViewWindow(theModule)){
658       QApplication::setOverrideCursor( Qt::waitCursor );
659       if(aActor = thePrs->CreateActor()){
660         aView->AddActor(aActor);
661       }
662       QApplication::restoreOverrideCursor();
663     }
664     return aActor;
665   }
666
667   VISU_Actor*
668   UpdateViewer(const SalomeApp_Module* theModule,
669                VISU::Prs3d_i* thePrs,
670                bool theDispOnly)
671   {
672     SVTK_ViewWindow* vw = GetViewWindow( theModule );
673     if (!vw) return NULL;
674
675     vtkRenderer *aRen = vw->getRenderer();
676     vtkActorCollection *anActColl = aRen->GetActors();
677
678     vtkActor *anActor;
679     VISU_Actor* anVISUActor = NULL;
680     VISU_Actor* aResActor = NULL;
681     for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
682       if(!SALOME_Actor::SafeDownCast(anActor))
683         continue;
684       if(anActor->IsA("VISU_Actor")){
685         anVISUActor = VISU_Actor::SafeDownCast(anActor);
686         VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();
687         if(aPrs == NULL) continue;
688         if (thePrs == aPrs) {
689           aResActor = anVISUActor->GetParent();
690           thePrs->UpdateActor(aResActor);
691           aResActor->VisibilityOn();
692
693         } else if (theDispOnly) {
694           anVISUActor->GetParent()->VisibilityOff();
695         } else {
696         }
697       } else if (theDispOnly && anActor->GetVisibility()) {
698         anActor->VisibilityOff();
699       } else {
700       }
701     }
702     if (aResActor)
703       return aResActor;
704
705     anVISUActor = PublishInView( theModule, thePrs );
706     return anVISUActor;
707   }
708
709   void
710   RepaintViewWindows (const SalomeApp_Module* theModule,
711                       const Handle(SALOME_InteractiveObject)& theIObject)
712   {
713     TViewWindows aViewWindows;
714     if (SalomeApp_Application* anApp = theModule->getApp()) {
715       ViewManagerList aViewManagerList;
716       anApp->viewManagers(SVTK_Viewer::Type(),aViewManagerList);
717       QPtrListIterator<SUIT_ViewManager> anIter (aViewManagerList);
718       while (SUIT_ViewManager* aViewManager = anIter.current()) {
719         QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
720         for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
721           if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
722             if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
723               if (vw->isVisible(theIObject)) {
724                 vw->getRenderer()->ResetCameraClippingRange();
725                 vw->Repaint();
726                 vw->highlight(theIObject, true, true);
727               }
728             }
729           }
730         }
731         ++anIter;
732       }
733     }
734   }
735
736   VISU_Actor*
737   FindActor(SVTK_ViewWindow* theViewWindow,
738             const char* theEntry)
739   {
740     using namespace VTK;
741     if(vtkRenderer* aRenderer = theViewWindow->getRenderer()){
742       if(vtkActorCollection* aCollection = aRenderer->GetActors()){
743         if(VISU_Actor* anActor = Find<VISU_Actor>(aCollection,TIsSameEntry<VISU_Actor>(theEntry))){
744           return anActor->GetParent();
745         }
746       }
747     }
748     return NULL;
749   }
750
751   VISU_Actor*
752   FindActor(SVTK_ViewWindow* theViewWindow,
753             VISU::Prs3d_i* thePrs)
754   {
755     SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
756     CORBA::String_var anEntry = aSObject->GetID();
757     return FindActor(theViewWindow,anEntry.in());
758   }
759
760   void
761   RecreateActor (const SalomeApp_Module* theModule,
762                  VISU::Prs3d_i* thePrs)
763   {
764     QApplication::setOverrideCursor(Qt::waitCursor);
765
766     SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
767     CORBA::String_var anEntry = aSObject->GetID();
768
769     try {
770       thePrs->Update();
771
772       TViewWindows aViewWindows = GetViews(theModule);
773       for (int i = 0, iEnd = aViewWindows.size(); i < iEnd; i++) {
774         SVTK_ViewWindow* aView = aViewWindows[i];
775         if (VISU_Actor* anActor = FindActor(aView, anEntry.in())) {
776           thePrs->UpdateActor(anActor);
777         }
778       }
779     } catch (std::runtime_error& ex) {
780       INFOS(ex.what());
781       QApplication::restoreOverrideCursor();
782       SUIT_MessageBox::warn1 (GetDesktop(theModule), QObject::tr("WRN_VISU"),
783                               QObject::tr("ERR_CANT_BUILD_PRESENTATION") + " " + QObject::tr(ex.what()),
784                               QObject::tr("BUT_OK"));
785
786       TViewWindows aViewWindows = GetViews(theModule);
787       for (int i = 0, iEnd = aViewWindows.size(); i < iEnd; i++) {
788         SVTK_ViewWindow* aView = aViewWindows[i];
789         if (VISU_Actor* anActor = FindActor(aView, anEntry.in())) {
790           aView->RemoveActor(anActor);
791           anActor->Delete();
792         }
793       }
794       return;
795     }
796     QApplication::restoreOverrideCursor();
797   }
798
799   //************************************************************
800   // Plot2d View
801
802   SPlot2d_Viewer*
803   GetPlot2dViewer(const SalomeApp_Module* theModule, const bool theCreate)
804   {
805     if(SalomeApp_Application* anApp = theModule->getApp()){
806       if(SUIT_ViewManager* aViewManager = anApp->getViewManager( Plot2d_Viewer::Type(), theCreate )){
807         return dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
808       }
809     }
810     return NULL;
811   }
812
813   // Internal function used by several public functions below
814   void
815   UpdateCurve(VISU::Curve_i* theCurve,
816               Plot2d_ViewFrame* aPlot,
817               SPlot2d_Curve* plotCurve,
818               int theDisplaying)
819   {
820     if ( theDisplaying == VISU::eErase ) {
821       if ( plotCurve )
822         aPlot->eraseCurve( plotCurve, false );
823     }
824     else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
825       if ( plotCurve ) {
826         plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
827         //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
828         plotCurve->setVerTitle( theCurve->GetName() );
829         plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
830         plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
831         double* xList = 0;
832         double* yList = 0;
833         int     nbPoints = theCurve->GetData( xList, yList );
834         if ( nbPoints > 0 && xList && yList ) {
835           plotCurve->setData( xList, yList, nbPoints );
836         }
837         if ( !theCurve->IsAuto() ) {
838           plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
839           plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
840           SALOMEDS::Color color = theCurve->GetColor();
841           plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
842         }
843         plotCurve->setAutoAssign( theCurve->IsAuto() );
844         aPlot->displayCurve( plotCurve, false );
845       }
846       else {
847         Plot2d_Curve* crv = theCurve->CreatePresentation();
848         if ( crv ) {
849           aPlot->displayCurve( crv, false );
850           theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
851           theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
852           SALOMEDS::Color newColor;
853           newColor.R = crv->getColor().red()/255.;
854           newColor.G = crv->getColor().green()/255.;
855           newColor.B = crv->getColor().blue()/255.;
856           theCurve->SetColor( newColor );
857           crv->setAutoAssign( theCurve->IsAuto() );
858         }
859       }
860     }
861   }
862
863   void
864   PlotTable(const SalomeApp_Module* theModule,
865             VISU::Table_i* table,
866             int theDisplaying)
867   {
868     SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true ); // create if necessary
869     if ( !aView )
870       return;
871     Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
872     if ( !aPlot )
873       return;
874
875     if ( theDisplaying == VISU::eDisplayOnly )
876       aPlot->EraseAll();
877     QList<Plot2d_Curve> clist;
878     aPlot->getCurves( clist );
879     _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
880     _PTR(SObject) TableSO = aStudy->FindObjectID( table->GetEntry().latin1() );
881     if ( TableSO ) {
882       _PTR(ChildIterator) Iter = aStudy->NewChildIterator( TableSO );
883       for ( ; Iter->More(); Iter->Next() ) {
884         CORBA::Object_var childObject = VISU::ClientSObjectToObject( Iter->Value() );
885         if( !CORBA::is_nil( childObject ) ) {
886           CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
887           if( !CORBA::is_nil( aCurve ) ) {
888             VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
889             SPlot2d_Curve* plotCurve = 0;
890             SPlot2d_Curve* tmpCurve;
891             for ( int i = 0; i < clist.count(); i++ ) {
892               tmpCurve = dynamic_cast<SPlot2d_Curve*>( clist.at( i ) );
893               if (tmpCurve && tmpCurve->hasIO() &&
894                   !strcmp(tmpCurve->getIO()->getEntry(), theCurve->GetEntry())) {
895                 plotCurve = tmpCurve;
896                 break;
897               }
898             }
899
900             UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
901
902             if ( theDisplaying == VISU::eErase && plotCurve ) {
903               clist.remove( plotCurve );
904             }
905           }
906         }
907       }
908       aPlot->Repaint();
909     }
910   }
911
912   void
913   PlotCurve(const SalomeApp_Module* theModule,
914             VISU::Curve_i* theCurve,
915             int theDisplaying)
916   {
917     SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true );
918     if ( !aView )
919       return;
920     Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
921     if ( !aPlot )
922       return;
923
924 //  if ( theDisplaying == VISU::eDisplayOnly )
925 //    aPlot->EraseAll();
926     QList<Plot2d_Curve> clist;
927     aPlot->getCurves( clist );
928     SPlot2d_Curve* plotCurve = 0;
929     SPlot2d_Curve* tmpCurve;
930     for (int i = 0; i < clist.count(); i++) {
931       tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
932       if (tmpCurve && tmpCurve->hasIO() &&
933           !strcmp(tmpCurve->getIO()->getEntry(), theCurve->GetEntry())) {
934         plotCurve = tmpCurve;
935       } else if (theDisplaying == VISU::eDisplayOnly) {
936         aPlot->eraseCurve(clist.at(i));
937       }
938     }
939
940     UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying);
941
942     aPlot->Repaint();
943   }
944
945   void
946   PlotContainer(const SalomeApp_Module* theModule,
947                 VISU::Container_i* container,
948                 int theDisplaying)
949   {
950     SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true );
951     if ( !aView )
952       return;
953     Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
954     if ( !aPlot )
955       return;
956
957     if ( theDisplaying == VISU::eDisplayOnly )
958       aPlot->EraseAll();
959     QList<Plot2d_Curve> clist;
960     aPlot->getCurves( clist );
961     if ( container->GetNbCurves() > 0 ) {
962       int nbCurves = container->GetNbCurves();
963       for ( int k = 1; k <= nbCurves; k++ ) {
964         VISU::Curve_i* theCurve = container->GetCurve( k );
965         if ( theCurve && theCurve->IsValid() ) {
966           SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>
967             (aView->getCurveByIO(new SALOME_InteractiveObject (theCurve->GetEntry(), "", "")));
968
969           UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
970
971           if ( plotCurve && theDisplaying == VISU::eErase ) {
972             clist.remove( plotCurve );
973           }
974         }
975       }
976     }
977     aPlot->Repaint();
978   }
979
980   void
981   CreatePlot(SalomeApp_Module* theModule,
982              _PTR(SObject) theTableSO)
983   {
984     if ( IsSObjectTable(theTableSO) ) {
985       CORBA::Object_var aTable = VISU::ClientSObjectToObject(theTableSO);
986       CORBA::Object_var aContainer = GetVisuGen( theModule )->CreateContainer();
987       if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
988         VISU::Table_i*     pTable     = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
989         VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
990
991         if ( pContainer && pTable ) {
992           for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
993             CORBA::Object_var aNewCurve = GetVisuGen( theModule )->CreateCurve( pTable->_this(), 1, i );
994             if( !CORBA::is_nil( aNewCurve ) ) {
995               VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
996               if ( pCrv ) {
997                 pContainer->AddCurve( pCrv->_this() );
998               }
999             }
1000           }
1001           theModule->updateObjBrowser();
1002           PlotContainer( theModule, pContainer, VISU::eDisplay );
1003         }
1004       }
1005     }
1006   }
1007
1008   //************************************************************
1009   // Others
1010
1011   void CreateMesh (const SalomeApp_Module* theModule,
1012                    const Handle(SALOME_InteractiveObject)& theIO)
1013   {
1014     _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
1015     //if (CheckLock(aStudy))
1016     //  return;
1017
1018     SALOMEDS::SObject_var aResultSObj =
1019       GetDSStudy(aStudy)->FindObjectID(theIO->getEntry());
1020
1021     // Get VISU::Result
1022     VISU::Result_var aResult;
1023     VISU::Result_i* pResult = CheckResult(theModule, aResultSObj, aResult);
1024     if (pResult == NULL)
1025       return;
1026
1027     Storable::TRestoringMap aMap = getMapOfValue(aResultSObj);
1028     bool isExist;
1029     string aComment = Storable::FindValue(aMap,"myComment",&isExist).latin1();
1030     if (!isExist)
1031       return;
1032
1033     CORBA::Object_var aMesh;
1034     string aMeshName = Storable::FindValue(aMap,"myMeshName").latin1();
1035 #ifdef CHECKTIME
1036     Utils_Timer timer;
1037     timer.Start();
1038 #endif
1039     if (aComment == "ENTITY") {
1040       VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myId").toInt();
1041       if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
1042         aMesh = GetVisuGen(theModule)->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1043     } else if (aComment == "FAMILY") {
1044       VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myEntityId").toInt();
1045       string aFamilyName = Storable::FindValue(aMap,"myName").latin1();
1046       if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
1047         aMesh = GetVisuGen(theModule)->FamilyMeshOnEntity
1048           (aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1049     } else if (aComment == "GROUP") {
1050       string aGroupName = Storable::FindValue(aMap,"myName").latin1();
1051       if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
1052         aMesh = GetVisuGen(theModule)->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1053     }
1054 #ifdef CHECKTIME
1055     timer.Stop();
1056     MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
1057     timer.Show();
1058 #endif
1059
1060     QApplication::restoreOverrideCursor();
1061     VISU::Mesh_i* pPresent = NULL;
1062     if (!CORBA::is_nil(aMesh))
1063       pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1064     if (pPresent == NULL) {
1065       SUIT_MessageBox::warn1 (GetDesktop(theModule),
1066                               QObject::tr("WRN_VISU"),
1067                               QObject::tr("ERR_CANT_BUILD_PRESENTATION"),
1068                               QObject::tr("BUT_OK"));
1069       return;
1070     }
1071
1072     if (SVTK_ViewWindow* aView = GetViewWindow(theModule)) {
1073       try {
1074 #ifdef CHECKTIME
1075         Utils_Timer timer;
1076         timer.Start();
1077 #endif
1078         PublishInView(theModule, pPresent);
1079         aView->onFitAll();
1080 #ifdef CHECKTIME
1081         timer.Stop();
1082         MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
1083         timer.Show();
1084 #endif
1085         theModule->application()->putInfo(QObject::tr("INF_DONE"));
1086       } catch (std::runtime_error& exc) {
1087         INFOS(exc.what());
1088         SUIT_MessageBox::warn1 (GetDesktop(theModule),
1089                                 QObject::tr("WRN_VISU"),
1090                                 QObject::tr("ERR_CANT_CREATE_ACTOR") + " " + QObject::tr(exc.what()),
1091                                 QObject::tr("BUT_OK"));
1092       }
1093     }
1094   }
1095
1096   // ========================================================================================
1097   // GetPrs3dList: find list of presentations for the given object
1098   // ========================================================================================
1099   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
1100                                             const Handle(SALOME_InteractiveObject)& theIO)
1101   {
1102     std::vector<VISU::Prs3d_i*> aList;
1103     if (!theIO.IsNull() && theIO->hasEntry()) {
1104       _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1105       SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
1106       SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(theIO->getEntry());
1107       aList = GetPrs3dList(theModule, aSObject);
1108     }
1109     return aList;
1110   }
1111
1112   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
1113                                             SALOMEDS::SObject_ptr theObject)
1114   {
1115     _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1116     SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
1117
1118     std::vector<VISU::Prs3d_i*> aList; int k = 0;
1119     if (!theObject->_is_nil()) {
1120       CORBA::Object_var aCORBAObject = VISU::SObjectToObject(theObject);
1121       if (!CORBA::is_nil(aCORBAObject)) {
1122         VISU::Base_var aVisuObj = VISU::Base::_narrow(aCORBAObject);
1123         if (!CORBA::is_nil(aVisuObj)) {
1124           VISU::VISUType aType = aVisuObj->GetType();
1125           switch (aType) {
1126           case VISU::TSCALARMAP:
1127           case VISU::TISOSURFACE:
1128           case VISU::TDEFORMEDSHAPE:
1129           case VISU::TCUTPLANES:
1130           case VISU::TCUTLINES:
1131           case VISU::TVECTORS:
1132           case VISU::TSTREAMLINES:
1133           case VISU::TPLOT3D:
1134             {
1135               PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
1136               if (aServant.in()) {
1137                 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1138                 aList.resize(k+1); aList[k] = aPrsObject; k++;
1139               }
1140             }
1141             break;
1142           case VISU::TFIELD:
1143             {
1144               SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theObject);
1145               SALOMEDS::SObject_var aTimeStamp;
1146               anIter->Next(); // First is reference on support
1147               for(;anIter->More();anIter->Next()) {
1148                 aTimeStamp = anIter->Value();
1149                 if (aTimeStamp->_is_nil()) continue;
1150                 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aTimeStamp);
1151                 if (!aSubList.empty()) {
1152                   int n = aSubList.size();
1153                   aList.resize(k+n);
1154                   for (int i = 0; i < n; i++)
1155                     { aList[k] = aSubList[i]; k++; }
1156                 }
1157               }
1158             }
1159             break;
1160           }
1161         }
1162       } else {
1163         SALOMEDS::GenericAttribute_var anAttr;
1164         if (theObject->FindAttribute(anAttr, "AttributeComment")) {
1165           SALOMEDS::AttributeComment_var aComment =
1166             SALOMEDS::AttributeComment::_narrow(anAttr);
1167           string aComm = aComment->Value();
1168           QString strIn( aComm.c_str() );
1169           VISU::Storable::TRestoringMap pMap;
1170           VISU::Storable::StrToMap( strIn, pMap );
1171           bool isExist;
1172           VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
1173           if (isExist) {
1174             switch (aType) {
1175             case VISU::TFIELD:
1176               {
1177                 SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theObject);
1178                 SALOMEDS::SObject_var aTimeStamp;
1179                 anIter->Next(); // First is reference on support
1180                 for (;anIter->More();anIter->Next()) {
1181                   aTimeStamp = anIter->Value();
1182                   if (aTimeStamp->_is_nil()) continue;
1183                   std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aTimeStamp);
1184                   if (!aSubList.empty()) {
1185                     int n = aSubList.size();
1186                     aList.resize(k+n);
1187                     for (int i = 0; i < n; i++)
1188                       { aList[k] = aSubList[i]; k++; }
1189                   }
1190                 }
1191               }
1192               break;
1193             case VISU::TTIMESTAMP:
1194               {
1195                 SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theObject);
1196                 SALOMEDS::SObject_var aPrs;
1197                 for (;anIter->More();anIter->Next()) {
1198                   aPrs = anIter->Value();
1199                   if (aPrs->_is_nil()) continue;
1200                   std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aPrs);
1201                   if (!aSubList.empty()) {
1202                     int n = aSubList.size();
1203                     aList.resize(k+n);
1204                     for (int i = 0; i < n; i++)
1205                       { aList[k] = aSubList[i]; k++; }
1206                   }
1207                 }
1208               }
1209               break;
1210             }
1211           }
1212         }
1213       }
1214     }
1215     return aList;
1216   }
1217 }