Browse Source

Implement insufficient trackpoint count warning

Johannes Kreutz 2 years ago
parent
commit
9c68bd0430

+ 41 - 2
trackpoint-app/gui/EditWidget.ui

@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>553</width>
-    <height>1076</height>
+    <height>912</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -40,7 +40,7 @@
         <x>0</x>
         <y>0</y>
         <width>551</width>
-        <height>1090</height>
+        <height>1114</height>
        </rect>
       </property>
       <layout class="QVBoxLayout" name="verticalLayout_7">
@@ -446,6 +446,9 @@
            <verstretch>0</verstretch>
           </sizepolicy>
          </property>
+         <property name="styleSheet">
+          <string notr="true"/>
+         </property>
          <property name="currentIndex">
           <number>0</number>
          </property>
@@ -467,6 +470,22 @@
              </property>
             </widget>
            </item>
+           <item>
+            <widget class="QLabel" name="optiTrackCheck">
+             <property name="styleSheet">
+              <string notr="true">color: lightgreen</string>
+             </property>
+             <property name="text">
+              <string>Everything is fine.</string>
+             </property>
+             <property name="margin">
+              <number>0</number>
+             </property>
+             <property name="indent">
+              <number>-1</number>
+             </property>
+            </widget>
+           </item>
            <item>
             <widget class="QGroupBox" name="optiTrackProperties">
              <property name="font">
@@ -576,6 +595,16 @@
              </property>
             </widget>
            </item>
+           <item>
+            <widget class="QLabel" name="emfTrackCheck">
+             <property name="styleSheet">
+              <string notr="true">color: lightgreen</string>
+             </property>
+             <property name="text">
+              <string>Everything is fine.</string>
+             </property>
+            </widget>
+           </item>
            <item>
             <widget class="QGroupBox" name="emfTrackProperties">
              <property name="font">
@@ -676,6 +705,16 @@
              </property>
             </widget>
            </item>
+           <item>
+            <widget class="QLabel" name="steamvrCheck">
+             <property name="styleSheet">
+              <string notr="true">color: lightgreen</string>
+             </property>
+             <property name="text">
+              <string>Everything is fine.</string>
+             </property>
+            </widget>
+           </item>
            <item>
             <widget class="QGroupBox" name="steamVrProperties">
              <property name="font">

+ 2 - 0
trackpoint-app/include/EMFTrackPoint.hpp

@@ -14,9 +14,11 @@ public:
   EMFTrackSettings getEMFTrackSettings();
   void updateEMFTrackSettings(EMFTrackSettings settings);
   float getNormalCompensation();
+  static int getMinimumRequiredPoints();
 
 private:
   double _width;
   double _height;
   double _depth;
+  static const int _minimumPointsRequired = 1;
 };

+ 1 - 0
trackpoint-app/include/EditWidget.hpp

@@ -60,6 +60,7 @@ private slots:
   void setOptiTrackSanityCheckStatus();
   void manualSteamVRTrackCollisionCheck();
   void setSteamVRTrackCollisionCheckStatus();
+  void setCountCheckString(ActiveTrackingSystem activeTrackingSystem);
 
 private:
   Ui::EditWidget* ui;

+ 2 - 0
trackpoint-app/include/OptiTrackPoint.hpp

@@ -13,9 +13,11 @@ public:
   OptiTrackSettings getOptiTrackSettings();
   void updateOptiTrackSettings(OptiTrackSettings settings);
   float getNormalCompensation();
+  static int getMinimumRequiredPoints();
 
 private:
   void updateShift();
   double _length;
   double _radius;
+  static const int _minimumPointsRequired = 3;
 };

+ 2 - 0
trackpoint-app/include/ProjectStore.hpp

@@ -67,6 +67,8 @@ public:
   void updateCompensation(bool compensation);
   // Return compensation
   bool getCompensation();
+  // Get the minimum required trackpoint count for a given tracking system
+  int getMinimumRequiredPoints(ActiveTrackingSystem activeTrackingSystem);
   // OPTITRACK
   // Get all OptiTrack points
   std::vector<OptiTrackPoint*> getOptiTrackPoints();

+ 2 - 0
trackpoint-app/include/SteamVRTrackPoint.hpp

@@ -12,8 +12,10 @@ public:
   SteamVRTrackSettings getSteamVRTrackSettings();
   void updateSteamVRTrackSettings(SteamVRTrackSettings settings);
   float getNormalCompensation();
+  static int getMinimumRequiredPoints();
 
 private:
   void updateShift();
   double _length;
+  static const int _minimumPointsRequired = 1;
 };

+ 4 - 0
trackpoint-app/src/EMFTrackPoint.cpp

@@ -36,3 +36,7 @@ float EMFTrackPoint::getNormalCompensation() {
   float compensationLength = MeshTools::compensationLength(_normal, _normalModifier, std::sqrt(std::pow(_width / 2, 2) + std::pow(_height / 2, 2)));
   return compensationLength > 0.0f ? compensationLength : 0.0f;
 }
+
+int EMFTrackPoint::getMinimumRequiredPoints() {
+    return _minimumPointsRequired;
+}

+ 46 - 0
trackpoint-app/src/EditWidget.cpp

@@ -11,6 +11,7 @@
 
 // Include dependencies
 #include <sstream>
+#include <iostream>
 #include <QFileDialog>
 
 EditWidget::EditWidget(QWidget* parent): QWidget(parent), ui(new Ui::EditWidget) {
@@ -151,6 +152,7 @@ void EditWidget::updateTrackpointCount() {
     QString countString("TRACKPOINTS SET: ");
     countString.append(QString::number(count));
     ui->optiTrackCount->setText(countString);
+    setCountCheckString(OptiTrack);
   }
 
   count = MainWindow::getInstance()->getStore()->getCount(EMFTrack);
@@ -158,6 +160,7 @@ void EditWidget::updateTrackpointCount() {
     QString countString("TRACKPOINTS SET: ");
     countString.append(QString::number(count));
     ui->emfTrackCount->setText(countString);
+    setCountCheckString(EMFTrack);
   }
 
   count = MainWindow::getInstance()->getStore()->getCount(SteamVRTrack);
@@ -165,6 +168,7 @@ void EditWidget::updateTrackpointCount() {
     QString countString("TRACKPOINTS SET: ");
     countString.append(QString::number(count));
     ui->steamVrTrackCount->setText(countString);
+    setCountCheckString(SteamVRTrack);
   }
 
   count = MainWindow::getInstance()->getStore()->getCount(ActionPoints);
@@ -187,6 +191,7 @@ void EditWidget::resetAllSettings() {
   updateEMFTrackSettings(true);
   updateSteamVRTrackSettings(true);
   resetActionPointSettings();
+  updateTrackpointCount();
 }
 
 void EditWidget::setExportAvailable(bool available) {
@@ -526,3 +531,44 @@ void EditWidget::manualSteamVRTrackCollisionCheck() {
 void EditWidget::setSteamVRTrackCollisionCheckStatus() {
   _steamVrTrackCollisionCheck = ui->compensation->checkState() == Qt::Checked ? true : false;
 }
+
+void EditWidget::setCountCheckString(ActiveTrackingSystem activeTrackingSystem) {
+  int required = MainWindow::getInstance()->getStore()->getMinimumRequiredPoints(activeTrackingSystem);
+  int available = MainWindow::getInstance()->getStore()->getCount(activeTrackingSystem);
+  std::cout << available << " " << required << std::endl;
+  QString okString("Everything is fine.");
+  QString okStyle("color: lightgreen");
+  QString errorString = QStringLiteral("Insufficient trackpoint count: Placed %1 but needs at least %2").arg(available).arg(required);
+  QString errorStyle("color: yellow");
+  switch(activeTrackingSystem) {
+    case OptiTrack:
+      if (available >= required) {
+        ui->optiTrackCheck->setText(okString);
+        ui->optiTrackCheck->setStyleSheet(okStyle);
+      } else {
+        ui->optiTrackCheck->setText(errorString);
+        ui->optiTrackCheck->setStyleSheet(errorStyle);
+      }
+      break;
+    case EMFTrack:
+      if (available >= required) {
+        ui->emfTrackCheck->setText(okString);
+        ui->emfTrackCheck->setStyleSheet(okStyle);
+      } else {
+        ui->emfTrackCheck->setText(errorString);
+        ui->emfTrackCheck->setStyleSheet(errorStyle);
+      }
+      break;
+    case SteamVRTrack:
+      if (available >= required) {
+        ui->steamvrCheck->setText(okString);
+        ui->steamvrCheck->setStyleSheet(okStyle);
+      } else {
+        ui->steamvrCheck->setText(errorString);
+        ui->steamvrCheck->setStyleSheet(errorStyle);
+      }
+      break;
+    case ActionPoints:
+      break;
+  }
+}

+ 4 - 0
trackpoint-app/src/OptiTrackPoint.cpp

@@ -37,3 +37,7 @@ float OptiTrackPoint::getNormalCompensation() {
   float compensationLength = MeshTools::compensationLength(_normal, _normalModifier, _radius);
   return compensationLength > 0.0f ? compensationLength : 0.0f;
 }
+
+int OptiTrackPoint::getMinimumRequiredPoints() {
+    return _minimumPointsRequired;
+}

+ 13 - 0
trackpoint-app/src/ProjectStore.cpp

@@ -260,6 +260,19 @@ bool ProjectStore::getCompensation() {
   return _compensation;
 }
 
+int ProjectStore::getMinimumRequiredPoints(ActiveTrackingSystem activeTrackingSystem) {
+  switch(activeTrackingSystem) {
+    case OptiTrack:
+      return OptiTrackPoint::getMinimumRequiredPoints();
+    case EMFTrack:
+      return EMFTrackPoint::getMinimumRequiredPoints();
+    case SteamVRTrack:
+      return SteamVRTrackPoint::getMinimumRequiredPoints();
+    case ActionPoints:
+      return 0;
+  }
+}
+
 std::vector<OptiTrackPoint*> ProjectStore::getOptiTrackPoints() {
   return _optiTrackPoints;
 }

+ 4 - 0
trackpoint-app/src/SteamVRTrackPoint.cpp

@@ -31,3 +31,7 @@ float SteamVRTrackPoint::getNormalCompensation() {
   float compensationLength = MeshTools::compensationLength(_normal, _normalModifier, STEAMVR_CONSTANT_RADIUS);
   return compensationLength > 0.0f ? compensationLength : 0.0f;
 }
+
+int SteamVRTrackPoint::getMinimumRequiredPoints() {
+    return _minimumPointsRequired;
+}