]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
MainWindow: add menu item (robomon): View -> Show shape detect
authorMartin Synek <synekmar@fel.cvut.cz>
Tue, 18 Jan 2011 07:33:31 +0000 (08:33 +0100)
committerMartin Synek <synekmar@fel.cvut.cz>
Tue, 18 Jan 2011 07:33:31 +0000 (08:33 +0100)
hokuyoscan: add method drawShapeDetect
robomon.pro: add library lshape_detect

src/hokuyo/shape-detect/shape_detect.h
src/robomon/MainWindow.cpp
src/robomon/MainWindow.h
src/robomon/RobomonAtlantis.cpp
src/robomon/RobomonAtlantis.h
src/robomon/hokuyoscan.cpp
src/robomon/hokuyoscan.h
src/robomon/robomon.pro

index 16a472430e500408b4db7c65009bb0a564dcd27a..70f73b4f707b5dd3aa22de092e39d7cbc82d37e2 100644 (file)
@@ -16,7 +16,7 @@
 #include <roboorte_robottype.h>
 
 // gnuplot graph
-#define GNUPLOT 1
+//#define GNUPLOT 0
 
 // debug mode with connect Hokuyo
 #define OFFLINE 1
index ed0ba94f0e6974e3400e4493e5ae7eff10a7526c..ced8ba2fbb161f2bfc2a1f62c5fa0a038fcdfd41 100644 (file)
@@ -52,6 +52,7 @@ void MainWindow::addRobomonAtlantisTab()
        connect(showMap, SIGNAL(toggled( bool )), robomonAtlantis, SLOT(showMap(bool)));
        connect(showTrails, SIGNAL(toggled( bool )), robomonAtlantis, SLOT(showTrails(bool)));
        connect(resetTrails, SIGNAL(triggered()), robomonAtlantis, SLOT(resetTrails()));
+       connect(showShapeDetect, SIGNAL(toggled( bool )), robomonAtlantis, SLOT(showShapeDetect(bool)));
        connect(useOpenGL, SIGNAL(toggled( bool )), robomonAtlantis, SLOT(useOpenGL(bool)));
 
        connect(showRobotRef, SIGNAL(toggled(bool)), robomonAtlantis->robotRefPos, SLOT(mySetVisible(bool)));
@@ -134,6 +135,8 @@ void MainWindow::createActions()
        showTrails->setCheckable(true);
        showMap = new QAction("Show &map", this);
        showMap->setCheckable(true);
+       showShapeDetect = new QAction("Show s&hape detect", this);
+       showShapeDetect->setCheckable(true);
        resetTrails = new QAction("Re&set trails", this);
 
        useOpenGL = new QAction("Use &OpenGL", this);
@@ -161,6 +164,7 @@ void MainWindow::createMenus()
        m->addAction(showMap);
        m->addAction(showTrails);
        m->addAction(resetTrails);
+       m->addAction(showShapeDetect);
        QMenu *robot = m->addMenu(tr("&Robot"));
        m->addAction(useOpenGL);
 
index 50650669fed534b23a2a94bf8401c31672f88bfe..e5260b7b3737c877af6b433aaf9f1f7235356ad4 100644 (file)
@@ -65,6 +65,7 @@ private:
        QAction *resetTrails;
        QAction *showTrails;
        QAction *showMap;
+       QAction *showShapeDetect;
        QAction *showRobotRef;
        QAction *showRobotEst;
        QAction *showRobotEstOdo;
index b63994c547844de441280fa19e372a30eaf9ee6c..49ddb685ed5258d2d195c35d72ee0c0aaeb8170f 100644 (file)
@@ -1005,3 +1005,13 @@ void RobomonAtlantis::showTrails(bool show)
        trailPosIndepOdo->setVisible(show && robotEstPosIndepOdo->isVisible());
        trailOdoPos->setVisible(show && robotEstPosOdo->isVisible());
 }
+
+void RobomonAtlantis::showShapeDetect(bool show)
+{
+       if (show)
+       {
+
+       } else {
+
+       }
+}
index d3ac3e8b364e684c91c605723bc0522656a03b77..8dc2473ad03bc02dc62360491f4279c2ebc2f79c 100644 (file)
@@ -60,6 +60,7 @@ public slots:
        void showMap(bool show);
        void useOpenGL(bool use);
        void showTrails(bool show);
+       void showShapeDetect(bool show);
        void resetTrails();
 private slots:
        /************************************************************
index f806cf5a805893f8ebe14b43beeff29e2a6452dd..bdf5a91bcca1e4de4195c1cdcdea7344fcc55f79 100644 (file)
@@ -22,6 +22,24 @@ QRectF HokuyoScan::boundingRect() const
     return QRectF(tl, br);
 }
 
+void HokuyoScan::drawShapeDetect(QPainter * painter)
+{
+       Shape_detect sd;
+       std::vector<int> input(HOKUYO_ARRAY_SIZE);
+
+       for (unsigned i = 0; i < HOKUYO_ARRAY_SIZE; i++)
+               input[i] = (int) data.data[i];
+
+       std::vector<Shape_detect::Line> output;
+       sd.shape_detect(input, output);
+
+       painter->setPen(QPen(Qt::green));
+       
+       for (unsigned i = 0; i < output.size(); i++)
+               painter->drawLine(output[i].a.x, output[i].a.y, output[i].b.x, output[i].b.y);
+}
+
 void HokuyoScan::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
 {
     int d;
@@ -56,6 +74,9 @@ void HokuyoScan::paint(QPainter * painter, const QStyleOptionGraphicsItem * opti
            point_num = 0;
        }
     }
+       
+       drawShapeDetect(painter);
+
     painter->drawPolygon(points, point_num);
 }
 
index 49128392b240f5346e3843cbf814dc5b69ff92a0..372e0fc5ea48baaf4051db3efa9d12cdd6c0a41c 100644 (file)
@@ -2,6 +2,7 @@
 #define HOKUYOSCAN_H
 
 #include <robottype.h>
+#include <shape_detect.h>
 #include <QRectF>
 #include <QPainter>
 #include <QStyleOptionGraphicsItem>
@@ -19,6 +20,8 @@ public:
     void setPosition(double x, double y, double phi);
     void newScan(struct hokuyo_scan_type *scan);
 
+       void drawShapeDetect(QPainter * painter);
+
     ~HokuyoScan();
 };
 
index e43f4967fec9ae2c69f22e769be48ce53d9e2686..17c9b76fc930cabe2c5bc11064fdc5093ad44c72 100644 (file)
@@ -36,4 +36,4 @@ HEADERS += MainWindow.h \
  hokuyoscan.h
 
 LIBS += -lm -lpthread -lmcl -llaser-nav -lrobodim -lrobomath -lroboorte \
-               -lrobottype -lorte  -lsharp -lmap -lactlib -lcornslib
+               -lrobottype -lorte  -lsharp -lmap -lactlib -lcornslib -lshape_detect