Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00038 #include <string>
00039
00040
00041 #include <QtGui/QApplication>
00042 #include <QString>
00043 #include <QtGui/QMessageBox>
00044 #include <QImage>
00045 #include <QFileInfo>
00046
00047 #include <multires_image/multires_view_node.h>
00048
00049 namespace multires_image
00050 {
00051 MultiresViewNode::MultiresViewNode(int argc, char **argv, QWidget *parent, Qt::WFlags flags) :
00052 QMainWindow(parent, flags),
00053 argc_(argc),
00054 argv_(argv),
00055 node_(NULL),
00056 thread_(NULL),
00057 initialized_(false)
00058 {
00059 setCentralWidget(new QGLMap());
00060 this->setMinimumSize(640, 480);
00061 }
00062
00063 MultiresViewNode::~MultiresViewNode()
00064 {
00065 delete node_;
00066 }
00067
00068 void MultiresViewNode::Spin()
00069 {
00070 if (thread_ == NULL)
00071 {
00072 thread_ = new boost::thread(&MultiresViewNode::SpinLoop, this);
00073 }
00074 }
00075
00076 void MultiresViewNode::SpinLoop()
00077 {
00078 while (ros::ok())
00079 {
00080 ros::spinOnce();
00081
00082 usleep(10);
00083 }
00084 }
00085
00086 void MultiresViewNode::showEvent(QShowEvent* event)
00087 {
00088 Initialize();
00089 }
00090
00091 void MultiresViewNode::Initialize()
00092 {
00093 if (!initialized_)
00094 {
00095 ros::init(argc_, argv_, "multires_view_node");
00096
00097 node_ = new ros::NodeHandle();
00098
00099 node_->param(ros::this_node::getName() + "/image_path", image_path_, std::string(""));
00100
00101
00102 tile_set_ = new TileSet(image_path_);
00103
00104 if (tile_set_->Load())
00105 {
00106 QGLMap* glMap = reinterpret_cast<QGLMap*>(centralWidget());
00107 glMap->SetTiles(tile_set_);
00108 glMap->UpdateView();
00109 }
00110 else
00111 {
00112 QMessageBox::warning(this, "Error", "Failed to load tiles.");
00113 }
00114
00115 Spin();
00116
00117 initialized_ = true;
00118 }
00119 }
00120 }
00121
00122 int main(int argc, char **argv)
00123 {
00124
00125 QApplication app(argc, argv);
00126
00127 multires_image::MultiresViewNode node(argc, argv);
00128 node.show();
00129
00130 return app.exec();
00131 }