1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
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
20 #include "LightApp_Plot2dSelector.h"
22 #include "LightApp_DataOwner.h"
23 #include "LightApp_DataObject.h"
24 #include "LightApp_Application.h"
25 #include "SUIT_SelectionMgr.h"
27 #include <SPlot2d_ViewModel.h>
29 #include <SALOME_ListIO.hxx>
34 LightApp_Plot2dSelector::LightApp_Plot2dSelector( Plot2d_Viewer* v, SUIT_SelectionMgr* mgr )
35 : SUIT_Selector( mgr, v ),
39 connect( v, SIGNAL( legendSelected( const QString& ) ), this, SLOT( onSelectionChanged( const QString& ) ) );
40 connect( v, SIGNAL( clearSelected() ), this, SLOT( onClearSelected( ) ) );
46 LightApp_Plot2dSelector::~LightApp_Plot2dSelector()
53 void LightApp_Plot2dSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
55 if( !myCurEntry.isNull() )
56 theList.append( new LightApp_DataOwner( new SALOME_InteractiveObject(qPrintable(myCurEntry),"","") ) );
60 void LightApp_Plot2dSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
62 SALOME_ListIO anIOList;
63 for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it ) {
64 const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
66 if( !owner->IO().IsNull() ) {
67 anIOList.Append(owner->IO());
68 } else if ( !owner->entry().isEmpty() ) {
69 anIOList.Append( new SALOME_InteractiveObject(qPrintable(owner->entry()),"","") );
73 SPlot2d_Viewer* v = dynamic_cast<SPlot2d_Viewer*>(myViewer);
76 v->setObjectsSelected(anIOList);
79 /*!On selection changed.*/
80 void LightApp_Plot2dSelector::onSelectionChanged( const QString& entry )
84 myCurEntry = QString();
87 /*!On clear selected.*/
88 void LightApp_Plot2dSelector::onClearSelected( )
90 selectionMgr()->clearSelected();