The FORCE
authorMjolnir <thomas.pietrzak@inria.fr>
Thu, 3 Sep 2015 13:58:44 +0000 (15:58 +0200)
committerMjolnir <thomas.pietrzak@inria.fr>
Thu, 3 Sep 2015 13:58:44 +0000 (15:58 +0200)
12 files changed:
Library/XYPlotter.cpp
Library/XYPlotter.h
LivingDemos/Force.cpp [new file with mode: 0644]
LivingDemos/Force.h [new file with mode: 0644]
LivingDemos/LivingDemos.pro
LivingDemos/MenuPrincipal.cpp
LivingDemos/MenuPrincipal.h
LivingDemos/Tidy.cpp [new file with mode: 0644]
LivingDemos/Tidy.h [new file with mode: 0644]
LivingDemos/fullscreen.ui [new file with mode: 0644]
LivingDemos/menuprincipal.ui
images/desktop.jpg [new file with mode: 0644]

index 134067e56287476186e3b3cab5442fa67be81d0e..74a7759e15842a35856d64c72aa2b37318e11b32 100644 (file)
@@ -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};
index a3903c08ffe93f742efa99ed507b69e8ebf0f257..dce8a21304b011b92d7ed1a1a97079ac21ac1fc9 100644 (file)
@@ -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 (file)
index 0000000..905cec1
--- /dev/null
@@ -0,0 +1,38 @@
+#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);
+}
diff --git a/LivingDemos/Force.h b/LivingDemos/Force.h
new file mode 100644 (file)
index 0000000..7102a62
--- /dev/null
@@ -0,0 +1,30 @@
+#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
index 10663e68fa2ac34bac2afd4b575617911b06d2c7..05b108487a48b70e21302b9474584d254cb4e16f 100644 (file)
@@ -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
index 4cf4b5ec4c1dc412a1f9e5169c0c6b50de9bb453..f7d78b6df24d81f858e1fa4d6de68abaeba636c6 100644 (file)
@@ -3,15 +3,25 @@
 
 #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();
@@ -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();
+}
index b4dd4cadd93c2f196d88b48940df49fe7e7c10d0..b7a6e43ce485d12123375b67d07595091e8241e7 100644 (file)
@@ -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 (file)
index 0000000..2685990
--- /dev/null
@@ -0,0 +1,43 @@
+#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);
+}
diff --git a/LivingDemos/Tidy.h b/LivingDemos/Tidy.h
new file mode 100644 (file)
index 0000000..8e9d702
--- /dev/null
@@ -0,0 +1,29 @@
+#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
diff --git a/LivingDemos/fullscreen.ui b/LivingDemos/fullscreen.ui
new file mode 100644 (file)
index 0000000..ca23847
--- /dev/null
@@ -0,0 +1,68 @@
+<?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>
index bd7d7b40bea8100b9d5a88aaa1714ec69768059e..9cfa8b0fc17ee41b5bce2f1c10b2075887fe0d8e 100644 (file)
@@ -70,7 +70,7 @@
        </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>
@@ -83,7 +83,7 @@
          </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>
diff --git a/images/desktop.jpg b/images/desktop.jpg
new file mode 100644 (file)
index 0000000..84d5677
Binary files /dev/null and b/images/desktop.jpg differ