Krita Source Code Documentation
Loading...
Searching...
No Matches
ChannelFlagAdapter Struct Reference

#include <kis_multinode_property.h>

+ Inheritance diagram for ChannelFlagAdapter:

Classes

struct  Property
 

Public Types

typedef MultinodePropertyBoolConnector< ChannelFlagAdapterConnectorType
 
typedef QList< PropertyPropertyList
 
typedef bool ValueType
 

Public Member Functions

 ChannelFlagAdapter (const Property &prop)
 
QString name () const
 
ValueType propForNode (KisNodeSP node)
 
void setPropForNode (KisNodeSP node, const ValueType &value, int index)
 
- Public Member Functions inherited from BaseAdapter
void setNumNodes (int numNodes)
 

Static Public Member Functions

static PropertyList adaptersList (KisNodeList nodes)
 
static KisNodeList filterNodes (KisNodeList nodes)
 
- Static Public Member Functions inherited from BaseAdapter
static KisNodeList filterNodes (KisNodeList nodes)
 

Static Public Attributes

static const bool forceIgnoreByDefault = false
 

Static Private Member Functions

static KisLayerSP toLayer (KisNodeSP node)
 

Private Attributes

Property m_prop
 

Additional Inherited Members

- Public Attributes inherited from BaseAdapter
int m_numNodes = 0
 

Detailed Description

Definition at line 202 of file kis_multinode_property.h.

Member Typedef Documentation

◆ ConnectorType

◆ PropertyList

◆ ValueType

Definition at line 203 of file kis_multinode_property.h.

Constructor & Destructor Documentation

◆ ChannelFlagAdapter()

ChannelFlagAdapter::ChannelFlagAdapter ( const Property & prop)
inline

Definition at line 214 of file kis_multinode_property.h.

214: m_prop(prop) {}

Member Function Documentation

◆ adaptersList()

static PropertyList ChannelFlagAdapter::adaptersList ( KisNodeList nodes)
inlinestatic

Definition at line 246 of file kis_multinode_property.h.

246 {
247 PropertyList props;
248
249 {
250 bool nodesDiffer = KisLayerUtils::checkNodesDiffer<const KoColorSpace*>(nodes, [](KisNodeSP node) { return node->colorSpace(); });
251
252 if (nodesDiffer) {
253 return props;
254 }
255 }
256
257
258 const QList<KoChannelInfo*> channels = nodes.first()->colorSpace()->channels();
259
260 int index = 0;
261 Q_FOREACH (KoChannelInfo *info, channels) {
262 props << Property(info->name(), index);
263 index++;
264 }
265
266 return props;
267 }
QString name() const
QList< Property > PropertyList
virtual const KoColorSpace * colorSpace() const =0

References KisBaseNode::colorSpace(), and KoChannelInfo::name().

◆ filterNodes()

static KisNodeList ChannelFlagAdapter::filterNodes ( KisNodeList nodes)
inlinestatic

Definition at line 269 of file kis_multinode_property.h.

269 {
270 KisNodeList filteredNodes;
271 Q_FOREACH (KisNodeSP node, nodes) {
272 if (toLayer(node)) {
273 filteredNodes << node;
274 }
275 }
276 return filteredNodes;
277 }
static KisLayerSP toLayer(KisNodeSP node)

References toLayer().

◆ name()

QString ChannelFlagAdapter::name ( ) const
inline

Definition at line 242 of file kis_multinode_property.h.

242 {
243 return m_prop.name;
244 }

References m_prop, and ChannelFlagAdapter::Property::name.

◆ propForNode()

ValueType ChannelFlagAdapter::propForNode ( KisNodeSP node)
inline

Definition at line 216 of file kis_multinode_property.h.

216 {
217 KisLayerSP layer = toLayer(node);
218 Q_ASSERT(layer);
219
220 QBitArray flags = layer->channelFlags();
221 if (flags.isEmpty()) return true;
222
223 return flags.testBit(m_prop.channelIndex);
224 }
QBitArray channelFlags
Definition kis_layer.cc:167

References KisLayer::channelFlags, ChannelFlagAdapter::Property::channelIndex, m_prop, and toLayer().

◆ setPropForNode()

void ChannelFlagAdapter::setPropForNode ( KisNodeSP node,
const ValueType & value,
int index )
inline

Definition at line 226 of file kis_multinode_property.h.

226 {
227 Q_UNUSED(index);
228 KisLayerSP layer = toLayer(node);
229 Q_ASSERT(layer);
230
231 QBitArray flags = layer->channelFlags();
232 if (flags.isEmpty()) {
233 flags = QBitArray(layer->colorSpace()->channelCount(), true);
234 }
235
236 if (flags.testBit(m_prop.channelIndex) != value) {
237 flags.setBit(m_prop.channelIndex, value);
238 layer->setChannelFlags(flags);
239 }
240 }
float value(const T *src, size_t ch)
virtual quint32 channelCount() const =0
const KoColorSpace * colorSpace() const override
returns the image's colorSpace or null, if there is no image
Definition kis_layer.cc:225
virtual void setChannelFlags(const QBitArray &channelFlags)
Definition kis_layer.cc:342

References KoColorSpace::channelCount(), KisLayer::channelFlags, ChannelFlagAdapter::Property::channelIndex, KisLayer::colorSpace(), m_prop, KisLayer::setChannelFlags(), toLayer(), and value().

◆ toLayer()

static KisLayerSP ChannelFlagAdapter::toLayer ( KisNodeSP node)
inlinestaticprivate

Definition at line 279 of file kis_multinode_property.h.

279 {
280 return qobject_cast<KisLayer*>(node.data());
281 }

References KisSharedPtr< T >::data().

Member Data Documentation

◆ forceIgnoreByDefault

const bool ChannelFlagAdapter::forceIgnoreByDefault = false
static

Definition at line 205 of file kis_multinode_property.h.

◆ m_prop

Property ChannelFlagAdapter::m_prop
private

Definition at line 283 of file kis_multinode_property.h.


The documentation for this struct was generated from the following file: