0029940: The method TPrsStd_AISPresentation::SetSelectionMode() seems useless for...
[occt.git] / src / TDataXtd / TDataXtd_Presentation.cxx
CommitLineData
f47afe53 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
5//
6// This file is part of Open CASCADE Technology software library.
7//
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#include <TDataXtd_Presentation.hxx>
18
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>
24
25IMPLEMENT_STANDARD_RTTIEXT(TDataXtd_Presentation,TDF_Attribute)
26
27//=======================================================================
28//function : TDataXtd_Presentation
29//purpose : Default constructor.
30//=======================================================================
31TDataXtd_Presentation::TDataXtd_Presentation()
32: myDriverGUID ("00000000-0000-0000-0000-000000000000"),
33 myColor (Quantity_NOC_WHITE),
34 myMaterialIndex (0),
35 myMode (0),
36 mySelectionMode (0),
37 myTransparency (0.0),
38 myWidth (0.0),
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)
46{}
47
48
49//=======================================================================
50//function : Set
51//purpose :
52//=======================================================================
53Handle(TDataXtd_Presentation) TDataXtd_Presentation::Set (const TDF_Label& theLabel,
54 const Standard_GUID& theDriverId)
55{
56 Handle(TDataXtd_Presentation) aPresentation;
57
58 if ( !theLabel.FindAttribute(TDataXtd_Presentation::GetID(), aPresentation) )
59 {
60 aPresentation = new TDataXtd_Presentation();
61 theLabel.AddAttribute(aPresentation);
62 }
63
64 aPresentation->SetDriverGUID(theDriverId);
65 return aPresentation;
66}
67
68//=======================================================================
69//function : Unset
70//purpose :
71//=======================================================================
72void TDataXtd_Presentation::Unset(const TDF_Label& theLabel)
73{
74 Handle(TDataXtd_Presentation) aPresentation;
75 if (theLabel.FindAttribute(TDataXtd_Presentation::GetID(), aPresentation))
76 theLabel.ForgetAttribute(aPresentation);
77}
78
79
80//=======================================================================
81//function : GetID
82//purpose :
83//=======================================================================
84const Standard_GUID& TDataXtd_Presentation::GetID()
85{
86 static Standard_GUID TDataXtd_PresentationID("04fb4d00-5690-11d1-8940-080009dc3333");
87 return TDataXtd_PresentationID;
88}
89
90
91//=======================================================================
92//function : ID
93//purpose :
94//=======================================================================
95const Standard_GUID& TDataXtd_Presentation::ID() const
96{
97 return GetID();
98}
99
100
101//=======================================================================
102//function :GetDriverGUID
103//purpose :
104//=======================================================================
105Standard_GUID TDataXtd_Presentation::GetDriverGUID() const
106{
107 return myDriverGUID;
108}
109
110
111//=======================================================================
112//function :SetDriverGUID
113//purpose :
114//=======================================================================
115void TDataXtd_Presentation::SetDriverGUID(const Standard_GUID& theGUID)
116{
117 if ( myDriverGUID != theGUID )
118 {
119 Backup();
120 myDriverGUID = theGUID;
121 }
122}
123
124
125//=======================================================================
126//function : IsDisplayed
127//purpose :
128//=======================================================================
129Standard_Boolean TDataXtd_Presentation::IsDisplayed() const
130{
131 return myIsDisplayed;
132}
133
134
135//=======================================================================
136//function : HasOwnMaterial
137//purpose :
138//=======================================================================
139Standard_Boolean TDataXtd_Presentation::HasOwnMaterial() const
140{
141 return myHasOwnMaterial;
142}
143
144
145//=======================================================================
146//function : HasOwnTransparency
147//purpose :
148//=======================================================================
149Standard_Boolean TDataXtd_Presentation::HasOwnTransparency() const
150{
151 return myHasOwnTransparency;
152}
153
154
155//=======================================================================
156//function : HasOwnColor
157//purpose :
158//=======================================================================
159Standard_Boolean TDataXtd_Presentation::HasOwnColor() const
160{
161 return myHasOwnColor;
162}
163
164
165//=======================================================================
166//function : HasOwnWidth
167//purpose :
168//=======================================================================
169Standard_Boolean TDataXtd_Presentation::HasOwnWidth() const
170{
171 return myHasOwnWidth;
172}
173
174
175//=======================================================================
176//function : HasOwnMode
177//purpose :
178//=======================================================================
179Standard_Boolean TDataXtd_Presentation::HasOwnMode() const
180{
181 return myHasOwnMode;
182}
183
184
185//=======================================================================
186//function : HasOwnSelectionMode
187//purpose :
188//=======================================================================
189Standard_Boolean TDataXtd_Presentation::HasOwnSelectionMode() const
190{
191 return myHasOwnSelectionMode;
192}
193
194
195//=======================================================================
196//function : SetDisplayed
197//purpose :
198//=======================================================================
199void TDataXtd_Presentation::SetDisplayed(const Standard_Boolean theIsDisplayed)
200{
201 if (myIsDisplayed != theIsDisplayed)
202 {
203 Backup();
204 myIsDisplayed = theIsDisplayed;
205 }
206}
207
208
209//=======================================================================
210//function : SetMaterialIndex
211//purpose :
212//=======================================================================
213void TDataXtd_Presentation::SetMaterialIndex(const Standard_Integer theMaterialIndex)
214{
215 if (! myHasOwnMaterial || myMaterialIndex != theMaterialIndex)
216 {
217 Backup();
218 myMaterialIndex = theMaterialIndex;
219 myHasOwnMaterial = Standard_True;
220 }
221}
222
223
224//=======================================================================
225//function : SetTransparency
226//purpose :
227//=======================================================================
228void TDataXtd_Presentation::SetTransparency(const Standard_Real theValue)
229{
230 if (! myHasOwnTransparency || myTransparency != theValue)
231 {
232 Backup();
233 myTransparency = theValue;
234 myHasOwnTransparency = Standard_True;
235 }
236}
237
238
239//=======================================================================
240//function : SetColor
241//purpose :
242//=======================================================================
243void TDataXtd_Presentation::SetColor(const Quantity_NameOfColor theColor)
244{
245 if (! myHasOwnColor || myColor != theColor)
246 {
247 Backup();
248 myColor = theColor;
249 myHasOwnColor = Standard_True;
250 }
251}
252
253
254//=======================================================================
255//function : SetWidth
256//purpose :
257//=======================================================================
258void TDataXtd_Presentation::SetWidth(const Standard_Real theWidth)
259{
260 if (! myHasOwnWidth || myWidth != theWidth)
261 {
262 Backup();
263 myWidth = theWidth;
264 myHasOwnWidth = Standard_True;
265 }
266}
267
268
269//=======================================================================
270//function : SetMode
271//purpose :
272//=======================================================================
273void TDataXtd_Presentation::SetMode(const Standard_Integer theMode)
274{
275 if (! myHasOwnMode || myMode != theMode)
276 {
277 Backup();
278 myMode = theMode;
279 myHasOwnMode = Standard_True;
280 }
281}
282
283
284//=======================================================================
285//function : SetSelectionMode
286//purpose :
287//=======================================================================
31e8d3c1 288void TDataXtd_Presentation::SetSelectionMode(const Standard_Integer theSelectionMode, const Standard_Boolean theTransaction)
f47afe53 289{
290 if (! myHasOwnSelectionMode || mySelectionMode != theSelectionMode)
291 {
31e8d3c1 292 if (theTransaction)
293 Backup();
f47afe53 294 mySelectionMode = theSelectionMode;
295 myHasOwnSelectionMode = Standard_True;
296 }
297}
298
299
300//=======================================================================
301//function : MaterialIndex
302//purpose :
303//=======================================================================
304Standard_Integer TDataXtd_Presentation::MaterialIndex() const
305{
306 return myMaterialIndex;
307}
308
309
310//=======================================================================
311//function : Transparency
312//purpose :
313//=======================================================================
314Standard_Real TDataXtd_Presentation::Transparency() const
315{
316 return myTransparency;
317}
318
319
320//=======================================================================
321//function : Color
322//purpose :
323//=======================================================================
324Quantity_NameOfColor TDataXtd_Presentation::Color() const
325{
326 return myColor;
327}
328
329
330//=======================================================================
331//function : Width
332//purpose :
333//=======================================================================
334Standard_Real TDataXtd_Presentation::Width() const
335{
336 return myWidth;
337}
338
339
340//=======================================================================
341//function : Mode
342//purpose :
343//=======================================================================
344Standard_Integer TDataXtd_Presentation::Mode() const
345{
346 return myMode;
347}
348
349
350//=======================================================================
351//function : SelectionMode
352//purpose :
353//=======================================================================
354Standard_Integer TDataXtd_Presentation::SelectionMode() const
355{
356 return mySelectionMode;
357}
358
359
360//=======================================================================
361//function : UnsetMaterial
362//purpose :
363//=======================================================================
364void TDataXtd_Presentation::UnsetMaterial()
365{
366 if (myHasOwnMaterial)
367 {
368 Backup();
369 myHasOwnMaterial = Standard_False;
370 }
371}
372
373
374//=======================================================================
375//function : UnsetTransparency
376//purpose :
377//=======================================================================
378void TDataXtd_Presentation::UnsetTransparency()
379{
380 if (myHasOwnTransparency)
381 {
382 Backup();
383 myHasOwnTransparency = Standard_False;
384 }
385}
386
387
388//=======================================================================
389//function : UnsetColor
390//purpose :
391//=======================================================================
392void TDataXtd_Presentation::UnsetColor()
393{
394 if (myHasOwnColor)
395 {
396 Backup();
397 myHasOwnColor = Standard_False;
398 }
399}
400
401
402//=======================================================================
403//function : UnsetWidth
404//purpose :
405//=======================================================================
406void TDataXtd_Presentation::UnsetWidth()
407{
408 if (myHasOwnWidth)
409 {
410 Backup();
411 myHasOwnWidth = Standard_False;
412 }
413}
414
415
416//=======================================================================
417//function : UnsetMode
418//purpose :
419//=======================================================================
420void TDataXtd_Presentation::UnsetMode()
421{
422 if (myHasOwnMode)
423 {
424 Backup();
425 myHasOwnMode = Standard_False;
426 }
427}
428
429
430//=======================================================================
431//function : UnsetSelectionMode
432//purpose :
433//=======================================================================
434void TDataXtd_Presentation::UnsetSelectionMode()
435{
436 if (myHasOwnSelectionMode)
437 {
438 Backup();
439 myHasOwnSelectionMode = Standard_False;
440 }
441}
442
443
444//=======================================================================
445//function : BackupCopy
446//purpose :
447//=======================================================================
448Handle(TDF_Attribute) TDataXtd_Presentation::BackupCopy() const
449{
450 Handle(TDataXtd_Presentation) aCopy = new TDataXtd_Presentation;
451
452 aCopy->myIsDisplayed = myIsDisplayed;
453 aCopy->myDriverGUID = myDriverGUID;
454 aCopy->mySelectionMode = mySelectionMode;
455 aCopy->myTransparency = myTransparency;
456 aCopy->myColor = myColor;
457 aCopy->myMode = myMode;
458 aCopy->myWidth = myWidth;
459 aCopy->myMaterialIndex = myMaterialIndex;
460
461 aCopy->myHasOwnColor = myHasOwnColor;
462 aCopy->myHasOwnMaterial = myHasOwnMaterial;
463 aCopy->myHasOwnWidth = myHasOwnWidth;
464 aCopy->myHasOwnMode = myHasOwnMode;
465 aCopy->myHasOwnTransparency = myHasOwnTransparency;
466 aCopy->myHasOwnSelectionMode = myHasOwnSelectionMode;
467
468 return aCopy;
469}
470
471
472//=======================================================================
473//function : NewEmpty
474//purpose :
475//=======================================================================
476Handle(TDF_Attribute) TDataXtd_Presentation::NewEmpty() const
477{
478 return new TDataXtd_Presentation();
479}
480
481
482//=======================================================================
483//function : Restore
484//purpose :
485//=======================================================================
486void TDataXtd_Presentation::Restore(const Handle(TDF_Attribute)& theAttribute)
487{
488 Handle(TDataXtd_Presentation) aPresentation =
489 Handle(TDataXtd_Presentation)::DownCast(theAttribute);
490
491 myHasOwnMaterial = aPresentation->HasOwnMaterial();
492 myMaterialIndex = aPresentation->MaterialIndex();
493
494 myHasOwnColor = aPresentation->HasOwnColor();
495 myColor = aPresentation->Color();
496
497 myHasOwnWidth = aPresentation->HasOwnWidth();
498 myWidth = aPresentation->Width();
499
500 myHasOwnMode = aPresentation->HasOwnMode();
501 myMode = aPresentation->Mode();
502
503 myHasOwnSelectionMode = aPresentation->HasOwnSelectionMode();
504 mySelectionMode = aPresentation->SelectionMode();
505
506 myHasOwnTransparency = aPresentation->HasOwnTransparency();
507 myTransparency = aPresentation->Transparency();
508
509 myIsDisplayed = aPresentation->IsDisplayed();
510 myDriverGUID = aPresentation->GetDriverGUID();
511}
512
513
514//=======================================================================
515//function : Paste
516//purpose :
517//=======================================================================
518void TDataXtd_Presentation::Paste(const Handle(TDF_Attribute)& theInto,
519 const Handle(TDF_RelocationTable)&) const
520{
521 Handle(TDataXtd_Presentation) anInto =
522 Handle(TDataXtd_Presentation)::DownCast(theInto);
523
524 anInto->Backup();
525
526 if (myHasOwnMaterial)
527 {
528 anInto->myMaterialIndex = myMaterialIndex;
529 anInto->myHasOwnMaterial = Standard_True;
530 }
531 else
532 {
533 anInto->myHasOwnMaterial = Standard_False;
534 }
535
536 if (myHasOwnColor)
537 {
538 anInto->myColor = myColor;
539 anInto->myHasOwnColor = Standard_True;
540 }
541 else
542 {
543 anInto->myHasOwnColor = Standard_False;
544 }
545
546 if(myHasOwnWidth)
547 {
548 anInto->myWidth = myWidth;
549 anInto->myHasOwnWidth = Standard_True;
550 }
551 else
552 {
553 anInto->myHasOwnWidth = Standard_False;
554 }
555
556 if (myHasOwnMode)
557 {
558 anInto->myMode = myMode;
559 anInto->myHasOwnMode = Standard_True;
560 }
561 else
562 {
563 anInto->myHasOwnMode = Standard_False;
564 }
565
566 if (myHasOwnSelectionMode)
567 {
568 anInto->mySelectionMode = mySelectionMode;
569 anInto->myHasOwnSelectionMode = Standard_True;
570 }
571 else
572 {
573 anInto->myHasOwnSelectionMode = Standard_False;
574 }
575
576 if (myHasOwnTransparency)
577 {
578 anInto->myTransparency = myTransparency;
579 anInto->myHasOwnTransparency = Standard_True;
580 }
581 else
582 {
583 anInto->myHasOwnTransparency = Standard_False;
584 }
585
586 anInto->myIsDisplayed = myIsDisplayed;
587 anInto->myDriverGUID = myDriverGUID;
588}