]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
robomon: Playground redefined for EB2009 and robot has correct dimensions and position
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 13 Apr 2009 22:13:23 +0000 (00:13 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 13 Apr 2009 22:44:47 +0000 (00:44 +0200)
Other changes include:
- Playground view is scalable
- Scene units are not in pixesl (as before) but in milimeters

src/robomon/PlaygroundScene.cpp
src/robomon/PlaygroundScene.h
src/robomon/RobomonAtlantis.cpp
src/robomon/Robot.cpp
src/robomon/Robot.h
src/robomon/dimensions.h [deleted file]
src/robomon/playgroundview.cpp [new file with mode: 0644]
src/robomon/playgroundview.h [new file with mode: 0644]
src/robomon/robomon.pro

index a6033e1ed60007b0c6f5cc0d2a56b433ca484119..b9c92bfdbfb3ff43326087e7272cdcf4284d84cc 100644 (file)
 #include <QGraphicsRectItem>
 
 #include "PlaygroundScene.h"
-#include "dimensions.h"
 
-PlaygroundScene::PlaygroundScene(int playgroundType, QObject *parent)
+PlaygroundScene::PlaygroundScene(QObject *parent)
        : QGraphicsScene(parent)
 {
-       switch (playgroundType) {
-               case PLAYGROUND_EUROBOT2007:
-                       createPlaygroundEurobot2007();
-                       break;
-               case PLAYGROUND_EUROBOT2008:
-                       createPlaygroundEurobot2008();
-                       break;
-               default:
-                       createPlaygroundEurobot2007();
-                       break;
-       }
-       
-       obstacle = new QGraphicsEllipseItem(0, 0, 10, 10);
-       obstacle->setZValue(5);
-       obstacle->setBrush(QBrush(Qt::blue));
-       obstacle->setVisible(false);
-       this->addItem(obstacle);
-}
-
-PlaygroundScene::~PlaygroundScene()
-{
-}
-
-void PlaygroundScene::createPlaygroundEurobot2007()
-{
+       using namespace Qt;
        QGraphicsRectItem *tempRect;
-       setSceneRect(0, 0, 615, 430);
        
-       /* playground border */
-       addLine(QLineF(TOP_LEFT, TOP_MIDDLE), QPen(QBrush(Qt::red),
-                       2, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
-       addLine(QLineF(TOP_MIDDLE,TOP_RIGHT), QPen(QBrush(Qt::blue),
-                       2, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
-       addLine(QLineF(TOP_LEFT, BOTTOM_LEFT), QPen(QBrush(Qt::red),
-                       2, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
-       addLine(QLineF(BOTTOM_LEFT, BOTTOM_MIDDLE), QPen(QBrush(Qt::red),
-                       2, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
-       addLine(QLineF(BOTTOM_MIDDLE, BOTTOM_RIGHT), QPen(QBrush(Qt::blue),
-                       2, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
-       addLine(QLineF(BOTTOM_RIGHT, TOP_RIGHT), QPen(QBrush(Qt::blue),
-                       2, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
-       
-       /* red basket */
-       addLine(QLineF(BIN_LEFT_BOTTLE_START, BIN_LEFT_BOTTLE_END),
-                       QPen(QBrush(Qt::red), 10, Qt::SolidLine, 
-                       Qt::FlatCap, Qt::BevelJoin));
-       addLine(QLineF(BIN_LEFT_CAN_START, BIN_LEFT_CAN_END),
-                       QPen(QBrush(Qt::red), 10, Qt::SolidLine,
-                       Qt::FlatCap, Qt::BevelJoin));
+       /* All scene units are milimeters */
        
-       /* blue basket */
-       addLine(QLineF(BIN_RIGHT_BOTTLE_START, BIN_RIGHT_BOTTLE_END),
-                       QPen(QBrush(Qt::blue), 10, Qt::SolidLine,
-                       Qt::FlatCap, Qt::BevelJoin));
-       addLine(QLineF(BIN_RIGHT_CAN_START, BIN_RIGHT_CAN_END),
-                       QPen(QBrush(Qt::blue), 10, Qt::SolidLine,
-                       Qt::FlatCap, Qt::BevelJoin));
+       /* playground border */
+       addRect(QRect(0, 0, -22, 2100), QPen(), QBrush(white));
+       addRect(QRect(-22, 2100, 3000+2*22, 22), QPen(), QBrush(white));
+       addRect(QRect(3000, 0, 22, 2100), QPen(), QBrush(white));
        
        /* playground */
-       tempRect = addRect(QRectF(11, 1, 597, 417), QPen(QBrush(Qt::lightGray),
-                               1, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin),
-                               QBrush(Qt::lightGray));
+       tempRect = addRect(QRect(0, 0, 3000, 2100), QPen(), QBrush(QColor(0, 148, 180)));
        tempRect->setZValue(1);
        
-       /* blue starting area */
-       tempRect = addRect(QRectF(11, 1, 100, 100), QPen(QBrush(Qt::green),
-                               1, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin),
-                               QBrush(Qt::green));
+       /* green starting area */
+       tempRect = addRect(QRect(0, 1600, 500, 500), QPen(NoPen), QBrush(green));
        tempRect->setZValue(3);
        
        /* red starting area */
-       tempRect = addRect(QRectF(508, 1, 100, 100), QPen(QBrush(Qt::red),
-                               1, Qt::SolidLine, Qt::FlatCap,Qt::BevelJoin),
-                               QBrush(Qt::red));
+       tempRect = addRect(QRect(2500, 1600, 500, 500), QPen(NoPen), QBrush(red));
        tempRect->setZValue(3);
+       
+       QBrush brownBrush = QBrush(QColor(202, 98, 9));
+       
+       /* circular building area */
+       addEllipse(1500-150, 1050-150, 300, 300, QPen(), brownBrush)->setZValue(3);
+       
+       /* side building areas */
+       addRect(QRect(600, 0, 600, 100), QPen(),  brownBrush)->setZValue(3);
+       addRect(QRect(1200, 0, 600, 100), QPen(),  brownBrush)->setZValue(3);
+       addRect(QRect(1800, 0, 600, 100), QPen(),  brownBrush)->setZValue(3);
+       
+       obstacle = new QGraphicsEllipseItem(0, 0, 300, 300);
+       obstacle->translate(-150,-150);
+       obstacle->setZValue(5);
+       obstacle->setBrush(QBrush(QColor(blue)));
+       obstacle->setVisible(false);
+       this->addItem(obstacle);
 }
 
-void PlaygroundScene::createPlaygroundEurobot2008()
+PlaygroundScene::~PlaygroundScene()
 {
-       createPlaygroundEurobot2007();
 }
 
 void PlaygroundScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
 {
        QGraphicsScene::mousePressEvent(mouseEvent);
        QPointF pos = scene2world(mouseEvent->scenePos());
-       obstacle->setPos(mouseEvent->scenePos().x() - 5, 
-                               mouseEvent->scenePos().y() - 5);
+       obstacle->setPos(mouseEvent->scenePos().x(),
+                        mouseEvent->scenePos().y());
        obstacleChanged(pos);
 }
 
@@ -116,8 +77,8 @@ void PlaygroundScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
  */
 QPointF PlaygroundScene::scene2world(QPointF scenePos)
 {
-       return QPointF((scenePos.x() - 10) / 200.0,                     // FIXME: these magic numbers... (F.J.)
-                       (420 - scenePos.y() + 1) / 200.0);
+       return QPointF((scenePos.x()) / 1000.0,
+                       (scenePos.y()) / 1000.0);
 }
 
 
@@ -126,8 +87,8 @@ QPointF PlaygroundScene::scene2world(QPointF scenePos)
  */
 QPointF PlaygroundScene::world2scene(QPointF worldPos)
 {
-       return QPointF(worldPos.x() * 200 + 10,                         // FIXME: these magic numbers... (F.J.)
-                       1 + 420-worldPos.y());
+       return QPointF(worldPos.x() * 1000,
+                      worldPos.y() * 1000);
 }
 
 
index 5d6f10964cb78fa14fb3d351d0c97bf9515b0ed9..ff40cdc21735282d763eadaaafa1586904e3bfa5 100644 (file)
@@ -19,17 +19,12 @@ class PlaygroundScene : public QGraphicsScene
        Q_OBJECT
 
 public:
-       PlaygroundScene(int playgroundType = 0, QObject *parent = 0);
+       PlaygroundScene(QObject *parent = 0);
        ~PlaygroundScene();
        virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
        static QPointF scene2world(QPointF scenePos);
        static QPointF world2scene(QPointF worldPos);
 
-       enum {
-               PLAYGROUND_EUROBOT2007,
-               PLAYGROUND_EUROBOT2008,
-       };
-
 signals:
        void obstacleChanged(QPointF pos);
 
index 8ba37ac9882987be2f5ef1f6aeee38ce33a32584..bfed9667f45c84c6154ba7096887d9c0c99232e9 100644 (file)
@@ -35,6 +35,7 @@
 #include "MiscGui.h"
 #include "robomon_orte.h"
 #include "RobomonAtlantis.h"
+#include "playgroundview.h"
 
 #include <QCoreApplication>
 #include <QEvent>
@@ -112,11 +113,12 @@ void RobomonAtlantis::createPlaygroundGroupBox()
        playgroundGroupBox = new QGroupBox(tr("Playground"));
        QHBoxLayout *layout = new QHBoxLayout();
 
-       playgroundScene = 
-               new PlaygroundScene(PlaygroundScene::PLAYGROUND_EUROBOT2008);
-       playgroundSceneView = new QGraphicsView(playgroundScene);
-       playgroundSceneView->setMinimumWidth((int)(playgroundScene->width())+15);
-       playgroundSceneView->setMinimumHeight((int)(playgroundScene->height())+15);
+       playgroundScene = new PlaygroundScene();
+       playgroundSceneView = new PlaygroundView(playgroundScene);
+       //playgroundSceneView->setMinimumWidth(630);
+       //playgroundSceneView->setMinimumHeight(445);
+        playgroundSceneView->setMatrix(QMatrix(1,0,0,-1,0,0), true);
+       playgroundSceneView->fitInView(playgroundScene->itemsBoundingRect());
        layout->addWidget(playgroundSceneView);
 
        playgroundGroupBox->setLayout(layout);
@@ -368,10 +370,10 @@ void RobomonAtlantis::createSharpSensorsLayout()
 
 void RobomonAtlantis::createRobots()
 {
-       robotActPos = new Robot(NULL, playgroundScene, Qt::black);
+       robotActPos = new Robot(QPen(), QBrush(Qt::darkGray));
        robotActPos->setZValue(10);
-       robotEstPos = new Robot(NULL, playgroundScene, Qt::green);
-       robotEstPos->setZValue(10);
+       robotEstPos = new Robot(QPen(Qt::darkBlue), QBrush(Qt::NoBrush));
+       robotEstPos->setZValue(11);
 
        playgroundScene->addItem(robotActPos);
        playgroundScene->addItem(robotEstPos);
index ae1a99c298bb626d62f7c206479810677c320b3b..c8752eb185a42591dff35d0b9997dc39d6f21812 100644 (file)
 
 #include "PlaygroundScene.h"
 #include "Robot.h"
+#include <robodim.h>
 
-Robot::Robot(QGraphicsItem *parent, QGraphicsScene *scene, Qt::GlobalColor color
-       : QGraphicsItem(parent)
+Robot::Robot(const QPen &pen, const QBrush &brush
+       : QGraphicsItem(0)
 {
-       actPhi = M_PI/2;
-       
-       this->scene = scene;
-
-       robotBody = new QGraphicsRectItem(
-                               QRectF(OFFSET_X, OFFSET_Y, ROBOT_SIZE_X, ROBOT_SIZE_Y), 
-                               parent, scene);
-       robotBody->setPen(QPen(QBrush(Qt::black), 1, Qt::SolidLine, 
-                               Qt::FlatCap, Qt::BevelJoin));
-       robotBody->setBrush(QBrush(color));
-       robotBody->setParentItem(this);
-       robotBody->setZValue(10);               
-               ;
-       sensShort[0] = new QGraphicsLineItem(OFFSET_X + 2*2, OFFSET_Y, 
-                               OFFSET_X + 2*2, OFFSET_Y - 30*2, parent, scene);
-       sensShort[1] = new QGraphicsLineItem(OFFSET_X + 9.5*2, OFFSET_Y,
-                               OFFSET_X + 9.5*2, OFFSET_Y - 30*2, parent, scene);
-       sensShort[2] = new QGraphicsLineItem(OFFSET_X+17*2, OFFSET_Y, 
-                               OFFSET_X + 17*2, OFFSET_Y-30*2, parent, scene);
-       sensShort[3] = new QGraphicsLineItem(OFFSET_X + 28*2, OFFSET_Y, 
-                               OFFSET_X + 28*2, OFFSET_Y - 30*2, parent, scene);
-       sensShort[4] = new QGraphicsLineItem(OFFSET_X + 25*2, 
-                               OFFSET_Y + ROBOT_SIZE_Y, OFFSET_X + 25*2,
-                               OFFSET_Y + ROBOT_SIZE_Y + 30*2, parent, scene);
-       sensShort[5] = new QGraphicsLineItem(OFFSET_X + 5*2, 
-                               OFFSET_Y + ROBOT_SIZE_Y, OFFSET_X + 5*2,
-                               OFFSET_Y + ROBOT_SIZE_Y + 30*2, parent, scene);
-       
-       for(int i=0; i<6; i++) {
-               sensShort[i]->setParentItem(this);
-               sensShort[i]->setPen(QPen(QBrush(Qt::red), 2, Qt::DashLine,
-                                       Qt::FlatCap, Qt::BevelJoin));
-       }       
-
-       sensLong[0] = new QGraphicsLineItem(OFFSET_X + 5*2, OFFSET_Y, 
-                               OFFSET_X + 5*2, OFFSET_Y - 80*2, parent, scene);
-       sensLong[1] = new QGraphicsLineItem(OFFSET_X + 15*2, OFFSET_Y, 
-                               OFFSET_X + 15*2, OFFSET_Y - 80*2, parent, scene);
-       sensLong[2] = new QGraphicsLineItem(OFFSET_X + 25*2, OFFSET_Y, 
-                               OFFSET_X + 25*2, OFFSET_Y - 80*2, parent, scene);
-       setZValue(10);
-
-//     for(int i=0; i<3; i++) {
-//             beacons[i] = new QGraphicsLineItem(parent, scene);
-//             beacon1->setLine(QLineF(OFFSET_X + ROBOT_SIZE_X/2,
-//                             OFFSET_Y + ROBOT_SIZE_Y/2, BEACON1_X, BEACON1_Y));
-//             beacons[i]->setPen(QPen(QBrush(Qt::cyan),
-//                             2, Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin));
-//             beacons[i]->setZValue(20);
-//     }
-//     beacon2 = new QGraphicsLineItem(parent, scene);
-//     beacon2->setLine(QLineF(OFFSET_X + ROBOT_SIZE_X/2,
-//                             OFFSET_Y + ROBOT_SIZE_Y/2, BEACON2_X, BEACON2_Y));
-//     beacon2->setPen(QPen(QBrush(Qt::cyan), 2, Qt::SolidLine,
-//                             Qt::SquareCap, Qt::BevelJoin));
-//     beacon2->setZValue(20);
-//     
-//     beacon3 = new QGraphicsLineItem(parent, scene);
-//     beacon3->setLine(QLineF(OFFSET_X + ROBOT_SIZE_X/2,
-//                             OFFSET_Y + ROBOT_SIZE_Y/2, BEACON3_X, BEACON3_Y));
-//     beacon3->setPen(QPen(QBrush(Qt::cyan), 2, Qt::SolidLine,
-//                             Qt::SquareCap, Qt::BevelJoin));
-//     beacon3->setZValue(20);
-//     
-//     pCenter = new QPoint(OFFSET_X + ROBOT_SIZE_X/2, 
-//                             420 - OFFSET_Y - ROBOT_SIZE_Y);
+       this->pen = pen;
+       this->brush = brush;
 }
 
 Robot::~Robot()
 {
 }
 
-void Robot::initBeacons()
-{      
-       setBeaconAngle(0,M_PI/4);
-       beacons[0]->setLine(pos().x() + ROBOT_SIZE_X/2,
-                       pos().y() + ROBOT_SIZE_Y/2, BEACON1_X, BEACON1_Y);
-       beacons[1]->setLine(pos().x() + ROBOT_SIZE_X/2,
-                       pos().y() + ROBOT_SIZE_Y/2, BEACON2_X, BEACON2_Y);
-       beacons[2]->setLine(pos().x() + ROBOT_SIZE_X/2,
-                       pos().y() + ROBOT_SIZE_Y/2, BEACON3_X, BEACON3_Y);
-}
-
-void Robot::setBeaconAngle(int idx, double angle)
-{
-       double y,x;
-       double c = 800;
-
-       angle += actPhi;
-       y = c*(sin(angle));
-       x = c*(cos(angle));
-
-       if (angle>M_PI) 
-               y = -y;
-       if ((angle>M_PI/2)&&(angle<3*M_PI/2)) 
-               x = -x;
-
-       printf("x %d, y %d\n", pCenter->x(), pCenter->y());
-//     printf("x %f, y %f, c %f, sin %f, cos %f\n",a,b,c,sin(angle),cos(angle));
-       beacons[idx]->setLine(0, 0, (int)x, (int)y);
-       beacons[idx]->moveBy(pCenter->x(), 420-pCenter->y());
-}
-
 QRectF Robot::boundingRect() const
 {
-       return QRectF(this->pos().x(), this->pos().y(), 
-                       ROBOT_SIZE_X+80, ROBOT_SIZE_Y+80);
+       return QRectF(0, 0, ROBOT_WIDTH_MM, ROBOT_AXIS_TO_BACK_MM + ROBOT_AXIS_TO_FRONT_MM);
 }
 
 void Robot::paint(QPainter *painter, 
@@ -134,31 +39,20 @@ void Robot::paint(QPainter *painter,
        Q_UNUSED(widget);
        Q_UNUSED(painter);
        
-//     painter->setPen(QPen(QBrush(Qt::black), 1, Qt::SolidLine, 
-//                             Qt::FlatCap, Qt::BevelJoin));
-//     painter->setBrush(QBrush(Qt::black));
-//     painter->drawRect(QRectF(OFFSET_X, OFFSET_Y, 
-//                             ROBOT_SIZE_X, ROBOT_SIZE_Y));
-}
-
-void Robot::sensorRange(qreal size, int sens_id)
-{      
-       qreal x1 = sensShort[sens_id]->line().x1();
-       qreal y1 = sensShort[sens_id]->line().y1();
-       qreal x2 = sensShort[sens_id]->line().x2();
-       qreal y2 = sensShort[sens_id]->line().y2();
-       
-       qreal dx = x1+size*(x2-x1);
-       qreal dy = y1+size*(y2-y1);     
-
-       sensShort[sens_id]->setLine(x1,y1,dx,dy);
-}
-
-void Robot::rotateRobot(qreal angle)
-{
-       translate(ROBOT_SIZE_X/2, ROBOT_SIZE_Y/2);
-       rotate(angle);
-       translate(-ROBOT_SIZE_X/2, -ROBOT_SIZE_Y/2);
+       painter->setPen(pen);
+       painter->setBrush(brush);
+       painter->drawRect(QRectF(0, 0, ROBOT_WIDTH_MM, 
+                         ROBOT_AXIS_TO_BACK_MM + ROBOT_AXIS_TO_FRONT_MM));
+       const float xa = ROBOT_WIDTH_MM/2.0;
+       const float ya = ROBOT_AXIS_TO_BACK_MM;
+       const float yb = ROBOT_AXIS_TO_BACK_MM + ROBOT_AXIS_TO_FRONT_MM*0.8;
+       const float yc = ROBOT_AXIS_TO_BACK_MM + ROBOT_AXIS_TO_FRONT_MM*0.4;
+       const float xd = ROBOT_WIDTH_MM/4.0;
+       QLineF arrow[] = { 
+               QLineF(xa, ya, xa, yb),
+               QLineF(xa, yb, xa-xd, yc),
+               QLineF(xa, yb, xa+xd, yc)};
+       painter->drawLines(arrow, 3);
 }
 
 void Robot::moveRobot(double x, double y, double phi)
@@ -167,11 +61,8 @@ void Robot::moveRobot(double x, double y, double phi)
 
        pos = PlaygroundScene::world2scene(pos);
        //TODO use this transpormation function
-    
-       setPos(x*100*2 - (ROBOT_SIZE_X/2),
-               420-ROBOT_SIZE_Y-(y*100*2)+(ROBOT_SIZE_Y/2));
-//     setPos(x*100*2-(ROBOT_SIZE_X),
-//             420-ROBOT_SIZE_Y-(y*100*2)+(ROBOT_SIZE_Y/2));
-       rotateRobot((actPhi-phi)*180/M_PI);
-       actPhi = phi;
+
+       setPos(x*1000, y*1000);
+       setTransform(QTransform().rotateRadians(phi-M_PI/2.0).translate(-ROBOT_WIDTH_MM/2.0, -ROBOT_AXIS_TO_BACK_MM));
 }
+
index 01f4bee60f3026cdf43d568c1193886debf53794..43718d53a6aed72cfaa208a7724ebd905aee6bbf 100644 (file)
 #include <QGraphicsLineItem>
 #include <QPainter>
 
-#define ROBOT_SIZE_X 30 * 2            // FIXME: add some comments (missing units, ...)
-#define ROBOT_SIZE_Y 30 * 2
-#define OFFSET_X 10
-#define OFFSET_Y 0
-#define SENSOR_SHORT_COUNT 6
-#define SENSOR_LONG_COUNT 10
-
-#define BEACON1_X 600 + OFFSET_X
-#define BEACON1_Y 210 + OFFSET_Y
-#define BEACON2_X 0 + OFFSET_X
-#define BEACON2_Y 420 + OFFSET_Y
-#define BEACON3_X 0 + OFFSET_X
-#define BEACON3_Y 0 + OFFSET_Y
-
 class Robot : public QGraphicsItem
 {
 public:
-       Robot(QGraphicsItem *parent = 0, QGraphicsScene *parentScene = 0, 
-                       Qt::GlobalColor color = Qt::black);
+       Robot(const QPen &pen = QPen(), const QBrush &brush = QBrush());
        ~Robot();
-
-       void initBeacons();
-       void setBeaconAngle(int, double);
-       void paint(QPainter *painter, 
-               const QStyleOptionGraphicsItem *option, QWidget *widget);
-       void sensorRange(qreal size, int sens_id);
-       void rotateRobot (qreal angle);
-       void moveRobot(double, double, double);
-
-       QGraphicsScene *scene;
-//     robotSensor *sens;
-       QGraphicsLineItem *sensShort[SENSOR_SHORT_COUNT];
-       QGraphicsLineItem *sensLong[SENSOR_LONG_COUNT];
-       QGraphicsRectItem *robotBody;
-       QGraphicsLineItem *beacons[3];
-       QPoint *pCenter;
        QRectF boundingRect() const;
-       char id;
-       qreal actPhi;
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+       void moveRobot(double x, double y, double angle);
+private:
+       QPen pen;
+       QBrush brush;
 };
 
 #endif
diff --git a/src/robomon/dimensions.h b/src/robomon/dimensions.h
deleted file mode 100644 (file)
index 684d8dc..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * dimension.h                 07/10/31
- *
- * Several definition of positions.
- *
- * Copyright: (c) 2007 CTU Dragons
- *            CTU FEE - Department of Control Engineering
- * Authors: Martin Zidek, Michal Sojka, Tran Duy Khanh
- * License: GNU GPL v.2
- */
-
-#ifndef DIMENSIONS_H
-#define DIMENSIONS_H
-
-#define RES_FACTOR 5
-#define RES_X 300 / RES_FACTOR
-#define RES_Y 210 / RES_FACTOR
-
-#define PG_X 600
-#define PG_Y 420
-
-#define TOP_LEFT QPointF(10,0)
-#define TOP_LEFT_X 10
-#define TOP_LEFT_Y 0
-#define TOP_MIDDLE QPointF(310,0)
-#define TOP_RIGHT QPointF(610,0)
-#define BOTTOM_LEFT QPointF(10,420)
-#define BOTTOM_MIDDLE QPointF(310,420)
-#define BOTTOM_RIGHT QPointF(610,420)
-#define BIN_LEFT_BOTTLE_START QPointF(5,320)
-#define BIN_LEFT_BOTTLE_END QPointF(5,420)
-#define BIN_LEFT_CAN_START QPointF(10,425)
-#define BIN_LEFT_CAN_END QPointF(110,425)
-#define BIN_RIGHT_BOTTLE_START QPointF(615,320)
-#define BIN_RIGHT_BOTTLE_END QPointF(615,420)
-#define BIN_RIGHT_CAN_START QPointF(510,425)
-#define BIN_RIGHT_CAN_END QPointF(610,425)
-
-#endif /* DIMENSIONS_H */
diff --git a/src/robomon/playgroundview.cpp b/src/robomon/playgroundview.cpp
new file mode 100644 (file)
index 0000000..a55c773
--- /dev/null
@@ -0,0 +1,20 @@
+//
+// C++ Implementation: playgroundview
+//
+// Description: 
+//
+//
+// Author: Michal Sojka <sojkam1@fel.cvut.cz>, (C) 2009
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "playgroundview.h"
+
+void PlaygroundView::resizeEvent(QResizeEvent * event)
+{
+       QGraphicsView::resizeEvent(event);
+       fitInView(scene()->itemsBoundingRect(), Qt::KeepAspectRatio);
+}
+
+
diff --git a/src/robomon/playgroundview.h b/src/robomon/playgroundview.h
new file mode 100644 (file)
index 0000000..dd4de27
--- /dev/null
@@ -0,0 +1,30 @@
+//
+// C++ Interface: playgroundview
+//
+// Description: 
+//
+//
+// Author: Michal Sojka <sojkam1@fel.cvut.cz>, (C) 2009
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef PLAYGROUNDVIEW_H
+#define PLAYGROUNDVIEW_H
+
+#include <QGraphicsView>
+
+/**
+       @author Michal Sojka <sojkam1@fel.cvut.cz>
+*/
+class PlaygroundView : public QGraphicsView
+{
+Q_OBJECT
+public:
+       PlaygroundView(QGraphicsScene * scene, QWidget * parent = 0) : QGraphicsView(scene, parent) {};
+protected:
+       void resizeEvent ( QResizeEvent * event );
+
+};
+
+#endif
index 461e997d811ac3a42c2891ec51e1597d24bd6a9e..1e792c2b597fb75533501a993047ec90f4549f56 100644 (file)
@@ -6,12 +6,11 @@ SOURCES += main.cpp \
            PlaygroundScene.cpp \
            Robot.cpp \
            SmallRobot.cpp \
-           MclPainter.cpp \
-           AnglesHistogramPainter.cpp \
            Widget.cpp \
            GlWidget.cpp \
            MiscGui.cpp \
-           robomon_orte.cpp
+           robomon_orte.cpp \
+ playgroundview.cpp
 
 TEMPLATE = app
 CONFIG += warn_on \
@@ -32,12 +31,11 @@ HEADERS += MainWindow.h \
            Robot.h \
            SmallRobot.h \
            Painter.h \
-           MclPainter.h \
-           AnglesHistogramPainter.h \
            Widget.h \
            GlWidget.h \
            MiscGui.h \
-           robomon_orte.h
+           robomon_orte.h \
+ playgroundview.h
 
 LIBS += -lm -lpthread -lmcl -llaser-nav -lrobodim -lrobomath -lroboorte \
                -lrobottype -lorte  -lsharp -lmap -lactlib