]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
robomon: Robot visibility can be set from menu
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 24 Apr 2010 21:44:01 +0000 (23:44 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sat, 24 Apr 2010 21:44:01 +0000 (23:44 +0200)
src/robomon/MainWindow.cpp
src/robomon/MainWindow.h
src/robomon/RobomonAtlantis.cpp
src/robomon/RobomonAtlantis.h
src/robomon/Robot.cpp
src/robomon/Robot.h

index 4c8416dca0ec073ba7258f3cd91b8630f664432e..709fec08b2aa9f5e27747311b931352e3bd2e01d 100644 (file)
@@ -52,6 +52,16 @@ 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(showRobotRef, SIGNAL(toggled(bool)), robomonAtlantis->robotRefPos, SLOT(mySetVisible(bool)));
+       connect(showRobotEst, SIGNAL(toggled(bool)), robomonAtlantis->robotEstPosBest, SLOT(mySetVisible(bool)));
+       connect(showRobotEstOdo, SIGNAL(toggled(bool)), robomonAtlantis->robotEstPosOdo, SLOT(mySetVisible(bool)));
+       connect(showRobotEstIndepOdo, SIGNAL(toggled(bool)), robomonAtlantis->robotEstPosIndepOdo, SLOT(mySetVisible(bool)));
+
+       showRobotRef->setChecked(true);
+       showRobotEst->setChecked(true);
+       showRobotEstOdo->setChecked(false);
+       showRobotEstIndepOdo->setChecked(false);
 }
 
 void MainWindow::about()
@@ -116,7 +126,16 @@ void MainWindow::createActions()
        showTrails->setCheckable(true);
        showMap = new QAction("Show &map", this);
        showMap->setCheckable(true);
-       resetTrails = new QAction("&Reset trails", this);
+       resetTrails = new QAction("Re&set trails", this);
+
+       showRobotRef = new QAction("&Reference position", this);
+       showRobotRef->setCheckable(true);
+       showRobotEst = new QAction("&Best available estimated position", this);
+       showRobotEst->setCheckable(true);
+       showRobotEstOdo = new QAction("&Motor odometry", this);
+       showRobotEstOdo->setCheckable(true);
+       showRobotEstIndepOdo = new QAction("&Independent odometry", this);
+       showRobotEstIndepOdo->setCheckable(true);
 }
 
 void MainWindow::createMenus()
@@ -130,6 +149,12 @@ void MainWindow::createMenus()
        m->addAction(showMap);
        m->addAction(showTrails);
        m->addAction(resetTrails);
+       QMenu *robot = m->addMenu(tr("&Robot"));
+
+       robot->addAction(showRobotRef);
+       robot->addAction(showRobotEst);
+       robot->addAction(showRobotEstOdo);
+       robot->addAction(showRobotEstIndepOdo);
        
        toolsMenu = menuBar()->addMenu(tr("&Tools"));
        toolsMenu->addAction(robomonTuningAct);
index 29271997a6e533350ff18c326ac12276b29df7cd..532df87ecce2802d0dd7e80636a80da79d57db14 100644 (file)
@@ -63,6 +63,10 @@ private:
        QAction *resetTrails;
        QAction *showTrails;
        QAction *showMap;
+       QAction *showRobotRef;
+       QAction *showRobotEst;
+       QAction *showRobotEstOdo;
+       QAction *showRobotEstIndepOdo;
 };
 
 #endif /* MAIN_WINDOW_H */
index 1b5958c575bd235012456990d591b2c664c2ee32..d87b7738b31479b90b22da7a0fdccbb6a6155e11 100644 (file)
@@ -964,8 +964,8 @@ void RobomonAtlantis::resetTrails()
 
 void RobomonAtlantis::showTrails(bool show)
 {
-       trailRefPos->setVisible(show);
-       trailEstPosBest->setVisible(show);
-//     trailPosIndepOdo->setVisible(show);
-//     trailOdoPos->setVisible(show);
+       trailRefPos->setVisible(show && robotRefPos->isVisible());
+       trailEstPosBest->setVisible(show && robotEstPosBest->isVisible());
+       trailPosIndepOdo->setVisible(show && robotEstPosIndepOdo->isVisible());
+       trailOdoPos->setVisible(show && robotEstPosOdo->isVisible());
 }
index f9eacc2b6881ddcac461fc85b8ff68e1ab8745a2..0edd23d26fb86caa6a59dd2a93260367b262d40b 100644 (file)
@@ -157,13 +157,13 @@ private:
        QLabel *fsm_motion_state;
        QCheckBox *startPlug;
        QCheckBox *puckInside;
-
+public:
        /* robot */
        Robot *robotRefPos;
        Robot *robotEstPosBest;
        Robot *robotEstPosIndepOdo;
        Robot *robotEstPosOdo;
-       
+private:
        Trail *trailRefPos;
        Trail *trailEstPosBest;
        Trail *trailPosIndepOdo;
index 97d7706ddb6551c87bacefef05acf844dd49b068..6a135d8910e6799eeb8e82e1c4e43ea6e7c1db91 100644 (file)
 #include "PlaygroundScene.h"
 #include "Robot.h"
 #include <robodim.h>
+#include <iostream>
 
-Robot::Robot(const QString &text, const QPen &pen, const QBrush &brush) 
-       : QGraphicsItem(0)
+Robot::Robot(const QString &text, const QPen &pen, const QBrush &brush) :
+       QGraphicsObject()
 {
        this->text = text;
        this->pen = pen;
        this->brush = brush;
+       setVisible(false);
        moveRobot(1, 1, 0);
 }
 
@@ -74,3 +76,7 @@ void Robot::moveRobot(double x, double y, double phi)
        setTransform(QTransform().rotateRadians(phi-M_PI/2.0).translate(-ROBOT_WIDTH_MM/2.0, -ROBOT_AXIS_TO_BACK_MM));
 }
 
+void Robot::mySetVisible(bool show)
+{
+       setVisible(show);
+}
index 368367e7bb16aafc03d7b6d999f578cf5a7d2457..52d5d1d3887b3ca1dfa2eca1121e3e77d02750fa 100644 (file)
 #include <QGraphicsLineItem>
 #include <QPainter>
 
-class Robot : public QGraphicsItem
+class Robot : public QGraphicsObject
 {
+       Q_OBJECT
 public:
        Robot(const QString &aText, const QPen &pen = QPen(), const QBrush &brush = QBrush());
        ~Robot();
        QRectF boundingRect() const;
        void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
        void moveRobot(double x, double y, double angle);
+public slots:
+       void mySetVisible(bool show);
 private:
        QString text;
        QPen pen;