EditWidget.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. // Include own headers
  2. #include "EditWidget.hpp"
  3. #include "../gui/ui_EditWidget.h"
  4. // Include modules
  5. #include "OSGWidget.hpp"
  6. #include "PickHandler.hpp"
  7. #include "TrackPointRenderer.hpp"
  8. #include "OpenScadRenderer.hpp"
  9. #include "MeshTools.hpp"
  10. // Include dependencies
  11. #include <sstream>
  12. #include <QFileDialog>
  13. EditWidget::EditWidget(QWidget* parent): QWidget(parent), ui(new Ui::EditWidget) {
  14. ui->setupUi(this);
  15. ui->actionPointDoubleIdentifier->setVisible(false);
  16. ui->insertionToolButton->setCheckable(true);
  17. ui->insertionToolButton->setChecked(true);
  18. QObject::connect(ui->insertionToolButton, &QToolButton::clicked, this, [=](){ this->selectTool(InsertionTool); });
  19. ui->selectionToolButton->setCheckable(true);
  20. QObject::connect(ui->selectionToolButton, &QToolButton::clicked, this, [=](){ this->selectTool(SelectionTool); });
  21. QObject::connect(ui->tabWidget, &QTabWidget::currentChanged, this, &EditWidget::tabChanged);
  22. // Modifiers
  23. QObject::connect(ui->anchorX, &QDoubleSpinBox::valueChanged, this, &EditWidget::changePositions);
  24. QObject::connect(ui->anchorY, &QDoubleSpinBox::valueChanged, this, &EditWidget::changePositions);
  25. QObject::connect(ui->anchorZ, &QDoubleSpinBox::valueChanged, this, &EditWidget::changePositions);
  26. QObject::connect(ui->normalModX, &QDoubleSpinBox::valueChanged, this, &EditWidget::updateNormalModifier);
  27. QObject::connect(ui->normalModY, &QDoubleSpinBox::valueChanged, this, &EditWidget::updateNormalModifier);
  28. QObject::connect(ui->normalModZ, &QDoubleSpinBox::valueChanged, this, &EditWidget::updateNormalModifier);
  29. QObject::connect(ui->rotateAroundNormal, &QDoubleSpinBox::valueChanged, this, [=](){ this->updateNormalRotation(false); });
  30. QObject::connect(ui->compensation, &QCheckBox::stateChanged, this, [=](){ this->updateCompensation(false); });
  31. QObject::connect(ui->modifierReset, &QPushButton::clicked, this, &EditWidget::resetNormalModifier);
  32. // OptiTrack settings
  33. QObject::connect(ui->optiTrackLength, &QDoubleSpinBox::valueChanged, this, [=](){ this->updateOptiTrackSettings(false); });
  34. QObject::connect(ui->optiTrackRadius, &QDoubleSpinBox::valueChanged, this, [=](){ this->updateOptiTrackSettings(false); });
  35. QObject::connect(ui->optiTrackLoadDefaults, &QPushButton::clicked, this, [=](){ this->updateOptiTrackSettings(true); });
  36. QObject::connect(ui->optiTrackSanityCheck, &QPushButton::clicked, this, &EditWidget::manualOptiTrackSanityCheck);
  37. QObject::connect(ui->optiTrackEnableSanityCheck, &QCheckBox::stateChanged, this, &EditWidget::setOptiTrackSanityCheckStatus);
  38. // EMF Track settings
  39. QObject::connect(ui->emfTrackWidth, &QDoubleSpinBox::valueChanged, this, [=](){ this->updateEMFTrackSettings(false); });
  40. QObject::connect(ui->emfTrackHeight, &QDoubleSpinBox::valueChanged, this, [=](){ this->updateEMFTrackSettings(false); });
  41. QObject::connect(ui->emfTrackDepth, &QDoubleSpinBox::valueChanged, this, [=](){ this->updateEMFTrackSettings(false); });
  42. QObject::connect(ui->emfTrackLoadDefaults, &QPushButton::clicked, this, [=](){ this->updateEMFTrackSettings(true); });
  43. // StramVRTrack settings
  44. QObject::connect(ui->steamVrTrackLength, &QDoubleSpinBox::valueChanged, this, [=](){ this->updateSteamVRTrackSettings(false); });
  45. QObject::connect(ui->steamVrTrackLoadDefaults, &QPushButton::clicked, this, [=](){ this->updateSteamVRTrackSettings(true); });
  46. QObject::connect(ui->steamVrTrackCollisionCheck, &QPushButton::clicked, this, &EditWidget::manualSteamVRTrackCollisionCheck);
  47. QObject::connect(ui->steamVrTrackEnableCollisionCheck, &QCheckBox::stateChanged, this, &EditWidget::setSteamVRTrackCollisionCheckStatus);
  48. // Action point settings
  49. QObject::connect(ui->actionPointIdentifier, &QLineEdit::textChanged, this, &EditWidget::updateActionPointSettings);
  50. QObject::connect(ui->actionPointLoadDefaults, &QPushButton::clicked, this, &EditWidget::resetActionPointSettings);
  51. // Delete button
  52. QObject::connect(ui->deleteTrackPoint, &QPushButton::clicked, this, &EditWidget::deleteCurrentTrackPoint);
  53. // Export button
  54. QObject::connect(ui->exportButton, &QPushButton::clicked, this, &EditWidget::exportProject);
  55. if (!OpenScadRenderer::openScadAvailable()) {
  56. ui->exportGroup->setEnabled(false);
  57. }
  58. ui->exportProgress->setVisible(false);
  59. ui->exportLabel->setVisible(false);
  60. }
  61. EditWidget::~EditWidget() {
  62. delete ui;
  63. }
  64. void EditWidget::updatePositions(osg::Vec3 point) {
  65. ui->anchorX->setValue(point.x());
  66. ui->anchorY->setValue(point.y());
  67. ui->anchorZ->setValue(point.z());
  68. }
  69. void EditWidget::updateNormals(osg::Vec3 normal) {
  70. ui->normalX->setText(QString::number(normal.x()));
  71. ui->normalY->setText(QString::number(normal.y()));
  72. ui->normalZ->setText(QString::number(normal.z()));
  73. }
  74. void EditWidget::invalidatePositions() {
  75. ui->deleteTrackPoint->setEnabled(false);
  76. ui->anchorX->setValue(0.0f);
  77. ui->anchorY->setValue(0.0f);
  78. ui->anchorZ->setValue(0.0f);
  79. ui->normalX->setText("-");
  80. ui->normalY->setText("-");
  81. ui->normalZ->setText("-");
  82. }
  83. ActiveTrackingSystem EditWidget::getSelectedTrackingSystem() {
  84. switch(ui->tabWidget->currentIndex()) {
  85. case 0: {
  86. return OptiTrack;
  87. }
  88. case 1: {
  89. return EMFTrack;
  90. }
  91. case 2: {
  92. return SteamVRTrack;
  93. }
  94. default: {
  95. return ActionPoints;
  96. }
  97. }
  98. }
  99. void EditWidget::setSelection(int id) {
  100. selectedPoint = id;
  101. ui->deleteTrackPoint->setEnabled(true);
  102. TrackPoint* point;
  103. switch(ui->tabWidget->currentIndex()) {
  104. case 0: {
  105. OptiTrackPoint* optiPoint = MainWindow::getInstance()->getStore()->getOptiTrackPoints()[id];
  106. setOptiTrackSettings(optiPoint->getLength(), optiPoint->getRadius());
  107. point = static_cast<TrackPoint*>(optiPoint);
  108. break;
  109. }
  110. case 1: {
  111. EMFTrackPoint* emfPoint = MainWindow::getInstance()->getStore()->getEMFTrackPoints()[id];
  112. setEMFTrackSettings(emfPoint->getWidth(), emfPoint->getHeight(), emfPoint->getDepth());
  113. point = static_cast<TrackPoint*>(emfPoint);
  114. break;
  115. }
  116. case 2: {
  117. SteamVRTrackPoint* steamVrPoint = MainWindow::getInstance()->getStore()->getSteamVRTrackPoints()[id];
  118. setSteamVRTrackSettings(steamVrPoint->getLength());
  119. point = static_cast<TrackPoint*>(steamVrPoint);
  120. break;
  121. }
  122. default: {
  123. ActionPoint* actionPoint = MainWindow::getInstance()->getStore()->getActionPoints()[id];
  124. setActionPointSettings(actionPoint->getIdentifier());
  125. point = static_cast<TrackPoint*>(actionPoint);
  126. break;
  127. }
  128. }
  129. updatePositions(point->getTranslation());
  130. updateNormals(point->getNormal());
  131. setNormalModifier(point->getNormalModifier());
  132. }
  133. int EditWidget::getSelectedPoint() {
  134. return selectedPoint;
  135. }
  136. void EditWidget::updateTrackpointCount() {
  137. int count;
  138. count = MainWindow::getInstance()->getStore()->getCount(OptiTrack);
  139. {
  140. QString countString("TRACKPOINTS SET: ");
  141. countString.append(QString::number(count));
  142. ui->optiTrackCount->setText(countString);
  143. }
  144. count = MainWindow::getInstance()->getStore()->getCount(EMFTrack);
  145. {
  146. QString countString("TRACKPOINTS SET: ");
  147. countString.append(QString::number(count));
  148. ui->emfTrackCount->setText(countString);
  149. }
  150. count = MainWindow::getInstance()->getStore()->getCount(SteamVRTrack);
  151. {
  152. QString countString("TRACKPOINTS SET: ");
  153. countString.append(QString::number(count));
  154. ui->steamVrTrackCount->setText(countString);
  155. }
  156. count = MainWindow::getInstance()->getStore()->getCount(ActionPoints);
  157. {
  158. QString countString("ACTION POINTS SET: ");
  159. countString.append(QString::number(count));
  160. ui->actionPointCount->setText(countString);
  161. }
  162. }
  163. void EditWidget::showEvent(QShowEvent* event) {
  164. QWidget::showEvent(event);
  165. resetAllSettings();
  166. }
  167. void EditWidget::resetAllSettings() {
  168. selectedPoint = -1;
  169. resetNormalModifier();
  170. updateOptiTrackSettings(true);
  171. updateEMFTrackSettings(true);
  172. updateSteamVRTrackSettings(true);
  173. resetActionPointSettings();
  174. }
  175. void EditWidget::setExportAvailable(bool available) {
  176. ui->exportButton->setVisible(available);
  177. ui->exportProgress->setVisible(!available);
  178. ui->exportLabel->setVisible(!available);
  179. }
  180. void EditWidget::setExportStatus(int jobs, int done) {
  181. ui->exportProgress->setValue(done);
  182. std::stringstream text;
  183. text << "Export running: " << done << " of " << jobs << " finished.";
  184. ui->exportLabel->setText(QString::fromUtf8(text.str().c_str()));
  185. }
  186. bool EditWidget::getOptiTrackSanityCheckStatus() {
  187. return _optiTrackSanityCheck;
  188. }
  189. bool EditWidget::getSteamVRTrackCollisionCheckStatus() {
  190. return _steamVrTrackCollisionCheck;
  191. }
  192. void EditWidget::selectTool(Tool tool) {
  193. switch(tool) {
  194. case InsertionTool: {
  195. ui->insertionToolButton->setChecked(true);
  196. ui->selectionToolButton->setChecked(false);
  197. MainWindow::getInstance()->getOsgWidget()->getPicker()->setSelection(true);
  198. resetAllSettings();
  199. invalidatePositions();
  200. setPositionEditing(true);
  201. break;
  202. }
  203. case SelectionTool: {
  204. ui->insertionToolButton->setChecked(false);
  205. ui->selectionToolButton->setChecked(true);
  206. MainWindow::getInstance()->getOsgWidget()->getPicker()->setSelection(false);
  207. setPositionEditing(false);
  208. break;
  209. }
  210. }
  211. }
  212. void EditWidget::tabChanged(int index) {
  213. if (selectedPoint < 0) {
  214. MainWindow::getInstance()->getOsgWidget()->getPicker()->updateRenderer();
  215. }
  216. selectedPoint = -1;
  217. ActiveTrackingSystem activeTrackingSystem = getSelectedTrackingSystem();
  218. MainWindow::getInstance()->getOsgWidget()->getPointRenderer()->render(activeTrackingSystem);
  219. }
  220. void EditWidget::updateNormalModifier() {
  221. osg::Vec3 modifier = osg::Vec3(ui->normalModX->value(), ui->normalModY->value(), ui->normalModZ->value());
  222. if (selectedPoint < 0) {
  223. MainWindow::getInstance()->getStore()->updateNormalModifier(modifier);
  224. MainWindow::getInstance()->getOsgWidget()->getPicker()->updateRenderer();
  225. } else {
  226. ActiveTrackingSystem activeTrackingSystem = getSelectedTrackingSystem();
  227. MainWindow::getInstance()->getStore()->getTrackPointById(selectedPoint, activeTrackingSystem)->updateNormalModifier(modifier);
  228. MainWindow::getInstance()->getOsgWidget()->getPointRenderer()->render(activeTrackingSystem);
  229. MainWindow::getInstance()->getStore()->projectModified();
  230. if (activeTrackingSystem == OptiTrack) {
  231. MeshTools::optiTrackSanityCheck(MainWindow::getInstance()->getStore()->getOptiTrackPoints(), false);
  232. } else if (activeTrackingSystem == SteamVRTrack) {
  233. MeshTools::steamVrTrackCollisionCheck(MainWindow::getInstance()->getStore()->getSteamVRTrackPoints(), false, MainWindow::getInstance()->getOsgWidget()->getVerifyGroup());
  234. }
  235. }
  236. }
  237. void EditWidget::resetNormalModifier() {
  238. osg::Vec3 modifier = osg::Vec3(0.0f, 0.0f, 0.0f);
  239. ui->normalModX->setValue(0.0f);
  240. ui->normalModY->setValue(0.0f);
  241. ui->normalModZ->setValue(0.0f);
  242. if (selectedPoint < 0) {
  243. MainWindow::getInstance()->getStore()->updateNormalModifier(modifier);
  244. MainWindow::getInstance()->getOsgWidget()->getPicker()->updateRenderer();
  245. } else {
  246. ActiveTrackingSystem activeTrackingSystem = getSelectedTrackingSystem();
  247. MainWindow::getInstance()->getStore()->getTrackPointById(selectedPoint, activeTrackingSystem)->updateNormalModifier(modifier);
  248. MainWindow::getInstance()->getOsgWidget()->getPointRenderer()->render(activeTrackingSystem);
  249. MainWindow::getInstance()->getStore()->projectModified();
  250. if (activeTrackingSystem == OptiTrack) {
  251. MeshTools::optiTrackSanityCheck(MainWindow::getInstance()->getStore()->getOptiTrackPoints(), false);
  252. } else if (activeTrackingSystem == SteamVRTrack) {
  253. MeshTools::steamVrTrackCollisionCheck(MainWindow::getInstance()->getStore()->getSteamVRTrackPoints(), false, MainWindow::getInstance()->getOsgWidget()->getVerifyGroup());
  254. }
  255. }
  256. }
  257. void EditWidget::setNormalModifier(osg::Vec3 normalModifier) {
  258. ui->normalModX->setValue(normalModifier.x());
  259. ui->normalModY->setValue(normalModifier.y());
  260. ui->normalModZ->setValue(normalModifier.z());
  261. }
  262. void EditWidget::updateNormalRotation(bool reset) {
  263. float normalRotation;
  264. if (reset) {
  265. normalRotation = 0.0f;
  266. } else {
  267. normalRotation = ui->rotateAroundNormal->value();
  268. }
  269. if (selectedPoint < 0) {
  270. MainWindow::getInstance()->getStore()->updateNormalRotation(normalRotation);
  271. MainWindow::getInstance()->getOsgWidget()->getPicker()->updateRenderer();
  272. } else {
  273. ActiveTrackingSystem activeTrackingSystem = getSelectedTrackingSystem();
  274. MainWindow::getInstance()->getStore()->getTrackPointById(selectedPoint, activeTrackingSystem)->updateNormalRotation(normalRotation);
  275. MainWindow::getInstance()->getOsgWidget()->getPointRenderer()->render(activeTrackingSystem);
  276. MainWindow::getInstance()->getStore()->projectModified();
  277. if (activeTrackingSystem == OptiTrack) {
  278. MeshTools::optiTrackSanityCheck(MainWindow::getInstance()->getStore()->getOptiTrackPoints(), false);
  279. } else if (activeTrackingSystem == SteamVRTrack) {
  280. MeshTools::steamVrTrackCollisionCheck(MainWindow::getInstance()->getStore()->getSteamVRTrackPoints(), false, MainWindow::getInstance()->getOsgWidget()->getVerifyGroup());
  281. }
  282. }
  283. }
  284. void EditWidget::setNormalRotation(float normalRotation) {
  285. ui->rotateAroundNormal->value();
  286. }
  287. void EditWidget::updateCompensation(bool reset) {
  288. bool compensation;
  289. if (reset) {
  290. compensation = true;
  291. } else {
  292. compensation = ui->compensation->checkState() == Qt::Checked ? true : false;
  293. }
  294. if (selectedPoint < 0) {
  295. MainWindow::getInstance()->getStore()->updateCompensation(compensation);
  296. MainWindow::getInstance()->getOsgWidget()->getPicker()->updateRenderer();
  297. } else {
  298. ActiveTrackingSystem activeTrackingSystem = getSelectedTrackingSystem();
  299. MainWindow::getInstance()->getStore()->getTrackPointById(selectedPoint, activeTrackingSystem)->updateCompensation(compensation);
  300. MainWindow::getInstance()->getOsgWidget()->getPointRenderer()->render(activeTrackingSystem);
  301. MainWindow::getInstance()->getStore()->projectModified();
  302. }
  303. }
  304. void EditWidget::setCompensation(bool compensation) {
  305. if (compensation) {
  306. ui->compensation->setCheckState(Qt::Checked);
  307. } else {
  308. ui->compensation->setCheckState(Qt::Unchecked);
  309. }
  310. }
  311. void EditWidget::updateOptiTrackSettings(bool reset) {
  312. OptiTrackSettings settings;
  313. if (reset) {
  314. settings = {OPTITRACK_DEFAULT_LENGTH, OPTITRACK_DEFAULT_RADIUS};
  315. setOptiTrackSettings(OPTITRACK_DEFAULT_LENGTH, OPTITRACK_DEFAULT_RADIUS);
  316. } else {
  317. settings = {ui->optiTrackLength->value(), ui->optiTrackRadius->value()};
  318. }
  319. if (selectedPoint < 0) {
  320. MainWindow::getInstance()->getStore()->updateOptiTrackSettings(settings);
  321. MainWindow::getInstance()->getOsgWidget()->getPicker()->updateRenderer();
  322. } else {
  323. MainWindow::getInstance()->getStore()->getOptiTrackPoints()[selectedPoint]->updateOptiTrackSettings(settings);
  324. MainWindow::getInstance()->getOsgWidget()->getPointRenderer()->render(OptiTrack);
  325. MainWindow::getInstance()->getStore()->projectModified();
  326. MeshTools::optiTrackSanityCheck(MainWindow::getInstance()->getStore()->getOptiTrackPoints(), false);
  327. }
  328. }
  329. void EditWidget::setOptiTrackSettings(double length, double radius) {
  330. ui->optiTrackLength->setValue(length);
  331. ui->optiTrackRadius->setValue(radius);
  332. }
  333. void EditWidget::updateEMFTrackSettings(bool reset) {
  334. EMFTrackSettings settings;
  335. if (reset) {
  336. settings = {EMFTRACK_DEFAULT_WIDTH, EMFTRACK_DEFAULT_HEIGHT, EMFTRACK_DEFAULT_DEPTH};
  337. setEMFTrackSettings(EMFTRACK_DEFAULT_WIDTH, EMFTRACK_DEFAULT_HEIGHT, EMFTRACK_DEFAULT_DEPTH);
  338. } else {
  339. settings = {ui->emfTrackWidth->value(), ui->emfTrackHeight->value(), ui->emfTrackDepth->value()};
  340. }
  341. if (selectedPoint < 0) {
  342. MainWindow::getInstance()->getStore()->updateEMFTrackSettings(settings);
  343. MainWindow::getInstance()->getOsgWidget()->getPicker()->updateRenderer();
  344. } else {
  345. MainWindow::getInstance()->getStore()->getEMFTrackPoints()[selectedPoint]->updateEMFTrackSettings(settings);
  346. MainWindow::getInstance()->getOsgWidget()->getPointRenderer()->render(EMFTrack);
  347. MainWindow::getInstance()->getStore()->projectModified();
  348. }
  349. }
  350. void EditWidget::setEMFTrackSettings(double width, double height, double depth) {
  351. ui->emfTrackWidth->setValue(width);
  352. ui->emfTrackHeight->setValue(height);
  353. ui->emfTrackDepth->setValue(depth);
  354. }
  355. void EditWidget::updateSteamVRTrackSettings(bool reset) {
  356. SteamVRTrackSettings settings;
  357. if (reset) {
  358. settings = {STEAMVR_DEFAULT_LENGTH};
  359. setSteamVRTrackSettings(STEAMVR_DEFAULT_LENGTH);
  360. } else {
  361. settings = {ui->steamVrTrackLength->value()};
  362. }
  363. if (selectedPoint < 0) {
  364. MainWindow::getInstance()->getStore()->updateSteamVRTrackSettings(settings);
  365. MainWindow::getInstance()->getOsgWidget()->getPicker()->updateRenderer();
  366. } else {
  367. MainWindow::getInstance()->getStore()->getSteamVRTrackPoints()[selectedPoint]->updateSteamVRTrackSettings(settings);
  368. MainWindow::getInstance()->getOsgWidget()->getPointRenderer()->render(SteamVRTrack);
  369. MainWindow::getInstance()->getStore()->projectModified();
  370. MeshTools::steamVrTrackCollisionCheck(MainWindow::getInstance()->getStore()->getSteamVRTrackPoints(), false, MainWindow::getInstance()->getOsgWidget()->getVerifyGroup());
  371. }
  372. }
  373. void EditWidget::setSteamVRTrackSettings(double length) {
  374. ui->steamVrTrackLength->setValue(length);
  375. }
  376. void EditWidget::updateActionPointSettings(QString qinput) {
  377. std::string input = qinput.toUtf8().constData();
  378. if (MainWindow::getInstance()->getStore()->actionPointIdentifierInUse(input, selectedPoint) > 0) {
  379. ui->actionPointDoubleIdentifier->setVisible(true);
  380. } else {
  381. ui->actionPointDoubleIdentifier->setVisible(false);
  382. QString qtext = ui->actionPointIdentifier->text();
  383. ActionPointSettings settings = {qtext.toUtf8().constData()};
  384. if (selectedPoint < 0) {
  385. MainWindow::getInstance()->getStore()->updateActionPointSettings(settings);
  386. } else {
  387. MainWindow::getInstance()->getStore()->getActionPoints()[selectedPoint]->updateActionPointSettings(settings);
  388. MainWindow::getInstance()->getStore()->projectModified();
  389. }
  390. }
  391. }
  392. void EditWidget::resetActionPointSettings() {
  393. int iterator = 0;
  394. ActionPointSettings settings;
  395. std::string candidate;
  396. while (true) {
  397. candidate = "point";
  398. candidate += std::to_string(iterator);
  399. unsigned int result = MainWindow::getInstance()->getStore()->actionPointIdentifierInUse(candidate, selectedPoint);
  400. if (result == 0) {
  401. settings = {candidate};
  402. break;
  403. }
  404. iterator++;
  405. }
  406. ui->actionPointIdentifier->setText(QString::fromStdString(candidate));
  407. if (selectedPoint < 0) {
  408. MainWindow::getInstance()->getStore()->updateActionPointSettings(settings);
  409. } else {
  410. MainWindow::getInstance()->getStore()->getActionPoints()[selectedPoint]->updateActionPointSettings(settings);
  411. MainWindow::getInstance()->getStore()->projectModified();
  412. }
  413. }
  414. void EditWidget::setActionPointSettings(std::string identifier) {
  415. ui->actionPointIdentifier->setText(QString::fromStdString(identifier));
  416. if (MainWindow::getInstance()->getStore()->actionPointIdentifierInUse(identifier, selectedPoint) > 0) {
  417. ui->actionPointDoubleIdentifier->setVisible(true);
  418. } else {
  419. ui->actionPointDoubleIdentifier->setVisible(false);
  420. }
  421. }
  422. void EditWidget::deleteCurrentTrackPoint() {
  423. ActiveTrackingSystem activeTrackingSystem = getSelectedTrackingSystem();
  424. MainWindow::getInstance()->getStore()->removeTrackPoint(selectedPoint, activeTrackingSystem);
  425. selectedPoint = -1;
  426. switch(activeTrackingSystem) {
  427. case OptiTrack: {
  428. updateOptiTrackSettings(true);
  429. break;
  430. }
  431. case EMFTrack: {
  432. updateEMFTrackSettings(true);
  433. break;
  434. }
  435. case SteamVRTrack: {
  436. updateSteamVRTrackSettings(true);
  437. break;
  438. }
  439. case ActionPoints: {
  440. resetActionPointSettings();
  441. break;
  442. }
  443. }
  444. resetNormalModifier();
  445. invalidatePositions();
  446. MainWindow::getInstance()->getOsgWidget()->getPointRenderer()->render(activeTrackingSystem);
  447. }
  448. void EditWidget::exportProject() {
  449. Qt::CheckState optiTrackSelected = ui->optiTrackCkeckbox->checkState();
  450. Qt::CheckState emfTrackSelected = ui->emfTrackCheckbox->checkState();
  451. Qt::CheckState steamVrTrackSelected = ui->steamVrCheckbox->checkState();
  452. ExportSettings settings = {optiTrackSelected == Qt::Checked, emfTrackSelected == Qt::Checked, steamVrTrackSelected == Qt::Checked};
  453. QString fileName = QFileDialog::getSaveFileName(this, tr("Export your TrackpointApp Project"), "", tr("3MF Files (*.3mf)"));
  454. std::string exportFile = fileName.toUtf8().constData();
  455. MainWindow::getInstance()->getStore()->exportProject(exportFile, settings);
  456. }
  457. void EditWidget::changePositions() {
  458. osg::Vec3 origin = osg::Vec3(ui->anchorX->value(), ui->anchorY->value(), ui->anchorZ->value());
  459. if (selectedPoint >= 0) {
  460. ActiveTrackingSystem activeTrackingSystem = getSelectedTrackingSystem();
  461. MainWindow::getInstance()->getStore()->getTrackPointById(selectedPoint, activeTrackingSystem)->updatePositions(origin);
  462. MainWindow::getInstance()->getOsgWidget()->getPointRenderer()->render(activeTrackingSystem);
  463. MainWindow::getInstance()->getStore()->projectModified();
  464. }
  465. }
  466. void EditWidget::setPositionEditing(bool mode) {
  467. ui->anchorX->setReadOnly(mode);
  468. ui->anchorY->setReadOnly(mode);
  469. ui->anchorZ->setReadOnly(mode);
  470. }
  471. void EditWidget::manualOptiTrackSanityCheck() {
  472. MeshTools::optiTrackSanityCheck(MainWindow::getInstance()->getStore()->getOptiTrackPoints(), true);
  473. }
  474. void EditWidget::setOptiTrackSanityCheckStatus() {
  475. _optiTrackSanityCheck = ui->compensation->checkState() == Qt::Checked ? true : false;
  476. }
  477. void EditWidget::manualSteamVRTrackCollisionCheck() {
  478. MeshTools::steamVrTrackCollisionCheck(MainWindow::getInstance()->getStore()->getSteamVRTrackPoints(), true, MainWindow::getInstance()->getOsgWidget()->getVerifyGroup());
  479. }
  480. void EditWidget::setSteamVRTrackCollisionCheckStatus() {
  481. _steamVrTrackCollisionCheck = ui->compensation->checkState() == Qt::Checked ? true : false;
  482. }