mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 16:13:28 +02:00
Add more complete error handling for import/export models
This commit is contained in:
parent
49e35bbc84
commit
3e2bb0f168
5 changed files with 31 additions and 17 deletions
|
@ -218,7 +218,10 @@ var ExportMenu = function(opts) {
|
|||
var filename = "models__" + Window.location.hostname + "__" + x + "_" + y + "_" + z + "_" + s + "__.svo";
|
||||
filename = Window.save("Select where to save", filename, "*.svo")
|
||||
if (filename) {
|
||||
Clipboard.exportModels(filename, x, y, z, s);
|
||||
var success = Clipboard.exportModels(filename, x, y, z, s);
|
||||
if (!succcess) {
|
||||
WIndow.alert("Export failed: no models found in selected area.");
|
||||
}
|
||||
}
|
||||
self.close();
|
||||
};
|
||||
|
@ -431,16 +434,24 @@ var ModelImporter = function(opts) {
|
|||
}
|
||||
} else {
|
||||
if (Window.confirm(("Would you like to import back to the source location?"))) {
|
||||
Clipboard.importModels(filename);
|
||||
Clipboard.pasteModels(x, y, z, 1);
|
||||
var success = Clipboard.importModels(filename);
|
||||
if (success) {
|
||||
Clipboard.pasteModels(x, y, z, 1);
|
||||
} else {
|
||||
Window.alert("There was an error importing the model file.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Clipboard.importModels(filename);
|
||||
self._importing = true;
|
||||
self.setImportVisible(true);
|
||||
Overlays.editOverlay(importBoundaries, { size: s });
|
||||
var success = Clipboard.importModels(filename);
|
||||
if (success) {
|
||||
self._importing = true;
|
||||
self.setImportVisible(true);
|
||||
Overlays.editOverlay(importBoundaries, { size: s });
|
||||
} else {
|
||||
Window.alert("There was an error importing the model file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1614,10 +1614,13 @@ void Application::importVoxels() {
|
|||
emit importDone();
|
||||
}
|
||||
|
||||
void Application::importModels(const QString& filename) {
|
||||
bool Application::importModels(const QString& filename) {
|
||||
_modelClipboard.eraseAllOctreeElements();
|
||||
_modelClipboard.readFromSVOFile(filename.toLocal8Bit().constData());
|
||||
_modelClipboard.reaverageOctreeElements();
|
||||
bool success = _modelClipboard.readFromSVOFile(filename.toLocal8Bit().constData());
|
||||
if (success) {
|
||||
_modelClipboard.reaverageOctreeElements();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void Application::pasteModels(float x, float y, float z) {
|
||||
|
|
|
@ -317,7 +317,7 @@ public slots:
|
|||
|
||||
void pasteModels(float x, float y, float z);
|
||||
bool exportModels(const QString& filename, float x, float y, float z, float scale);
|
||||
void importModels(const QString& filename);
|
||||
bool importModels(const QString& filename);
|
||||
|
||||
void importVoxels(); // doesn't include source voxel because it goes to clipboard
|
||||
void cutVoxels(const VoxelDetail& sourceVoxel);
|
||||
|
|
|
@ -102,12 +102,12 @@ void ClipboardScriptingInterface::nudgeVoxel(float x, float y, float z, float s,
|
|||
}
|
||||
|
||||
|
||||
void ClipboardScriptingInterface::exportModels(const QString& filename, float x, float y, float z, float s) {
|
||||
Application::getInstance()->exportModels(filename, x, y, z, s);
|
||||
bool ClipboardScriptingInterface::exportModels(const QString& filename, float x, float y, float z, float s) {
|
||||
return Application::getInstance()->exportModels(filename, x, y, z, s);
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::importModels(const QString& filename) {
|
||||
Application::getInstance()->importModels(filename);
|
||||
bool ClipboardScriptingInterface::importModels(const QString& filename) {
|
||||
return Application::getInstance()->importModels(filename);
|
||||
}
|
||||
|
||||
void ClipboardScriptingInterface::pasteModels(float x, float y, float z, float s) {
|
||||
|
|
|
@ -43,8 +43,8 @@ public slots:
|
|||
void nudgeVoxel(const VoxelDetail& sourceVoxel, const glm::vec3& nudgeVec);
|
||||
void nudgeVoxel(float x, float y, float z, float s, const glm::vec3& nudgeVec);
|
||||
|
||||
void importModels(const QString& filename);
|
||||
void exportModels(const QString& filename, float x, float y, float z, float s);
|
||||
bool importModels(const QString& filename);
|
||||
bool exportModels(const QString& filename, float x, float y, float z, float s);
|
||||
void pasteModels(float x, float y, float z, float s);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue