1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 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 // File : VISU_ColoredPrs3dHolder_i.cc
24 // Author : Oleg UVAROV
27 #include "VISU_ColoredPrs3dHolder_i.hh"
29 #include "VISU_ColoredPrs3dCache_i.hh"
30 #include "VISU_ColoredPrs3d_i.hh"
32 #include "SALOME_Event.hxx"
38 static int MYDEBUG = 0;
40 static int MYDEBUG = 0;
43 //---------------------------------------------------------------
44 int VISU::ColoredPrs3dHolder_i::myNbHolders = 0;
46 //---------------------------------------------------------------
48 VISU::ColoredPrs3dHolder_i
51 return VISU::GenerateName("Holder",myNbHolders++);
54 //----------------------------------------------------------------------------
55 const string VISU::ColoredPrs3dHolder_i::myComment = "COLOREDPRS3DHOLDER";
58 VISU::ColoredPrs3dHolder_i
61 return myComment.c_str();
65 //----------------------------------------------------------------------------
66 VISU::ColoredPrs3dHolder_i
67 ::ColoredPrs3dHolder_i(VISU::ColoredPrs3dCache_i& theCache) :
68 PrsObject_i(theCache.GetStudyDocument()),
71 if(MYDEBUG) MESSAGE("ColoredPrs3dHolder_i::ColoredPrs3dHolder_i - this = "<<this);
75 //----------------------------------------------------------------------------
76 VISU::ColoredPrs3dHolder_i
77 ::~ColoredPrs3dHolder_i()
79 if(MYDEBUG) MESSAGE("ColoredPrs3dHolder_i::~ColoredPrs3dHolder_i - this = "<<this);
83 //----------------------------------------------------------------------------
85 VISU::ColoredPrs3dHolder_i
86 ::PublishInStudy(const std::string& theName,
87 const std::string& theIconName,
88 const std::string& theComment)
90 SetName(theName, false);
91 CORBA::String_var anIOR = GetID();
92 std::string aFatherEntry = myCache.GetEntry();
93 CreateAttributes(GetStudyDocument(),
103 //----------------------------------------------------------------------------
104 struct TApplyEvent: public SALOME_Event
106 VISU::ColoredPrs3dCache_i& myCache;
107 VISU::ColoredPrs3dHolder_i* myHolder;
108 VISU::ColoredPrs3d_i* myPrs3d;
109 VISU::ColoredPrs3dHolder::BasicInput myInput;
110 VISU::View3D_ptr myView3D;
112 typedef CORBA::Boolean TResult;
115 TApplyEvent(VISU::ColoredPrs3dCache_i& theCache,
116 VISU::ColoredPrs3dHolder_i* theHolder,
117 VISU::ColoredPrs3d_i* thePrs3d,
118 VISU::ColoredPrs3dHolder::BasicInput theInput,
119 VISU::View3D_ptr theView3D):
131 myResult = myCache.UpdateLastVisitedPrs(myHolder, myPrs3d, myInput, myView3D);
135 //----------------------------------------------------------------------------
137 VISU::ColoredPrs3dHolder_i
138 ::Apply(VISU::ColoredPrs3d_ptr thePrs3d,
139 const VISU::ColoredPrs3dHolder::BasicInput& theInput,
140 VISU::View3D_ptr theView3D)
143 VISU::ColoredPrs3d_i* aPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>( VISU::GetServant(thePrs3d).in() );
144 return ProcessEvent(new TApplyEvent(myCache, this, aPrs3d, theInput, theView3D));
145 //return myCache.UpdateLastVisitedPrs(this, aPrs3d, theInput, theView3D);
148 //----------------------------------------------------------------------------
149 VISU::ColoredPrs3d_i*
150 VISU::ColoredPrs3dHolder_i
154 return myCache.GetLastVisitedPrs(this);
161 VISU::ColoredPrs3d_ptr
162 VISU::ColoredPrs3dHolder_i
165 if( VISU::ColoredPrs3d_i* aDevice = GetPrs3dDevice() )
166 return aDevice->_this();
168 return VISU::ColoredPrs3d::_nil();
172 //----------------------------------------------------------------------------
173 VISU::ColoredPrs3dHolder::TimeStampsRange*
174 VISU::ColoredPrs3dHolder_i
175 ::GetTimeStampsRange()
177 if( VISU::ColoredPrs3d_i* aDevice = GetPrs3dDevice() )
178 return aDevice->GetTimeStampsRange();
184 //----------------------------------------------------------------------------
185 VISU::ColoredPrs3dHolder::BasicInput*
186 VISU::ColoredPrs3dHolder_i
189 if( VISU::ColoredPrs3d_ptr aDevice = GetDevice() )
191 VISU::ColoredPrs3d_i* aPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>( VISU::GetServant(aDevice).in() );
193 return aPrs3d->GetBasicInput();
200 //----------------------------------------------------------------------------
201 VISU::ColoredPrs3dCache_ptr
202 VISU::ColoredPrs3dHolder_i
205 return myCache._this();
209 //----------------------------------------------------------------------------
211 VISU::ColoredPrs3dHolder_i
214 return GetDevice()->GetMemorySize();
218 //----------------------------------------------------------------------------
220 VISU::ColoredPrs3dHolder_i
223 return GetPrs3dDevice()->GetType();
226 //----------------------------------------------------------------------------
228 VISU::ColoredPrs3dHolder_i
231 myCache.RemoveHolder(this);
232 CORBA::String_var anIOR = GetID();
233 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectIOR(anIOR.in());
234 VISU::RemoveFromStudy(aSObject, false);
238 //----------------------------------------------------------------------------
240 VISU::ColoredPrs3dHolder_i
241 ::ToStream(std::ostringstream& theStr)
243 Storable::DataToStream( theStr, "myPrsType", GetPrsType() );
244 GetPrs3dDevice()->ToStream(theStr);
247 //---------------------------------------------------------------
249 VISU::ColoredPrs3dHolder_i
250 ::StorableEngine(SALOMEDS::SObject_ptr theSObject,
251 const Storable::TRestoringMap& theMap,
252 const std::string& thePrefix,
253 CORBA::Boolean theIsMultiFile)
255 using namespace VISU;
256 SALOMEDS::Study_var aStudy = theSObject->GetStudy();
257 VISUType aType = VISUType(Storable::FindValue(theMap,"myPrsType").toInt());
258 if(ColoredPrs3d_i* aColoredPrs3d = CreatePrs3d_i(aType, aStudy, ColoredPrs3d_i::EDoNotPublish)){
259 if(ColoredPrs3dCache_i* aCache = ColoredPrs3dCache_i::GetInstance_i(aStudy))
260 if(ColoredPrs3dHolder_i* aHolder = new ColoredPrs3dHolder_i(*aCache)){
261 // To postpone restoring of the device
262 aColoredPrs3d->SaveRestoringState(theSObject, theMap);
263 CORBA::String_var anEntry = theSObject->GetID();
264 aCache->RegisterInHolder(aColoredPrs3d, anEntry.in());