00001 #include <QCloseEvent>
00002 #include <QMessageBox>
00003 #include <QPushButton>
00004 #include <QComboBox>
00005 #include <QLabel>
00006 #include <QSizePolicy>
00007 #include <QFileDialog>
00008 #include <QFile>
00009 #include <QDomElement>
00010 #include <QDesktopWidget>
00011 #include <QApplication>
00012
00013
00014
00015 #include "ThymioVisualProgramming.h"
00016 #include "ThymioVisualProgramming.moc"
00017 #include "../../TargetModels.h"
00018
00019 using namespace std;
00020
00021 namespace Aseba
00022 {
00023
00024 ThymioVisualProgramming::ThymioVisualProgramming(NodeTab* nodeTab):
00025 InvasivePlugin(nodeTab),
00026 windowWidth(900),
00027 windowHeight(800)
00028 {
00029
00030 setWindowTitle(tr("Thymio Visual Programming Language"));
00031
00032 resize(windowWidth, windowHeight);
00033 setMinimumSize(QSize(450,400));
00034
00035 mainLayout = new QVBoxLayout(this);
00036
00037 toolBar = new QToolBar();
00038 toolBar->setMaximumHeight(36);
00039 toolBar->setIconSize(QSize(24,24));
00040 toolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
00041 mainLayout->addWidget(toolBar);
00042
00043 newButton = new QToolButton();
00044 openButton = new QToolButton();
00045 saveButton = new QToolButton();
00046 saveAsButton = new QToolButton();
00047 runButton = new QToolButton();
00048 stopButton = new QToolButton();
00049 colorComboButton = new QComboBox();
00050 advancedButton = new QToolButton();
00051 quitButton = new QToolButton();
00052
00053 newButton->setIcon(QIcon(":/images/filenew.svgz"));
00054 newButton->setToolTip(tr("New"));
00055
00056 openButton->setIcon(QIcon(":/images/fileopen.svgz"));
00057 openButton->setToolTip(tr("Open"));
00058
00059 saveButton->setIcon(QIcon(":/images/save.svgz"));
00060 saveButton->setToolTip(tr("Save"));
00061
00062 saveAsButton->setIcon(QIcon(":/images/saveas.svgz"));
00063 saveAsButton->setToolTip(tr("Save as"));
00064
00065 runButton->setIcon(QIcon(":/images/play.svgz"));
00066 runButton->setToolTip(tr("Load & Run"));
00067
00068 stopButton->setIcon(QIcon(":/images/stop1.png"));
00069 stopButton->setToolTip(tr("Stop"));
00070
00071 colorComboButton->setToolTip(tr("Color scheme"));
00072 setColors(colorComboButton);
00073
00074
00075 advancedButton->setIcon(QIcon(":/images/run.png"));
00076 advancedButton->setToolTip(tr("Advanced mode"));
00077
00078 quitButton->setIcon(QIcon(":/images/exit.svgz"));
00079 quitButton->setToolTip(tr("Quit"));
00080
00081 toolBar->addWidget(newButton);
00082 toolBar->addWidget(openButton);
00083 toolBar->addWidget(saveButton);
00084 toolBar->addWidget(saveAsButton);
00085 toolBar->addSeparator();
00086 toolBar->addWidget(runButton);
00087 toolBar->addWidget(stopButton);
00088 toolBar->addSeparator();
00089 toolBar->addWidget(colorComboButton);
00090 toolBar->addSeparator();
00091 toolBar->addWidget(advancedButton);
00092 toolBar->addSeparator();
00093 toolBar->addWidget(quitButton);
00094
00095 connect(newButton, SIGNAL(clicked()), this, SLOT(newFile()));
00096 connect(openButton, SIGNAL(clicked()), this, SLOT(openFile()));
00097 connect(saveButton, SIGNAL(clicked()), this, SLOT(save()));
00098 connect(saveAsButton, SIGNAL(clicked()), this, SLOT(saveAs()));
00099 connect(colorComboButton, SIGNAL(currentIndexChanged(int)), this, SLOT(setColorScheme(int)));
00100 connect(quitButton, SIGNAL(clicked()), this, SLOT(closeFile()));
00101 connect(runButton, SIGNAL(clicked()), this, SLOT(run()));
00102 connect(stopButton, SIGNAL(clicked()), this, SLOT(stop()));
00103 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advancedMode()));
00104
00105 horizontalLayout = new QHBoxLayout();
00106 mainLayout->addLayout(horizontalLayout);
00107
00108
00109 eventsLayout = new QVBoxLayout();
00110
00111 tapSvg = new QSvgRenderer(QString(":/images/thymiotap.svg"));
00112 clapSvg = new QSvgRenderer(QString(":/images/thymioclap.svg"));
00113
00114 ThymioPushButton *buttonsButton = new ThymioPushButton("button");
00115 ThymioPushButton *proxButton = new ThymioPushButton("prox");
00116 ThymioPushButton *proxGroundButton = new ThymioPushButton("proxground");
00117 ThymioPushButton *tapButton = new ThymioPushButton("tap", tapSvg);
00118 ThymioPushButton *clapButton = new ThymioPushButton("clap", clapSvg);
00119
00120 eventButtons.push_back(buttonsButton);
00121 eventButtons.push_back(proxButton);
00122 eventButtons.push_back(proxGroundButton);
00123 eventButtons.push_back(tapButton);
00124 eventButtons.push_back(clapButton);
00125
00126 eventsLabel = new QLabel(tr("<b>Events</b>"));
00127 eventsLayout->setAlignment(Qt::AlignTop);
00128 eventsLayout->setSpacing(10);
00129 eventsLayout->addWidget(eventsLabel);
00130 eventsLayout->addWidget(buttonsButton);
00131 eventsLayout->addWidget(proxButton);
00132 eventsLayout->addWidget(proxGroundButton);
00133 eventsLayout->addWidget(tapButton);
00134 eventsLayout->addWidget(clapButton);
00135
00136 horizontalLayout->addLayout(eventsLayout);
00137
00138 sceneLayout = new QVBoxLayout();
00139
00140
00141 compilationResultImage = new QLabel();
00142 compilationResult = new QLabel(tr("Compilation success."));
00143
00144 compilationResultImage->setPixmap(QPixmap(QString(":/images/ok.png")));
00145 compilationResult->setWordWrap(true);
00146 compilationResult->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
00147
00148 compilationResultLayout = new QHBoxLayout;
00149 compilationResultLayout->addWidget(compilationResultImage);
00150 compilationResultLayout->addWidget(compilationResult,10000);
00151 sceneLayout->addLayout(compilationResultLayout);
00152
00153
00154 scene = new ThymioScene(this);
00155 view = new QGraphicsView(scene);
00156 view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
00157 view->setRenderHint(QPainter::Antialiasing);
00158 view->setAcceptDrops(true);
00159 view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
00160 view->centerOn(200,0);
00161 sceneLayout->addWidget(view);
00162
00163 connect(scene, SIGNAL(stateChanged()), this, SLOT(recompileButtonSet()));
00164
00165 horizontalLayout->addLayout(sceneLayout);
00166
00167
00168 actionsLayout = new QVBoxLayout();
00169
00170 ThymioPushButton *moveButton = new ThymioPushButton("move");
00171 ThymioPushButton *colorButton = new ThymioPushButton("color");
00172 ThymioPushButton *circleButton = new ThymioPushButton("circle");
00173 ThymioPushButton *soundButton = new ThymioPushButton("sound");
00174 ThymioPushButton *memoryButton = new ThymioPushButton("memory");
00175 actionsLabel = new QLabel(tr("<b>Actions</b>"));
00176
00177 actionButtons.push_back(moveButton);
00178 actionButtons.push_back(colorButton);
00179 actionButtons.push_back(circleButton);
00180 actionButtons.push_back(soundButton);
00181 actionButtons.push_back(memoryButton);
00182
00183 actionsLayout->setAlignment(Qt::AlignTop);
00184 actionsLayout->setSpacing(10);
00185 actionsLayout->addWidget(actionsLabel);
00186 actionsLayout->addWidget(moveButton);
00187 actionsLayout->addWidget(colorButton);
00188 actionsLayout->addWidget(circleButton);
00189 actionsLayout->addWidget(soundButton);
00190 actionsLayout->addWidget(memoryButton);
00191
00192 memoryButton->hide();
00193
00194 horizontalLayout->addLayout(actionsLayout);
00195
00196
00197 connect(buttonsButton, SIGNAL(clicked()),this,SLOT(addButtonsEvent()));
00198 connect(proxButton, SIGNAL(clicked()), this, SLOT(addProxEvent()));
00199 connect(proxGroundButton, SIGNAL(clicked()), this, SLOT(addProxGroundEvent()));
00200 connect(tapButton, SIGNAL(clicked()), this, SLOT(addTapEvent()));
00201 connect(clapButton, SIGNAL(clicked()), this, SLOT(addClapEvent()));
00202
00203 connect(moveButton, SIGNAL(clicked()), this, SLOT(addMoveAction()));
00204 connect(colorButton, SIGNAL(clicked()), this, SLOT(addColorAction()));
00205 connect(circleButton, SIGNAL(clicked()), this, SLOT(addCircleAction()));
00206 connect(soundButton, SIGNAL(clicked()), this, SLOT(addSoundAction()));
00207 connect(memoryButton, SIGNAL(clicked()), this, SLOT(addMemoryAction()));
00208
00209 QRect clientRect = QApplication::desktop()->availableGeometry();
00210
00211 if( clientRect.width() < (windowWidth+100) || clientRect.height() < (windowHeight+100) )
00212 resize(clientRect.width()-100, clientRect.height()-100);
00213 }
00214
00215 ThymioVisualProgramming::~ThymioVisualProgramming()
00216 {
00217 delete(tapSvg);
00218 delete(clapSvg);
00219 }
00220
00221 void ThymioVisualProgramming::setColors(QComboBox *button)
00222 {
00223 eventColors.push_back(QColor(0,191,255)); actionColors.push_back(QColor(218,112,214));
00224 eventColors.push_back(QColor(155,48,255)); actionColors.push_back(QColor(159,182,205));
00225 eventColors.push_back(QColor(67,205,128)); actionColors.push_back(QColor(0,197,205));
00226 eventColors.push_back(QColor(255,215,0)); actionColors.push_back(QColor(255,99,71));
00227 eventColors.push_back(QColor(255,97,3)); actionColors.push_back(QColor(142,56,142));
00228 eventColors.push_back(QColor(125,158,192)); actionColors.push_back(QColor(56,142,142));
00229
00230 if( button )
00231 {
00232 for(int i=0; i<eventColors.size(); ++i)
00233 button->addItem(drawColorScheme(eventColors.at(i), actionColors.at(i)), "");
00234 }
00235 }
00236
00237 QPixmap ThymioVisualProgramming::drawColorScheme(QColor color1, QColor color2)
00238 {
00239 QPixmap pixmap(128,58);
00240 pixmap.fill(Qt::transparent);
00241 QPainter painter(&pixmap);
00242
00243 painter.setBrush(color1);
00244 painter.drawRoundedRect(0,0,54,54,4,4);
00245
00246 painter.setBrush(color2);
00247 painter.drawRoundedRect(66,0,54,54,4,4);
00248
00249 return pixmap;
00250 }
00251
00252 QWidget* ThymioVisualProgramming::createMenuEntry()
00253 {
00254 QPushButton *vplButton = new QPushButton(tr("Launch VPL"));
00255 connect(vplButton, SIGNAL(clicked()), SLOT(showVPL()));
00256 return vplButton;
00257 }
00258
00259 void ThymioVisualProgramming::closeAsSoonAsPossible()
00260 {
00261 advancedButton->setEnabled(true);
00262 actionButtons.last()->hide();
00263
00264 scene->reset();
00265 close();
00266 }
00267
00268 void ThymioVisualProgramming::showVPL()
00269 {
00270 if (InvasivePlugin::newFile())
00271 exec();
00272 }
00273
00274 void ThymioVisualProgramming::newFile()
00275 {
00276 if( !scene->isEmpty() && warningDialog() )
00277 {
00278 bool advanced = scene->getAdvanced();
00279 scene->reset();
00280 thymioFilename.clear();
00281 scene->setAdvanced(advanced);
00282 }
00283 }
00284
00285 void ThymioVisualProgramming::openFile()
00286 {
00287 if( scene->isEmpty() || warningDialog() )
00288 InvasivePlugin::openFile();
00289 }
00290
00291 bool ThymioVisualProgramming::save()
00292 {
00293 return InvasivePlugin::saveFile(false);
00294 }
00295
00296 bool ThymioVisualProgramming::saveAs()
00297 {
00298 return InvasivePlugin::saveFile(true);
00299 }
00300
00301 void ThymioVisualProgramming::closeFile()
00302 {
00303 if( scene->isEmpty() || warningDialog() )
00304 {
00305 advancedButton->setEnabled(true);
00306 actionButtons.last()->hide();
00307 scene->reset();
00308 close();
00309 }
00310 }
00311
00312 void ThymioVisualProgramming::setColorScheme(int index)
00313 {
00314 scene->setColorScheme(eventColors.at(index), actionColors.at(index));
00315
00316 for(QList<ThymioPushButton*>::iterator itr = eventButtons.begin();
00317 itr != eventButtons.end(); ++itr)
00318 (*itr)->changeButtonColor(eventColors.at(index));
00319
00320 for(QList<ThymioPushButton*>::iterator itr = actionButtons.begin();
00321 itr != actionButtons.end(); ++itr)
00322 (*itr)->changeButtonColor(actionColors.at(index));
00323 }
00324
00325 void ThymioVisualProgramming::run()
00326 {
00327 if(runButton->isEnabled())
00328 loadNrun();
00329 }
00330
00331 void ThymioVisualProgramming::stop()
00332 {
00333 InvasivePlugin::stop();
00334 const unsigned leftSpeedVarPos = getVariablesModel()->getVariablePos("motor.left.target");
00335 setVariableValues(leftSpeedVarPos, VariablesDataVector(1, 0));
00336 const unsigned rightSpeedVarPos = getVariablesModel()->getVariablePos("motor.right.target");
00337 setVariableValues(rightSpeedVarPos, VariablesDataVector(1, 0));
00338 }
00339
00340 void ThymioVisualProgramming::advancedMode()
00341 {
00342 advancedButton->setEnabled(false);
00343 actionButtons.last()->show();
00344 scene->setAdvanced(true);
00345 }
00346
00347 void ThymioVisualProgramming::closeEvent ( QCloseEvent * event )
00348 {
00349 if ( scene->isEmpty() || warningDialog() )
00350 {
00351 advancedButton->setEnabled(true);
00352 actionButtons.last()->hide();
00353
00354 scene->reset();
00355 close();
00356 }
00357 else
00358 event->ignore();
00359 }
00360
00361 bool ThymioVisualProgramming::warningDialog()
00362 {
00363 if(!scene->isModified())
00364 return true;
00365
00366 QMessageBox msgBox;
00367 msgBox.setWindowTitle(tr("Warning"));
00368 msgBox.setText(tr("The VPL document has been modified."));
00369 msgBox.setInformativeText(tr("Do you want to save the changes?"));
00370 msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
00371 msgBox.setDefaultButton(QMessageBox::Save);
00372
00373 int ret = msgBox.exec();
00374 switch (ret)
00375 {
00376 case QMessageBox::Save:
00377 if (save())
00378 return true;
00379 else
00380 return false;
00381 case QMessageBox::Discard:
00382 return true;
00383 case QMessageBox::Cancel:
00384 default:
00385 return false;
00386 }
00387
00388 return false;
00389 }
00390
00391 QDomDocument ThymioVisualProgramming::saveToDom() const
00392 {
00393
00394
00395 if (scene->getNumberOfButtonSets() == 0)
00396 return QDomDocument();
00397 if ((scene->getNumberOfButtonSets() == 1) &&
00398 (!(*scene->buttonsBegin())->eventExists()) &&
00399 (!(*scene->buttonsBegin())->actionExists()))
00400 return QDomDocument();
00401
00402 QDomDocument document("tool-plugin-data");
00403
00404 QDomElement vplroot = document.createElement("vplroot");
00405 document.appendChild(vplroot);
00406
00407 QDomElement settings = document.createElement("settings");
00408 settings.setAttribute("advanced-mode", scene->getAdvanced() ? "true" : "false");
00409 settings.setAttribute("color-scheme", QString::number(colorComboButton->currentIndex()));
00410 vplroot.appendChild(settings);
00411 vplroot.appendChild(document.createTextNode("\n\n"));
00412
00413 for (ThymioScene::ButtonSetItr itr = scene->buttonsBegin();
00414 itr != scene->buttonsEnd(); ++itr )
00415 {
00416 QDomElement element = document.createElement("buttonset");
00417
00418 if( (*itr)->eventExists() )
00419 {
00420 ThymioButton *button = (*itr)->getEventButton();
00421 element.setAttribute("event-name", button->getName() );
00422
00423 for(int i=0; i<button->getNumButtons(); ++i)
00424 element.setAttribute( QString("eb%0").arg(i), button->isClicked(i));
00425 element.setAttribute("state", button->getState());
00426 }
00427
00428 if( (*itr)->actionExists() )
00429 {
00430 ThymioButton *button = (*itr)->getActionButton();
00431 element.setAttribute("action-name", button->getName() );
00432 for(int i=0; i<button->getNumButtons(); ++i)
00433 element.setAttribute(QString("ab%0").arg(i), button->isClicked(i));
00434 }
00435
00436 vplroot.appendChild(element);
00437 vplroot.appendChild(document.createTextNode("\n\n"));
00438 }
00439
00440 scene->setModified(false);
00441
00442 return document;
00443 }
00444
00445 void ThymioVisualProgramming::loadFromDom(const QDomDocument& document, bool fromFile)
00446 {
00447 scene->clear();
00448
00449 QDomNode domNode = document.documentElement().firstChild();
00450
00451 while (!domNode.isNull())
00452 {
00453 if (domNode.isElement())
00454 {
00455 QDomElement element = domNode.toElement();
00456 if (element.tagName() == "settings")
00457 {
00458 if( element.attribute("advanced-mode") == "true" )
00459 advancedMode();
00460 else
00461 {
00462 advancedButton->setEnabled(true);
00463 actionButtons.last()->hide();
00464 scene->setAdvanced(false);
00465 }
00466
00467 colorComboButton->setCurrentIndex(element.attribute("color-scheme").toInt());
00468 }
00469 else if(element.tagName() == "buttonset")
00470 {
00471 QString buttonName;
00472 ThymioButton *eventButton = 0;
00473 ThymioButton *actionButton = 0;
00474
00475 if( !(buttonName = element.attribute("event-name")).isEmpty() )
00476 {
00477
00478 if ( buttonName == "button" )
00479 eventButton = new ThymioButtonsEvent(0,scene->getAdvanced());
00480 else if ( buttonName == "prox" )
00481 eventButton = new ThymioProxEvent(0,scene->getAdvanced());
00482 else if ( buttonName == "proxground" )
00483 eventButton = new ThymioProxGroundEvent(0,scene->getAdvanced());
00484 else if ( buttonName == "tap" )
00485 {
00486 eventButton = new ThymioTapEvent(0,scene->getAdvanced());
00487 eventButton->setSharedRenderer(tapSvg);
00488 }
00489 else if ( buttonName == "clap" )
00490 {
00491 eventButton = new ThymioClapEvent(0,scene->getAdvanced());
00492 eventButton->setSharedRenderer(clapSvg);
00493 }
00494 else
00495 {
00496 QMessageBox::warning(this,tr("Loading"),
00497 tr("Error in XML source file: %0 unknown event type").arg(buttonName));
00498 return;
00499 }
00500
00501 for(int i=0; i<eventButton->getNumButtons(); ++i)
00502 eventButton->setClicked(i,element.attribute(QString("eb%0").arg(i)).toInt());
00503
00504 eventButton->setState(element.attribute("state").toInt());
00505 }
00506
00507 if( !(buttonName = element.attribute("action-name")).isEmpty() )
00508 {
00509 if ( buttonName == "move" )
00510 actionButton = new ThymioMoveAction();
00511 else if ( buttonName == "color" )
00512 actionButton = new ThymioColorAction();
00513 else if ( buttonName == "circle" )
00514 actionButton = new ThymioCircleAction();
00515 else if ( buttonName == "sound" )
00516 actionButton = new ThymioSoundAction();
00517 else if ( buttonName == "memory" )
00518 actionButton = new ThymioMemoryAction();
00519 else
00520 {
00521 QMessageBox::warning(this,tr("Loading"),
00522 tr("Error in XML source file: %0 unknown event type").arg(buttonName));
00523 return;
00524 }
00525
00526 for(int i=0; i<actionButton->getNumButtons(); ++i)
00527 actionButton->setClicked(i,element.attribute(QString("ab%0").arg(i)).toInt());
00528 }
00529
00530 scene->addButtonSet(eventButton, actionButton);
00531 }
00532 }
00533 domNode = domNode.nextSibling();
00534 }
00535
00536 scene->setModified(!fromFile);
00537
00538 if (!scene->isEmpty())
00539 QTimer::singleShot(0, this, SLOT(exec()));
00540 }
00541
00542 void ThymioVisualProgramming::recompileButtonSet()
00543 {
00544 compilationResult->setText(scene->getErrorMessage());
00545
00546 if( scene->isSuccessful() )
00547 {
00548 compilationResultImage->setPixmap(QPixmap(QString(":/images/ok.png")));
00549 displayCode(scene->getCode(), scene->getFocusItemId());
00550 runButton->setEnabled(true);
00551 }
00552 else
00553 {
00554 compilationResultImage->setPixmap(QPixmap(QString(":/images/warning.png")));
00555 runButton->setEnabled(false);
00556 }
00557 }
00558
00559 void ThymioVisualProgramming::addButtonsEvent()
00560 {
00561 ThymioButtonsEvent *button = new ThymioButtonsEvent(0, scene->getAdvanced());
00562 scene->setFocus();
00563 view->centerOn(scene->addEvent(button));
00564 }
00565
00566 void ThymioVisualProgramming::addProxEvent()
00567 {
00568 ThymioProxEvent *button = new ThymioProxEvent(0, scene->getAdvanced());
00569 scene->setFocus();
00570 view->centerOn(scene->addEvent(button));
00571 }
00572
00573 void ThymioVisualProgramming::addProxGroundEvent()
00574 {
00575 ThymioProxGroundEvent *button = new ThymioProxGroundEvent(0, scene->getAdvanced());
00576 scene->setFocus();
00577 view->centerOn(scene->addEvent(button));
00578 }
00579
00580 void ThymioVisualProgramming::addTapEvent()
00581 {
00582 ThymioTapEvent *button = new ThymioTapEvent(0, scene->getAdvanced());
00583 button->setSharedRenderer(tapSvg);
00584 scene->setFocus();
00585 view->centerOn(scene->addEvent(button));
00586 }
00587
00588 void ThymioVisualProgramming::addClapEvent()
00589 {
00590 ThymioClapEvent *button = new ThymioClapEvent(0, scene->getAdvanced());
00591 button->setSharedRenderer(clapSvg);
00592 scene->setFocus();
00593 view->centerOn(scene->addEvent(button));
00594 }
00595
00596 void ThymioVisualProgramming::addMoveAction()
00597 {
00598 ThymioMoveAction *button = new ThymioMoveAction();
00599 scene->setFocus();
00600 view->centerOn(scene->addAction(button));
00601 }
00602
00603 void ThymioVisualProgramming::addColorAction()
00604 {
00605 ThymioColorAction *button = new ThymioColorAction();
00606 scene->setFocus();
00607 view->centerOn(scene->addAction(button));
00608 }
00609
00610 void ThymioVisualProgramming::addCircleAction()
00611 {
00612 ThymioCircleAction *button = new ThymioCircleAction();
00613 scene->setFocus();
00614 view->centerOn(scene->addAction(button));
00615 }
00616
00617 void ThymioVisualProgramming::addSoundAction()
00618 {
00619 ThymioSoundAction *button = new ThymioSoundAction();
00620 scene->setFocus();
00621 view->centerOn(scene->addAction(button));
00622 }
00623
00624 void ThymioVisualProgramming::addMemoryAction()
00625 {
00626 ThymioMemoryAction *button = new ThymioMemoryAction();
00627 scene->setFocus();
00628 view->centerOn(scene->addAction(button));
00629 }
00630
00631 void ThymioVisualProgramming::resizeEvent( QResizeEvent *event)
00632 {
00633 QSize iconSize;
00634 QSize deltaSize = (event->size() - QSize(windowWidth, windowHeight));
00635 double scaleH = 1 + 1.2*(double)deltaSize.height()/windowHeight;
00636 double scaleV = 1 + 1.2*(double)deltaSize.width()/windowWidth;
00637 double scale = (scaleH < scaleV ? (scaleH > 1.95 ? 1.95 : scaleH) :
00638 (scaleV > 1.95 ? 1.95 : scaleV) );
00639
00640 iconSize = QSize(128*scale, 128*scale);
00641 scene->setScale(scale);
00642
00643 for(QList<ThymioPushButton*>::iterator itr = eventButtons.begin();
00644 itr != eventButtons.end(); ++itr)
00645 (*itr)->setIconSize(iconSize);
00646
00647 for(QList<ThymioPushButton*>::iterator itr = actionButtons.begin();
00648 itr != actionButtons.end(); ++itr)
00649 (*itr)->setIconSize(iconSize);
00650 }
00651
00652 };