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> |
14bbbdcb |
25 | |
26 | #include <AIS_InteractiveObject.hxx> |
27 | #include <AIS_Shape.hxx> |
28 | #include <BRep_Builder.hxx> |
29 | #include <BRepTools.hxx> |
30 | #include <TNaming_Builder.hxx> |
31 | #include <TNaming_Iterator.hxx> |
32 | #include <TNaming_NamedShape.hxx> |
33 | #include <TNaming_Tool.hxx> |
34 | #include <TopoDS_Shape.hxx> |
35 | #include <TopoDS_Compound.hxx> |
36 | |
130eb114 |
37 | #include <Standard_WarningsDisable.hxx> |
14bbbdcb |
38 | #include <QFileDialog> |
39 | #include <QGridLayout> |
40 | #include <QEvent> |
41 | #include <QHeaderView> |
42 | #include <QIcon> |
43 | #include <QMap> |
44 | #include <QPainter> |
45 | #include <QStyledItemDelegate> |
46 | #include <QTableView> |
47 | #include <QVariant> |
48 | #include <QWidget> |
130eb114 |
49 | #include <Standard_WarningsRestore.hxx> |
14bbbdcb |
50 | |
51 | const int COLUMN_EXPORT_WIDTH = 20; |
52 | const int COLUMN_TYPE_WIDTH = 70; |
53 | const int COLUMN_POINTER_WIDTH = 110; |
54 | const int COLUMN_REFERENCE_WIDTH = 90; |
55 | const int COLUMN_EVOLUTION_WIDTH = 90; |
56 | |
14bbbdcb |
57 | // ======================================================================= |
58 | // function : Constructor |
59 | // purpose : |
60 | // ======================================================================= |
61 | DFBrowserPane_TNamingNamedShape::DFBrowserPane_TNamingNamedShape() |
62 | : DFBrowserPane_AttributePane(), myEvolutionTableView (0), myHelperExport (0) |
63 | { |
d2c90917 |
64 | getPaneModel()->SetColumnCount (5); |
14bbbdcb |
65 | |
14bbbdcb |
66 | myEvolutionPaneModel = new DFBrowserPane_AttributePaneModel(); |
d2c90917 |
67 | myEvolutionPaneModel->SetColumnCount (11); |
68 | QList<int> anItalicColumns; |
69 | anItalicColumns << 2 << 6; |
70 | myEvolutionPaneModel->SetItalicColumns (anItalicColumns); |
14bbbdcb |
71 | QItemSelectionModel* aSelectionModel = new QItemSelectionModel (myEvolutionPaneModel); |
72 | mySelectionModels.push_back (aSelectionModel); |
73 | } |
74 | |
75 | // ======================================================================= |
76 | // function : CreateWidget |
77 | // purpose : |
78 | // ======================================================================= |
79 | QWidget* DFBrowserPane_TNamingNamedShape::CreateWidget (QWidget* theParent) |
80 | { |
81 | QWidget* aMainWidget = new QWidget (theParent); |
82 | aMainWidget->setVisible (false); |
83 | |
84 | myTableView = new DFBrowserPane_TableView (aMainWidget); |
d2c90917 |
85 | myTableView->GetTableView()->verticalHeader()->setVisible (false); |
14bbbdcb |
86 | myTableView->SetModel (myPaneModel); |
87 | QTableView* aTableView = myTableView->GetTableView(); |
88 | aTableView->setSelectionBehavior (QAbstractItemView::SelectItems); |
89 | std::list<QItemSelectionModel*>::const_iterator aSelectionModelsIt = mySelectionModels.begin(); |
90 | aTableView->setSelectionModel (*aSelectionModelsIt); |
91 | aSelectionModelsIt++; |
92 | |
93 | aTableView->horizontalHeader()->setStretchLastSection (false); |
14bbbdcb |
94 | aTableView->setColumnWidth (3, COLUMN_EXPORT_WIDTH); |
d2c90917 |
95 | aTableView->setColumnWidth (4, COLUMN_EXPORT_WIDTH); |
14bbbdcb |
96 | DFBrowserPane_ItemDelegateButton* anItemDelegate = new DFBrowserPane_ItemDelegateButton (aTableView, |
97 | ":/icons/export_shape.png"); |
98 | QList<int> aRows; |
99 | aRows << 0 << 1; |
100 | anItemDelegate->SetFreeRows (aRows); |
101 | QObject::connect (anItemDelegate, SIGNAL (buttonPressed (const QModelIndex&)), |
102 | &myHelperExport, SLOT (OnButtonPressed (const QModelIndex&))); |
d2c90917 |
103 | aTableView->setItemDelegateForColumn (3, anItemDelegate); |
14bbbdcb |
104 | |
105 | DFBrowserPane_ItemDelegateButton* anItemDelegate2 = new DFBrowserPane_ItemDelegateButton (aTableView, |
106 | ":/icons/folder_export.png"); |
107 | anItemDelegate2->SetFreeRows (aRows); |
d2c90917 |
108 | aTableView->setItemDelegateForColumn (4, anItemDelegate2); |
14bbbdcb |
109 | |
110 | myEvolutionTableView = new DFBrowserPane_TableView (aMainWidget); |
111 | myEvolutionTableView->SetModel (myEvolutionPaneModel); |
112 | aTableView = myEvolutionTableView->GetTableView(); |
113 | |
114 | aTableView->setSelectionModel (*aSelectionModelsIt); |
115 | |
d2c90917 |
116 | aTableView->horizontalHeader()->setStretchLastSection (false); |
117 | aTableView->setColumnWidth (5, COLUMN_EXPORT_WIDTH); |
118 | aTableView->setColumnWidth (10, COLUMN_EXPORT_WIDTH); |
14bbbdcb |
119 | |
120 | anItemDelegate = new DFBrowserPane_ItemDelegateButton (myEvolutionTableView->GetTableView(), ":/icons/export_shape.png"); |
121 | QObject::connect (anItemDelegate, SIGNAL (buttonPressed (const QModelIndex&)), |
122 | &myHelperExport, SLOT (OnButtonPressed (const QModelIndex&))); |
d2c90917 |
123 | myEvolutionTableView->GetTableView()->setItemDelegateForColumn (5, anItemDelegate); |
14bbbdcb |
124 | |
125 | anItemDelegate = new DFBrowserPane_ItemDelegateButton (myEvolutionTableView->GetTableView(), ":/icons/export_shape.png"); |
126 | QObject::connect (anItemDelegate, SIGNAL (buttonPressed (const QModelIndex&)), |
127 | &myHelperExport, SLOT (OnButtonPressed (const QModelIndex&))); |
d2c90917 |
128 | myEvolutionTableView->GetTableView()->setItemDelegateForColumn (10, anItemDelegate); |
14bbbdcb |
129 | |
130 | QGridLayout* aLay = new QGridLayout (aMainWidget); |
131 | aLay->setContentsMargins (0, 0, 0, 0); |
132 | aLay->addWidget (myTableView, 0, 0); |
133 | aLay->addWidget (myEvolutionTableView, 1, 0); |
134 | |
135 | return aMainWidget; |
136 | } |
137 | |
138 | // ======================================================================= |
139 | // function : Init |
140 | // purpose : |
141 | // ======================================================================= |
142 | void DFBrowserPane_TNamingNamedShape::Init (const Handle(TDF_Attribute)& theAttribute) |
143 | { |
144 | Handle(TNaming_NamedShape) aShapeAttr = Handle(TNaming_NamedShape)::DownCast (theAttribute); |
145 | myHelperExport.Clear(); |
146 | |
14bbbdcb |
147 | QList<QVariant> aValues; |
d2c90917 |
148 | aValues << "Version" << QString::number (aShapeAttr->Version()) << "" << "" << ""; |
149 | aValues << "Evolution" << DFBrowserPane_Tools::ToName (DB_NS_TYPE, aShapeAttr->Evolution()).ToCString() << "" << "" << ""; |
14bbbdcb |
150 | |
151 | NCollection_List<TopoDS_Shape> aShapes; |
d2c90917 |
152 | QList<int> aFreeRows; |
153 | aFreeRows << 0 << 1; |
154 | |
155 | TopoDS_Shape aShape = aShapeAttr->Get(); |
156 | TCollection_AsciiString aShapeInfo = !aShape.IsNull() ? DFBrowserPane_Tools::GetPointerInfo (aShape.TShape()) : ""; |
157 | aValues << "Shape" << aShapeInfo.ToCString() << DFBrowserPane_Tools::ShapeTypeInfo (aShape) << "" << ""; |
158 | aShapes.Append (aShape); |
159 | if (aShape.IsNull()) |
160 | aFreeRows << 2; |
161 | |
162 | TopoDS_Shape aCurrentShape = TNaming_Tool::CurrentShape (aShapeAttr); |
163 | TCollection_AsciiString aCurrentShapeInfo = !aCurrentShape.IsNull() ? |
164 | DFBrowserPane_Tools::GetPointerInfo (aCurrentShape.TShape()) : ""; |
165 | aValues << "CurrentShape" << aCurrentShapeInfo.ToCString() |
166 | << DFBrowserPane_Tools::ShapeTypeInfo (aCurrentShape) << "" << ""; |
167 | aShapes.Append (aCurrentShape); |
168 | if (aCurrentShape.IsNull()) |
169 | aFreeRows << 3; |
170 | |
171 | TopoDS_Shape anOriginalShape = TNaming_Tool::OriginalShape (aShapeAttr); |
172 | TCollection_AsciiString anOriginalShapeInfo = !anOriginalShape.IsNull() ? |
173 | DFBrowserPane_Tools::GetPointerInfo (anOriginalShape.TShape()) : ""; |
174 | aValues << "OriginalShape" << anOriginalShapeInfo.ToCString() |
175 | << DFBrowserPane_Tools::ShapeTypeInfo (anOriginalShape) << "" << ""; |
176 | aShapes.Append (anOriginalShape); |
177 | if (anOriginalShape.IsNull()) |
178 | aFreeRows << 4; |
179 | |
14bbbdcb |
180 | |
181 | DFBrowserPane_AttributePaneModel* aModel = getPaneModel(); |
182 | aModel->Init (aValues); |
d2c90917 |
183 | if (myTableView) |
184 | { |
185 | QTableView* aTableView = myTableView->GetTableView(); |
186 | for (int i = 0; i < aModel->columnCount(); i++) |
187 | { |
188 | if (i == 3 || i == 4) |
189 | dynamic_cast<DFBrowserPane_ItemDelegateButton*>(aTableView->itemDelegateForColumn(3))->SetFreeRows (aFreeRows); |
190 | else |
191 | aTableView->resizeColumnToContents (i); |
192 | } |
193 | } |
14bbbdcb |
194 | QModelIndexList anIndices; |
195 | int aRowId = 2; |
196 | for (NCollection_List<TopoDS_Shape>::Iterator aShapeIt (aShapes); aShapeIt.More(); aShapeIt.Next(), aRowId++) |
197 | { |
d2c90917 |
198 | if (aShapeIt.Value().IsNull()) |
14bbbdcb |
199 | continue; |
14bbbdcb |
200 | anIndices.clear(); |
d2c90917 |
201 | anIndices << aModel->index (aRowId, 1) << aModel->index (aRowId, 2) << |
202 | aModel->index (aRowId, 3) << aModel->index (aRowId, 4); |
203 | myHelperExport.AddShape (aShapeIt.Value(), anIndices); |
14bbbdcb |
204 | } |
205 | |
206 | // evolution table view filling |
207 | aValues.clear(); |
208 | aRowId = 0; |
d2c90917 |
209 | bool aHasModified = false; |
14bbbdcb |
210 | for (TNaming_Iterator aShapeAttrIt (aShapeAttr); aShapeAttrIt.More(); aShapeAttrIt.Next(), aRowId++) |
211 | { |
212 | const TopoDS_Shape& anOldShape = aShapeAttrIt.OldShape(); |
213 | const TopoDS_Shape& aNewShape = aShapeAttrIt.NewShape(); |
214 | |
215 | Handle(TNaming_NamedShape) anOldAttr = TNaming_Tool::NamedShape (anOldShape, aShapeAttr->Label()); |
d2c90917 |
216 | aValues << DFBrowserPane_Tools::ToName (DB_NS_TYPE, aShapeAttrIt.Evolution()).ToCString() |
217 | << (aShapeAttrIt.IsModification() ? "modified" : "-"); |
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()) |
230 | aValues << DFBrowserPane_Tools::GetPointerInfo (aNewShape.TShape()->This()).ToCString() |
231 | << DFBrowserPane_Tools::ShapeTypeInfo (aNewShape) |
232 | << ""; |
233 | else |
d2c90917 |
234 | aValues << "-" << "-" << ""; |
235 | aValues << "Old:"; |
14bbbdcb |
236 | if (!anOldShape.IsNull()) |
237 | aValues << DFBrowserPane_Tools::GetPointerInfo (anOldShape.TShape()->This()).ToCString() |
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(); |
d2c90917 |
260 | anIndices << myEvolutionPaneModel->index (aRowId, 3) << myEvolutionPaneModel->index (aRowId, 4) |
261 | << myEvolutionPaneModel->index (aRowId, 5); |
14bbbdcb |
262 | myHelperExport.AddShape (aNewShape, anIndices); |
263 | } |
264 | if (!anOldShape.IsNull()) |
265 | { |
266 | anIndices.clear(); |
d2c90917 |
267 | anIndices << myEvolutionPaneModel->index (aRowId, 7) << myEvolutionPaneModel->index (aRowId, 8) |
268 | << myEvolutionPaneModel->index (aRowId, 10); |
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, |
370 | NCollection_List<Handle(Standard_Transient)>& theParameters) |
371 | { |
372 | QTableView* aTableView = myTableView->GetTableView(); |
373 | if (aTableView->selectionModel() != theModel) |
374 | return; |
375 | |
376 | QModelIndexList aSelectedIndices = theModel->selectedIndexes(); |
377 | if (aSelectedIndices.size() != 1) |
378 | return; |
379 | |
380 | QModelIndex aSelectedIndex = aSelectedIndices.first(); |
d2c90917 |
381 | if (aSelectedIndex.column() != 4) |
14bbbdcb |
382 | return; |
383 | |
384 | const TopoDS_Shape& aShape = myHelperExport.GetShape (aSelectedIndex); |
385 | if (aShape.IsNull()) |
386 | return; |
387 | theParameters.Append (aShape.TShape()); |
388 | } |
389 | |
390 | // ======================================================================= |
391 | // function : GetReferences |
392 | // purpose : |
393 | // ======================================================================= |
394 | void DFBrowserPane_TNamingNamedShape::GetReferences (const Handle(TDF_Attribute)& theAttribute, |
395 | NCollection_List<TDF_Label>& theRefLabels, |
396 | Handle(Standard_Transient)& theRefPresentation) |
397 | { |
398 | if (!myEvolutionTableView) |
399 | return; |
400 | QStringList aSelectedEntries = DFBrowserPane_TableView::GetSelectedColumnValues ( |
d2c90917 |
401 | myEvolutionTableView->GetTableView(), 9); |
14bbbdcb |
402 | |
403 | Handle(TNaming_NamedShape) aShapeAttr = Handle(TNaming_NamedShape)::DownCast (theAttribute); |
404 | for (TNaming_Iterator aShapeAttrIt (aShapeAttr); aShapeAttrIt.More(); aShapeAttrIt.Next()) |
405 | { |
406 | const TopoDS_Shape& anOldShape = aShapeAttrIt.OldShape(); |
407 | |
408 | Handle(TNaming_NamedShape) anOldAttr = TNaming_Tool::NamedShape (anOldShape, aShapeAttr->Label()); |
409 | QString aLabelInfo; |
410 | if (!anOldAttr.IsNull()) |
411 | { |
412 | TDF_Label anOldLabel = anOldAttr->Label(); |
413 | if (!anOldLabel.IsNull()) |
414 | { |
415 | if (aSelectedEntries.contains (DFBrowserPane_Tools::GetEntry (anOldLabel).ToCString())) |
416 | theRefLabels.Append (anOldLabel); |
417 | } |
418 | } |
419 | } |
420 | TopoDS_Shape aShape = getSelectedShapes(); |
421 | if (!aShape.IsNull()) |
422 | theRefPresentation = new AIS_Shape (aShape); |
423 | } |
424 | |
425 | // ======================================================================= |
426 | // function : GetPresentation |
427 | // purpose : |
428 | // ======================================================================= |
429 | Handle(Standard_Transient) DFBrowserPane_TNamingNamedShape::GetPresentation (const Handle(TDF_Attribute)& theAttribute) |
430 | { |
431 | Handle(Standard_Transient) aPresentation; |
432 | Handle(TNaming_NamedShape) aShapeAttr = Handle(TNaming_NamedShape)::DownCast (theAttribute); |
433 | if (aShapeAttr.IsNull()) |
434 | return aPresentation; |
435 | |
436 | TopoDS_Shape aShape = aShapeAttr->Get(); |
437 | if (aShape.IsNull()) |
438 | return aPresentation; |
439 | |
440 | aPresentation = new AIS_Shape (aShape); |
441 | return aPresentation; |
442 | } |
443 | |
444 | // ======================================================================= |
445 | // function : getSelectedShapes |
446 | // purpose : |
447 | // ======================================================================= |
448 | TopoDS_Shape DFBrowserPane_TNamingNamedShape::getSelectedShapes() |
449 | { |
450 | TopoDS_Shape aShape; |
451 | |
452 | if (!myTableView && !myEvolutionTableView) |
453 | return aShape; |
454 | |
455 | // table view selected shapes |
456 | QItemSelectionModel* aTableViewSelModel = myTableView->GetTableView()->selectionModel(); |
457 | QModelIndexList anIndices = aTableViewSelModel->selectedIndexes(); |
458 | |
459 | BRep_Builder aBuilder; |
460 | TopoDS_Compound aComp; |
461 | aBuilder.MakeCompound (aComp); |
462 | bool aHasShapes = false; |
463 | for (QModelIndexList::const_iterator anIt = anIndices.begin(), aLast = anIndices.end(); anIt != aLast; anIt++) |
464 | { |
465 | QModelIndex anIndex = *anIt; |
466 | if (!myHelperExport.HasShape (anIndex)) |
467 | continue; |
468 | aBuilder.Add (aComp, myHelperExport.GetShape (anIndex)); |
469 | aHasShapes = true; |
470 | } |
471 | |
472 | // evolution table selected shapes |
473 | aTableViewSelModel = myEvolutionTableView->GetTableView()->selectionModel(); |
474 | anIndices.clear(); |
475 | anIndices = aTableViewSelModel->selectedIndexes(); |
476 | for (QModelIndexList::const_iterator anIt = anIndices.begin(), aLast = anIndices.end(); anIt != aLast; anIt++) |
477 | { |
478 | QModelIndex anIndex = *anIt; |
479 | if (!myHelperExport.HasShape (anIndex)) |
480 | continue; |
481 | aBuilder.Add (aComp, myHelperExport.GetShape (anIndex)); |
482 | aHasShapes = true; |
483 | } |
484 | if (aHasShapes) |
485 | aShape = aComp; |
486 | return aShape; |
487 | } |