Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/kis_painting_assistant.cc
Context not available. | |||||
167 | d->isSnappingActive = set; | 167 | d->isSnappingActive = set; | ||
---|---|---|---|---|---|
168 | } | 168 | } | ||
169 | 169 | | |||
170 | void KisPaintingAssistant::setCustomPropertyFloat(QString propertyName, float value) | ||||
171 | { | ||||
172 | customFloatProperties.insert(propertyName, value); // updates value too if it already exists | ||||
173 | } | ||||
174 | | ||||
175 | float KisPaintingAssistant::getCustomPropertyFloat(QString propertyName) | ||||
176 | { | ||||
177 | if (customFloatProperties.contains(propertyName)) { | ||||
178 | return customFloatProperties.value(propertyName); | ||||
179 | } | ||||
180 | | ||||
181 | return -1; // is not found | ||||
182 | } | ||||
183 | | ||||
170 | void KisPaintingAssistant::drawPath(QPainter& painter, const QPainterPath &path, bool isSnappingOn) | 184 | void KisPaintingAssistant::drawPath(QPainter& painter, const QPainterPath &path, bool isSnappingOn) | ||
171 | { | 185 | { | ||
172 | int alpha = d->assistantColor.alpha(); | 186 | int alpha = d->assistantColor.alpha(); | ||
Context not available. | |||||
331 | xml.writeStartElement("assistant"); | 345 | xml.writeStartElement("assistant"); | ||
332 | xml.writeAttribute("type",d->id); | 346 | xml.writeAttribute("type",d->id); | ||
333 | xml.writeAttribute("active", QString::number(d->isSnappingActive)); | 347 | xml.writeAttribute("active", QString::number(d->isSnappingActive)); | ||
348 | | ||||
349 | | ||||
350 | // write custom properties if they exist with the assistant | ||||
351 | // the vanishing point assistant angle is the only one right now | ||||
352 | if (customFloatProperties.count() > 0) { | ||||
353 | xml.writeStartElement("floatProperties"); | ||||
354 | | ||||
355 | QHash<QString, float>::iterator i; | ||||
356 | for (i = customFloatProperties.begin(); i != customFloatProperties.end(); ++i) { | ||||
357 | xml.writeAttribute(i.key(), QString::number(i.value())); | ||||
358 | } | ||||
359 | xml.writeEndElement(); | ||||
360 | } | ||||
361 | | ||||
362 | | ||||
363 | // write individual handle data | ||||
334 | xml.writeStartElement("handles"); | 364 | xml.writeStartElement("handles"); | ||
335 | Q_FOREACH (const KisPaintingAssistantHandleSP handle, d->handles) { | 365 | Q_FOREACH (const KisPaintingAssistantHandleSP handle, d->handles) { | ||
336 | int id = handleMap.size(); | 366 | int id = handleMap.size(); | ||
Context not available. | |||||
365 | d->isSnappingActive = (active != "0"); | 395 | d->isSnappingActive = (active != "0"); | ||
366 | } | 396 | } | ||
367 | 397 | | |||
398 | if (xml.name() == "floatProperties") { | ||||
399 | for (int i=0; i < xml.attributes().size(); ++i) { | ||||
400 | setCustomPropertyFloat(xml.attributes().at(i).name().toString(), xml.attributes().at(i).value().toFloat()); | ||||
401 | } | ||||
402 | } | ||||
403 | | ||||
368 | if (xml.name() == "handle") { | 404 | if (xml.name() == "handle") { | ||
369 | QString strId = xml.attributes().value("id").toString(), | 405 | QString strId = xml.attributes().value("id").toString(), | ||
370 | strX = xml.attributes().value("x").toString(), | 406 | strX = xml.attributes().value("x").toString(), | ||
Context not available. |