From: dmv Date: Fri, 24 Oct 2008 12:11:34 +0000 (+0000) Subject: Plot2d: clicking in legend on curve name doesn't highlight it in object browser X-Git-Tag: V5_1_0a3~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cb05e79db7557d30510b67194cc024aedf4b8ab9;p=modules%2Fgui.git Plot2d: clicking in legend on curve name doesn't highlight it in object browser --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 4818feb39..c31a8aac4 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -83,6 +83,7 @@ #ifndef DISABLE_PLOT2DVIEWER #include #include + #include "LightApp_Plot2dSelector.h" #ifndef DISABLE_SALOMEOBJECT #include #else @@ -1252,7 +1253,9 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() ); Plot2d_Viewer* vm; #ifndef DISABLE_SALOMEOBJECT - vm = new SPlot2d_Viewer(); + SPlot2d_Viewer* v = new SPlot2d_Viewer(); + vm = v; + new LightApp_Plot2dSelector( v, mySelMgr ); #else vm = new Plot2d_Viewer(); #endif diff --git a/src/LightApp/LightApp_Plot2dSelector.cxx b/src/LightApp/LightApp_Plot2dSelector.cxx new file mode 100755 index 000000000..a88c5f334 --- /dev/null +++ b/src/LightApp/LightApp_Plot2dSelector.cxx @@ -0,0 +1,65 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// 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. +// +// 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 +// +#include "LightApp_Plot2dSelector.h" + +#include "LightApp_DataOwner.h" +#include "LightApp_DataObject.h" +#include "LightApp_Application.h" + +/*! + Constructor +*/ +LightApp_Plot2dSelector::LightApp_Plot2dSelector( SPlot2d_Viewer* v, SUIT_SelectionMgr* mgr ) +: SUIT_Selector( mgr, v ) +{ + if ( v ) + connect( v, SIGNAL( legendSelected( const QString& ) ), this, SLOT( onSelectionChanged( const QString& ) ) ); +} + +/*! + Destructor +*/ +LightApp_Plot2dSelector::~LightApp_Plot2dSelector() +{ +} + +/*! + Gets selection. +*/ +void LightApp_Plot2dSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const +{ + if( !myCurEntry.isNull() ) + theList.append( new LightApp_DataOwner( myCurEntry ) ); +} + +/*!Sets selection.*/ +void LightApp_Plot2dSelector::setSelection( const SUIT_DataOwnerPtrList& theList ) +{ + /* if( theList.count()>0 ) + myCurEntry = theList.first()->getEntry(); + else + myCurEntry = QString::null;*/ +} + +/*!On selection changed.*/ +void LightApp_Plot2dSelector::onSelectionChanged( const QString& entry ) +{ + myCurEntry = entry; + selectionChanged(); +} diff --git a/src/LightApp/LightApp_Plot2dSelector.h b/src/LightApp/LightApp_Plot2dSelector.h new file mode 100755 index 000000000..7a47b46ec --- /dev/null +++ b/src/LightApp/LightApp_Plot2dSelector.h @@ -0,0 +1,56 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// 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. +// +// 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 +// +#ifndef LIGHTAPP_PLOT2DSELECTOR_H +#define LIGHTAPP_PLOT2DSELECTOR_H + +#include "LightApp.h" + +#include +#include +#include + +class LightApp_DataObject; + +/*! + \class LightApp_Plot2dSelector + Custom selector to get/set selection from object browser +*/ +class LIGHTAPP_EXPORT LightApp_Plot2dSelector : public QObject, public SUIT_Selector +{ + Q_OBJECT + +public: + LightApp_Plot2dSelector( SPlot2d_Viewer*, SUIT_SelectionMgr* ); + virtual ~LightApp_Plot2dSelector(); + + /*!Return "ObjectBrowser"*/ + virtual QString type() const { return "PLot2dViewer"; } + +private slots: + void onSelectionChanged( const QString& ); + +protected: + virtual void getSelection( SUIT_DataOwnerPtrList& ) const; + virtual void setSelection( const SUIT_DataOwnerPtrList& ); + +private: + QString myCurEntry; +}; + +#endif diff --git a/src/LightApp/Makefile.am b/src/LightApp/Makefile.am index fecbda7c5..10b5d2288 100755 --- a/src/LightApp/Makefile.am +++ b/src/LightApp/Makefile.am @@ -66,6 +66,9 @@ endif if ENABLE_GLVIEWER salomeinclude_HEADERS += LightApp_GLSelector.h endif +if ENABLE_PLOT2DVIEWER + salomeinclude_HEADERS += LightApp_Plot2dSelector.h +endif dist_libLightApp_la_SOURCES = \ LightApp_AboutDlg.cxx \ @@ -106,6 +109,9 @@ endif if ENABLE_GLVIEWER dist_libLightApp_la_SOURCES += LightApp_GLSelector.cxx endif +if ENABLE_PLOT2DVIEWER + dist_libLightApp_la_SOURCES += LightApp_Plot2dSelector.cxx +endif MOC_FILES = \ LightApp_AboutDlg_moc.cxx \ @@ -136,6 +142,9 @@ endif if ENABLE_GLVIEWER MOC_FILES += LightApp_GLSelector_moc.cxx endif +if ENABLE_PLOT2DVIEWER + MOC_FILES += LightApp_Plot2dSelector_moc.cxx +endif nodist_libLightApp_la_SOURCES = $(MOC_FILES) dist_salomeres_DATA = \ diff --git a/src/SPlot2d/Makefile.am b/src/SPlot2d/Makefile.am index db5b1a877..b2dc3f6a5 100644 --- a/src/SPlot2d/Makefile.am +++ b/src/SPlot2d/Makefile.am @@ -41,7 +41,7 @@ nodist_libSPlot2d_la_SOURCES = $(MOC_FILES) libSPlot2d_la_CPPFLAGS = $(QT_INCLUDES) $(CAS_CPPFLAGS) $(QWT_INCLUDES) $(BOOST_CPPFLAGS) \ -I$(srcdir)/../Qtx -I$(srcdir)/../SUIT -I$(srcdir)/../Plot2d \ - -I$(srcdir)/../Prs -I$(srcdir)/../OBJECT -I$(srcdir)/../LightApp -I$(srcdir)/../CAM -I$(srcdir)/../STD + -I$(srcdir)/../Prs -I$(srcdir)/../OBJECT libSPlot2d_la_LDFLAGS = $(QT_MT_LIBS) $(QWT_LIBS) ../SUIT/libsuit.la ../Plot2d/libPlot2d.la ../Prs/libSalomePrs.la diff --git a/src/SPlot2d/SPlot2d_ViewModel.cxx b/src/SPlot2d/SPlot2d_ViewModel.cxx index 4b2bfda05..29113385e 100644 --- a/src/SPlot2d/SPlot2d_ViewModel.cxx +++ b/src/SPlot2d/SPlot2d_ViewModel.cxx @@ -29,8 +29,6 @@ #include "SUIT_Application.h" #include "SUIT_ViewManager.h" -#include "LightApp_SelectionMgr.h" -#include "LightApp_Application.h" #include "SALOME_ListIO.hxx" #include @@ -400,14 +398,7 @@ void SPlot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem ) } // Highlight curve in Object Browser if(aSCurve && aSCurve->hasIO()) { - LightApp_Application* anApp = dynamic_cast< LightApp_Application* >( SUIT_Session::session()->activeApplication() ); - if ( anApp ) { - LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr(); - if (aSelectionMgr) { - SALOME_ListIO aListIO; - aListIO.Append( aSCurve->getIO() ); - aSelectionMgr->setSelectedObjects( aListIO, false ); - } - } + QString anEntry = aSCurve->getIO()->getEntry(); + emit legendSelected( anEntry ); } } diff --git a/src/SPlot2d/SPlot2d_ViewModel.h b/src/SPlot2d/SPlot2d_ViewModel.h index 5aca6ff92..b6b3747fe 100644 --- a/src/SPlot2d/SPlot2d_ViewModel.h +++ b/src/SPlot2d/SPlot2d_ViewModel.h @@ -78,6 +78,9 @@ public: protected slots: virtual void onLegendClicked( QwtPlotItem* plotItem ); + +signals: + void legendSelected( const QString& ); };