Cleanup: comment line length (editors)
[blender.git] / source / blender / compositor / nodes / COM_SplitViewerNode.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_SplitViewerNode.h"
24 #include "BKE_global.h"
25 #include "BKE_image.h"
26 #include "BKE_scene.h"
27
28 #include "COM_SplitOperation.h"
29 #include "COM_ViewerOperation.h"
30 #include "COM_ExecutionSystem.h"
31
32 SplitViewerNode::SplitViewerNode(bNode *editorNode) : Node(editorNode)
33 {
34         /* pass */
35 }
36
37 void SplitViewerNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
38 {
39         bNode *editorNode = this->getbNode();
40         bool do_output = (editorNode->flag & NODE_DO_OUTPUT_RECALC || context.isRendering()) && (editorNode->flag & NODE_DO_OUTPUT);
41
42         NodeInput *image1Socket = this->getInputSocket(0);
43         NodeInput *image2Socket = this->getInputSocket(1);
44         Image *image = (Image *)this->getbNode()->id;
45         ImageUser *imageUser = (ImageUser *) this->getbNode()->storage;
46
47         SplitOperation *splitViewerOperation = new SplitOperation();
48         splitViewerOperation->setSplitPercentage(this->getbNode()->custom1);
49         splitViewerOperation->setXSplit(!this->getbNode()->custom2);
50
51         converter.addOperation(splitViewerOperation);
52         converter.mapInputSocket(image1Socket, splitViewerOperation->getInputSocket(0));
53         converter.mapInputSocket(image2Socket, splitViewerOperation->getInputSocket(1));
54
55         ViewerOperation *viewerOperation = new ViewerOperation();
56         viewerOperation->setImage(image);
57         viewerOperation->setImageUser(imageUser);
58         viewerOperation->setViewSettings(context.getViewSettings());
59         viewerOperation->setDisplaySettings(context.getDisplaySettings());
60         viewerOperation->setRenderData(context.getRenderData());
61         viewerOperation->setViewName(context.getViewName());
62
63         /* defaults - the viewer node has these options but not exposed for split view
64          * we could use the split to define an area of interest on one axis at least */
65         viewerOperation->setChunkOrder(COM_ORDER_OF_CHUNKS_DEFAULT);
66         viewerOperation->setCenterX(0.5f);
67         viewerOperation->setCenterY(0.5f);
68
69         converter.addOperation(viewerOperation);
70         converter.addLink(splitViewerOperation->getOutputSocket(), viewerOperation->getInputSocket(0));
71
72         converter.addPreview(splitViewerOperation->getOutputSocket());
73
74         if (do_output)
75                 converter.registerViewer(viewerOperation);
76 }