ProjectStore.hpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #pragma once
  2. // Include modules
  3. #include "lib3mf_implicit.hpp"
  4. #include "OptiTrackPoint.hpp"
  5. #include "EMFTrackPoint.hpp"
  6. #include "SteamVRTrackPoint.hpp"
  7. #include "ActionPoint.hpp"
  8. #include "TrackSystemSettingsStructs.hpp"
  9. #include "OpenScadRenderer.hpp"
  10. #include "enums.hpp"
  11. // Include dependencies
  12. #include <string>
  13. #include <nlohmann/json.hpp>
  14. #include <QThread>
  15. using json = nlohmann::json;
  16. class ProjectStore: public QObject {
  17. Q_OBJECT
  18. public:
  19. // Create an empty project
  20. ProjectStore(QObject* parent = nullptr);
  21. // Destructor
  22. ~ProjectStore();
  23. // Load a mesh
  24. void loadMesh(std::string meshFile);
  25. // Load a project
  26. bool loadProject(std::string projectFile);
  27. // Save the project to the loaded file
  28. bool saveProject();
  29. // Save the project to a new file
  30. bool saveProject(std::string projectFile);
  31. // Export the project
  32. bool exportProject(std::string path, ExportSettings settings);
  33. // Is currently a project opened
  34. bool isProjectOpen();
  35. // Close the current project
  36. void closeProject();
  37. // Is current project modified
  38. bool isModified();
  39. // Is a rendering in progress
  40. bool isRendering();
  41. // Set project modification status
  42. void projectModified();
  43. // UNIVERSAL
  44. // Get trackpoint
  45. TrackPoint* getTrackPointById(int id, ActiveTrackingSystem activeTrackingSystem);
  46. // Add trackpoint
  47. void addTrackPoint(osg::Vec3 point, osg::Vec3 normal, ActiveTrackingSystem activeTrackingSystem);
  48. // Count trackpoints
  49. int getCount(ActiveTrackingSystem activeTrackingSystem);
  50. // Remove trackpoint
  51. void removeTrackPoint(int id, ActiveTrackingSystem activeTrackingSystem);
  52. // NORMAL MODIFIER
  53. // Update normal modifier
  54. void updateNormalModifier(osg::Vec3 modifier);
  55. // Return normal modifier
  56. osg::Vec3 getNormalModifier();
  57. // Update normal rotation
  58. void updateNormalRotation(float normalRotation);
  59. // Return normal rotation
  60. float getNormalRotation();
  61. // Update compensation
  62. void updateCompensation(bool compensation);
  63. // Return compensation
  64. bool getCompensation();
  65. // OPTITRACK
  66. // Get all OptiTrack points
  67. std::vector<OptiTrackPoint*> getOptiTrackPoints();
  68. // Update actual OptiTrack settings
  69. void updateOptiTrackSettings(OptiTrackSettings optiTrackSettings);
  70. // Return OptiTrack settings
  71. OptiTrackSettings getOptiTrackSettings();
  72. // EMF TRACK
  73. // Get all EMFTrack points
  74. std::vector<EMFTrackPoint*> getEMFTrackPoints();
  75. // Update actual EMFTrack settings
  76. void updateEMFTrackSettings(EMFTrackSettings emfTrackSettings);
  77. // Return EMFTrack settings
  78. EMFTrackSettings getEMFTrackSettings();
  79. // STEAM VR TRACK
  80. // Get all SteamVRTrack points
  81. std::vector<SteamVRTrackPoint*> getSteamVRTrackPoints();
  82. // Update actual SteamVRTrack settings
  83. void updateSteamVRTrackSettings(SteamVRTrackSettings steamVrTrackSettings);
  84. // Return SteamVRTrack settings
  85. SteamVRTrackSettings getSteamVRTrackSettings();
  86. // ACTION POINTS
  87. // Get all Action points
  88. std::vector<ActionPoint*> getActionPoints();
  89. // Update actual Action point settings
  90. void updateActionPointSettings(ActionPointSettings actionPointSettings);
  91. // Return Action point settings
  92. ActionPointSettings getActionPointSettings();
  93. // Check if an identifier is already in use
  94. unsigned int actionPointIdentifierInUse(std::string candidate, int current);
  95. private slots:
  96. void renderThreadDone();
  97. private:
  98. bool _projectLoaded;
  99. bool _projectModified;
  100. Lib3MF::PWrapper _wrapper;
  101. Lib3MF::PModel _project;
  102. std::string _projectFile;
  103. std::vector<OptiTrackPoint*> _optiTrackPoints;
  104. std::vector<EMFTrackPoint*> _emfTrackPoints;
  105. std::vector<SteamVRTrackPoint*> _steamVrTrackPoints;
  106. std::vector<ActionPoint*> _actionPoints;
  107. OptiTrackSettings _optiTrackSettings = OptiTrackSettings {OPTITRACK_DEFAULT_LENGTH, OPTITRACK_DEFAULT_RADIUS};
  108. EMFTrackSettings _emfTrackSettings = EMFTrackSettings {EMFTRACK_DEFAULT_WIDTH, EMFTRACK_DEFAULT_HEIGHT, EMFTRACK_DEFAULT_DEPTH};
  109. SteamVRTrackSettings _steamVrTrackSettings = SteamVRTrackSettings {STEAMVR_DEFAULT_LENGTH};
  110. ActionPointSettings _actionPointSettings = ActionPointSettings {ACTIONPOINT_DEFAULT_IDENFIFIER};
  111. osg::Vec3 _normalModifier = osg::Vec3(0.0f, 0.0f, 0.0f);
  112. float _normalRotation = 0.0f;
  113. bool _compensation = true;
  114. QThread* _optiTrackRenderThread;
  115. QThread* _emfTrackRenderThread;
  116. QThread* _steamVrTrackRenderThread;
  117. bool _exportRunning = false;
  118. ExportSettings _currentExportSettings;
  119. int _wantedExports;
  120. int _doneExports;
  121. std::string _exportPath;
  122. void load3mfLib();
  123. void reset();
  124. void render3MFMesh();
  125. void updateMetaData();
  126. void loadMetaData();
  127. static void renderOptiTrackInThread(std::vector<OptiTrackPoint*> optiTrackPoints);
  128. static void renderEMFTrackInThread(std::vector<EMFTrackPoint*> emfTrackPoints);
  129. static void renderSteamVRTrackInThread(std::vector<SteamVRTrackPoint*> steamVrTrackPoints);
  130. std::vector<float> osgVecToStdVec(osg::Vec3f input);
  131. osg::Vec3f stdVecToOsgVec(std::vector<float> input);
  132. };