Esempio n. 1
0
    def execute(self, context):
        bpy.ops.node.clean_desk()
        NodeCommandHandler.clear_node_groups()
        NodeCommandHandler.get_or_create_node_tree()
        # orange_theme()
        bpy.engine_worker_thread.start()
        # bpy.jupyter_worker_thread.start()

        # self._timer = context.window_manager.event_timer_add(1, context.window)
        # context.window_manager.modal_handler_add(self)
        if self.loc_tutorial_path:
            url = "file://" + self.loc_tutorial_path
            webbrowser.open(url)
            logger.info("Opne tutorial from URL: {}".format(url))
        return {'FINISHED'}
Esempio n. 2
0
 def step_2(self):
     self.step = 2
     nt = NodeCommandHandler.get_or_create_node_tree()
     if nt.nodes.get('ImageViewer'):
         self.col.label(text=TEXT_STEP_2, icon="FILE_TICK")
         return self.step_3()
     else:
         self.col.operator('node.tutorial_mode_command',
                           text=TEXT_STEP_2,
                           icon='NODETREE').loc_command = ' imageviewer!'
Esempio n. 3
0
 def step_4(self):
     self.step = 4
     nt = NodeCommandHandler.get_or_create_node_tree()
     if nt.nodes.get('blur'):
         self.col.label(text=TEXT_STEP_4, icon="FILE_TICK")
         return self.step_5()
     else:
         self.col.operator('node.tutorial_mode_command',
                           text=TEXT_STEP_4,
                           icon='NODETREE').loc_command = ' blur!'
Esempio n. 4
0
 def step_10(self):
     self.step = 10
     nt = NodeCommandHandler.get_or_create_node_tree()
     add_weighted = nt.nodes.get('addWeighted')
     if add_weighted:
         self.col.label(text=TEXT_STEP_10, icon="FILE_TICK")
         return self.step_11()
     else:
         self.col.operator('node.tutorial_mode_command',
                           text=TEXT_STEP_10,
                           icon='NODETREE').loc_command = ' addweighted!'
Esempio n. 5
0
    def step_7(self):
        self.step = 7
        nt = NodeCommandHandler.get_or_create_node_tree()

        if nt.nodes.get('ImageSample.001'):
            self.col.label(text=TEXT_STEP_7, icon="FILE_TICK")
            return self.step_8()
        else:
            self.col.operator('node.tutorial_mode_command',
                              text=TEXT_STEP_7,
                              icon='NODETREE').loc_command = ' imagesample!'
Esempio n. 6
0
 def step_11(self):
     self.step = 11
     nt = NodeCommandHandler.get_or_create_node_tree()
     add_weighted = nt.nodes.get('addWeighted')
     if add_weighted and add_weighted.inputs["image_1_in"].is_linked:
         self.col.label(text=TEXT_STEP_11, icon="FILE_TICK")
         return self.step_12()
     else:
         self.col.operator('node.tutorial_mode_command',
                           text=TEXT_STEP_11,
                           icon='NODETREE'
                           ).loc_command = 'connect_addweighted_first_input'
Esempio n. 7
0
 def step_9(self):
     self.step = 9
     nt = NodeCommandHandler.get_or_create_node_tree()
     image_sample = nt.nodes.get('ImageSample.001')
     if image_sample and image_sample.loc_image_mode == "FILE" and image_sample.loc_filepath != "":
         self.col.label(text=TEXT_STEP_9, icon="FILE_TICK")
         return self.step_10()
     else:
         self.col.operator(
             'node.tutorial_mode_command',
             text=TEXT_STEP_9,
             icon='NODETREE').loc_command = 'select_file_for_sample'
Esempio n. 8
0
    def step_6(self):
        self.step = 6
        nt = NodeCommandHandler.get_or_create_node_tree()
        blur = nt.nodes.get('blur')

        if blur.ksize_in[0] == 10 and blur.ksize_in[1] == 10:
            self.col.label(text=TEXT_STEP_6, icon="FILE_TICK")
            return self.step_7()
        else:
            self.col.operator(
                'node.tutorial_mode_command',
                text=TEXT_STEP_6,
                icon='NODETREE').loc_command = 'set_ksize_on_blur'
Esempio n. 9
0
 def step_3(self):
     self.step = 3
     nt = NodeCommandHandler.get_or_create_node_tree()
     img_sample = nt.nodes.get('ImageSample')
     img_viewer = nt.nodes.get('ImageViewer')
     if img_sample.outputs['image_out'].is_linked and img_viewer.inputs[
             'image_in'].is_linked:
         self.col.label(text=TEXT_STEP_3, icon="FILE_TICK")
         return self.step_4()
     else:
         self.col.operator(
             'node.tutorial_mode_command',
             text=TEXT_STEP_3,
             icon='NODETREE').loc_command = 'connect_sample_and_view'
Esempio n. 10
0
    def execute(self, context):
        for area in bpy.context.screen.areas:
            if area.type == 'NODE_EDITOR':
                NodeCommandHandler.clear_node_groups()
                NodeCommandHandler.get_or_create_node_tree()
                NodeCommandHandler.create_node("OCVLAuthNode",
                                               location=(520, 560))
                NodeCommandHandler.create_node("OCVLSettingsNode",
                                               location=(-300, 240))
                NodeCommandHandler.create_node("OCVLDocsNode",
                                               location=(-300, 100))
                NodeCommandHandler.create_node("OCVLSplashNode",
                                               location=(-60, 460))

                NodeCommandHandler.connect_nodes("Splash", "settings",
                                                 "Settings", "settings")
                NodeCommandHandler.connect_nodes("Splash", "docs", "Docs",
                                                 "docs")
                NodeCommandHandler.connect_nodes("Auth", "auth", "Splash",
                                                 "auth")
                NodeCommandHandler.view_all()
                return {'FINISHED'}
        return {'CANCELLED'}
Esempio n. 11
0
 def execute(self, context):
     for area in bpy.context.screen.areas:
         if area.type == 'NODE_EDITOR':
             NodeCommandHandler.clear_node_groups()
             NodeCommandHandler.get_or_create_node_tree()
             NodeCommandHandler.create_node("OCVLFirstStepsNode",
                                            location=(0, 0))
             NodeCommandHandler.create_node("OCVLTipNode",
                                            location=(400, 0))
             NodeCommandHandler.connect_nodes("Tip", "tip", "FirstSteps",
                                              "tip")
             NodeCommandHandler.view_all()
             bpy.ops.wm.modal_timer_refresh_first_steps_tip_operator()
             return {'FINISHED'}
     return {'CANCELLED'}
Esempio n. 12
0
    def execute(self, context):

        if self.loc_command == "connect_sample_and_view":
            nt = NodeCommandHandler.get_or_create_node_tree()
            NodeCommandHandler.connect_nodes(node_input="ImageViewer",
                                             node_output="ImageSample",
                                             input_name="image_in",
                                             output_name="image_out")
            return {'FINISHED'}

        elif self.loc_command == "connect_sample_and_view_and_blur":
            nt = NodeCommandHandler.get_or_create_node_tree()
            NodeCommandHandler.connect_nodes(node_input="ImageViewer",
                                             node_output="blur",
                                             input_name="image_in",
                                             output_name="image_out")
            NodeCommandHandler.connect_nodes(node_input="blur",
                                             node_output="ImageSample",
                                             input_name="image_in",
                                             output_name="image_out")
            return {'FINISHED'}

        elif self.loc_command == "set_ksize_on_blur":
            nt = NodeCommandHandler.get_or_create_node_tree()
            blur = nt.nodes.get('blur')
            blur.ksize_in = (10, 10)
            return {'FINISHED'}

        elif self.loc_command == "file_mode_for_image_sample":
            nt = NodeCommandHandler.get_or_create_node_tree()
            blur = nt.nodes.get('ImageSample.001')
            blur.loc_image_mode = "FILE"
            return {'FINISHED'}

        elif self.loc_command == "select_file_for_sample":
            nt = NodeCommandHandler.get_or_create_node_tree()
            blur = nt.nodes.get('ImageSample.001')
            full_tutorial_path = os.path.abspath(
                os.path.join(TUTORIAL_PATH, "first_steps/ml.png"))
            blur.loc_filepath = full_tutorial_path
            return {'FINISHED'}

        elif self.loc_command == "connect_addweighted_first_input":
            nt = NodeCommandHandler.get_or_create_node_tree()
            NodeCommandHandler.connect_nodes(node_input="addWeighted",
                                             node_output="ImageSample.001",
                                             input_name="image_1_in",
                                             output_name="image_out")
            return {'FINISHED'}

        elif self.loc_command == "connect_addweighted_second_input":
            nt = NodeCommandHandler.get_or_create_node_tree()
            NodeCommandHandler.connect_nodes(node_input="addWeighted",
                                             node_output="blur",
                                             input_name="image_2_in",
                                             output_name="image_out")
            return {'FINISHED'}

        elif self.loc_command == "connect_addweighted_output":
            nt = NodeCommandHandler.get_or_create_node_tree()
            NodeCommandHandler.connect_nodes(node_input="ImageViewer",
                                             node_output="addWeighted",
                                             input_name="image_in",
                                             output_name="image_out")
            return {'FINISHED'}

        elif self.loc_command:
            keyborad_worker_thread = print_keyborad_worker(
                text=self.loc_command)
            keyborad_worker_thread.start()

        return {'FINISHED'}