void RConstants::setValue(std::string section, std::string name, SEXP value) {
    if(TYPEOF(value) != STRSXP) {
        Rcpp::NumericVector v(value);
        std::ostringstream strs;
        for(size_t i=0; i<v.size(); i++) {
            if(i>= c->lc->size) {
                std::cout << "Too many values. Add more layers \n";
                break;
            }

            if(i>0) strs << " ";
            strs << v[i];
        }
        writeOption(section, name, strs.str());
    } else {
        Rcpp::CharacterVector v(value);
        assert(v.size() > 0);
        std::string fv(v[0]);
        if(fv.find(' ') != std::string::npos) {
            if(v.size() > 1) {
                std::cout << "Too messy value\n";
                return;
            }
            std::vector<std::string> x = split(fv, ' ');
            std::string acc_str("");
            for(size_t i=0; i<x.size(); i++) {
                if(i>= c->lc->size) {
                    std::cout << "Too many values. Add more layers \n";
                    break;
                }

                if(i>0) acc_str += " ";
                acc_str += x[i];
            }
            writeOption(section, name, acc_str);
        } else {
            std::string acc_str("");
            for(size_t i=0; i<v.size(); i++) {
                if(i>= c->lc->size) {
                    std::cout << "Too many values. Add more layers \n";
                    break;
                }

                if(i>0) acc_str += " ";
                acc_str += v[i];
            }
            writeOption(section, name, acc_str);
        }
    }
}
Exemple #2
0
void FontConfigDialog::accept(){
  QDir::home().mkpath(".config/fontconfig/");
  QString path = QDir::homePath() + "/.config/fontconfig/fonts.conf";
  qDebug("FontConfigDialog: fontconfig path: %s", qPrintable(path));
  if(QFile::exists(path)){
    if(QMessageBox::question(this, tr("Font Configuration"), tr("<i>%1</i> already exists. Do you want to replace it?").arg(path), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No){
      QDialog::reject();
      return;
      }
    QFile::remove(path + ".back");
    QFile::copy(path, path + ".back");
    }
  QFile file(path);
  if(!file.open(QIODevice::WriteOnly)){
    qWarning("FontConfigDialog: unable to open file: %s", qPrintable(file.errorString()));
    return;
    }
  QXmlStreamWriter stream(&file);
  stream.setAutoFormatting(true);
  stream.writeStartDocument();
  stream.writeDTD("<!DOCTYPE fontconfig SYSTEM \"fonts.dtd\">");
  stream.writeStartElement("fontconfig");
  stream.writeStartElement("match");
  stream.writeAttribute("target", "font");
  writeOption(&stream, "antialias", "bool", m_ui->antialisingCheckBox->isChecked() ? "true" : "false");
  writeOption(&stream, "hinting", "bool", m_ui->hintingCheckBox->isChecked() ? "true" : "false");
  writeOption(&stream, "hintstyle", "const", m_ui->hintingStyleComboBox->currentData().toString());
  writeOption(&stream, "rgba", "const", m_ui->rgbaComboBox->currentData().toString());
  writeOption(&stream, "autohint", "bool", m_ui->autohinterCheckBox->isChecked() ? "true" : "false");
  writeOption(&stream, "lcdfilter", "const", m_ui->lcdFilterComboBox->currentText());
  writeOption(&stream, "dpi", "double", QString::number(m_ui->dpiSpinBox->value()));
  stream.writeEndElement();
  if(m_ui->disableBoldAutohintCheckBox->isChecked()){
    stream.writeStartElement("match");
    stream.writeAttribute("target", "font");
    stream.writeStartElement("test");
    stream.writeAttribute("name", "weight");
    stream.writeAttribute("compare", "more");
    stream.writeTextElement("const", "medium");
    stream.writeEndElement();
    writeOption(&stream, "autohint", "bool", m_ui->autohinterCheckBox->isChecked() ? "true" : "false");
    stream.writeEndElement();
    }
  stream.writeEndElement();
  stream.writeEndDocument();
  QDialog::accept();
}
	void Options::SaveOptions()
	{
		NativeString configurationPath(NativeString(mMaxInterface->GetDir(APP_PLUGCFG_DIR)));
		URI configurationPathUri(URI::nativePathToUri(configurationPath.toUtf8String()));
		URI optionsFileUri(configurationPathUri, CONFIGURATION_FILE_NAME);
	//	NativeString filename = configurationPath + "\\" + CONFIGURATION_FILE_NAME;
		FILE* file;
		errno_t error = fopen_s(&file, optionsFileUri.toNativePath().c_str(), "wb");
		if ( error )
			return;



		// Write down a standard INI header to allow MaxScript edition.
		String headerString("[" + CONFIGURATION_HEADER_NAME + "]\r\n");
		fwrite(headerString.data(), headerString.length(), 1, file);

		// Write down the options, one by one, in the form: 'option=X\n'
		writeOption(file, OPTION_NORMALS_NAME, mNormals );

		writeOption(file, OPTION_TRIANGULAT_NAME, mTriangulate );
		writeOption(file, OPTION_XREFS_NAME, mIncludeXrefs );
		writeOption(file, OPTION_TANGENTS_NAME, mTangents );
		writeOption(file, OPTION_ANIMATIONS_NAME, mAnimations );
		writeOption(file, OPTION_SAMPLEANIMATIONS_NAME, mSampleAnimation );
		writeOption(file, OPTION_CREATECLIP_NAME, mCreateClip );
		writeOption(file, OPTION_BAKEMATRICES_NAME, mBakeMatrices );
		writeOption(file, OPTION_RELATIVEPATHS_NAME, mRelativePaths );
		writeOption(file, OPTION_CHECKIFANIMATIONISANIMATED_NAME, mCheckIfAnimationIsAnimated );
		writeOption(file, OPTION_ANIMATIONSTART_NAME, mAnimationStart );
		writeOption(file, OPTION_ANIMATIONEND_NAME, mAnimationEnd );
		writeOption(file, OPTION_COPY_IMAGES_NAME, mCopyImages );
		writeOption(file, OPTION_EXPORT_USERDEFINED_PROPERTIES_NAME, mExportUserDefinedProperties );

		fclose(file);
	}
void edOptions::SaveOptions()
{
    writeOption("ExportDirectory",exportDir);
    writeOption("SceneryFile",sceneryFile);
}