Merged changes in the trunk up to revision 47700.
[blender.git] / source / blender / compositor / nodes / COM_CompositorNode.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_CompositorNode.h"
24 #include "COM_CompositorOperation.h"
25 #include "COM_ExecutionSystem.h"
26
27 CompositorNode::CompositorNode(bNode *editorNode): Node(editorNode)
28 {
29 }
30
31 void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
32 {
33         InputSocket *imageSocket = this->getInputSocket(0);
34         InputSocket *alphaSocket = this->getInputSocket(1);
35         if (imageSocket->isConnected()) {
36                 CompositorOperation *colourAlphaProg = new CompositorOperation();
37                 colourAlphaProg->setScene(context->getScene());
38                 colourAlphaProg->setbNodeTree(context->getbNodeTree());
39                 imageSocket->relinkConnections(colourAlphaProg->getInputSocket(0));
40                 alphaSocket->relinkConnections(colourAlphaProg->getInputSocket(1));
41                 graph->addOperation(colourAlphaProg);
42                 addPreviewOperation(graph, colourAlphaProg->getInputSocket(0));
43         }
44 }