robotmodule.h 3.1 KB
Newer Older
1 2 3 4
#ifndef ROBOTMODULE_H
#define ROBOTMODULE_H

#include "robotmodulebase.h"
Alexander A. Maly's avatar
Alexander A. Maly committed
5 6 7 8 9
class QPushButton;
class QSpinBox;
class QTimer;


10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
class RoboPult;

namespace ActorRobot
{
class RobotModule;
class RobotView;
class RoboField;
class ConsoleField;

class RobotModule : public RobotModuleBase
{
	Q_OBJECT

public:
	static const RobotModule *self;
	static ExtensionSystem::SettingsPtr robotSettings() {
		return RobotModule::self->mySettings();
	}

	RobotModule(ExtensionSystem::KPlugin *parent);

	QSize minimumSize() const;

public slots:
	// Reset actor state before program starts
	void reset();
	void terminateEvaluation() {}
	void loadActorData(QIODevice *source);

	void setAnimationEnabled(bool enabled);
	static QList<ExtensionSystem::CommandLineParameter> acceptableCommandLineParameters();
	QString initialize(
		const QStringList &configurationParameters,
		const ExtensionSystem::CommandLine &runtimeParameters
	);

private:
	// Actor methods
	void runGoUp();
	void runGoDown();
	void runGoLeft();
	void runGoRight();
	void runDoPaint();
	bool runIsWallAtTop();
	bool runIsWallAtBottom();
	bool runIsWallAtLeft();
	bool runIsWallAtRight();
	bool runIsFreeAtTop();
	bool runIsFreeAtBottom();
	bool runIsFreeAtLeft();
	bool runIsFreeAtRight();
	bool runIsColor();
	bool runIsClear();
	qreal runRadiation();
	int runTemperature();
	void runFieldSize(int &rows, int &cols);
	bool runMark(const int row, const int col) ;
	bool runColored(const int row, const int col);
	void runRobotPos(int &row, int &col);
	int runCellTemp(const int row, const int col);
	qreal runCellRad(const int row, const int col);
	QChar runUpChar(const int row, const int col);
	QChar runDownChar(const int row, const int col);
	bool isSafeToQuit();

public:
	QWidget *mainWidget() const;
	QWidget *pultWidget() const;

public slots:
	void reloadSettings(ExtensionSystem::SettingsPtr settings, const QStringList &keys);
	void changeGlobalState(ExtensionSystem::GlobalState old, ExtensionSystem::GlobalState current);
	void loadEnv();
	void resetEnv();
	void save2png();
	void saveEnv();
	void editEnv();
	void newEnv();
	void createNewField();
	void createRescentMenu();
	void updateLastFiles(const QString newFile);
	void openRecent();
	void setWindowSize();
	void copyFromPult(QString log);
	void getTimer();

signals:
	void sendToPultLog(const QVariant&);

private:
	void createGui();
	void updateRobot();
	void createEmptyField(int rows, int cols);
	int LoadFromFile(QString p_FileName);
	int SaveToFile(QString p_FileName);

	QWidget *m_mainWidget;
	RoboPult *m_pultWidget;
	RoboField *field;
	RoboField *startField;
	bool animation;
	RobotView *view;
	QString curDir, curPDir;
	bool pressed;
	bool inDock;
	QPushButton *btnOK1;
	QPushButton *btnCancel1;  //Кнопки диалога новая обстановка
	QSpinBox *eXSizeEdit;
	QSpinBox *eYSizeEdit;
	QWidget *NewWindow;
	QMenu *rescentMenu;
	void prepareNewWindow();
	int CurCellSize;
	bool DISPLAY;
124
	QString oName;
125 126 127 128 129 130 131
	ExtensionSystem::SettingsPtr curSettings;
	ConsoleField *curConsoleField;
	QMutex mutex;
	ExtensionSystem::GlobalState currentState;
	QTimer *redrawTimer;

}; // RobotModule
132

133 134 135
} // ActorRobot

#endif // ROBOTMODULE_H