1 // Copyright (C) 2007-2024 CEA, EDF, 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, 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
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 #ifndef DISABLE_SALOMEOBJECT
28 #include <SALOME_ListIO.hxx>
29 #ifndef DISABLE_PLOT2DVIEWER
30 #include <SPlot2d_ViewModel.h>
37 LightApp_Plot2dSelector::LightApp_Plot2dSelector( Plot2d_Viewer* v, SUIT_SelectionMgr* mgr )
38 : SUIT_Selector( mgr, v ),
42 connect( v, SIGNAL( legendSelected( const QString& ) ), this, SLOT( onSelectionChanged( const QString& ) ) );
43 connect( v, SIGNAL( clearSelected() ), this, SLOT( onClearSelected( ) ) );
50 LightApp_Plot2dSelector::~LightApp_Plot2dSelector()
57 void LightApp_Plot2dSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
59 if( !myCurEntry.isNull() ) {
60 #ifndef DISABLE_SALOMEOBJECT
61 theList.append( new LightApp_DataOwner( new SALOME_InteractiveObject(qUtf8Printable(myCurEntry),"","") ) );
63 theList.append( new LightApp_DataOwner( myCurEntry ) );
69 void LightApp_Plot2dSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
71 #ifndef DISABLE_SALOMEOBJECT
72 SALOME_ListIO anIOList;
73 for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it ) {
74 const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
76 if( !owner->IO().IsNull() ) {
77 anIOList.Append(owner->IO());
79 else if ( !owner->entry().isEmpty() ) {
80 anIOList.Append( new SALOME_InteractiveObject(qUtf8Printable(owner->entry()),"","") );
84 SPlot2d_Viewer* v = dynamic_cast<SPlot2d_Viewer*>(myViewer);
87 v->setObjectsSelected(anIOList);
91 /*!On selection changed.*/
92 void LightApp_Plot2dSelector::onSelectionChanged( const QString& entry )
96 myCurEntry = QString();
99 /*!On clear selected.*/
100 void LightApp_Plot2dSelector::onClearSelected( )
102 selectionMgr()->clearSelected();