00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __FXPLOT2D_H
00023 #define __FXPLOT2D_H
00024
00025 #include "FXPlotBase.h"
00026 #include "FXCurve.h"
00027 #include "FXAxis.h"
00028
00029 #include <vector>
00030
00031
00032 class FXAxis;
00033
00035 struct FXDoubleRect {
00036 public:
00038 double xmin;
00040 double xmax;
00042 double ymin;
00044 double ymax;
00045
00047 FXDoubleRect(double xmin = 0, double xmax = 0, double ymin = 0, double ymax = 0){
00048 this->xmin = xmin;
00049 this->ymin = ymin;
00050 this->xmax = xmax;
00051 this->ymax = ymax;
00052 }
00053 };
00054
00068 class FXPlot2D : public FXPlotBase
00069 {
00070 FXDECLARE(FXPlot2D)
00071 protected:
00072
00073 FXPlot2D(){}
00074
00076 enum Modes {
00077 ZoomInMode = 0x0001,
00078 ZoomOutMode = 0x0002,
00079 ZoomMask = 0x000f,
00080
00081 LegendShown = 0x0010,
00082 LegendMoving = 0x0020,
00083 LegendMask = 0x00f0,
00084
00085 GridShown = 0x0100,
00086 };
00087
00089 std::vector<FXCurve*> curves;
00090
00092 FXCurve* selCurve;
00093
00095 FXPlotPen auxW;
00096
00097
00098 bool _bgRepaint;
00099 FXRectangle legendRect,legendRect2;
00100
00102 FXFont *legendFont;
00103
00105 FXint flags;
00106
00108 FXPoint zoominit;
00110 FXPoint zoomfinal;
00111
00112
00113 FXMenuPane *mainmenu, *curvesmenu;
00114
00116 FXCursor *zoomin;
00118 FXCursor *zoomout;
00119
00121 FXAxis *axisx[2];
00123 FXAxis *axisy[2];
00124
00130 void updateCurves(void);
00131
00133 void drawPlot(FXDC *dc, FXint rootx, FXint rooty);
00135 void drawLegend(FXDC *dc, FXint rootx, FXint rooty);
00137 void drawGrid(FXDC *dc, FXint rootx, FXint rooty);
00139 void drawAuxWindows(FXDC *dc, FXint rootx, FXint rooty);
00141 void updateCursor(FXEvent* event);
00143 void setRanges(const FXDoubleRect &rect);
00144
00146 void newFactor();
00147
00149 static void putRectangleInside(FXRectangle &outer, FXRectangle &r);
00150 public:
00154 FXRectangle plotRect;
00155
00157 FXPlot2D(FXComposite *parent, FXString name);
00158
00160 ~FXPlot2D();
00161
00163 void setRangesShowAll(void);
00164
00170 FXCurve* addCurve(const FXString &label, FXCurveData *x, FXCurveData *y,
00171 FXCurve::CurveStyle style = FXCurve::Lines);
00172
00180 void addCurve(FXCurve *FXCurve);
00181
00185 void removeCurve(FXCurve *FXCurve, FXbool del = TRUE);
00186
00190 void removeAllCurves();
00191
00193 void setRanges(double xmin,double xmax,double ymin,double ymax);
00194
00196 void setLegend(FXbool on = TRUE){
00197 if(on) flags |= LegendShown;
00198 else flags |= ~LegendShown;
00199 }
00200
00202 void setGrid(FXbool on = TRUE){
00203 if(on) flags |= GridShown;
00204 else flags |= ~GridShown;
00205 }
00206
00208 void drawSelf(FXDC *dc, FXint rootx, FXint rooty);
00209
00210
00211 void create(void);
00212 void layout(void);
00213 void recalc(void);
00214
00215
00216 long onZoomOut(FXObject *obj,FXSelector sel,void* ptr);
00217 long onShowAll(FXObject*,FXSelector,void* ptr);
00218 long onProperties(FXObject *obj,FXSelector sel,void* ptr);
00219 long onCmdToogleGrid(FXObject *obj,FXSelector sel,void* ptr);
00220 long onCmdToogleLegend(FXObject *obj,FXSelector sel,void* ptr);
00221
00222 long onLeftBtnPress(FXObject*,FXSelector,void* ptr);
00223 long onLeftBtnRelease(FXObject*,FXSelector,void* ptr);
00224 long onMotion(FXObject*,FXSelector,void* ptr);
00225 long onRightBtnPress(FXObject*,FXSelector,void* ptr);
00226 long onKeyPress(FXObject*,FXSelector,void* ptr);
00227 long onKeyRelease(FXObject*,FXSelector,void* ptr);
00228 long onFocusOut(FXObject*,FXSelector,void* ptr);
00229
00231 std::vector<FXCurve*>::iterator curveBegin(void);
00233 std::vector<FXCurve*>::iterator curveEnd(void);
00234
00236 FXAxis* getBottomAxis(){
00237 return axisx[0];
00238 }
00240 FXAxis* getTopAxis(){
00241 return axisx[1];
00242 }
00244 FXAxis* getLeftAxis(){
00245 return axisy[0];
00246 }
00248 FXAxis* getRightAxis(){
00249 return axisy[1];
00250 }
00251
00252
00253 enum Commands {
00254 ID_FIRST = FXPlotBase::ID_LAST,
00255 ID_ZOOM_OUT,
00256 ID_SHOW_ALL,
00257 ID_GRID,
00258 ID_LEGEND,
00259 ID_SAVE,
00260 ID_PROPERTIES,
00261 ID_LAST
00262 };
00263
00264 };
00265
00266 #endif // __FXPLOT2D_H
00267
00268
00269
00270