1 /*
2  *  Copyright (c) 2015 Dmitry Kazakov <dimula73@gmail.com>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef __KIS_PROJECTION_LEAF_H
20 #define __KIS_PROJECTION_LEAF_H
21 
22 #include <QScopedPointer>
23 
24 #include "kis_types.h"
25 #include "kritaimage_export.h"
26 
27 class KisNodeVisitor;
28 
29 
30 class KRITAIMAGE_EXPORT KisProjectionLeaf
31 {
32 public:
33     KisProjectionLeaf(KisNode *node);
34     virtual ~KisProjectionLeaf();
35 
36     KisProjectionLeafSP parent() const;
37 
38     KisProjectionLeafSP firstChild() const;
39     KisProjectionLeafSP lastChild() const;
40 
41     KisProjectionLeafSP prevSibling() const;
42     KisProjectionLeafSP nextSibling() const;
43 
44     KisNodeSP node() const;
45     KisAbstractProjectionPlaneSP projectionPlane() const;
46     bool accept(KisNodeVisitor &visitor);
47 
48     KisPaintDeviceSP original();
49     KisPaintDeviceSP projection();
50 
51     bool isRoot() const;
52     bool isLayer() const;
53     bool isMask() const;
54     bool canHaveChildLayers() const;
55     bool dependsOnLowerNodes() const;
56     bool visible() const;
57     quint8 opacity() const;
58     QBitArray channelFlags() const;
59     bool isStillInGraph() const;
60     bool hasClones() const;
61 
62     bool isDroppedNode() const;
63 
64     enum NodeDropReason {
65         NodeAvailable,
66         DropPassThroughMask,
67         DropPassThroughClone
68     };
69     NodeDropReason dropReason() const;
70 
71     bool isOverlayProjectionLeaf() const;
72 
73     /**
74      * Temporarily exclude the projection leaf from rendering by making
75      * it invisible (KisProjectionLeaf::visible() == false).
76      *
77      * This method is used by the tools that want to hide the
78      * original layer's content temporarily.
79      *
80      * NOTE: the method is not thread-safe! The caller must guarantee
81      * exclusive access to the projection leaf himself.
82      */
83     void setTemporaryHiddenFromRendering(bool value);
84 
85     /**
86      * \see setTemporaryHiddenFromRendering
87      */
88     bool isTemporaryHiddenFromRendering() const;
89 
90     /**
91      * Regenerate projection of the current group layer iff it is
92      * pass-through mode.
93      *
94      * WARNING: must be called either under the image lock held
95      *          or in the context of an exclusive stroke job.
96      */
97     void explicitlyRegeneratePassThroughProjection();
98 
99 private:
100     struct Private;
101     const QScopedPointer<Private> m_d;
102 };
103 
104 #endif /* __KIS_PROJECTION_LEAF_H */
105