Skip to content
table.h 2.41 KiB
Newer Older
#ifndef TABLE_H_INCLUDED
#define TABLE_H_INCLUDED

#include <QWidget>
Alexandre Manoury's avatar
Alexandre Manoury committed
#include <QTime>

#include <Box2D.h>
#include "TableGraphics.h"
#include "XMLReader.h"
//#include "v1-archive/singleton.h"
#include "position.h"
#include "robot.h"
Victor Dubois's avatar
Victor Dubois committed
#include "contactlistener.h"
#include "../hardware/tourelle.h"
#include <QList>

Alexandre Manoury's avatar
Alexandre Manoury committed
#include "krabipacket.h"

class Table : public QWidget//, public Singleton<Table>
Alexandre Manoury's avatar
Alexandre Manoury committed
Q_OBJECT
    //friend class Singleton<Table>;
    std::vector<Objet*> objets;
    std::vector<Robot*> robots;
Victor Dubois's avatar
Victor Dubois committed
    ContactListener contactListenerTable;
Alexandre Manoury's avatar
Alexandre Manoury committed
    bool mHideTable, mDisplayRoute, mDisplayStrategy, mRemoteMod;

    long mTimerAdjust;

Alexandre Manoury's avatar
Alexandre Manoury committed
    QImage robotRoute;

    QTime mTime;

Alexandre Manoury's avatar
Alexandre Manoury committed
    PositionPlusAngle previousPos;
    bool previousPosition;

    static Table* _instance;
Alexandre Manoury's avatar
Alexandre Manoury committed
public slots:
    void createObjects();
    void removeAllObjects();
    void hideTable(bool hidden);
    void displayRoute(bool display);
    void displayStrategy(bool display);
    void setRemoteMod(bool remote);

ZHAO Fei's avatar
ZHAO Fei committed
    static const int tableHeight = 2000;
	static b2AABB getWorldAABB();
	//static const int tableWidth = 2100;
	//static const int tableHeight = 3000;

    static Table* getMainInstance();

    Table(MainWindow* mainWindow, QWidget* parent = 0, bool isYellow = true);
Alexandre Manoury's avatar
Alexandre Manoury committed
    void treat(KrabiPacket &packet);
    void watch(KrabiPacket &packet);

    void resetTimer();

	void keyPressEvent(QKeyEvent* evt, bool press);
    void mousePressEvent(QMouseEvent* evt, bool press);

    float getDistanceToObject(Position pos);
    void removeClosestObject(Position pos);
    Robot* getMainRobot();
    // Returns a list of the exact position of the beacons (i.e. other bots), in polar coordinates, relative to 'bot'.
    // By default, uses the main robot as reference
    QList</*Tourelle::*/PositionData> getBeaconsRelativePosition(Robot* bot = 0);

    float getCurrentTime();

    bool isInRemoteMod();

    void clearRoute();

    std::vector<Objet*> findObjectsNear(Position pos, Distance searchRadius = 0., Objet::Type type = Objet::ANY);