~joerg-ehrichs/botrace/master

« back to all changes in this revision

Viewing changes to src/client/gamesimulationitem.h

  • Committer: Jörg Ehrichs
  • Date: 2012-07-24 18:55:17 UTC
  • Revision ID: git-v1:7b1838990c4571e7af3bf6f3ff6ded57d3519ffe
minor cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#ifndef GAMESIMULATIONITEM_H
19
19
#define GAMESIMULATIONITEM_H
20
20
 
21
 
#include <QGraphicsItem>
 
21
#include <QGraphicsPixmapItem>
22
22
#include <QObject>
23
23
 
24
 
#include "ki/robosimulator.h"
25
 
#include "renderer/bottheme.h"
26
 
 
27
24
namespace BotRace {
28
25
namespace Core {
29
 
class BoardManager;
30
 
class AbstractClient;
31
 
class RoboSimulator;
 
26
    class BoardManager;
 
27
    class AbstractClient;
 
28
    class RoboSimulator;
 
29
}
 
30
namespace Renderer {
 
31
    class BotTheme;
32
32
}
33
33
namespace Client {
34
34
 
35
 
class GameSimulationItem : public QObject, public QGraphicsItem
 
35
/**
 
36
 * @brief The simulation Pixmap item to indicate where the robot will end up after the execution of the current cards
 
37
 *
 
38
 * Useful to find out where the robot might end. Uses the RoboSimulator to figure out the endposition without taking other robots into account.
 
39
 */
 
40
class GameSimulationItem : public QObject, public QGraphicsPixmapItem
36
41
{
37
42
    Q_OBJECT
38
 
    Q_INTERFACES( QGraphicsItem );
 
43
    Q_INTERFACES( QGraphicsItem )
39
44
public:
 
45
    /**
 
46
     * @brief Constructs a new Item
 
47
     * @param renderer the BotTheme renderer for the used item
 
48
     * @param parent the parent item (the GameBoard)
 
49
     */
40
50
    explicit GameSimulationItem(Renderer::BotTheme *renderer, QGraphicsItem *parent = 0);
41
51
 
 
52
    /**
 
53
     * @brief Sets the client which will be used for the simulation
 
54
     * @param client the client which cards are used
 
55
     */
42
56
    void setClient(Core::AbstractClient *client);
43
57
 
44
 
    QRectF boundingRect() const;
45
 
    void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 );
46
 
 
47
58
public slots:
 
59
    /**
 
60
     * @brief Sets the new tile size. Will be called whenenver the gamewindow will be resized
 
61
     * @param sizeOfOneTile th enew size of one boardtile (and thus the robot)
 
62
     */
48
63
    void setTileSize( const QSizeF &sizeOfOneTile );
 
64
 
 
65
    /**
 
66
     * @brief Updates the pixmap when the renderer has a new version of it. Or the bottheme was changes
 
67
     */
 
68
    void updatePixmap();
 
69
 
 
70
    /**
 
71
     * @brief Simulates the current card movements
 
72
     *
 
73
     * Takes all cards in the current CardDeck and simulates where the robot might end.
 
74
     * Ignores any further cards if one card in the middle is missing.
 
75
     * Does not simulate pushing of other robots
 
76
     */
49
77
    void updateSimulation();
50
78
 
51
79
private:
52
 
    QSizeF m_sizeOfTheBoard;
53
 
    QSizeF m_sizeOfOneTile;
54
 
 
55
 
    Core::AbstractClient* m_client;
56
 
    Renderer::BotTheme *m_renderer;
57
 
    Core::RoboSimulator* m_simulator;
58
 
 
59
 
    Core::RoboSimulator::RobotSimResult m_simulationResult;
60
 
    
 
80
    QSizeF m_sizeOfOneTile;             /**< Caches size of one tile */
 
81
 
 
82
    Core::AbstractClient *m_client;     /**< Pointer to the client which Carddeck is used */
 
83
    Renderer::BotTheme   *m_renderer;   /**< The Bottheme for the simulation pixmap */
 
84
    Core::RoboSimulator  *m_simulator;  /**< The simulator used for the simulation */
61
85
};
62
86
 
63
87
}