|
@@ -26,8 +26,12 @@ ProjectStore::~ProjectStore() {
|
|
}
|
|
}
|
|
|
|
|
|
void ProjectStore::loadMesh(std::string meshFile) {
|
|
void ProjectStore::loadMesh(std::string meshFile) {
|
|
|
|
+ if (meshFile == "") {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
if (StringBasics::endsWithCaseInsensitive(meshFile, ".STL")) {
|
|
if (StringBasics::endsWithCaseInsensitive(meshFile, ".STL")) {
|
|
_projectLoaded = true;
|
|
_projectLoaded = true;
|
|
|
|
+ _projectModified = false;
|
|
// Read STL file
|
|
// Read STL file
|
|
std::vector<Lib3MF::sPosition> verticesBuffer;
|
|
std::vector<Lib3MF::sPosition> verticesBuffer;
|
|
std::vector<Lib3MF::sTriangle> triangleBuffer;
|
|
std::vector<Lib3MF::sTriangle> triangleBuffer;
|
|
@@ -38,6 +42,7 @@ void ProjectStore::loadMesh(std::string meshFile) {
|
|
MainWindow::getInstance()->renderView(Edit);
|
|
MainWindow::getInstance()->renderView(Edit);
|
|
} else if (StringBasics::endsWithCaseInsensitive(meshFile, ".3MF")) {
|
|
} else if (StringBasics::endsWithCaseInsensitive(meshFile, ".3MF")) {
|
|
_projectLoaded = true;
|
|
_projectLoaded = true;
|
|
|
|
+ _projectModified = false;
|
|
// Read 3MF file
|
|
// Read 3MF file
|
|
Lib3MF::PReader reader = _project->QueryReader("3mf");
|
|
Lib3MF::PReader reader = _project->QueryReader("3mf");
|
|
reader->ReadFromFile(meshFile);
|
|
reader->ReadFromFile(meshFile);
|
|
@@ -50,11 +55,15 @@ void ProjectStore::loadMesh(std::string meshFile) {
|
|
}
|
|
}
|
|
|
|
|
|
bool ProjectStore::loadProject(std::string projectFile) {
|
|
bool ProjectStore::loadProject(std::string projectFile) {
|
|
|
|
+ if (projectFile == "") {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
if (!_projectLoaded) {
|
|
if (!_projectLoaded) {
|
|
Lib3MF::PReader reader = _project->QueryReader("3mf");
|
|
Lib3MF::PReader reader = _project->QueryReader("3mf");
|
|
reader->ReadFromFile(projectFile);
|
|
reader->ReadFromFile(projectFile);
|
|
_projectLoaded = true;
|
|
_projectLoaded = true;
|
|
_projectModified = false;
|
|
_projectModified = false;
|
|
|
|
+ _projectFile = projectFile;
|
|
loadMetaData();
|
|
loadMetaData();
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -69,10 +78,14 @@ bool ProjectStore::saveProject() {
|
|
}
|
|
}
|
|
|
|
|
|
bool ProjectStore::saveProject(std::string path) {
|
|
bool ProjectStore::saveProject(std::string path) {
|
|
|
|
+ if (path == "") {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
updateMetaData();
|
|
updateMetaData();
|
|
Lib3MF::PWriter writer = _project->QueryWriter("3mf");
|
|
Lib3MF::PWriter writer = _project->QueryWriter("3mf");
|
|
writer->WriteToFile(path);
|
|
writer->WriteToFile(path);
|
|
_projectFile = path;
|
|
_projectFile = path;
|
|
|
|
+ _projectModified = false;
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -177,6 +190,23 @@ bool ProjectStore::exportProject(std::string path, ExportSettings settings) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+bool ProjectStore::isProjectOpen() {
|
|
|
|
+ return _projectLoaded;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ProjectStore::closeProject() {
|
|
|
|
+ _projectLoaded = false;
|
|
|
|
+ reset();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool ProjectStore::isModified() {
|
|
|
|
+ return _projectModified;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ProjectStore::projectModified() {
|
|
|
|
+ _projectModified = true;
|
|
|
|
+}
|
|
|
|
+
|
|
TrackPoint* ProjectStore::getTrackPointById(int id, ActiveTrackingSystem activeTrackingSystem) {
|
|
TrackPoint* ProjectStore::getTrackPointById(int id, ActiveTrackingSystem activeTrackingSystem) {
|
|
switch(activeTrackingSystem) {
|
|
switch(activeTrackingSystem) {
|
|
case OptiTrack: {
|
|
case OptiTrack: {
|
|
@@ -215,6 +245,7 @@ void ProjectStore::addTrackPoint(osg::Vec3 point, osg::Vec3 normal, ActiveTracki
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ projectModified();
|
|
MainWindow::getInstance()->getEditWiget()->updateTrackpointCount();
|
|
MainWindow::getInstance()->getEditWiget()->updateTrackpointCount();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -253,6 +284,7 @@ void ProjectStore::removeTrackPoint(int id, ActiveTrackingSystem activeTrackingS
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ projectModified();
|
|
MainWindow::getInstance()->getEditWiget()->updateTrackpointCount();
|
|
MainWindow::getInstance()->getEditWiget()->updateTrackpointCount();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -317,6 +349,17 @@ void ProjectStore::load3mfLib() {
|
|
_project = _wrapper->CreateModel();
|
|
_project = _wrapper->CreateModel();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void ProjectStore::reset() {
|
|
|
|
+ _project = _wrapper->CreateModel();
|
|
|
|
+ _optiTrackPoints.clear();
|
|
|
|
+ _steamVrTrackPoints.clear();
|
|
|
|
+ _actionPoints.clear();
|
|
|
|
+ _optiTrackSettings = OptiTrackSettings {OPTITRACK_DEFAULT_LENGTH, OPTITRACK_DEFAULT_RADIUS};
|
|
|
|
+ _steamVrTrackSettings = SteamVRTrackSettings {STEAMVR_DEFAULT_LENGTH};
|
|
|
|
+ _actionPointSettings = ActionPointSettings {ACTIONPOINT_DEFAULT_IDENFIFIER};
|
|
|
|
+ _normalModifier = osg::Vec3(0.0f, 0.0f, 0.0f);
|
|
|
|
+}
|
|
|
|
+
|
|
void ProjectStore::render3MFMesh() {
|
|
void ProjectStore::render3MFMesh() {
|
|
// Get meshes
|
|
// Get meshes
|
|
Lib3MF::PMeshObjectIterator meshIterator = _project->GetMeshObjects();
|
|
Lib3MF::PMeshObjectIterator meshIterator = _project->GetMeshObjects();
|
|
@@ -388,7 +431,8 @@ void ProjectStore::updateMetaData() {
|
|
actionPointData.push_back({
|
|
actionPointData.push_back({
|
|
{"point", osgVecToStdVec(actionPoint->getTranslation())},
|
|
{"point", osgVecToStdVec(actionPoint->getTranslation())},
|
|
{"normal", osgVecToStdVec(actionPoint->getNormal())},
|
|
{"normal", osgVecToStdVec(actionPoint->getNormal())},
|
|
- {"normalModifier", osgVecToStdVec(actionPoint->getNormalModifier())}
|
|
|
|
|
|
+ {"normalModifier", osgVecToStdVec(actionPoint->getNormalModifier())},
|
|
|
|
+ {"identifier", actionPoint->getIdentifier()}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
@@ -446,7 +490,7 @@ void ProjectStore::loadMetaData() {
|
|
osg::Vec3f point = osg::Vec3f(pointData["point"][0], pointData["point"][1], pointData["point"][2]);
|
|
osg::Vec3f point = osg::Vec3f(pointData["point"][0], pointData["point"][1], pointData["point"][2]);
|
|
osg::Vec3f normal = osg::Vec3f(pointData["normal"][0], pointData["normal"][1], pointData["normal"][2]);
|
|
osg::Vec3f normal = osg::Vec3f(pointData["normal"][0], pointData["normal"][1], pointData["normal"][2]);
|
|
osg::Vec3f normalModifier = osg::Vec3f(pointData["normalModifier"][0], pointData["normalModifier"][1], pointData["normalModifier"][2]);
|
|
osg::Vec3f normalModifier = osg::Vec3f(pointData["normalModifier"][0], pointData["normalModifier"][1], pointData["normalModifier"][2]);
|
|
- ActionPoint* actionPoint = new ActionPoint(point, normal, normalModifier);
|
|
|
|
|
|
+ ActionPoint* actionPoint = new ActionPoint(point, normal, normalModifier, pointData["identifier"]);
|
|
_actionPoints.push_back(actionPoint);
|
|
_actionPoints.push_back(actionPoint);
|
|
}
|
|
}
|
|
} catch (Lib3MF::ELib3MFException &e) {
|
|
} catch (Lib3MF::ELib3MFException &e) {
|