From 1a7761af4d535a98780a51d7f1bc6176f8d42849 Mon Sep 17 00:00:00 2001 From: dmv Date: Tue, 21 Oct 2008 11:29:41 +0000 Subject: [PATCH] Plot2d: clicking in legend on curve name doesn't highlight it in object browser --- src/Plot2d/Plot2d_ViewFrame.cxx | 5 +++-- src/Plot2d/Plot2d_ViewFrame.h | 1 + src/Plot2d/Plot2d_ViewManager.cxx | 5 +++++ src/Plot2d/Plot2d_ViewModel.cxx | 7 +++++++ src/Plot2d/Plot2d_ViewModel.h | 1 + src/SPlot2d/Makefile.am | 2 +- src/SPlot2d/SPlot2d_ViewModel.cxx | 32 ++++++++++++++++++++++++++++++- src/SPlot2d/SPlot2d_ViewModel.h | 1 + 8 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 55b805bfc..afa7baa03 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -168,8 +168,8 @@ Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title ) this, SLOT( plotMousePressed( const QMouseEvent& ) ) ); connect( myPlot, SIGNAL( plotMouseReleased( const QMouseEvent& ) ), this, SLOT( plotMouseReleased( const QMouseEvent& ) ) ); - //connect( myPlot, SIGNAL( legendClicked( long ) ), - // this, SLOT( onLegendClicked( long ) ) ); + connect( myPlot, SIGNAL( legendClicked( long ) ), + this, SIGNAL( legendClicked( long ) ) ); /* Initial Setup - get from the preferences */ readPreferences(); @@ -1135,6 +1135,7 @@ void Plot2d_ViewFrame::setLegendPos( int pos ) } } + /*! Sets new marker size */ diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 108cbd957..1ca3f197f 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -162,6 +162,7 @@ signals: void vpModeVerChanged(); void vpCurveChanged(); void contextMenuRequested( QContextMenuEvent *e ); + void legendClicked(long key); protected: Plot2d_Plot2d* myPlot; diff --git a/src/Plot2d/Plot2d_ViewManager.cxx b/src/Plot2d/Plot2d_ViewManager.cxx index a94f5642c..071794bd2 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,10 @@ 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( long ) ), aViewer, SLOT( onLegendClicked( long ) ) ); } return res; } diff --git a/src/Plot2d/Plot2d_ViewModel.cxx b/src/Plot2d/Plot2d_ViewModel.cxx index 514d04b73..d3a8cb66e 100755 --- a/src/Plot2d/Plot2d_ViewModel.cxx +++ b/src/Plot2d/Plot2d_ViewModel.cxx @@ -204,6 +204,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( long key ) +{ +} + /*! Sets view manager \param mgr - new view manager diff --git a/src/Plot2d/Plot2d_ViewModel.h b/src/Plot2d/Plot2d_ViewModel.h index a61755549..cd049698f 100755 --- a/src/Plot2d/Plot2d_ViewModel.h +++ b/src/Plot2d/Plot2d_ViewModel.h @@ -57,6 +57,7 @@ protected slots: void onDumpView(); void onShowToolbar(); virtual void onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* ); + virtual void onLegendClicked( QwtPlotItem* plotItem ); private: Plot2d_Prs* myPrs; diff --git a/src/SPlot2d/Makefile.am b/src/SPlot2d/Makefile.am index 17dc25b37..204978dfd 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)/../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 bb17e1c63..b46c9e2c3 100644 --- a/src/SPlot2d/SPlot2d_ViewModel.cxx +++ b/src/SPlot2d/SPlot2d_ViewModel.cxx @@ -28,7 +28,10 @@ #include "SUIT_Session.h" #include "SUIT_Application.h" -//#include "utilities.h" +#include "LightApp_SelectionMgr.h" +#include "LightApp_Application.h" +#include "SALOME_ListIO.hxx" + #include "qapplication.h" #include #include @@ -385,6 +388,33 @@ void SPlot2d_Viewer::onCloneView( Plot2d_ViewFrame* clonedVF, Plot2d_ViewFrame* Plot2d_Viewer::onCloneView( clonedVF, newVF ); } +/*! + SLOT: called when action "Legend Clicked" is activated. + override "onLegendClicked" method from Plot2d_ViewModel. +*/ +void SPlot2d_Viewer::onLegendClicked( long key ) +{ + Plot2d_ViewFrame* aViewFrame = getActiveViewFrame(); + if(aViewFrame == NULL) return; + + QIntDict aCurves = aViewFrame->getCurves(); + + Plot2d_Curve* aCurve = aCurves.find( 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 ); + } + } + } +} + /*! create SPlot2d_ViewWindow */ diff --git a/src/SPlot2d/SPlot2d_ViewModel.h b/src/SPlot2d/SPlot2d_ViewModel.h index 7182def58..0f215921e 100644 --- a/src/SPlot2d/SPlot2d_ViewModel.h +++ b/src/SPlot2d/SPlot2d_ViewModel.h @@ -78,6 +78,7 @@ public: protected slots: virtual void onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* ); + virtual void onLegendClicked( long key ); }; -- 2.39.2