From 182a6141a4a1756460f25fb3eb6c50a0224457f5 Mon Sep 17 00:00:00 2001 From: dmv Date: Fri, 24 Oct 2008 12:03:43 +0000 Subject: [PATCH] Plot2d: clicking in legend on curve name doesn't highlight it in object browser --- src/LightApp/LightApp_Application.cxx | 5 +- src/LightApp/LightApp_Plot2dSelector.cxx | 70 ++++++++++++++++++++++++ src/LightApp/LightApp_Plot2dSelector.h | 56 +++++++++++++++++++ src/LightApp/Makefile.am | 10 +++- src/Plot2d/Plot2d_ViewModel.h | 3 +- src/SPlot2d/Makefile.am | 2 +- src/SPlot2d/SPlot2d_ViewModel.cxx | 13 +---- src/SPlot2d/SPlot2d_ViewModel.h | 3 + 8 files changed, 146 insertions(+), 16 deletions(-) create mode 100755 src/LightApp/LightApp_Plot2dSelector.cxx create mode 100755 src/LightApp/LightApp_Plot2dSelector.h diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 6486e0285..686efcbd5 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -77,6 +77,7 @@ #ifndef DISABLE_PLOT2DVIEWER #include #include + #include "LightApp_Plot2dSelector.h" #ifndef DISABLE_SALOMEOBJECT #include #else @@ -1428,7 +1429,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..2cad34118 --- /dev/null +++ b/src/LightApp/LightApp_Plot2dSelector.cxx @@ -0,0 +1,70 @@ +// 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 ) +{ + ////////////////////////// + // CURRENTLY NOT SUPPORTED + ////////////////////////// + /* + 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..823991eaa --- /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 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 f59c4bd09..6d2acc85c 100755 --- a/src/LightApp/Makefile.am +++ b/src/LightApp/Makefile.am @@ -66,7 +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 \ LightApp_Application.cxx \ @@ -105,6 +107,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 \ @@ -135,6 +140,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/Plot2d/Plot2d_ViewModel.h b/src/Plot2d/Plot2d_ViewModel.h index a132efb41..a5ec5424f 100755 --- a/src/Plot2d/Plot2d_ViewModel.h +++ b/src/Plot2d/Plot2d_ViewModel.h @@ -28,7 +28,6 @@ class Plot2d_ViewFrame; class Plot2d_Prs; class QString; class QPopupMenu; -class QwtPlotItem; class PLOT2D_EXPORT Plot2d_Viewer: public SUIT_ViewModel { @@ -58,7 +57,7 @@ protected slots: void onDumpView(); void onShowToolbar(); virtual void onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* ); - virtual void onLegendClicked( long key/*QwtPlotItem* plotItem*/ ); + virtual void onLegendClicked( long ); private: Plot2d_Prs* myPrs; diff --git a/src/SPlot2d/Makefile.am b/src/SPlot2d/Makefile.am index 204978dfd..17dc25b37 100644 --- a/src/SPlot2d/Makefile.am +++ b/src/SPlot2d/Makefile.am @@ -43,7 +43,7 @@ nodist_salomeres_DATA = SPlot2d_msg_en.qm 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)/../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 b46c9e2c3..39f89063e 100644 --- a/src/SPlot2d/SPlot2d_ViewModel.cxx +++ b/src/SPlot2d/SPlot2d_ViewModel.cxx @@ -28,8 +28,6 @@ #include "SUIT_Session.h" #include "SUIT_Application.h" -#include "LightApp_SelectionMgr.h" -#include "LightApp_Application.h" #include "SALOME_ListIO.hxx" #include "qapplication.h" @@ -403,15 +401,8 @@ void SPlot2d_Viewer::onLegendClicked( long key ) SPlot2d_Curve* aSCurve = dynamic_cast(aCurve); 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 0f215921e..21680d410 100644 --- a/src/SPlot2d/SPlot2d_ViewModel.h +++ b/src/SPlot2d/SPlot2d_ViewModel.h @@ -79,6 +79,9 @@ public: protected slots: virtual void onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* ); virtual void onLegendClicked( long key ); + +signals: + void legendSelected( const QString& ); }; -- 2.39.2