Back to index

salome-gui  6.5.0
LightApp_Plot2dSelector.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "LightApp_Plot2dSelector.h"
00021 
00022 #include "LightApp_DataOwner.h"
00023 #include "LightApp_DataObject.h"
00024 #include "LightApp_Application.h"
00025 #include "SUIT_SelectionMgr.h"
00026 
00027 #include <SPlot2d_ViewModel.h>
00028 
00029 #include <SALOME_ListIO.hxx>
00030 
00034 LightApp_Plot2dSelector::LightApp_Plot2dSelector( Plot2d_Viewer* v, SUIT_SelectionMgr* mgr )
00035   : SUIT_Selector( mgr, v ),
00036     myViewer(v)
00037 {
00038   if ( v )
00039     connect( v, SIGNAL( legendSelected( const QString& ) ), this, SLOT( onSelectionChanged( const QString& ) ) );
00040     connect( v, SIGNAL( clearSelected() ), this, SLOT( onClearSelected( ) ) );
00041 }
00042 
00046 LightApp_Plot2dSelector::~LightApp_Plot2dSelector()
00047 {
00048 }
00049 
00053 void LightApp_Plot2dSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
00054 {
00055   if( !myCurEntry.isNull() )
00056     theList.append( new LightApp_DataOwner( new SALOME_InteractiveObject(qPrintable(myCurEntry),"","") ) );
00057 }
00058 
00060 void LightApp_Plot2dSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
00061 {
00062   SALOME_ListIO anIOList;
00063   for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it ) {
00064     const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
00065     if ( owner  ) {
00066       if( !owner->IO().IsNull() ) {
00067        anIOList.Append(owner->IO());
00068       } else if ( !owner->entry().isEmpty() ) {
00069        anIOList.Append( new SALOME_InteractiveObject(qPrintable(owner->entry()),"","") );
00070       }      
00071     }
00072   }
00073   SPlot2d_Viewer* v = dynamic_cast<SPlot2d_Viewer*>(myViewer);
00074 
00075   if(v)
00076     v->setObjectsSelected(anIOList);
00077 }
00078 
00080 void LightApp_Plot2dSelector::onSelectionChanged( const QString& entry )
00081 {
00082   myCurEntry = entry;
00083   selectionChanged();
00084   myCurEntry = QString();
00085 }
00086 
00088 void LightApp_Plot2dSelector::onClearSelected( ) 
00089 {
00090        selectionMgr()->clearSelected();
00091 }