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

basescenenode.h

Go to the documentation of this file.
00001 //--- < BASESCENENODE.H > -------| ViewGraph - A Flexible Graph view Framework |
00002 //
00003 // This is the base class in a scene tree.
00004 // Base scene nodes can paint and get the
00005 // bounding rectangle.
00006 // 
00007 // $Author: botik32 $
00008 // $Revision: 1.5 $
00009 // $Date: 2004/06/02 08:03:55 $
00010 //-----------------------------------------------------------------------------/
00011 
00012 #ifndef BASESCENENODE_H
00013 #define BASESCENENODE_H
00014 
00015 #include <map>
00016 #include <cZUI/eventhub.h>
00017 #include <cZUI/eventlistener.h>
00018 
00019 class Camera;
00020 class SceneNode;
00021 class Message;
00022 class Event;
00023 class RepaintEvent;
00024 class MouseEvent;
00025 
00026 class BaseSceneNode : public EventHub, public EventListener
00027 {
00028 protected:
00029         bool check_event_fitsrect( Event * e );
00030         bool check_node_visible( Event * e );
00031         // the resize map below is used to store node size
00032         // if it has been changed.
00033         static std::map<BaseSceneNode*,double> resize_map;
00034         void resize( double newsize );
00035         double get_size( void );
00036 public:
00037         /// This function should be overloaded in every node 
00038         /// to provide for event handling and repaint.
00039         virtual void get_boundrect( double&, double&, double&, double& )=0;
00040         /// This function is used to compute scene bounds.
00041         /// Certain types of nodes, e.g. HUDGroups will return
00042         /// an invalid rect here. <br>
00043         /// get_boundrect() is aliased to get_boundrect in BaseSceneNode
00044         /// and there is normally no need to override it.
00045         virtual void get_scenerect( double&, double&, double&, double& );
00046         
00047         /// call the base event handler in all nodes because it
00048         /// provides checks for node visibility and mouse event
00049         /// fitting into bounding rectangle.
00050         virtual bool handle_event( Event * );
00051 
00052         /// messages are intended to a certain node but can be
00053         /// processed by nodes directly higher up (i.e. decorator
00054         /// nodes). Beware that this can be slow for large graphs
00055         /// but using smart group nodes can help.
00056         virtual bool handle_message( Message * );
00057 
00058         /// This function should be overloaded in every node 
00059         /// to provide for event handling.
00060         virtual bool check_event_fitspixels( Event * )=0;
00061 
00062         /// this one always returns NULL for BaseSceneNode.
00063         /// SceneNode and GroupNode override this function.
00064         virtual BaseSceneNode* get_child( void );
00065 
00066         virtual void translate( double dx, double dy ){};
00067         virtual void rotate( double ax, double ay, double rad ){};
00068         virtual void move( double newx, double newy ){};
00069 
00070         virtual ~BaseSceneNode();
00071 };
00072 
00073 #endif
00074 
00075 /// $Log: basescenenode.h,v $
00076 /// Revision 1.5  2004/06/02 08:03:55  botik32
00077 /// Removed fitsall bool from GroupNode
00078 /// Added get_scenerect() to BaseSceneNode
00079 /// Added get_scenerect() to HUDGroupNode
00080 /// Added recompute_scenerect() to GroupNode
00081 /// Changed GroupNode's recompute_boundrect behaviour to
00082 /// accept FitAllRect bounds again
00083 ///
00084 /// Revision 1.4  2004/05/05 07:10:14  botik32
00085 /// Added ContainerNode class for simple element selection/unselection
00086 /// More bugfixes
00087 ///
00088 /// Revision 1.3  2004/04/30 12:39:21  botik32
00089 /// Numerous changes related to making the SceneChangedEvents
00090 /// to work.
00091 /// - Moved listen_event() from BaseSceneNode to EventListener class
00092 /// - Made GroupNode listen to the added children's SceneChangedEvents
00093 /// - Changed Camera to listen to layers' SceneChangedEvents
00094 /// - Moved eventlistener list cleanup from Camera to EventHub class
00095 ///   where it belonged in the first place
00096 ///
00097 /// Revision 1.2  2004/04/18 12:58:31  botik32
00098 /// Changes to groupnode's handling of events.
00099 /// This speeds up the framework tremendously but
00100 /// breaks a few things.
00101 ///
00102 /// Revision 1.1.1.1  2004/03/26 10:50:21  botik32
00103 /// Initial release
00104 ///
00105 /// Revision 1.1.1.1  2004/03/26 08:53:33  botik
00106 /// initial import
00107 ///
00108 ///
00109 /// Revision 1.11  2003/12/30 17:10:31  botik
00110 /// more fixes to remove memory leaks
00111 ///
00112 /// Revision 1.10  2003/11/29 16:11:23  botik
00113 /// Added event listener support to basescenenode and camera
00114 /// classes
00115 ///
00116 /// Revision 1.9  2003/11/28 22:12:12  botik
00117 /// Added size storing for basescenenode so that
00118 /// hud nodes draw appropriately
00119 ///
00120 /// Revision 1.8  2003/11/18 11:23:12  botik
00121 /// Fixed a bug in scenenode that mucked message passing
00122 /// Removed some old handlers from basescenenode that caused
00123 /// problems with repainting under a group
00124 /// Groups work now okay.
00125 ///
00126 /// Revision 1.7  2003/11/13 18:50:18  botik
00127 /// Fixed (almost) clear and update rect behaviour.
00128 /// Added update_rect to framework and sdl wrapper.
00129 /// Added mouse_in/mouse_out handling
00130 /// Fixed message handling
00131 /// Many small bugfixes
00132 ///
00133 /// Revision 1.6  2003/11/13 12:50:51  botik
00134 /// Refined the event handling architecture
00135 /// Got the event handling to recognize and treat mouse
00136 /// events accordingly
00137 /// Important fixes to ./Makefile
00138 ///
00139 /// Revision 1.5  2003/11/12 18:14:25  botik
00140 /// Got the framework to check scene nodes for viewport fit
00141 /// before painting.
00142 ///
00143 /// Revision 1.4  2003/11/11 15:30:58  botik
00144 /// Added and compiled second framework test,
00145 /// fixed along a few bugs.
00146 ///
00147 /// Revision 1.3  2003/11/09 15:23:01  botik
00148 /// Got GraphDisplay to compile and run.
00149 ///
00150 /// Revision 1.2  2003/11/08 23:45:54  botik
00151 /// Got the framework to compile, in order to do that
00152 /// filled in some functions and added some empty
00153 /// ones as well.
00154 ///
00155 /// Revision 1.1  2003/11/06 13:35:57  botik
00156 /// Moved leafnode to basescenenode and removed cached
00157 /// boundrect stuff from leafnode. Boundrect will be
00158 /// moved to an optimizedgroupnode.
00159 ///

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