1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2011, Blender Foundation.
17  */
18 
19 #include "COM_FlipNode.h"
20 
21 #include "COM_ExecutionSystem.h"
22 #include "COM_FlipOperation.h"
23 
FlipNode(bNode * editorNode)24 FlipNode::FlipNode(bNode *editorNode) : Node(editorNode)
25 {
26   /* pass */
27 }
28 
convertToOperations(NodeConverter & converter,const CompositorContext &) const29 void FlipNode::convertToOperations(NodeConverter &converter,
30                                    const CompositorContext & /*context*/) const
31 {
32   NodeInput *inputSocket = this->getInputSocket(0);
33   NodeOutput *outputSocket = this->getOutputSocket(0);
34   FlipOperation *operation = new FlipOperation();
35   switch (this->getbNode()->custom1) {
36     case 0: /* TODO: I didn't find any constants in the old implementation,
37              * should I introduce them. */
38       operation->setFlipX(true);
39       operation->setFlipY(false);
40       break;
41     case 1:
42       operation->setFlipX(false);
43       operation->setFlipY(true);
44       break;
45     case 2:
46       operation->setFlipX(true);
47       operation->setFlipY(true);
48       break;
49   }
50 
51   converter.addOperation(operation);
52   converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
53   converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
54 }
55