00001 #ifndef __ENKI_VIEWER_H
00002 #define __ENKI_VIEWER_H
00003
00004 #ifdef HAVE_VIEWER
00005
00006 #include <string>
00007
00008 #include <ishtar/settings.h>
00009 #include <enki/PhysicalEngine.h>
00010
00011 #include "videorec.h"
00012
00013 #include "../libgag/GAG.h"
00014
00015 namespace Enki
00016 {
00017 class Alice;
00018 }
00019
00021 class Viewer
00022 {
00023 protected:
00024 GAG::GraphicContext *gc;
00025 GAG::Font *font;
00026 unsigned eventStep;
00027 unsigned delayStartTick;
00028 bool displayAll;
00029 #ifdef HAVE_AVCODEC
00030 VideoRecorder *vrec;
00031 #endif
00032
00033 int width, height;
00034
00035 Ishtar::Variable<unsigned> realtime;
00036 Ishtar::Variable<std::string, true> fontFileName;
00037
00039 virtual void displayViewer(int w, int h) = 0;
00040
00041 public:
00043 Viewer(bool recVideo = false);
00045 virtual ~Viewer();
00046
00048 void init(int width, int height);
00050 void step(double dt);
00051
00053 void handleEvent(bool eachStep = false);
00055 void startRecordingVideo(const std::string &fileName);
00057 void stopRecordingVideo(void);
00059 void display(bool force = false);
00061 void setCaption(const std::string &caption);
00063 void startDelayFrame(void);
00065 void endDelayFrame(double dt);
00066 };
00067
00070 class EnkiViewer : public Viewer
00071 {
00072 protected:
00073 const Enki::World *world;
00074
00075 Ishtar::Variable<double> scale;
00076 int sideBarWidth;
00077
00078 public:
00080 EnkiViewer(const Enki::World *w, bool recVideo = false, int sideBarWidth = 0);
00082 virtual ~EnkiViewer() { }
00083
00084 protected:
00086 virtual void displayViewer(int w, int h);
00088 virtual void displayWorld(int x, int y, int w, int h);
00090 virtual void displaySideBar(int x, int y, int w, int h);
00091
00093 void drawIRSensors (int bottom, const Enki::Alice *owner, int which);
00095 void drawCameraRays(int bottom, const Enki::Alice *owner);
00096
00097 };
00098
00101 class VisionEnkiViewer : public EnkiViewer
00102 {
00103 public:
00105 VisionEnkiViewer(const Enki::World *w, bool recVideo = false, int sideBarWidth = 268) : EnkiViewer(w, recVideo, sideBarWidth) { }
00107 virtual ~VisionEnkiViewer() { };
00108
00109 protected:
00111 virtual void displaySideBar(int x, int y, int w, int h);
00113 void drawIRSensor(double dx, double dy, double angle, int bottom, const Enki::PhysicalObject &owner);
00114 };
00115
00116 #endif // HAVE_VIEWER
00117
00118 #endif