ThymioScene.h
Go to the documentation of this file.
00001 #ifndef THYMIO_SCENE_H
00002 #define THYMIO_SCENE_H
00003 
00004 #include <QGraphicsScene>
00005 
00006 #include "ThymioButtons.h"
00007 
00008 namespace Aseba
00009 {       
00010         class ThymioScene : public QGraphicsScene
00011         {
00012                 Q_OBJECT
00013                 
00014         public:
00015                 ThymioScene(QObject *parent = 0);
00016                 ~ThymioScene();
00017                 
00018                 QGraphicsItem *addAction(ThymioButton *item);
00019                 QGraphicsItem *addEvent(ThymioButton *item);
00020                 void addButtonSet(ThymioButton *event, ThymioButton *action);
00021 
00022                 bool isEmpty() const;
00023                 void reset();
00024                 void clear();
00025                 void setColorScheme(QColor eventColor, QColor actionColor);
00026                 bool isModified() const { return sceneModified; }
00027                 void setModified(bool mod) { sceneModified=mod; }
00028                 void setScale(qreal scale);
00029                 void setAdvanced(bool advanced);
00030                 bool getAdvanced() const { return advancedMode; }
00031                 int getNumberOfButtonSets() const { return buttonSets.size(); }
00032                 
00033                 QString getErrorMessage() const;
00034                 QList<QString> getCode() const;
00035                 
00036                 bool isSuccessful() const { return  thymioCompiler.isSuccessful(); }
00037                 int getFocusItemId() const;
00038                 
00039                 typedef QList<ThymioButtonSet *>::iterator ButtonSetItr;
00040                 
00041                 ButtonSetItr buttonsBegin() { return buttonSets.begin(); }
00042                 ButtonSetItr buttonsEnd() { return buttonSets.end(); }
00043                 
00044         signals:
00045                 void stateChanged();
00046                 
00047         private slots:
00048                 void buttonUpdateDetected();
00049                 
00050         protected:
00051                 virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
00052                 virtual void dropEvent(QGraphicsSceneDragDropEvent *event);
00053 
00054                 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
00055                 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
00056 
00057         private:
00058                 void removeButton(int row);
00059                 void insertButton(int row);
00060                 void rearrangeButtons(int row=0);
00061                 
00062                 ThymioButtonSet *createNewButtonSet();
00063 
00064                 bool prevNewEventButton;
00065                 bool prevNewActionButton;
00066                 int lastFocus;
00067                 
00068                 QList<ThymioButtonSet *> buttonSets;
00069                 ThymioCompiler thymioCompiler;
00070                 
00071                 QColor eventButtonColor;
00072                 QColor actionButtonColor;
00073                 // TODO: set this always through a function and emit a signal when it is changed, to update windows title (see issue 154)
00074                 bool sceneModified;
00075                 double scaleFactor;
00076                 bool newRow;
00077                 qreal buttonSetHeight;
00078                 bool advancedMode;
00079         };
00080 };
00081 
00082 #endif


aseba
Author(s): Stéphane Magnenat
autogenerated on Thu Jan 2 2014 11:17:17