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/DFBrowserPane_TNamingNamedShape.hxx> |
14bbbdcb |
17 | |
0cb512c0 |
18 | #include <inspector/DFBrowserPane_AttributePaneModel.hxx> |
19 | #include <inspector/DFBrowserPane_ItemDelegateButton.hxx> |
20 | #include <inspector/DFBrowserPane_ItemRole.hxx> |
21 | #include <inspector/DFBrowserPane_HelperExport.hxx> |
22 | #include <inspector/DFBrowserPane_SelectionKind.hxx> |
23 | #include <inspector/DFBrowserPane_TableView.hxx> |
24 | #include <inspector/DFBrowserPane_Tools.hxx> |
6822a3be |
25 | #include <inspector/TInspectorAPI_PluginParameters.hxx> |
14bbbdcb |
26 | |
27 | #include <AIS_InteractiveObject.hxx> |
28 | #include <AIS_Shape.hxx> |
29 | #include <BRep_Builder.hxx> |
30 | #include <BRepTools.hxx> |
31 | #include <TNaming_Builder.hxx> |
32 | #include <TNaming_Iterator.hxx> |
33 | #include <TNaming_NamedShape.hxx> |
34 | #include <TNaming_Tool.hxx> |
35 | #include <TopoDS_Shape.hxx> |
36 | #include <TopoDS_Compound.hxx> |
37 | |
130eb114 |
38 | #include <Standard_WarningsDisable.hxx> |
14bbbdcb |
39 | #include <QFileDialog> |
40 | #include <QGridLayout> |
41 | #include <QEvent> |
42 | #include <QHeaderView> |
43 | #include <QIcon> |
44 | #include <QMap> |
45 | #include <QPainter> |
46 | #include <QStyledItemDelegate> |
47 | #include <QTableView> |
48 | #include <QVariant> |
49 | #include <QWidget> |
130eb114 |
50 | #include <Standard_WarningsRestore.hxx> |
14bbbdcb |
51 | |
52 | const int COLUMN_EXPORT_WIDTH = 20; |
53 | const int COLUMN_TYPE_WIDTH = 70; |
54 | const int COLUMN_POINTER_WIDTH = 110; |
55 | const int COLUMN_REFERENCE_WIDTH = 90; |
56 | const int COLUMN_EVOLUTION_WIDTH = 90; |
57 | |
14bbbdcb |
58 | // ======================================================================= |
59 | // function : Constructor |
60 | // purpose : |
61 | // ======================================================================= |
62 | DFBrowserPane_TNamingNamedShape::DFBrowserPane_TNamingNamedShape() |
63 | : DFBrowserPane_AttributePane(), myEvolutionTableView (0), myHelperExport (0) |
64 | { |
d2c90917 |
65 | getPaneModel()->SetColumnCount (5); |
14bbbdcb |
66 | |
14bbbdcb |
67 | myEvolutionPaneModel = new DFBrowserPane_AttributePaneModel(); |
b2300241 |
68 | myEvolutionPaneModel->SetColumnCount (10); |
d2c90917 |
69 | QList<int> anItalicColumns; |
b2300241 |
70 | anItalicColumns << 1 << 5; |
d2c90917 |
71 | myEvolutionPaneModel->SetItalicColumns (anItalicColumns); |
14bbbdcb |
72 | QItemSelectionModel* aSelectionModel = new QItemSelectionModel (myEvolutionPaneModel); |
73 | mySelectionModels.push_back (aSelectionModel); |
74 | } |
75 | |
76 | // ======================================================================= |
77 | // function : CreateWidget |
78 | // purpose : |
79 | // ======================================================================= |
80 | QWidget* DFBrowserPane_TNamingNamedShape::CreateWidget (QWidget* theParent) |
81 | { |
82 | QWidget* aMainWidget = new QWidget (theParent); |
83 | aMainWidget->setVisible (false); |
84 | |
85 | myTableView = new DFBrowserPane_TableView (aMainWidget); |
d2c90917 |
86 | myTableView->GetTableView()->verticalHeader()->setVisible (false); |
14bbbdcb |
87 | myTableView->SetModel (myPaneModel); |
88 | QTableView* aTableView = myTableView->GetTableView(); |
89 | aTableView->setSelectionBehavior (QAbstractItemView::SelectItems); |
90 | std::list<QItemSelectionModel*>::const_iterator aSelectionModelsIt = mySelectionModels.begin(); |
91 | aTableView->setSelectionModel (*aSelectionModelsIt); |
92 | aSelectionModelsIt++; |
93 | |
94 | aTableView->horizontalHeader()->setStretchLastSection (false); |
14bbbdcb |
95 | aTableView->setColumnWidth (3, COLUMN_EXPORT_WIDTH); |
d2c90917 |
96 | aTableView->setColumnWidth (4, COLUMN_EXPORT_WIDTH); |
14bbbdcb |
97 | DFBrowserPane_ItemDelegateButton* anItemDelegate = new DFBrowserPane_ItemDelegateButton (aTableView, |
98 | ":/icons/export_shape.png"); |
99 | QList<int> aRows; |
100 | aRows << 0 << 1; |
101 | anItemDelegate->SetFreeRows (aRows); |
102 | QObject::connect (anItemDelegate, SIGNAL (buttonPressed (const QModelIndex&)), |
103 | &myHelperExport, SLOT (OnButtonPressed (const QModelIndex&))); |
d2c90917 |
104 | aTableView->setItemDelegateForColumn (3, anItemDelegate); |
14bbbdcb |
105 | |
106 | DFBrowserPane_ItemDelegateButton* anItemDelegate2 = new DFBrowserPane_ItemDelegateButton (aTableView, |
107 | ":/icons/folder_export.png"); |
108 | anItemDelegate2->SetFreeRows (aRows); |
d2c90917 |
109 | aTableView->setItemDelegateForColumn (4, anItemDelegate2); |
14bbbdcb |
110 | |
111 | myEvolutionTableView = new DFBrowserPane_TableView (aMainWidget); |
112 | myEvolutionTableView->SetModel (myEvolutionPaneModel); |
113 | aTableView = myEvolutionTableView->GetTableView(); |
114 | |
115 | aTableView->setSelectionModel (*aSelectionModelsIt); |
116 | |
d2c90917 |
117 | aTableView->horizontalHeader()->setStretchLastSection (false); |
b2300241 |
118 | aTableView->setColumnWidth (4, COLUMN_EXPORT_WIDTH); |
119 | aTableView->setColumnWidth (9, COLUMN_EXPORT_WIDTH); |
14bbbdcb |
120 | |
121 | anItemDelegate = new DFBrowserPane_ItemDelegateButton (myEvolutionTableView->GetTableView(), ":/icons/export_shape.png"); |
122 | QObject::connect (anItemDelegate, SIGNAL (buttonPressed (const QModelIndex&)), |
123 | &myHelperExport, SLOT (OnButtonPressed (const QModelIndex&))); |
b2300241 |
124 | myEvolutionTableView->GetTableView()->setItemDelegateForColumn (4, anItemDelegate); |
14bbbdcb |
125 | |
126 | anItemDelegate = new DFBrowserPane_ItemDelegateButton (myEvolutionTableView->GetTableView(), ":/icons/export_shape.png"); |
127 | QObject::connect (anItemDelegate, SIGNAL (buttonPressed (const QModelIndex&)), |
128 | &myHelperExport, SLOT (OnButtonPressed (const QModelIndex&))); |
b2300241 |
129 | myEvolutionTableView->GetTableView()->setItemDelegateForColumn (9, anItemDelegate); |
14bbbdcb |
130 | |
131 | QGridLayout* aLay = new QGridLayout (aMainWidget); |
132 | aLay->setContentsMargins (0, 0, 0, 0); |
133 | aLay->addWidget (myTableView, 0, 0); |
134 | aLay->addWidget (myEvolutionTableView, 1, 0); |
135 | |
136 | return aMainWidget; |
137 | } |
138 | |
139 | // ======================================================================= |
140 | // function : Init |
141 | // purpose : |
142 | // ======================================================================= |
143 | void DFBrowserPane_TNamingNamedShape::Init (const Handle(TDF_Attribute)& theAttribute) |
144 | { |
145 | Handle(TNaming_NamedShape) aShapeAttr = Handle(TNaming_NamedShape)::DownCast (theAttribute); |
146 | myHelperExport.Clear(); |
147 | |
14bbbdcb |
148 | QList<QVariant> aValues; |
d2c90917 |
149 | aValues << "Version" << QString::number (aShapeAttr->Version()) << "" << "" << ""; |
150 | aValues << "Evolution" << DFBrowserPane_Tools::ToName (DB_NS_TYPE, aShapeAttr->Evolution()).ToCString() << "" << "" << ""; |
14bbbdcb |
151 | |
152 | NCollection_List<TopoDS_Shape> aShapes; |
d2c90917 |
153 | QList<int> aFreeRows; |
154 | aFreeRows << 0 << 1; |
155 | |
156 | TopoDS_Shape aShape = aShapeAttr->Get(); |
7e1c1e48 |
157 | TCollection_AsciiString aShapeInfo = !aShape.IsNull() ? Standard_Dump::GetPointerInfo (aShape.TShape()) : ""; |
d2c90917 |
158 | aValues << "Shape" << aShapeInfo.ToCString() << DFBrowserPane_Tools::ShapeTypeInfo (aShape) << "" << ""; |
159 | aShapes.Append (aShape); |
160 | if (aShape.IsNull()) |
161 | aFreeRows << 2; |
162 | |
163 | TopoDS_Shape aCurrentShape = TNaming_Tool::CurrentShape (aShapeAttr); |
164 | TCollection_AsciiString aCurrentShapeInfo = !aCurrentShape.IsNull() ? |
7e1c1e48 |
165 | Standard_Dump::GetPointerInfo (aCurrentShape.TShape()) : ""; |
d2c90917 |
166 | aValues << "CurrentShape" << aCurrentShapeInfo.ToCString() |
167 | << DFBrowserPane_Tools::ShapeTypeInfo (aCurrentShape) << "" << ""; |
168 | aShapes.Append (aCurrentShape); |
169 | if (aCurrentShape.IsNull()) |
170 | aFreeRows << 3; |
171 | |
172 | TopoDS_Shape anOriginalShape = TNaming_Tool::OriginalShape (aShapeAttr); |
173 | TCollection_AsciiString anOriginalShapeInfo = !anOriginalShape.IsNull() ? |
7e1c1e48 |
174 | Standard_Dump::GetPointerInfo (anOriginalShape.TShape()) : ""; |
d2c90917 |
175 | aValues << "OriginalShape" << anOriginalShapeInfo.ToCString() |
176 | << DFBrowserPane_Tools::ShapeTypeInfo (anOriginalShape) << "" << ""; |
177 | aShapes.Append (anOriginalShape); |
178 | if (anOriginalShape.IsNull()) |
179 | aFreeRows << 4; |
180 | |
14bbbdcb |
181 | |
182 | DFBrowserPane_AttributePaneModel* aModel = getPaneModel(); |
183 | aModel->Init (aValues); |
d2c90917 |
184 | if (myTableView) |
185 | { |
186 | QTableView* aTableView = myTableView->GetTableView(); |
187 | for (int i = 0; i < aModel->columnCount(); i++) |
188 | { |
189 | if (i == 3 || i == 4) |
190 | dynamic_cast<DFBrowserPane_ItemDelegateButton*>(aTableView->itemDelegateForColumn(3))->SetFreeRows (aFreeRows); |
191 | else |
192 | aTableView->resizeColumnToContents (i); |
193 | } |
194 | } |
14bbbdcb |
195 | QModelIndexList anIndices; |
196 | int aRowId = 2; |
197 | for (NCollection_List<TopoDS_Shape>::Iterator aShapeIt (aShapes); aShapeIt.More(); aShapeIt.Next(), aRowId++) |
198 | { |
d2c90917 |
199 | if (aShapeIt.Value().IsNull()) |
14bbbdcb |
200 | continue; |
14bbbdcb |
201 | anIndices.clear(); |
d2c90917 |
202 | anIndices << aModel->index (aRowId, 1) << aModel->index (aRowId, 2) << |
203 | aModel->index (aRowId, 3) << aModel->index (aRowId, 4); |
204 | myHelperExport.AddShape (aShapeIt.Value(), anIndices); |
14bbbdcb |
205 | } |
206 | |
207 | // evolution table view filling |
208 | aValues.clear(); |
209 | aRowId = 0; |
d2c90917 |
210 | bool aHasModified = false; |
14bbbdcb |
211 | for (TNaming_Iterator aShapeAttrIt (aShapeAttr); aShapeAttrIt.More(); aShapeAttrIt.Next(), aRowId++) |
212 | { |
213 | const TopoDS_Shape& anOldShape = aShapeAttrIt.OldShape(); |
214 | const TopoDS_Shape& aNewShape = aShapeAttrIt.NewShape(); |
215 | |
216 | Handle(TNaming_NamedShape) anOldAttr = TNaming_Tool::NamedShape (anOldShape, aShapeAttr->Label()); |
b2300241 |
217 | aValues << DFBrowserPane_Tools::ToName (DB_NS_TYPE, aShapeAttrIt.Evolution()).ToCString(); |
d2c90917 |
218 | aHasModified = aHasModified | aShapeAttrIt.IsModification(); |
219 | |
220 | aValues << "New:"; |
221 | |
14bbbdcb |
222 | QString aLabelInfo; |
223 | if (!anOldAttr.IsNull()) |
224 | { |
225 | TDF_Label anOldLabel = anOldAttr->Label(); |
226 | if (!anOldLabel.IsNull()) |
227 | aLabelInfo = QString (DFBrowserPane_Tools::GetEntry (anOldLabel).ToCString()); |
228 | } |
229 | if (!aNewShape.IsNull()) |
7e1c1e48 |
230 | aValues << Standard_Dump::GetPointerInfo (aNewShape.TShape()->This()).ToCString() |
14bbbdcb |
231 | << DFBrowserPane_Tools::ShapeTypeInfo (aNewShape) |
232 | << ""; |
233 | else |
d2c90917 |
234 | aValues << "-" << "-" << ""; |
235 | aValues << "Old:"; |
14bbbdcb |
236 | if (!anOldShape.IsNull()) |
7e1c1e48 |
237 | aValues << Standard_Dump::GetPointerInfo (anOldShape.TShape()->This()).ToCString() |
14bbbdcb |
238 | << DFBrowserPane_Tools::ShapeTypeInfo (anOldShape) |
239 | << aLabelInfo |
240 | << ""; |
241 | else |
d2c90917 |
242 | aValues << "-" << "-" << "-" << ""; |
14bbbdcb |
243 | } |
244 | |
245 | if (myEvolutionTableView) |
246 | { |
247 | myEvolutionTableView->setVisible (aValues.size() > 0); |
d2c90917 |
248 | myEvolutionTableView->GetTableView()->setColumnHidden (1, !aHasModified); |
14bbbdcb |
249 | myEvolutionPaneModel->Init (aValues); |
250 | |
251 | aRowId = 0; |
252 | for (TNaming_Iterator aShapeAttrIt (aShapeAttr); aShapeAttrIt.More(); aShapeAttrIt.Next(), aRowId++) |
253 | { |
254 | const TopoDS_Shape& anOldShape = aShapeAttrIt.OldShape(); |
255 | const TopoDS_Shape& aNewShape = aShapeAttrIt.NewShape(); |
256 | |
257 | if (!aNewShape.IsNull()) |
258 | { |
259 | anIndices.clear(); |
b2300241 |
260 | anIndices << myEvolutionPaneModel->index (aRowId, 2) << myEvolutionPaneModel->index (aRowId, 3) |
261 | << myEvolutionPaneModel->index (aRowId, 4); |
14bbbdcb |
262 | myHelperExport.AddShape (aNewShape, anIndices); |
263 | } |
264 | if (!anOldShape.IsNull()) |
265 | { |
266 | anIndices.clear(); |
b2300241 |
267 | anIndices << myEvolutionPaneModel->index (aRowId, 6) << myEvolutionPaneModel->index (aRowId, 7) |
268 | << myEvolutionPaneModel->index (aRowId, 9); |
14bbbdcb |
269 | myHelperExport.AddShape (anOldShape, anIndices); |
270 | } |
271 | } |
d2c90917 |
272 | for (int i = 0; i < myEvolutionPaneModel->columnCount(); i++) |
273 | { |
274 | if (i == 5 || i == 10) continue; |
275 | myEvolutionTableView->GetTableView()->resizeColumnToContents (i); |
276 | } |
14bbbdcb |
277 | } |
278 | } |
279 | |
280 | // ======================================================================= |
281 | // function : GetValues |
282 | // purpose : |
283 | // ======================================================================= |
284 | void DFBrowserPane_TNamingNamedShape::GetValues (const Handle(TDF_Attribute)&, QList<QVariant>&) |
285 | { |
286 | } |
287 | |
288 | // ======================================================================= |
289 | // function : GetAttributeInfo |
290 | // purpose : |
291 | // ======================================================================= |
292 | QVariant DFBrowserPane_TNamingNamedShape::GetAttributeInfo (const Handle(TDF_Attribute)& theAttribute, int theRole, |
293 | int theColumnId) |
294 | { |
295 | if (theColumnId != 0) |
296 | return DFBrowserPane_AttributePane::GetAttributeInfo (theAttribute, theRole, theColumnId); |
297 | |
298 | switch (theRole) |
299 | { |
300 | case Qt::DecorationRole: return QIcon (":/icons/named_shape.png"); |
301 | case DFBrowserPane_ItemRole_Decoration_40x40: return QIcon (":/icons/named_shape_40x40.png"); |
302 | case Qt::ForegroundRole: |
303 | { |
304 | TopoDS_Shape aShape; |
305 | Handle(TNaming_NamedShape) anAttribute = Handle(TNaming_NamedShape)::DownCast (theAttribute); |
306 | if (!anAttribute.IsNull()) |
307 | aShape = anAttribute->Get(); |
308 | if (aShape.IsNull()) |
309 | return QColor (Qt::black); |
310 | |
311 | return QColor (aShape.Orientation() == TopAbs_FORWARD ? Qt::darkGray : |
312 | aShape.Orientation() == TopAbs_REVERSED ? QColor (Qt::gray) : Qt::black); |
313 | } |
314 | default: |
315 | break; |
316 | } |
317 | return DFBrowserPane_AttributePane::GetAttributeInfo (theAttribute, theRole, theColumnId); |
318 | } |
319 | |
320 | // ======================================================================= |
321 | // function : GetShortAttributeInfo |
322 | // purpose : |
323 | // ======================================================================= |
324 | void DFBrowserPane_TNamingNamedShape::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute, |
325 | QList<QVariant>& theValues) |
326 | { |
327 | Handle(TNaming_NamedShape) aShapeAttribute = Handle(TNaming_NamedShape)::DownCast (theAttribute); |
328 | |
329 | if (aShapeAttribute->Get().IsNull()) |
330 | theValues.append ("EMPTY SHAPE"); |
331 | else |
332 | { |
333 | theValues.append (QString ("%1 : %2").arg (DFBrowserPane_Tools::ToName (DB_SHAPE_TYPE, aShapeAttribute->Get().ShapeType()).ToCString()) |
334 | .arg (DFBrowserPane_Tools::ToName (DB_NS_TYPE, aShapeAttribute->Evolution()).ToCString())); |
335 | } |
336 | } |
337 | |
338 | // ======================================================================= |
339 | // function : GetSelectionKind |
340 | // purpose : |
341 | // ======================================================================= |
342 | int DFBrowserPane_TNamingNamedShape::GetSelectionKind (QItemSelectionModel* theModel) |
343 | { |
344 | int aKind = DFBrowserPane_AttributePaneAPI::GetSelectionKind (theModel); |
345 | |
346 | QTableView* aTableView = myTableView->GetTableView(); |
347 | if (aTableView->selectionModel() != theModel) |
348 | return aKind; |
349 | |
350 | QModelIndexList aSelectedIndices = theModel->selectedIndexes(); |
351 | if (aSelectedIndices.size() != 1) |
352 | return aKind; |
353 | |
354 | QModelIndex aSelectedIndex = aSelectedIndices.first(); |
355 | int aRow = aSelectedIndex.row(); |
356 | if (aRow == 0 || aRow == 1) |
357 | return aKind; |
358 | |
d2c90917 |
359 | if (aSelectedIndex.column() == 4) |
14bbbdcb |
360 | aKind = DFBrowserPane_SelectionKind_ExportToShapeViewer; |
361 | |
362 | return aKind; |
363 | } |
364 | |
365 | // ======================================================================= |
366 | // function : GetSelectionParameters |
367 | // purpose : |
368 | // ======================================================================= |
369 | void DFBrowserPane_TNamingNamedShape::GetSelectionParameters (QItemSelectionModel* theModel, |
6822a3be |
370 | NCollection_List<Handle(Standard_Transient)>& theParameters, |
371 | NCollection_List<TCollection_AsciiString>& theItemNames) |
14bbbdcb |
372 | { |
373 | QTableView* aTableView = myTableView->GetTableView(); |
374 | if (aTableView->selectionModel() != theModel) |
375 | return; |
376 | |
377 | QModelIndexList aSelectedIndices = theModel->selectedIndexes(); |
378 | if (aSelectedIndices.size() != 1) |
379 | return; |
380 | |
381 | QModelIndex aSelectedIndex = aSelectedIndices.first(); |
d2c90917 |
382 | if (aSelectedIndex.column() != 4) |
14bbbdcb |
383 | return; |
384 | |
7e1c1e48 |
385 | const TopoDS_Shape& aShape = myHelperExport.Shape (aSelectedIndex); |
14bbbdcb |
386 | if (aShape.IsNull()) |
387 | return; |
388 | theParameters.Append (aShape.TShape()); |
6822a3be |
389 | theItemNames.Append (TInspectorAPI_PluginParameters::ParametersToString (aShape)); |
14bbbdcb |
390 | } |
391 | |
392 | // ======================================================================= |
393 | // function : GetReferences |
394 | // purpose : |
395 | // ======================================================================= |
396 | void DFBrowserPane_TNamingNamedShape::GetReferences (const Handle(TDF_Attribute)& theAttribute, |
397 | NCollection_List<TDF_Label>& theRefLabels, |
398 | Handle(Standard_Transient)& theRefPresentation) |
399 | { |
400 | if (!myEvolutionTableView) |
401 | return; |
402 | QStringList aSelectedEntries = DFBrowserPane_TableView::GetSelectedColumnValues ( |
d2c90917 |
403 | myEvolutionTableView->GetTableView(), 9); |
14bbbdcb |
404 | |
405 | Handle(TNaming_NamedShape) aShapeAttr = Handle(TNaming_NamedShape)::DownCast (theAttribute); |
406 | for (TNaming_Iterator aShapeAttrIt (aShapeAttr); aShapeAttrIt.More(); aShapeAttrIt.Next()) |
407 | { |
408 | const TopoDS_Shape& anOldShape = aShapeAttrIt.OldShape(); |
409 | |
410 | Handle(TNaming_NamedShape) anOldAttr = TNaming_Tool::NamedShape (anOldShape, aShapeAttr->Label()); |
411 | QString aLabelInfo; |
412 | if (!anOldAttr.IsNull()) |
413 | { |
414 | TDF_Label anOldLabel = anOldAttr->Label(); |
415 | if (!anOldLabel.IsNull()) |
416 | { |
417 | if (aSelectedEntries.contains (DFBrowserPane_Tools::GetEntry (anOldLabel).ToCString())) |
418 | theRefLabels.Append (anOldLabel); |
419 | } |
420 | } |
421 | } |
422 | TopoDS_Shape aShape = getSelectedShapes(); |
423 | if (!aShape.IsNull()) |
424 | theRefPresentation = new AIS_Shape (aShape); |
425 | } |
426 | |
427 | // ======================================================================= |
428 | // function : GetPresentation |
429 | // purpose : |
430 | // ======================================================================= |
431 | Handle(Standard_Transient) DFBrowserPane_TNamingNamedShape::GetPresentation (const Handle(TDF_Attribute)& theAttribute) |
432 | { |
433 | Handle(Standard_Transient) aPresentation; |
434 | Handle(TNaming_NamedShape) aShapeAttr = Handle(TNaming_NamedShape)::DownCast (theAttribute); |
435 | if (aShapeAttr.IsNull()) |
436 | return aPresentation; |
437 | |
438 | TopoDS_Shape aShape = aShapeAttr->Get(); |
439 | if (aShape.IsNull()) |
440 | return aPresentation; |
441 | |
442 | aPresentation = new AIS_Shape (aShape); |
443 | return aPresentation; |
444 | } |
445 | |
446 | // ======================================================================= |
447 | // function : getSelectedShapes |
448 | // purpose : |
449 | // ======================================================================= |
450 | TopoDS_Shape DFBrowserPane_TNamingNamedShape::getSelectedShapes() |
451 | { |
452 | TopoDS_Shape aShape; |
453 | |
454 | if (!myTableView && !myEvolutionTableView) |
455 | return aShape; |
456 | |
457 | // table view selected shapes |
458 | QItemSelectionModel* aTableViewSelModel = myTableView->GetTableView()->selectionModel(); |
459 | QModelIndexList anIndices = aTableViewSelModel->selectedIndexes(); |
460 | |
461 | BRep_Builder aBuilder; |
462 | TopoDS_Compound aComp; |
463 | aBuilder.MakeCompound (aComp); |
464 | bool aHasShapes = false; |
465 | for (QModelIndexList::const_iterator anIt = anIndices.begin(), aLast = anIndices.end(); anIt != aLast; anIt++) |
466 | { |
467 | QModelIndex anIndex = *anIt; |
468 | if (!myHelperExport.HasShape (anIndex)) |
469 | continue; |
7e1c1e48 |
470 | aBuilder.Add (aComp, myHelperExport.Shape (anIndex)); |
14bbbdcb |
471 | aHasShapes = true; |
472 | } |
473 | |
474 | // evolution table selected shapes |
475 | aTableViewSelModel = myEvolutionTableView->GetTableView()->selectionModel(); |
476 | anIndices.clear(); |
477 | anIndices = aTableViewSelModel->selectedIndexes(); |
478 | for (QModelIndexList::const_iterator anIt = anIndices.begin(), aLast = anIndices.end(); anIt != aLast; anIt++) |
479 | { |
480 | QModelIndex anIndex = *anIt; |
481 | if (!myHelperExport.HasShape (anIndex)) |
482 | continue; |
7e1c1e48 |
483 | aBuilder.Add (aComp, myHelperExport.Shape (anIndex)); |
14bbbdcb |
484 | aHasShapes = true; |
485 | } |
486 | if (aHasShapes) |
487 | aShape = aComp; |
488 | return aShape; |
489 | } |