void Gui::createLaserScannerObjects() { // the start position for the pos. calculation laserXPos = 0; laserYPos = 0; //laserFrontYPos = INITIALLASERYPOSFRONT; //laserRearYPos = INITIALLASERYPOSREAR; // set some nice colors for some widgets colorLaserObstacle = QColor(255, 50, 50); // light red colorLaserFreeWay = Qt::darkRed; colorLaserPreferredDrivingDirection = QColor(7, 68, 30); // green colorLaserCenterDrivingDirection = Qt::green; colorGraphicsSceneBackground = Qt::black; // the graphicsScene for the laser scanner scene = new LaserScene(); // set some colors scene->setBackgroundBrush(colorGraphicsSceneBackground); // turn off moving of scene, when objects extend the scene -> DISABLED to enable dragging the robot in the laserView!! // (set scene rect to size of GUI element) -> DISABLED to enable dragging the robot in the laserView!! //scene->setSceneRect(0, 0, ui.graphicsViewLaser->width(), ui.graphicsViewLaser->height()); -> DISABLED to enable dragging the robot in the laserView!! // set scene to the GUI ui.graphicsViewLaser->setScene(scene); // enable OpenGL rendering with antialiasing (and direct hardware rendering (if supportet from the hardware)) ui.graphicsViewLaser->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::DirectRendering))); //======================================================= // add robot picture1 //======================================================= // add items to the scene pixmapBot1 = new QGraphicsPixmapItem(QPixmap(":/images/images/bot_from_above.png")); // init the scale for the laser line / distances drawing stuff lastZoom = ui.sliderZoom->value(); //-------------------------------------------------------------- // set the start scale //-------------------------------------------------------------- startScale = 10; // change scale of the robot pic to 1/10 to fit in the window and to fit on the size of the laser lines pixmapBot1->scale( (1.0 / startScale), (1.0 / startScale)); // horizontal center pixmapBot1->setPos(laserXPos, laserYPos); // add the pixmap scene->addItem(pixmapBot1); // put one layer up (layer 2). All others share the same (unset) layer under the pixmap. pixmapBot1->setZValue(1); //===================================================== // create the laser line lists //===================================================== laserLineListFront = new QList <QGraphicsLineItem*>(); laserLineListRear = new QList <QGraphicsLineItem*>(); //------------------------------------- // create the FRONT laser line list //------------------------------------- // TODO: check if always 180 lines! // create 180 laser lines (0 to 179) for (int i=-90; i<90; i++) { QGraphicsLineItem *line = new QGraphicsLineItem(); // the length (and position) of the laser line in pixel line->setLine(0,0,0,0); // FIXME doest not work: line->setPen(QPen(colorLaserFreeWay, 3)); line->setPen(QPen(colorLaserFreeWay)); // set position of each line line->rotate(i); // put one layer up (layer 2). All others share the same (unset) layer under the pixmap. line->setZValue(2); // add line to QList laserLineListFront->append(line); // add line to scene scene->addItem(line); } //------------------------------------- // create the REAR laser line list //------------------------------------- // TODO: check if always 180 lines! // create 180 laser lines (0 to 179) for (int i=90; i>-90; i--) { QGraphicsLineItem *line = new QGraphicsLineItem(); // FIXME doest not work: line->setPen(QPen(colorLaserFreeWay, 3)); line->setPen(QPen(colorLaserFreeWay)); // the length (and position) of the laser line in pixel line->setLine(0,0,0,0); // set position of each line line->rotate(i); // put one layer up (layer 2). All others share the same (unset) layer under the pixmap. line->setZValue(2); // add line to QList laserLineListRear->append(line); // add line to scene scene->addItem(line); } //======================================================= // add robot picture2 //======================================================= // add items to the scene pixmapBot2 = new QGraphicsPixmapItem(QPixmap(":/images/images/bot_from_above_TOP2.png")); // change scale of the robot pic to 1/10 to fit in the window and to fit on the size of the laser lines pixmapBot2->scale( (1.0 / startScale), (1.0 / startScale)); // horizontal center pixmapBot2->setPos(laserXPos, laserYPos); // add the pixmap scene->addItem(pixmapBot2); // put one layer up (layer 2). All others share the same (unset) layer under the pixmap. pixmapBot2->setZValue(3); }