ProjectStore.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. using json = nlohmann::json;
  15. class ProjectStore {
  16. public:
  17. // Create an empty project
  18. ProjectStore();
  19. // Destructor
  20. ~ProjectStore();
  21. // Load a mesh
  22. void loadMesh(std::string meshFile);
  23. // Load a project
  24. bool loadProject(std::string projectFile);
  25. // Save the project to the loaded file
  26. bool saveProject();
  27. // Save the project to a new file
  28. bool saveProject(std::string projectFile);
  29. // Export the project
  30. bool exportProject(std::string path, ExportSettings settings);
  31. // Is currently a project opened
  32. bool isProjectOpen();
  33. // Close the current project
  34. void closeProject();
  35. // Is current project modified
  36. bool isModified();
  37. // Set project modification status
  38. void projectModified();
  39. // UNIVERSAL
  40. // Get trackpoint
  41. TrackPoint* getTrackPointById(int id, ActiveTrackingSystem activeTrackingSystem);
  42. // Add trackpoint
  43. void addTrackPoint(osg::Vec3 point, osg::Vec3 normal, ActiveTrackingSystem activeTrackingSystem);
  44. // Count trackpoints
  45. int getCount(ActiveTrackingSystem activeTrackingSystem);
  46. // Remove trackpoint
  47. void removeTrackPoint(int id, ActiveTrackingSystem activeTrackingSystem);
  48. // NORMAL MODIFIER
  49. // Update normal modifier
  50. void updateNormalModifier(osg::Vec3 modifier);
  51. // Return normal modifier
  52. osg::Vec3 getNormalModifier();
  53. // Update normal rotation
  54. void updateNormalRotation(float normalRotation);
  55. // Return normal rotation
  56. float getNormalRotation();
  57. // Update compensation
  58. void updateCompensation(bool compensation);
  59. // Return compensation
  60. bool getCompensation();
  61. // OPTITRACK
  62. // Get all OptiTrack points
  63. std::vector<OptiTrackPoint*> getOptiTrackPoints();
  64. // Update actual OptiTrack settings
  65. void updateOptiTrackSettings(OptiTrackSettings optiTrackSettings);
  66. // Return OptiTrack settings
  67. OptiTrackSettings getOptiTrackSettings();
  68. // EMF TRACK
  69. // Get all EMFTrack points
  70. std::vector<EMFTrackPoint*> getEMFTrackPoints();
  71. // Update actual EMFTrack settings
  72. void updateEMFTrackSettings(EMFTrackSettings emfTrackSettings);
  73. // Return EMFTrack settings
  74. EMFTrackSettings getEMFTrackSettings();
  75. // STEAM VR TRACK
  76. // Get all SteamVRTrack points
  77. std::vector<SteamVRTrackPoint*> getSteamVRTrackPoints();
  78. // Update actual SteamVRTrack settings
  79. void updateSteamVRTrackSettings(SteamVRTrackSettings steamVrTrackSettings);
  80. // Return SteamVRTrack settings
  81. SteamVRTrackSettings getSteamVRTrackSettings();
  82. // ACTION POINTS
  83. // Get all Action points
  84. std::vector<ActionPoint*> getActionPoints();
  85. // Update actual Action point settings
  86. void updateActionPointSettings(ActionPointSettings actionPointSettings);
  87. // Return Action point settings
  88. ActionPointSettings getActionPointSettings();
  89. // Check if an identifier is already in use
  90. unsigned int actionPointIdentifierInUse(std::string candidate, int current);
  91. private:
  92. bool _projectLoaded;
  93. bool _projectModified;
  94. Lib3MF::PWrapper _wrapper;
  95. Lib3MF::PModel _project;
  96. std::string _projectFile;
  97. std::vector<OptiTrackPoint*> _optiTrackPoints;
  98. std::vector<EMFTrackPoint*> _emfTrackPoints;
  99. std::vector<SteamVRTrackPoint*> _steamVrTrackPoints;
  100. std::vector<ActionPoint*> _actionPoints;
  101. OptiTrackSettings _optiTrackSettings = OptiTrackSettings {OPTITRACK_DEFAULT_LENGTH, OPTITRACK_DEFAULT_RADIUS};
  102. EMFTrackSettings _emfTrackSettings = EMFTrackSettings {EMFTRACK_DEFAULT_WIDTH, EMFTRACK_DEFAULT_HEIGHT, EMFTRACK_DEFAULT_DEPTH};
  103. SteamVRTrackSettings _steamVrTrackSettings = SteamVRTrackSettings {STEAMVR_DEFAULT_LENGTH};
  104. ActionPointSettings _actionPointSettings = ActionPointSettings {ACTIONPOINT_DEFAULT_IDENFIFIER};
  105. osg::Vec3 _normalModifier = osg::Vec3(0.0f, 0.0f, 0.0f);
  106. float _normalRotation = 0.0f;
  107. bool _compensation = true;
  108. void load3mfLib();
  109. void reset();
  110. void render3MFMesh();
  111. void updateMetaData();
  112. void loadMetaData();
  113. std::vector<float> osgVecToStdVec(osg::Vec3f input);
  114. osg::Vec3f stdVecToOsgVec(std::vector<float> input);
  115. };