ProjectStore.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #pragma once
  2. // Include modules
  3. #include "lib3mf_implicit.hpp"
  4. #include "OptiTrackPoint.hpp"
  5. #include "SteamVRTrackPoint.hpp"
  6. #include "ActionPoint.hpp"
  7. #include "TrackSystemSettingsStructs.hpp"
  8. #include "OpenScadRenderer.hpp"
  9. #include "enums.hpp"
  10. // Include dependencies
  11. #include <string>
  12. #include <nlohmann/json.hpp>
  13. struct steamVrTrackPointJson {
  14. float point[3];
  15. float normal[3];
  16. };
  17. using json = nlohmann::json;
  18. class ProjectStore {
  19. public:
  20. // Create an empty project
  21. ProjectStore();
  22. // Destructor
  23. ~ProjectStore();
  24. // Load a mesh
  25. void loadMesh(std::string meshFile);
  26. // Load a project
  27. bool loadProject(std::string projectFile);
  28. // Save the project to the loaded file
  29. bool saveProject();
  30. // Save the project to a new file
  31. bool saveProject(std::string projectFile);
  32. // Export the project
  33. bool exportProject(std::string path, ExportSettings settings);
  34. // Is currently a project opened
  35. bool isProjectOpen();
  36. // Close the current project
  37. void closeProject();
  38. // Is current project modified
  39. bool isModified();
  40. // Set project modification status
  41. void projectModified();
  42. // UNIVERSAL
  43. // Get trackpoint
  44. TrackPoint* getTrackPointById(int id, ActiveTrackingSystem activeTrackingSystem);
  45. // Add trackpoint
  46. void addTrackPoint(osg::Vec3 point, osg::Vec3 normal, ActiveTrackingSystem activeTrackingSystem);
  47. // Count trackpoints
  48. int getCount(ActiveTrackingSystem activeTrackingSystem);
  49. // Remove trackpoint
  50. void removeTrackPoint(int id, ActiveTrackingSystem activeTrackingSystem);
  51. // NORMAL MODIFIER
  52. // Update normal modifier
  53. void updateNormalModifier(osg::Vec3 modifier);
  54. // Return normal modifier
  55. osg::Vec3 getNormalModifier();
  56. // OPTITRACK
  57. // Get all OptiTrack points
  58. std::vector<OptiTrackPoint*> getOptiTrackPoints();
  59. // Update actual OptiTrack settings
  60. void updateOptiTrackSettings(OptiTrackSettings optiTrackSettings);
  61. // Return OptiTrack settings
  62. OptiTrackSettings getOptiTrackSettings();
  63. // STEAM VR TRACK
  64. // Get all SteamVRTrack points
  65. std::vector<SteamVRTrackPoint*> getSteamVRTrackPoints();
  66. // Update actual SteamVRTrack settings
  67. void updateSteamVRTrackSettings(SteamVRTrackSettings steamVrTrackSettings);
  68. // Return SteamVRTrack settings
  69. SteamVRTrackSettings getSteamVRTrackSettings();
  70. // ACTION POINTS
  71. // Get all Action points
  72. std::vector<ActionPoint*> getActionPoints();
  73. // Update actual Action point settings
  74. void updateActionPointSettings(ActionPointSettings actionPointSettings);
  75. // Return Action point settings
  76. ActionPointSettings getActionPointSettings();
  77. // Check if an identifier is already in use
  78. unsigned int actionPointIdentifierInUse(std::string candidate, int current);
  79. private:
  80. bool _projectLoaded;
  81. bool _projectModified;
  82. Lib3MF::PWrapper _wrapper;
  83. Lib3MF::PModel _project;
  84. std::string _projectFile;
  85. std::vector<OptiTrackPoint*> _optiTrackPoints;
  86. std::vector<SteamVRTrackPoint*> _steamVrTrackPoints;
  87. std::vector<ActionPoint*> _actionPoints;
  88. OptiTrackSettings _optiTrackSettings = OptiTrackSettings {OPTITRACK_DEFAULT_LENGTH, OPTITRACK_DEFAULT_RADIUS};
  89. EMFTrackSettings _emfTrackSettings;
  90. SteamVRTrackSettings _steamVrTrackSettings = SteamVRTrackSettings {STEAMVR_DEFAULT_LENGTH};
  91. ActionPointSettings _actionPointSettings = ActionPointSettings {ACTIONPOINT_DEFAULT_IDENFIFIER};
  92. osg::Vec3 _normalModifier = osg::Vec3(0.0f, 0.0f, 0.0f);
  93. void load3mfLib();
  94. void reset();
  95. void render3MFMesh();
  96. void updateMetaData();
  97. void loadMetaData();
  98. std::vector<float> osgVecToStdVec(osg::Vec3f input);
  99. osg::Vec3f stdVecToOsgVec(std::vector<float> input);
  100. };