void KisPaintingInformationBuilder::updateSettings()
{
    KisConfig cfg;
    KisCubicCurve curve;
    curve.fromString(cfg.pressureTabletCurve());
    m_pressureSamples = curve.floatTransfer(LEVEL_OF_PRESSURE_RESOLUTION + 1);
}
void KisBrightnessContrastFilterConfiguration::fromXML(const QDomElement& root)
{
    KisCubicCurve curve;
    int version;
    version  = root.attribute("version").toInt();

    QDomElement e = root.firstChild().toElement();
    QString attributeName;

    while (!e.isNull()) {
        if ((attributeName = e.attribute("name")) != "nTransfers") {
            QRegExp rx("curve(\\d+)");
            if (rx.indexIn(attributeName, 0) != -1) {
                quint16 index = rx.cap(1).toUShort();

                if (index == 0 && !e.text().isEmpty()) {
                    /**
                     * We are going to use first curve only
                     */
                    curve.fromString(e.text());
                }
            }
        }
        e = e.nextSiblingElement();
    }

    setVersion(version);
    setCurve(curve);
}
Example #3
0
InputSettings::InputSettings(QWidget *parent) :
	QDockWidget(tr("Input"), parent)
{
	_ui = new Ui_InputSettings;
	QWidget *w = new QWidget(this);
	setWidget(w);
	_ui->setupUi(w);

	// Restore settings
	QSettings cfg;
	cfg.beginGroup("input");
	_ui->smoothing->setValue(cfg.value("smoothing", 0).toInt());
	_ui->pressuresrc->setCurrentIndex(cfg.value("pressuremode", 0).toInt());
	_ui->stackedWidget->setCurrentIndex(_ui->pressuresrc->currentIndex());

	if(cfg.contains("pressurecurve")) {
		KisCubicCurve curve;
		curve.fromString(cfg.value("pressurecurve").toString());
		_ui->stylusCurve->setCurve(curve);
	}

	if(cfg.contains("distancecurve")) {
		KisCubicCurve curve;
		curve.fromString(cfg.value("distancecurve").toString());
		_ui->distanceCurve->setCurve(curve);
	}

	if(cfg.contains("velocitycurve")) {
		KisCubicCurve curve;
		curve.fromString(cfg.value("velocitycurve").toString());
		_ui->velocityCurve->setCurve(curve);
	} else {
		KisCubicCurve curve;
		curve.fromString("0,1;1,0");
		_ui->velocityCurve->setCurve(curve);
	}

	_ui->distance->setValue(cfg.value("distance", _ui->distance->minimum()).toInt());
	_ui->velocity->setValue(cfg.value("velocity", _ui->velocity->minimum()).toInt());
}
KisMaskGenerator* KisMaskGenerator::fromXML(const QDomElement& elt)
{
    double diameter = 1.0;
    // backward compatibility -- it was mistakenly named radius for 2.2
    if (elt.hasAttribute("radius")){
        diameter = KisDomUtils::toDouble(elt.attribute("radius", "1.0"));
    }
    else /*if (elt.hasAttribute("diameter"))*/{
        diameter = KisDomUtils::toDouble(elt.attribute("diameter", "1.0"));
    }
    double ratio = KisDomUtils::toDouble(elt.attribute("ratio", "1.0"));
    double hfade = KisDomUtils::toDouble(elt.attribute("hfade", "0.0"));
    double vfade = KisDomUtils::toDouble(elt.attribute("vfade", "0.0"));

    int spikes = elt.attribute("spikes", "2").toInt();
    QString typeShape = elt.attribute("type", "circle");
    QString id = elt.attribute("id", DefaultId.id());
    bool antialiasEdges = elt.attribute("antialiasEdges", "0").toInt();

    if (id == DefaultId.id()) {
        if (typeShape == "circle") {
            return new KisCircleMaskGenerator(diameter, ratio, hfade, vfade, spikes, antialiasEdges);
        } else {
            return new KisRectangleMaskGenerator(diameter, ratio, hfade, vfade, spikes, antialiasEdges);
        }
    }

    if (id == SoftId.id()) {
        KisCubicCurve curve;
        curve.fromString(elt.attribute("softness_curve","0,0;1,1"));

        if (typeShape == "circle") {
            return new KisCurveCircleMaskGenerator(diameter, ratio, hfade, vfade, spikes, curve, antialiasEdges);
        } else {
            return new KisCurveRectangleMaskGenerator(diameter, ratio, hfade, vfade, spikes, curve, antialiasEdges);
        }
    }

    if (id == GaussId.id()) {
        if (typeShape == "circle") {
            return new KisGaussCircleMaskGenerator(diameter, ratio, hfade, vfade, spikes, antialiasEdges);
        } else {
            return new KisGaussRectangleMaskGenerator(diameter, ratio, hfade, vfade, spikes, antialiasEdges);
        }
    }

    // if unknown
    return new KisCircleMaskGenerator(diameter, ratio, hfade, vfade, spikes, true);
}
Example #5
0
void KisAutoBrushWidget::setBrush(KisBrushSP brush)
{
    m_autoBrush = brush;
    m_brush = brush->image();
    // XXX: lock, set and unlock the widgets.
    KisAutoBrush* aBrush = dynamic_cast<KisAutoBrush*>(brush.data());
    if (aBrush->maskGenerator()->type() == KisMaskGenerator::CIRCLE) {
        comboBoxShape->setCurrentIndex(0);
    }
    else if (aBrush->maskGenerator()->type() == KisMaskGenerator::RECTANGLE) {
        comboBoxShape->setCurrentIndex(1);
    }
    else {
        comboBoxShape->setCurrentIndex(2);
    }

    comboBoxMaskType->setCurrentIndex(comboBoxMaskType->findText(aBrush->maskGenerator()->name()));


    inputRadius->setValue(aBrush->maskGenerator()->diameter());
    inputRatio->setValue(aBrush->maskGenerator()->ratio());

    inputVFade->blockSignals(true);
    inputHFade->blockSignals(true);
    inputHFade->setValue(aBrush->maskGenerator()->horizontalFade());
    inputVFade->setValue(aBrush->maskGenerator()->verticalFade());
    inputVFade->blockSignals(false);
    inputHFade->blockSignals(false);

    inputAngle->setValue(aBrush->angle() * 180 / M_PI);
    inputSpikes->setValue(aBrush->maskGenerator()->spikes());
    inputSpacing->setValue(aBrush->spacing());
    inputSpacing->setExponentRatio(3.0);
    inputRandomness->setValue(aBrush->randomness() * 100);
    density->setValue(aBrush->density() * 100);

    if (!aBrush->maskGenerator()->curveString().isEmpty()) {
        KisCubicCurve curve;
        curve.fromString(aBrush->maskGenerator()->curveString());
        softnessCurve->setCurve(curve);
    }
}
KisHatchingPaintOpSettingsWidget:: KisHatchingPaintOpSettingsWidget(QWidget* parent)
                                 : KisBrushBasedPaintopOptionWidget(parent)
{
    //-------Adding widgets to the screen------------
    
    addPaintOpOption(new KisHatchingOptions());
    addPaintOpOption(new KisHatchingPreferences());
    addPaintOpOption(new KisPaintActionTypeOption());
    addPaintOpOption(new KisCurveOptionWidget(new KisHatchingPressureSeparationOption()));
    addPaintOpOption(new KisCurveOptionWidget(new KisHatchingPressureThicknessOption()));
    addPaintOpOption(new KisCurveOptionWidget(new KisHatchingPressureCrosshatchingOption()));
    addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption()));
    addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption()));

    //-----Useful to read first:------
    /*
    Below you will encounter a reasonably correct solution to the problem of changing
    the default presets of the "BrushTip" popup configuration dialgoue.
    In my (Pentalis) opinion, the best solution is code refactoring (simpler ways
    to change the defaults). On the meanwhile, copypasting this code
    won't give your class a charisma penalty.
    In kis_hatching_paintop_settings.cpp you will find a snippet of code to
    discover the structure of your XML config tree if you need to edit it at build
    time like here.    
    */
    
    //---------START ALTERING DEFAULT VALUES-----------
    
    //As the name implies, reconfigurationCourier is the KisPropertiesConfiguration*
    //we'll use as an intermediary to edit the default settings
    KisPropertiesConfiguration* reconfigurationCourier = configuration();
    
    /*xMLAnalyzer is an empty document we'll use to analyze and edit the config string part by part
    I know the important string is "brush_definition" because I read the tree with the snippet
    in kis_hatching_paintop_settings.cpp */
    QDomDocument xMLAnalyzer("");
    xMLAnalyzer.setContent(reconfigurationCourier->getString("brush_definition") );
    
    /*More things I know by reading the XML tree. At this point you can just read it with:
    qDebug() << xMLAnalyzer.toString() ;
    those QDomElements are the way to navigate the XML tree, read
    http://doc.qt.nokia.com/latest/qdomdocument.html for more information */
    QDomElement firstTag = xMLAnalyzer.documentElement();
    QDomElement firstTagsChild = firstTag.elementsByTagName("MaskGenerator").item(0).toElement();
    
    // SET THE DEFAULT VALUES
    firstTag.attributeNode("spacing").setValue("0.4");
    firstTagsChild.attributeNode("diameter").setValue("30");
    
    //Write them into the intermediary config file
    reconfigurationCourier->setProperty("brush_definition", xMLAnalyzer.toString() );
    
    KisCubicCurve CurveSize;
    
    CurveSize.fromString("0,1;1,0.1;");
    //qDebug() << "\n\n\n" << CurveSize.toString() << "\n\n\n";
    
    QVariant QVCurveSize = QVariant::fromValue(CurveSize);
    
    reconfigurationCourier->setProperty("CurveSize", QVCurveSize);
    
    setConfiguration(reconfigurationCourier);  // Finished.
    
    /* Debugging block
    QMap<QString, QVariant> rofl = QMap<QString, QVariant>(reconfigurationCourier->getProperties());
    
    QMap<QString, QVariant>::const_iterator i;
    for (i = rofl.constBegin(); i != rofl.constEnd(); ++i)
        qDebug() << i.key() << ":" << i.value();
    */
    
    delete reconfigurationCourier;
}