diff options
Diffstat (limited to 'tracker-fusion')
-rw-r--r-- | tracker-fusion/fusion.cpp | 53 | ||||
-rw-r--r-- | tracker-fusion/fusion.h | 4 |
2 files changed, 33 insertions, 24 deletions
diff --git a/tracker-fusion/fusion.cpp b/tracker-fusion/fusion.cpp index 07f6483f..0b81b682 100644 --- a/tracker-fusion/fusion.cpp +++ b/tracker-fusion/fusion.cpp @@ -22,10 +22,7 @@ static auto get_modules() return Modules(OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH); } -fusion_tracker::fusion_tracker() : - rot_tracker_data{}, - pos_tracker_data{}, - other_frame(new QFrame) +fusion_tracker::fusion_tracker() { } @@ -52,11 +49,14 @@ const QString& fusion_tracker::caption() return caption; } -void fusion_tracker::start_tracker(QFrame* frame) +module_status fusion_tracker::start_tracker(QFrame* frame) { assert(!rot_tracker && !pos_tracker); assert(!rot_dylib && !pos_dylib); + QString err; + module_status status; + fusion_settings s; const QString rot_tracker_name = s.rot_tracker_name().toString(); const QString pos_tracker_name = s.pos_tracker_name().toString(); @@ -65,14 +65,15 @@ void fusion_tracker::start_tracker(QFrame* frame) assert(pos_tracker_name != own_name); if (rot_tracker_name.isEmpty() || pos_tracker_name.isEmpty()) - goto fail; + { + err = tr("Trackers not selected."); + goto end; + } if (rot_tracker_name == pos_tracker_name) { - QMessageBox::warning(nullptr, caption(), - tr("Select different trackers for rotation and position."), - QMessageBox::Close); - goto cleanup; + err = tr("Select different trackers for rotation and position."); + goto end; } { @@ -95,17 +96,28 @@ void fusion_tracker::start_tracker(QFrame* frame) } if (!rot_dylib || !pos_dylib) - goto fail; + goto end; rot_tracker = make_dylib_instance<ITracker>(rot_dylib); pos_tracker = make_dylib_instance<ITracker>(pos_dylib); - pos_tracker->start_tracker(frame); + status = pos_tracker->start_tracker(frame); + + if (!status.is_ok()) + { + err = pos_dylib->name + QStringLiteral(":\n ") + status.error; + goto end; + } if (frame->layout() == nullptr) { - rot_tracker->start_tracker(frame); + status = rot_tracker->start_tracker(frame); other_frame = nullptr; + if (!status.is_ok()) + { + err = rot_dylib->name + QStringLiteral(":\n ") + status.error; + goto end; + } } else { @@ -121,14 +133,11 @@ void fusion_tracker::start_tracker(QFrame* frame) } - return; - -fail: - QMessageBox::warning(nullptr, - caption(), tr("Select rotation and position trackers."), - QMessageBox::Close); -cleanup: - other_frame = nullptr; +end: + if (!err.isEmpty()) + return error(err); + else + return status_ok(); } void fusion_tracker::data(double *data) @@ -203,4 +212,4 @@ fusion_settings::fusion_settings() : { } -OPENTRACK_DECLARE_TRACKER(fusion_tracker, fusion_dialog, fusion_metadata)
\ No newline at end of file +OPENTRACK_DECLARE_TRACKER(fusion_tracker, fusion_dialog, fusion_metadata) diff --git a/tracker-fusion/fusion.h b/tracker-fusion/fusion.h index 28e584da..96a1a496 100644 --- a/tracker-fusion/fusion.h +++ b/tracker-fusion/fusion.h @@ -19,7 +19,7 @@ class fusion_tracker : public QObject, public ITracker { Q_OBJECT - double rot_tracker_data[6], pos_tracker_data[6]; + double rot_tracker_data[6] {}, pos_tracker_data[6] {}; std::unique_ptr<QFrame> other_frame; std::shared_ptr<dylib> rot_dylib, pos_dylib; @@ -28,7 +28,7 @@ class fusion_tracker : public QObject, public ITracker public: fusion_tracker(); ~fusion_tracker() override; - void start_tracker(QFrame*) override; + module_status start_tracker(QFrame*) override; void data(double* data) override; static const QString& caption(); |