]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Plot2d: clicking in legend on curve name doesn't highlight it in object browser
authordmv <dmv@opencascade.com>
Tue, 21 Oct 2008 11:27:39 +0000 (11:27 +0000)
committerdmv <dmv@opencascade.com>
Tue, 21 Oct 2008 11:27:39 +0000 (11:27 +0000)
src/Plot2d/Plot2d_ViewFrame.cxx
src/Plot2d/Plot2d_ViewFrame.h
src/Plot2d/Plot2d_ViewManager.cxx
src/Plot2d/Plot2d_ViewModel.cxx
src/Plot2d/Plot2d_ViewModel.h
src/SPlot2d/Makefile.am
src/SPlot2d/SPlot2d_ViewModel.cxx
src/SPlot2d/SPlot2d_ViewModel.h

index d234801fba42a6d8e52fc58653ac9a69e175c3da..b3fe3d4e608d955baf1828e59cad5442c4ff0b6a 100755 (executable)
@@ -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 );
   }
index ba9f2e5f8621750f6a31c5c844a8a1591bc78c69..c08c827aedc7e4d909f2420801081aa53d507d2b 100755 (executable)
@@ -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;
index a94f5642c01f410ea16e7017796d91f855a1337d..8d2eb31746494c52901de618cdae1ddb8fc647d1 100755 (executable)
@@ -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;
 }
index 5725fb412a7dd9b4a50052dd66138ac1a3f45622..dfd54f1247f70c7db21f4cc996146cbe44db0654 100755 (executable)
@@ -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
index b2c0b041629496a53cc3bd02fb400e08f5af2f64..3402dc6a943889514664cc6ba1ae6d8d8e19fa45 100755 (executable)
@@ -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;
index b2dc3f6a5b6c642ecfeb57c4eb6bd92a8427b2c8..db5b1a8773386d6a5ec3ad97aac2755c28289fba 100644 (file)
@@ -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
 
 
index 993e6bab0a9043c45e161a126dbd37de6d116699..4b2bfda05e504fa9d5ecae41203400d1c85f198f 100644 (file)
 #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>
@@ -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<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 );
+      }
+    }
+  }
+}
index f12a8d601f00ccae7fb0a2dd0d931102e5a7aa2f..5aca6ff92c0d0807ed44dad24d697c98c30f010a 100644 (file)
@@ -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 );
 };