Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

sxy_graph.h

Go to the documentation of this file.
00001 #ifndef graph_h
00002 #define graph_h
00003 
00004 // =======================================================================
00005 
00006 extern "C" {
00007 #include <iup.h>
00008 #include <cd.h>
00009 }
00010 
00011 #include "sxy_vector.h"
00012 #include "sxy_axis.h"
00013 #include "sxy_task.h"
00014 
00015 class SXYChart;
00016 
00017 // =======================================================================
00018 
00019 typedef enum {
00020    WITH_DOUBLE_BUFFER = 0,
00021    WITHOUT_DOUBLE_BUFFER
00022 } SXYGraphDoubleBufferMode;
00023 
00024 typedef enum {
00025    ALL_X = 0,
00026    ALL_Y,
00027    INDIVIDUAL_X,
00028    INDIVIDUAL_Y,
00029 } SXYGraphFitOption;
00030 
00031 // =======================================================================
00032 //
00033 //* Define um gráfico genérico
00034 class SXYGraph {
00035 
00036   void fitAllAxis(SXYAxisOrientation orientation);
00037 
00040   SXYVector<SXYChart*> *charts_vector;
00041 
00043   SXYVector<SXYTask*> *tasks_vector;
00044 
00046   cdCanvas* cd_canvas;
00047 
00049   Ihandle*  iup_canvas;
00050 
00051   // ....................................................................
00052 
00053   /* Métodos estáticos utilitários privados da classe */
00054   static SXYGraph* getThis(Ihandle* handle);
00055   void drawChartsAt( cdCanvas* cnv, SXYGraphDoubleBufferMode mode );
00056 
00057   /* Métodos utilitários da classe */
00058   void deleteGraphDatas(void);
00059 
00060   /* Callbacks nativas para o canvas IUP */
00061   static int iupActionCallback(Ihandle* h);
00062   static int iupResizeCallback(Ihandle* h, int width, int height);
00063   static int iupEnterCallback(Ihandle* h);
00064   static int iupLeaveCallback(Ihandle* h);
00065   static int iupMotionCallback(Ihandle* h, int x, int y, char *r);
00066   static int iupButtonCallback(Ihandle* h, int b, int e, int x, int y, char *r);
00067 
00068 
00069  protected:
00070 
00071   /* Callbacks chamadas quando do surgimento de eventos de mouse */
00072   virtual void mouseClick(int b, int x, int y, int sft, int ctr) {};
00073   virtual void mouseUnclick(int b, int x, int y, int sft, int ctr) {};
00074   virtual void mouseMotion(int x, int y, int sft, int ctr) {};
00075   virtual void mouseEnter(void) {};
00076   virtual void mouseLeave(void) {};
00077 
00078  public:
00079 
00080   /* Métodos de manipulação dos charts associados */
00081   SXYChart* getChart(int i);
00082   int getNumCharts(void);
00083   void insertChart(SXYChart* cht);
00084   void removeChart(SXYChart* cht);
00085 
00086   /* Métodos de manipulação das tarefas associadas */
00087   void setStandartTasks(void);
00088   SXYTask* getTask(int i);
00089   int getNumTasks(void);
00090   void insertTask(SXYTask* tsk);
00091   void removeTask(SXYTask* tsk);
00092 
00093   /* Consulta a dados de evento no canvas */
00094   int getChartOfEvent(int x, int y);
00095 
00096   /* Funções de consulta e manipulação dos dados IUP/CD */
00097   int       getDeviceSizeMM(double& w, double& h);
00098   cdCanvas* getCdCanvas(void);
00099   Ihandle*  getIupCanvas(void);
00100   void      activateDisplayCanvas(void);
00101 
00102   /* Métodos de manipulação de características comuns aos gráficos */
00103   void setZoom(double xratio, double yratio);
00104   void fitScales(SXYGraphFitOption opt);
00105 
00106   /* Métodos de redesenho, impressão e cópia para o clipboard */
00107   void redrawGraph(void);
00108   void printGraph(int ask, char* ps_cmd);
00109   void copyGraph(int width, int height);
00110 
00111   /* Métodos de remontagem e atualização de gráficos */
00112   virtual void remountGraph(void) = 0;
00113   virtual void updateGraph(void) {};
00114 
00115   /* Auxílio ao ajuste do grid */
00116   void tryGridAdjust();
00117 
00118 
00119   /* Construtores e destrutores */
00120   SXYGraph(Ihandle* iupcnv);
00121   virtual ~SXYGraph();
00122 };
00123 
00124 // =======================================================================
00125 
00126 #endif
00127 

SXY
Tecgraf / PUC-Rio - Computer Graphics Technology Group