Cleanup: comment line length (editors)
[blender.git] / source / blender / compositor / nodes / COM_SeparateColorNode.cpp
1 /*
2  * Copyright 2011, Blender Foundation.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (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 Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor:
19  *      Jeroen Bakker
20  *      Monique Dewanchand
21  *      Lukas Toenne
22  */
23
24 #include "COM_SeparateColorNode.h"
25
26 #include "COM_ConvertOperation.h"
27
28
29 SeparateColorNode::SeparateColorNode(bNode *editorNode) :
30     Node(editorNode)
31 {
32 }
33
34 void SeparateColorNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
35 {
36         NodeInput *imageSocket = this->getInputSocket(0);
37         NodeOutput *outputRSocket = this->getOutputSocket(0);
38         NodeOutput *outputGSocket = this->getOutputSocket(1);
39         NodeOutput *outputBSocket = this->getOutputSocket(2);
40         NodeOutput *outputASocket = this->getOutputSocket(3);
41
42         NodeOperation *color_conv = getColorConverter(context);
43         if (color_conv) {
44                 converter.addOperation(color_conv);
45
46                 converter.mapInputSocket(imageSocket, color_conv->getInputSocket(0));
47         }
48
49         {
50                 SeparateChannelOperation *operation = new SeparateChannelOperation();
51                 operation->setChannel(0);
52                 converter.addOperation(operation);
53
54                 if (color_conv)
55                         converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
56                 else
57                         converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
58                 converter.mapOutputSocket(outputRSocket, operation->getOutputSocket(0));
59         }
60
61         {
62                 SeparateChannelOperation *operation = new SeparateChannelOperation();
63                 operation->setChannel(1);
64                 converter.addOperation(operation);
65
66                 if (color_conv)
67                         converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
68                 else
69                         converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
70                 converter.mapOutputSocket(outputGSocket, operation->getOutputSocket(0));
71         }
72
73         {
74                 SeparateChannelOperation *operation = new SeparateChannelOperation();
75                 operation->setChannel(2);
76                 converter.addOperation(operation);
77
78                 if (color_conv)
79                         converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
80                 else
81                         converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
82                 converter.mapOutputSocket(outputBSocket, operation->getOutputSocket(0));
83         }
84
85         {
86                 SeparateChannelOperation *operation = new SeparateChannelOperation();
87                 operation->setChannel(3);
88                 converter.addOperation(operation);
89
90                 if (color_conv)
91                         converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0));
92                 else
93                         converter.mapInputSocket(imageSocket, operation->getInputSocket(0));
94                 converter.mapOutputSocket(outputASocket, operation->getOutputSocket(0));
95         }
96 }
97
98
99 NodeOperation *SeparateRGBANode::getColorConverter(const CompositorContext &/*context*/) const
100 {
101         return NULL; /* no conversion needed */
102 }
103
104 NodeOperation *SeparateHSVANode::getColorConverter(const CompositorContext &/*context*/) const
105 {
106         return new ConvertRGBToHSVOperation();
107 }
108
109 NodeOperation *SeparateYCCANode::getColorConverter(const CompositorContext &/*context*/) const
110 {
111         ConvertRGBToYCCOperation *operation = new ConvertRGBToYCCOperation();
112         bNode *editorNode = this->getbNode();
113         operation->setMode(editorNode->custom1);
114         return operation;
115 }
116
117 NodeOperation *SeparateYUVANode::getColorConverter(const CompositorContext &/*context*/) const
118 {
119         return new ConvertRGBToYUVOperation();
120 }