]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Fix remarks for the "0021383: [CEA 507] Plot2d Add analytic functions on curves"...
authorrnv <rnv@opencascade.com>
Tue, 17 Jan 2012 09:33:05 +0000 (09:33 +0000)
committerrnv <rnv@opencascade.com>
Tue, 17 Jan 2012 09:33:05 +0000 (09:33 +0000)
19 files changed:
doc/salome/gui/images/analytical_curves_dlg.png [new file with mode: 0755]
doc/salome/gui/input/plot2d_viewer.doc
src/LightApp/LightApp_Plot2dSelector.cxx
src/LightApp/LightApp_Plot2dSelector.h
src/Plot2d/Plot2d_AnalyticalCurveDlg.cxx
src/Plot2d/Plot2d_AnalyticalCurveDlg.h [new file with mode: 0755]
src/Plot2d/Plot2d_AnalyticalParser.cxx [new file with mode: 0755]
src/Plot2d/Plot2d_AnalyticalParser.h [new file with mode: 0755]
src/Plot2d/Plot2d_ViewFrame.cxx
src/Plot2d/Plot2d_ViewFrame.h
src/Plot2d/Plot2d_ViewWindow.cxx
src/Plot2d/Plot2d_ViewWindow.h
src/Plot2d/resources/Plot2d_images.ts
src/Plot2d/resources/Plot2d_msg_en.ts
src/Plot2d/resources/Plot2d_msg_fr.ts
src/Plot2d/resources/plot2d_analitic_curve.png [deleted file]
src/Plot2d/resources/plot2d_analytical_curve.png [new file with mode: 0755]
src/SPlot2d/SPlot2d_ViewModel.cxx
src/SPlot2d/SPlot2d_ViewModel.h

diff --git a/doc/salome/gui/images/analytical_curves_dlg.png b/doc/salome/gui/images/analytical_curves_dlg.png
new file mode 100755 (executable)
index 0000000..6bddc84
Binary files /dev/null and b/doc/salome/gui/images/analytical_curves_dlg.png differ
index 17efc2c4cbc9616f5dc383cdb2b4cfeb7c3fa3d7..1c664f75e4f381b6e5cba7df912ff447e9f7af01 100644 (file)
@@ -144,8 +144,37 @@ or ordinate) of all points displayed in the viewer is greater than zero.
 XY plots will be displayed with these defined properties.
 <hr>
 
+\anchor analytical_curve
+\image html plot2d_analytical_curve.png
+<br><center><b>Analytical curves</b> - provides an access to the analytical curves dialog box, 
+that allows to add, remove and modify analytical curves for the Plot 2d Viewer.</center>
+
+<br>
+
+\image html analytical_curves_dlg.png
+
+The options are as follows:<br>
+Curve parameters:
+<ul>
+<li><b>y(x)=</b> allows to specify python expression, which used to calculate coordinates of the points of the curve.</li>
+<li><b>Nb. itervals</b> allows to specify number of the points of the curve.</li>
+</ul>
+Curve properties:
+<ul>
+<li><b>Auto assign</b> if it is checked, properties of the curves (Line type, Line width, Marker type and Color)
+assigned automatically.To define the properties of the curve manually remove the checkmark from this control.</li>
+<li><b>Line type</b> allows to choose curve's line type from (None, Solid, Dash, Dot, Dash - Dot, Dash - Dot - Dot).</li>
+<li><b>Line width</b> allows to specify line width of the curve.</li>
+<li><b>Marker type</b> allows to choose curve's marker type from (Circle, Rectangle, Diamond, Rightward, 
+Leftward, Downward & Upward Triangle, Cross or Diagonal Cross).</li>
+<li><b>Color</b> allows to specify color of the curve.</li>
+</ul>
+
+<hr>
+
 \image html plot2d_clone.png
 <br><center><b>Clone view</b> - opens a new duplicate scene.</center>
+
 <hr>
 
 \image html plot2d_print.png
index 05b7c514dec3bde45033be9c29ec0c6b89c56d81..88f4f932794874c3ad0200de478c35a1d25fcd0d 100755 (executable)
@@ -22,6 +22,7 @@
 #include "LightApp_DataOwner.h"
 #include "LightApp_DataObject.h"
 #include "LightApp_Application.h"
+#include "SUIT_SelectionMgr.h"
 
 #include <SPlot2d_ViewModel.h>
 
@@ -36,6 +37,7 @@ LightApp_Plot2dSelector::LightApp_Plot2dSelector( Plot2d_Viewer* v, SUIT_Selecti
 {
   if ( v )
     connect( v, SIGNAL( legendSelected( const QString& ) ), this, SLOT( onSelectionChanged( const QString& ) ) );
+    connect( v, SIGNAL( clearSelected() ), this, SLOT( onClearSelected( ) ) );
 }
 
 /*!
@@ -81,3 +83,9 @@ void LightApp_Plot2dSelector::onSelectionChanged( const QString& entry )
   selectionChanged();
   myCurEntry = QString();
 }
+
+/*!On clear selected.*/
+void LightApp_Plot2dSelector::onClearSelected( ) 
+{
+       selectionMgr()->clearSelected();
+}
\ No newline at end of file
index 4032fa8ed57cff5e0cd70daabc3e5e7e0008afff..7a39fa04bef2917b1499275df9cba6443bb9369d 100755 (executable)
@@ -45,6 +45,7 @@ public:
 
 private slots:
   void         onSelectionChanged( const QString& );
+  void         onClearSelected();
 
 protected:
   virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
index a57dd27a774dc736e4ee97334e94838a3960fe2c..580d5d68d79cab422f06a6db0b6251ce4d59cf70 100755 (executable)
@@ -499,7 +499,7 @@ void Plot2d_AnalyticalCurveDlg::help()
 {
   SUIT_Application* app = SUIT_Session::session()->activeApplication();
   if ( app )
-    app->onHelpContextModule( "GUI", "plot2d_analytical_curves.html" );
+    app->onHelpContextModule( "GUI", "plot2d_viewer_page.html", "analytical_curve" );
 }
 
 /*!
diff --git a/src/Plot2d/Plot2d_AnalyticalCurveDlg.h b/src/Plot2d/Plot2d_AnalyticalCurveDlg.h
new file mode 100755 (executable)
index 0000000..d49ff75
--- /dev/null
@@ -0,0 +1,129 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+// File   : Plot2d_AnalyticalCurveDlg.h
+// Author : Roman NIKOLAEV, Open CASCADE S.A.S. (roman.nikolaev@opencascade.com)
+
+
+#ifndef PLOT2D_ANALYTICAL_CURVE_DLG_H
+#define PLOT2D_ANALYTICAL_CURVE_DLG_H
+
+#include "Plot2d.h"
+#include "Plot2d_AnalyticalCurve.h"
+
+#include <QDialog>
+#include <QMap>
+
+class QListWidget;
+class QListWidgetItem;
+class QGroupBox;
+class QLineEdit;
+class QCheckBox;
+class QComboBox;
+class QPushButton;
+
+class QtxIntSpinBox;
+class QtxColorButton;
+class QwtPlot;
+
+class Plot2d_AnalyticalCurve;
+class Plot2d_CurveContainer;
+class Plot2d_ViewFrame;
+
+class PLOT2D_EXPORT Plot2d_AnalyticalCurveDlg : public QDialog
+{ 
+  Q_OBJECT
+
+  class Updater;
+  class UpdateLocker;
+
+  enum { ItemExisting, ItemAdded, ItemRemoved };
+
+public:
+  Plot2d_AnalyticalCurveDlg( Plot2d_CurveContainer*, QWidget* );
+  ~Plot2d_AnalyticalCurveDlg();
+
+  void accept();
+  void reject();
+
+private:  
+  
+  void                  init();
+  void                  initPropsFromCurve(Plot2d_AnalyticalCurve*);
+  QListWidgetItem*      selected() const;
+  Plot2d_AnalyticalCurve* selectedCurve() const;
+  QListWidgetItem*      getItem(Plot2d_AnalyticalCurve*) const;
+  bool                  processCurves();
+  QwtPlot*              getPlot();
+  int                   propStatus( Plot2d_AnalyticalCurve* = 0, const int def = ItemExisting );
+  QString               propTitle( Plot2d_AnalyticalCurve* = 0, const QString& def = "" );
+  bool                  propVisible( Plot2d_AnalyticalCurve* = 0, bool def = true );
+  QString               propFormula( Plot2d_AnalyticalCurve* = 0, const QString& def = "" );
+  int                   propIntervals( Plot2d_AnalyticalCurve* = 0, int def = 100 );
+  Plot2d::MarkerType    propMarkerType( Plot2d_AnalyticalCurve* = 0, Plot2d::MarkerType def = Plot2d::None );
+  Plot2d::LineType      propLineType( Plot2d_AnalyticalCurve* = 0, Plot2d::LineType def = Plot2d::NoPen );
+  int                   propLineWidth( Plot2d_AnalyticalCurve* = 0, int def = 0 );
+  QColor                propColor( Plot2d_AnalyticalCurve* = 0, const QColor& def = QColor() );
+  bool                  propAutoAssign( Plot2d_AnalyticalCurve* = 0, bool def = true );
+
+private slots:
+  void addCurve();
+  void removeCurve();
+  void updateCurve();
+  void updateState();
+  void selectionChanged();
+  void help();
+  void apply();
+
+private:
+  typedef QMap <QString, QVariant> CurveProps;
+  typedef QMap <Plot2d_AnalyticalCurve*, CurveProps> PropMap;
+
+  Plot2d_CurveContainer* myContainer;
+  PropMap                myProperties;
+  Updater*               myUpdater;
+
+  QListWidget*           myCurvesList;
+  QGroupBox*             myCurveParams;
+  QLineEdit*             myFormula;
+  QtxIntSpinBox*         myNbIntervals;
+  QGroupBox*             myCurveProps;
+  QCheckBox*             myAutoAssign;
+  QWidget*               myPropsGrp;
+  QComboBox*             myMarkerType;
+  QComboBox*             myLineType;
+  QtxIntSpinBox*         myLineWidth;
+  QtxColorButton*        myColor;
+  QPushButton*           myAddButton;
+  QPushButton*           myRemoveButton;
+};
+
+class Plot2d_AnalyticalCurveDlg::Updater : public QObject
+{
+  Q_OBJECT
+public:
+  Updater( QWidget* parent );
+  ~Updater();
+signals:
+  void update();
+};
+
+#endif //PLOT2D_ANALYTICAL_CURVE_DLG_H
diff --git a/src/Plot2d/Plot2d_AnalyticalParser.cxx b/src/Plot2d/Plot2d_AnalyticalParser.cxx
new file mode 100755 (executable)
index 0000000..f10a562
--- /dev/null
@@ -0,0 +1,276 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+//  File   : Plot2d_AnalyticalParser.cxx
+//  Author : Roman NIKOLAEV, Open CASCADE S.A.S. (roman.nikolaev@opencascade.com)
+#include "Plot2d_AnalyticalParser.h"
+#include <structmember.h>
+
+
+/* ==================================
+ * ===========  PYTHON ==============
+ * ==================================*/
+
+typedef struct {
+  PyObject_HEAD
+  int softspace;
+  std::string *out;
+  } PyStdOut;
+
+static void
+PyStdOut_dealloc(PyStdOut *self)
+{
+  PyObject_Del(self);
+}
+
+static PyObject *
+PyStdOut_write(PyStdOut *self, PyObject *args)
+{
+  char *c;
+  int l;
+  if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
+    return NULL;
+
+  //std::cerr << c ;
+  *(self->out)=*(self->out)+c;
+
+  Py_INCREF(Py_None);
+  return Py_None;
+}
+
+static PyMethodDef PyStdOut_methods[] = {
+  {"write",  (PyCFunction)PyStdOut_write,  METH_VARARGS,
+    PyDoc_STR("write(string) -> None")},
+  {NULL,    NULL}   /* sentinel */
+};
+
+static PyMemberDef PyStdOut_memberlist[] = {
+  {(char*)"softspace", T_INT,  offsetof(PyStdOut, softspace), 0,
+   (char*)"flag indicating that a space needs to be printed; used by print"},
+  {NULL} /* Sentinel */
+};
+
+static PyTypeObject PyStdOut_Type = {
+  /* The ob_type field must be initialized in the module init function
+   * to be portable to Windows without using C++. */
+  PyObject_HEAD_INIT(NULL)
+  0,                            /*ob_size*/
+  "PyOut",                      /*tp_name*/
+  sizeof(PyStdOut),             /*tp_basicsize*/
+  0,                            /*tp_itemsize*/
+  /* methods */
+  (destructor)PyStdOut_dealloc, /*tp_dealloc*/
+  0,                            /*tp_print*/
+  0,                            /*tp_getattr*/
+  0,                            /*tp_setattr*/
+  0,                            /*tp_compare*/
+  0,                            /*tp_repr*/
+  0,                            /*tp_as_number*/
+  0,                            /*tp_as_sequence*/
+  0,                            /*tp_as_mapping*/
+  0,                            /*tp_hash*/
+  0,                            /*tp_call*/
+  0,                            /*tp_str*/
+  PyObject_GenericGetAttr,      /*tp_getattro*/
+  /* softspace is writable:  we must supply tp_setattro */
+  PyObject_GenericSetAttr,      /* tp_setattro */
+  0,                            /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT,           /*tp_flags*/
+  0,                            /*tp_doc*/
+  0,                            /*tp_traverse*/
+  0,                            /*tp_clear*/
+  0,                            /*tp_richcompare*/
+  0,                            /*tp_weaklistoffset*/
+  0,                            /*tp_iter*/
+  0,                            /*tp_iternext*/
+  PyStdOut_methods,             /*tp_methods*/
+  PyStdOut_memberlist,          /*tp_members*/
+  0,                            /*tp_getset*/
+  0,                            /*tp_base*/
+  0,                            /*tp_dict*/
+  0,                            /*tp_descr_get*/
+  0,                            /*tp_descr_set*/
+  0,                            /*tp_dictoffset*/
+  0,                            /*tp_init*/
+  0,                            /*tp_alloc*/
+  0,                            /*tp_new*/
+  0,                            /*tp_free*/
+  0,                            /*tp_is_gc*/
+};
+
+PyObject * newPyStdOut( std::string& out )
+{
+  PyStdOut *self;
+  self = PyObject_New(PyStdOut, &PyStdOut_Type);
+  if (self == NULL)
+    return NULL;
+  self->softspace = 0;
+  self->out=&out;
+  return (PyObject*)self;
+}
+
+
+////////////////////////END PYTHON///////////////////////////
+
+
+//! The only one instance of Parser
+Plot2d_AnalyticalParser* Plot2d_AnalyticalParser::myParser = 0;
+
+//Define the script
+QString Plot2d_AnalyticalParser::myScript = QString("");
+
+/*!
+  \brief Return the only instance of the Plot2d_AnalyticalParser
+  \return instance of the Plot2d_AnalyticalParser
+*/
+Plot2d_AnalyticalParser* Plot2d_AnalyticalParser::parser()
+{
+  if ( !myParser )
+    myParser = new Plot2d_AnalyticalParser();
+  return myParser;
+}
+
+/*!
+  \brief Constructor.
+
+  Construct the Parser and initialize python interpritator.
+*/
+Plot2d_AnalyticalParser::Plot2d_AnalyticalParser() 
+{
+  /* Initialize the Python interpreter */
+  if (Py_IsInitialized()) {
+    PyGILState_STATE gstate = PyGILState_Ensure();
+    myMainMod = PyImport_AddModule("__main__");
+    myMainDict = PyModule_GetDict(myMainMod);
+    PyGILState_Release(gstate);
+    initScript();
+  }
+}
+
+int Plot2d_AnalyticalParser::calculate( const QString& theExpr,
+                                     const double theMin,
+                                     const double theMax,
+                                     const int theNbStep,
+                                     double** theX,
+                                     double** theY) {
+  
+  QString aPyScript = myScript;
+  aPyScript = aPyScript.arg(theExpr);
+  int result = -1;
+  PyGILState_STATE gstate = PyGILState_Ensure();
+  PyObject* obj = PyRun_String(qPrintable(aPyScript), Py_file_input, myMainDict, NULL);
+
+  if(obj == NULL) {
+    PyErr_Print();
+    PyGILState_Release(gstate);        
+    return result;
+    
+  } else {
+    Py_DECREF(obj);
+  }
+  
+  PyObject* func = NULL;
+  PyObject* f_y = NULL;
+  
+  if(PyObject_HasAttrString(myMainMod, "Y")) {
+    f_y = PyObject_GetAttrString(myMainMod, "Y");
+  }
+
+  if(PyObject_HasAttrString(myMainMod, "coordCalculator")) {
+    func = PyObject_GetAttrString(myMainMod, "coordCalculator");
+  }
+
+  PyObject* new_stderr = NULL;
+  
+  if( f_y == NULL || func == NULL )  {
+    fflush(stderr);
+    std::string err_description="";
+    new_stderr = newPyStdOut(err_description);
+    PySys_SetObject((char*)"stderr", new_stderr);
+    PyErr_Print();
+    PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+    Py_DECREF(new_stderr);
+    PyGILState_Release(gstate);
+    return result;
+  }
+    
+  PyObject* coords;
+  coords = PyObject_CallFunction(func,(char*)"(d, d, i)", theMin, theMax, theNbStep );
+
+  new_stderr = NULL;
+  
+  if (coords == NULL){
+    fflush(stderr);
+    std::string err_description="";
+    new_stderr = newPyStdOut(err_description);
+    PySys_SetObject((char*)"stderr", new_stderr);
+    PyErr_Print();
+    PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+    Py_DECREF(new_stderr);
+    PyGILState_Release(gstate);
+    return result;
+  }
+
+  Py_ssize_t size = PyList_Size( coords );
+  if( size <= 0 ) {
+    Py_DECREF(coords);
+    return result;
+  }
+
+  result = size;
+
+  *theX = new double[size];
+  *theY = new double[size];
+  
+  for ( Py_ssize_t i = 0; i< size; ++i ) {
+    PyObject* coord = PyList_GetItem( coords, i );
+    (*theX)[i] =  PyFloat_AsDouble(PyList_GetItem(coord, 0));
+    (*theY)[i] =  PyFloat_AsDouble(PyList_GetItem(coord, 1));
+  }
+
+  PyGILState_Release(gstate);
+  return result;
+}
+
+/*!
+  \brief Initialize python script.
+*/
+void Plot2d_AnalyticalParser::initScript() {
+  myScript.clear();
+  myScript += "from math import *                      \n";
+  myScript += "def Y(x):                               \n";
+  myScript += "    return ";
+  myScript += "%1\n";
+
+  myScript += "def coordCalculator(xmin, xmax, nstep):     \n";
+  myScript += "   coords = []                              \n";
+  myScript += "   xstep  = (xmax - xmin) / nstep           \n";
+  myScript += "   n = 0                                    \n";
+  myScript += "   while n <= nstep :                       \n";
+  myScript += "      x = xmin + n*xstep                    \n";
+  myScript += "      try:                                  \n";
+  myScript += "                        y = Y(x)                           \n";
+  myScript += "                        coords.append([x,y])               \n";
+  myScript += "      except ValueError, ZeroDivisionError: \n";
+  myScript += "                        pass                               \n";
+  myScript += "      n = n+1                               \n";
+  myScript += "   return coords                            \n";
+}
diff --git a/src/Plot2d/Plot2d_AnalyticalParser.h b/src/Plot2d/Plot2d_AnalyticalParser.h
new file mode 100755 (executable)
index 0000000..37b55d9
--- /dev/null
@@ -0,0 +1,52 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+//  File   : Plot2d_AnalyticalParser.h
+//  Author : Roman NIKOLAEV, Open CASCADE S.A.S. (roman.nikolaev@opencascade.com)
+
+#ifndef PLOT2D_ANALYTICAL_Parser_H
+#define PLOT2D_ANALYTICAL_Parser_H
+#include <Python.h>
+
+#include "Plot2d.h"
+
+class PLOT2D_EXPORT Plot2d_AnalyticalParser {
+public: 
+  ~Plot2d_AnalyticalParser();
+
+
+  static Plot2d_AnalyticalParser*  parser();
+  int                            calculate( const QString&, const double,
+                                           const double, const int, 
+                                           double**, double**);
+  
+private:
+  Plot2d_AnalyticalParser();
+  void initScript();
+
+private:
+  static Plot2d_AnalyticalParser*  myParser;    //!< instance of the Parser
+  PyObject*                      myMainMod;   //!< main python module
+  PyObject*                      myMainDict;  //!< main python dictionary
+  static QString                 myScript;    //!< python script       
+};
+
+#endif //PLOT2D_ANALYTICAL_Parser_H
index ff36d6b5d8f222ed1d0029e69f55e30f905ab74c..3bb45f3deee9a31b75aa1d994a3bf14a31993f00 100755 (executable)
 #include "Plot2d_FitDataDlg.h"
 #include "Plot2d_ViewWindow.h"
 #include "Plot2d_SetupViewDlg.h"
-#ifndef DISABLE_PYCONSOLE
-#include "Plot2d_AnaliticCurveDlg.h"
-#include "Plot2d_AnaliticCurve.h"
-#endif
+#include "Plot2d_AnalyticalCurveDlg.h"
+#include "Plot2d_AnalyticalCurve.h"
 #include "Plot2d_ToolTip.h"
 
 #include "SUIT_Tools.h"
@@ -66,7 +64,6 @@
 #include <qwt_plot_zoomer.h>
 #include <qwt_curve_fitter.h>
 
-#include <iostream>
 #include <stdlib.h>
 #include <qprinter.h>
 
@@ -1602,24 +1599,38 @@ void Plot2d_ViewFrame::onSettings()
   delete dlg;
 }
 
-#ifndef DISABLE_PYCONSOLE
 /*!
-  "Analitic Curves" toolbar action slot
+  "Analytical Curves" toolbar action slot
 */
-void Plot2d_ViewFrame::onAnaliticCurve() {
-  Plot2d_AnaliticCurveDlg* dlg = new Plot2d_AnaliticCurveDlg(this, myPlot);
-  dlg->setCurveList(myAnaliticCurves);
-  dlg->exec();
-  delete dlg;
-}
+void Plot2d_ViewFrame::onAnalyticalCurve()
+{
+#ifndef DISABLE_PYCONSOLE
+  Plot2d_AnalyticalCurveDlg dlg( this, this );
+  dlg.exec();
+  updateAnalyticalCurves();
 #endif
+}
 
+void Plot2d_ViewFrame::addAnalyticalCurve( Plot2d_AnalyticalCurve* theCurve)
+{
+#ifndef DISABLE_PYCONSOLE
+       myAnalyticalCurves.append(theCurve);
+#endif
+}
 
+void Plot2d_ViewFrame::removeAnalyticalCurve( Plot2d_AnalyticalCurve* theCurve)
+{
 #ifndef DISABLE_PYCONSOLE
+       theCurve->setAction(Plot2d_AnalyticalCurve::ActRemoveFromView);
+#endif
+}
+
 /*
-  Update analitic curve
+  Update Analytical curve
 */
-void Plot2d_ViewFrame::updateAnaliticCurve(Plot2d_AnaliticCurve* c, bool updateView){
+void Plot2d_ViewFrame::updateAnalyticalCurve(Plot2d_AnalyticalCurve* c, bool updateView)
+{
+#ifndef DISABLE_PYCONSOLE
   if(!c) return;
   QwtScaleDiv* div = myPlot->axisScaleDiv(QwtPlot::xBottom);
   c->setRangeBegin(div->lowerBound());
@@ -1629,17 +1640,17 @@ void Plot2d_ViewFrame::updateAnaliticCurve(Plot2d_AnaliticCurve* c, bool updateV
   QwtPlotItem* item = c->plotItem();
   
   switch( c->getAction() ) {
-  case Plot2d_AnaliticCurve::ActAddInView:
+  case Plot2d_AnalyticalCurve::ActAddInView:
     if( c->isActive() ) {
+      c->updatePlotItem();
       item->attach( myPlot );
+      item->show();
     }
-    myAnaliticCurves.append(c);
-    c->setAction(Plot2d_AnaliticCurve::ActNothing);
+    c->setAction(Plot2d_AnalyticalCurve::ActNothing);
     break;
     
-  case Plot2d_AnaliticCurve::ActUpdateInView:
+  case Plot2d_AnalyticalCurve::ActUpdateInView:
     if(c->isActive()) {
-      item->attach( myPlot );
       c->updatePlotItem();
       item->show();
     } else {      
@@ -1647,33 +1658,56 @@ void Plot2d_ViewFrame::updateAnaliticCurve(Plot2d_AnaliticCurve* c, bool updateV
       item->detach();
     }
     
-    c->setAction(Plot2d_AnaliticCurve::ActNothing);
+    c->setAction(Plot2d_AnalyticalCurve::ActNothing);
     break;    
-  case Plot2d_AnaliticCurve::ActRemoveFromView:
+  case Plot2d_AnalyticalCurve::ActRemoveFromView:
     item->hide();
     item->detach();
-    myAnaliticCurves.removeAll(c);
+    myAnalyticalCurves.removeAll(c);
     delete c;
     break;
   }
 
   if(updateView)
     myPlot->replot();
-}
 #endif
+}
 
-#ifndef DISABLE_PYCONSOLE
 /*
-  Update analitic curves
+  Update Analytical curves
 */
-void Plot2d_ViewFrame::updateAnaliticCurves() {
-  AnaliticCurveList::iterator it = myAnaliticCurves.begin();
-  for( ; it != myAnaliticCurves.end(); it++) {
-    updateAnaliticCurve(*it);
+void Plot2d_ViewFrame::updateAnalyticalCurves()
+{
+#ifndef DISABLE_PYCONSOLE
+  AnalyticalCurveList::iterator it = myAnalyticalCurves.begin();
+  for( ; it != myAnalyticalCurves.end(); it++) {
+    updateAnalyticalCurve(*it);
   }
   myPlot->replot();
+#endif
 }
+
+/*!
+  Return list of the alalytical curves.
+*/
+AnalyticalCurveList Plot2d_ViewFrame::getAnalyticalCurves() const
+{
+  return myAnalyticalCurves;
+}
+
+/*!
+  Get analytical curve by plot item.
+*/
+Plot2d_AnalyticalCurve* Plot2d_ViewFrame::getAnalyticalCurve(QwtPlotItem * theItem) {
+#ifndef DISABLE_PYCONSOLE
+  AnalyticalCurveList::iterator it = myAnalyticalCurves.begin();
+  for( ; it != myAnalyticalCurves.end(); it++) {
+    if((*it)->plotItem() == theItem);
+               return (*it);
+  }
+  return 0;
 #endif
+}
 
 /*!
   "Fit Data" command slot
@@ -1690,9 +1724,7 @@ void Plot2d_ViewFrame::onFitData()
     fitData(mode,xMin,xMax,yMin,yMax,y2Min,y2Max);
   }
   delete dlg;
-#ifndef DISABLE_PYCONSOLE
-  updateAnaliticCurves();
-#endif
+  updateAnalyticalCurves();
 }
 
 /*!
@@ -2362,11 +2394,9 @@ void Plot2d_ViewFrame::plotMouseReleased( const QMouseEvent& me )
                               me.pos(), me.globalPos() );
     emit contextMenuRequested( &aEvent );
   } 
-#ifndef DISABLE_PYCONSOLE
   else {
-    updateAnaliticCurves();
+    updateAnalyticalCurves();
   }
-#endif
   myPlot->canvas()->setCursor( QCursor( Qt::CrossCursor ) );
   myPlot->defaultPicker();
 
@@ -2399,9 +2429,7 @@ void Plot2d_ViewFrame::wheelEvent(QWheelEvent* event)
   myPlot->replot();
   if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
   myPnt = event->pos();
-#ifndef DISABLE_PYCONSOLE
-  updateAnaliticCurves();
-#endif
+  updateAnalyticalCurves();
 }
 
 /*!
@@ -3217,15 +3245,14 @@ QString Plot2d_ViewFrame::getVisualParameters()
                  myLegendFont.italic(), myLegendFont.underline(),myLegendColor.red(),
                  myLegendColor.green(), myLegendColor.blue());
   
-#ifndef DISABLE_PYCONSOLE
-  //store all analitic curves
+  //store all Analytical curves
   //store each curve in the following format
   // ...*Name|isActive|Expresion|NbInervals|isAutoAssign[|MarkerType|LineType|LineWidth|r:g:b]
   // parameters in the [ ] is optional in case if isAutoAssign == true
-  AnaliticCurveList::iterator it = myAnaliticCurves.begin();
-  Plot2d_AnaliticCurve* c = 0;
+  AnalyticalCurveList::iterator it = myAnalyticalCurves.begin();
+  Plot2d_AnalyticalCurve* c = 0;
   bool isAuto; 
-  for( ; it != myAnaliticCurves.end(); it++) {
+  for( ; it != myAnalyticalCurves.end(); it++) {
     c = (*it);
     if(!c) continue;
     QString curveString("");
@@ -3250,7 +3277,6 @@ QString Plot2d_ViewFrame::getVisualParameters()
       retStr+=optCurveString;
     }
   }
-#endif
   return retStr; 
 }
 
@@ -3308,14 +3334,13 @@ void Plot2d_ViewFrame::setVisualParameters( const QString& parameters )
     }    
   }
 
-#ifndef DISABLE_PYCONSOLE
-  //Restore all analitical curves
+  //Restore all Analyticalal curves
   int startCurveIndex = 10;
   if( paramsLst.size() >= startCurveIndex+1 ) {
     for( int i=startCurveIndex; i<paramsLst.size() ; i++ ) {
       QStringList curveLst = paramsLst[i].split("|");
       if( curveLst.size() == 5 || curveLst.size() == 9 ) {
-       Plot2d_AnaliticCurve* c = new Plot2d_AnaliticCurve();
+       Plot2d_AnalyticalCurve* c = new Plot2d_AnalyticalCurve();
        c->setName(curveLst[0]);
        c->setActive(curveLst[1].toInt());
        c->setExpression(curveLst[2]);
@@ -3334,13 +3359,12 @@ void Plot2d_ViewFrame::setVisualParameters( const QString& parameters )
        } else {
          c->autoFill( myPlot );
        }
-       c->setAction(Plot2d_AnaliticCurve::ActAddInView);
-       updateAnaliticCurve(c);
+       addAnalyticalCurve(c);
+       updateAnalyticalCurve(c);
       }
     }
     myPlot->replot();
   }
-#endif
 }
 
 /*!
@@ -3449,6 +3473,25 @@ Plot2d_Curve* Plot2d_ViewFrame::getClosestCurve( QPoint p, double& distance, int
   return 0;
 }
 
+/*!
+ \brief  Deselect all analytical curves.
+*/
+void Plot2d_ViewFrame::deselectAnalyticalCurves() {
+  foreach(Plot2d_AnalyticalCurve* c, myAnalyticalCurves) {
+   c->setSelected(false);
+  }
+}
+
+/*!
+ \brief  Deselect all objects, except analytical curves.
+*/
+void Plot2d_ViewFrame::deselectObjects() {
+  ObjectDict::const_iterator it = myObjects.begin(), aLast = myObjects.end();
+  for ( ; it != aLast; it++ ) {
+         it.value()->setSelected(false);
+   }
+}
+
 #define INCREMENT_FOR_OP 10
 
 /*!
@@ -3457,9 +3500,7 @@ Plot2d_Curve* Plot2d_ViewFrame::getClosestCurve( QPoint p, double& distance, int
 void Plot2d_ViewFrame::onPanLeft()
 {
   this->incrementalPan( -INCREMENT_FOR_OP, 0 );
-#ifndef DISABLE_PYCONSOLE
-  updateAnaliticCurves();
-#endif
+  updateAnalyticalCurves();
 }
 
 /*!
@@ -3468,9 +3509,7 @@ void Plot2d_ViewFrame::onPanLeft()
 void Plot2d_ViewFrame::onPanRight()
 {
   this->incrementalPan( INCREMENT_FOR_OP, 0 );
-#ifndef DISABLE_PYCONSOLE
-  updateAnaliticCurves();
-#endif
+  updateAnalyticalCurves();
 }
 
 /*!
@@ -3479,9 +3518,7 @@ void Plot2d_ViewFrame::onPanRight()
 void Plot2d_ViewFrame::onPanUp()
 {
   this->incrementalPan( 0, -INCREMENT_FOR_OP );
-#ifndef DISABLE_PYCONSOLE
-  updateAnaliticCurves();
-#endif
+  updateAnalyticalCurves();
 }
 
 /*!
@@ -3490,9 +3527,7 @@ void Plot2d_ViewFrame::onPanUp()
 void Plot2d_ViewFrame::onPanDown()
 {
   this->incrementalPan( 0, INCREMENT_FOR_OP );
-#ifndef DISABLE_PYCONSOLE
-  updateAnaliticCurves();
-#endif
+  updateAnalyticalCurves();
 }
 
 /*!
@@ -3501,9 +3536,7 @@ void Plot2d_ViewFrame::onPanDown()
 void Plot2d_ViewFrame::onZoomIn()
 {
   this->incrementalZoom( INCREMENT_FOR_OP, INCREMENT_FOR_OP );
-#ifndef DISABLE_PYCONSOLE
-  updateAnaliticCurves();
-#endif
+  updateAnalyticalCurves();
 }
 
 /*!
@@ -3512,9 +3545,7 @@ void Plot2d_ViewFrame::onZoomIn()
 void Plot2d_ViewFrame::onZoomOut()
 {
   this->incrementalZoom( -INCREMENT_FOR_OP, -INCREMENT_FOR_OP );
-#ifndef DISABLE_PYCONSOLE
-  updateAnaliticCurves();
-#endif
+  updateAnalyticalCurves();
 }
 
 /*!
index 69eb8bfdd1ec4dc669670d95153b9c814b912c33..63a10e25c1a1b1e8dfc445f71ae489d4835eae82 100755 (executable)
@@ -25,9 +25,7 @@
 
 #include "Plot2d.h"
 #include "Plot2d_Curve.h"
-#ifndef DISABLE_PYCONSOLE
-#include "Plot2d_AnaliticCurve.h"
-#endif
+#include "Plot2d_AnalyticalCurve.h"
 #include "Plot2d_NormalizeAlgorithm.h"
 
 #include <QWidget>
@@ -58,7 +56,7 @@ class Plot2d_QwtPlotPicker;
 typedef QMultiHash<QwtPlotCurve*, Plot2d_Curve*>  CurveDict;
 typedef QMultiHash<QwtPlotItem*,  Plot2d_Object*> ObjectDict;
 
-class PLOT2D_EXPORT Plot2d_ViewFrame : public QWidget
+class PLOT2D_EXPORT Plot2d_ViewFrame : public QWidget, public Plot2d_CurveContainer
 { 
   Q_OBJECT
   
@@ -153,10 +151,16 @@ public:
   
   void           getFitRangeByCurves( double&, double&, double&, double&,
                                      double&, double& );
-#ifndef DISABLE_PYCONSOLE
-  void           updateAnaliticCurves();
-  void           updateAnaliticCurve( Plot2d_AnaliticCurve*, bool = false );
-#endif
+
+  void              addAnalyticalCurve( Plot2d_AnalyticalCurve* );
+  void              removeAnalyticalCurve( Plot2d_AnalyticalCurve* );
+  void              updateAnalyticalCurve( Plot2d_AnalyticalCurve*, bool = false );
+  void              updateAnalyticalCurves();
+  void              deselectAnalyticalCurves();        
+  void              deselectObjects(); 
+
+  AnalyticalCurveList getAnalyticalCurves() const;
+  Plot2d_AnalyticalCurve* getAnalyticalCurve(QwtPlotItem *);
 
   /* view parameters */
   void           copyPreferences( Plot2d_ViewFrame* );
@@ -241,6 +245,10 @@ protected:
   void           setCurveType( QwtPlotCurve*, int );
   bool           hasPlotObject( Plot2d_Object* ) const;
 
+
+  
+  
+
 public slots:
   void           onViewPan(); 
   void           onViewZoom();
@@ -248,9 +256,7 @@ public slots:
   void           onViewFitArea();
   void           onViewGlobalPan(); 
   void           onSettings();
-#ifndef DISABLE_PYCONSOLE
-  void           onAnaliticCurve();
-#endif
+  void           onAnalyticalCurve();
   void           onFitData();
   void           onChangeBackground();
   void           onPanLeft();
@@ -298,9 +304,7 @@ protected:
   double              myXDistance, myYDistance, myYDistance2;
   bool                mySecondY;
   ObjectDict          myObjects;
-#ifndef DISABLE_PYCONSOLE
-  AnaliticCurveList   myAnaliticCurves;
-#endif
+  AnalyticalCurveList myAnalyticalCurves;
   Plot2d_NormalizeAlgorithm* myLNormAlgo;
   Plot2d_NormalizeAlgorithm* myRNormAlgo;
   bool                myIsDefTitle;
index a9cfe63b7e86b73d56e4a309bdcc3be7a10a1c1b..1dfa2d22a9ec5c705b822b68df9bf9d47f9f06d5 100755 (executable)
@@ -432,16 +432,17 @@ void Plot2d_ViewWindow::createActions()
   connect( aAction, SIGNAL( triggered( bool ) ), myViewFrame, SLOT( onSettings() ) );
   mgr->registerAction( aAction, CurvSettingsId );
 
-  // 9. Analitic curves
-  aAction = new QtxAction( tr( "TOT_PLOT2D_ANALITIC_CURVES" ),
-                           aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_ANALITIC_CURVES" ) ),
-                           tr( "MEN_PLOT2D_ANALITIC_CURVES" ),
+  // 9. Analytical curves
+#ifndef DISABLE_PYCONSOLE
+  aAction = new QtxAction( tr( "TOT_PLOT2D_ANALYTICAL_CURVES" ),
+                           aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_ANALYTICAL_CURVES" ) ),
+                           tr( "MEN_PLOT2D_ANALYTICAL_CURVES" ),
                            0, this );
 
-  aAction->setStatusTip( tr( "PRP_PLOT2D_ANALITIC_CURVES" ) );
-  connect( aAction, SIGNAL( triggered( bool ) ), myViewFrame, SLOT( onAnaliticCurve() ) );
-  mgr->registerAction( aAction, AnaliticCurveId );
-
+  aAction->setStatusTip( tr( "PRP_PLOT2D_ANALYTICAL_CURVES" ) );
+  connect( aAction, SIGNAL( triggered( bool ) ), myViewFrame, SLOT( onAnalyticalCurve() ) );
+  mgr->registerAction( aAction, AnalyticalCurveId );
+#endif
 
   // 10. Clone
   aAction = new QtxAction( tr( "MNU_CLONE_VIEW" ),
@@ -499,7 +500,7 @@ void Plot2d_ViewWindow::createToolBar()
   mgr->append( toolMgr()->separator(), myToolBar );
   mgr->append( LegendId, myToolBar );
   mgr->append( CurvSettingsId, myToolBar );
-  mgr->append( AnaliticCurveId, myToolBar );
+  mgr->append( AnalyticalCurveId, myToolBar );
   mgr->append( CloneId, myToolBar );
   mgr->append( PrintId, myToolBar );
 }
index 66975732d0a2698d7fc82fb281fb90c7c884f29b..ffa44da2c0bc4772014e1c9bc48bb78e8ed88770 100755 (executable)
@@ -59,7 +59,7 @@ public:
         LegendId,
         CurvSettingsId,
         CloneId, PrintId,
-        AnaliticCurveId };
+        AnalyticalCurveId };
 
 public:
   Plot2d_ViewWindow( SUIT_Desktop*, Plot2d_Viewer* );
index 5841ec8a00c9904db4bc8489e700213e2d22dcb1..33028818f22243c8a5ac4b4c15d20460975417d5 100644 (file)
@@ -72,8 +72,8 @@
         <translation>plot2d_settings.png</translation>
     </message>
     <message>
-        <source>ICON_PLOT2D_ANALITIC_CURVES</source>
-        <translation>plot2d_analitic_curve.png</translation>
+        <source>ICON_PLOT2D_ANALYTICAL_CURVES</source>
+        <translation>plot2d_analytical_curve.png</translation>
     </message>    
     <message>
         <source>ICON_PLOT2D_CURVES_LINES</source>
index d312ff17d40491f4e1f9716ea7a7d090500f935d..b363b48e81fc4d46a59baf34af4e4942dccbede9 100644 (file)
         <translation>Settings</translation>
     </message>
     <message>
-        <source>TOT_PLOT2D_ANALITIC_CURVES</source>
-        <translation>Analytic curves</translation>
+        <source>TOT_PLOT2D_ANALYTICAL_CURVES</source>
+        <translation>Analytical curves</translation>
     </message>    
     <message>
         <source>TOT_PLOT2D_NORMALIZE_MODE_LMAX</source>
@@ -394,8 +394,8 @@ Logarithmic scale for ordinate axis is not allowed.</translation>
         <translation>Zoom the view</translation>
     </message>
     <message>
-        <source>PRP_PLOT2D_ANALITIC_CURVES</source>
-        <translation>Setups analytic curves properties</translation>
+        <source>PRP_PLOT2D_ANALYTICAL_CURVES</source>
+        <translation>Setups analytical curves properties</translation>
     </message>
     <message>
         <source>PRP_PLOT2D_NORMALIZE_MODE_LMAX</source>
@@ -522,8 +522,8 @@ Logarithmic scale for ordinate axis is not allowed.</translation>
         <translation>&amp;Settings</translation>
     </message>
     <message>
-        <source>MEN_PLOT2D_ANALITIC_CURVES</source>
-        <translation>Analytic curves</translation>
+        <source>MEN_PLOT2D_ANALYTICAL_CURVES</source>
+        <translation>Analytical curves</translation>
     </message>
     <message>
         <source>CIRCLE_MARKER_LBL</source>
@@ -673,10 +673,10 @@ Logarithmic scale for ordinate axis is not allowed.</translation>
     </message>
 </context>
 <context>
-    <name>Plot2d_AnaliticCurveDlg</name>
+    <name>Plot2d_AnalyticalCurveDlg</name>
     <message>
-        <source>ANALITIC_CURVE_TLT</source>
-        <translation>Analitic curves properties</translation>
+        <source>ANALYTICAL_CURVE_TLT</source>
+        <translation>Analytical curves properties</translation>
     </message>
     <message>
         <source>AC_CURVE_PARAMS</source>
@@ -723,9 +723,13 @@ Logarithmic scale for ordinate axis is not allowed.</translation>
         <translation>Remove curve</translation>
     </message>                    
     <message>
-        <source>AC_UPD_BTN</source>
-        <translation>Update Curve</translation>
+        <source>AC_OK_BTN</source>
+        <translation>Ok</translation>
     </message>                    
+    <message>
+        <source>AC_APPLY_BTN</source>
+        <translation>Apply</translation>
+    </message>                                        
     <message>
         <source>AC_CANT_CALCULATE</source>
         <translation>Can't calculate curve. 
@@ -735,6 +739,11 @@ Please, check input parameters!!!</translation>
         <source>AC_CLOSE_BTN</source>
         <translation>&amp;Close</translation>
     </message>
+    <message>
+        <source>AC_HELP_BTN</source>
+        <translation>Help</translation>
+    </message>
+
 </context>
 <context>
     <name>Plot2d_SetupCurveScaleDlg</name>
index 53be6d0ac293cb3fb9620230527cda71480b7a72..8ba2de9b1a44a2298680d425de8aeba975b63f45 100755 (executable)
         <translation>Paramètres</translation>
     </message>
     <message>
-        <source>TOT_PLOT2D_ANALITIC_CURVES</source>
+        <source>TOT_PLOT2D_ANALYTICAL_CURVES</source>
         <translation>Courbes analytiques</translation>
     </message>    
     <message>
@@ -354,7 +354,7 @@ L&apos;échelle logarithmique de l&apos;ordonnée n&apos;est pas permise.</trans
         <translation>Zoomer la vue</translation>
     </message>
     <message>
-        <source>PRP_PLOT2D_ANALITIC_CURVES</source>
+        <source>PRP_PLOT2D_ANALYTICAL_CURVES</source>
         <translation>Réglage des propriétés des courbes analytiques</translation>
     </message>
     <message>
@@ -450,7 +450,7 @@ L&apos;échelle logarithmique de l&apos;ordonnée n&apos;est pas permise.</trans
         <translation>&amp;Paramètres</translation>
     </message>
     <message>
-        <source>MEN_PLOT2D_ANALITIC_CURVES</source>
+        <source>MEN_PLOT2D_ANALYTICAL_CURVES</source>
         <translation>Courbes analytiques</translation>
     </message>
     <message>
@@ -601,9 +601,9 @@ L&apos;échelle logarithmique de l&apos;ordonnée n&apos;est pas permise.</trans
     </message>
 </context>
 <context>
-    <name>Plot2d_AnaliticCurveDlg</name>
+    <name>Plot2d_AnalyticalCurveDlg</name>
     <message>
-        <source>ANALITIC_CURVE_TLT</source>
+        <source>ANALYTICAL_CURVE_TLT</source>
         <translation>Propriétés des courbes analytiques</translation>
     </message>
     <message>
diff --git a/src/Plot2d/resources/plot2d_analitic_curve.png b/src/Plot2d/resources/plot2d_analitic_curve.png
deleted file mode 100755 (executable)
index 7ceb5f2..0000000
Binary files a/src/Plot2d/resources/plot2d_analitic_curve.png and /dev/null differ
diff --git a/src/Plot2d/resources/plot2d_analytical_curve.png b/src/Plot2d/resources/plot2d_analytical_curve.png
new file mode 100755 (executable)
index 0000000..7ceb5f2
Binary files /dev/null and b/src/Plot2d/resources/plot2d_analytical_curve.png differ
index 0c4d53a9b42b0919f9f879d2a785881fb5fbdaa4..c1e8b6cce13fed6f0b72c49d79cdfa2644a9acab 100644 (file)
@@ -79,7 +79,8 @@ using namespace std;
   Constructor
 */
 SPlot2d_Viewer::SPlot2d_Viewer(  bool theAutoDel )
-: Plot2d_Viewer( theAutoDel )    
+: Plot2d_Viewer( theAutoDel ),
+  myDeselectAnalytical(true)
 {
 }
 
@@ -406,6 +407,23 @@ void SPlot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem )
   Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
   if(aViewFrame == NULL) return;
 
+  bool isAnalytical = false;
+  AnalyticalCurveList curves = aViewFrame->getAnalyticalCurves();
+   foreach ( Plot2d_AnalyticalCurve* curve, curves ) {
+          if(plotItem == curve->plotItem()) {
+                 isAnalytical = true;
+                 curve->setSelected(true);
+          } else {
+                 curve->setSelected(false);
+          }
+   }
+  if(isAnalytical) {
+       myDeselectAnalytical = false;
+       emit clearSelected();
+       aViewFrame->updateAnalyticalCurves();
+       myDeselectAnalytical = true;
+       return;
+  }
 
   Plot2d_Object* anObject = aViewFrame->getPlotObject(plotItem);
   
@@ -423,7 +441,7 @@ void SPlot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem )
     
     if(!anEntry.isEmpty())
       emit legendSelected( anEntry );
-  }
+  }    
 }
 
 /*!
@@ -473,7 +491,11 @@ void SPlot2d_Viewer::setObjectsSelected( SALOME_ListIO& theList ) {
        o->setSelected(false);
        aViewFrame->updateObject(o);
       }
-    }    
+    }
+       if( myDeselectAnalytical ) {
+               aViewFrame->deselectAnalyticalCurves();
+               aViewFrame->updateAnalyticalCurves(); 
+       }
     aViewFrame->Repaint();
   }
 }
index f29904fd8ecfd456c6cbc8331439bf76b267d072..8a31b3da1e0306db7fe9e8a76d148308666aaa92 100644 (file)
@@ -88,6 +88,9 @@ protected slots:
 
 signals:
   void legendSelected( const QString& );
+  void clearSelected();
+private:
+  bool myDeselectAnalytical;
 };