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
#include "LightApp_DataOwner.h"
#include "LightApp_DataObject.h"
#include "LightApp_Application.h"
+#include "SUIT_SelectionMgr.h"
#include <SPlot2d_ViewModel.h>
{
if ( v )
connect( v, SIGNAL( legendSelected( const QString& ) ), this, SLOT( onSelectionChanged( const QString& ) ) );
+ connect( v, SIGNAL( clearSelected() ), this, SLOT( onClearSelected( ) ) );
}
/*!
selectionChanged();
myCurEntry = QString();
}
+
+/*!On clear selected.*/
+void LightApp_Plot2dSelector::onClearSelected( )
+{
+ selectionMgr()->clearSelected();
+}
\ No newline at end of file
private slots:
void onSelectionChanged( const QString& );
+ void onClearSelected();
protected:
virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
{
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" );
}
/*!
--- /dev/null
+// 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
--- /dev/null
+// 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";
+}
--- /dev/null
+// 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
#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"
#include <qwt_plot_zoomer.h>
#include <qwt_curve_fitter.h>
-#include <iostream>
#include <stdlib.h>
#include <qprinter.h>
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());
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 {
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
fitData(mode,xMin,xMax,yMin,yMax,y2Min,y2Max);
}
delete dlg;
-#ifndef DISABLE_PYCONSOLE
- updateAnaliticCurves();
-#endif
+ updateAnalyticalCurves();
}
/*!
me.pos(), me.globalPos() );
emit contextMenuRequested( &aEvent );
}
-#ifndef DISABLE_PYCONSOLE
else {
- updateAnaliticCurves();
+ updateAnalyticalCurves();
}
-#endif
myPlot->canvas()->setCursor( QCursor( Qt::CrossCursor ) );
myPlot->defaultPicker();
myPlot->replot();
if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase();
myPnt = event->pos();
-#ifndef DISABLE_PYCONSOLE
- updateAnaliticCurves();
-#endif
+ updateAnalyticalCurves();
}
/*!
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("");
retStr+=optCurveString;
}
}
-#endif
return retStr;
}
}
}
-#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]);
} else {
c->autoFill( myPlot );
}
- c->setAction(Plot2d_AnaliticCurve::ActAddInView);
- updateAnaliticCurve(c);
+ addAnalyticalCurve(c);
+ updateAnalyticalCurve(c);
}
}
myPlot->replot();
}
-#endif
}
/*!
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
/*!
void Plot2d_ViewFrame::onPanLeft()
{
this->incrementalPan( -INCREMENT_FOR_OP, 0 );
-#ifndef DISABLE_PYCONSOLE
- updateAnaliticCurves();
-#endif
+ updateAnalyticalCurves();
}
/*!
void Plot2d_ViewFrame::onPanRight()
{
this->incrementalPan( INCREMENT_FOR_OP, 0 );
-#ifndef DISABLE_PYCONSOLE
- updateAnaliticCurves();
-#endif
+ updateAnalyticalCurves();
}
/*!
void Plot2d_ViewFrame::onPanUp()
{
this->incrementalPan( 0, -INCREMENT_FOR_OP );
-#ifndef DISABLE_PYCONSOLE
- updateAnaliticCurves();
-#endif
+ updateAnalyticalCurves();
}
/*!
void Plot2d_ViewFrame::onPanDown()
{
this->incrementalPan( 0, INCREMENT_FOR_OP );
-#ifndef DISABLE_PYCONSOLE
- updateAnaliticCurves();
-#endif
+ updateAnalyticalCurves();
}
/*!
void Plot2d_ViewFrame::onZoomIn()
{
this->incrementalZoom( INCREMENT_FOR_OP, INCREMENT_FOR_OP );
-#ifndef DISABLE_PYCONSOLE
- updateAnaliticCurves();
-#endif
+ updateAnalyticalCurves();
}
/*!
void Plot2d_ViewFrame::onZoomOut()
{
this->incrementalZoom( -INCREMENT_FOR_OP, -INCREMENT_FOR_OP );
-#ifndef DISABLE_PYCONSOLE
- updateAnaliticCurves();
-#endif
+ updateAnalyticalCurves();
}
/*!
#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>
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
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* );
void setCurveType( QwtPlotCurve*, int );
bool hasPlotObject( Plot2d_Object* ) const;
+
+
+
+
public slots:
void onViewPan();
void onViewZoom();
void onViewFitArea();
void onViewGlobalPan();
void onSettings();
-#ifndef DISABLE_PYCONSOLE
- void onAnaliticCurve();
-#endif
+ void onAnalyticalCurve();
void onFitData();
void onChangeBackground();
void onPanLeft();
double myXDistance, myYDistance, myYDistance2;
bool mySecondY;
ObjectDict myObjects;
-#ifndef DISABLE_PYCONSOLE
- AnaliticCurveList myAnaliticCurves;
-#endif
+ AnalyticalCurveList myAnalyticalCurves;
Plot2d_NormalizeAlgorithm* myLNormAlgo;
Plot2d_NormalizeAlgorithm* myRNormAlgo;
bool myIsDefTitle;
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" ),
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 );
}
LegendId,
CurvSettingsId,
CloneId, PrintId,
- AnaliticCurveId };
+ AnalyticalCurveId };
public:
Plot2d_ViewWindow( SUIT_Desktop*, Plot2d_Viewer* );
<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>
<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>
<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>
<translation>&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>
</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>
<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.
<source>AC_CLOSE_BTN</source>
<translation>&Close</translation>
</message>
+ <message>
+ <source>AC_HELP_BTN</source>
+ <translation>Help</translation>
+ </message>
+
</context>
<context>
<name>Plot2d_SetupCurveScaleDlg</name>
<translation>Paramètres</translation>
</message>
<message>
- <source>TOT_PLOT2D_ANALITIC_CURVES</source>
+ <source>TOT_PLOT2D_ANALYTICAL_CURVES</source>
<translation>Courbes analytiques</translation>
</message>
<message>
<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>
<translation>&Paramètres</translation>
</message>
<message>
- <source>MEN_PLOT2D_ANALITIC_CURVES</source>
+ <source>MEN_PLOT2D_ANALYTICAL_CURVES</source>
<translation>Courbes analytiques</translation>
</message>
<message>
</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>
Constructor
*/
SPlot2d_Viewer::SPlot2d_Viewer( bool theAutoDel )
-: Plot2d_Viewer( theAutoDel )
+: Plot2d_Viewer( theAutoDel ),
+ myDeselectAnalytical(true)
{
}
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);
if(!anEntry.isEmpty())
emit legendSelected( anEntry );
- }
+ }
}
/*!
o->setSelected(false);
aViewFrame->updateObject(o);
}
- }
+ }
+ if( myDeselectAnalytical ) {
+ aViewFrame->deselectAnalyticalCurves();
+ aViewFrame->updateAnalyticalCurves();
+ }
aViewFrame->Repaint();
}
}
signals:
void legendSelected( const QString& );
+ void clearSelected();
+private:
+ bool myDeselectAnalytical;
};