Main Page | Class Hierarchy | Class List | Directories | File List | Class Members

FXPlot2D.h

00001 /*******************************************************************************
00002 * Copyright (C) 2003-2005 by Rafael de Pelegrini Soares.   All Rights Reserved.
00003 ********************************************************************************
00004 * This library is free software; you can redistribute it and/or
00005 * modify it under the terms of the GNU Lesser General Public
00006 * License as published by the Free Software Foundation; either
00007 * version 2.1 of the License, or (at your option) any later version.
00008 *
00009 * This library is distributed in the hope that it will be useful,
00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00012 * Lesser General Public License for more details.
00013 *
00014 * You should have received a copy of the GNU Lesser General Public
00015 * License along with this library; if not, write to the Free Software
00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
00017 ********************************************************************************
00018 * $Id: FXPlot2D.h,v 1.3 2006/01/12 17:57:08 rpseng Exp $
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 //forward declaration
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         // FOX protected default constructor.
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         //legend data
00098         bool _bgRepaint;
00099         FXRectangle legendRect,legendRect2; // área onde está a legenda
00100         
00102         FXFont *legendFont;
00103 
00105         FXint flags;
00106 
00108         FXPoint zoominit;
00110         FXPoint zoomfinal;
00111 
00112         //Menus
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         // fox stuff
00211         void create(void);
00212         void layout(void);
00213         void recalc(void);
00214 
00215         // fox commands
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         // FOX IDs
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 

Generated on Tue Jan 31 10:55:30 2006 for FXPlot by  doxygen 1.4.4