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();
legend = new QwtLegend( myPlot );
legend->setFrameStyle( QFrame::Box | QFrame::Sunken );
}
+ legend->setItemMode( QwtLegend::ClickableItem );
myPlot->insertLegend( legend );
setLegendPos( myLegendPos );
}
void onSettings();
void onFitData();
void onChangeBackground();
-
void onPanLeft();
void onPanRight();
void onPanUp();
void vpModeVerChanged();
void vpCurveChanged();
void contextMenuRequested( QContextMenuEvent *e );
+ void legendClicked( QwtPlotItem* );
protected:
Plot2d_Plot2d* myPlot;
#include "Plot2d_ViewManager.h"
#include "Plot2d_ViewModel.h"
#include "Plot2d_ViewWindow.h"
+#include "Plot2d_ViewFrame.h"
/*!
Constructor
{
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;
}
}
}
+/*
+ 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
#include "Plot2d.h"
#include "SUIT_ViewModel.h"
+#include "qwt_plot.h"
class SUIT_ViewWindow;
class SUIT_Desktop;
void onDumpView();
void onShowToolbar();
virtual void onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* );
+ virtual void onLegendClicked( QwtPlotItem* );
private:
Plot2d_Prs* myPrs;
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
#include "SUIT_Application.h"
#include "SUIT_ViewManager.h"
-//#include "utilities.h"
+#include "LightApp_SelectionMgr.h"
+#include "LightApp_Application.h"
+#include "SALOME_ListIO.hxx"
+
#include <QApplication>
#include <QToolBar>
#include <QToolButton>
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<SPlot2d_Curve*>( 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 );
+ }
+ }
+ }
+}
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 );
};