VOXEDIT: alt+ctrl+q toggles quad view

master
Martin Gerhardy 2016-11-08 20:22:46 +01:00
parent 3a735d9182
commit 14b7124c1a
4 changed files with 36 additions and 10 deletions

View File

@ -1,3 +1,4 @@
ctrl+l load
ctrl+s save
ctrl+n new
ctrl+alt+q toggleviewport

View File

@ -87,6 +87,10 @@ core::AppState VoxEdit::onInit() {
}
}).setArgumentCompleter(fileCompleter).setHelp("Save the current state to the given file");
core::Command::registerCommand("toggleviewport", [this] (const core::CmdArgs& args) {
this->_mainWindow->toggleQuadViewport();
}).setArgumentCompleter(fileCompleter).setHelp("Toggle quad view on/off");
core::Command::registerCommand("export", [this] (const core::CmdArgs& args) {
std::string_view file = args.empty() ? "" : args[0];
if (!exportFile(file)) {

View File

@ -81,6 +81,34 @@ bool MainWindow::init() {
return true;
}
void MainWindow::toggleQuadViewport() {
bool vis = false;
if (_sceneTop != nullptr) {
vis = _sceneTop->GetVisibilityCombined();
}
if (!vis && _sceneLeft != nullptr) {
vis = _sceneLeft->GetVisibilityCombined();
}
if (!vis && _sceneFront != nullptr) {
vis = _sceneFront->GetVisibilityCombined();
}
setQuadViewport(!vis);
}
void MainWindow::setQuadViewport(bool active) {
const tb::WIDGET_VISIBILITY vis = active ? tb::WIDGET_VISIBILITY_VISIBLE : tb::WIDGET_VISIBILITY_GONE;
if (_sceneTop != nullptr) {
_sceneTop->SetVisibility(vis);
}
if (_sceneLeft != nullptr) {
_sceneLeft->SetVisibility(vis);
}
if (_sceneFront != nullptr) {
_sceneFront->SetVisibility(vis);
}
}
static const struct {
tb::TBID id;
Action action;
@ -203,16 +231,7 @@ bool MainWindow::handleChangeEvent(const tb::TBWidgetEvent &ev) {
} else if (ev.target->GetID() == TBIDC("toggleviewport")) {
tb::TBWidget *widget = ev.target;
const int value = widget->GetValue();
const tb::WIDGET_VISIBILITY vis = value ? tb::WIDGET_VISIBILITY_VISIBLE : tb::WIDGET_VISIBILITY_GONE;
if (_sceneTop != nullptr) {
_sceneTop->SetVisibility(vis);
}
if (_sceneLeft != nullptr) {
_sceneLeft->SetVisibility(vis);
}
if (_sceneFront != nullptr) {
_sceneFront->SetVisibility(vis);
}
setQuadViewport(value == 1);
return true;
}

View File

@ -52,6 +52,8 @@ public:
void OnProcess() override;
void OnDie() override;
void toggleQuadViewport();
void setQuadViewport(bool active);
bool voxelize(std::string_view file);
bool save(std::string_view file);
bool load(std::string_view file);