1 // Copyright (C) 2010-2024 CEA, EDF
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Adrien BRUNETON
22 #ifndef SRC_CPP_CURVEPLOT_HXX_
23 #define SRC_CPP_CURVEPLOT_HXX_
26 # if defined CURVEPLOT_EXPORTS || defined CurvePlot_EXPORTS
27 # define CURVEPLOT_EXPORT __declspec(dllexport)
29 # define CURVEPLOT_EXPORT __declspec(dllimport)
32 # define CURVEPLOT_EXPORT
44 * This function should be called before doing anything in the CURVEPLOT namespace.
46 CURVEPLOT_EXPORT void* InitializeCurvePlot();
48 class CURVEPLOT_EXPORT ColumnVector
51 friend class CurvePlot;
53 virtual ~ColumnVector();
56 * Build a ColumnVector from a std::vector() of double. The memory is copied for now (TODO: optimize this).
58 static ColumnVector BuildFromStdVector(const std::vector<double> & vec);
61 * Build a ColumnVector from a block of memory which was malloc'ed.
62 * The memory is not copied, and the array thus created becomes responsible of the block.
63 * So do NOT free the memory that you pass.
65 static ColumnVector BuildFromCMemory(double * data, int size);
68 * Get the current size of the vector.
72 /** Get a string representation */
73 std::string toStdString() const;
79 void createPythonVar(std::string varName) const;
80 void cleanPythonVar(std::string varName) const;
87 * C++ wrapping of the public API exposed in the Python package curveplot. See doc there.
89 class CURVEPLOT_EXPORT CurvePlot
92 static PlotID AddCurve(const ColumnVector & x, const ColumnVector & y,
94 std::string curve_label="", std::string x_label="", std::string y_label="",
97 static PlotID AddPlotSet(std::string title="");
99 static PlotID DeleteCurve(PlotID curve_id=-1);
101 static PlotID DeletePlotSet(PlotID plot_set_id=-1);
103 static PlotID ClearPlotSet(PlotID plot_set_id=-1);
105 static bool SetXLabel(std::string x_label, PlotID plot_set_id=-1);
107 static bool SetYLabel(std::string y_label, PlotID plot_set_id=-1);
109 static bool SetPlotSetTitle(std::string title, PlotID plot_set_id=-1);
111 static PlotID GetPlotSetID(PlotID curve_id);
113 static PlotID GetPlotSetIDByName(std::string name);
115 static PlotID GetCurrentCurveID();
117 static PlotID GetCurrentPlotSetID();
119 static void ToggleCurveBrowser(bool with_curve_browser);
121 static bool IsValidPlotSetID(PlotID plot_set_id=-1);
123 static int GetSalomeViewID(PlotID plot_set_id);
125 static CurvePlot * GetInstance(bool test_mode=false);
127 /**! Temporary ... */
128 static void OnSalomeViewTryClose(int salome_view_id);
135 static CurvePlot * _instance;
137 CurvePlot(bool testMode);
138 virtual ~CurvePlot();
144 #endif /* SRC_CPP_CURVEPLOT_HXX_ */