14bbbdcb |
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 | |
0cb512c0 |
16 | #include <inspector/DFBrowserPaneXDE_AttributeCommonPane.hxx> |
14bbbdcb |
17 | |
0cb512c0 |
18 | #include <inspector/DFBrowserPane_ItemRole.hxx> |
19 | #include <inspector/DFBrowserPaneXDE_XDEDRAW.hxx> |
14bbbdcb |
20 | |
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> |
32 | |
33 | #include <set> |
34 | |
130eb114 |
35 | #include <Standard_WarningsDisable.hxx> |
14bbbdcb |
36 | #include <QStringList> |
130eb114 |
37 | #include <Standard_WarningsRestore.hxx> |
14bbbdcb |
38 | |
39 | static std::set<Standard_CString> AttributeTypes; |
40 | |
41 | // ======================================================================= |
42 | // function : Constructor |
43 | // purpose : |
44 | // ======================================================================= |
45 | DFBrowserPaneXDE_AttributeCommonPane::DFBrowserPaneXDE_AttributeCommonPane (DFBrowserPane_AttributePaneAPI* theStandardPane) |
46 | : DFBrowserPane_AttributePane() |
47 | { |
48 | myStandardPane = dynamic_cast<DFBrowserPane_AttributePane*> (theStandardPane); |
49 | } |
50 | |
51 | // ======================================================================= |
52 | // function : ProcessAttribute |
53 | // purpose : |
54 | // ======================================================================= |
55 | bool DFBrowserPaneXDE_AttributeCommonPane::ProcessAttribute (const Standard_CString& theAttributeType) |
56 | { |
57 | if (AttributeTypes.empty()) |
58 | { |
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()); |
70 | } |
71 | return AttributeTypes.find (theAttributeType) != AttributeTypes.end(); |
72 | } |
73 | |
74 | // ======================================================================= |
75 | // function : CreateWidget |
76 | // purpose : |
77 | // ======================================================================= |
78 | QWidget* DFBrowserPaneXDE_AttributeCommonPane::CreateWidget (QWidget* theParent) |
79 | { |
80 | return myStandardPane ? myStandardPane->CreateWidget (theParent) : 0; |
81 | } |
82 | |
83 | // ======================================================================= |
84 | // function : Init |
85 | // purpose : |
86 | // ======================================================================= |
87 | void DFBrowserPaneXDE_AttributeCommonPane::Init (const Handle(TDF_Attribute)& theAttribute) |
88 | { |
89 | if (myStandardPane) |
90 | myStandardPane->Init (theAttribute); |
91 | } |
92 | |
93 | // ======================================================================= |
94 | // function : GetSelectionModels |
95 | // purpose : |
96 | // ======================================================================= |
97 | std::list<QItemSelectionModel*> DFBrowserPaneXDE_AttributeCommonPane::GetSelectionModels() |
98 | { |
99 | return myStandardPane ? myStandardPane->GetSelectionModels() : std::list<QItemSelectionModel*>(); |
100 | } |
101 | |
102 | // ======================================================================= |
103 | // function : GetValues |
104 | // purpose : |
105 | // ======================================================================= |
106 | void DFBrowserPaneXDE_AttributeCommonPane::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues) |
107 | { |
108 | if (myStandardPane) |
109 | myStandardPane->GetValues (theAttribute, theValues); |
110 | } |
111 | |
112 | // ======================================================================= |
113 | // function : GetAttributeInfo |
114 | // purpose : |
115 | // ======================================================================= |
116 | QVariant DFBrowserPaneXDE_AttributeCommonPane::GetAttributeInfo (const Handle(TDF_Attribute)& theAttribute, |
117 | int theRole, int theColumnId) |
118 | { |
119 | QVariant aValue; |
120 | if (myStandardPane) |
121 | { |
122 | if (theRole == DFBrowserPane_ItemRole_ShortInfo) |
123 | { |
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 (", "); |
130 | } |
131 | else |
132 | aValue = myStandardPane->GetAttributeInfo (theAttribute, theRole, theColumnId); |
133 | } |
134 | else |
135 | aValue = DFBrowserPane_AttributePane::GetAttributeInfoByType (theAttribute->DynamicType()->Name(), |
136 | theRole, theColumnId); |
137 | return aValue; |
138 | } |
139 | |
140 | // ======================================================================= |
141 | // function : GetShortAttributeInfo |
142 | // purpose : |
143 | // ======================================================================= |
144 | void DFBrowserPaneXDE_AttributeCommonPane::GetShortAttributeInfo ( |
145 | const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues) |
146 | { |
147 | theValues.append (DFBrowserPaneXDE_XDEDRAW::GetAttributeInfo (theAttribute).ToCString()); |
148 | } |
149 | |
150 | // ======================================================================= |
151 | // function : GetSelectionKind |
152 | // purpose : |
153 | // ======================================================================= |
154 | int DFBrowserPaneXDE_AttributeCommonPane::GetSelectionKind (QItemSelectionModel* theModel) |
155 | { |
156 | if (myStandardPane) |
157 | return myStandardPane->GetSelectionKind (theModel); |
158 | |
159 | return DFBrowserPane_AttributePane::GetSelectionKind (theModel); |
160 | } |
161 | |
162 | // ======================================================================= |
163 | // function : GetSelectionParameters |
164 | // purpose : |
165 | // ======================================================================= |
166 | void DFBrowserPaneXDE_AttributeCommonPane::GetSelectionParameters (QItemSelectionModel* theModel, |
6822a3be |
167 | NCollection_List<Handle(Standard_Transient)>& theParameters, |
168 | NCollection_List<TCollection_AsciiString>& theItemNames) |
14bbbdcb |
169 | { |
170 | if (myStandardPane) |
6822a3be |
171 | myStandardPane->GetSelectionParameters (theModel, theParameters, theItemNames); |
14bbbdcb |
172 | |
6822a3be |
173 | DFBrowserPane_AttributePane::GetSelectionParameters (theModel, theParameters, theItemNames); |
14bbbdcb |
174 | } |
175 | |
176 | // ======================================================================= |
177 | // function : GetPresentation |
178 | // purpose : |
179 | // ======================================================================= |
180 | Handle(Standard_Transient) DFBrowserPaneXDE_AttributeCommonPane::GetPresentation ( |
181 | const Handle(TDF_Attribute)& theAttribute) |
182 | { |
183 | Handle(Standard_Transient) anIO; |
184 | if (myStandardPane) |
185 | anIO = myStandardPane->GetPresentation (theAttribute); |
186 | return anIO; |
187 | } |
188 | |
189 | // ======================================================================= |
190 | // function : GetReferences |
191 | // purpose : |
192 | // ======================================================================= |
193 | void DFBrowserPaneXDE_AttributeCommonPane::GetReferences ( |
194 | const Handle(TDF_Attribute)& theAttribute, |
195 | NCollection_List<TDF_Label>& theRefLabels, |
196 | Handle(Standard_Transient)& theRefPresentation) |
197 | { |
198 | Handle(Standard_Transient) anIO; |
199 | if (myStandardPane) |
200 | myStandardPane->GetReferences (theAttribute, theRefLabels, theRefPresentation); |
201 | } |
202 | |
203 | // ======================================================================= |
204 | // function : GetAttributeReferences |
205 | // purpose : |
206 | // ======================================================================= |
207 | void DFBrowserPaneXDE_AttributeCommonPane::GetAttributeReferences ( |
208 | const Handle(TDF_Attribute)& theAttribute, |
209 | NCollection_List<Handle(TDF_Attribute)>& theRefAttributes, |
210 | Handle(Standard_Transient)& theRefPresentation) |
211 | { |
212 | Handle(Standard_Transient) anIO; |
213 | if (myStandardPane) |
214 | myStandardPane->GetAttributeReferences (theAttribute, theRefAttributes, theRefPresentation); |
215 | } |