00001
00017 #define STATECONTROL_H
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_VECTOR
00028 #include <vector>
00029 #endif
00030
00031 #ifndef _GLIBCXX_MAP
00032 #include <map>
00033 #endif
00034
00035 #ifndef _GLIBCXX_STRING
00036 #include <string>
00037 #endif
00038
00039 #ifndef _PTHREAD_H
00040 #include <pthread.h>
00041 #endif
00042
00043 #ifndef OSG_GROUP
00044 #include <osg/Group>
00045 #endif
00046
00047 #ifndef OSG_NODE
00048 #include <osg/Node>
00049 #endif
00050
00051 #ifndef OSGPRODUCER_VIEWER
00052 #include <osgProducer/Viewer>
00053 #endif
00054
00055 #ifndef OSGGA_NODETRACKERMANIPULATOR
00056 #include <osgGA/NodeTrackerManipulator>
00057 #endif
00058
00059 #ifndef ANIMATIONPATHTIMEDCALLBACK_H
00060 #include <AnimationPathTimedCallback.h>
00061 #endif
00062
00063 #ifndef TRAPLASOBJECT_H
00064 #include "TraplasObject.h"
00065 #endif
00066
00067 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
00068 #include <boost/shared_ptr.hpp>
00069 #endif
00070
00071
00072 class Dispatcher;
00073 class UserInterface;
00074
00075 using namespace boost;
00076 using namespace std;
00077
00078 #define CARGO 0
00079 #define TRANSPORT 1
00080 #define LOCATION 2
00081
00082
00083
00091 class StateControl{
00092
00093 public:
00098 StateControl(Dispatcher* disp);
00102 ~StateControl();
00119 bool location(int loc_id, shared_ptr<string> desc, unsigned int capacity, double dist, double s, int tile, double width, double height, double x, double y, double rot);
00131 bool drv(int Rt, int Ri_a, int Ri_b, int Ri_d, double ts, double te);
00142 bool load(int Rt, int Ri, int C, double ts, double tf);
00153 bool unload(int Rt, int Ri, int C, double ts, double te);
00161 bool setspdinviz(int R, double s);
00171 bool trnew(int Rt, shared_ptr<string> desc, int Ri, double s);
00178 bool trdel(int Rt);
00187 bool newcarg(int C, shared_ptr<string> desc, int Ri);
00194 bool rmcarg(int C);
00202 bool arc(int Ri_a, int Ri_b);
00206 inline osg::Group* getOsgRoot(){return osgRoot;}
00212 friend void* go(void *none);
00218 bool adjustTimeFlow(double adj);
00222 double getTimeFlow();
00226 double getTime();
00230 void pause();
00236 int selectObject(TraplasObject* obj);
00240 TraplasObject* getLastSelected();
00246 int deselectObject(TraplasObject* obj);
00250 void clearSelection();
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261 private:
00262 Dispatcher* dis;
00263 UserInterface* ui;
00264 osgProducer::Viewer* view;
00265 string trackingCamName;
00266 string previousCamName;
00267 map<int, TraplasObject*> world;
00268 vector<TraplasObject*> selected;
00269 osg::Group* osgRoot;
00270 map<int, string> tileMap;
00271 double tilescale;
00272 string transmodel;
00273 double transscale;
00274 string cargomodel;
00275 double cargoscale;
00276 pthread_t osg_update_loop;
00277 bool readMapping(int);
00278 void updateHudText(TraplasObject* upd);
00279 double pausetime;
00280 };
00281
00282