ThymioEventButtons.cpp
Go to the documentation of this file.
00001 #include <QPainter>
00002 
00003 #include <QGraphicsSceneMouseEvent>
00004 
00005 #include "ThymioButtons.h"
00006 
00007 namespace Aseba
00008 {
00009         // Buttons Event
00010         ThymioButtonsEvent::ThymioButtonsEvent(QGraphicsItem *parent, bool advanced) : 
00011                 ThymioButton(true, 1.0, true, advanced, parent)
00012         {       
00013                 setData(0, "event");
00014                 setData(1, "button");
00015                 
00016                 // top, left, bottom, right             
00017                 for(int i=0; i<4; i++) 
00018                 {
00019                         ThymioClickableButton *button = new ThymioClickableButton(QRectF(-25, -21.5, 50, 43), THYMIO_TRIANGULAR_BUTTON, 2, this);
00020 
00021                         qreal offset = (qreal)i;
00022                         button->setRotation(-90*offset);
00023                         button->setPos(128 - 70*qSin(1.57079633*offset), 
00024                                                    128 - 70*qCos(1.57079633*offset));
00025                         button->setButtonColor(Qt::green);
00026                         
00027                         thymioButtons.push_back(button);
00028 
00029                         connect(button, SIGNAL(stateChanged()), this, SLOT(updateIRButton()));
00030                 }
00031 
00032                 ThymioClickableButton *button = new ThymioClickableButton(QRectF(-25, -25, 50, 50), THYMIO_CIRCULAR_BUTTON, 2, this);
00033                 button->setPos(QPointF(128, 128));
00034                 button->setButtonColor(Qt::green);
00035                 thymioButtons.push_back(button);
00036                 connect(button, SIGNAL(stateChanged()), this, SLOT(updateIRButton()));
00037         }
00038                         
00039         // Prox Event
00040         ThymioProxEvent::ThymioProxEvent(QGraphicsItem *parent, bool advanced) : 
00041                 ThymioButton(true, 1.0, true, advanced, parent)
00042         {
00043                 setData(0, "event");
00044                 setData(1, "prox");
00045                 
00046                 for(int i=0; i<5; ++i) 
00047                 {
00048                         ThymioClickableButton *button = new ThymioClickableButton(QRectF(-16,-16,32,32), THYMIO_RECTANGULAR_BUTTON, 3, this);   
00049                         
00050                         qreal offset = (qreal)2-i;
00051                         button->setRotation(-20*offset);
00052                         button->setPos(128 - 150*qSin(0.34906585*offset) , 
00053                                                    175 - 150*qCos(0.34906585*offset) );
00054                         button->setBeginButtonColor(QColor(110,255,110));
00055                         button->setButtonColor(QColor(230,0,0));
00056 
00057                         thymioButtons.push_back(button);
00058                         
00059                         connect(button, SIGNAL(stateChanged()), this, SLOT(updateIRButton()));                  
00060                 }
00061                 
00062                 for(int i=0; i<2; ++i) 
00063                 {
00064                         ThymioClickableButton *button = new ThymioClickableButton(QRectF(-16,-16,32,32), THYMIO_RECTANGULAR_BUTTON, 3, this);   
00065 
00066                         button->setPos(QPointF(64 + i*128, 234));
00067                         button->setBeginButtonColor(QColor(110,255,110));
00068                         button->setButtonColor(QColor(230,0,0));
00069                         
00070                         thymioButtons.push_back(button);
00071                         
00072                         connect(button, SIGNAL(stateChanged()), this, SLOT(updateIRButton()));
00073                 }
00074 
00075         }
00076         
00077         // Prox Ground Event
00078         ThymioProxGroundEvent::ThymioProxGroundEvent( QGraphicsItem *parent, bool advanced ) : 
00079                 ThymioButton(true, 1.0, false, advanced, parent)
00080         {
00081                 setData(0, "event");
00082                 setData(1, "proxground");
00083                 
00084                 for(int i=0; i<2; ++i) 
00085                 {
00086                         ThymioClickableButton *button = new ThymioClickableButton(QRectF(-16,-16,32,32), THYMIO_RECTANGULAR_BUTTON, 3, this);   
00087 
00088                         button->setPos(QPointF(98 + i*60, 40));
00089                         button->setBeginButtonColor(QColor(110,255,110));
00090                         button->setButtonColor(QColor(230,0,0));
00091                         
00092                         thymioButtons.push_back(button);
00093                         
00094                         connect(button, SIGNAL(stateChanged()), this, SLOT(updateIRButton()));
00095                 }
00096         }       
00097                         
00098         // Tap Event
00099         ThymioTapEvent::ThymioTapEvent( QGraphicsItem *parent, bool advanced ) :
00100                 ThymioButton(true, 1.0, true, advanced, parent)
00101         {
00102                 setData(0, "event");
00103                 setData(1, "tap");
00104                 
00105                 delete(thymioBody);
00106                 thymioBody=0;
00107         }
00108         
00109         
00110         // Clap Event
00111         ThymioClapEvent::ThymioClapEvent( QGraphicsItem *parent, bool advanced ) :
00112                 ThymioButton(true, 1.0, true, advanced, parent)
00113         {               
00114                 setData(0, "event");            
00115                 setData(1, "clap");
00116                 
00117                 delete(thymioBody);
00118                 thymioBody=0;
00119         }
00120         
00121 
00122 };
00123 


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