From: Mjolnir Date: Thu, 3 Sep 2015 13:58:44 +0000 (+0200) Subject: The FORCE X-Git-Url: https://git.thomaspietrzak.com/?a=commitdiff_plain;h=1fdf4c604d8488d21d4097a91fe7ea39b46d775d;p=livingdesktop.git The FORCE --- diff --git a/Library/XYPlotter.cpp b/Library/XYPlotter.cpp index 134067e..74a7759 100644 --- a/Library/XYPlotter.cpp +++ b/Library/XYPlotter.cpp @@ -13,7 +13,7 @@ XYPlotter::~XYPlotter() { } -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}; diff --git a/Library/XYPlotter.h b/Library/XYPlotter.h index a3903c0..dce8a21 100644 --- a/Library/XYPlotter.h +++ b/Library/XYPlotter.h @@ -9,7 +9,7 @@ class LIVINGDESKTOPLIBRARYSHARED_EXPORT XYPlotter : public LivingDevice XYPlotter(); ~XYPlotter(); - void moveTo(int x, int y, bool toolup); + void moveTo(int x, int y, bool toolup=true); void calibrate(); diff --git a/LivingDemos/Force.cpp b/LivingDemos/Force.cpp new file mode 100644 index 0000000..905cec1 --- /dev/null +++ b/LivingDemos/Force.cpp @@ -0,0 +1,38 @@ +#include "Force.h" + +#include +#include + +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(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(this->parent()); + if (menu->getMouse()) + menu->getMouse()->moveTo(0, 0); +} diff --git a/LivingDemos/Force.h b/LivingDemos/Force.h new file mode 100644 index 0000000..7102a62 --- /dev/null +++ b/LivingDemos/Force.h @@ -0,0 +1,30 @@ +#ifndef FORCE_H +#define FORCE_H + +#include + +#include + +#include + +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 diff --git a/LivingDemos/LivingDemos.pro b/LivingDemos/LivingDemos.pro index 10663e6..05b1084 100644 --- a/LivingDemos/LivingDemos.pro +++ b/LivingDemos/LivingDemos.pro @@ -24,10 +24,15 @@ LIBS += -L$$PWD/../builds/livingdesktop-Release -lLivingDesktop 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 diff --git a/LivingDemos/MenuPrincipal.cpp b/LivingDemos/MenuPrincipal.cpp index 4cf4b5e..f7d78b6 100644 --- a/LivingDemos/MenuPrincipal.cpp +++ b/LivingDemos/MenuPrincipal.cpp @@ -3,15 +3,25 @@ #include +#include +#include + 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(); @@ -149,3 +159,15 @@ void MenuPrincipal::openOptions() { options.show(); } + +void MenuPrincipal::openTidy() +{ + Tidy *t = new Tidy(this); + t->show(); +} + +void MenuPrincipal::openForce() +{ + Force *f = new Force(this); + f->show(); +} diff --git a/LivingDemos/MenuPrincipal.h b/LivingDemos/MenuPrincipal.h index b4dd4ca..b7a6e43 100644 --- a/LivingDemos/MenuPrincipal.h +++ b/LivingDemos/MenuPrincipal.h @@ -21,6 +21,10 @@ class MenuPrincipal : public QMainWindow 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(); @@ -41,6 +45,10 @@ class MenuPrincipal : public QMainWindow private slots: void openOptions(); + //run demos + void openTidy(); + void openForce(); + private: Ui::MenuPrincipal *ui; Options options; diff --git a/LivingDemos/Tidy.cpp b/LivingDemos/Tidy.cpp new file mode 100644 index 0000000..2685990 --- /dev/null +++ b/LivingDemos/Tidy.cpp @@ -0,0 +1,43 @@ +#include "Tidy.h" +#include "ui_tidy.h" + +#include +#include + +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(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(this->parent()); + if (menu->getMouse()) + menu->getMouse()->moveTo(100, 800); + if (menu->getKeyboard()) + menu->getKeyboard()->translation(LivingKeyboard::FORWARD, 100); +} diff --git a/LivingDemos/Tidy.h b/LivingDemos/Tidy.h new file mode 100644 index 0000000..8e9d702 --- /dev/null +++ b/LivingDemos/Tidy.h @@ -0,0 +1,29 @@ +#ifndef TIDY_H +#define TIDY_H + +#include +#include + +#include + +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 diff --git a/LivingDemos/fullscreen.ui b/LivingDemos/fullscreen.ui new file mode 100644 index 0000000..ca23847 --- /dev/null +++ b/LivingDemos/fullscreen.ui @@ -0,0 +1,68 @@ + + + Fullscreen + + + Qt::WindowModal + + + + 0 + 0 + 800 + 600 + + + + Fullscreen + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + Start + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + diff --git a/LivingDemos/menuprincipal.ui b/LivingDemos/menuprincipal.ui index bd7d7b4..9cfa8b0 100644 --- a/LivingDemos/menuprincipal.ui +++ b/LivingDemos/menuprincipal.ui @@ -70,7 +70,7 @@ - + 0 @@ -83,7 +83,7 @@ - Demo 2 + Force @@ -106,7 +106,7 @@ - + 0 @@ -119,7 +119,7 @@ - Demo 1 + Tidy @@ -175,6 +175,13 @@ + + tidy + force + pushButton_2 + pushButton_4 + options + diff --git a/images/desktop.jpg b/images/desktop.jpg new file mode 100644 index 0000000..84d5677 Binary files /dev/null and b/images/desktop.jpg differ