]> 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>
Fri, 24 Oct 2008 12:11:34 +0000 (12:11 +0000)
committerdmv <dmv@opencascade.com>
Fri, 24 Oct 2008 12:11:34 +0000 (12:11 +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/SPlot2d/Makefile.am
src/SPlot2d/SPlot2d_ViewModel.cxx
src/SPlot2d/SPlot2d_ViewModel.h

index 4818feb39c5034d9e3c1ab5aeb9f2f9433861b44..c31a8aac4363341ab8c3ba6dbb5459e9cf0ecb4c 100644 (file)
@@ -83,6 +83,7 @@
 #ifndef DISABLE_PLOT2DVIEWER
   #include <Plot2d_ViewManager.h>
   #include <Plot2d_ViewModel.h>
+  #include "LightApp_Plot2dSelector.h"
 #ifndef DISABLE_SALOMEOBJECT
   #include <SPlot2d_ViewModel.h>
 #else
@@ -1252,7 +1253,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..a88c5f3
--- /dev/null
@@ -0,0 +1,65 @@
+// 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 )
+{
+  /*  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..7a47b46
--- /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 QObject, 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 fecbda7c51a78e9f3acf61e84423de5ca3d317a4..10b5d22882774ec75e4ab8f3f82e535493b41d29 100755 (executable)
@@ -66,6 +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           \
@@ -106,6 +109,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       \
@@ -136,6 +142,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 db5b1a8773386d6a5ec3ad97aac2755c28289fba..b2dc3f6a5b6c642ecfeb57c4eb6bd92a8427b2c8 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)/../LightApp -I$(srcdir)/../CAM -I$(srcdir)/../STD
+                        -I$(srcdir)/../Prs -I$(srcdir)/../OBJECT
 libSPlot2d_la_LDFLAGS  = $(QT_MT_LIBS) $(QWT_LIBS) ../SUIT/libsuit.la ../Plot2d/libPlot2d.la ../Prs/libSalomePrs.la
 
 
index 4b2bfda05e504fa9d5ecae41203400d1c85f198f..29113385e51d36e2a6e7bf35679d974d5ded83d8 100644 (file)
@@ -29,8 +29,6 @@
 #include "SUIT_Application.h"
 #include "SUIT_ViewManager.h"
 
-#include "LightApp_SelectionMgr.h"
-#include "LightApp_Application.h"
 #include "SALOME_ListIO.hxx"
 
 #include <QApplication>
@@ -400,14 +398,7 @@ void SPlot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem )
   }
   // 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 );
-      }
-    }
+    QString anEntry = aSCurve->getIO()->getEntry();
+    emit legendSelected( anEntry );
   }
 }
index 5aca6ff92c0d0807ed44dad24d697c98c30f010a..b6b3747fe26a87acc226669b80e06b3dbef407ef 100644 (file)
@@ -78,6 +78,9 @@ public:
 
 protected slots:
   virtual void onLegendClicked( QwtPlotItem* plotItem );
+
+signals:
+  void legendSelected( const QString& );
 };