Changeset View
Changeset View
Standalone View
Standalone View
libs/image/kis_layer.cc
Context not available. | |||||
131 | KisAbstractProjectionPlaneSP layerStyleProjectionPlane; | 131 | KisAbstractProjectionPlaneSP layerStyleProjectionPlane; | ||
---|---|---|---|---|---|
132 | 132 | | |||
133 | KisAbstractProjectionPlaneSP projectionPlane; | 133 | KisAbstractProjectionPlaneSP projectionPlane; | ||
134 | | ||||
135 | KisSelectionMaskSP selectionMask; | ||||
136 | QList<KisEffectMaskSP> effectMasks; | ||||
134 | }; | 137 | }; | ||
135 | 138 | | |||
136 | 139 | | |||
Context not available. | |||||
143 | m_d->image = image; | 146 | m_d->image = image; | ||
144 | m_d->metaDataStore = new KisMetaData::Store(); | 147 | m_d->metaDataStore = new KisMetaData::Store(); | ||
145 | m_d->projectionPlane = toQShared(new KisLayerProjectionPlane(this)); | 148 | m_d->projectionPlane = toQShared(new KisLayerProjectionPlane(this)); | ||
149 | notifyChildMaskChanged(KisNodeSP()); | ||||
146 | } | 150 | } | ||
147 | 151 | | |||
148 | KisLayer::KisLayer(const KisLayer& rhs) | 152 | KisLayer::KisLayer(const KisLayer& rhs) | ||
Context not available. | |||||
160 | if (rhs.m_d->layerStyle) { | 164 | if (rhs.m_d->layerStyle) { | ||
161 | setLayerStyle(rhs.m_d->layerStyle->clone()); | 165 | setLayerStyle(rhs.m_d->layerStyle->clone()); | ||
162 | } | 166 | } | ||
167 | notifyChildMaskChanged(KisNodeSP()); | ||||
163 | } | 168 | } | ||
164 | } | 169 | } | ||
165 | 170 | | |||
Context not available. | |||||
313 | 318 | | |||
314 | void KisLayer::setTemporary(bool t) | 319 | void KisLayer::setTemporary(bool t) | ||
315 | { | 320 | { | ||
316 | nodeProperties().setProperty("temporary", t); | 321 | setNodeProperty("temporary", t); | ||
317 | } | 322 | } | ||
318 | 323 | | |||
319 | KisImageWSP KisLayer::image() const | 324 | KisImageWSP KisLayer::image() const | ||
Context not available. | |||||
435 | m_d->clonesList.setDirty(rect); | 440 | m_d->clonesList.setDirty(rect); | ||
436 | } | 441 | } | ||
437 | 442 | | |||
443 | void KisLayer::notifyChildMaskChanged(KisNodeSP changedChildMask) | ||||
444 | { | ||||
445 | updateSelectionMask(); | ||||
446 | updateEffectMasks(); | ||||
447 | } | ||||
448 | | ||||
438 | KisSelectionMaskSP KisLayer::selectionMask() const | 449 | KisSelectionMaskSP KisLayer::selectionMask() const | ||
439 | { | 450 | { | ||
451 | return m_d->selectionMask; | ||||
452 | } | ||||
453 | | ||||
454 | void KisLayer::updateSelectionMask() | ||||
455 | { | ||||
440 | KoProperties properties; | 456 | KoProperties properties; | ||
441 | properties.setProperty("active", true); | 457 | properties.setProperty("active", true); | ||
442 | QList<KisNodeSP> masks = childNodes(QStringList("KisSelectionMask"), properties); | 458 | QList<KisNodeSP> masks = childNodes(QStringList("KisSelectionMask"), properties); | ||
Context not available. | |||||
444 | // return the first visible mask | 460 | // return the first visible mask | ||
445 | Q_FOREACH (KisNodeSP mask, masks) { | 461 | Q_FOREACH (KisNodeSP mask, masks) { | ||
446 | if (mask->visible()) { | 462 | if (mask->visible()) { | ||
447 | return dynamic_cast<KisSelectionMask*>(mask.data()); | 463 | m_d->selectionMask = dynamic_cast<KisSelectionMask*>(mask.data()); | ||
464 | return; | ||||
448 | } | 465 | } | ||
449 | } | 466 | } | ||
450 | return KisSelectionMaskSP(); | 467 | m_d->selectionMask = KisSelectionMaskSP(); | ||
451 | } | 468 | } | ||
452 | 469 | | |||
453 | KisSelectionSP KisLayer::selection() const | 470 | KisSelectionSP KisLayer::selection() const | ||
Context not available. | |||||
468 | /////////////////////////////////////////////////////////////////////// | 485 | /////////////////////////////////////////////////////////////////////// | ||
469 | /////////////////////////////////////////////////////////////////////// | 486 | /////////////////////////////////////////////////////////////////////// | ||
470 | 487 | | |||
488 | const QList<KisEffectMaskSP> &KisLayer::effectMasks() const | ||||
489 | { | ||||
490 | return m_d->effectMasks; | ||||
491 | } | ||||
492 | | ||||
471 | QList<KisEffectMaskSP> KisLayer::effectMasks(KisNodeSP lastNode) const | 493 | QList<KisEffectMaskSP> KisLayer::effectMasks(KisNodeSP lastNode) const | ||
472 | { | 494 | { | ||
495 | if (lastNode.isNull()) { | ||||
496 | return effectMasks(); | ||||
497 | } else { | ||||
498 | // happens rarely. | ||||
499 | return searchEffectMasks(lastNode); | ||||
500 | } | ||||
501 | } | ||||
502 | | ||||
503 | void KisLayer::updateEffectMasks() | ||||
504 | { | ||||
505 | m_d->effectMasks = searchEffectMasks(KisNodeSP()); | ||||
506 | } | ||||
507 | | ||||
508 | QList<KisEffectMaskSP> KisLayer::searchEffectMasks(KisNodeSP lastNode) const | ||||
509 | { | ||||
473 | QList<KisEffectMaskSP> masks; | 510 | QList<KisEffectMaskSP> masks; | ||
474 | 511 | | |||
475 | if (childCount() > 0) { | 512 | if (childCount() > 0) { | ||
Context not available. | |||||
477 | properties.setProperty("visible", true); | 514 | properties.setProperty("visible", true); | ||
478 | QList<KisNodeSP> nodes = childNodes(QStringList("KisEffectMask"), properties); | 515 | QList<KisNodeSP> nodes = childNodes(QStringList("KisEffectMask"), properties); | ||
479 | 516 | | |||
480 | Q_FOREACH (const KisNodeSP& node, nodes) { | 517 | Q_FOREACH (const KisNodeSP& node, nodes) { | ||
481 | if (node == lastNode) break; | 518 | if (node == lastNode) break; | ||
482 | 519 | | |||
483 | KisEffectMaskSP mask = dynamic_cast<KisEffectMask*>(const_cast<KisNode*>(node.data())); | 520 | KisEffectMaskSP mask = dynamic_cast<KisEffectMask*>(const_cast<KisNode*>(node.data())); | ||
Context not available. | |||||
485 | masks.append(mask); | 522 | masks.append(mask); | ||
486 | } | 523 | } | ||
487 | } | 524 | } | ||
525 | | ||||
488 | return masks; | 526 | return masks; | ||
489 | } | 527 | } | ||
490 | 528 | | |||
491 | bool KisLayer::hasEffectMasks() const | 529 | bool KisLayer::hasEffectMasks() const | ||
492 | { | 530 | { | ||
493 | if (childCount() == 0) return false; | 531 | return !m_d->effectMasks.empty(); | ||
494 | | ||||
495 | KisNodeSP node = firstChild(); | | |||
496 | while (node) { | | |||
497 | if (node->inherits("KisEffectMask") && node->visible()) { | | |||
498 | return true; | | |||
499 | } | | |||
500 | node = node->nextSibling(); | | |||
501 | } | | |||
502 | | ||||
503 | return false; | | |||
504 | } | 532 | } | ||
505 | 533 | | |||
506 | QRect KisLayer::masksChangeRect(const QList<KisEffectMaskSP> &masks, | 534 | QRect KisLayer::masksChangeRect(const QList<KisEffectMaskSP> &masks, | ||
Context not available. | |||||
784 | return changeRect; | 812 | return changeRect; | ||
785 | } | 813 | } | ||
786 | 814 | | |||
815 | void KisLayer::childNodeChanged(KisNodeSP changedChildNode) | ||||
816 | { | ||||
817 | if (dynamic_cast<KisMask*>(changedChildNode.data())) { | ||||
818 | notifyChildMaskChanged(changedChildNode); | ||||
819 | } | ||||
820 | } | ||||
821 | | ||||
787 | QRect KisLayer::incomingChangeRect(const QRect &rect) const | 822 | QRect KisLayer::incomingChangeRect(const QRect &rect) const | ||
788 | { | 823 | { | ||
789 | return rect; | 824 | return rect; | ||
Context not available. |