Main Page | Namespace List | Class Hierarchy | Data Structures | File List | Data Fields | Globals

zoomablesurfaceview.h

Go to the documentation of this file.
00001 //--- < ZOOMABLESURFACEVIEW.H > -| ViewGraph - A Flexible Graph view Framework |
00002 //
00003 // This class implements a viewport, handles zooming
00004 // and scrolling. Redirects drawing calls to
00005 // SurfaceDriver, shifting and magnifying the
00006 // parameters.
00007 //
00008 // Use this class when magnification is 
00009 // straightforward (objects are not 
00010 // magnification-aware). Otherwise, see the
00011 // ZoomableObjectView class.
00012 //
00013 // $Author: botik32 $
00014 // $Revision: 1.7 $
00015 // $Date: 2004/05/19 16:40:36 $
00016 //-----------------------------------------------------------------------------/
00017 
00018 #ifndef ZOOMABLESURFACEVIEW_H
00019 #define ZOOMABLESURFACEVIEW_H
00020 
00021 #include <cZUI/zoomableview.h>
00022 
00023 class ZoomableSurfaceView : public ZoomableView{
00024 protected:
00025         /// this value is used in determining how much the graphics
00026         /// should be scaled
00027         double object_magnification;
00028         /// View's absolute magnification
00029         double view_magnification;
00030         /// View's inverse of absolute magnification
00031         double thickness1;
00032         inline double scene2screenx( double p )
00033         {
00034                 p -= posx; p *= view_magnification;
00035                 p += screenx; return p;
00036         };
00037         inline double scene2screeny( double p )
00038         {
00039                 p -= posy; p *= view_magnification;
00040                 p += screeny; return p;
00041         };
00042         inline double screen2scenex( double p )
00043         {
00044                 p -= screenx; p /= view_magnification;
00045                 p += posx; return p;
00046         };
00047         inline double screen2sceney( double p )
00048         {
00049                 p -= screeny; p /= view_magnification;
00050                 p += posy; return p;
00051         };
00052 
00053 public:
00054         void pen( unsigned char r, unsigned char g,
00055                 unsigned char b, double thickness );
00056         void get_pen( unsigned char& r, unsigned char& g, 
00057                 unsigned char& b, double& thickness );
00058         void clear_rect( double, double, double, double );
00059         void repaint_rect( double, double, double, double );
00060         void get_rect( double&, double&, double&, double& );
00061         void line( double x1, double y1, double x2, double y2 );
00062         void rectangle( double x1, double y1, double x2, double y2 );
00063         void dot( double x1, double y1 );
00064         void circle( double x1, double y1, double radius );
00065         void arc( double x1, double y1, double radius,
00066                 double an1, double an2 );
00067         void bezier( double x1, double y1, double x2, double y2, 
00068                                  double x3, double y3 );
00069         virtual void fill_h_triangle( double x1, double y1, 
00070                                  double x2, double y2, double x3 );
00071         virtual void fill_v_triangle( double x1, double y1, 
00072                                  double x2, double y2, double y3 );
00073         virtual void fillrect( double x1, double y1, double x2, double y2,
00074                 unsigned char fr, unsigned char fg, unsigned char fb );
00075 
00076         void textout( double x1, double y1, const char *text );
00077         void textrect( double x1, double y1,
00078                     double x2, double y2, const char *text );
00079         void setfontsize( double );
00080 
00081         /// use this function to tell the view that the object is initially
00082         /// visible at magnification m and thus should be resized accordingly.
00083         void set_object_magnification( double );        
00084         
00085         double zoom( double factor );
00086         double get_zoom( void );
00087         double get_thickness1( void );
00088 
00089         void center( double, double );
00090         void scroll( double, double );
00091 
00092         /// This function is used when deciding scenenode visibility
00093         /// (including for paint events)
00094         bool rectfits( double, double, double, double );
00095 
00096         void get_scenemousepos( double&, double& );
00097         ZoomableSurfaceView( SurfaceDriver *, int x, int y, 
00098                                                         int w, int h,
00099                 unsigned char pbkgr, 
00100                 unsigned char pbkgg,
00101                 unsigned char pbkgb );
00102 
00103         // scale the image before placing
00104         void put_image( Image *, int destx, int desty,
00105                 double imgzoom = 1. );
00106 
00107 };
00108 
00109 
00110 #endif
00111 
00112 /// $Log: zoomablesurfaceview.h,v $
00113 /// Revision 1.7  2004/05/19 16:40:36  botik32
00114 /// Bugfixes and enhancements:
00115 /// Added repaint_due() and brepaint_due to ScrollableView
00116 /// Fixed repaint decisions in GraphWindow to work for multiple-window
00117 /// scenes
00118 /// Fixed ScrollableView to call surfacedriver->clear() in constructor
00119 /// Changed mapchooser to use a smaller resolution world map
00120 ///
00121 /// Revision 1.6  2004/05/03 21:02:01  botik32
00122 /// Significant changes and many bugfixes.
00123 /// ScrollableView now has a background color used to
00124 /// tell SurfaceDriver to clear with.
00125 /// SurfaceDriver's clear() requires a color now
00126 /// Added SceneEvents for all node additions/removals
00127 /// in GroupNode and Camera.
00128 /// Added paint_selected and paint_selected_invalid
00129 /// to ActiveLeaf
00130 /// Modified ActiveLeaf's mouse_down and mouse_up
00131 /// handler signatures to accept an Event* instead of
00132 /// Camera*
00133 /// - Many more bugfixes
00134 ///
00135 /// Revision 1.5  2004/04/29 09:50:48  botik32
00136 /// Fixed the zoomablesurfaceview's put_image to work
00137 /// correctly with zooms.
00138 /// Moved convert_image_to16() from SurfaceDriver to Image. It
00139 /// is now called convert_to_565()
00140 /// Fixed bug in rgb24.cpp including rgb24.h in the wrong location
00141 /// Finished code zoom in ZoomableSurfaceView, not tested
00142 ///
00143 /// Revision 1.4  2004/04/15 10:31:29  botik32
00144 /// Interface change: added arc() function to surfacedriver.
00145 ///
00146 /// Revision 1.3  2004/04/10 06:57:20  botik32
00147 /// zoomablesurfaceview.h: Removed typo causing compiler
00148 /// error on multiple include
00149 ///
00150 /// Revision 1.2  2004/04/09 17:15:08  botik32
00151 /// Changes in interface: added get_pen to scrollableview and
00152 /// surfacedriver
00153 ///
00154 /// Revision 1.1.1.1  2004/03/26 10:50:26  botik32
00155 /// Initial release
00156 ///
00157 /// Revision 1.1.1.1  2004/03/26 08:53:33  botik
00158 /// initial import
00159 ///
00160 ///
00161 /// Revision 1.17  2004/01/03 19:59:41  botik
00162 /// added text support via aedGUI
00163 ///
00164 /// Revision 1.16  2003/11/25 13:01:03  botik
00165 /// Changed the flawed way scene node's requests were
00166 /// handled in ZoomableSurfaceView. This fixes a bad bug
00167 /// with HUD nodes moving all over the place.
00168 /// Added CameraZoomedMessage and CameraScrolledMessage
00169 /// Replaced the TranslateNodeMEssage with
00170 /// CameraScrolledMessage in HUDGroupNode. This fixed
00171 /// a HUD flicker bug.
00172 /// Simplified repaint and clear handling in GraphWindow.
00173 /// This fixed a few bugs in repainting.
00174 /// Added rect bounds checking in ScrollableView's
00175 /// clear_rect and repaint_rect. This fixed cameras to only
00176 /// clear their rectangle even if the view holds a larger
00177 /// area.
00178 /// Changed ActiveLeaf to use default paint function if
00179 /// the payload of CameraRepaintLeafMessage is empty. This
00180 /// will allow repaints of moved nodes.
00181 /// Changed LayerNode to allow CameraMovement events even
00182 /// if the layer is inactive. This will update existing HUD
00183 /// controls' position on inactive layers so they do not move
00184 /// astray during scrolls.
00185 /// This is an intermediate change; mouseover checks do not work.
00186 ///
00187 /// Revision 1.15  2003/11/24 20:45:29  botik
00188 /// Merged four features from surfacecamera into camera.
00189 /// Modified ScrollableView to hold a width/height of
00190 /// the viewport and to report it to whoever asks.
00191 /// Added scenex, sceney fields to Event.
00192 /// Added coordinate transform for all messages, done
00193 /// at camera level. This should speed up drawability
00194 /// and mouseover checks.
00195 ///
00196 /// Repaint and mouse detection work now over arbitrary
00197 /// magnification.
00198 /// Borderlayer is broken and scrolling segfaults in
00199 /// a weird way.
00200 ///
00201 /// Revision 1.14  2003/11/24 16:12:10  botik
00202 /// Halfway through major redesign of a view's geometric
00203 /// parameters. This will influence zooming and repainting.
00204 ///
00205 /// Revision 1.13  2003/11/20 00:32:41  botik
00206 /// Changed the way repaint works by using a screen
00207 /// rectangle as intermediate event.
00208 /// Added get_screenrect to Camera
00209 /// Added screen2scenerect to Camera
00210 ///
00211 /// Revision 1.12  2003/11/18 17:47:20  botik
00212 /// Added triangle fill function to surface driver
00213 /// and views
00214 ///
00215 /// Revision 1.11  2003/11/18 13:54:06  botik
00216 /// Got the borderlayer to scroll well.
00217 ///
00218 /// Revision 1.10  2003/11/17 18:39:37  botik
00219 /// Added rectangle to surface driver.
00220 /// Sdxpsdl line and rectangle bugfixes
00221 ///
00222 /// Revision 1.9  2003/11/17 13:46:34  botik
00223 /// Removed default cursor from scrollableview
00224 /// Changed message handling behaviour for GroupNode
00225 ///     to recognize broadcast messages
00226 /// Changed message handling behaviour for BaseSceneNode
00227 ///     to recognize broadcast messages
00228 /// Added NodeTranslateMessage to message module
00229 /// Added handling of NodeTranslateMessage for LeafNode
00230 ///
00231 /// Revision 1.8  2003/11/15 16:45:18  botik
00232 /// Added ActiveLeaf node allowing for much easier scene
00233 /// node creation.
00234 /// Added default_cursor to scrollableview.
00235 /// Numerous bugfixes.
00236 /// MouseIn/Out now changes cursor.
00237 ///
00238 /// Revision 1.7  2003/11/13 18:50:18  botik
00239 /// Fixed (almost) clear and update rect behaviour.
00240 /// Added update_rect to framework and sdl wrapper.
00241 /// Added mouse_in/mouse_out handling
00242 /// Fixed message handling
00243 /// Many small bugfixes
00244 ///
00245 /// Revision 1.6  2003/11/13 12:50:51  botik
00246 /// Refined the event handling architecture
00247 /// Got the event handling to recognize and treat mouse
00248 /// events accordingly
00249 /// Important fixes to ./Makefile
00250 ///
00251 /// Revision 1.5  2003/11/12 18:14:25  botik
00252 /// Got the framework to check scene nodes for viewport fit
00253 /// before painting.
00254 ///
00255 /// Revision 1.4  2003/11/11 14:44:34  botik
00256 /// Changed zoomablesurfaceview to zoom the commands
00257 /// (which it was supposed to do in the first place),
00258 /// Changed some function details in leafnode,
00259 /// Added a new test in tests
00260 ///
00261 /// Revision 1.3  2003/11/09 15:23:01  botik
00262 /// Got GraphDisplay to compile and run.
00263 ///
00264 /// Revision 1.2  2003/10/21 17:39:00  botik
00265 /// Added preliminary scene support
00266 ///
00267 /// Revision 1.1  2003/10/15 12:04:24  botik
00268 /// Changed the name of the SurfaceView class
00269 ///
00270 /// Revision 1.2  2003/10/13 16:41:35  botik
00271 /// Added Log keyword to the end of the files
00272 ///

Generated on Wed Jun 23 18:47:21 2004 for cZUI by doxygen 1.3.5