| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeGraph.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00027 #ifndef __TERRALIB_INTERNAL_GRAPH_H
    00028 #define __TERRALIB_INTERNAL_GRAPH_H
    00029
    00030 #include "TeLegendEntry.h"
    00031 #define CURVES_MAX   10
    00032 #define AXIS_MAX     64
    00033 #define TITLE_MAX    64
    00034 #define LABEL_MAX    64
    00035
    00036 #define XY_ASCII   0
    00037 #define XY_BINARY  1
    00038 #define XYY_ASCII  2
    00039 #define XYY_BINARY 3
    00040 #define PIE_BINARY 4
    00041 #define BAR_BINARY 5
    00042 #define ROSE_BINARY 6
    00043 #define POINT_BINARY 7
    00044
    00045 #define Real double
    00046 typedef Real* Real_Vector;
    00047 typedef struct {
    00048            char title[TITLE_MAX+1];
    00049            char xaxis[AXIS_MAX+1];
    00050            char yaxis[AXIS_MAX+1];
    00051            char curve[CURVES_MAX][LABEL_MAX+1];
    00052 } Labels;
    00053
    00054 class TL_DLL TeGraphPlot
    00055 {
    00056 protected:
    00057            int label_field;       /* maximum no. of characters in a label field */
    00058            int major_tick;        /* length of major tick mark (in pixels) */
    00059            int minor_tick;        /* length of minor tick mark (in pixels) */
    00060            int x_major;           /* number of x axis divisions */
    00061            int y_major;           /* number of y axis divisions */
    00062            int x_minor;           /* number of x axis subdivisions */
    00063            int y_minor;           /* number of y axis subdivisions */
    00064            Real xminval;          /* minimum value on x axis */
    00065            Real xmaxval;          /* maximum value on x axis */
    00066            Real yminval;          /* minimum value on y axis */
    00067            Real ymaxval;          /* maximum value on y axis */
    00068            int xupleft;           /* x pixel coordinate (upper left) */
    00069            int yupleft;           /* y pixel coordinate (upper left) */
    00070            int width;             /* width of axes (in pixels) */
    00071            int height;            /* height of axes (in pixels) */
    00072            int label_width;       /* width of label character */
    00073            int label_height;      /* height of label character */
    00074            int label_font;        /* font number to use for labels */
    00075            int title_width;       /* width of title characters */
    00076            int title_height;      /* height of title characters */
    00077            int title_font;        /* font number to use for title */
    00078            int xaxis_width;       /* width of x axis characters */
    00079            int xaxis_height;      /* height of x axis characters */
    00080            int xaxis_font;        /* font number to use for x axis */
    00081            int yaxis_width;       /* width of y axis characters */
    00082            int yaxis_height;      /* height of y axis characters */
    00083            int yaxis_font;        /* font number to use for y axis */
    00084            int yaxis_direct;      /* direction of y axis characters */
    00085            int X_pixels;          /* number of pixels in horizontal direction */
    00086            int Y_pixels;          /* number of pixels in vertical direction */
    00087            int Xaxis_y;           /* y pixel coordinate of X axis title */
    00088            int Yaxis_x;           /* x pixel coordinate of Y axis title */
    00089            int Title_y;           /* y pixel coordinate of main title */
    00090
    00091
    00092            int Plot_curves;       /* number of curves */
    00093            int Plot_symbols;      /* maximum number of symbols on curve */
    00094            int Curve_choice;      /* number of selected curve */
    00095            int Plot_choice;       /* graphics menu item choice */
    00096            int Plot_points[CURVES_MAX];    /* number of points in each curve */
    00097            Real_Vector Plot_x[CURVES_MAX]; /* X data points for each curve */
    00098            Real_Vector Plot_y[CURVES_MAX]; /* Y data points for each curve */
    00099            Labels Plot_label;              /* labels for title, axes, and curves */
    00100
    00101            int Scale_curve;           /* number of curve to scale (-1 for all) */
    00102            int Scale_factor;          /* used to scale Y axis for printing */
    00103            int Output_format;         /* output format for xywrite */
    00104            int Input_format[CURVES_MAX];          /* format of file loaded */
    00105            char Data_filename[13];    /* name of last file loaded */
    00106            TeLegendEntryVector* sliceVector;/* vector of TeLegendEntry */
    00107            TeColor GPpcor;                                /*piechart color */
    00108            char *GPpieleg;
    00109            int GPpointwidth, GPpointheight;
    00110
    00111 // Private members
    00112
    00113            void       draw_plot(void);
    00114            void       draw_symbols(int curve);
    00115            void       plot_axes(void);
    00116            void       plot_ticks(void);
    00117            void       plot_grid(void);
    00118            int                   plot_labels(void);
    00119            int                   plot_title(char *text);
    00120            int                   plot_xaxis(char *text);
    00121            int                   plot_yaxis(char *text);
    00122            int     point_visible(Real x, Real y);
    00123            void    value_to_pixel(Real x_value, Real y_value, int *x_pixel, int *y_pixel);
    00124            int     plot_curve(Real_Vector x, Real_Vector y, int points, TeColor c);
    00125            void    label_format(Real values[], int nvalues, int field_width, int *digits_left, int *digits_right, int *exp_flag);
    00126            void       plot_horiz(char *text, int y, int width);
    00127            int     plot_point(Real x_value, Real y_value, int pen_status);
    00128            void    find_intersect(Real x_in, Real y_in, Real *x_out, Real *y_out);
    00129            void    draw_symbol(int x, int y, int symbol, int width, int height);
    00130            void    draw_symbol_legend(int x, int y, int symbol, int width, int height);
    00131            void    get_plot_fonts();
    00132            int                   get_font_size(int font_number, int *width, int *height);
    00133
    00134            virtual int           getWidth () = 0;
    00135            virtual int           getHeight () = 0;
    00136            virtual void          setLineAttributes(TeColor c, int , int ) = 0;
    00137            virtual void          setFillAreaColor (TeColor c) = 0;
    00138            virtual void          setTextColor (TeColor c) = 0;
    00139            virtual void          fillRectangle (int x, int y, int dx, int dy) = 0;
    00140            virtual void          drawRectangle (int x, int y, int dx, int dy) = 0;
    00141            virtual void          drawLine (int sx, int sy, int dx, int dy) = 0;
    00142            virtual void          drawText (int x, int y, char* str, double angle = 0.) = 0;
    00143            virtual void          fillArc (int xc, int yc, int w, int h, double a1, double a2, TeColor c) = 0;
    00144            virtual void          drawArc (int xc, int yc, int w, int h, double a1, double a2, TeColor c) = 0;
    00145            virtual void          textExtent ( string &str, int &w, int &h, double angle = 0.) = 0;
    00146
    00147 // Public members
    00148
    00149 public :
    00150            TeGraphPlot ();
    00151            virtual ~TeGraphPlot ();
    00152            int                   loadDirect ( int format, int curv, int points, Labels& labels, Real_Vector x, Real_Vector y);
    00153            void       loadHistogram (TeLegendEntryVector& sv, const string& label);
    00154            void       loadPie (TeLegendEntryVector& sv, const string& label);
    00155            void       plotInit( int , int , int , int );
    00156            void       autoScale( void);
    00157            void       setScale( Real x1, Real x2 , Real y1, Real y2);
    00158            int                   kill( int order);
    00159            int                   plotSymbol( Real x_value, Real y_value,int symbol, int width, int height, int curve=0);
    00160            void       plotCurves (int with_simbols = 0);
    00161            void       pixelToValue( int x_p, int y_p, Real& x_v, Real& y_v);
    00162            void       reset();
    00163            void    setColorGrid( int , int , int );
    00164            void    setColorText( int , int , int );
    00165            void    setColorLine( int , int , int );
    00166            int                   setColorCurve( int ,int , int , int );
    00167            void    setColorSymbol( int , int, int, int=-1, int=7, int=7); // r, g, b, curve, width, height
    00168            void    setSymbolType( int, int=0); // type , curve
    00169            void       drawLegend( void);
    00170            int                   setGridSize( int );
    00171            int                   setGridSize( int, int, int, int );
    00172            void       drawMoranText (double x1, double y1, double x2, double y2);
    00173
    00174            void       pieLegends ();
    00175 };
    00176
    00177 // Utility functions
    00178
    00179 TL_DLL void show_err(char const *s);
    00180 TL_DLL void ftos(Real f, int digits_left, int digits_right, int exp_flag, char *s);
    00181
    00182 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines