Multi-View and Stereo 3D
[blender-staging.git] / source / blender / editors / render / render_shading.c
index cf712a653e6910d22071c58e87cc9a84549a394a..3de2153614812bae2770987ed98188629f502f1a 100644 (file)
@@ -605,6 +605,70 @@ void SCENE_OT_render_layer_remove(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
 }
 
+/********************** render view operators *********************/
+
+static int render_view_remove_poll(bContext *C)
+{
+       Scene *scene = CTX_data_scene(C);
+
+       /* don't allow user to remove "left" and "right" views */
+       return scene->r.actview > 1;
+}
+
+static int render_view_add_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       Scene *scene = CTX_data_scene(C);
+
+       BKE_scene_add_render_view(scene, NULL);
+       scene->r.actview = BLI_listbase_count(&scene->r.views) - 1;
+
+       WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
+
+       return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_render_view_add(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "Add Render View";
+       ot->idname = "SCENE_OT_render_view_add";
+       ot->description = "Add a render view";
+
+       /* api callbacks */
+       ot->exec = render_view_add_exec;
+
+       /* flags */
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+static int render_view_remove_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       Scene *scene = CTX_data_scene(C);
+       SceneRenderView *rv = BLI_findlink(&scene->r.views, scene->r.actview);
+
+       if (!BKE_scene_remove_render_view(scene, rv))
+               return OPERATOR_CANCELLED;
+
+       WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
+
+       return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_render_view_remove(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "Remove Render View";
+       ot->idname = "SCENE_OT_render_view_remove";
+       ot->description = "Remove the selected render view";
+
+       /* api callbacks */
+       ot->exec = render_view_remove_exec;
+       ot->poll = render_view_remove_poll;
+
+       /* flags */
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
 #ifdef WITH_FREESTYLE
 
 static bool freestyle_linestyle_check_report(FreestyleLineSet *lineset, ReportList *reports)