1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISU_ColoredPrs3dCache_i.hh
25 // Author : Oleg UVAROV
28 #ifndef VISU_ColoredPrs3dCache_i_HeaderFile
29 #define VISU_ColoredPrs3dCache_i_HeaderFile
33 #include "VISU_ColoredPrs3dFactory.hh"
35 #include "SALOME_GenericObjPointer.hh"
41 class ColoredPrs3dHolder_i;
43 struct TPrs3dPtr: SALOME::GenericObjPtr<ColoredPrs3d_i>
45 typedef SALOME::GenericObjPtr<ColoredPrs3d_i> TSuperClass;
47 //! Initialize smart pointer to NULL.
52 //! Initialize smart pointer to given object (TSGenericObj must be complete).
53 TPrs3dPtr(ColoredPrs3d_i* thePointer):
54 TSuperClass(thePointer)
58 Initialize smart pointer with a new reference to the same object
59 referenced by given smart pointer.
61 TPrs3dPtr(const TPrs3dPtr& thePointer):
62 TSuperClass(thePointer)
67 Assign object to reference. This removes any reference to an old
71 operator=(const TPrs3dPtr& thePointer)
73 TSuperClass::operator=(thePointer);
78 Assign object to reference. This removes any reference to an old
82 operator=(ColoredPrs3d_i* thePointer)
84 TSuperClass::operator=(thePointer);
88 //! Get the contained pointer.
92 ColoredPrs3d_i* aColoredPrs3d = TSuperClass::get();
93 // To implement postponed restoring of the presentation
95 aColoredPrs3d->InitFromRestoringState();
100 typedef std::deque<TPrs3dPtr> TLastVisitedPrsList;
102 typedef std::string THolderEntry;
103 typedef std::map<THolderEntry,TLastVisitedPrsList> TColoredPrs3dHolderMap;
106 * This interface is responsible for memory management of 3d presentations.
107 * One cache corresponds to one study.
109 class VISU_I_EXPORT ColoredPrs3dCache_i : public virtual POA_VISU::ColoredPrs3dCache,
110 public virtual SALOME::GenericObj_i,
111 public virtual RemovableObject_i
113 ColoredPrs3dCache_i();
114 ColoredPrs3dCache_i(const ColoredPrs3dCache_i&);
116 //----------------------------------------------------------------------------
117 //! A constructor to create an instance of the class
119 ColoredPrs3dCache_i(SALOMEDS::Study_ptr theStudy,
120 bool thePublishInStudy = true);
123 ~ColoredPrs3dCache_i();
125 //----------------------------------------------------------------------------
126 /*! Creates ColoredPrs3dHolder */
128 VISU::ColoredPrs3dHolder_ptr
129 CreateHolder(VISU::VISUType theType,
130 const VISU::ColoredPrs3dHolder::BasicInput& theInput);
132 //----------------------------------------------------------------------------
133 /*! Gets a memory which is required to create a holder. */
135 VISU::ColoredPrs3dCache::EnlargeType
136 GetRequiredMemory(VISU::VISUType theType,
137 const VISU::ColoredPrs3dHolder::BasicInput& theInput,
138 CORBA::Float& theRequiredMemory);
140 //----------------------------------------------------------------------------
141 //! Sets a memory mode.
144 SetMemoryMode(VISU::ColoredPrs3dCache::MemoryMode theMode);
147 VISU::ColoredPrs3dCache::MemoryMode
150 //----------------------------------------------------------------------------
151 //! Sets a memory size for limited mode.
154 SetLimitedMemory(CORBA::Float theMemorySize);
166 GetDeviceMemorySize();
168 //----------------------------------------------------------------------------
173 return VISU::TCOLOREDPRS3DCACHE;
190 ToStream(std::ostringstream&);
194 Restore(SALOMEDS::SObject_ptr theSObject,
195 const Storable::TRestoringMap& theMap);
199 StorableEngine(SALOMEDS::SObject_ptr theSObject,
200 const Storable::TRestoringMap& theMap,
201 const std::string& thePrefix,
202 CORBA::Boolean theIsMultiFile);
204 //----------------------------------------------------------------------------
205 //! Finds or creates instance of the ColoredPrs3dCache in the given SALOMEDS::Study
207 VISU::ColoredPrs3dCache_i*
208 GetInstance_i(SALOMEDS::Study_ptr theStudy);
211 VISU::ColoredPrs3dCache_ptr
212 GetInstance(SALOMEDS::Study_ptr theStudy);
214 //! Creates corresponding ColoredPrs3d instance and apply the BasicInput
215 VISU::ColoredPrs3d_i*
216 CreateColoredPrs3d(VISU::VISUType theType,
217 VISU::ColoredPrs3dHolder::BasicInput theInput);
219 //! Registers the given ColoredPrs3d instance for the ColoredPrs3dHolder
220 VISU::ColoredPrs3d_i*
221 RegisterInHolder(VISU::ColoredPrs3d_i* thePrs3d,
222 const std::string& theHolderEntry);
224 //! Creates and registers corresponding ColoredPrs3d instance for the ColoredPrs3dHolder
225 VISU::ColoredPrs3d_i*
226 CreatePrs(VISU::VISUType theType,
227 VISU::ColoredPrs3dHolder::BasicInput theInput,
228 VISU::ColoredPrs3dHolder_i* theHolder);
231 GetLastVisitedPrsList(VISU::ColoredPrs3dHolder_i* theHolder);
234 GetLastVisitedPrs(VISU::ColoredPrs3dHolder_i* theHolder);
237 UpdateLastVisitedPrs(VISU::ColoredPrs3dHolder_i* theHolder,
238 VISU::ColoredPrs3d_i* thePrs,
239 const VISU::ColoredPrs3dHolder::BasicInput& theInput,
240 VISU::View3D_ptr theView3D);
242 //! Unregister the holder instance from cache
244 RemoveHolder(VISU::ColoredPrs3dHolder_i* theHolder);
247 static const std::string myComment;
250 //----------------------------------------------------------------------------
252 IsPossible(VISU::VISUType theType,
253 const VISU::ColoredPrs3dHolder::BasicInput& theInput,
254 float& theMemoryToClear,
255 const std::string theHolderEntry);
258 FindPrsByInput(TLastVisitedPrsList& theLastVisitedPrsList,
259 const VISU::ColoredPrs3dHolder::BasicInput& theInput);
261 //----------------------------------------------------------------------------
263 ClearCache(float theMemory = 0);
266 ClearMemory(CORBA::Float theRequiredMemory,
267 const std::string& theHolderEntry);
273 CORBA::Float myLimitedMemory;
274 VISU::ColoredPrs3dCache::MemoryMode myMemoryMode;
276 TColoredPrs3dHolderMap myHolderMap;
280 //----------------------------------------------------------------------------