From: dmv Date: Tue, 21 Oct 2008 11:27:39 +0000 (+0000) Subject: Plot2d: clicking in legend on curve name doesn't highlight it in object browser X-Git-Tag: V5_1_0a3~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=24189cbde30fa0c861fe8dda8242db47760e8fea;p=modules%2Fgui.git Plot2d: clicking in legend on curve name doesn't highlight it in object browser --- diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index d234801fb..b3fe3d4e6 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -171,9 +171,9 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title ) aLayout->addWidget( myPlot ); -// createActions(); - //connect( myPlot, SIGNAL( legendClicked( long ) ), - // this, SLOT( onLegendClicked( long ) ) ); + // createActions(); + connect( myPlot, SIGNAL( legendClicked( QwtPlotItem* ) ), + this, SIGNAL( legendClicked( QwtPlotItem* ) ) ); /* Initial Setup - get from the preferences */ readPreferences(); @@ -1029,6 +1029,7 @@ void Plot2d_ViewFrame::showLegend( bool show, bool update ) legend = new QwtLegend( myPlot ); legend->setFrameStyle( QFrame::Box | QFrame::Sunken ); } + legend->setItemMode( QwtLegend::ClickableItem ); myPlot->insertLegend( legend ); setLegendPos( myLegendPos ); } diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index ba9f2e5f8..c08c827ae 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -150,7 +150,6 @@ public slots: void onSettings(); void onFitData(); void onChangeBackground(); - void onPanLeft(); void onPanRight(); void onPanUp(); @@ -169,6 +168,7 @@ signals: void vpModeVerChanged(); void vpCurveChanged(); void contextMenuRequested( QContextMenuEvent *e ); + void legendClicked( QwtPlotItem* ); protected: Plot2d_Plot2d* myPlot; diff --git a/src/Plot2d/Plot2d_ViewManager.cxx b/src/Plot2d/Plot2d_ViewManager.cxx index a94f5642c..8d2eb3174 100755 --- a/src/Plot2d/Plot2d_ViewManager.cxx +++ b/src/Plot2d/Plot2d_ViewManager.cxx @@ -19,6 +19,7 @@ #include "Plot2d_ViewManager.h" #include "Plot2d_ViewModel.h" #include "Plot2d_ViewWindow.h" +#include "Plot2d_ViewFrame.h" /*! Constructor @@ -55,6 +56,11 @@ bool Plot2d_ViewManager::insertView( SUIT_ViewWindow* theView ) { Plot2d_ViewWindow* view = (Plot2d_ViewWindow*)theView; connect( view, SIGNAL( cloneView() ), this, SLOT( onCloneView() ) ); + + Plot2d_ViewFrame* aViewFrame = view->getViewFrame(); + Plot2d_Viewer* aViewer = getPlot2dModel(); + connect( aViewFrame, SIGNAL( legendClicked( QwtPlotItem* ) ), + aViewer, SLOT( onLegendClicked( QwtPlotItem* ) ) ); } return res; } diff --git a/src/Plot2d/Plot2d_ViewModel.cxx b/src/Plot2d/Plot2d_ViewModel.cxx index 5725fb412..dfd54f124 100755 --- a/src/Plot2d/Plot2d_ViewModel.cxx +++ b/src/Plot2d/Plot2d_ViewModel.cxx @@ -208,6 +208,13 @@ void Plot2d_Viewer::onCloneView( Plot2d_ViewFrame* clonedVF, Plot2d_ViewFrame* n } } +/* + SLOT: called when clicked item in the legend from Plot2d_ViewManager + */ +void Plot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem ) +{ +} + /*! Sets view manager \param mgr - new view manager diff --git a/src/Plot2d/Plot2d_ViewModel.h b/src/Plot2d/Plot2d_ViewModel.h index b2c0b0416..3402dc6a9 100755 --- a/src/Plot2d/Plot2d_ViewModel.h +++ b/src/Plot2d/Plot2d_ViewModel.h @@ -21,6 +21,7 @@ #include "Plot2d.h" #include "SUIT_ViewModel.h" +#include "qwt_plot.h" class SUIT_ViewWindow; class SUIT_Desktop; @@ -57,6 +58,7 @@ protected slots: void onDumpView(); void onShowToolbar(); virtual void onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* ); + virtual void onLegendClicked( QwtPlotItem* ); private: Plot2d_Prs* myPrs; diff --git a/src/SPlot2d/Makefile.am b/src/SPlot2d/Makefile.am index b2dc3f6a5..db5b1a877 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)/../Prs -I$(srcdir)/../OBJECT -I$(srcdir)/../LightApp -I$(srcdir)/../CAM -I$(srcdir)/../STD 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 993e6bab0..4b2bfda05 100644 --- a/src/SPlot2d/SPlot2d_ViewModel.cxx +++ b/src/SPlot2d/SPlot2d_ViewModel.cxx @@ -29,7 +29,10 @@ #include "SUIT_Application.h" #include "SUIT_ViewManager.h" -//#include "utilities.h" +#include "LightApp_SelectionMgr.h" +#include "LightApp_Application.h" +#include "SALOME_ListIO.hxx" + #include #include #include @@ -375,3 +378,36 @@ SUIT_ViewWindow* SPlot2d_Viewer::createView( SUIT_Desktop* theDesktop ) aPlot2dView->getViewFrame()->Display(getPrs()); return aPlot2dView; } + +/*! + SLOT: called when action "Legend Clicked" is activated. + override "onLegendClicked" method from Plot2d_ViewModel. +*/ +void SPlot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem ) +{ + Plot2d_ViewFrame* aViewFrame = getActiveViewFrame(); + if(aViewFrame == NULL) return; + + CurveDict aCurves = aViewFrame->getCurves(); + SPlot2d_Curve* aSCurve; + CurveDict::Iterator it = aCurves.begin(); + for( ; it != aCurves.end(); ++it ) + { + if ( it.key() == plotItem ) { + aSCurve = dynamic_cast( it.value() ); + break; + } + } + // 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 ); + } + } + } +} diff --git a/src/SPlot2d/SPlot2d_ViewModel.h b/src/SPlot2d/SPlot2d_ViewModel.h index f12a8d601..5aca6ff92 100644 --- a/src/SPlot2d/SPlot2d_ViewModel.h +++ b/src/SPlot2d/SPlot2d_ViewModel.h @@ -75,6 +75,9 @@ public: SPlot2d_Curve* getCurveByIO( const Handle(SALOME_InteractiveObject)&, Plot2d_ViewFrame* = 0 ); Plot2d_ViewFrame* getActiveViewFrame(); Handle(SALOME_InteractiveObject) FindIObject( const char* Entry ); + +protected slots: + virtual void onLegendClicked( QwtPlotItem* plotItem ); };