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

Draw2D.h

Go to the documentation of this file.
00001 //     $Id: Draw2D.h,v 1.1.1.1 2001/01/04 01:01:11 burnett Exp $
00002 //  Author: Toby Burnett
00003 //
00004 //
00005 #ifndef DRAW2D_H
00006 #define DRAW2D_H
00007 
00008 namespace gui {
00009 
00010 class Draw2D {
00011 
00012 // Abstract base class for 2-dimensional event and detector plotting
00013 // Functions as a canvas
00014 public:
00015  
00016     virtual ~Draw2D(){};
00017     // destructor;
00018   
00019 
00020 //--------------these methods must be defined by derived class-----
00021 
00022     virtual void draw_string(float x, float y, const char *, int=0)=0;
00023     // draw a string at given coords
00024 
00025     virtual void draw_string(const char*, int=0)=0;
00026     // draw a character string at current point
00027 
00028     virtual void move_to(float, float)=0;
00029     virtual void line_to(float, float)=0;
00030     // move or draw line from current point to specified one
00031 
00032     virtual void draw_marker(float,float)=0;
00033     // draw a marker (cross) at the point
00034 
00035     virtual void set_quad(int quad=0, const char * title = 0, int selected=0)=0;
00036     // define and clear viewport quadrant, optionally draw title and box
00037     // quad 0 means whole display area, 1-4 are respective quadrants of display
00038     // the drawer is expected to clip to the defined region
00039 
00040     enum Shading { NONE, BRIGHT, MEDIUM, DARK };
00041     virtual void fill_polygon(const float* xy, int npoints, Shading pattern);
00042     // draw and close the polygon, and fill it according to the shading. Implement below
00043     // as a simple draw
00044 
00045     //------------- following optionally implemented---------------------
00046     virtual void set_enhanced(int){};
00047     // turn on/off (device-dependent) enhancement attribute
00048 
00049     virtual void new_path(){}
00050     virtual void close_path(){}
00051     virtual void stroke() {}
00052     virtual void fill() {}
00053     // to set a newpath and stroke
00054 
00055     virtual void set_defaults(){};
00056     // set all attributes to default values
00057 
00058     virtual void flush(){};
00059     // flush the accumulated drawing commands
00060 
00061 
00062     virtual void set_line_width(float){};
00063     // set the line width
00064 
00065     virtual void set_col_index(int){};
00066     // set the color Index
00067 
00068     virtual void set_rgb(float,float,float){};
00069     virtual void set_line_style(int){};
00070 
00071     virtual void set_marker_size(float){};
00072     // change the current marker size
00073 
00074     virtual void set_cap_style(int){};
00075 
00076 
00077 protected:
00078 
00079     Draw2D(){};
00080     // constructor is projected, since abstract class
00081 
00082 
00083 private:
00084 
00085 };
00086 // define the default polygon, with no shading
00087 inline void Draw2D::fill_polygon(const float* xy, int npoints, Draw2D::Shading )
00088 {
00089     float x1 = *xy++, y1=*xy++;
00090     move_to(x1,y1);
00091     for(int i = 2; i<npoints; i+=2){
00092         float x = *xy++, y = *xy++; 
00093         line_to(x,y);
00094     }
00095     move_to(x1,y1);
00096 }
00097 
00098 } // namespace gui
00099 #endif
00100 

Generated at Mon Nov 26 18:18:10 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000