1 /********************************************************************************
2 *                                                                               *
3 *                      P l o t - C u r v e   D e s c r i p t i o n              *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 2007,2021 by Jeroen van der Zijp.   All Rights Reserved.        *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify          *
9 * it under the terms of the GNU Lesser General Public License as published by   *
10 * the Free Software Foundation; either version 3 of the License, or             *
11 * (at your option) any later version.                                           *
12 *                                                                               *
13 * This library is distributed in the hope that it will be useful,               *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
16 * GNU Lesser General Public License for more details.                           *
17 *                                                                               *
18 * You should have received a copy of the GNU Lesser General Public License      *
19 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
20 ********************************************************************************/
21 #include "fx.h"
22 #include "chartdefs.h"
23 #include "chartutils.h"
24 #include "FXChart.h"
25 #include "FXCurve.h"
26 #include "FX2DChart.h"
27 #include "FX2DPlot.h"
28 
29 /*
30   Notes:
31 */
32 
33 
34 using namespace FXCHART;
35 
36 /*******************************************************************************/
37 
38 namespace FXCHART {
39 
40 // Object implementation
41 FXIMPLEMENT(FXCurve,FXObject,NULL,0)
42 
43 
44 class FXData {
45   };
46 
47 
48 // Deserialization
FXCurve()49 FXCurve::FXCurve():plot(NULL),xdata(NULL),ydata(NULL),xaxis(0),yaxis(0){
50   }
51 
52 
53 // Init
FXCurve(FX2DPlot * plt,const FXString & nm)54 FXCurve::FXCurve(FX2DPlot* plt,const FXString& nm):plot(plt),xdata(NULL),ydata(NULL),label(nm),xaxis(0),yaxis(0){
55   }
56 
57 
58 // Sets the curve name
setLabel(const FXString & nm)59 void FXCurve::setLabel(const FXString& nm){
60   if(label!=nm){
61     label=nm;
62     plot->update();
63     }
64   }
65 
66 
67 // Change x axis description
setXAxis(FXuchar ax)68 void FXCurve::setXAxis(FXuchar ax){
69   if(xaxis!=ax){
70     xaxis=ax;
71     plot->update();
72     }
73   }
74 
75 
76 // Change y axis description
setYAxis(FXuchar ax)77 void FXCurve::setYAxis(FXuchar ax){
78   if(yaxis!=ax){
79     yaxis=ax;
80     plot->update();
81     }
82   }
83 
84 
85 // Change x data samples
setXData(FXData * dd)86 void FXCurve::setXData(FXData* dd){
87   if(xdata!=dd){
88     xdata=dd;
89     plot->update();
90     }
91   }
92 
93 // Change y data samples
setYData(FXData * dd)94 void FXCurve::setYData(FXData* dd){
95   if(ydata!=dd){
96     ydata=dd;
97     plot->update();
98     }
99   }
100 
101 
102 // Save data
save(FXStream & store) const103 void FXCurve::save(FXStream& store) const {
104   FXObject::save(store);
105   store << label;
106   store << xaxis;
107   store << yaxis;
108   }
109 
110 
111 // Load data
load(FXStream & store)112 void FXCurve::load(FXStream& store){
113   FXObject::load(store);
114   store >> label;
115   store >> xaxis;
116   store >> yaxis;
117   }
118 
119 
120 // Destroy
~FXCurve()121 FXCurve::~FXCurve(){
122   delete xdata;
123   delete ydata;
124   plot=(FX2DPlot*)-1L;
125   xdata=(FXData*)-1L;
126   ydata=(FXData*)-1L;
127   }
128 
129 }
130