0000818: [PATCH] added new page to Customize dialog for space navigator

This commit is contained in:
wmayer 2012-08-30 11:31:46 +02:00
parent 549f4dfa26
commit 57b633f21f
17 changed files with 1080 additions and 17 deletions

View File

@ -202,8 +202,9 @@ void Gui::GUIApplicationNativeEventAware::Move3d(HANDLE device, std::vector<floa
rz = ceil(motionData[5]);
Spaceball::MotionEvent *motionEvent = new Spaceball::MotionEvent();
motionEvent->setTranslations(x, y, z);
motionEvent->setRotations(rx, ry, rz);
//motionEvent->setTranslations(x, y, z);
//motionEvent->setRotations(rx, ry, rz);
motionEvent->setMotionData(x, y, z, rx, ry, rz);
this->postEvent(currentWidget, motionEvent);
}

View File

@ -104,6 +104,7 @@ set(Gui_MOC_HDRS
DlgCommandsImp.h
DlgCustomizeImp.h
DlgCustomizeSpaceball.h
DlgCustomizeSpNavSettings.h
DlgDisplayPropertiesImp.h
DlgEditorImp.h
DlgGeneralImp.h
@ -190,6 +191,7 @@ SET(Gui_UIC_SRCS
DlgAuthorization.ui
DlgChooseIcon.ui
DlgCommands.ui
DlgCustomizeSpNavSettings.ui
DlgDisplayProperties.ui
DlgEditor.ui
DlgGeneral.ui
@ -338,6 +340,7 @@ SET(Dialog_Customize_CPP_SRCS
DlgCommandsImp.cpp
DlgCustomizeImp.cpp
DlgCustomizeSpaceball.cpp
DlgCustomizeSpNavSettings.cpp
DlgKeyboardImp.cpp
DlgToolbarsImp.cpp
)
@ -346,6 +349,7 @@ SET(Dialog_Customize_HPP_SRCS
DlgCommandsImp.h
DlgCustomizeImp.h
DlgCustomizeSpaceball.h
DlgCustomizeSpNavSettings.h
DlgKeyboardImp.h
DlgToolbarsImp.h
)
@ -355,6 +359,7 @@ SET(Dialog_Customize_SRCS
DlgActions.ui
DlgChooseIcon.ui
DlgCommands.ui
DlgCustomizeSpNavSettings.ui
DlgKeyboard.ui
DlgToolbars.ui
)

View File

@ -0,0 +1,310 @@
/***************************************************************************
* Copyright (c) 2012 Petar Perisin <petar.perisin@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "DlgCustomizeSpNavSettings.h"
#include "GuiApplicationNativeEventAware.h"
#include "Application.h"
using namespace Gui::Dialog;
DlgCustomizeSpNavSettings::DlgCustomizeSpNavSettings(QWidget *parent) :
CustomizeActionPage(parent)
{
GUIApplicationNativeEventAware *app = qobject_cast<GUIApplicationNativeEventAware *>(QApplication::instance());
if (!app)
return;
if (!app->isSpaceballPresent())
{
this->setWindowTitle(tr("Spaceball Motion"));
this->setMessage(tr("No Spaceball Present"));
return;
}
this->setupUi(this);
initialize();
}
DlgCustomizeSpNavSettings::~DlgCustomizeSpNavSettings()
{
}
void DlgCustomizeSpNavSettings::setMessage(const QString& message)
{
QLabel *messageLabel = new QLabel(message,this);
QVBoxLayout *layout = new QVBoxLayout();
QHBoxLayout *layout2 = new QHBoxLayout();
layout2->addStretch();
layout2->addWidget(messageLabel);
layout2->addStretch();
layout->addItem(layout2);
this->setLayout(layout);
}
void DlgCustomizeSpNavSettings::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
}
ParameterGrp::handle DlgCustomizeSpNavSettings::spaceballMotionGroup() const
{
static ParameterGrp::handle group = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Spaceball")->GetGroup("Motion");
return group;
}
void DlgCustomizeSpNavSettings::on_ButtonCalibrate_clicked()
{
spaceballMotionGroup()->SetBool("Calibrate", true);
}
void DlgCustomizeSpNavSettings::initialize()
{
CBDominant->setChecked(spaceballMotionGroup()->GetBool("Dominant", false));
CBFlipYZ->setChecked(spaceballMotionGroup()->GetBool("FlipYZ", false));
CBRotations->setChecked(spaceballMotionGroup()->GetBool("Rotations", true));
CBTranslations->setChecked(spaceballMotionGroup()->GetBool("Translations", true));
SliderGlobal->setValue(spaceballMotionGroup()->GetInt("GlobalSensitivity", 0));
CBEnablePanLR ->setChecked(spaceballMotionGroup()->GetBool("PanLREnable", true));
CBReversePanLR->setChecked(spaceballMotionGroup()->GetBool("PanLRReverse", false));
SliderPanLR ->setValue(spaceballMotionGroup()->GetInt("PanLRSensitivity", 0));
CBEnablePanUD ->setChecked(spaceballMotionGroup()->GetBool("PanUDEnable", true));
CBReversePanUD->setChecked(spaceballMotionGroup()->GetBool("PanUDReverse", false));
SliderPanUD ->setValue(spaceballMotionGroup()->GetInt("PanUDSensitivity", 0));
CBEnableZoom ->setChecked(spaceballMotionGroup()->GetBool("ZoomEnable", true));
CBReverseZoom->setChecked(spaceballMotionGroup()->GetBool("ZoomReverse", false));
SliderZoom ->setValue(spaceballMotionGroup()->GetInt("ZoomSensitivity", 0));
CBEnableTilt ->setChecked(spaceballMotionGroup()->GetBool("TiltEnable", true));
CBReverseTilt->setChecked(spaceballMotionGroup()->GetBool("TiltReverse", false));
SliderTilt ->setValue(spaceballMotionGroup()->GetInt("TiltSensitivity", 0));
CBEnableRoll ->setChecked(spaceballMotionGroup()->GetBool("RollEnable", true));
CBReverseRoll->setChecked(spaceballMotionGroup()->GetBool("RollReverse", false));
SliderRoll ->setValue(spaceballMotionGroup()->GetInt("RollSensitivity", 0));
CBEnableSpin ->setChecked(spaceballMotionGroup()->GetBool("SpinEnable", true));
CBReverseSpin->setChecked(spaceballMotionGroup()->GetBool("SpinReverse", false));
SliderSpin ->setValue(spaceballMotionGroup()->GetInt("SpinSensitivity", 0));
CBEnableTilt ->setEnabled(CBRotations->isChecked());
CBReverseTilt->setEnabled(CBRotations->isChecked() && CBEnableTilt->isChecked());
SliderTilt ->setEnabled(CBRotations->isChecked() && CBEnableTilt->isChecked());
CBEnableRoll ->setEnabled(CBRotations->isChecked());
CBReverseRoll->setEnabled(CBRotations->isChecked() && CBEnableRoll->isChecked());
SliderRoll ->setEnabled(CBRotations->isChecked() && CBEnableRoll->isChecked());
CBEnableSpin ->setEnabled(CBRotations->isChecked());
CBReverseSpin->setEnabled(CBRotations->isChecked() && CBEnableSpin->isChecked());
SliderSpin ->setEnabled(CBRotations->isChecked() && CBEnableSpin->isChecked());
CBEnablePanLR ->setEnabled(CBTranslations->isChecked());
CBReversePanLR->setEnabled(CBTranslations->isChecked() && CBEnablePanLR->isChecked());
SliderPanLR ->setEnabled(CBTranslations->isChecked() && CBEnablePanLR->isChecked());
CBEnablePanUD ->setEnabled(CBTranslations->isChecked());
CBReversePanUD->setEnabled(CBTranslations->isChecked() && CBEnablePanUD->isChecked());
SliderPanUD ->setEnabled(CBTranslations->isChecked() && CBEnablePanUD->isChecked());
CBEnableZoom ->setEnabled(CBTranslations->isChecked());
CBReverseZoom ->setEnabled(CBTranslations->isChecked() && CBEnableZoom->isChecked());
SliderZoom ->setEnabled(CBTranslations->isChecked() && CBEnableZoom->isChecked());
}
void DlgCustomizeSpNavSettings::on_ButtonDefaultSpNavMotions_clicked()
{
spaceballMotionGroup()->Clear();
initialize();
}
void DlgCustomizeSpNavSettings::on_CBDominant_clicked()
{
spaceballMotionGroup()->SetBool("Dominant", CBDominant->isChecked());
}
void DlgCustomizeSpNavSettings::on_CBFlipYZ_clicked()
{
spaceballMotionGroup()->SetBool("FlipYZ", CBFlipYZ->isChecked());
}
void DlgCustomizeSpNavSettings::on_CBRotations_clicked()
{
spaceballMotionGroup()->SetBool("Rotations", CBRotations->isChecked());
CBEnableTilt ->setEnabled(CBRotations->isChecked());
CBReverseTilt->setEnabled(CBRotations->isChecked() && CBEnableTilt->isChecked());
SliderTilt ->setEnabled(CBRotations->isChecked() && CBEnableTilt->isChecked());
CBEnableRoll ->setEnabled(CBRotations->isChecked());
CBReverseRoll->setEnabled(CBRotations->isChecked() && CBEnableRoll->isChecked());
SliderRoll ->setEnabled(CBRotations->isChecked() && CBEnableRoll->isChecked());
CBEnableSpin ->setEnabled(CBRotations->isChecked());
CBReverseSpin->setEnabled(CBRotations->isChecked() && CBEnableSpin->isChecked());
SliderSpin ->setEnabled(CBRotations->isChecked() && CBEnableSpin->isChecked());
}
void DlgCustomizeSpNavSettings::on_CBTranslations_clicked()
{
spaceballMotionGroup()->SetBool("Translations", CBTranslations->isChecked());
CBEnablePanLR ->setEnabled(CBTranslations->isChecked());
CBReversePanLR->setEnabled(CBTranslations->isChecked() && CBEnablePanLR->isChecked());
SliderPanLR ->setEnabled(CBTranslations->isChecked() && CBEnablePanLR->isChecked());
CBEnablePanUD ->setEnabled(CBTranslations->isChecked());
CBReversePanUD->setEnabled(CBTranslations->isChecked() && CBEnablePanUD->isChecked());
SliderPanUD ->setEnabled(CBTranslations->isChecked() && CBEnablePanUD->isChecked());
CBEnableZoom ->setEnabled(CBTranslations->isChecked());
CBReverseZoom ->setEnabled(CBTranslations->isChecked() && CBEnableZoom->isChecked());
SliderZoom ->setEnabled(CBTranslations->isChecked() && CBEnableZoom->isChecked());
}
void DlgCustomizeSpNavSettings::on_SliderGlobal_sliderReleased()
{
spaceballMotionGroup()->SetInt("GlobalSensitivity", SliderGlobal->value());
}
void DlgCustomizeSpNavSettings::on_CBEnablePanLR_clicked()
{
spaceballMotionGroup()->SetBool("PanLREnable", CBEnablePanLR->isChecked());
CBReversePanLR->setEnabled(CBEnablePanLR->isChecked());
SliderPanLR ->setEnabled(CBEnablePanLR->isChecked());
}
void DlgCustomizeSpNavSettings::on_CBReversePanLR_clicked()
{
spaceballMotionGroup()->SetBool("PanLRReverse", CBReversePanLR->isChecked());
}
void DlgCustomizeSpNavSettings::on_SliderPanLR_sliderReleased()
{
spaceballMotionGroup()->SetInt("PanLRSensitivity", SliderPanLR->value());
}
void DlgCustomizeSpNavSettings::on_CBEnablePanUD_clicked()
{
spaceballMotionGroup()->SetBool("PanUDEnable", CBEnablePanUD->isChecked());
CBReversePanUD->setEnabled(CBEnablePanUD->isChecked());
SliderPanUD ->setEnabled(CBEnablePanUD->isChecked());
}
void DlgCustomizeSpNavSettings::on_CBReversePanUD_clicked()
{
spaceballMotionGroup()->SetBool("PanUDReverse", CBReversePanUD->isChecked());
}
void DlgCustomizeSpNavSettings::on_SliderPanUD_sliderReleased()
{
spaceballMotionGroup()->SetInt("PanUDSensitivity", SliderPanUD->value());
}
void DlgCustomizeSpNavSettings::on_CBEnableZoom_clicked()
{
spaceballMotionGroup()->SetBool("ZoomEnable", CBEnableZoom->isChecked());
CBReverseZoom ->setEnabled(CBEnableZoom->isChecked());
SliderZoom ->setEnabled(CBEnableZoom->isChecked());
}
void DlgCustomizeSpNavSettings::on_CBReverseZoom_clicked()
{
spaceballMotionGroup()->SetBool("ZoomReverse", CBReverseZoom->isChecked());
}
void DlgCustomizeSpNavSettings::on_SliderZoom_sliderReleased()
{
spaceballMotionGroup()->SetInt("ZoomSensitivity", SliderZoom->value());
}
void DlgCustomizeSpNavSettings::on_CBEnableTilt_clicked()
{
spaceballMotionGroup()->SetBool("TiltEnable", CBEnableTilt->isChecked());
CBReverseTilt->setEnabled(CBEnableTilt->isChecked());
SliderTilt ->setEnabled(CBEnableTilt->isChecked());
}
void DlgCustomizeSpNavSettings::on_CBReverseTilt_clicked()
{
spaceballMotionGroup()->SetBool("TiltReverse", CBReverseTilt->isChecked());
}
void DlgCustomizeSpNavSettings::on_SliderTilt_sliderReleased()
{
spaceballMotionGroup()->SetInt("TiltSensitivity", SliderTilt->value());
}
void DlgCustomizeSpNavSettings::on_CBEnableRoll_clicked()
{
spaceballMotionGroup()->SetBool("RollEnable", CBEnableRoll->isChecked());
CBReverseRoll->setEnabled(CBEnableRoll->isChecked());
SliderRoll ->setEnabled(CBEnableRoll->isChecked());
}
void DlgCustomizeSpNavSettings::on_CBReverseRoll_clicked()
{
spaceballMotionGroup()->SetBool("RollReverse", CBReverseRoll->isChecked());
}
void DlgCustomizeSpNavSettings::on_SliderRoll_sliderReleased()
{
spaceballMotionGroup()->SetInt("RollSensitivity", SliderRoll->value());
}
void DlgCustomizeSpNavSettings::on_CBEnableSpin_clicked()
{
spaceballMotionGroup()->SetBool("SpinEnable", CBEnableSpin->isChecked());
CBReverseSpin->setEnabled(CBEnableSpin->isChecked());
SliderSpin ->setEnabled(CBEnableSpin->isChecked());
}
void DlgCustomizeSpNavSettings::on_CBReverseSpin_clicked()
{
spaceballMotionGroup()->SetBool("SpinReverse", CBReverseSpin->isChecked());
}
void DlgCustomizeSpNavSettings::on_SliderSpin_sliderReleased()
{
spaceballMotionGroup()->SetInt("SpinSensitivity", SliderSpin->value());
}
void DlgCustomizeSpNavSettings::onAddMacroAction(const QByteArray &macroName)
{
//don't think I need to do anything here.
}
void DlgCustomizeSpNavSettings::onRemoveMacroAction(const QByteArray &macroName)
{
//don't think I need to do anything here.
}
void DlgCustomizeSpNavSettings::onModifyMacroAction(const QByteArray &macroName)
{
//don't think I need to do anything here.
}
#include "moc_DlgCustomizeSpNavSettings.cpp"

View File

@ -0,0 +1,85 @@
/***************************************************************************
* Copyright (c) 2012 Petar Perisin <petar.perisin@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef DLGCUSTOMIZESPNAVSETTINGS_H
#define DLGCUSTOMIZESPNAVSETTINGS_H
#include "ui_DlgCustomizeSpNavSettings.h"
#include "PropertyPage.h"
#include <Base/Parameter.h>
namespace Gui
{
namespace Dialog
{
class DlgCustomizeSpNavSettings : public CustomizeActionPage, public Ui_DlgCustomizeSpNavSettings
{
Q_OBJECT
public:
explicit DlgCustomizeSpNavSettings(QWidget *parent = 0);
~DlgCustomizeSpNavSettings();
protected Q_SLOTS:
void onAddMacroAction(const QByteArray&);
void onRemoveMacroAction(const QByteArray&);
void onModifyMacroAction(const QByteArray&);
void on_CBDominant_clicked();
void on_CBFlipYZ_clicked();
void on_CBRotations_clicked();
void on_CBTranslations_clicked();
void on_SliderGlobal_sliderReleased();
void on_CBEnablePanLR_clicked();
void on_CBReversePanLR_clicked();
void on_SliderPanLR_sliderReleased();
void on_CBEnablePanUD_clicked();
void on_CBReversePanUD_clicked();
void on_SliderPanUD_sliderReleased();
void on_CBEnableZoom_clicked();
void on_CBReverseZoom_clicked();
void on_SliderZoom_sliderReleased();
void on_CBEnableTilt_clicked();
void on_CBReverseTilt_clicked();
void on_SliderTilt_sliderReleased();
void on_CBEnableRoll_clicked();
void on_CBReverseRoll_clicked();
void on_SliderRoll_sliderReleased();
void on_CBEnableSpin_clicked();
void on_CBReverseSpin_clicked();
void on_SliderSpin_sliderReleased();
void on_ButtonDefaultSpNavMotions_clicked();
void on_ButtonCalibrate_clicked();
protected:
void changeEvent(QEvent *e);
private:
ParameterGrp::handle spaceballMotionGroup() const;
void setMessage(const QString& message);
void initialize();
};
}
}
#endif // DLGCUSTOMIZESPNAVSETTINGS_H

View File

@ -0,0 +1,534 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgCustomizeSpNavSettings</class>
<widget class="QWidget" name="DlgCustomizeSpNavSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>439</width>
<height>537</height>
</rect>
</property>
<property name="windowTitle">
<string>Spaceball Motion</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="labelSlow">
<property name="text">
<string>Global Sensitivity: </string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="SliderGlobal">
<property name="minimum">
<number>-50</number>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QCheckBox" name="CBDominant">
<property name="text">
<string>Dominant Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="CBFlipYZ">
<property name="text">
<string>Flip Y/Z</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QCheckBox" name="CBTranslations">
<property name="text">
<string>Enable Translations</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="CBRotations">
<property name="text">
<string>Enable Rotations</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</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>
<item>
<widget class="QPushButton" name="ButtonCalibrate">
<property name="text">
<string>Calibrate</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ButtonDefaultSpNavMotions">
<property name="text">
<string>Default</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>116</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="ImagePanLR">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="Icons/resource.qrc">:/icons/SpNav-PanLR.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="ImagePanUD">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="Icons/resource.qrc">:/icons/SpNav-PanUD.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="ImageZoom">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="Icons/resource.qrc">:/icons/SpNav-Zoom.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="imageTilt">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="Icons/resource.qrc">:/icons/SpNav-Tilt.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="ImageRoll">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="Icons/resource.qrc">:/icons/SpNav-Roll.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="ImageSpin">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="Icons/resource.qrc">:/icons/SpNav-Spin.png</pixmap>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_9">
<property name="spacing">
<number>20</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="CBEnablePanLR">
<property name="text">
<string>Enable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="CBReversePanLR">
<property name="text">
<string>Reverse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="CBEnablePanUD">
<property name="text">
<string>Enable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="CBReversePanUD">
<property name="text">
<string>Reverse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="CBEnableZoom">
<property name="text">
<string>Enable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="CBReverseZoom">
<property name="text">
<string>Reverse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="CBEnableTilt">
<property name="text">
<string>Enable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="CBReverseTilt">
<property name="text">
<string>Reverse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="CBEnableRoll">
<property name="text">
<string>Enable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="CBReverseRoll">
<property name="text">
<string>Reverse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="CBEnableSpin">
<property name="text">
<string>Enable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="CBReverseSpin">
<property name="text">
<string>Reverse</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>30</number>
</property>
<item>
<widget class="QSlider" name="SliderPanLR">
<property name="minimum">
<number>-50</number>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="SliderPanUD">
<property name="minimum">
<number>-50</number>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="SliderZoom">
<property name="minimum">
<number>-50</number>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="SliderTilt">
<property name="minimum">
<number>-50</number>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="SliderRoll">
<property name="minimum">
<number>-50</number>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="SliderSpin">
<property name="minimum">
<number>-50</number>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="Icons/resource.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -525,7 +525,7 @@ DlgCustomizeSpaceball::DlgCustomizeSpaceball(QWidget *parent)
: CustomizeActionPage(parent), buttonView(0), buttonModel(0),
commandView(0), commandModel(0), clearButton(0), printReference(0)
{
this->setWindowTitle(tr("Spaceball"));
this->setWindowTitle(tr("Spaceball Buttons"));
GUIApplicationNativeEventAware *app = qobject_cast<GUIApplicationNativeEventAware *>(QApplication::instance());
if (!app)
return;

View File

@ -143,8 +143,9 @@ bool Gui::GUIApplicationNativeEventAware::x11EventFilter(XEvent *event)
if (navEvent.type == SPNAV_EVENT_MOTION)
{
Spaceball::MotionEvent *motionEvent = new Spaceball::MotionEvent();
motionEvent->setTranslations(navEvent.motion.x, navEvent.motion.y, navEvent.motion.z);
motionEvent->setRotations(navEvent.motion.rx, navEvent.motion.ry, navEvent.motion.rz);
// motionEvent->setTranslations(navEvent.motion.x, navEvent.motion.y, navEvent.motion.z);
// motionEvent->setRotations(navEvent.motion.rx, navEvent.motion.ry, navEvent.motion.rz);
motionEvent->setMotionData(navEvent.motion.x, navEvent.motion.y, navEvent.motion.z, navEvent.motion.rx, navEvent.motion.ry, navEvent.motion.rz);
this->postEvent(currentWidget, motionEvent);
return true;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -78,5 +78,11 @@
<file>Tree_Dimension.svg</file>
<file>Tree_Python.svg</file>
<file>spaceball_button.svg</file>
<file>SpNav-PanLR.png</file>
<file>SpNav-PanUD.png</file>
<file>SpNav-Roll.png</file>
<file>SpNav-Spin.png</file>
<file>SpNav-Tilt.png</file>
<file>SpNav-Zoom.png</file>
</qresource>
</RCC>

View File

@ -22,6 +22,7 @@
#include "PreCompiled.h"
#include "SpaceballEvent.h"
#include "Application.h"
using namespace Spaceball;
@ -40,15 +41,132 @@ MotionEvent::MotionEvent() : EventBase(static_cast<QEvent::Type>(MotionEventType
MotionEvent::MotionEvent(const MotionEvent& in) : EventBase(static_cast<QEvent::Type>(MotionEventType))
{
xTrans = in.xTrans;
yTrans = in.yTrans;
zTrans = in.zTrans;
xRot = in.xRot;
yRot = in.yRot;
zRot = in.zRot;
int motionDataArray[6] = {in.xTrans, in.yTrans, in.zTrans, in.xRot, in.yRot, in.zRot};
importSettings(motionDataArray);
handled = in.handled;
}
float MotionEvent::convertPrefToSensitivity(int value)
{
if (value < 0)
{
return ((0.6/50)*float(value) + 1);
}
else
{
return ((1.1/50)*float(value) + 1);
}
}
void MotionEvent::importSettings(int* motionDataArray)
{
ParameterGrp::handle group = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Spaceball")->GetGroup("Motion");
// here I import settings from a dialog. For now they are set as is
bool dominant = group->GetBool("Dominant"); // Is dominant checked
bool flipXY = group->GetBool("FlipYZ");; // Is Flip X/Y checked
float generalSensitivity = convertPrefToSensitivity(group->GetInt("GlobalSensitivity"));
// array that has stored info about "Enabled" checkboxes of all axes
bool enabled[6];
enabled[0] = group->GetBool("Translations", true) && group->GetBool("PanLREnable", true);
enabled[1] = group->GetBool("Translations", true) && group->GetBool("PanUDEnable", true);
enabled[2] = group->GetBool("Translations", true) && group->GetBool("ZoomEnable", true);
enabled[3] = group->GetBool("Rotations", true) && group->GetBool("TiltEnable", true);
enabled[4] = group->GetBool("Rotations", true) && group->GetBool("RollEnable", true);
enabled[5] = group->GetBool("Rotations", true) && group->GetBool("SpinEnable", true);
// array that has stored info about "Reversed" checkboxes of all axes
bool reversed[6];
reversed[0] = group->GetBool("PanLRReverse");
reversed[1] = group->GetBool("PanUDReverse");
reversed[2] = group->GetBool("ZoomReverse");
reversed[3] = group->GetBool("TiltReverse");
reversed[4] = group->GetBool("RollReverse");
reversed[5] = group->GetBool("SpinReverse");
// array that has stored info about sliders - on each slider you need to use method DlgSpaceballSettings::GetValuefromSlider
// which will convert <-50, 50> linear integers from slider to <0.1, 10> exponential floating values
float sensitivity[6];
sensitivity[0] = convertPrefToSensitivity(group->GetInt("PanLRSensitivity"));
sensitivity[1] = convertPrefToSensitivity(group->GetInt("PanUDSensitivity"));
sensitivity[2] = convertPrefToSensitivity(group->GetInt("ZoomSensitivity"));
sensitivity[3] = convertPrefToSensitivity(group->GetInt("TiltSensitivity"));
sensitivity[4] = convertPrefToSensitivity(group->GetInt("RollSensitivity"));
sensitivity[5] = convertPrefToSensitivity(group->GetInt("SpinSensitivity"));
int i;
if (group->GetBool("Calibrate"))
{
group->SetInt("CalibrationX",motionDataArray[0]);
group->SetInt("CalibrationY",motionDataArray[1]);
group->SetInt("CalibrationZ",motionDataArray[2]);
group->SetInt("CalibrationXr",motionDataArray[3]);
group->SetInt("CalibrationYr",motionDataArray[4]);
group->SetInt("CalibrationZr",motionDataArray[5]);
group->RemoveBool("Calibrate");
return;
}
else
{
motionDataArray[0] = motionDataArray[0] - group->GetInt("CalibrationX");
motionDataArray[1] = motionDataArray[1] - group->GetInt("CalibrationY");
motionDataArray[2] = motionDataArray[2] - group->GetInt("CalibrationZ");
motionDataArray[3] = motionDataArray[3] - group->GetInt("CalibrationXr");
motionDataArray[4] = motionDataArray[4] - group->GetInt("CalibrationYr");
motionDataArray[5] = motionDataArray[5] - group->GetInt("CalibrationZr");
}
if (dominant) { // if dominant is checked
int max = 0;
bool flag = false;
for (i = 0; i < 6; ++i) {
if (abs(motionDataArray[i]) > abs(max)) max = motionDataArray[i];
}
for (i = 0; i < 6; ++i) {
if ((motionDataArray[i] != max) || (flag)) {
motionDataArray[i] = 0;
} else if (motionDataArray[i] == max){
flag = true;
}
}
}
if (flipXY) {
int temp = motionDataArray[1];
motionDataArray[1] = motionDataArray[2];
motionDataArray[2] = - temp;
}
for (i = 0; i < 6; ++i) {
if (motionDataArray[i] != 0) {
if (enabled[i] == false)
motionDataArray[i] = 0;
else {
if (reversed[i] == true)
motionDataArray[i] = - motionDataArray[i];
motionDataArray[i] = (int)((float)(motionDataArray[i]) * sensitivity[i] * generalSensitivity);
}
}
}
xTrans = motionDataArray[0];
yTrans = motionDataArray[1];
zTrans = motionDataArray[2];
xRot = motionDataArray[3];
yRot = motionDataArray[4];
zRot = motionDataArray[5];
}
void MotionEvent::setMotionData(int &xTransIn, int &yTransIn, int &zTransIn, int &xRotIn, int &yRotIn, int &zRotIn){
int motionDataArray[6] = {xTransIn, yTransIn, zTransIn, xRotIn, yRotIn, zRotIn};
importSettings(motionDataArray);
}
void MotionEvent::translations(int &xTransOut, int &yTransOut, int &zTransOut)
{
xTransOut = xTrans;
@ -58,9 +176,8 @@ void MotionEvent::translations(int &xTransOut, int &yTransOut, int &zTransOut)
void MotionEvent::setTranslations(const int &xTransIn, const int &yTransIn, const int &zTransIn)
{
xTrans = xTransIn;
yTrans = yTransIn;
zTrans = zTransIn;
int motionDataArray[6] = {xTransIn, yTransIn, zTransIn, xRot, yRot, zRot};
importSettings(motionDataArray);
}
void MotionEvent::rotations(int &xRotOut, int &yRotOut, int &zRotOut)
@ -72,9 +189,8 @@ void MotionEvent::rotations(int &xRotOut, int &yRotOut, int &zRotOut)
void MotionEvent::setRotations(const int &xRotIn, const int &yRotIn, const int &zRotIn)
{
xRot = xRotIn;
yRot = yRotIn;
zRot = zRotIn;
int motionDataArray[6] = {xTrans, yTrans, zTrans, xRotIn, yRotIn, zRotIn};
importSettings(motionDataArray);
}

View File

@ -56,6 +56,7 @@ namespace Spaceball
int rotationY(){return yRot;}
int rotationZ(){return zRot;}
void setMotionData(int &xTransOut, int &yTransOut, int &zTransOut, int &xRotOut, int &yRotOut, int &zRotOut);
static int MotionEventType;
private:
@ -66,6 +67,8 @@ namespace Spaceball
int yRot;
int zRot;
bool handled;
void importSettings(int* motionDataArray);
float convertPrefToSensitivity(int value);
};
class ButtonEvent : public EventBase

View File

@ -45,6 +45,7 @@
#include "DlgCommandsImp.h"
#include "DlgKeyboardImp.h"
#include "DlgCustomizeSpaceball.h"
#include "DlgCustomizeSpNavSettings.h"
using namespace Gui;
using namespace Gui::Dialog;
@ -75,6 +76,7 @@ WidgetFactorySupplier::WidgetFactorySupplier()
new CustomPageProducer<DlgCustomToolbarsImp>;
//new CustomPageProducer<DlgCustomToolBoxbarsImp>;
new CustomPageProducer<DlgCustomActionsImp>;
new CustomPageProducer<DlgCustomizeSpNavSettings>;
new CustomPageProducer<DlgCustomizeSpaceball>;
// ADD YOUR PREFERENCE WIDGETS HERE