ProjectStore.hpp 3.5 KB

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