All: Reformat according to new standard
This commit is contained in:
committed by
Kacper Donat
parent
eafd18dac0
commit
25c3ba7338
@@ -21,7 +21,6 @@
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
@@ -33,21 +32,22 @@
|
||||
|
||||
|
||||
#if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND)
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
||||
#if defined(SPNAV_USE_X11)
|
||||
#include "3Dconnexion/GuiNativeEventLinuxX11.h"
|
||||
#else
|
||||
#include "3Dconnexion/GuiNativeEventLinux.h"
|
||||
#endif
|
||||
#elif defined(Q_OS_WIN)
|
||||
#include "3Dconnexion/GuiNativeEventWin32.h"
|
||||
#elif defined(Q_OS_MACOS)
|
||||
#include "3Dconnexion/GuiNativeEventMac.h"
|
||||
#endif // Platform switch
|
||||
#endif // Spacemice
|
||||
# if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
||||
# if defined(SPNAV_USE_X11)
|
||||
# include "3Dconnexion/GuiNativeEventLinuxX11.h"
|
||||
# else
|
||||
# include "3Dconnexion/GuiNativeEventLinux.h"
|
||||
# endif
|
||||
# elif defined(Q_OS_WIN)
|
||||
# include "3Dconnexion/GuiNativeEventWin32.h"
|
||||
# elif defined(Q_OS_MACOS)
|
||||
# include "3Dconnexion/GuiNativeEventMac.h"
|
||||
# endif // Platform switch
|
||||
#endif // Spacemice
|
||||
|
||||
Gui::GUIApplicationNativeEventAware::GUIApplicationNativeEventAware(int &argc, char *argv[]) :
|
||||
QApplication (argc, argv), spaceballPresent(false)
|
||||
Gui::GUIApplicationNativeEventAware::GUIApplicationNativeEventAware(int& argc, char* argv[])
|
||||
: QApplication(argc, argv)
|
||||
, spaceballPresent(false)
|
||||
{
|
||||
#if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND)
|
||||
nativeEvent = new Gui::GuiNativeEvent(this);
|
||||
@@ -56,12 +56,13 @@ Gui::GUIApplicationNativeEventAware::GUIApplicationNativeEventAware(int &argc, c
|
||||
|
||||
Gui::GUIApplicationNativeEventAware::~GUIApplicationNativeEventAware() = default;
|
||||
|
||||
void Gui::GUIApplicationNativeEventAware::initSpaceball(QMainWindow *window)
|
||||
void Gui::GUIApplicationNativeEventAware::initSpaceball(QMainWindow* window)
|
||||
{
|
||||
#if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND)
|
||||
# if defined(USE_3DCONNEXION_NAVLIB)
|
||||
ParameterGrp::handle hViewGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/View");
|
||||
"User parameter:BaseApp/Preferences/View"
|
||||
);
|
||||
if (nativeEvent && hViewGrp->GetBool("LegacySpaceMouseDevices", false)) {
|
||||
nativeEvent->initSpaceball(window);
|
||||
}
|
||||
@@ -75,7 +76,7 @@ void Gui::GUIApplicationNativeEventAware::initSpaceball(QMainWindow *window)
|
||||
Spaceball::ButtonEvent::ButtonEventType = QEvent::registerEventType();
|
||||
}
|
||||
|
||||
bool Gui::GUIApplicationNativeEventAware::processSpaceballEvent(QObject *object, QEvent *event)
|
||||
bool Gui::GUIApplicationNativeEventAware::processSpaceballEvent(QObject* object, QEvent* event)
|
||||
{
|
||||
if (!activeWindow()) {
|
||||
qDebug("No active window\n");
|
||||
@@ -83,27 +84,25 @@ bool Gui::GUIApplicationNativeEventAware::processSpaceballEvent(QObject *object,
|
||||
}
|
||||
|
||||
QApplication::notify(object, event);
|
||||
if (event->type() == Spaceball::MotionEvent::MotionEventType)
|
||||
{
|
||||
if (event->type() == Spaceball::MotionEvent::MotionEventType) {
|
||||
auto motionEvent = dynamic_cast<Spaceball::MotionEvent*>(event);
|
||||
if (!motionEvent)
|
||||
if (!motionEvent) {
|
||||
return true;
|
||||
if (!motionEvent->isHandled())
|
||||
{
|
||||
//make a new event and post to parent.
|
||||
}
|
||||
if (!motionEvent->isHandled()) {
|
||||
// make a new event and post to parent.
|
||||
auto newEvent = new Spaceball::MotionEvent(*motionEvent);
|
||||
postEvent(object->parent(), newEvent);
|
||||
}
|
||||
}
|
||||
|
||||
if (event->type() == Spaceball::ButtonEvent::ButtonEventType)
|
||||
{
|
||||
if (event->type() == Spaceball::ButtonEvent::ButtonEventType) {
|
||||
auto buttonEvent = dynamic_cast<Spaceball::ButtonEvent*>(event);
|
||||
if (!buttonEvent)
|
||||
if (!buttonEvent) {
|
||||
return true;
|
||||
if (!buttonEvent->isHandled())
|
||||
{
|
||||
//make a new event and post to parent.
|
||||
}
|
||||
if (!buttonEvent->isHandled()) {
|
||||
// make a new event and post to parent.
|
||||
auto newEvent = new Spaceball::ButtonEvent(*buttonEvent);
|
||||
postEvent(object->parent(), newEvent);
|
||||
}
|
||||
@@ -134,32 +133,32 @@ void Gui::GUIApplicationNativeEventAware::postButtonEvent(int buttonNumber, int
|
||||
|
||||
auto buttonEvent = new Spaceball::ButtonEvent();
|
||||
buttonEvent->setButtonNumber(buttonNumber);
|
||||
if (buttonPress)
|
||||
{
|
||||
buttonEvent->setButtonStatus(Spaceball::BUTTON_PRESSED);
|
||||
if (buttonPress) {
|
||||
buttonEvent->setButtonStatus(Spaceball::BUTTON_PRESSED);
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonEvent->setButtonStatus(Spaceball::BUTTON_RELEASED);
|
||||
else {
|
||||
buttonEvent->setButtonStatus(Spaceball::BUTTON_RELEASED);
|
||||
}
|
||||
this->postEvent(currentWidget, buttonEvent);
|
||||
}
|
||||
|
||||
float Gui::GUIApplicationNativeEventAware::convertPrefToSensitivity(int value)
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
return ((0.9/50)*float(value) + 1);
|
||||
if (value < 0) {
|
||||
return ((0.9 / 50) * float(value) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((2.5/50)*float(value) + 1);
|
||||
else {
|
||||
return ((2.5 / 50) * float(value) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void Gui::GUIApplicationNativeEventAware::importSettings(std::vector<int>& motionDataArray)
|
||||
{
|
||||
ParameterGrp::handle group = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Spaceball")->GetGroup("Motion");
|
||||
ParameterGrp::handle group = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Spaceball")
|
||||
->GetGroup("Motion");
|
||||
|
||||
// Remapping of motion data
|
||||
long remap = group->GetInt("Remapping", 12345);
|
||||
@@ -175,18 +174,19 @@ void Gui::GUIApplicationNativeEventAware::importSettings(std::vector<int>& motio
|
||||
std::string::size_type pos2 = std::string("012345").find_first_not_of(str);
|
||||
if (pos1 == std::string::npos && pos2 == std::string::npos) {
|
||||
std::vector<int> vec(str.size());
|
||||
std::transform(str.begin(), str.end(), vec.begin(), [](char c) -> int { return c - '0';});
|
||||
std::transform(str.begin(), str.end(), vec.begin(), [](char c) -> int { return c - '0'; });
|
||||
|
||||
std::vector<int> copy = motionDataArray;
|
||||
for (int i=0; i<6; i++) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
motionDataArray[i] = copy[vec[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
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
|
||||
@@ -199,7 +199,7 @@ void Gui::GUIApplicationNativeEventAware::importSettings(std::vector<int>& motio
|
||||
enabled[5] = group->GetBool("Rotations", true) && group->GetBool("SpinEnable", true);
|
||||
|
||||
// array that has stored info about "Reversed" checkboxes of all axes
|
||||
bool reversed[6];
|
||||
bool reversed[6];
|
||||
reversed[0] = group->GetBool("PanLRReverse");
|
||||
reversed[1] = group->GetBool("PanUDReverse");
|
||||
reversed[2] = group->GetBool("ZoomReverse");
|
||||
@@ -207,8 +207,9 @@ void Gui::GUIApplicationNativeEventAware::importSettings(std::vector<int>& motio
|
||||
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
|
||||
// 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"));
|
||||
@@ -217,21 +218,19 @@ void Gui::GUIApplicationNativeEventAware::importSettings(std::vector<int>& motio
|
||||
sensitivity[4] = convertPrefToSensitivity(group->GetInt("RollSensitivity"));
|
||||
sensitivity[5] = convertPrefToSensitivity(group->GetInt("SpinSensitivity"));
|
||||
|
||||
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]);
|
||||
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
|
||||
{
|
||||
else {
|
||||
motionDataArray[0] = motionDataArray[0] - group->GetInt("CalibrationX");
|
||||
motionDataArray[1] = motionDataArray[1] - group->GetInt("CalibrationY");
|
||||
motionDataArray[2] = motionDataArray[2] - group->GetInt("CalibrationZ");
|
||||
@@ -243,55 +242,58 @@ void Gui::GUIApplicationNativeEventAware::importSettings(std::vector<int>& motio
|
||||
int i;
|
||||
|
||||
if (flipXY) {
|
||||
bool tempBool;
|
||||
bool tempBool;
|
||||
float tempFloat;
|
||||
|
||||
tempBool = enabled[1];
|
||||
tempBool = enabled[1];
|
||||
enabled[1] = enabled[2];
|
||||
enabled[2] = tempBool;
|
||||
|
||||
tempBool = enabled[4];
|
||||
tempBool = enabled[4];
|
||||
enabled[4] = enabled[5];
|
||||
enabled[5] = tempBool;
|
||||
|
||||
|
||||
tempBool = reversed[1];
|
||||
tempBool = reversed[1];
|
||||
reversed[1] = reversed[2];
|
||||
reversed[2] = tempBool;
|
||||
|
||||
tempBool = reversed[4];
|
||||
tempBool = reversed[4];
|
||||
reversed[4] = reversed[5];
|
||||
reversed[5] = tempBool;
|
||||
|
||||
|
||||
tempFloat = sensitivity[1];
|
||||
tempFloat = sensitivity[1];
|
||||
sensitivity[1] = sensitivity[2];
|
||||
sensitivity[2] = tempFloat;
|
||||
|
||||
tempFloat = sensitivity[4];
|
||||
tempFloat = sensitivity[4];
|
||||
sensitivity[4] = sensitivity[5];
|
||||
sensitivity[5] = tempFloat;
|
||||
|
||||
|
||||
i = motionDataArray[1];
|
||||
motionDataArray[1] = motionDataArray[2];
|
||||
motionDataArray[2] = - i;
|
||||
motionDataArray[2] = -i;
|
||||
|
||||
i = motionDataArray[4];
|
||||
motionDataArray[4] = motionDataArray[5];
|
||||
motionDataArray[5] = - i;
|
||||
motionDataArray[5] = -i;
|
||||
}
|
||||
|
||||
if (dominant) { // if dominant is checked
|
||||
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];
|
||||
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) {
|
||||
}
|
||||
else if (motionDataArray[i] == max) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
@@ -299,12 +301,15 @@ void Gui::GUIApplicationNativeEventAware::importSettings(std::vector<int>& motio
|
||||
|
||||
for (i = 0; i < 6; ++i) {
|
||||
if (motionDataArray[i] != 0) {
|
||||
if (!enabled[i])
|
||||
if (!enabled[i]) {
|
||||
motionDataArray[i] = 0;
|
||||
}
|
||||
else {
|
||||
if (reversed[i])
|
||||
motionDataArray[i] = - motionDataArray[i];
|
||||
motionDataArray[i] = (int)((float)(motionDataArray[i]) * sensitivity[i] * generalSensitivity);
|
||||
if (reversed[i]) {
|
||||
motionDataArray[i] = -motionDataArray[i];
|
||||
}
|
||||
motionDataArray[i] = (int)((float)(motionDataArray[i]) * sensitivity[i]
|
||||
* generalSensitivity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user