MapTileOptionList::MapTileOptionList(int x, int y, int w, int h, int i) : ScrollingOptionList(x, y, w, h, i) { selectedType = Cell::CellType::Floor; TileOption * opt; opt = new TileOption(Cell::CellType::Wall, 0, 0, w, (h - buttonHeight * 2) / i); opt->setVisibility(false); opt->functionPointer = std::bind(&MapTileOptionList::setSelectedType, this, std::placeholders::_1); addMapTileOption(opt); opt = new TileOption(Cell::CellType::Floor, 0, 0, w, (h - buttonHeight * 2) / i); opt->setVisibility(false); opt->functionPointer = std::bind(&MapTileOptionList::setSelectedType, this, std::placeholders::_1); addMapTileOption(opt); opt = new TileOption(Cell::CellType::Start, 0, 0, w, (h - buttonHeight * 2) / i); opt->setVisibility(false); opt->functionPointer = std::bind(&MapTileOptionList::setSelectedType, this, std::placeholders::_1); addMapTileOption(opt); opt = new TileOption(Cell::CellType::End, 0, 0, w, (h - buttonHeight * 2) / i); opt->setVisibility(false); opt->functionPointer = std::bind(&MapTileOptionList::setSelectedType, this, std::placeholders::_1); addMapTileOption(opt); opt = nullptr; updateOptionVisibility(); }
void SnapshotWidget::openForVP(const ViewportType type) { vpGroup.button(type)->setChecked(true); updateOptionVisibility(); show(); activateWindow(); raise(); }
void SnapshotWidget::loadSettings() { QSettings settings; settings.beginGroup(SNAPSHOT_WIDGET); restoreGeometry(settings.value(GEOMETRY).toByteArray()); const auto vp = settings.value(VIEWPORT, VIEWPORT_XY).toInt(); vpGroup.button(vp)->setChecked(true); withAxesCheck.setChecked(settings.value(WITH_AXES, true).toBool()); withBoxCheck.setChecked(settings.value(WITH_BOX, false).toBool()); withOverlayCheck.setChecked(settings.value(WITH_OVERLAY, true).toBool()); withSkeletonCheck.setChecked(settings.value(WITH_SKELETON, true).toBool()); withScaleCheck.setChecked(settings.value(WITH_SCALE, true).toBool()); withVpPlanes.setChecked(settings.value(WITH_VP_PLANES, false).toBool()); updateOptionVisibility(); saveDir = settings.value(SAVE_DIR, QDir::homePath() + "/").toString(); settings.endGroup(); }
SnapshotWidget::SnapshotWidget(QWidget *parent) : DialogVisibilityNotify(SNAPSHOT_WIDGET, parent), saveDir(QDir::homePath()) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowIcon(QIcon(":/resources/icons/snapshot.png")); setWindowTitle("Snapshot Tool"); sizeCombo.addItem("8192 x 8192"); sizeCombo.addItem("4096 x 4096"); sizeCombo.addItem("2048 x 2048"); sizeCombo.addItem("1024 x 1024"); sizeCombo.setCurrentIndex(2); // 2048x2048 default vpArbRadio.setHidden(true); auto viewportChoiceLayout = new QVBoxLayout(); vpGroup.addButton(&vpXYRadio, VIEWPORT_XY); vpGroup.addButton(&vpXZRadio, VIEWPORT_XZ); vpGroup.addButton(&vpZYRadio, VIEWPORT_ZY); vpGroup.addButton(&vpArbRadio, VIEWPORT_ARBITRARY); vpGroup.addButton(&vp3dRadio, VIEWPORT_SKELETON); viewportChoiceLayout->addWidget(&vpXYRadio); viewportChoiceLayout->addWidget(&vpXZRadio); viewportChoiceLayout->addWidget(&vpZYRadio); viewportChoiceLayout->addWidget(&vpArbRadio); viewportChoiceLayout->addWidget(&vp3dRadio); QObject::connect(&vpGroup, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), [this](const int) { updateOptionVisibility(); }); auto imageOptionsLayout = new QVBoxLayout(); imageOptionsLayout->addWidget(&withAxesCheck); imageOptionsLayout->addWidget(&withBoxCheck); imageOptionsLayout->addWidget(&withOverlayCheck); imageOptionsLayout->addWidget(&withSkeletonCheck); imageOptionsLayout->addWidget(&withScaleCheck); imageOptionsLayout->addWidget(&withVpPlanes); auto settingsLayout = new QHBoxLayout(); settingsLayout->addLayout(viewportChoiceLayout); auto line = new QFrame(); line->setFrameShape(QFrame::VLine); line->setFrameStyle(QFrame::Sunken); settingsLayout->addWidget(line); settingsLayout->addLayout(imageOptionsLayout); mainLayout.addWidget(&sizeCombo); mainLayout.addLayout(settingsLayout); mainLayout.addWidget(&snapshotButton); QObject::connect(&snapshotButton, &QPushButton::clicked, [this]() { state->viewerState->renderInterval = SLOW; const auto path = QFileDialog::getSaveFileName(this, tr("Save path"), saveDir + defaultFilename(), tr("Images (*.png *.xpm *.xbm *.jpg *.bmp)")); state->viewerState->renderInterval = FAST; if(path.isEmpty() == false) { QFileInfo info(path); saveDir = info.absolutePath() + "/"; emit snapshotRequest(path, static_cast<ViewportType>(vpGroup.checkedId()), 8192/pow(2, sizeCombo.currentIndex()), withAxesCheck.isChecked(), withBoxCheck.isChecked(), withOverlayCheck.isChecked(), withSkeletonCheck.isChecked(), withScaleCheck.isChecked(), withVpPlanes.isChecked()); } }); QObject::connect(state->viewer, &Viewer::enabledArbVP, [this](const bool on) { vpArbRadio.setVisible(on); if (vpArbRadio.isChecked() && vpArbRadio.isHidden()) { for (auto * button : vpGroup.buttons()) { if (button->isVisible()) { button->setChecked(true); } } } }); QObject::connect(state->viewer, &Viewer::changedDefaultVPSizeAndPos, [this]() { const auto xy = state->viewer->window->viewportXY.get()->isVisibleTo(state->viewer->window); const auto xz = state->viewer->window->viewportXZ.get()->isVisibleTo(state->viewer->window); const auto zy = state->viewer->window->viewportZY.get()->isVisibleTo(state->viewer->window); const auto arb = state->viewer->window->viewportArb.get()->isVisibleTo(state->viewer->window); const auto skel = state->viewer->window->viewport3D.get()->isVisibleTo(state->viewer->window); vpXYRadio.setVisible(xy); vpXZRadio.setVisible(xz); vpZYRadio.setVisible(zy); vpArbRadio.setVisible(arb); vp3dRadio.setVisible(skel); if (vpGroup.checkedButton() && vpGroup.checkedButton()->isHidden()) { for (auto * button : vpGroup.buttons()) { if (button->isVisible()) { button->setChecked(true); } } } snapshotButton.setEnabled(xy || xz || zy || arb || skel); }); setLayout(&mainLayout); }