Cleanup: comment line length (editors)
[blender.git] / source / blender / compositor / nodes / COM_MathNode.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  */
22
23 #include "COM_MathNode.h"
24 #include "COM_MathBaseOperation.h"
25 #include "COM_ExecutionSystem.h"
26
27 void MathNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
28 {
29         MathBaseOperation *operation = NULL;
30
31         switch (this->getbNode()->custom1) {
32                 case NODE_MATH_ADD:
33                         operation = new MathAddOperation();
34                         break;
35                 case NODE_MATH_SUB:
36                         operation = new MathSubtractOperation();
37                         break;
38                 case NODE_MATH_MUL:
39                         operation = new MathMultiplyOperation();
40                         break;
41                 case NODE_MATH_DIVIDE:
42                         operation = new MathDivideOperation();
43                         break;
44                 case NODE_MATH_SIN:
45                         operation = new MathSineOperation();
46                         break;
47                 case NODE_MATH_COS:
48                         operation = new MathCosineOperation();
49                         break;
50                 case NODE_MATH_TAN:
51                         operation = new MathTangentOperation();
52                         break;
53                 case NODE_MATH_ASIN:
54                         operation = new MathArcSineOperation();
55                         break;
56                 case NODE_MATH_ACOS:
57                         operation = new MathArcCosineOperation();
58                         break;
59                 case NODE_MATH_ATAN:
60                         operation = new MathArcTangentOperation();
61                         break;
62                 case NODE_MATH_POW:
63                         operation = new MathPowerOperation();
64                         break;
65                 case NODE_MATH_LOG:
66                         operation = new MathLogarithmOperation();
67                         break;
68                 case NODE_MATH_MIN:
69                         operation = new MathMinimumOperation();
70                         break;
71                 case NODE_MATH_MAX:
72                         operation = new MathMaximumOperation();
73                         break;
74                 case NODE_MATH_ROUND:
75                         operation = new MathRoundOperation();
76                         break;
77                 case NODE_MATH_LESS:
78                         operation = new MathLessThanOperation();
79                         break;
80                 case NODE_MATH_GREATER:
81                         operation = new MathGreaterThanOperation();
82                         break;
83                 case NODE_MATH_MOD:
84                         operation = new MathModuloOperation();
85                         break;
86                 case NODE_MATH_ABS:
87                         operation = new MathAbsoluteOperation();
88                         break;
89                 case NODE_MATH_ATAN2:
90                         operation = new MathArcTan2Operation();
91                         break;
92                 case NODE_MATH_FLOOR:
93                         operation = new MathFloorOperation();
94                         break;
95                 case NODE_MATH_CEIL:
96                         operation = new MathCeilOperation();
97                         break;
98                 case NODE_MATH_FRACT:
99                         operation = new MathFractOperation();
100                         break;
101                 case NODE_MATH_SQRT:
102                         operation = new MathSqrtOperation();
103                         break;
104         }
105
106         if (operation) {
107                 bool useClamp = getbNode()->custom2;
108                 operation->setUseClamp(useClamp);
109                 converter.addOperation(operation);
110
111                 converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
112                 converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
113                 converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
114         }
115 }