Salome HOME
Debug of CMake build procedure
[modules/gui.git] / src / LightApp / LightApp_Plot2dSelector.cxx
index 9efc836b0d9e76d7c69f9bdb671aa44550184465..27b6edcf38b80f43186a712dee20e2f910c04a88 100755 (executable)
@@ -1,38 +1,46 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 #include "LightApp_Plot2dSelector.h"
 
 #include "LightApp_DataOwner.h"
 #include "LightApp_DataObject.h"
 #include "LightApp_Application.h"
+#include "SUIT_SelectionMgr.h"
+
+#ifndef DISABLE_SALOMEOBJECT
+  #include <SALOME_ListIO.hxx>
+  #ifndef DISABLE_PLOT2DVIEWER
+    #include <SPlot2d_ViewModel.h>
+  #endif
+#endif
 
 /*!
   Constructor
 */
-LightApp_Plot2dSelector::LightApp_Plot2dSelector( SPlot2d_Viewer* v, SUIT_SelectionMgr* mgr )
-: SUIT_Selector( mgr, v )
+LightApp_Plot2dSelector::LightApp_Plot2dSelector( Plot2d_Viewer* v, SUIT_SelectionMgr* mgr )
+  : SUIT_Selector( mgr, v ),
+    myViewer(v)
 {
   if ( v )
     connect( v, SIGNAL( legendSelected( const QString& ) ), this, SLOT( onSelectionChanged( const QString& ) ) );
+    connect( v, SIGNAL( clearSelected() ), this, SLOT( onClearSelected( ) ) );
 }
 
 /*!
@@ -47,17 +55,36 @@ LightApp_Plot2dSelector::~LightApp_Plot2dSelector()
 */
 void LightApp_Plot2dSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
 {
-  if( !myCurEntry.isNull() )
+  if( !myCurEntry.isNull() ) {
+#ifndef DISABLE_SALOMEOBJECT
+    theList.append( new LightApp_DataOwner( new SALOME_InteractiveObject(qPrintable(myCurEntry),"","") ) );
+#else
     theList.append( new LightApp_DataOwner( myCurEntry ) );
+#endif
+  }
 }
 
 /*!Sets selection.*/
 void LightApp_Plot2dSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
 {
-  /*  if( theList.count()>0 )
-    myCurEntry = theList.first()->getEntry();
-  else*/
-  myCurEntry = QString::null;
+#ifndef DISABLE_SALOMEOBJECT
+  SALOME_ListIO anIOList;
+  for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it ) {
+    const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
+    if ( owner  ) {
+      if( !owner->IO().IsNull() ) {
+           anIOList.Append(owner->IO());
+      }
+      else if ( !owner->entry().isEmpty() ) {
+           anIOList.Append( new SALOME_InteractiveObject(qPrintable(owner->entry()),"","") );
+      }      
+    }
+  }
+  SPlot2d_Viewer* v = dynamic_cast<SPlot2d_Viewer*>(myViewer);
+
+  if(v)
+    v->setObjectsSelected(anIOList);
+#endif
 }
 
 /*!On selection changed.*/
@@ -65,4 +92,11 @@ void LightApp_Plot2dSelector::onSelectionChanged( const QString& entry )
 {
   myCurEntry = entry;
   selectionChanged();
+  myCurEntry = QString();
+}
+
+/*!On clear selected.*/
+void LightApp_Plot2dSelector::onClearSelected( ) 
+{
+       selectionMgr()->clearSelected();
 }