{
}
-void XYPlotter::moveTo(int x, int y, bool toolup=true)
+void XYPlotter::moveTo(int x, int y, bool toolup)
{
char commands[] = {'G', 'X', 'Y', 'Z'};
int values[] = {0, x, y, toolup * toolDistance};
XYPlotter();
~XYPlotter();
- void moveTo(int x, int y, bool toolup);
+ void moveTo(int x, int y, bool toolup=true);
void calibrate();
--- /dev/null
+#include "Force.h"
+
+#include <QDebug>
+#include <MenuPrincipal.h>
+
+Force::Force(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::Fullscreen)
+{
+ ui->setupUi(this);
+ setWindowState(Qt::WindowMaximized);
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ ui->image->setScene(&_background);
+ _background.addPixmap(QPixmap("../../images/desktop.jpg"));
+ ui->image->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ ui->image->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+ connect(ui->start, SIGNAL(clicked()), this, SLOT(moveMouse()));
+
+ MenuPrincipal * menu = dynamic_cast<MenuPrincipal *>(parent);
+ if (!menu->getMouse())
+ qDebug() << "Warning: mouse not connected";
+ else
+ menu->getMouse()->moveTo(500, 500);
+}
+
+Force::~Force()
+{
+ delete ui;
+}
+
+void Force::moveMouse()
+{
+ MenuPrincipal * menu = dynamic_cast<MenuPrincipal *>(this->parent());
+ if (menu->getMouse())
+ menu->getMouse()->moveTo(0, 0);
+}
--- /dev/null
+#ifndef FORCE_H
+#define FORCE_H
+
+#include <QMainWindow>
+
+#include <QGraphicsScene>
+
+#include <ui_fullscreen.h>
+
+namespace Ui {
+ class Fullscreen;
+}
+
+class Force : public QMainWindow
+{
+ Q_OBJECT
+
+ public:
+ explicit Force(QWidget *parent = 0);
+ ~Force();
+
+ public slots:
+ void moveMouse();
+
+ private:
+ Ui::Fullscreen *ui;
+ QGraphicsScene _background;
+};
+
+#endif // FORCE_H
SOURCES += main.cpp\
MenuPrincipal.cpp \
- Options.cpp
+ Options.cpp \
+ Tidy.cpp \
+ Force.cpp
HEADERS += MenuPrincipal.h \
- Options.h
+ Options.h \
+ Tidy.h \
+ Force.h
FORMS += menuprincipal.ui \
- options.ui
+ options.ui \
+ fullscreen.ui
#include <QDebug>
+#include <Tidy.h>
+#include <Force.h>
+
MenuPrincipal::MenuPrincipal(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MenuPrincipal),
- options(this)
+ options(this),
+ _mouse(NULL),
+ _keyboard(NULL),
+ _screen(NULL)
{
ui->setupUi(this);
connect(ui->options, SIGNAL(clicked()), this, SLOT(openOptions()));
+ //demos
+ connect(ui->tidy, SIGNAL(clicked()), this, SLOT(openTidy()));
+ connect(ui->force, SIGNAL(clicked()), this, SLOT(openForce()));
+
connectKeyboard();
connectScreen();
connectMouse();
{
options.show();
}
+
+void MenuPrincipal::openTidy()
+{
+ Tidy *t = new Tidy(this);
+ t->show();
+}
+
+void MenuPrincipal::openForce()
+{
+ Force *f = new Force(this);
+ f->show();
+}
explicit MenuPrincipal(QWidget *parent = 0);
~MenuPrincipal();
+ XYPlotter *getMouse() const { return _mouse; }
+ LivingKeyboard *getKeyboard() const { return _keyboard; }
+ LivingScreen *getScreen() const { return _screen; }
+
public slots:
void connectMouse();
void connectKeyboard();
private slots:
void openOptions();
+ //run demos
+ void openTidy();
+ void openForce();
+
private:
Ui::MenuPrincipal *ui;
Options options;
--- /dev/null
+#include "Tidy.h"
+#include "ui_tidy.h"
+
+#include <QDebug>
+#include <MenuPrincipal.h>
+
+Tidy::Tidy(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::Fullscreen)
+{
+ ui->setupUi(this);
+ setWindowState(Qt::WindowMaximized);
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ ui->image->setScene(&_background);
+ _background.addPixmap(QPixmap("../../images/desktop.jpg"));
+ ui->image->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ ui->image->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ //ui->image->ensureVisible(_background.itemsBoundingRect());
+ //sceneRect());
+
+ connect(ui->start, SIGNAL(clicked()), this, SLOT(moveDevices()));
+
+ MenuPrincipal * menu = dynamic_cast<MenuPrincipal *>(parent);
+ if (!menu->getMouse())
+ qDebug() << "Warning: mouse not connected";
+ if (!menu->getKeyboard())
+ qDebug() << "Warning: keyboard not connected";
+}
+
+Tidy::~Tidy()
+{
+ delete ui;
+}
+
+void Tidy::moveDevices()
+{
+ MenuPrincipal * menu = dynamic_cast<MenuPrincipal *>(this->parent());
+ if (menu->getMouse())
+ menu->getMouse()->moveTo(100, 800);
+ if (menu->getKeyboard())
+ menu->getKeyboard()->translation(LivingKeyboard::FORWARD, 100);
+}
--- /dev/null
+#ifndef TIDY_H
+#define TIDY_H
+
+#include <QMainWindow>
+#include <QGraphicsScene>
+
+#include <ui_fullscreen.h>
+
+namespace Ui {
+ class Fullscreen;
+}
+
+class Tidy : public QMainWindow
+{
+ Q_OBJECT
+
+ public:
+ explicit Tidy(QWidget *parent = 0);
+ ~Tidy();
+
+ public slots:
+ void moveDevices();
+
+ private:
+ Ui::Fullscreen *ui;
+ QGraphicsScene _background;
+};
+
+#endif // TIDY_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Fullscreen</class>
+ <widget class="QMainWindow" name="Fullscreen">
+ <property name="windowModality">
+ <enum>Qt::WindowModal</enum>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Fullscreen</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QGraphicsView" name="image"/>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="start">
+ <property name="text">
+ <string>Start</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
</widget>
</item>
<item row="1" column="1">
- <widget class="QPushButton" name="pushButton_3">
+ <widget class="QPushButton" name="force">
<property name="minimumSize">
<size>
<width>0</width>
</font>
</property>
<property name="text">
- <string>Demo 2</string>
+ <string>Force</string>
</property>
</widget>
</item>
</widget>
</item>
<item row="1" column="0">
- <widget class="QPushButton" name="pushButton">
+ <widget class="QPushButton" name="tidy">
<property name="minimumSize">
<size>
<width>0</width>
</font>
</property>
<property name="text">
- <string>Demo 1</string>
+ <string>Tidy</string>
</property>
</widget>
</item>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
+ <tabstops>
+ <tabstop>tidy</tabstop>
+ <tabstop>force</tabstop>
+ <tabstop>pushButton_2</tabstop>
+ <tabstop>pushButton_4</tabstop>
+ <tabstop>options</tabstop>
+ </tabstops>
<resources/>
<connections/>
</ui>