VOXEDIT: started with the export feature

master
Martin Gerhardy 2016-11-02 20:53:11 +01:00
parent c9b7ecfa2c
commit 661e2e5857
7 changed files with 50 additions and 0 deletions

View File

@ -25,6 +25,11 @@ TBLayout: distribution: gravity, axis: y
@include definitions>menubutton
text Load
id load
TBButton
gravity: left
@include definitions>menubutton
text Export
id export
TBLayout: gravity: left right
TBWidget
TBSelectDropdown: gravity: left top

View File

@ -32,6 +32,10 @@ bool VoxEdit::newFile(bool force) {
return _mainWindow->createNew(force);
}
bool VoxEdit::exportFile(std::string_view file) {
return _mainWindow->exportFile(file);
}
core::AppState VoxEdit::onCleanup() {
const core::AppState state = Super::onCleanup();
_meshPool->shutdown();
@ -75,6 +79,16 @@ core::AppState VoxEdit::onInit() {
}
}).setArgumentCompleter(fileCompleter).setHelp("Save the current state to the given file");
core::Command::registerCommand("export", [this] (const core::CmdArgs& args) {
if (args.empty()) {
Log::error("Usage: export <filename>");
return;
}
if (!exportFile(args[0])) {
Log::error("Failed to export to file %s", args[0].c_str());
}
}).setArgumentCompleter(fileCompleter).setHelp("Export the current state to the given file");
core::Command::registerCommand("load", [this] (const core::CmdArgs& args) {
if (args.empty()) {
Log::error("Usage: load <filename>");

View File

@ -24,6 +24,7 @@ public:
bool saveFile(std::string_view file);
bool loadFile(std::string_view file);
bool voxelizeFile(std::string_view file);
bool exportFile(std::string_view file);
bool newFile(bool force = false);
video::MeshPoolPtr meshPool() const;

View File

@ -183,6 +183,18 @@ bool EditorScene::voxelizeModel(const video::MeshPtr& meshPtr) {
return false;
}
bool EditorScene::exportModel(std::string_view file) {
core_trace_scoped(EditorSceneExportModel);
const io::FilePtr& filePtr = core::App::getInstance()->filesystem()->open(std::string(file));
if (!(bool)filePtr) {
return false;
}
//const std::string& ext = filePtr->getExtension();
// TODO: assimp exporters
return false;
}
bool EditorScene::loadModel(std::string_view file) {
core_trace_scoped(EditorSceneLoadModel);
const io::FilePtr& filePtr = core::App::getInstance()->filesystem()->open(std::string(file));

View File

@ -77,6 +77,7 @@ public:
bool voxelizeModel(const video::MeshPtr& mesh);
bool saveModel(std::string_view file);
bool loadModel(std::string_view file);
bool exportModel(std::string_view file);
bool newModel(bool force);
void setActionExecutionDelay(long actionExecutionDelay);

View File

@ -71,6 +71,9 @@ bool MainWindow::handleClickEvent(const tb::TBWidgetEvent &ev) {
} else if (ev.target->GetID() == TBIDC("load")) {
load("");
return true;
} else if (ev.target->GetID() == TBIDC("export")) {
exportFile("");
return true;
} else if (ev.target->GetID() == TBIDC("save")) {
save("");
return true;
@ -166,6 +169,19 @@ bool MainWindow::voxelize(std::string_view file) {
return false;
}
bool MainWindow::exportFile(std::string_view file) {
std::string f;
if (file.empty()) {
// TODO: extract extension - filter
f = _voxedit->openDialog("vox,qbt");
if (f.empty()) {
return false;
}
file = f;
}
return _scene->exportModel(file);
}
bool MainWindow::load(std::string_view file) {
std::string f;
if (file.empty()) {

View File

@ -38,6 +38,7 @@ public:
bool voxelize(std::string_view file);
bool save(std::string_view file);
bool load(std::string_view file);
bool exportFile(std::string_view file);
bool createNew(bool force);
};