1 // Copyright (C) 2009-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 #include "utilities.h"
26 #include <QtxWorkstack.h>
27 #include <STD_TabDesktop.h>
28 #include <STD_MDIDesktop.h>
29 #include <STD_SDIDesktop.h>
31 #include <SalomeApp_Tools.h>
33 #include "SOCC_ViewModel.h"
34 #include <OCCViewer_ViewManager.h>
35 #include <OCCViewer_ViewModel.h>
36 #include <OCCViewer_ViewWindow.h>
38 #include <SUIT_OverrideCursor.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_Session.h>
41 #include <SUIT_Selector.h>
42 #include <SUIT_Desktop.h>
43 #include <SUIT_ViewManager.h>
44 #include <SVTK_View.h>
46 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
47 #include "HEXABLOCKGUI_OccGraphicView.hxx"
48 #include "HEXABLOCKGUI_SalomeTools.hxx"
49 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
50 #include "HEXABLOCKGUI_DocumentItem.hxx"
51 #include "HEXABLOCKGUI.hxx"
54 #include <SVTK_Selector.h>
55 #include <SVTK_ViewModel.h>
58 #include <SalomeApp_Study.h>
59 #include <SalomeApp_Application.h>
60 #include <SALOME_Actor.h>
61 #include <SALOME_ListIO.hxx>
62 #include <AIS_ListIteratorOfListOfInteractive.hxx>
66 #include <OCCViewer_ViewModel.h>
67 #include <SVTK_ViewModel.h>
68 #include <SalomeApp_Study.h>
69 #include <SalomeApp_Application.h>
70 #include <LightApp_SelectionMgr.h>
72 #include <TopExp_Explorer.hxx>
73 #include <TopoDS_Iterator.hxx>
74 #include <TopTools_MapOfShape.hxx>
75 #include <TopTools_IndexedMapOfShape.hxx>
76 #include <TColStd_IndexedMapOfInteger.hxx>
81 using namespace HEXABLOCK::GUI;
84 // //===========================================================================
86 // //===========================================================================
88 bool SelectionModel::infoMode = true;
90 SelectionModel::SelectionModel( QAbstractItemModel * model ):
91 QItemSelectionModel( model )
96 SelectionModel::~SelectionModel()
98 disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) );
102 QModelIndex SelectionModel::indexBy( int role, const QString& value )
104 QModelIndex eltIndex; // element (vertex, edge, quad) of model
105 const QAbstractItemModel* theModel = model();
106 if ( !theModel ) return eltIndex;
107 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
111 Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
112 if ( theIndexes.count()>0 )
113 eltIndex = theIndexes[0] ;
118 QModelIndex SelectionModel::indexBy( int role, const QVariant& var )
120 QModelIndex eltIndex; // element (vertex, edge, quad) of model
121 const QAbstractItemModel* theModel = model();
122 if ( !theModel ) return eltIndex;
123 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
127 Qt::MatchRecursive /*| Qt::MatchContains*/ );//Qt::MatchFixedString );
128 if ( theIndexes.count()>0 )
129 eltIndex = theIndexes[0] ;
133 QModelIndex SelectionModel::indexOf( const QString& anEntry, int role )
135 QModelIndex eltIndex; // element (vertex, edge, quad) of model
136 const QAbstractItemModel* theModel = model();
137 if ( !theModel ) return eltIndex;
139 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
143 Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
144 if ( theIndexes.count()>0 )
145 eltIndex = theIndexes[0] ;
150 QModelIndexList SelectionModel::indexListOf( const QString& anEntry, int role )
152 QModelIndexList theIndexes; // element (vertex, edge, quad) of model
153 const QAbstractItemModel* theModel = model();
154 if ( !theModel ) return theIndexes;
155 theIndexes = theModel->match( theModel->index(0, 0),
159 Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
163 DocumentModel* SelectionModel::getDocModel() const
165 DocumentModel* docModel = NULL;
166 const QSortFilterProxyModel *pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
168 docModel = dynamic_cast<DocumentModel*>( pModel->sourceModel() );
173 void SelectionModel::showEltInfo(QModelIndex& elt)
175 DocumentModel* docModel = getDocModel();
176 if (!elt.isValid() || docModel == NULL)
179 HEXA_NS::Vertex* vertex = docModel->getHexaPtr<HEXA_NS::Vertex*>(elt);
180 HEXA_NS::Edge* edge = docModel->getHexaPtr<HEXA_NS::Edge*>(elt);
181 HEXA_NS::Quad* quad = docModel->getHexaPtr<HEXA_NS::Quad*>(elt);
182 HEXA_NS::Hexa* hexa = docModel->getHexaPtr<HEXA_NS::Hexa*>(elt);
183 HEXA_NS::Vector* vector = docModel->getHexaPtr<HEXA_NS::Vector*>(elt);
184 HEXA_NS::Group* group = docModel->getHexaPtr<HEXA_NS::Group*>(elt);
185 HEXA_NS::Law* law = docModel->getHexaPtr<HEXA_NS::Law*>(elt);
186 HEXA_NS::Propagation* propagation = docModel->getHexaPtr<HEXA_NS::Propagation*>(elt);
188 HEXABLOCKGUI* hexagui = HEXABLOCKGUI::getInstance();
190 hexagui->showVertexInfoDialog(vertex);
191 else if (edge != NULL)
192 hexagui->showEdgeInfoDialog(edge);
193 else if (quad != NULL)
194 hexagui->showQuadInfoDialog(quad);
195 else if (hexa != NULL)
196 hexagui->showHexaInfoDialog(hexa);
197 else if (vector != NULL)
198 hexagui->showVectorInfoDialog(vector);
199 else if (group != NULL)
200 hexagui->showGroupInfoDialog(group);
201 else if (law != NULL)
202 hexagui->showLawInfoDialog(law);
203 else if (propagation != NULL)
204 hexagui->showPropagationInfoDialog(propagation);
207 void SelectionModel::salomeSelectionChanged()
209 // clear highlights and selections in the trees
210 PatternDataSelectionModel* pdsm = HEXABLOCKGUI::currentDocGView->getPatternDataSelectionModel();
211 // PatternBuilderSelectionModel* pbsm = HEXABLOCKGUI::currentDocGView->getPatternBuilderSelectionModel();
212 PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
213 pdsm->clearSelection();
214 // pbsm->clearSelection();
215 pgsm->clearSelection();
216 pdsm->unhighlightTreeItems();
217 pgsm->unhighlightTreeItems();
220 SALOME_ListIO selectedObjects;
221 Handle(SALOME_InteractiveObject) anIObject;
223 switch (HEXABLOCKGUI::getActiveViewType())
225 case HEXABLOCKGUI::VTK:
227 HEXABLOCKGUI::currentDocGView->getSelected(selectedObjects);
228 if ( selectedObjects.IsEmpty() )
230 anIObject = selectedObjects.First();
231 vtkSelectionChanged( anIObject );
234 case HEXABLOCKGUI::OCC:
235 HEXABLOCKGUI::currentOccGView->getSelected(selectedObjects);
236 if ( selectedObjects.IsEmpty() )
238 anIObject = selectedObjects.First();
239 geomSelectionChanged( anIObject );
243 MESSAGE("* Unknown selection exception!");
248 QModelIndexList SelectionModel::getSelectionFromModel(const Handle(SALOME_InteractiveObject)& anIObject)
250 QModelIndexList selectedIndexes;
252 //verify if the IOBject is valid and from VTK selection
253 bool fromVTK = ( strcmp("HEXABLOCK", anIObject->getComponentDataType()) == 0 );
254 if ( !fromVTK || !anIObject->hasEntry() || HEXABLOCKGUI::currentDocGView->getViewWindow() == NULL)
255 return selectedIndexes;
257 QString anIOEntry = anIObject->getEntry();
261 //extract vtk selection from the model -----------
262 if ( GetNameOfSelectedElements( HEXABLOCKGUI::currentDocGView->getViewWindow(), anIObject, aText ) <= 0 )
263 return selectedIndexes;
265 Document_Actor* docActor = dynamic_cast<Document_Actor*>( findActorByEntry( HEXABLOCKGUI::currentDocGView->getViewWindow(),
266 anIOEntry.toLatin1() ) );
267 if ( !docActor ) return selectedIndexes;
268 QStringList idList = aText.split(" ");
269 foreach( const QString& id, idList )
273 //find selection in the model
274 anhexaElemsId = docActor->hexaElemsId[ id.toInt() ];
275 anIOEntry = QString::number( anhexaElemsId );
277 selectedIndexes << indexOf( anIOEntry, HEXA_ENTRY_ROLE );
280 return selectedIndexes;
283 // //===========================================================================
284 // PatternDataSelectionModel
285 // //===========================================================================
287 PatternDataSelectionModel::PatternDataSelectionModel( QAbstractItemModel * model ):
288 SelectionModel( model )
290 connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
291 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ), Qt::UniqueConnection );
292 connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
293 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection );
297 PatternDataSelectionModel::~PatternDataSelectionModel()
299 disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
300 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
301 disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
302 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
306 void PatternDataSelectionModel::onCurrentChanged( const QModelIndex & current, const QModelIndex & previous )
308 //Setting the selection mode of the selected item from the treeview
309 HEXABLOCKGUI::currentDocGView->setSelectionMode( current );
310 HEXABLOCKGUI::currentOccGView->setSelectionMode( current );
313 void PatternDataSelectionModel::highlightTreeItems(QModelIndexList& indexes,
314 Qt::GlobalColor bgColor,
315 Qt::GlobalColor fgColor, bool only)
317 if (indexes.count() == 0)
321 unhighlightTreeItems();
324 QAbstractItemModel* theModel = (QAbstractItemModel*) model();
325 foreach( const QModelIndex& anItemIndex, indexes )
327 if (anItemIndex.isValid())
329 theModel->setData(anItemIndex, QColor(fgColor), Qt::ForegroundRole);
330 theModel->setData(anItemIndex, QColor(bgColor), Qt::BackgroundRole);
331 currentHighlightedItems << anItemIndex;
335 // * scroll to the first highlighted item in the tree
336 HEXABLOCKGUI* module = HEXABLOCKGUI::getInstance();
337 if (module != NULL && indexes[0].isValid())
338 module->getPatternDataTreeView()->scrollTo(indexes[0]);
341 void PatternDataSelectionModel::unhighlightTreeItems(bool clearSelected)
345 if (currentHighlightedItems.count() == 0)
348 QAbstractItemModel* theModel = (QAbstractItemModel*) model();
349 foreach( const QModelIndex& anItemIndex, currentHighlightedItems)
351 if (anItemIndex.isValid())
353 theModel->setData(anItemIndex, QColor(Qt::darkGreen), Qt::ForegroundRole);
354 theModel->setData(anItemIndex, QColor(Qt::white), Qt::BackgroundRole);
357 currentHighlightedItems.clear();
360 QModelIndexList PatternDataSelectionModel::getGeomAssociations(const QModelIndex& dataIndex)
362 QModelIndexList geomIndexList;
363 DocumentModel* docModel = getDocModel();
364 PatternGeomSelectionModel* pGSModel = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
365 if (docModel == NULL || pGSModel == NULL)
366 return geomIndexList;
368 const QSortFilterProxyModel *pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
369 HEXA_NS::Vertex* vertex = docModel->getHexaPtr<HEXA_NS::Vertex*>(dataIndex);
370 HEXA_NS::Edge* edge = docModel->getHexaPtr<HEXA_NS::Edge*>(dataIndex);
371 HEXA_NS::Quad* quad = docModel->getHexaPtr<HEXA_NS::Quad*>(dataIndex);
372 QModelIndex index = pModel->mapToSource(dataIndex);
375 geomIndexList << docModel->getVertexAssociation( index );
376 else if (edge != NULL)
377 geomIndexList = docModel->getEdgeAssociations( index );
378 else if ( quad != NULL)
379 geomIndexList = docModel->getQuadAssociations( index );
381 return geomIndexList;
384 void PatternDataSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
386 QModelIndexList indexes = selected.indexes();
387 int nbSelected = indexes.count();
391 // ** unhighlight current highlighted items in the trees
392 PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
395 unhighlightTreeItems(false);
397 QModelIndexList associatedGeomIndexes = getGeomAssociations(indexes[0]); //Mono Selection
398 if (associatedGeomIndexes.count() == 0)
399 pgsm->unhighlightTreeItems();
401 // ** highlight association in geometry tree
402 pgsm->highlightTreeItems(associatedGeomIndexes);
404 // ** highlight association in the vtk view
405 HEXABLOCKGUI::currentDocGView->highlight(indexes);
407 // ** highlight association in the occ view
408 HEXABLOCKGUI::currentOccGView->highlight(indexes);
410 if (!infoMode || nbSelected > 1)
413 // ** Show informations of the selected element
414 QModelIndex elt = indexes[0];
418 void PatternDataSelectionModel::geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject )
420 // if (HEXABLOCKGUI::assocInProgress) return;
422 PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
423 if (pgsm == NULL) return;
425 QModelIndex geomModelIndex = pgsm->getModelIndex(anIObject);
426 if (!geomModelIndex.isValid())
428 pgsm->select( geomModelIndex, QItemSelectionModel::SelectCurrent );
432 void PatternDataSelectionModel::vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject )
434 QModelIndexList selectedIndexes = getSelectionFromModel(anIObject);
435 if (selectedIndexes.count() == 0)
440 QModelIndex anIOIndex = selectedIndexes[0]; //Monoselection
442 //Temporary Debug for hexa selection ------------------------------
443 if (HEXABLOCKGUI::currentDocGView->getSelectionMode() == HEXA_TREE)
445 DocumentModel* docModel = getDocModel();
446 if ( docModel != NULL && anIOIndex.isValid())
448 //get the selected quad
449 HEXA_NS::Quad* quad = docModel->getHexaPtr<HEXA_NS::Quad*>(anIOIndex);
453 //get the hexa the quad belongs to
454 HEXA_NS::Hexa* hexa = docModel->getQuadHexa(quad);
455 if (hexa != NULL) //convert the hexa to a QModelIndex so we can select it in the model
456 anIOIndex = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(hexa));
459 SUIT_MessageBox::critical( 0,
461 tr("The Hexahedron this quad belongs to has been deleted!"));
466 }//end if HEXA_TREE-----------------------------------------------
468 //select the element in the model
469 select( anIOIndex, QItemSelectionModel::SelectCurrent );
472 // //===========================================================================
473 // PatternGeomSelectionModel
474 // //===========================================================================
476 PatternGeomSelectionModel::PatternGeomSelectionModel( QAbstractItemModel * model ):
477 SelectionModel( model )
479 connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
480 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
481 connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
482 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection );
485 PatternGeomSelectionModel::~PatternGeomSelectionModel()
487 disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
488 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
489 disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
490 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
493 void PatternGeomSelectionModel::onCurrentChanged( const QModelIndex & current, const QModelIndex & previous )
495 //Setting the selection mode of the selected item from the treeview}
496 HEXABLOCKGUI::currentDocGView->setSelectionMode( current );
497 HEXABLOCKGUI::currentOccGView->setSelectionMode( current );
500 void PatternGeomSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
502 DocumentModel* docModel = NULL;
503 const QSortFilterProxyModel *pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
505 docModel = dynamic_cast<DocumentModel*>(pModel->sourceModel());
507 QModelIndexList indexes = selected.indexes();
508 if (indexes.count() == 0 || docModel == NULL)
511 // ** unhighlight current highlighted items in the trees
512 PatternDataSelectionModel* pdsm = HEXABLOCKGUI::currentDocGView->getPatternDataSelectionModel();
515 unhighlightTreeItems(false);
517 //find the corresponding element in the model
518 HEXA_NS::SubShape* eltSubShape = dynamic_cast<HEXA_NS::SubShape*>(docModel->getHexaPtr(indexes[0]));
519 if (eltSubShape == NULL) return;
521 HEXA_NS::NewShape* subShapeParent = eltSubShape->getParentShape();
522 if (subShapeParent == NULL) return;
524 QString parentShapeName = subShapeParent->getName();
525 QString subId = QString::number(eltSubShape->getIdent());
526 QString aGeomObjModelEntry = parentShapeName + "," + subId + ";";
528 QModelIndexList assocsIndexes = pdsm->indexListOf(aGeomObjModelEntry, HEXA_ASSOC_ENTRY_ROLE);
529 if (assocsIndexes.count() == 0)
530 pdsm->unhighlightTreeItems();
532 // ** highlight associations in the data tree
533 pdsm->highlightTreeItems(assocsIndexes);
535 // ** highlight associations in the vtk view
536 HEXABLOCKGUI::currentDocGView->highlight(assocsIndexes);
538 // ** highlight the selected element in the occ view
539 QMultiMap<QString, int> entrySubIDs;
540 entrySubIDs.insert(parentShapeName, eltSubShape->getIdent());
541 HEXABLOCKGUI::currentOccGView->highlight(entrySubIDs);
544 QModelIndex PatternGeomSelectionModel::getModelIndex(const Handle(SALOME_InteractiveObject)& anIObject)
547 DocumentModel *docModel = NULL;
548 const QSortFilterProxyModel *pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
550 docModel = dynamic_cast<DocumentModel*>( pModel->sourceModel());
552 if ( docModel == NULL || HEXABLOCKGUI::selectionMgr() == NULL ||
553 HEXABLOCKGUI::currentOccGView->getViewWindow() == NULL)
556 //extract associated elements in the model
557 TColStd_IndexedMapOfInteger anIndexes;
558 HEXABLOCKGUI::selectionMgr()->GetIndexes(anIObject, anIndexes);
559 if (anIndexes.Extent() == 0) return result;
560 QString aGeomObjStudyEntry = anIObject->getEntry();
561 QString aGeomObjModelEntry = docModel->getGeomObjName(aGeomObjStudyEntry) + "," + QString::number(anIndexes(1));
563 HEXA_NS::SubShape* ssh = docModel->getGeomPtr(aGeomObjModelEntry);
564 HEXA_NS::VertexShape* vSh = dynamic_cast<HEXA_NS::VertexShape*>(ssh);
565 HEXA_NS::EdgeShape* eSh = dynamic_cast<HEXA_NS::EdgeShape*>(ssh);
566 HEXA_NS::FaceShape* fSh = dynamic_cast<HEXA_NS::FaceShape*>(ssh);
569 result = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(vSh));
570 else if (eSh != NULL)
571 result = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(eSh));
572 else if (fSh != NULL)
573 result = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(fSh));
578 void PatternGeomSelectionModel::highlightTreeItems(QModelIndexList& indexes,
579 Qt::GlobalColor bgColor,
580 Qt::GlobalColor fgColor, bool only)
582 if (indexes.count() == 0)
586 unhighlightTreeItems();
589 QAbstractItemModel* theModel = (QAbstractItemModel*) model();
590 foreach( const QModelIndex& anItemIndex, indexes )
592 if (anItemIndex.isValid())
594 theModel->setData(anItemIndex, QColor(fgColor), Qt::ForegroundRole);
595 theModel->setData(anItemIndex, QColor(bgColor), Qt::BackgroundRole);
596 currentHighlightedItems << anItemIndex;
600 // * scroll to the first highlighted item in the tree
601 HEXABLOCKGUI* module = HEXABLOCKGUI::getInstance();
602 if (module != NULL && indexes[0].isValid())
603 module->getPatternGeomTreeView()->scrollTo(indexes[0]);
606 void PatternGeomSelectionModel::unhighlightTreeItems(bool clearSelected)
610 if (currentHighlightedItems.count() == 0)
612 QAbstractItemModel* theModel = (QAbstractItemModel*) model();
613 foreach( const QModelIndex& anItemIndex, currentHighlightedItems)
615 if (anItemIndex.isValid())
617 theModel->setData(anItemIndex, QColor(Qt::darkGreen), Qt::ForegroundRole);
618 theModel->setData(anItemIndex, QColor(Qt::white), Qt::BackgroundRole);
621 currentHighlightedItems.clear();
624 // //===========================================================================
625 // GroupsSelectionModel
626 // //===========================================================================
627 GroupsSelectionModel::GroupsSelectionModel( QAbstractItemModel * model ):
628 SelectionModel( model )
630 connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
631 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ), Qt::UniqueConnection );
632 connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
633 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection );
636 GroupsSelectionModel::~GroupsSelectionModel()
638 disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
639 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
640 disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
641 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
644 void GroupsSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
646 QModelIndexList indexes = selected.indexes();
647 int nbSelected = indexes.count();
651 // ** Highlight the group in the vtk view **/
653 for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
654 HEXABLOCKGUI::currentDocGView->highlightGroups( *i_index );
657 MESSAGE("Unknown exception was cought !!!");
660 if (!infoMode || nbSelected > 1)
663 // ** Show informations of the selected element **/
664 QModelIndex elt = indexes[0];
668 // //===========================================================================
669 // MeshSelectionModel
670 // //===========================================================================
671 MeshSelectionModel::MeshSelectionModel( QAbstractItemModel * model ):
672 SelectionModel( model )
674 connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
675 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ), Qt::UniqueConnection );
676 connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
677 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection );
680 MeshSelectionModel::~MeshSelectionModel()
682 disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
683 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
684 disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
685 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
689 void MeshSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
691 QModelIndexList indexes = selected.indexes();
692 int nbSelected = indexes.count();
697 for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
698 HEXABLOCKGUI::currentDocGView->highlightPropagation( *i_index );
701 MESSAGE("Unknown exception was cought !!!");
704 if (!infoMode || nbSelected > 1)
707 // ** Show informations of the selected element **/
708 QModelIndex elt = indexes[0];