1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <inspector/DFBrowserPaneXDE_AttributeCommonPane.hxx>
18 #include <inspector/DFBrowserPane_ItemRole.hxx>
19 #include <inspector/DFBrowserPaneXDE_XDEDRAW.hxx>
21 #include <TDataStd_TreeNode.hxx>
22 #include <TDF_Reference.hxx>
23 #include <TNaming_NamedShape.hxx>
24 #include <XCAFDoc_Volume.hxx>
25 #include <XCAFDoc_Area.hxx>
26 #include <XCAFDoc_Centroid.hxx>
27 #include <TDataStd_UAttribute.hxx>
28 #include <XCAFDoc_Color.hxx>
29 #include <XCAFDoc_DimTol.hxx>
30 #include <XCAFDoc_Material.hxx>
31 #include <XCAFDoc_GraphNode.hxx>
35 #include <Standard_WarningsDisable.hxx>
36 #include <QStringList>
37 #include <Standard_WarningsRestore.hxx>
39 static std::set<Standard_CString> AttributeTypes;
41 // =======================================================================
42 // function : Constructor
44 // =======================================================================
45 DFBrowserPaneXDE_AttributeCommonPane::DFBrowserPaneXDE_AttributeCommonPane (DFBrowserPane_AttributePaneAPI* theStandardPane)
46 : DFBrowserPane_AttributePane()
48 myStandardPane = dynamic_cast<DFBrowserPane_AttributePane*> (theStandardPane);
51 // =======================================================================
52 // function : ProcessAttribute
54 // =======================================================================
55 bool DFBrowserPaneXDE_AttributeCommonPane::ProcessAttribute (const Standard_CString& theAttributeType)
57 if (AttributeTypes.empty())
59 AttributeTypes.insert (STANDARD_TYPE (TDataStd_TreeNode)->Name());
60 AttributeTypes.insert (STANDARD_TYPE (TDF_Reference)->Name());
61 AttributeTypes.insert (STANDARD_TYPE (TNaming_NamedShape)->Name());
62 AttributeTypes.insert (STANDARD_TYPE (XCAFDoc_Volume)->Name());
63 AttributeTypes.insert (STANDARD_TYPE (XCAFDoc_Area)->Name());
64 AttributeTypes.insert (STANDARD_TYPE (XCAFDoc_Centroid)->Name());
65 AttributeTypes.insert (STANDARD_TYPE (TDataStd_UAttribute)->Name());
66 AttributeTypes.insert (STANDARD_TYPE (XCAFDoc_Color)->Name());
67 AttributeTypes.insert (STANDARD_TYPE (XCAFDoc_DimTol)->Name());
68 AttributeTypes.insert (STANDARD_TYPE (XCAFDoc_Material)->Name());
69 AttributeTypes.insert (STANDARD_TYPE (XCAFDoc_GraphNode)->Name());
71 return AttributeTypes.find (theAttributeType) != AttributeTypes.end();
74 // =======================================================================
75 // function : CreateWidget
77 // =======================================================================
78 QWidget* DFBrowserPaneXDE_AttributeCommonPane::CreateWidget (QWidget* theParent)
80 return myStandardPane ? myStandardPane->CreateWidget (theParent) : 0;
83 // =======================================================================
86 // =======================================================================
87 void DFBrowserPaneXDE_AttributeCommonPane::Init (const Handle(TDF_Attribute)& theAttribute)
90 myStandardPane->Init (theAttribute);
93 // =======================================================================
94 // function : GetSelectionModels
96 // =======================================================================
97 std::list<QItemSelectionModel*> DFBrowserPaneXDE_AttributeCommonPane::GetSelectionModels()
99 return myStandardPane ? myStandardPane->GetSelectionModels() : std::list<QItemSelectionModel*>();
102 // =======================================================================
103 // function : GetValues
105 // =======================================================================
106 void DFBrowserPaneXDE_AttributeCommonPane::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
109 myStandardPane->GetValues (theAttribute, theValues);
112 // =======================================================================
113 // function : GetAttributeInfo
115 // =======================================================================
116 QVariant DFBrowserPaneXDE_AttributeCommonPane::GetAttributeInfo (const Handle(TDF_Attribute)& theAttribute,
117 int theRole, int theColumnId)
122 if (theRole == DFBrowserPane_ItemRole_ShortInfo)
124 QList<QVariant> aValues;
125 GetShortAttributeInfo (theAttribute, aValues);
126 QStringList anInfoList;
127 for (QList<QVariant>::const_iterator aValuesIt = aValues.begin(); aValuesIt != aValues.end(); aValuesIt++)
128 anInfoList.append (aValuesIt->toString());
129 aValue = anInfoList.join (", ");
132 aValue = myStandardPane->GetAttributeInfo (theAttribute, theRole, theColumnId);
135 aValue = DFBrowserPane_AttributePane::GetAttributeInfoByType (theAttribute->DynamicType()->Name(),
136 theRole, theColumnId);
140 // =======================================================================
141 // function : GetShortAttributeInfo
143 // =======================================================================
144 void DFBrowserPaneXDE_AttributeCommonPane::GetShortAttributeInfo (
145 const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues)
147 theValues.append (DFBrowserPaneXDE_XDEDRAW::GetAttributeInfo (theAttribute).ToCString());
150 // =======================================================================
151 // function : GetSelectionKind
153 // =======================================================================
154 int DFBrowserPaneXDE_AttributeCommonPane::GetSelectionKind (QItemSelectionModel* theModel)
157 return myStandardPane->GetSelectionKind (theModel);
159 return DFBrowserPane_AttributePane::GetSelectionKind (theModel);
162 // =======================================================================
163 // function : GetSelectionParameters
165 // =======================================================================
166 void DFBrowserPaneXDE_AttributeCommonPane::GetSelectionParameters (QItemSelectionModel* theModel,
167 NCollection_List<Handle(Standard_Transient)>& theParameters)
170 myStandardPane->GetSelectionParameters (theModel, theParameters);
172 DFBrowserPane_AttributePane::GetSelectionParameters (theModel, theParameters);
175 // =======================================================================
176 // function : GetPresentation
178 // =======================================================================
179 Handle(Standard_Transient) DFBrowserPaneXDE_AttributeCommonPane::GetPresentation (
180 const Handle(TDF_Attribute)& theAttribute)
182 Handle(Standard_Transient) anIO;
184 anIO = myStandardPane->GetPresentation (theAttribute);
188 // =======================================================================
189 // function : GetReferences
191 // =======================================================================
192 void DFBrowserPaneXDE_AttributeCommonPane::GetReferences (
193 const Handle(TDF_Attribute)& theAttribute,
194 NCollection_List<TDF_Label>& theRefLabels,
195 Handle(Standard_Transient)& theRefPresentation)
197 Handle(Standard_Transient) anIO;
199 myStandardPane->GetReferences (theAttribute, theRefLabels, theRefPresentation);
202 // =======================================================================
203 // function : GetAttributeReferences
205 // =======================================================================
206 void DFBrowserPaneXDE_AttributeCommonPane::GetAttributeReferences (
207 const Handle(TDF_Attribute)& theAttribute,
208 NCollection_List<Handle(TDF_Attribute)>& theRefAttributes,
209 Handle(Standard_Transient)& theRefPresentation)
211 Handle(Standard_Transient) anIO;
213 myStandardPane->GetAttributeReferences (theAttribute, theRefAttributes, theRefPresentation);