void MainWindow::on_actionAutoPalette_toggled(bool state) { if (state == true) useGradient(ADJUSTED); else useGradient(ORIGINAL); }
QBrush FillTab::brush(QBrush b) const { QColor this_color = colorDirty() ? color() : b.color(); Qt::BrushStyle this_style = styleDirty() ? style() : b.style(); if (useGradientDirty()) { // Apply / unapply gradient if (useGradient()) { b = QBrush(gradient()); } else { b.setColor(this_color); b.setStyle(this_style); } } else { // Leave gradient but make other changes. QGradient this_gradient; if (const QGradient *grad = b.gradient()) { if (gradientDirty()) { this_gradient = gradient(); } else { this_gradient = *grad; } b = QBrush(this_gradient); } else { b.setColor(this_color); b.setStyle(this_style); } } return b; }
void MainWindow::on_actionDEMOpen_triggered() { QString filepath = QFileDialog::getOpenFileName(this, QString("Select the file"), lastDir, "SRTM DEMs (*.hgt *.M01)"); if (filepath == NULL) return; lastDir = filepath.left(filepath.lastIndexOf(QChar('/'))); if (em != NULL) delete em; em = NULL; if (gAdjusted != NULL) delete gAdjusted; gAdjusted = NULL; try { em = new ElevationModel(filepath); gAdjusted = GradientAdjuster::getAdjusted(gOrig, em); useGradient(current); ui->actionAutoPalette->setEnabled(true); } catch(HGTFormatException e) { QMessageBox::critical(this, QString("Error opening file"), QString("Error opening file: %1:\n%2").arg(filepath).arg(e.getError())); ui->actionAutoPalette->setChecked(false); ui->actionAutoPalette->setEnabled(false); this->useGradient(ORIGINAL); } }