f9e64d76950f7da6f8cfc994d2650f1f2f39cf6c
[occt.git] / tools / DFBrowserPaneXDE / DFBrowserPaneXDE_XCAFDocDatum.cxx
1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement. 
15
16 #include <inspector/DFBrowserPaneXDE_XCAFDocDatum.hxx>
17
18 #include <inspector/DFBrowserPane_AttributePaneModel.hxx>
19
20 #include <Standard_Version.hxx>
21 #include <TCollection_HAsciiString.hxx>
22
23 #include <XCAFDoc_Datum.hxx>
24 #if OCC_VERSION_HEX > 0x060901
25 #include <XCAFDimTolObjects_DatumObject.hxx>
26 #endif
27
28 // =======================================================================
29 // function : Constructor
30 // purpose :
31 // =======================================================================
32 DFBrowserPaneXDE_XCAFDocDatum::DFBrowserPaneXDE_XCAFDocDatum()
33 : DFBrowserPane_AttributePane()
34 {
35 }
36
37 // =======================================================================
38 // function : GetValues
39 // purpose :
40 // =======================================================================
41 void DFBrowserPaneXDE_XCAFDocDatum::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
42 {
43   Handle(XCAFDoc_Datum) anAttr = Handle(XCAFDoc_Datum)::DownCast (theAttribute);
44
45   Handle(TCollection_HAsciiString) aName = anAttr->GetName();
46   Handle(TCollection_HAsciiString) aDescription = anAttr->GetDescription();
47   Handle(TCollection_HAsciiString) anIndentification = anAttr->GetIdentification();
48
49   theValues << "Name" << (!aName.IsNull() ? aName->ToCString() : QString (""))
50             << "Description" << (!aDescription.IsNull() ? aDescription->ToCString() : QString (""))
51             << "Indentification" << (!anIndentification.IsNull() ? anIndentification->ToCString() : QString (""));
52
53 #if OCC_VERSION_HEX > 0x060901
54   Handle(XCAFDimTolObjects_DatumObject) anObject = anAttr->GetObject();
55   Handle(TCollection_HAsciiString) anObjectName;
56   if (!anObject.IsNull())
57     anObjectName = anObject->GetName();
58   theValues << "Object" << (!anObjectName.IsNull() ? anObjectName->ToCString() : "Empty Name");
59 #endif
60 }
61
62 // =======================================================================
63 // function : GetShortAttributeInfo
64 // purpose :
65 // =======================================================================
66 void DFBrowserPaneXDE_XCAFDocDatum::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
67 {
68   Handle(XCAFDoc_Datum) anAttr = Handle(XCAFDoc_Datum)::DownCast (theAttribute);
69
70   Handle(TCollection_HAsciiString) aName = anAttr->GetName();
71   theValues << (!aName.IsNull() ? aName->ToCString() : QString (""));
72 }