00001 #ifndef THYMIO_VISUAL_PROGRAMMING_H 00002 #define THYMIO_VISUAL_PROGRAMMING_H 00003 00004 #include <QDialog> 00005 #include <QVBoxLayout> 00006 #include <QHBoxLayout> 00007 #include <QGraphicsView> 00008 #include <QSvgRenderer> 00009 #include <QGraphicsSvgItem> 00010 #include <QGraphicsItem> 00011 #include <QGraphicsWidget> 00012 #include <QGraphicsLinearLayout> 00013 #include <QComboBox> 00014 #include <QToolBar> 00015 #include <QToolButton> 00016 00017 #include <dashel/dashel.h> 00018 00019 #include <map> 00020 #include <vector> 00021 #include <iterator> 00022 #include <QDomDocument> 00023 00024 #include "ThymioButtons.h" 00025 #include "ThymioScene.h" 00026 00027 #include "../../Plugin.h" 00028 #include "../../DashelTarget.h" 00029 00030 namespace Aseba 00031 { 00034 class ThymioVisualProgramming : public QDialog, public InvasivePlugin, public NodeToolInterface 00035 { 00036 Q_OBJECT 00037 00038 public: 00039 ThymioVisualProgramming(NodeTab* nodeTab); 00040 ~ThymioVisualProgramming(); 00041 00042 virtual QWidget* createMenuEntry(); 00043 virtual void closeAsSoonAsPossible(); 00044 00045 virtual void loadFromDom(const QDomDocument& content, bool fromFile); 00046 virtual QDomDocument saveToDom() const; 00047 //virtual bool surviveTabDestruction() const; 00048 00049 private slots: 00050 void showVPL(); 00051 void addButtonsEvent(); 00052 void addProxEvent(); 00053 void addProxGroundEvent(); 00054 void addTapEvent(); 00055 void addClapEvent(); 00056 00057 void addMoveAction(); 00058 void addColorAction(); 00059 void addCircleAction(); 00060 void addSoundAction(); 00061 void addMemoryAction(); 00062 00063 void newFile(); 00064 void openFile(); 00065 bool save(); 00066 bool saveAs(); 00067 void setColorScheme(int index); 00068 void run(); 00069 void stop(); 00070 void advancedMode(); 00071 void closeFile(); 00072 00073 void recompileButtonSet(); 00074 00075 protected: 00076 QGraphicsView *view; 00077 ThymioScene *scene; 00078 00079 // Event & Action buttons 00080 QList<ThymioPushButton *> eventButtons; 00081 QList<ThymioPushButton *> actionButtons; 00082 QLabel *eventsLabel; 00083 QLabel *actionsLabel; 00084 00085 QList<QColor> eventColors; 00086 QList<QColor> actionColors; 00087 00088 QLabel *compilationResult; 00089 QLabel *compilationResultImage; 00090 00091 QToolBar *toolBar; 00092 QToolButton *newButton; 00093 QToolButton *openButton; 00094 QToolButton *saveButton; 00095 QToolButton *saveAsButton; 00096 QToolButton *runButton; 00097 QToolButton *stopButton; 00098 QToolButton *advancedButton; 00099 QComboBox *colorComboButton; 00100 QToolButton *quitButton; 00101 00102 QVBoxLayout *mainLayout; 00103 QHBoxLayout *horizontalLayout; 00104 QVBoxLayout *eventsLayout; 00105 QVBoxLayout *sceneLayout; 00106 QHBoxLayout *compilationResultLayout; 00107 QVBoxLayout *actionsLayout; 00108 00109 00110 QSvgRenderer *tapSvg; 00111 QSvgRenderer *clapSvg; 00112 00113 QString thymioFilename; 00114 00115 int windowWidth; 00116 int windowHeight; 00117 00118 // we must cache this because during the flashing process, the tab is not there any more 00119 unsigned nodeId; 00120 // Target * target; 00121 // Dashel::Stream *stream; 00122 00123 QPixmap drawColorScheme(QColor color1, QColor color2); 00124 bool warningDialog(); 00125 void setColors(QComboBox *button = 0); 00126 void closeEvent(QCloseEvent * event); 00127 // bool saveFile(QString filename); 00128 // bool loadFile(QString filename); 00129 00130 virtual void resizeEvent( QResizeEvent *event ); 00131 }; 00133 }; // Aseba 00134 00135 #endif