1 // Created on: 2015-04-20
2 // Created by: Alexander Zaikin
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2015 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <TDataXtd_Presentation.hxx>
19 #include <TDF_DefaultDeltaOnRemoval.hxx>
20 #include <TDF_DefaultDeltaOnModification.hxx>
21 #include <TDF_DeltaOnAddition.hxx>
22 #include <TDF_Tool.hxx>
23 #include <TCollection_ExtendedString.hxx>
25 IMPLEMENT_STANDARD_RTTIEXT(TDataXtd_Presentation,TDF_Attribute)
27 //=======================================================================
28 //function : TDataXtd_Presentation
29 //purpose : Default constructor.
30 //=======================================================================
31 TDataXtd_Presentation::TDataXtd_Presentation()
32 : myDriverGUID ("00000000-0000-0000-0000-000000000000"),
33 myColor (Quantity_NOC_WHITE),
39 myIsDisplayed (Standard_False),
40 myHasOwnColor (Standard_False),
41 myHasOwnMaterial (Standard_False),
42 myHasOwnTransparency (Standard_False),
43 myHasOwnWidth (Standard_False),
44 myHasOwnMode (Standard_False),
45 myHasOwnSelectionMode (Standard_False)
49 //=======================================================================
52 //=======================================================================
53 Handle(TDataXtd_Presentation) TDataXtd_Presentation::Set (const TDF_Label& theLabel,
54 const Standard_GUID& theDriverId)
56 Handle(TDataXtd_Presentation) aPresentation;
58 if ( !theLabel.FindAttribute(TDataXtd_Presentation::GetID(), aPresentation) )
60 aPresentation = new TDataXtd_Presentation();
61 theLabel.AddAttribute(aPresentation);
64 aPresentation->SetDriverGUID(theDriverId);
68 //=======================================================================
71 //=======================================================================
72 void TDataXtd_Presentation::Unset(const TDF_Label& theLabel)
74 Handle(TDataXtd_Presentation) aPresentation;
75 if (theLabel.FindAttribute(TDataXtd_Presentation::GetID(), aPresentation))
76 theLabel.ForgetAttribute(aPresentation);
80 //=======================================================================
83 //=======================================================================
84 const Standard_GUID& TDataXtd_Presentation::GetID()
86 static Standard_GUID TDataXtd_PresentationID("04fb4d00-5690-11d1-8940-080009dc3333");
87 return TDataXtd_PresentationID;
91 //=======================================================================
94 //=======================================================================
95 const Standard_GUID& TDataXtd_Presentation::ID() const
101 //=======================================================================
102 //function :GetDriverGUID
104 //=======================================================================
105 Standard_GUID TDataXtd_Presentation::GetDriverGUID() const
111 //=======================================================================
112 //function :SetDriverGUID
114 //=======================================================================
115 void TDataXtd_Presentation::SetDriverGUID(const Standard_GUID& theGUID)
117 if ( myDriverGUID != theGUID )
120 myDriverGUID = theGUID;
125 //=======================================================================
126 //function : IsDisplayed
128 //=======================================================================
129 Standard_Boolean TDataXtd_Presentation::IsDisplayed() const
131 return myIsDisplayed;
135 //=======================================================================
136 //function : HasOwnMaterial
138 //=======================================================================
139 Standard_Boolean TDataXtd_Presentation::HasOwnMaterial() const
141 return myHasOwnMaterial;
145 //=======================================================================
146 //function : HasOwnTransparency
148 //=======================================================================
149 Standard_Boolean TDataXtd_Presentation::HasOwnTransparency() const
151 return myHasOwnTransparency;
155 //=======================================================================
156 //function : HasOwnColor
158 //=======================================================================
159 Standard_Boolean TDataXtd_Presentation::HasOwnColor() const
161 return myHasOwnColor;
165 //=======================================================================
166 //function : HasOwnWidth
168 //=======================================================================
169 Standard_Boolean TDataXtd_Presentation::HasOwnWidth() const
171 return myHasOwnWidth;
175 //=======================================================================
176 //function : HasOwnMode
178 //=======================================================================
179 Standard_Boolean TDataXtd_Presentation::HasOwnMode() const
185 //=======================================================================
186 //function : HasOwnSelectionMode
188 //=======================================================================
189 Standard_Boolean TDataXtd_Presentation::HasOwnSelectionMode() const
191 return myHasOwnSelectionMode;
195 //=======================================================================
196 //function : SetDisplayed
198 //=======================================================================
199 void TDataXtd_Presentation::SetDisplayed(const Standard_Boolean theIsDisplayed)
201 if (myIsDisplayed != theIsDisplayed)
204 myIsDisplayed = theIsDisplayed;
209 //=======================================================================
210 //function : SetMaterialIndex
212 //=======================================================================
213 void TDataXtd_Presentation::SetMaterialIndex(const Standard_Integer theMaterialIndex)
215 if (! myHasOwnMaterial || myMaterialIndex != theMaterialIndex)
218 myMaterialIndex = theMaterialIndex;
219 myHasOwnMaterial = Standard_True;
224 //=======================================================================
225 //function : SetTransparency
227 //=======================================================================
228 void TDataXtd_Presentation::SetTransparency(const Standard_Real theValue)
230 if (! myHasOwnTransparency || myTransparency != theValue)
233 myTransparency = theValue;
234 myHasOwnTransparency = Standard_True;
239 //=======================================================================
240 //function : SetColor
242 //=======================================================================
243 void TDataXtd_Presentation::SetColor(const Quantity_NameOfColor theColor)
245 if (! myHasOwnColor || myColor != theColor)
249 myHasOwnColor = Standard_True;
254 //=======================================================================
255 //function : SetWidth
257 //=======================================================================
258 void TDataXtd_Presentation::SetWidth(const Standard_Real theWidth)
260 if (! myHasOwnWidth || myWidth != theWidth)
264 myHasOwnWidth = Standard_True;
269 //=======================================================================
272 //=======================================================================
273 void TDataXtd_Presentation::SetMode(const Standard_Integer theMode)
275 if (! myHasOwnMode || myMode != theMode)
279 myHasOwnMode = Standard_True;
284 //=======================================================================
285 //function : SetSelectionMode
287 //=======================================================================
288 void TDataXtd_Presentation::SetSelectionMode(const Standard_Integer theSelectionMode)
290 if (! myHasOwnSelectionMode || mySelectionMode != theSelectionMode)
293 mySelectionMode = theSelectionMode;
294 myHasOwnSelectionMode = Standard_True;
299 //=======================================================================
300 //function : MaterialIndex
302 //=======================================================================
303 Standard_Integer TDataXtd_Presentation::MaterialIndex() const
305 return myMaterialIndex;
309 //=======================================================================
310 //function : Transparency
312 //=======================================================================
313 Standard_Real TDataXtd_Presentation::Transparency() const
315 return myTransparency;
319 //=======================================================================
322 //=======================================================================
323 Quantity_NameOfColor TDataXtd_Presentation::Color() const
329 //=======================================================================
332 //=======================================================================
333 Standard_Real TDataXtd_Presentation::Width() const
339 //=======================================================================
342 //=======================================================================
343 Standard_Integer TDataXtd_Presentation::Mode() const
349 //=======================================================================
350 //function : SelectionMode
352 //=======================================================================
353 Standard_Integer TDataXtd_Presentation::SelectionMode() const
355 return mySelectionMode;
359 //=======================================================================
360 //function : UnsetMaterial
362 //=======================================================================
363 void TDataXtd_Presentation::UnsetMaterial()
365 if (myHasOwnMaterial)
368 myHasOwnMaterial = Standard_False;
373 //=======================================================================
374 //function : UnsetTransparency
376 //=======================================================================
377 void TDataXtd_Presentation::UnsetTransparency()
379 if (myHasOwnTransparency)
382 myHasOwnTransparency = Standard_False;
387 //=======================================================================
388 //function : UnsetColor
390 //=======================================================================
391 void TDataXtd_Presentation::UnsetColor()
396 myHasOwnColor = Standard_False;
401 //=======================================================================
402 //function : UnsetWidth
404 //=======================================================================
405 void TDataXtd_Presentation::UnsetWidth()
410 myHasOwnWidth = Standard_False;
415 //=======================================================================
416 //function : UnsetMode
418 //=======================================================================
419 void TDataXtd_Presentation::UnsetMode()
424 myHasOwnMode = Standard_False;
429 //=======================================================================
430 //function : UnsetSelectionMode
432 //=======================================================================
433 void TDataXtd_Presentation::UnsetSelectionMode()
435 if (myHasOwnSelectionMode)
438 myHasOwnSelectionMode = Standard_False;
443 //=======================================================================
444 //function : BackupCopy
446 //=======================================================================
447 Handle(TDF_Attribute) TDataXtd_Presentation::BackupCopy() const
449 Handle(TDataXtd_Presentation) aCopy = new TDataXtd_Presentation;
451 aCopy->myIsDisplayed = myIsDisplayed;
452 aCopy->myDriverGUID = myDriverGUID;
453 aCopy->mySelectionMode = mySelectionMode;
454 aCopy->myTransparency = myTransparency;
455 aCopy->myColor = myColor;
456 aCopy->myMode = myMode;
457 aCopy->myWidth = myWidth;
458 aCopy->myMaterialIndex = myMaterialIndex;
460 aCopy->myHasOwnColor = myHasOwnColor;
461 aCopy->myHasOwnMaterial = myHasOwnMaterial;
462 aCopy->myHasOwnWidth = myHasOwnWidth;
463 aCopy->myHasOwnMode = myHasOwnMode;
464 aCopy->myHasOwnTransparency = myHasOwnTransparency;
465 aCopy->myHasOwnSelectionMode = myHasOwnSelectionMode;
471 //=======================================================================
472 //function : NewEmpty
474 //=======================================================================
475 Handle(TDF_Attribute) TDataXtd_Presentation::NewEmpty() const
477 return new TDataXtd_Presentation();
481 //=======================================================================
484 //=======================================================================
485 void TDataXtd_Presentation::Restore(const Handle(TDF_Attribute)& theAttribute)
487 Handle(TDataXtd_Presentation) aPresentation =
488 Handle(TDataXtd_Presentation)::DownCast(theAttribute);
490 myHasOwnMaterial = aPresentation->HasOwnMaterial();
491 myMaterialIndex = aPresentation->MaterialIndex();
493 myHasOwnColor = aPresentation->HasOwnColor();
494 myColor = aPresentation->Color();
496 myHasOwnWidth = aPresentation->HasOwnWidth();
497 myWidth = aPresentation->Width();
499 myHasOwnMode = aPresentation->HasOwnMode();
500 myMode = aPresentation->Mode();
502 myHasOwnSelectionMode = aPresentation->HasOwnSelectionMode();
503 mySelectionMode = aPresentation->SelectionMode();
505 myHasOwnTransparency = aPresentation->HasOwnTransparency();
506 myTransparency = aPresentation->Transparency();
508 myIsDisplayed = aPresentation->IsDisplayed();
509 myDriverGUID = aPresentation->GetDriverGUID();
513 //=======================================================================
516 //=======================================================================
517 void TDataXtd_Presentation::Paste(const Handle(TDF_Attribute)& theInto,
518 const Handle(TDF_RelocationTable)&) const
520 Handle(TDataXtd_Presentation) anInto =
521 Handle(TDataXtd_Presentation)::DownCast(theInto);
525 if (myHasOwnMaterial)
527 anInto->myMaterialIndex = myMaterialIndex;
528 anInto->myHasOwnMaterial = Standard_True;
532 anInto->myHasOwnMaterial = Standard_False;
537 anInto->myColor = myColor;
538 anInto->myHasOwnColor = Standard_True;
542 anInto->myHasOwnColor = Standard_False;
547 anInto->myWidth = myWidth;
548 anInto->myHasOwnWidth = Standard_True;
552 anInto->myHasOwnWidth = Standard_False;
557 anInto->myMode = myMode;
558 anInto->myHasOwnMode = Standard_True;
562 anInto->myHasOwnMode = Standard_False;
565 if (myHasOwnSelectionMode)
567 anInto->mySelectionMode = mySelectionMode;
568 anInto->myHasOwnSelectionMode = Standard_True;
572 anInto->myHasOwnSelectionMode = Standard_False;
575 if (myHasOwnTransparency)
577 anInto->myTransparency = myTransparency;
578 anInto->myHasOwnTransparency = Standard_True;
582 anInto->myHasOwnTransparency = Standard_False;
585 anInto->myIsDisplayed = myIsDisplayed;
586 anInto->myDriverGUID = myDriverGUID;