Blender  V2.93
COM_SplitViewerNode.cc
Go to the documentation of this file.
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_SplitViewerNode.h"
20 #include "BKE_global.h"
21 #include "BKE_image.h"
22 #include "BKE_scene.h"
23 
24 #include "COM_ExecutionSystem.h"
25 #include "COM_SplitOperation.h"
26 #include "COM_ViewerOperation.h"
27 
28 namespace blender::compositor {
29 
30 SplitViewerNode::SplitViewerNode(bNode *editorNode) : Node(editorNode)
31 {
32  /* pass */
33 }
34 
36  const CompositorContext &context) const
37 {
38  bNode *editorNode = this->getbNode();
39  bool do_output = (editorNode->flag & NODE_DO_OUTPUT_RECALC || context.isRendering()) &&
40  (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(ChunkOrdering::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  }
77 }
78 
79 } // namespace blender::compositor
#define NODE_DO_OUTPUT
#define NODE_DO_OUTPUT_RECALC
Overall context of the compositor.
void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket)
void addPreview(NodeOperationOutput *output)
void addOperation(NodeOperation *operation)
void registerViewer(ViewerOperation *viewer)
void addLink(NodeOperationOutput *from, NodeOperationInput *to)
NodeInput are sockets that can receive data/input.
Definition: COM_Node.h:210
NodeOperationInput * getInputSocket(unsigned int index)
NodeOperationOutput * getOutputSocket(unsigned int index=0)
bNode * getbNode() const
get the reference to the SDNA bNode struct
Definition: COM_Node.h:82
NodeInput * getInputSocket(const unsigned int index) const
Definition: COM_Node.cc:113
void setSplitPercentage(float splitPercentage)
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
void setViewSettings(const ColorManagedViewSettings *viewSettings)
void setChunkOrder(ChunkOrdering tileOrder)
void setRenderData(const RenderData *rd)
void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings)
void setImageUser(ImageUser *imageUser)
void setViewName(const char *viewName)
struct ID * id
void * storage