1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_GVSelector.h"
21 #include "HYDROGUI_DataModel.h"
22 #include "HYDROGUI_DataObject.h"
23 #include "HYDROGUI_Module.h"
24 #include "HYDROGUI_Prs.h"
25 #include "HYDROGUI_Tool2.h"
27 #include <GraphicsView_Object.h>
28 #include <GraphicsView_Selector.h>
29 #include <GraphicsView_ViewPort.h>
30 #include <GraphicsView_Viewer.h>
32 #include <LightApp_DataOwner.h>
34 HYDROGUI_GVSelector::HYDROGUI_GVSelector( HYDROGUI_Module* theModule,
35 GraphicsView_Viewer* theViewer,
36 SUIT_SelectionMgr* theSelMgr )
37 : LightApp_GVSelector( theViewer, theSelMgr ),
42 HYDROGUI_GVSelector::~HYDROGUI_GVSelector()
46 void HYDROGUI_GVSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
48 if( GraphicsView_ViewPort* aViewPort = myViewer->getActiveViewPort() )
50 for( aViewPort->initSelected(); aViewPort->moreSelected(); aViewPort->nextSelected() )
52 if( HYDROGUI_Prs* aPrs = dynamic_cast<HYDROGUI_Prs*>( aViewPort->selectedObject() ) )
54 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aPrs->getObject() );
55 theList.append( new LightApp_DataOwner( anEntry ) );
61 void HYDROGUI_GVSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
63 HYDROGUI_DataModel* aModel = myModule->getDataModel();
64 if( GraphicsView_ViewPort* aViewPort = myViewer->getActiveViewPort() )
66 aViewPort->clearSelected();
67 SUIT_DataOwnerPtrList::const_iterator it;
68 GraphicsView_ObjectList anObjectList = aViewPort->getObjects();
69 for ( it = theList.begin(); it != theList.end(); ++it )
71 LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( (*it).operator->() );
74 QString anEntry = anOwner->entry();
75 Handle(HYDROData_Entity) aModelObject = aModel->objectByEntry( anEntry );
76 if( !aModelObject.IsNull() )
78 if( HYDROGUI_Prs* aPrs = HYDROGUI_Tool::GetPresentation( aModelObject, anObjectList ) )
79 aViewPort->setSelected( aPrs );