1 #include "mainwindow.h"
2 #include "timercontrolledtursas.h"
11 MainWindow::MainWindow(QWidget *parent)
16 pScene_ = new SeaScene ();
17 pView_ = new QGraphicsView ();
19 QPixmap waves (":/pix/meri.png");
20 pScene_->setBackgroundBrush(QBrush(waves));
22 pView_->setScene(pScene_);
23 setCentralWidget(pView_);
26 //the boundaries of the scene are set to match the size of the view window, which is not
27 //available in the constructor --> timer needed
28 QTimer::singleShot(100,this,SLOT(initializeBoundaries()));
33 MainWindow::~MainWindow()
38 void MainWindow::initializeBoundaries()
40 //the boundaries of the scene are set to match the size of the view window, and
41 //the view is set to show exactly the whole scene area
44 QSize windowsize = pView_->size();
45 QRectF rectangle (topleft,windowsize);
48 pScene_->setSceneRect(rectangle);
49 pView_->setSceneRect(rectangle);
51 qDebug() << "Initialized boundaries" << rectangle.left() << rectangle.right() << pView_->width();
53 pScene_->setupMap(5,5,5);
56 void MainWindow::pause(bool paused)
58 // qDebug() << "pause pressed " << paused;
59 if (paused_ == paused)
66 // qDebug() << "starting to move again";
67 pTursas_->startMoving();
72 qDebug("about to stop movement");
73 pTursas_->stopMoving();