00001
00017 #define USERINTERFACE_H 1
00018
00019 #ifndef _STDLIB_H
00020 #include <stdlib.h>
00021 #endif
00022
00023 #ifndef _STDIO_H
00024 #include <stdio.h>
00025 #endif
00026
00027 #ifndef _GLIBCXX_IOSTREAM
00028 #include <iostream>
00029 #endif
00030
00031 #ifndef OSG_GROUP
00032 #include <osg/Group>
00033 #endif
00034
00035 #ifndef OSG_NODE
00036 #include <osg/Node>
00037 #endif
00038
00039 #ifndef OSG_VEC3
00040 #include <osg/Vec3>
00041 #endif
00042
00043 #ifndef OSG_VEC4
00044 #include <osg/Vec4>
00045 #endif
00046
00047 #ifndef OSG_MATRIX
00048 #include <osg/Matrix>
00049 #endif
00050
00051 #ifndef OSG_AUTOTRANSFORM
00052 #include <osg/AutoTransform>
00053 #endif
00054
00055 #ifndef OSG_MATRIXTRANSFORM
00056 #include <osg/MatrixTransform>
00057 #endif
00058
00059 #ifndef OSG_GEOMETRY
00060 #include <osg/Geometry>
00061 #endif
00062
00063 #ifndef OSG_STATESET
00064 #include <osg/StateSet>
00065 #endif
00066
00067 #ifndef OSGTEXT_TEXT
00068 #include <osgText/Text>
00069 #endif
00070
00071 #ifndef OSG_SHAPEDRAWABLE
00072 #include <osg/ShapeDrawable>
00073 #endif
00074
00075 #ifndef OSGPRODUCER_VIEWER
00076 #include <osgProducer/Viewer>
00077 #endif
00078
00079 #ifndef OSG_CAMERANODE
00080 #include <osg/CameraNode>
00081 #endif
00082
00083
00084 class StateControl;
00085
00090 class UserEventHandler : public osgGA::GUIEventHandler {
00091 public:
00092 UserEventHandler(osgProducer::Viewer* viewer, UserInterface* ui);
00098 bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
00103 virtual void pick(const osgGA::GUIEventAdapter& ea);
00104
00105 protected:
00106 UserInterface* _user;
00107 osgProducer::Viewer* _viewer;
00108 ~UserEventHandler() {}
00109 };
00110
00111
00117 class UserInterface{
00118 public:
00123 UserInterface(StateControl* st);
00124
00125 ~UserInterface(){}
00126
00131 osg::Node* createHud();
00140 osg::AutoTransform* createHUDObject(string text, bool pickable, int xpos, int ypos);
00145 void setHUDText(string t);
00150 void rmHUDText(string rt);
00155 bool buttonAction(string buttonName);
00161 bool selectionAction(osg::Node* selected);
00165 void updateClock();
00166
00167 friend bool UserEventHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
00168 private:
00169 StateControl* s;
00170 osg::Node* hud;
00171 osg::CameraNode* hudCam;
00172 osgText::Text* clock;
00173 };