]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Plot2d: clicking in legend on curve name doesn't highlight it in object browser RELIQUAT_4x_25102008
authordmv <dmv@opencascade.com>
Fri, 24 Oct 2008 12:03:43 +0000 (12:03 +0000)
committerdmv <dmv@opencascade.com>
Fri, 24 Oct 2008 12:03:43 +0000 (12:03 +0000)
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Plot2dSelector.cxx [new file with mode: 0755]
src/LightApp/LightApp_Plot2dSelector.h [new file with mode: 0755]
src/LightApp/Makefile.am
src/Plot2d/Plot2d_ViewModel.h
src/SPlot2d/Makefile.am
src/SPlot2d/SPlot2d_ViewModel.cxx
src/SPlot2d/SPlot2d_ViewModel.h

index 6486e0285a0785fa1c3add96e4752c94a176b685..686efcbd547b37a0632c3b6d0ee48fdd226618c6 100644 (file)
@@ -77,6 +77,7 @@
 #ifndef DISABLE_PLOT2DVIEWER
   #include <Plot2d_ViewManager.h>
   #include <Plot2d_ViewModel.h>
+  #include "LightApp_Plot2dSelector.h"
 #ifndef DISABLE_SALOMEOBJECT
   #include <SPlot2d_ViewModel.h>
 #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 (executable)
index 0000000..2cad341
--- /dev/null
@@ -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 (executable)
index 0000000..823991e
--- /dev/null
@@ -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 <SUIT_Selector.h>
+#include <SUIT_DataOwner.h>
+#include <SPlot2d_ViewModel.h>
+
+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
index f59c4bd09b88ea3ef1d04c9af702643af726285d..6d2acc85ce0695d203caf3bb09a36e5cb0b1f77d 100755 (executable)
@@ -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= \
index a132efb41046ca66e430c892f4983054b750044e..a5ec5424f8d0edc9096ac80c4e0f6e5a23bee15a 100755 (executable)
@@ -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;
index 204978dfd52dc2c7bb0711f6a7760f616e4f6e49..17dc25b37d1601d1c1c9698ac9556316157cf2a8 100644 (file)
@@ -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
 
 
index b46c9e2c32e9e427cfff4c3d1d13c2388e65ccb8..39f89063ebbb98fb45b74984cd887130429d91d1 100644 (file)
@@ -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<SPlot2d_Curve*>(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 );
   }
 }
 
index 0f215921e80c7457a096dc3d9e7c0e54cae9c105..21680d410f7dd14a0c885c81a798d7ded001f5e2 100644 (file)
@@ -79,6 +79,9 @@ public:
 protected slots:
   virtual void onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* );
   virtual void onLegendClicked( long key );
+
+signals:
+  void legendSelected( const QString& );
 };