History

importVoxels() JS override: specify file and location

Bennett Goble committed 12 years ago

Commit bd409f21 parent 8be42bf9 files · +215 −160Browse files

Showing the changes to interface/src/scripting/ClipboardScriptingInterface.cpp (1 of 9 files). Show all

Unified · Split

interface/src/scripting/ClipboardScriptingInterface.cpp+31−0
@@ -87,6 +87,37 @@ bool ClipboardScriptingInterface::importVoxels() { · 86 unmodified lines
8787 return Application::getInstance()->getImportSucceded();
8888 }
8989
90+bool ClipboardScriptingInterface::importVoxels(const QString& filename) {
91+ qDebug() << "Importing ... ";
92+
93+ VoxelImporter* importer = Application::getInstance()->getVoxelImporter();
94+
95+ if (!importer->validImportFile(filename)) {
96+ return false;
97+ }
98+
99+ QEventLoop loop;
100+ connect(importer, SIGNAL(importDone()), &loop, SLOT(quit()));
101+ importer->import(filename);
102+ loop.exec();
103+
104+ return true;
105+}
106+
107+bool ClipboardScriptingInterface::importVoxels(const QString& filename, float x, float y, float z, float s) {
108+ bool success = importVoxels(filename);
109+
110+ if (success) {
111+ pasteVoxel(x, y, z, s);
112+ }
113+
114+ return success;
115+}
116+
117+bool ClipboardScriptingInterface::importVoxels(const QString& filename, const VoxelDetail& destinationVoxel) {
118+ return importVoxels(filename, destinationVoxel.x, destinationVoxel.y, destinationVoxel.z, destinationVoxel.s);
119+}
120+
90121 void ClipboardScriptingInterface::nudgeVoxel(const VoxelDetail& sourceVoxel, const glm::vec3& nudgeVec) {
91122 nudgeVoxel(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s, nudgeVec);
92123 }