|
Krita Source Code Documentation
|
#include <KoDerivedResourceConverter.h>
Inheritance diagram for KoDerivedResourceConverter:Classes | |
| struct | Private |
Public Member Functions | |
| int | key () const |
| KoDerivedResourceConverter (int key, int sourceKey) | |
| virtual bool | notifySourceChanged (const QVariant &sourceValue) |
| QVariant | readFromSource (const QVariant &value) |
| int | sourceKey () const |
| QVariant | writeToSource (const QVariant &value, const QVariant &sourceValue, bool *changed) |
| virtual | ~KoDerivedResourceConverter () |
Protected Member Functions | |
| virtual QVariant | fromSource (const QVariant &value)=0 |
| virtual QVariant | toSource (const QVariant &value, const QVariant &sourceValue)=0 |
Private Attributes | |
| const QScopedPointer< Private > | m_d |
Defines the abstraction of a derived resource. It should be uploaded to the KoResourceManager during the loading phase. The manager will use it to convert values to/from the source resource.
"Derived" resources are the resources that do not exist themselves. Instead they are contained in some other resources and are updated synchronously with the parent resources as well.
E.g. we store opacity and composite op and opacity in the current paintop preset, which is also a resource. So composite op and opacity are "derived" resources.
The main goal of this class is to make our resources comply with a general Model-View-Controller architecture:
Model: KisPaintOpPreset. It stores opacity, composite op, eraser mode and other "global" properties.
Controller: KoCanvasResourceManager. It controls access to the resources and emits notification signals when they are changed.
View: KisPaintOpBox and other classes that show the resources on screen
Please take into account that according to the MVC design all the access to the model resources should be performed through the controller.
Definition at line 47 of file KoDerivedResourceConverter.h.
| KoDerivedResourceConverter::KoDerivedResourceConverter | ( | int | key, |
| int | sourceKey ) |
| key | the unique id of the resource defined by this converter |
| sourceKey | the id of the parent resource, i.e. where the values are really loaded/saved. |
Definition at line 25 of file KoDerivedResourceConverter.cpp.
|
virtual |
Definition at line 30 of file KoDerivedResourceConverter.cpp.
|
protectedpure virtual |
Converts the value of the source resource into the space of the "derived" resource. E.g. preset -> opacity.
Implemented in KisCompositeOpResourceConverter, KisEffectiveCompositeOpResourceConverter, KisOpacityToPresetOpacityResourceConverter, KisFlowResourceConverter, KisFadeResourceConverter, KisScatterResourceConverter, KisSizeResourceConverter, KisBrushRotationResourceConverter, KisPatternSizeResourceConverter, KisLodAvailabilityResourceConverter, KisLodSizeThresholdResourceConverter, KisLodSizeThresholdSupportedResourceConverter, KisEraserModeResourceConverter, and KisBrushNameResourceConverter.
| int KoDerivedResourceConverter::key | ( | ) | const |
Definition at line 34 of file KoDerivedResourceConverter.cpp.
References m_d.
|
virtual |
Definition at line 44 of file KoDerivedResourceConverter.cpp.
References fromSource(), and m_d.
| QVariant KoDerivedResourceConverter::readFromSource | ( | const QVariant & | value | ) |
Definition at line 55 of file KoDerivedResourceConverter.cpp.
References fromSource(), and m_d.
| int KoDerivedResourceConverter::sourceKey | ( | ) | const |
Definition at line 39 of file KoDerivedResourceConverter.cpp.
References m_d.
|
protectedpure virtual |
Converts the value of the "derived" resource into the space of the original ("source") resource. E.g. opacity -> preset.
Implemented in KisCompositeOpResourceConverter, KisEffectiveCompositeOpResourceConverter, KisOpacityToPresetOpacityResourceConverter, KisFlowResourceConverter, KisFadeResourceConverter, KisScatterResourceConverter, KisSizeResourceConverter, KisBrushRotationResourceConverter, KisPatternSizeResourceConverter, KisLodAvailabilityResourceConverter, KisLodSizeThresholdResourceConverter, KisLodSizeThresholdSupportedResourceConverter, KisEraserModeResourceConverter, and KisBrushNameResourceConverter.
| QVariant KoDerivedResourceConverter::writeToSource | ( | const QVariant & | value, |
| const QVariant & | sourceValue, | ||
| bool * | changed ) |
Some resources may be immutable, that is, writing to them will not alter the value. Example: size property of the Shape Brush (always 1.0)
Definition at line 63 of file KoDerivedResourceConverter.cpp.
References fromSource(), m_d, toSource(), and value().
|
private |
Definition at line 85 of file KoDerivedResourceConverter.h.