Add DBus input driver.

This commit is contained in:
Torsten Paul 2016-10-08 20:17:46 +02:00
parent e620427092
commit 22ae5c61cb
5 changed files with 208 additions and 2 deletions

View file

@ -187,6 +187,13 @@ CONFIG += libxml2
CONFIG += hidapi
CONFIG += spnav
unix:!macx {
QT += dbus
DEFINES += ENABLE_DBUS
DBUS_ADAPTORS += org.openscad.OpenSCAD.xml
DBUS_INTERFACES += org.openscad.OpenSCAD.xml
}
#Uncomment the following line to enable the QScintilla editor
!nogui {
CONFIG += scintilla
@ -358,7 +365,8 @@ HEADERS += src/version_check.h \
src/input/InputDriverManager.h \
src/input/HidApiInputDriver.h \
src/input/SpaceNavInputDriver.h \
src/input/JoystickInputDriver.h
src/input/JoystickInputDriver.h \
src/input/DBusInputDriver.h
SOURCES += \
src/libsvg/libsvg.cc \
@ -487,7 +495,8 @@ SOURCES += \
src/input/InputDriverManager.cc \
src/input/HidApiInputDriver.cc \
src/input/SpaceNavInputDriver.cc \
src/input/JoystickInputDriver.cc
src/input/JoystickInputDriver.cc \
src/input/DBusInputDriver.cc
# ClipperLib
SOURCES += src/polyclipping/clipper.cpp

38
org.openscad.OpenSCAD.xml Normal file
View file

@ -0,0 +1,38 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.openscad.OpenSCAD">
<signal name="zoom">
<arg name="zoom" type="d" direction="out"/>
</signal>
<signal name="zoomTo">
<arg name="zoom" type="d" direction="out"/>
</signal>
<signal name="rotate">
<arg name="x" type="d" direction="out"/>
<arg name="y" type="d" direction="out"/>
<arg name="z" type="d" direction="out"/>
</signal>
<signal name="rotateTo">
<arg name="x" type="d" direction="out"/>
<arg name="y" type="d" direction="out"/>
<arg name="z" type="d" direction="out"/>
</signal>
<signal name="translate">
<arg name="x" type="d" direction="out"/>
<arg name="y" type="d" direction="out"/>
<arg name="z" type="d" direction="out"/>
</signal>
<signal name="translateTo">
<arg name="x" type="d" direction="out"/>
<arg name="y" type="d" direction="out"/>
<arg name="z" type="d" direction="out"/>
</signal>
<signal name="action">
<arg name="name" type="s" direction="out"/>
</signal>
<signal name="buttonPress">
<arg name="idx" type="u" direction="out"/>
</signal>
</interface>
</node>

View file

@ -0,0 +1,107 @@
/*
* OpenSCAD (www.openscad.org)
* Copyright (C) 2009-2015 Clifford Wolf <clifford@clifford.at> and
* Marius Kintel <marius@kintel.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* As a special exception, you have permission to link this program
* with the CGAL library and distribute executables, as long as you
* follow the requirements of the GNU GPL in regard to all of the
* software in the executable aside from CGAL.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "DBusInputDriver.h"
#include "InputDriverManager.h"
#include "openscad_adaptor.h"
#include "openscad_interface.h"
void DBusInputDriver::run()
{
}
DBusInputDriver::DBusInputDriver()
{
}
DBusInputDriver::~DBusInputDriver()
{
}
bool DBusInputDriver::open()
{
if (!QDBusConnection::sessionBus().isConnected()) {
return false;
}
new OpenSCADAdaptor(this);
QDBusConnection::sessionBus().registerObject("/org/openscad/OpenSCAD/Application", this);
org::openscad::OpenSCAD *iface;
iface = new org::openscad::OpenSCAD(QString(), QString(), QDBusConnection::sessionBus(), this);
connect(iface, SIGNAL(zoom(double)), this, SLOT(zoom(double)));
connect(iface, SIGNAL(zoomTo(double)), this, SLOT(zoomTo(double)));
connect(iface, SIGNAL(rotate(double, double, double)), this, SLOT(rotate(double, double, double)));
connect(iface, SIGNAL(rotateTo(double, double, double)), this, SLOT(rotateTo(double, double, double)));
connect(iface, SIGNAL(translate(double, double, double)), this, SLOT(translate(double, double, double)));
connect(iface, SIGNAL(translateTo(double, double, double)), this, SLOT(translateTo(double, double, double)));
return true;
}
void DBusInputDriver::close()
{
}
void DBusInputDriver::zoom(double zoom)
{
InputDriverManager::instance()->postEvent(new InputEventZoom(zoom), false);
}
void DBusInputDriver::zoomTo(double zoom)
{
InputDriverManager::instance()->postEvent(new InputEventZoom(zoom, false), false);
}
void DBusInputDriver::rotate(double x, double y, double z)
{
InputDriverManager::instance()->postEvent(new InputEventRotate(x, y, z), false);
}
void DBusInputDriver::rotateTo(double x, double y, double z)
{
InputDriverManager::instance()->postEvent(new InputEventRotate(x, y, z, false), false);
}
void DBusInputDriver::translate(double x, double y, double z)
{
InputDriverManager::instance()->postEvent(new InputEventTranslate(x, y, z), false);
}
void DBusInputDriver::translateTo(double x, double y, double z)
{
InputDriverManager::instance()->postEvent(new InputEventTranslate(x, y, z, false), false);
}
const std::string & DBusInputDriver::get_name() const
{
static std::string name = "DBusInputDriver";
return name;
}

View file

@ -0,0 +1,50 @@
/*
* OpenSCAD (www.openscad.org)
* Copyright (C) 2009-2015 Clifford Wolf <clifford@clifford.at> and
* Marius Kintel <marius@kintel.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* As a special exception, you have permission to link this program
* with the CGAL library and distribute executables, as long as you
* follow the requirements of the GNU GPL in regard to all of the
* software in the executable aside from CGAL.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#pragma once
#include "InputDriver.h"
class DBusInputDriver : public InputDriver
{
Q_OBJECT
public:
DBusInputDriver();
virtual ~DBusInputDriver();
virtual void run();
virtual bool open();
virtual void close();
virtual const std::string & get_name() const;
private slots:
void zoom(double zoom);
void zoomTo(double zoom);
void rotate(double x, double y, double z);
void rotateTo(double x, double y, double z);
void translate(double x, double y, double z);
void translateTo(double x, double y, double z);
};

View file

@ -577,6 +577,7 @@ Q_IMPORT_PLUGIN(qtaccessiblewidgets)
#include "input/HidApiInputDriver.h"
#include "input/SpaceNavInputDriver.h"
#include "input/JoystickInputDriver.h"
#include "input/DBusInputDriver.h"
#include <QString>
#include <QDir>
#include <QFileInfo>
@ -760,6 +761,7 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
InputDriverManager::instance()->registerDriver(new HidApiInputDriver());
InputDriverManager::instance()->registerDriver(new SpaceNavInputDriver());
InputDriverManager::instance()->registerDriver(new JoystickInputDriver());
InputDriverManager::instance()->registerDriver(new DBusInputDriver());
InputDriverManager::instance()->init();
int rc = app.exec();
for(auto &mainw : scadApp->windowManager.getWindows()) delete mainw;