Exemplo n.º 1
0
bool TFEditor::save() {

    if(fileName_.isEmpty())
    {
        fileName_ = QDir::currentPath().append(QString::fromStdString("/" + name_));

        fileName_ = QFileDialog::getSaveFileName(this,
                    QObject::tr("Save Transfer Function Editor"),
                    fileName_,
                    QObject::tr("TF Editor Files (*.tfe)"));

        if (fileName_.isEmpty()) return false;
    }

    if (!writer_->begin(fileName_.toLocal8Bit().data()))
    {
        QMessageBox errorMessage(QMessageBox::Critical,
                                 "Error",
                                 QString::fromStdString(writer_->errorMessage()),
                                 QMessageBox::Ok
                                );
        errorMessage.setDefaultButton(QMessageBox::Ok);
        errorMessage.exec();
        return false;
    }

    writer_->writeDTD("TransferFunctionEditorFile");

    writer_->writeStartElement("Editor");

    writer_->writeAttribute("Name", name_);
    writer_->writeAttribute("Predefined",
                            TF::convert<TF::Types::Predefined, std::string>(structure_.predefined));
    writer_->writeAttribute("Dimension",
                            TF::convert<TF::Types::Dimension, std::string>(structure_.dimension));
    writer_->writeAttribute("Function",
                            TF::convert<TF::Types::Function, std::string>(structure_.function));
    writer_->writeAttribute("Painter",
                            TF::convert<TF::Types::Painter, std::string>(structure_.painter));
    writer_->writeAttribute("Modifier",
                            TF::convert<TF::Types::Modifier, std::string>(structure_.modifier));

    saveSettings_(writer_);

    modifier_->save(writer_);

    writer_->end();

    lastSave_ = modifier_->getTimeStamp();

    return true;
}
Exemplo n.º 2
0
void PlayGameEngineDialog::accept()
{
    saveSettings_();
    QDialog::accept();
}