Salome HOME
Fix for the "0051899: curves are not shown in opened study" issue.
[modules/visu.git] / src / VISU_I / VISU_Prs3d_i.cc
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  VISU OBJECT : interactive object for VISU entities implementation
24 //  File   : VISU_Prs3d_i.cc
25 //  Author : Alexey PETROV
26 //  Module : VISU
27 //
28 #include "VISU_Prs3d_i.hh"
29 #include "VISU_Prs3dUtils.hh"
30 #include "VISU_Gen_i.hh"
31 #include "VISU_PipeLine.hxx"
32
33 #include "VISU_Result_i.hh"
34 #include "VISU_Actor.h"
35
36 #include "SALOME_Event.h"
37 #include "SUIT_ResourceMgr.h"
38 #include "SUIT_MessageBox.h"
39
40 #include <VTKViewer_MarkerUtils.h>
41
42 #include <vtkActorCollection.h>
43 #include <vtkUnstructuredGrid.h>
44 #include <vtkDataSet.h>
45 #include <vtkMapper.h>
46
47 #include <boost/bind.hpp>
48
49 #ifdef _DEBUG_
50 static int MYDEBUG = 1;
51 #else
52 static int MYDEBUG = 0;
53 #endif
54
55
56 //----------------------------------------------------------------------------
57 VISU::Prs3d_i::Prs3d_i() :
58   PrsObject_i(SALOMEDS::Study::_nil()),
59   myActorCollection(vtkActorCollection::New()),
60   myIsActiveSatate(true),
61   myIsForcedHidden(false)
62 {
63   if(MYDEBUG) MESSAGE("Prs3d_i::Prs3d_i - this = "<<this);
64   myOffset[0] = myOffset[1] = myOffset[2] = 0;
65   myActorCollection->Delete();
66
67   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
68   myMarkerType = (VISU::MarkerType)aResourceMgr->integerValue("VISU", "type_of_marker", 1); // dot
69   myMarkerScale = (VISU::MarkerScale)aResourceMgr->integerValue("VISU", "marker_scale", 9); // 5 pixels
70   myMarkerId = 0;
71 }
72
73
74 //----------------------------------------------------------------------------
75 void
76 VISU::Prs3d_i
77 ::SameAs(const Prs3d_i* theOrigin)
78 {
79   if(Prs3d_i* anOrigin = const_cast<Prs3d_i*>(theOrigin)){
80     VISU::TSetModified aModified(this);
81
82     GetPipeLine()->SameAs(anOrigin->GetPipeLine());
83     anOrigin->GetOffset(myOffset);
84
85     myMarkerType = anOrigin->GetMarkerType();
86     myMarkerScale = anOrigin->GetMarkerScale();
87     myMarkerId = anOrigin->GetMarkerTexture();
88
89     SetForcedHidden(anOrigin->IsForcedHidden());
90   }
91 }
92
93
94 //----------------------------------------------------------------------------
95 namespace VISU
96 {
97   struct TInvokeSignalEvent: public SALOME_Event
98   {
99     typedef boost::signal0<void> TSignal;
100     const TSignal& mySignal;
101     
102     TInvokeSignalEvent(const TSignal& theSignal):
103       mySignal(theSignal)
104     {}
105     
106     virtual
107     void
108     Execute()
109     {
110       mySignal();
111     }
112   };
113 }
114
115 //----------------------------------------------------------------------------
116 VISU::Prs3d_i::~Prs3d_i()
117 {
118   if(MYDEBUG) MESSAGE("Prs3d_i::~Prs3d_i - this = "<<this);
119   ProcessVoidEvent(new TInvokeSignalEvent(myRemoveActorsFromRendererSignal));
120 }
121
122
123 //----------------------------------------------------------------------------
124 bool 
125 VISU::Prs3d_i
126 ::SetInput(bool theReInit)
127 {
128   if(GetCResult()){
129     if(myMeshName != ""){
130       myPreviousResult = myResult;
131       myPreviousMeshName = myMeshName;
132       return true;
133     }
134   }
135   return false;
136 }
137
138
139 //----------------------------------------------------------------------------
140 void 
141 VISU::Prs3d_i
142 ::OnRestoreInput()
143 {
144   SetCResult(myPreviousResult);
145   myMeshName = myPreviousMeshName;
146 }
147
148
149 //----------------------------------------------------------------------------
150 CORBA::Boolean 
151 VISU::Prs3d_i
152 ::Apply(bool theReInit)
153 {
154   try{
155     if(SetInput(theReInit)){
156       if(myActorCollection->GetNumberOfItems())
157         UpdateActors();
158       return true;
159     }
160   }catch(std::exception& exc){
161     INFOS("Follow exception was occured :\n"<<exc.what());
162   }catch(...){
163     INFOS("Unknown exception was occured!");
164   }
165   OnRestoreInput();
166   return false;
167 }
168
169
170 //----------------------------------------------------------------------------
171 void
172 VISU::Prs3d_i
173 ::SetCResult(VISU::Result_i* theResult)
174 {
175   if(GetCResult() == theResult)
176     return;
177
178   if(theResult) {
179     SetStudyDocument(theResult->GetStudyDocument());
180   }
181   
182   VISU::TSetModified aModified(this);
183   
184   myResult = theResult;
185   myParamsTime.Modified();
186 }
187
188 //----------------------------------------------------------------------------
189 void
190 VISU::Prs3d_i
191 ::SetResultEntry(const std::string& theResultEntry)
192 {
193   SetCResult(VISU::GetResult(GetStudyDocument(), theResultEntry));
194 }
195
196 //----------------------------------------------------------------------------
197 std::string
198 VISU::Prs3d_i
199 ::GetResultEntry()
200 {
201   if(VISU::Result_i* aResult = GetCResult())
202     return aResult->GetEntry();
203   return "";
204 }
205
206 //----------------------------------------------------------------------------
207 VISU::Result_i* 
208 VISU::Prs3d_i
209 ::GetCResult() const 
210
211   return myResult;
212 }
213
214
215 //----------------------------------------------------------------------------
216 void
217 VISU::Prs3d_i
218 ::SetResultObject(VISU::Result_ptr theResult)
219 {
220   SetCResult(dynamic_cast<VISU::Result_i*>(GetServant(theResult).in()));
221 }
222
223
224 //----------------------------------------------------------------------------
225 VISU::Result_ptr
226 VISU::Prs3d_i
227 ::GetResultObject()
228 {
229   return GetCResult()->_this();
230 }
231
232
233 //----------------------------------------------------------------------------
234 void 
235 VISU::Prs3d_i
236 ::SetMeshName(const char* theMeshName)
237 {
238   if(myMeshName == theMeshName)
239     return;
240
241   VISU::TSetModified aModified(this);
242
243   myMeshName = theMeshName;
244   myParamsTime.Modified();
245 }
246
247
248 //----------------------------------------------------------------------------
249 char*
250 VISU::Prs3d_i
251 ::GetMeshName()
252 {
253   return CORBA::string_dup(myMeshName.c_str());
254 }
255
256
257 //----------------------------------------------------------------------------
258 std::string
259 VISU::Prs3d_i
260 ::GetCMeshName() const
261 {
262   return myMeshName;
263 }
264
265
266 //----------------------------------------------------------------------------
267 unsigned long int 
268 VISU::Prs3d_i
269 ::GetMTime()
270 {
271   unsigned long int aTime = myParamsTime.GetMTime();
272   if(IsPipeLineExists())
273     aTime = std::max(aTime, GetPipeLine()->GetMTime());
274   return aTime;
275 }
276
277 //----------------------------------------------------------------------------
278 bool 
279 VISU::Prs3d_i
280 ::GetActiveState()
281 {
282   return myIsActiveSatate;
283 }
284
285 //----------------------------------------------------------------------------
286 void 
287 VISU::Prs3d_i
288 ::SetActiveState(bool theState)
289 {
290   myIsActiveSatate = theState;
291 }
292
293 //----------------------------------------------------------------------------
294 VISU::Storable* 
295 VISU::Prs3d_i
296 ::Restore(SALOMEDS::SObject_ptr theSObject,
297           const Storable::TRestoringMap& theMap)
298 {
299   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
300   SetStudyDocument(aStudy);
301
302   bool anIsExists = false;
303   QString aResultEntry = VISU::Storable::FindValue(theMap,"myResultEntry", &anIsExists);
304   if(!anIsExists){
305     SALOMEDS::SObject_var aSObject = SALOMEDS::SObject::_duplicate(theSObject);
306     for(; aSObject->Depth() > 2 && !aResultEntry.isEmpty(); aSObject = aSObject->GetFather()){
307       CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
308       if(CORBA::is_nil(anObject))
309         continue;
310
311       VISU::Result_var aResult = VISU::Result::_narrow(anObject);
312       if(CORBA::is_nil(aResult))
313         continue;
314
315       CORBA::String_var anEntry = aSObject->GetID();
316       aResultEntry = anEntry.in();
317     }
318   }
319   SetResultEntry(aResultEntry.toLatin1().data());
320   if(!GetCResult())
321     return NULL;
322
323   SetMeshName((const char*)VISU::Storable::FindValue(theMap,"myMeshName").toLatin1());
324   SetName((const char*)VISU::Storable::FindValue(theMap,"myName").toLatin1(), false);
325   myOffset[0] = VISU::Storable::FindValue(theMap,"myOffset[0]").toFloat();
326   myOffset[1] = VISU::Storable::FindValue(theMap,"myOffset[1]").toFloat();
327   myOffset[2] = VISU::Storable::FindValue(theMap,"myOffset[2]").toFloat();
328   myMarkerType = VISU::MarkerType(VISU::Storable::FindValue(theMap,"myMarkerType").toInt());
329   myMarkerScale = VISU::MarkerScale(VISU::Storable::FindValue(theMap,"myMarkerScale").toInt());
330   myMarkerId = VISU::Storable::FindValue(theMap,"myMarkerId").toInt();
331   myParamsTime.Modified();
332   return this;
333 }
334
335 //----------------------------------------------------------------------------
336 void
337 VISU::Prs3d_i
338 ::ToStream(std::ostringstream& theStr)
339 {
340   Storable::DataToStream( theStr, "myResultEntry", GetResultEntry().c_str() );
341   Storable::DataToStream( theStr, "myMeshName", GetCMeshName().c_str() );
342   Storable::DataToStream( theStr, "myName", GetName().c_str() );
343   Storable::DataToStream( theStr, "myOffset[0]", myOffset[0] );
344   Storable::DataToStream( theStr, "myOffset[1]", myOffset[1] );
345   Storable::DataToStream( theStr, "myOffset[2]", myOffset[2] );
346   Storable::DataToStream( theStr, "myMarkerType", int(myMarkerType) );
347   Storable::DataToStream( theStr, "myMarkerScale", int(myMarkerScale) );
348   Storable::DataToStream( theStr, "myMarkerId", myMarkerId );
349 }
350
351
352 //----------------------------------------------------------------------------
353 SALOMEDS::SObject_var
354 VISU::Prs3d_i
355 ::GetSObject()
356 {
357   const SALOMEDS::Study_var& aStudy = GetStudyDocument();
358   if(!CORBA::is_nil(aStudy.in())){
359     CORBA::String_var anIOR = GetID();
360     return aStudy->FindObjectIOR(anIOR);
361   }
362   return SALOMEDS::SObject::_nil();
363 }
364
365
366 //----------------------------------------------------------------------------
367 void
368 VISU::Prs3d_i
369 ::Update()
370 {
371   if(GetMTime() < myUpdateTime.GetMTime())
372     return;
373
374   if(MYDEBUG) MESSAGE("Prs3d_i::Update - this = "<<this);
375
376   try{
377     ProcessVoidEvent(new TVoidMemFunEvent<VISU_PipeLine>
378                      (GetPipeLine(), &VISU_PipeLine::Update));
379     myUpdateTime.Modified();
380   }catch(std::exception&){
381     throw;
382   }catch(...){
383     throw std::runtime_error("Prs3d_i::Update >> unexpected exception was caught!!!");
384   }
385 }
386
387
388 //----------------------------------------------------------------------------
389 void
390 VISU::Prs3d_i
391 ::CheckDataSet()
392 {
393   vtkMapper *aMapper = GetPipeLine()->GetMapper();
394   vtkDataSet *aDataSet = aMapper->GetInput();
395   if (!aDataSet)
396     throw std::runtime_error("There is no input data !!!");
397
398   aMapper->Update();
399   static float eps = VTK_LARGE_FLOAT * 0.1 ;
400   if (!aDataSet->GetNumberOfCells())
401     throw std::runtime_error("There are no visible elements");
402
403   if (aDataSet->GetLength() > eps)
404     throw std::runtime_error("Diagonal of the actor is too large !!!");
405 }
406
407
408 //----------------------------------------------------------------------------
409 void
410 VISU::Prs3d_i
411 ::RemoveFromStudy()
412 {
413   struct TEvent: public TInvokeSignalEvent
414   {
415     VISU::Prs3d_i* myRemovable;
416   
417     TEvent(const TSignal& theSignal,
418            VISU::Prs3d_i* theRemovable):
419       TInvokeSignalEvent(theSignal),
420       myRemovable(theRemovable)
421     {}
422   
423     virtual
424     void
425     Execute()
426     {
427       //TInvokeSignalEvent::Execute();
428       myRemovable->UnRegister();
429     }
430   };
431
432   ProcessVoidEvent(new TEvent(myRemoveActorsFromRendererSignal, this));
433 }
434
435
436 //----------------------------------------------------------------------------
437 VISU_PipeLine*
438 VISU::Prs3d_i
439 ::GetPipeLine() const
440 {
441   if(!myPipeLine.GetPointer())
442     throw std::runtime_error("VISU::Prs3d_i::myPipeLine == NULL !!!");
443
444   return myPipeLine.GetPointer();
445 }
446
447 //----------------------------------------------------------------------------
448 void
449 VISU::Prs3d_i
450 ::SetPipeLine(VISU_PipeLine* thePipeLine)
451 {
452   myPipeLine = thePipeLine;
453   if(thePipeLine)
454     thePipeLine->Delete();
455 }
456
457 //----------------------------------------------------------------------------
458 bool 
459 VISU::Prs3d_i
460 ::IsPipeLineExists()
461 {
462   return myPipeLine.GetPointer() != NULL;
463 }
464
465 //----------------------------------------------------------------------------
466 VISU_PipeLine* 
467 VISU::Prs3d_i
468 ::GetActorPipeLine()
469 {
470   return GetPipeLine();
471 }
472
473 //----------------------------------------------------------------------------
474 vtkDataSet* 
475 VISU::Prs3d_i
476 ::GetInput()
477 {
478   return GetPipeLine()->GetInput();
479 }
480
481 //----------------------------------------------------------------------------
482 Handle(SALOME_InteractiveObject)
483 VISU::Prs3d_i
484 ::GetIO()
485 {
486   if( myIO.IsNull() )
487     myIO = new SALOME_InteractiveObject(GetActorEntry().c_str(), "VISU", GetName().c_str());
488
489   return myIO;
490 }
491
492 //----------------------------------------------------------------------------
493 std::string
494 VISU::Prs3d_i
495 ::GetActorEntry()
496 {
497   return GetEntry();
498 }
499
500
501 //----------------------------------------------------------------------------
502 void
503 VISU::Prs3d_i
504 ::CreateActor(VISU_Actor* theActor)
505 {
506   try{
507     SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
508
509     Handle(SALOME_InteractiveObject) anIO = GetIO();
510     if(!anIO.IsNull() && anIO->hasEntry()){
511       theActor->setIO(anIO);
512     }
513
514     Update();
515     CheckDataSet();
516
517     theActor->SetPrs3d(this);
518     theActor->SetShrinkFactor(aResourceMgr->integerValue("VISU", "shrink_factor", 80)/100.);
519     theActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]);
520
521     if( myMarkerType != VISU::MT_USER )
522       theActor->SetMarkerStd( (VTK::MarkerType)myMarkerType, (VTK::MarkerScale)myMarkerScale );
523     else if( myMarkerId > 0 ) {
524       VTK::MarkerTexture aMarkerTexture;
525       if( LoadMarkerTexture( myMarkerId, aMarkerTexture ) )
526         theActor->SetMarkerTexture( myMarkerId, aMarkerTexture );
527     }
528
529     theActor->SetPipeLine(GetActorPipeLine());
530     if(theActor->GetPipeLine() != GetPipeLine()){
531        // To decrease actor'ss pipeline reference counter
532       theActor->GetPipeLine()->Delete();
533     }
534
535     theActor->SetFactory(this);
536     theActor->ConnectToFactory(myUpdateActorsSignal, myRemoveActorsFromRendererSignal);
537
538     myActorCollection->AddItem(theActor);
539     theActor->Delete();
540   }catch(std::bad_alloc& ex){
541     throw std::runtime_error("CreateActor >> No enough memory");
542     throw ex;
543   } catch(std::exception&){
544     throw;
545   }catch(...) {
546     throw std::runtime_error("CreateActor >> unexpected exception was caught!!!");
547   }
548 }
549
550 //----------------------------------------------------------------------------
551 void
552 VISU::Prs3d_i
553 ::RemoveActor(VISU_ActorBase* theActor)
554 {
555   if(MYDEBUG) MESSAGE("Prs3d_i::RemoveActor - this = "<<this<<"; theActor = "<<theActor<<"; "<<theActor->GetReferenceCount());
556   myActorCollection->RemoveItem(theActor);
557 }
558
559 //----------------------------------------------------------------------------
560 void
561 VISU::Prs3d_i
562 ::RemoveActors()
563 {
564   if(MYDEBUG) MESSAGE("Prs3d_i::RemoveActors - this = "<<this);
565   ProcessVoidEvent(new TInvokeSignalEvent(myRemoveActorsFromRendererSignal));
566   myActorCollection->RemoveAllItems();
567 }
568
569 //----------------------------------------------------------------------------
570 void
571 VISU::Prs3d_i
572 ::UpdateActor(VISU_ActorBase* theActor)
573 {
574   if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(theActor)){
575     if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor - this = "<<this<<"; theActor = "<<anActor);
576     anActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]);
577
578     if( myMarkerType != VISU::MT_USER )
579       anActor->SetMarkerStd( (VTK::MarkerType)myMarkerType, (VTK::MarkerScale)myMarkerScale );
580     else if( myMarkerId > 0 ) {
581       VTK::MarkerTexture aMarkerTexture;
582       if( LoadMarkerTexture( myMarkerId, aMarkerTexture ) )
583         anActor->SetMarkerTexture( myMarkerId, aMarkerTexture );
584     }
585
586     anActor->ShallowCopyPL(GetPipeLine());
587     anActor->highlight(anActor->isHighlighted());
588   }
589 }
590
591 void
592 VISU::Prs3d_i
593 ::UpdateActors()
594 {
595   if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActors - this = "<<this);
596   Update();
597   try {
598     CheckDataSet();
599   } catch( std::exception& ex ) {
600     if( !IsForcedHidden() ) {
601       if( HasVisibleActors() )
602         SetForcedHidden( true );
603       RemoveActors();
604       SUIT_MessageBox::warning( 0,
605                                 QObject::tr("WRN_VISU"),
606                                 QString( ex.what() ),
607                                 QObject::tr("BUT_OK") );
608     }
609     return;
610   }
611   ProcessVoidEvent(new TInvokeSignalEvent(myUpdateActorsSignal));
612 }
613
614
615 //----------------------------------------------------------------------------
616 // Clipping planes
617 void
618 VISU::Prs3d_i
619 ::RemoveAllClippingPlanes()
620 {
621   GetPipeLine()->RemoveAllClippingPlanes();
622 }
623
624 //----------------------------------------------------------------------------
625 bool
626 VISU::Prs3d_i
627 ::AddClippingPlane(vtkPlane* thePlane)
628 {
629   return GetPipeLine()->AddClippingPlane(thePlane);
630 }
631
632 //----------------------------------------------------------------------------
633 vtkIdType
634 VISU::Prs3d_i
635 ::GetNumberOfClippingPlanes() const
636 {
637   return GetPipeLine()->GetNumberOfClippingPlanes();
638 }
639
640 //----------------------------------------------------------------------------
641 vtkPlane* 
642 VISU::Prs3d_i::
643 GetClippingPlane(vtkIdType theID) const
644 {
645   return GetPipeLine()->GetClippingPlane(theID);
646 }
647
648 //----------------------------------------------------------------------------
649 void VISU::Prs3d_i::RemoveClippingPlane(vtkIdType theID)
650 {
651   GetPipeLine()->RemoveClippingPlane(theID);
652 }
653
654 //----------------------------------------------------------------------------
655 void
656 VISU::Prs3d_i
657 ::SetPlaneParam(double theDir[3], 
658                 double theDist, 
659                 vtkPlane* thePlane) 
660 {
661   GetPipeLine()->SetPlaneParam(theDir, theDist, thePlane);
662 }
663
664
665 //----------------------------------------------------------------------------
666 void
667 VISU::Prs3d_i
668 ::GetBounds(double aBounds[6])
669 {
670   GetPipeLine()->GetMapper()->GetBounds(aBounds);
671 }
672
673 //----------------------------------------------------------------------------
674 void 
675 VISU::Prs3d_i
676 ::SetOffset(const CORBA::Float* theOffsets)
677 {
678   VISU::TSetModified aModified(this);
679   myOffset[0] = theOffsets[0];
680   myOffset[1] = theOffsets[1];
681   myOffset[2] = theOffsets[2];
682   myParamsTime.Modified();
683 }
684
685 //----------------------------------------------------------------------------
686 void
687 VISU::Prs3d_i
688 ::SetOffset(CORBA::Float theDx,
689             CORBA::Float theDy,
690             CORBA::Float theDz)
691 {
692   VISU::TSetModified aModified(this);
693   myOffset[0] = theDx;
694   myOffset[1] = theDy;
695   myOffset[2] = theDz;
696   myParamsTime.Modified();
697 }
698
699 //----------------------------------------------------------------------------
700 void
701 VISU::Prs3d_i
702 ::GetOffset(CORBA::Float* theOffsets)
703 {
704   theOffsets[0] = myOffset[0];
705   theOffsets[1] = myOffset[1];
706   theOffsets[2] = myOffset[2];
707 }
708
709 //----------------------------------------------------------------------------
710 void 
711 VISU::Prs3d_i
712 ::GetOffset(CORBA::Float& theDx,
713             CORBA::Float& theDy,
714             CORBA::Float& theDz)
715 {
716   theDx = myOffset[0];
717   theDy = myOffset[1];
718   theDz = myOffset[2];
719 }
720
721
722 //----------------------------------------------------------------------------
723 CORBA::Float
724 VISU::Prs3d_i
725 ::GetMemorySize()
726 {
727   // To calculate memory used by VISU PipeLine
728   CORBA::Float aSize = GetPipeLine()->GetMemorySize();
729   //cout<<"Prs3d_i::GetMemorySize - "<<this<<"; GetPipeLine = "<<aSize / (1024.0 * 1024.0)<<endl;
730
731   // To calculate memory used by VISU Actos
732   int anEnd = myActorCollection->GetNumberOfItems();
733   for(int anId = 0; anId < anEnd; anId++)
734     if(vtkObject* anObject = myActorCollection->GetItemAsObject(anId))
735       if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anObject)){
736         aSize += anActor->GetMemorySize();
737         //cout<<"Prs3d_i::GetMemorySize - "<<this<<"; anActor = "<<aSize / (1024.0 * 1024.0)<<endl;
738       }
739
740   // Convert to mega bytes
741   return aSize / (1024.0 * 1024.0);
742 }
743
744 int
745 VISU::Prs3d_i
746 ::GetNumberOfActors()
747 {
748   return myActorCollection->GetNumberOfItems();
749 }
750
751 bool
752 VISU::Prs3d_i
753 ::HasVisibleActors()
754 {
755   myActorCollection->InitTraversal();
756   while( vtkActor* anActor = myActorCollection->GetNextActor() )
757     if( VISU_Actor* aVISUActor = dynamic_cast<VISU_Actor*>( anActor ) )
758       if( aVISUActor->GetVisibility() )
759         return true;
760   return false;
761 }
762
763 bool
764 VISU::Prs3d_i
765 ::IsForcedHidden() const
766 {
767   return myIsForcedHidden;
768 }
769
770 void
771 VISU::Prs3d_i
772 ::SetForcedHidden( bool theFlag )
773 {
774   myIsForcedHidden = theFlag;
775 }
776
777 //----------------------------------------------------------------------------
778 void
779 VISU::Prs3d_i
780 ::SetMarkerStd(VISU::MarkerType theMarkerType, VISU::MarkerScale theMarkerScale)
781 {
782   myMarkerType = theMarkerType;
783   myMarkerScale = theMarkerScale;
784   if( myMarkerType == VISU::MT_POINT_SPRITE )
785     myMarkerScale = VISU::MS_NONE;
786   myParamsTime.Modified();
787 }
788   
789 //----------------------------------------------------------------------------
790 void
791 VISU::Prs3d_i
792 ::SetMarkerTexture(CORBA::Long theMarkerId)
793 {
794   myMarkerType = VISU::MT_USER;
795   myMarkerId = theMarkerId;
796   myParamsTime.Modified();
797 }
798   
799 //----------------------------------------------------------------------------
800 VISU::MarkerType
801 VISU::Prs3d_i
802 ::GetMarkerType()
803 {
804   return myMarkerType;
805 }
806
807 //----------------------------------------------------------------------------
808 VISU::MarkerScale
809 VISU::Prs3d_i
810 ::GetMarkerScale()
811 {
812   return myMarkerScale;
813 }
814
815 //----------------------------------------------------------------------------
816 CORBA::Long
817 VISU::Prs3d_i
818 ::GetMarkerTexture()
819 {
820   return myMarkerId;
821 }
822
823 //----------------------------------------------------------------------------
824 bool
825 VISU::Prs3d_i
826 ::LoadMarkerTexture(int theMarkerId, VTK::MarkerTexture& theMarkerTexture)
827 {
828   VISU::VISU_Gen_i* aVisuGen = VISU::VISU_Gen_i::GetVisuGenImpl();
829   if( !aVisuGen )
830     return false;
831
832   const VISU::StudyId2MarkerMap& aStudyId2MarkerMap = aVisuGen->GetMarkerMap();
833
834   const SALOMEDS::Study_var& aStudy = GetStudyDocument();
835   if( CORBA::is_nil( aStudy.in() ) )
836     return false;
837
838   int aStudyId = aStudy->StudyId();
839   VISU::StudyId2MarkerMap::const_iterator aStudyId2MarkerIter = aStudyId2MarkerMap.find( aStudyId );
840   if( aStudyId2MarkerIter == aStudyId2MarkerMap.end() )
841     return false;
842
843   VTK::MarkerMap aMarkerMap = aStudyId2MarkerIter->second;
844   VTK::MarkerMap::const_iterator aMarkerIter = aMarkerMap.find( theMarkerId );
845   if( aMarkerIter == aMarkerMap.end() )
846     return false;
847
848   theMarkerTexture = aMarkerIter->second.second;
849   return true;
850 }