1 // Copyright (C) 2009-2012 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.
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>
47 #include "HEXABLOCKGUI_SalomeTools.hxx"
48 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
49 #include "HEXABLOCKGUI_DocumentModel.hxx"
50 #include "HEXABLOCKGUI_DocumentGraphicView.hxx"
51 #include "HEXABLOCKGUI_DocumentItem.hxx"
52 #include "HEXABLOCKGUI.hxx"
55 #include <SVTK_Selector.h>
56 #include <SVTK_ViewModel.h>
59 #include <SalomeApp_Study.h>
60 #include <SalomeApp_Application.h>
61 #include <SALOME_Actor.h>
62 #include <SALOME_ListIO.hxx>
63 #include <SALOME_ListIteratorOfListIO.hxx>
68 #include "MyGEOMBase_Helper.hxx"
70 #include <OCCViewer_ViewModel.h>
71 #include <SVTK_ViewModel.h>
72 #include <SalomeApp_Study.h>
73 #include <SalomeApp_Application.h>
74 #include <LightApp_SelectionMgr.h>
75 #include <SALOME_ListIteratorOfListIO.hxx>
77 #include <TopExp_Explorer.hxx>
78 #include <TopoDS_Iterator.hxx>
79 #include <TopTools_MapOfShape.hxx>
80 #include <TopTools_IndexedMapOfShape.hxx>
81 #include <TColStd_IndexedMapOfInteger.hxx>
86 using namespace HEXABLOCK::GUI;
90 PatternDataSelectionModel::PatternDataSelectionModel( QAbstractItemModel * model ):
91 QItemSelectionModel( model ),
92 MyGEOMBase_Helper( SUIT_Session::session()->activeApplication()->desktop() ),
93 _theModelSelectionChanged(false),
94 _theVtkSelectionChanged(false),
95 _theGeomSelectionChanged(false),
96 salomeNothingSelected(true),
98 _salomeSelectionMgr(0)
100 connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
101 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
102 connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
103 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
107 PatternDataSelectionModel::~PatternDataSelectionModel()
109 disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
110 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
111 disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
112 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
114 // if ( _salomeSelectionMgr )
115 // disconnect( _salomeSelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) );
116 disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) );
119 void PatternDataSelectionModel::setVertexSelection()
121 MESSAGE("PatternDataSelectionModel::setVertexSelection(){");
122 SetSelectionMode(NodeSelection);
125 // // EdgeOfCellSelection,
128 // // VolumeSelection,
129 // // ActorSelection };
130 _selectionFilter = VERTEX_TREE;
134 void PatternDataSelectionModel::setEdgeSelection()
136 MESSAGE("PatternDataSelectionModel::setEdgeSelection(){");
137 SetSelectionMode(EdgeSelection);
138 _selectionFilter = EDGE_TREE;
142 void PatternDataSelectionModel::setQuadSelection()
144 MESSAGE("PatternDataSelectionModel::setQuadSelection(){");
145 SetSelectionMode(FaceSelection);
146 _selectionFilter = QUAD_TREE;
150 void PatternDataSelectionModel::setHexaSelection()
152 MESSAGE("PatternDataSelectionModel::setHexaSelection(){");
153 // SetSelectionMode(VolumeSelection);
154 SetSelectionMode(FaceSelection); //temporary for hexa selection debug
155 _selectionFilter = HEXA_TREE;
160 void PatternDataSelectionModel::setAllSelection()
162 MESSAGE("PatternDataSelectionModel::setAllSelection(){");
163 SetSelectionMode(ActorSelection);
164 _selectionFilter = -1;
169 QModelIndex PatternDataSelectionModel::indexBy( int role, const QString& value )
171 QModelIndex eltIndex; // element (vertex, edge, quad) of model
172 const QAbstractItemModel* theModel = model();
173 if ( !theModel ) return eltIndex;
174 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
178 Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
179 if ( theIndexes.count()>0 )
180 eltIndex = theIndexes[0] ;
185 QModelIndex PatternDataSelectionModel::indexBy( int role, const QVariant& var )
187 QModelIndex eltIndex; // element (vertex, edge, quad) of model
188 const QAbstractItemModel* theModel = model();
189 if ( !theModel ) return eltIndex;
190 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
194 Qt::MatchRecursive /*| Qt::MatchContains*/ );//Qt::MatchFixedString );
195 if ( theIndexes.count()>0 )
196 eltIndex = theIndexes[0] ;
201 void PatternDataSelectionModel::setSalomeSelectionMgr( LightApp_SelectionMgr* mgr )
203 _salomeSelectionMgr = mgr;
204 connect( _salomeSelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) );
208 void PatternDataSelectionModel::SetSelectionMode(Selection_Mode theMode)
210 MESSAGE("PatternDataSelectionModel::SetSelectionMode(){");
211 // SVTK_ViewWindow* aVTKViewWindow = _getVTKViewWindow();
212 // aViewWindow->clearFilters();
213 // _salomeSelectionMgr->clearFilters();
214 if ( _getVTKViewWindow() != NULL )
215 _getVTKViewWindow()->SetSelectionMode( theMode );
220 // A) De Salome(OCC, VTK) vers Hexablock(TreeView Data) :
222 // in: selection (vertex associé OCC).
223 // out: (vertex VTK) highlighté, (vertex TreeView) sélectionné.
225 // in : selection (vertex associé VTK).
226 // out: (vertex OCC) highlighté, (vertex TreeView) sélectionné.
229 // in: selection (edge associé OCC).
230 // out: (vertex VTK) highlighté, (vertex TreeView) sélectionné.
232 // in: selection (edge associé VTK).
233 // out: (toute la ligne OCC) highlighté + vertex sur (deb,fin) , (edge TreeView) sélectionné.
235 // -Face: idem vertex
236 void PatternDataSelectionModel::onCurrentChanged( const QModelIndex & current, const QModelIndex & previous )
238 MESSAGE("PatternDataSelectionModel::onCurrentChanged(){");
239 MESSAGE("* current : " << current.data().toString().toStdString());
240 MESSAGE("* previous : " << previous.data().toString().toStdString());
242 //Setting the selection mode of the selected item from the treeview
243 _setVTKSelectionMode( current);
245 // _selectSalome( current, true );
246 // _selectSalome( previous, false );
250 void PatternDataSelectionModel::highlightEltsWithAssocs(const QModelIndexList& elts)
253 // if ( HEXABLOCKGUI::selectionMgr() != NULL) HEXABLOCKGUI::selectionMgr()->clearSelected();
254 highlightVTKElts(elts);
255 for( QModelIndexList::const_iterator i_index = elts.begin(); i_index != elts.end(); ++i_index ){
256 // _selectVTK( *i_index );
257 _highlightGEOM( *i_index );
260 MESSAGE("Unknown exception was cought !!!");
264 void PatternDataSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
266 // MESSAGE("PatternDataSelectionModel::onSelectionChanged(){");
267 // foreach( const QModelIndex& isel, selected.indexes() ){
268 // MESSAGE("* selected : " << isel.data().toString().toStdString());
270 // foreach( const QModelIndex& iunsel, deselected.indexes() ){
271 // MESSAGE("* unselected : " << iunsel.data().toString().toStdString());
274 // _theModelSelectionChanged = true;
276 // if ( _salomeSelectionMgr == NULL ) return;
277 //// if ( !_theVtkSelectionChanged and !_theGeomSelectionChanged ) return;
279 // _salomeSelectionMgr->clearSelected();
280 // // erasePreview(true);
281 // QModelIndexList indexes = selected.indexes();
282 // for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
283 // // std::cout << "entry selected" << i_index->data( HEXA_ENTRY_ROLE ).toString().toStdString() << std::endl;
284 // if ( !_theVtkSelectionChanged ) _selectVTK( *i_index );
285 // if ( !_theGeomSelectionChanged ) _highlightGEOM( *i_index );
287 // // CS_BP todo SALOMEGUI_Swig.cxx:370
288 // // indexes = deselected.indexes();
289 // // for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index )
290 // // _unselectSalome( *i_index);
292 // MESSAGE("Unknown exception was cought !!!");
294 // _theModelSelectionChanged = false;
299 void PatternDataSelectionModel::salomeSelectionChanged()
301 MESSAGE("PatternDataSelectionModel::salomeSelectionChanged(){");
303 QModelIndex toSelect;
305 if ( _salomeSelectionMgr == NULL ) return;
306 SALOME_ListIO salomeSelected;
307 // _salomeSelectionMgr->selectedObjects( salomeSelected, SVTK_Viewer::Type() );//salomeSelected.Extent()
308 _salomeSelectionMgr->selectedObjects( salomeSelected, NULL, false );
309 if ( salomeSelected.IsEmpty() ){
310 MESSAGE("* salomeSelected.IsEmpty()");
311 salomeNothingSelected = true;
316 Handle(SALOME_InteractiveObject) anIObject;
318 SALOME_ListIteratorOfListIO it(salomeSelected);
319 for( ; it.More(); it.Next()){
320 anIObject = it.Value(); //anIObject->getName()
321 toSelect = _geomSelectionChanged( anIObject );// is it comming from GEOM?
322 if ( !toSelect.isValid() ){
323 toSelect = _vtkSelectionChanged( anIObject ); ;// or VTK?...
324 if ( toSelect.isValid() )
325 MESSAGE("* OK : selection from VTK");
327 MESSAGE("* OK : selection from GEOM");
330 salomeNothingSelected = false;
332 MESSAGE("* Unknown exception was cought !!!");
337 QModelIndex PatternDataSelectionModel::_geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject )
339 MESSAGE("PatternDataSelectionModel::_geomSelectionChanged(){");
340 QModelIndexList assocsIndexes;// elements of the model which is associated to the geom object and that is to be selected
341 QModelIndex assocIndex;
343 if (HEXABLOCKGUI::assocInProgress) return assocIndex;
344 bool fromGEOM = ( strcmp("GEOM", anIObject->getComponentDataType()) == 0 );
345 if ( !fromGEOM ) return assocIndex;
346 if (!_salomeSelectionMgr) return assocIndex;
349 GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject( anIObject );
352 if ( GEOMBase::IsShape(aGeomObj) ){
353 aName = GEOMBase::GetName(aGeomObj);
354 TColStd_IndexedMapOfInteger anIndexes;
355 _salomeSelectionMgr->GetIndexes(anIObject, anIndexes);
356 if ( anIndexes.Extent() == 1 )
357 anIndex = anIndexes(1);
358 QString aGeomObjStudyEntry = aGeomObj->GetStudyEntry();
359 QString aGeomObjModelEntry = aGeomObjStudyEntry + "," + QString::number(anIndex) + ";";
360 assocsIndexes = _indexListOf( aGeomObjModelEntry, HEXA_ASSOC_ENTRY_ROLE );
361 if ( !_theModelSelectionChanged && assocsIndexes.count()>0 && assocsIndexes[0].isValid() ){ // select in model
362 _theGeomSelectionChanged = true;
363 setCurrentIndex( assocsIndexes[0], QItemSelectionModel::Clear ); //CS_TEST
364 setCurrentIndex( assocsIndexes[0], QItemSelectionModel::SelectCurrent );
365 _theGeomSelectionChanged = false;
373 if (assocsIndexes.count() > 0)
375 // HEXABLOCKGUI::currentVtkView->setFocus();
376 highlightVTKElts(assocsIndexes);
377 return assocsIndexes[0];
382 QModelIndex PatternDataSelectionModel::_vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject )
384 MESSAGE("PatternDataSelectionModel::_vtkSelectionChanged(){");
385 QModelIndex anIOIndex;// // the element of the model which is associated to the Interactive object and that is to be selected
387 bool fromVTK = ( strcmp("HEXABLOCK", anIObject->getComponentDataType()) == 0 );
388 if ( !fromVTK ) return anIOIndex;
390 SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
391 if ( !currentVTKViewWindow ) return anIOIndex;
392 if ( !anIObject->hasEntry() ) return anIOIndex;
394 QString anIOEntry = anIObject->getEntry();
395 Document_Actor *anDocActor = NULL;
399 if ( GetNameOfSelectedElements( currentVTKViewWindow, anIObject, aText ) <= 0 ) return anIOIndex;
400 anDocActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, anIOEntry.toLatin1() ) );
401 if ( !anDocActor ) return anIOIndex;
402 anhexaElemsId = anDocActor->hexaElemsId[ aText.toInt() ];
403 anIOEntry = QString::number( anhexaElemsId );
404 anIOIndex = _indexOf( anIOEntry, HEXA_ENTRY_ROLE );
406 if ( !_theModelSelectionChanged && anIOIndex.isValid() ){ // select in model
407 _theVtkSelectionChanged = true;
409 //Temporary Debug for hexa selection -----------------------------------------------------------------
410 if (getSelectionFilter() == HEXA_TREE)
412 DocumentModel *docModel = NULL;
413 const QSortFilterProxyModel *pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
415 if ( pModel != NULL){
416 docModel = dynamic_cast<DocumentModel*>( pModel->sourceModel() );
417 if ( docModel != NULL && anIOIndex.isValid())
419 //get the selected quad
420 HEXA_NS::Quad* quad = docModel->getHexaPtr<HEXA_NS::Quad*>(anIOIndex);
423 //get the hexa the quad belongs to
424 HEXA_NS::Hexa* hexa = docModel->getQuadHexa(quad);
425 if (hexa != NULL) //convert the hexa to a QModelIndex so we can select it in the model
426 anIOIndex = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(hexa));
429 SUIT_MessageBox::critical( 0,
431 tr("The Hexahedron This quad belongs to has been deleted!"));
437 }//end if HEXA_TREE------------------------------------------------------------------------------------
439 setCurrentIndex( anIOIndex, QItemSelectionModel::Clear );
440 setCurrentIndex( anIOIndex, QItemSelectionModel::SelectCurrent );
441 _theVtkSelectionChanged = false;
446 // if (anIOIndex.isValid())
447 // _selectVTK(anIOIndex);
449 // if (anIOIndex.isValid())
451 // QModelIndexList l;
453 // highlightVTKElts(l);
454 // _highlightGEOM(anIOIndex); // JMD test à faire
461 SVTK_ViewWindow* PatternDataSelectionModel::_getVTKViewWindow()
463 // SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView;
464 return HEXABLOCKGUI::currentVtkView;
468 OCCViewer_ViewWindow* PatternDataSelectionModel::_getOCCViewWindow()
470 // OCCViewer_ViewWindow* aOccView = HEXABLOCKGUI::currentOccView;
471 // MESSAGE(" dans OCCViewer" << aOccView);
472 return HEXABLOCKGUI::currentOccView;
476 QModelIndex PatternDataSelectionModel::_indexOf( const QString& anEntry, int role )
478 QModelIndex eltIndex; // element (vertex, edge, quad) of model
479 const QAbstractItemModel* theModel = model();
480 if ( !theModel ) return eltIndex;
481 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
485 Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
486 if ( theIndexes.count()>0 )
487 eltIndex = theIndexes[0] ;
492 QModelIndexList PatternDataSelectionModel::_indexListOf( const QString& anEntry, int role )
494 QModelIndexList theIndexes; // element (vertex, edge, quad) of model
495 const QAbstractItemModel* theModel = model();
496 if ( !theModel ) return theIndexes;
497 theIndexes = theModel->match( theModel->index(0, 0),
501 Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
506 void PatternDataSelectionModel::_setVTKSelectionMode( const QModelIndex& eltIndex )
508 MESSAGE("PatternDataSelectionModel::_setVTKSelectionMode( "<< eltIndex.data().toString().toStdString() << " )");
509 QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE );
510 if ( !treeVariant.isValid() ) return;
511 int eltType = treeVariant.toInt();
513 // if ( (_selectionFilter != -1) and ( _selectionFilter != eltType ) ) return;
514 if ( _selectionFilter == eltType ) return;
518 case VERTEX_DIR_TREE : setVertexSelection(); MESSAGE("VERTEX"); break;
520 case EDGE_DIR_TREE : setEdgeSelection(); MESSAGE("EDGE"); break;
522 case QUAD_DIR_TREE : setQuadSelection(); MESSAGE("QUAD"); break;
524 case HEXA_DIR_TREE : setHexaSelection(); MESSAGE("HEXA"); break;
525 case PROPAGATION_TREE :
526 case PROPAGATION_DIR_TREE : setEdgeSelection(); MESSAGE("PROPAGATION"); break;
528 // EdgeOfCellSelection,
535 void PatternDataSelectionModel::highlightVTKElts( const QModelIndexList& elts )
537 if (!elts.size()) return;
539 SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
540 if ( currentVTKViewWindow == NULL ) return;
541 SVTK_Selector* selector = currentVTKViewWindow->GetSelector();
542 if ( selector == NULL ) return;
544 // document selection
545 Document_Actor* docActor = NULL;
546 Handle(SALOME_InteractiveObject) docIO;
547 // Handle(SALOME_InteractiveObject) docIO2; //JMD
550 TColStd_MapOfInteger aMap;
551 // TColStd_MapOfInteger aMap2;
552 QList<int>::const_iterator anIter;
557 QVariant docEntryVariant = elts[0].data( HEXA_DOC_ENTRY_ROLE );
559 if ( !docEntryVariant.isValid() ){
560 //INFOS("data from model not valid");
564 docEntry = docEntryVariant.toString();
566 // Select the document in Salome
567 docActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) );
568 if ( docActor == NULL) return;
571 // // Set selection mode in VTK view
572 // currentVTKViewWindow->SetSelectionMode(VolumeSelection);
573 docIO = docActor->getIO();
577 // QString autreDocentry = "toti";
578 // Associate_Actor* associateActor = dynamic_cast<Associate_Actor*>( findActorByEntry( currentVTKViewWindow, autreDocentry.toLatin1() ) );
579 // docIO2 = associateActor->getIO();
581 // Highlight in vtk view the element from document
585 foreach( const QModelIndex& iElt, elts ){
586 eltEntry = iElt.data( HEXA_ENTRY_ROLE ).toString();
587 vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ];
588 if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId );
590 // if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId );
594 // if ( vtkElemsId > 0 ) aMap2.Add( vtkElemsId );
599 selector->AddOrRemoveIndex( docIO, aMap, false ); //true
600 // selector->RemoveIObject(docActor);
601 currentVTKViewWindow->highlight( docIO, true, true );
602 // Document_Actor* docActor = NULL;
603 // QVariant docEntryVariant = selected.data( HEXA_DOC_ENTRY_ROLE );
604 // if ( docEntryVariant.isValid() ){
605 // QString docEntry = docEntryVariant.toString();
606 // docActor = dynamic_cast<Document_Actor*>( findActorByEntry( HEXABLOCKGUI::currentVtkView, docEntry.toLatin1() ) );
607 // if ( docActor != NULL) HEXABLOCKGUI::currentVtkView->getView()->highlight( docActor->getIO(), false, false );
609 // currentVTKViewWindow->getView()->SetColor(docIO, QColor("blue"));
612 // selector->AddOrRemoveIndex( docIO2, aMap2, false );
613 // currentVTKViewWindow->highlight( docIO2, true, true );
616 //SUIT_ViewManager* PatternDataSelectionModel::initOccViewManager()
618 // SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
619 // SUIT_ViewManager* occVm = anApp->getViewManager( OCCViewer_Viewer::Type(), true );
620 // SVTK_ViewWindow* viewWindow = dynamic_cast<SVTK_ViewWindow*>(svw);
621 // return viewWindow;
623 SUIT_ViewWindow* PatternDataSelectionModel::initOccViewManager()
625 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
626 SUIT_ViewManager* occVm = anApp->getViewManager( OCCViewer_Viewer::Type(), true );
628 QVector<SUIT_ViewWindow*> viewS = occVm->getViews ();
630 int nb = viewS.count();
632 MESSAGE("????HexaBaseDialog::initOccView number of : " << nb);
636 MESSAGE(" OK ????HexaBaseDialog::initOccView number of : " << nb);
637 return viewS.first();
643 // 1 vertex -> 1 point
644 // 1 edge -> n lines + points(deb,fin)
646 void PatternDataSelectionModel::_highlightGEOM( const QMultiMap<QString, int>& entrySubIDs )
648 MESSAGE("PatternDataSelectionModel::_highlightGEOM( const QMultiMap<QString, int>& entrySubIDs ){");
649 MESSAGE("debut entry => "<< entrySubIDs.count());
651 OCCViewer_ViewWindow* occView = _getOCCViewWindow();
652 if ( occView == NULL ) {
653 // occView = (OCCViewer_ViewWindow*)initOccViewManager();
654 // if ( occView == NULL )
657 MESSAGE("step 1 occView=> " << occView);
659 MESSAGE("step 1 entry => ");
660 SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>( occView->getViewManager()->getViewModel() );
661 if (!soccViewer) return;
662 MESSAGE("step 2 entry => ");
663 _PTR(Study) aStudy = GetActiveStudyDocument();
665 MESSAGE("step 3 entry => ");
667 CORBA::Object_var aCorbaObj = CORBA::Object::_nil();
668 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_nil();
670 MESSAGE("Avant entry => "<< entrySubIDs.count());
671 foreach ( QString entry, entrySubIDs.keys() ){
672 _PTR(SObject) aSChild = aStudy->FindObjectID( entry.toStdString() );
673 MESSAGE("* entry => "<< entry.toStdString());
674 aCorbaObj = corbaObj( aSChild );
675 aGeomObj = GEOM::GEOM_Object::_narrow( aCorbaObj );
676 if ( !CORBA::is_nil(aGeomObj) ){
677 MESSAGE("* !CORBA::is_nil(aGeomObj)");
678 QString objIOR = GEOMBase::GetIORFromObject( aGeomObj._retn() );
679 Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIORinGEOMAISShape( objIOR );//, true );
680 if ( !aSh.IsNull() ){
681 MESSAGE("* !aSh.IsNull() ");
682 TColStd_IndexedMapOfInteger anIndexes;
683 foreach ( int subid, entrySubIDs.values(entry) ){
685 anIndexes.Add( subid );
687 if ( anIndexes.Extent() > 0 ){ // if it's a sub-shape
688 MESSAGE("* a sub-shape");
689 aSh->highlightSubShapes( anIndexes, true );
690 soccViewer->Repaint();
691 } else { // or a main shape
692 // std::cout << "aSh->getIO() => " << aSh->getIO() << std::endl;
693 // getDisplayer()->SetDisplayMode(0);
694 // soccViewer->setColor( aSh->getIO(), QColor( Qt::red ), true );
695 // soccViewer->switchRepresentation( aSh->getIO(), 2 );
696 MESSAGE("* a main shape");
697 // globalSelection();
698 soccViewer->highlight( aSh->getIO(), true, true );
708 void PatternDataSelectionModel::_highlightGEOM( const QModelIndex & anEltIndex )
710 MESSAGE("PatternDataSelectionModel::_highlightGEOM(" << anEltIndex.data().toString().toStdString() << ")");
711 // getting association(s) from model
712 QList<DocumentModel::GeomObj> assocs;
713 QMultiMap< QString, int > assocEntrySubIDs;
714 DocumentModel *docModel = NULL;
715 const QSortFilterProxyModel *pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
717 if ( !pModel ) return;
718 docModel = dynamic_cast<DocumentModel*>( pModel->sourceModel() );
719 if ( !docModel ) return;
720 assocs = docModel->getAssociations( pModel->mapToSource(anEltIndex) );
721 foreach( const DocumentModel::GeomObj& anAssoc, assocs )
723 // MESSAGE(" dedans " << anAssoc.entry.toStdString());
724 // MESSAGE(" + " << anAssoc.subid.toInt());
725 assocEntrySubIDs.insert( anAssoc.entry, anAssoc.subid.toInt() );
728 _highlightGEOM( assocEntrySubIDs );
733 void PatternDataSelectionModel::_selectVTK( const QModelIndex& eltIndex )
735 MESSAGE("PatternDataSelectionModel::_selectVTK( "<< eltIndex.data().toString().toStdString() << ")");
736 SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
737 if ( currentVTKViewWindow == NULL ) return;
738 SVTK_Selector* selector = currentVTKViewWindow->GetSelector();
739 if ( selector == NULL ) return;
741 // document selection
742 Document_Actor* docActor = NULL;
743 Handle(SALOME_InteractiveObject) docIO;
747 TColStd_MapOfInteger aMap;
748 QList<int>::const_iterator anIter;
754 QVariant entryVariant = eltIndex.data( HEXA_ENTRY_ROLE );
755 QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE );
757 if ( !entryVariant.isValid() ){
758 //INFOS("entryVariant not valid");
761 if ( !docEntryVariant.isValid() ){
762 //INFOS("docEntryVariant not valid");
766 eltEntry = entryVariant.toString();
767 docEntry = docEntryVariant.toString();
769 // Select the document in Salome
770 docActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) );
771 if ( docActor == NULL ) return;
773 // Set selection mode in VTK view
774 //_setVTKSelectionMode( eltIndex, currentVTKViewWindow );
776 // if ( _salomeSelectionMgr == NULL ) return;
777 // _salomeSelectionMgr->selectedObjects( aList );
778 // std::cout<<"aList.Extent() => " << aList.Extent() << std::endl;
779 // aList.Append(docIO);
780 // _salomeSelectionMgr->setSelectedObjects( aList, true );//false );//true ); //CS_BP false?
781 docIO = docActor->getIO();
783 // Highlight in vtk view the element from document
784 vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ];// get vtk ids from actor
785 if ( vtkElemsId > 0 ) // CS_BP ?: erreur si 1er elt == vertex (0,0,0)
786 aMap.Add( vtkElemsId );
787 // for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) {
788 // aMap.Add(*anIter);
790 selector->AddOrRemoveIndex( docIO, aMap, false );
791 currentVTKViewWindow->highlight( docIO, true, true );
796 GroupsSelectionModel::GroupsSelectionModel( QAbstractItemModel * model ):
797 QItemSelectionModel( model )
799 connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
800 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
801 connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
802 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
805 GroupsSelectionModel::~GroupsSelectionModel()
807 disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
808 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
809 disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
810 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
816 QModelIndex GroupsSelectionModel::indexBy( int role, const QVariant& var )
818 QModelIndex eltIndex; // element (vertex, edge, quad) of model
819 const QAbstractItemModel* theModel = model();
820 if ( !theModel ) return eltIndex;
821 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
825 Qt::MatchRecursive /*| Qt::MatchContains*/ );//Qt::MatchFixedString );
826 if ( theIndexes.count()>0 )
827 eltIndex = theIndexes[0] ;
832 SVTK_ViewWindow* GroupsSelectionModel::_getVTKViewWindow()
834 // SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView;
835 return HEXABLOCKGUI::currentVtkView;
839 void GroupsSelectionModel::_highlightGroups( const QModelIndex& eltIndex )
841 const GroupsModel* m = dynamic_cast<const GroupsModel *>( model() );
844 if ( m == NULL ) return;
845 SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
846 if ( currentVTKViewWindow == NULL ) return;
847 SVTK_Selector* selector = currentVTKViewWindow->GetSelector();
848 if ( selector == NULL ) return;
851 // document selection
852 Document_Actor* docActor = NULL;
853 Handle(SALOME_InteractiveObject) docIO;
857 TColStd_MapOfInteger aMap;
858 QList<int>::const_iterator anIter;
863 // debut ** data from model
867 QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE );
868 QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE );
870 if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){
871 //INFOS("data from model not valid");
875 eltType = treeVariant.toInt();
876 docEntry = docEntryVariant.toString();
878 if ( eltType != GROUP_TREE ){
879 //INFOS("bad element type : not a group item" << eltType );
882 // fin ** data from model
884 // Select the document in Salome
885 docActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) );
886 if ( docActor == NULL) return;
887 docIO = docActor->getIO();
889 // Highlight in vtk view the element from document
890 DocumentModel::Group kind;
891 QModelIndexList iElements = m->getGroupElements( eltIndex, kind );
893 // Set selection mode in VTK view
895 case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: currentVTKViewWindow->SetSelectionMode(VolumeSelection); break;
896 case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: currentVTKViewWindow->SetSelectionMode(FaceSelection); break;
897 case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: currentVTKViewWindow->SetSelectionMode(EdgeSelection); break;
898 case HEXA_NS::VertexNode: currentVTKViewWindow->SetSelectionMode(NodeSelection); break;
902 foreach( const QModelIndex& iElt, iElements ){
903 eltEntry = iElt.data( HEXA_ENTRY_ROLE ).toString();
904 vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ];
905 if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId );
908 selector->AddOrRemoveIndex( docIO, aMap, false );
909 currentVTKViewWindow->highlight( docIO, true, true );
913 void GroupsSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
915 MESSAGE("GroupsSelectionModel::onSelectionChanged");
917 // if ( _salomeSelectionMgr == NULL ) return;
918 // _salomeSelectionMgr->clearSelected();
919 // erasePreview(true);
920 QModelIndexList indexes = selected.indexes();
921 for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
922 MESSAGE( "entry selected" << i_index->data( HEXA_ENTRY_ROLE ).toString().toStdString() );
923 _highlightGroups( *i_index );
926 // CS_BP todo SALOMEGUI_Swig.cxx:370
927 // indexes = deselected.indexes();
928 // for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index )
929 // _unselectSalome( *i_index);
931 MESSAGE("Unknown exception was cought !!!");
936 MeshSelectionModel::MeshSelectionModel( QAbstractItemModel * model ):
937 QItemSelectionModel( model )
939 connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
940 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
941 connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
942 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
946 MeshSelectionModel::~MeshSelectionModel()
948 disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
949 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
950 disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
951 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
955 QModelIndex MeshSelectionModel::indexBy( int role, const QVariant& var )
957 QModelIndex eltIndex; // element (vertex, edge, quad) of model
958 const QAbstractItemModel* theModel = model();
959 if ( !theModel ) return eltIndex;
960 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
964 Qt::MatchRecursive /*| Qt::MatchContains*/ );//Qt::MatchFixedString );
965 if ( theIndexes.count()>0 )
966 eltIndex = theIndexes[0] ;
972 SVTK_ViewWindow* MeshSelectionModel::_getVTKViewWindow()
974 // SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView;
975 return HEXABLOCKGUI::currentVtkView;
979 void MeshSelectionModel::_highlightPropagation( const QModelIndex& eltIndex )
981 const MeshModel* m = dynamic_cast<const MeshModel *>( model() );
982 if ( m == NULL ) return;
983 SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
984 if ( currentVTKViewWindow == NULL ) return;
985 SVTK_Selector* selector = currentVTKViewWindow->GetSelector();
986 if ( selector == NULL ) return;
988 // document selection
989 Document_Actor* docActor = NULL;
990 Handle(SALOME_InteractiveObject) docIO;
994 TColStd_MapOfInteger aMap;
995 QList<int>::const_iterator anIter;
1002 QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE );
1003 QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE );
1005 if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){
1006 //INFOS("data from model not valid");
1010 eltType = treeVariant.toInt();
1011 docEntry = docEntryVariant.toString();
1013 if ( eltType != PROPAGATION_TREE ){
1014 //INFOS("bad element type : not a propagation item" << eltType );
1018 // Select the document in Salome
1019 docActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) );
1020 if ( docActor == NULL) return;
1022 // // Set selection mode in VTK view
1023 currentVTKViewWindow->SetSelectionMode(EdgeSelection);
1024 docIO = docActor->getIO();
1026 // Highlight in vtk view the element from document
1027 QModelIndexList iEdges = m->getPropagation( eltIndex );
1030 foreach( const QModelIndex& iEdge, iEdges ){
1031 edgeEntry = iEdge.data( HEXA_ENTRY_ROLE ).toString();
1032 vtkElemsId = docActor->vtkElemsId[ edgeEntry.toInt() ];
1033 if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId );
1036 selector->AddOrRemoveIndex( docIO, aMap, false );
1037 currentVTKViewWindow->highlight( docIO, true, true );
1042 void MeshSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
1044 MESSAGE("MeshSelectionModel::onSelectionChanged");
1046 // if ( _salomeSelectionMgr == NULL ) return;
1047 // _salomeSelectionMgr->clearSelected();
1048 // erasePreview(true);
1049 QModelIndexList indexes = selected.indexes();
1050 for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
1051 MESSAGE( "entry selected" << i_index->data( HEXA_ENTRY_ROLE ).toString().toStdString() );
1052 _highlightPropagation( *i_index );
1055 // CS_BP todo SALOMEGUI_Swig.cxx:370
1056 // indexes = deselected.indexes();
1057 // for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index )
1058 // _unselectSalome( *i_index);
1060 MESSAGE("Unknown exception was cought !!!");
1066 // //=================================================================================
1067 // // function : activateSelection
1068 // // purpose : Activate selection in accordance with myEditCurrentArgument
1069 // //=================================================================================
1070 // void PatternDataSelectionModel::activateSelection()
1072 // erasePreview(false);
1074 // // local selection
1075 // if (!myObject->_is_nil() && !isAllSubShapes())
1077 // GEOM_Displayer* aDisplayer = getDisplayer();
1078 // SALOME_View* view = GEOM_Displayer::GetActiveView();
1080 // CORBA::String_var aMainEntry = myObject->GetStudyEntry();
1081 // Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
1082 // if (view->isVisible(io)) {
1083 // aDisplayer->Erase(myObject, false, false);
1084 // myIsHiddenMain = true;
1088 // int prevDisplayMode = aDisplayer->SetDisplayMode(0);
1090 // SUIT_ViewWindow* aViewWindow = 0;
1091 // SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
1093 // aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
1094 // if (aViewWindow == 0) return;
1096 // SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
1097 // if (aViewManager->getType() != OCCViewer_Viewer::Type() &&
1098 // aViewManager->getType() != SVTK_Viewer::Type())
1101 // SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
1102 // SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
1103 // if (aView == 0) return;
1105 // //TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myObject);
1107 // TopTools_IndexedMapOfShape aSubShapesMap;
1108 // TopExp::MapShapes(myShape, aSubShapesMap);
1109 // CORBA::String_var aMainEntry = myObject->GetStudyEntry();
1110 // QString anEntryBase = aMainEntry.in();
1112 // TopExp_Explorer anExp (myShape, (TopAbs_ShapeEnum)shapeType());
1113 // for (; anExp.More(); anExp.Next())
1115 // TopoDS_Shape aSubShape = anExp.Current();
1116 // int index = aSubShapesMap.FindIndex(aSubShape);
1117 // QString anEntry = anEntryBase + QString("_%1").arg(index);
1119 // SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
1121 // displayPreview(aPrs, true, false); // append, do not update
1124 // aDisplayer->UpdateViewer();
1125 // aDisplayer->SetDisplayMode(prevDisplayMode);
1128 // globalSelection(GEOM_ALLSHAPES);
1134 // SUIT_DataOwnerPtrList aList;
1135 // ObjectList::iterator anIter;
1136 // for ( anIter = objects.begin(); anIter != objects.end(); ++anIter )
1138 // QString anEntry = getEntry( *anIter );
1139 // LightApp_DataOwner* anOwher = new LightApp_DataOwner( anEntry );
1140 // aList.append( anOwher );
1143 // SUIT_Session* session = SUIT_Session::session();
1144 // SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1148 // LightApp_SelectionMgr* aMgr = app->selectionMgr();
1151 // _getVTKViewWindow()
1152 // aMgr->setSelecte_getVTKViewWindow()d( aList, false );
1158 // SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
1159 // if (!anActor || !anActor->hasIO())
1162 // Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
1163 // //mySelectionMgr->clearSelected();
1164 // //mySelectionMgr->AddIObject(anIO, false);
1165 // SALOME_ListIO aList;
1166 // aList.Append(anIO);
1167 // mySelectionMgr->setSelectedObjects(aList, false);
1169 // // Remove filter corresponding to the current type from viewer
1170 // int aType = myTable->GetType();
1171 // int aFilterId = SMESH::UnknownFilter;
1172 // if (aType == SMESH::EDGE ) aFilterId = SMESH::EdgeFilter;
1173 // else if (aType == SMESH::FACE ) aFilterId = SMESH::FaceFilter;
1174 // else if (aType == SMESH::VOLUME) aFilterId = SMESH::VolumeFilter;
1175 // Handle(VTKViewer_Filter) aFilter = SMESH::GetFilter(aFilterId);
1176 // SMESH::RemoveFilter(aFilterId);
1179 // TColStd_MapOfInteger aMap;
1180 // QList<int>::const_iterator anIter;
1181 // for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) {
1182 // aMap.Add(*anIter);
1185 // // Set new selection
1186 // activeViewWindow->AddOrRemoveIndex(anIO, aMap, false);
1187 // if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1188 // aViewWindow->highlight( anIO, true, true );
1190 // // insert previously stored filter in viewer if necessary
1191 // if (!aFilter.IsNull())
1192 // SMESH::SetFilter(aFilter);
1203 // if(SVTK_Selector* aSelector = aView->GetSelector()){
1204 // const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
1205 // SALOME_ListIteratorOfListIO anIter(aListIO);
1206 // for(; anIter.More(); anIter.Next()){
1207 // Handle(SALOME_InteractiveObject) anIO = anIter.Value();
1208 // _PTR(Study) aStudy = HEXABLOCKGUI::activeStudy()->studyDS();
1209 // _PTR(SObject) aSObj = aStudy->FindObjectID( anEntry.toStdString().c_str() );
1210 // LightApp_DataObject* o = HEXABLOCKGUI::activeStudy()->findObjectByEntry(anEntry.toStdString().c_str());
1217 // void PatternDataSelectionModel::test()
1219 // if (myBusy) return;
1222 // SALOME_ListIO aList;
1223 // mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
1225 // if (aList.Extent() == 1) {
1226 // Handle(SALOME_InteractiveObject) anIO = aList.First();
1227 // myMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
1230 // if (SMESH::GetNameOfSelectedNodes(activeViewWindow,anIO,aText) == 1) {
1231 // if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()) {
1232 // if(const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) {
1234 // myId->setText(aText);
1235 // myX->SetValue(aNode->X());
1236 // myY->SetValue(aNode->Y());
1237 // myZ->SetValue(aNode->Z());
1239 // erasePreview(); // avoid overlapping of a selection and a preview
1254 void PatternDataSelectionModel::setGeomEngine( GEOM::GEOM_Gen_var geomEngine )
1256 _geomEngine = geomEngine;
1259 GEOM::GEOM_IOperations_ptr PatternDataSelectionModel::createOperation()
1261 // return myGeomGUI->GetGeomGen()->GetIBasicOperations(getStudyId());
1262 return _geomEngine->GetIBasicOperations(getStudyId());
1265 bool PatternDataSelectionModel::execute(ObjectList& objects)
1269 _PTR(Study) aStudy = GetActiveStudyDocument();
1270 _PTR(SObject) aSChild;
1271 CORBA::Object_var aCorbaObj = CORBA::Object::_nil();
1272 GEOM::GEOM_Object_var assoc;
1274 foreach( const DocumentModel::GeomObj& anAssoc, _assocList ){
1275 std::cout << "FOUND=> " << anAssoc.entry.toStdString() << std::endl;
1276 aSChild = aStudy->FindObjectID( anAssoc.entry.toStdString() );
1277 aCorbaObj = corbaObj(aSChild);
1278 assoc = GEOM::GEOM_Object::_narrow(aCorbaObj);
1280 if ( !CORBA::is_nil(assoc) ){
1281 std::cout << "geom to highlight =>" << anAssoc.name.toStdString() << std::endl;
1282 objects.push_back( assoc._retn() );
1285 std::cout << "not a geom =>" << anAssoc.name.toStdString()<< std::endl;
1294 // SVTK_ViewWindow* PatternDataSelectionModel::GetViewWindow()
1296 // SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
1297 // (SUIT_Session::session()->activeApplication());
1299 // if (SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow()))
1302 // // SUIT_ViewManager* aViewManager =
1303 // // anApp->getViewManager(SVTK_Viewer::Type(), createIfNotFound);
1304 // // if (aViewManager) {
1305 // // if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) {
1306 // // if (SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
1307 // // aViewWindow->raise();
1308 // // aViewWindow->setFocus();
1320 // void PatternDataSelectionModel::SetSelectionMode(Selection_Mode theMode)
1323 // QList<SUIT_Selector*> aSelectors;
1324 // _salomeSelectionMgr->selectors( SVTK_Viewer::Type(), aSelectors );
1325 // QListIterator<SUIT_Selector*> it( aSelectors );
1327 // std::cout << "PatternDataSelectionModel::SetSelectionMode()" << std::endl;
1328 // while ( it.hasNext() )
1330 // // SUIT_Selector* selector = it.next();
1331 // SVTK_Selector* selector = dynamic_cast<SVTK_Selector*>( it.next() );
1333 // std::cout << "PatternDataSelectionModel::SetSelectionMode()" << theMode << std::endl;
1334 // selector->SetSelectionMode(theMode);
1339 // LightApp_SelectionMgr* PatternDataSelectionModel::selectionMgr()
1341 // SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1343 // return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1349 // SUIT_DataOwnerPtrList aOList;
1350 // LightApp_DataOwner* anOwher = new LightApp_DataOwner( "0:1:1:1:2" );
1351 // aOList.append( anOwher );
1352 // _salomeSelectionMgr->setSelected( aOList, false );
1355 // void PatternDataSelectionModel::_highlightGEOM( const QModelIndex & anEltIndex )
1357 // std::cout << "PatternDataSelectionModel::_highlightGEOM go find ASSOCIATION for"<< anEltIndex.data().toString().toStdString()<<std::endl;
1358 // // HEXABLOCKGUI::currentVtkView
1360 // QList<DocumentModel::GeomObj> assocList;
1362 // DocumentModel *docModel = NULL;
1363 // const QSortFilterProxyModel *pModel = NULL;
1364 // // const QStandardItemModel *smodel
1365 // // const QAbstractItemModel *theModel = NULL;
1367 // pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
1369 // std::cout << "pModel "<< pModel << std::endl;
1371 // std::cout << "if ( pModel ){"<< std::endl;
1372 // docModel = dynamic_cast<DocumentModel*>( pModel->sourceModel() );
1374 // std::cout << "if ( docModel ){"<< std::endl;
1375 // assocList = docModel->getAssociations( pModel->mapToSource(anEltIndex) );
1380 // _PTR(Study) aStudy = GetActiveStudyDocument();
1381 // _PTR(SObject) aSChild;
1382 // CORBA::Object_var aCorbaObj = CORBA::Object::_nil();
1383 // GEOM::GEOM_Object_var assoc;
1384 // // foreach( const QString& entry, geomEntries ){
1385 // // struct GeomObj
1388 // // QString entry;
1394 // QVariant treeVariant = pModel->mapToSource(anEltIndex).data( HEXA_TREE_ROLE );
1396 // if ( !treeVariant.isValid() ) return;
1397 // eltType = treeVariant.toInt();
1399 // // GEOM::GeomObjPtr
1400 // // GEOM::GEOM_Object_ptr firstLine; //firstLine.nullify();//
1401 // GEOM::GEOM_Object_var firstLine = GEOM::GEOM_Object::_nil(); //GEOM::GeomObjPtr
1402 // GEOM::GEOM_Object_var lastLine = GEOM::GEOM_Object::_nil();
1403 // double firstParameter = 0.2; //CS_TODO
1404 // double lastParameter = 0.4; //CS_TODO
1406 // foreach( const DocumentModel::GeomObj& anAssoc, assocList ){
1407 // std::cout << "FOUND=> " << anAssoc.entry.toStdString() << std::endl;
1408 // aSChild = aStudy->FindObjectID( anAssoc.entry.toStdString() );
1409 // aCorbaObj = corbaObj(aSChild);
1410 // assoc = GEOM::GEOM_Object::_narrow(aCorbaObj);
1412 // if ( !CORBA::is_nil(assoc) ){
1413 // std::cout << "geom to highlight =>" << anAssoc.name.toStdString() << std::endl;
1414 // // objects.push_back(assoc._retn());
1415 // // if ( eltType == EDGE_TREE ){
1416 // // if ( CORBA::is_nil(firstLine) ){
1417 // // firstLine = GEOM::GEOM_Object::_duplicate( assoc._retn() );
1419 // // lastLine = GEOM::GEOM_Object::_duplicate( assoc._retn() );
1421 // displayPreview( assoc._retn(),
1422 // true, //false, //append,
1423 // false,//true, //false, //activate,
1424 // false,//true,//update,
1426 // 1,//-1,//displayMode,
1427 // Quantity_NOC_RED );
1429 // std::cout << "not a geom =>" << anAssoc.name.toStdString()<< std::endl;
1432 // // std::cout << "CORBA::is_nil(firstLine) =>" << CORBA::is_nil(firstLine) << std::endl;
1433 // // std::cout << "CORBA::is_nil(lastLine) =>" << CORBA::is_nil(lastLine) << std::endl;
1434 // // std::cout << "test" << ( !( CORBA::is_nil(firstLine) and !CORBA::is_nil(lastLine) ) ) << std::endl;
1436 // if ( !( CORBA::is_nil(firstLine) and !CORBA::is_nil(lastLine) ) ){
1437 // GEOM::GEOM_IBasicOperations_var anOper = _geomEngine->GetIBasicOperations( getStudyId() );
1438 // GEOM::GEOM_Object_var firstPoint = anOper->MakePointOnCurve( firstLine, firstParameter );
1439 // GEOM::GEOM_Object_var lastPoint = anOper->MakePointOnCurve( lastLine, lastParameter );
1441 // // std::cout << "firstPoint->_is_nil() =>" << firstPoint->_is_nil() << std::endl;
1442 // std::cout << "lastPoint->_is_nil() =>" << lastPoint->_is_nil() << std::endl;
1443 // if ( !( CORBA::is_nil(firstPoint) ) )// !firstPoint->_is_nil() )
1444 // displayPreview( firstPoint._retn(), true );
1445 // if ( !( CORBA::is_nil(lastPoint) ) )//if ( !lastPoint->_is_nil() )
1446 // displayPreview( lastPoint._retn(), true );