Go to the documentation of this file.00001
00009 #ifndef DISPLAY_QT__HPP_
00010 #define DISPLAY_QT__HPP_
00011 #ifdef HAVE_MODULE_QDISPLAY
00012
00013 #include <boost/thread/condition_variable.hpp>
00014
00015 #include "qdisplay/ImageView.hpp"
00016 #include "qdisplay/Viewer.hpp"
00017 #include "qdisplay/Shape.hpp"
00018 #include "qdisplay/Ellipsoid.hpp"
00019 #include "qdisplay/Line.hpp"
00020 #include "qdisplay/init.hpp"
00021
00022 #include "rtslam/display.hpp"
00023 #include "rtslam/rawImage.hpp"
00024
00025 #include "jmath/misc.hpp"
00026
00027 #define DEFINE_USELESS_OBJECTS 1
00028
00029
00030 #define EMBED_PREDICTED_APP 0
00031
00032 namespace jafar {
00033 namespace rtslam {
00034 namespace display {
00035
00036
00037
00038
00039 class WorldQt;
00040 class MapQt;
00041 class RobotQt;
00042 class SensorQt;
00043 class LandmarkQt;
00044 class ObservationQt;
00045
00046 struct RunStatus
00047 {
00048 bool pause;
00049 bool next;
00050 bool render_all;
00051 boost::condition_variable condition;
00052 boost::mutex mutex;
00053 RunStatus(): next(false) {}
00054 };
00055
00056
00057 #if DEFINE_USELESS_OBJECTS
00058 class ViewerQt: public Viewer<WorldQt,MapQt,RobotQt,SensorQt,LandmarkQt,ObservationQt,
00059 boost::variant<QGraphicsItem*, qdisplay::Viewer*, qdisplay::ImageView*> >
00060 {
00061 public:
00062 int fontSize;
00063 double ellipsesScale;
00064 bool doDump;
00065 std::string dump_pattern;
00066 std::map<int,SensorQt*> sensorsList;
00067 public:
00068 ViewerQt(int _fontSize = 8, double _ellipsesScale = 3.0, bool _dump = false, std::string _dump_pattern = "data/rendered2D_%02d-%06d.png"):
00069 fontSize(_fontSize), ellipsesScale(_ellipsesScale), doDump(_dump), dump_pattern(_dump_pattern) {}
00070 void dump(std::string filepattern);
00071 static RunStatus runStatus;
00072 };
00073 #else
00074 #error "does not work"
00075
00076 #endif
00077
00078
00079
00080
00081
00082 #if DEFINE_USELESS_OBJECTS
00083
00087 class WorldQt : public WorldDisplay
00088 {
00089 ViewerQt *viewerQt;
00090 public:
00091 WorldQt(ViewerAbstract *_viewer, rtslam::WorldAbstract *_slamWor, WorldDisplay *garbage);
00092 void bufferize() {}
00093 void render() {}
00094 };
00095
00099 class MapQt : public MapDisplay
00100 {
00101 ViewerQt *viewerQt;
00102 public:
00103 MapQt(ViewerAbstract *_viewer, rtslam::MapAbstract *_slamMap, WorldQt *_dispWorld);
00104 void bufferize() {}
00105 void render() {}
00106 };
00107
00111 class RobotQt : public RobotDisplay
00112 {
00113 ViewerQt *viewerQt;
00114 public:
00115
00116
00117
00118
00119 public:
00120 RobotQt(ViewerAbstract *_viewer, rtslam::RobotAbstract *_slamRob, MapQt *_dispMap);
00121 void bufferize() {}
00122 void render() {}
00123 };
00124 #endif
00125
00129 class SensorQt : public QObject, public SensorDisplay
00130 {
00131 Q_OBJECT
00132 private:
00133 ViewerQt *viewerQt;
00134 public:
00135
00136 image::Image image;
00137 unsigned framenumber;
00138 double avg_framerate;
00139 double t;
00140 vec7 pose;
00141 unsigned int id_;
00142 cv::Size size;
00143 char isImage;
00144
00145 qdisplay::Viewer *viewer_;
00146 qdisplay::ImageView* view_private;
00147 QGraphicsTextItem* framenumber_label;
00148 QGraphicsTextItem* sensorpose_label;
00149 qdisplay::ImageView* view();
00150 public:
00151 SensorQt(ViewerAbstract *_viewer, rtslam::SensorExteroAbstract *_slamSen, RobotQt *_dispRob);
00152 ~SensorQt();
00153 void bufferize();
00154 void render();
00155 void dump(std::string filename);
00156 public slots:
00157 void onKeyPress(QKeyEvent *event);
00158 void onMouseClick(QGraphicsSceneMouseEvent *mouseEvent, bool isClick);
00159 };
00160
00161 #if DEFINE_USELESS_OBJECTS
00162
00165 class LandmarkQt : public LandmarkDisplay
00166 {
00167 ViewerQt *viewerQt;
00168 public:
00169
00170
00171
00172 public:
00173 LandmarkQt(ViewerAbstract *_viewer, rtslam::LandmarkAbstract *_slamLmk, MapQt *_dispMap);
00174 void bufferize() {}
00175 void render() {}
00176 };
00177 #endif
00178
00182 class ObservationQt : public ObservationDisplay
00183 {
00184 ViewerQt *viewerQt;
00185 public:
00186
00187 ObservationAbstract::Events events_;
00188
00189
00190
00191
00192
00193 jblas::vec predObs_;
00194 jblas::sym_mat predObsCov_;
00195 std::vector<jblas::vec> predObsHyps_;
00196 unsigned n_hyps_;
00197 std::vector<jblas::sym_mat> predObsCovHyps_;
00198 jblas::vec measObs_;
00199 #if EMBED_PREDICTED_APP
00200 AppearanceAbstract *predictedApp_;
00201 #endif
00202 unsigned int id_;
00203 double match_score;
00204
00205
00206 SensorQt *dispSen_;
00207 typedef std::list<qdisplay::Shape*> ItemList;
00208 ItemList items_;
00209 typedef std::vector<qdisplay::Shape*> ItemVec;
00210 ItemVec hyp_items_;
00211 public:
00212 ObservationQt(ViewerAbstract *_viewer, rtslam::ObservationAbstract *_slamObs, SensorQt *_dispSen);
00213 ~ObservationQt();
00214 void bufferize();
00215 void render();
00216 };
00217
00218
00219
00220
00221 }}}
00222
00223 #endif
00224 #endif
00225