Skip to content
Snippets Groups Projects
ui.py 82.7 KiB
Newer Older
  • Learn to ignore specific revisions
  • 
        def draw_header(self, context):
            cam = context.camera
    
    
            self.layout.prop(cam.pov, "dof_enable", text="")
    
        def draw(self, context):
            layout = self.layout
    
            cam = context.camera
    
    
            split = layout.split()
    
            col = split.column()
    
            col.prop(cam.pov, "dof_samples_min")
            col.prop(cam.pov, "dof_variance")
    
            col = split.column()
    
            col.prop(cam.pov, "dof_samples_max")
            col.prop(cam.pov, "dof_confidence")
    
    class CAMERA_PT_povray_cam_nor(CameraDataButtonsPanel, bpy.types.Panel):
        bl_label = "POV-Ray Perturbation"
        COMPAT_ENGINES = {'POVRAY_RENDER'}
    
        def draw_header(self, context):
            cam = context.camera
    
            self.layout.prop(cam.pov, "normal_enable", text="")
    
        def draw(self, context):
            layout = self.layout
    
            cam = context.camera
    
            layout.active = cam.pov.normal_enable
    
            layout.prop(cam.pov,"normal_patterns")
            layout.prop(cam.pov,"cam_normal")
            layout.prop(cam.pov,"turbulence")
            layout.prop(cam.pov,"scale")
    
    
    
    class CAMERA_PT_povray_replacement_text(CameraDataButtonsPanel, bpy.types.Panel):
        bl_label = "Custom POV Code"
    
    Thomas Dinges's avatar
    Thomas Dinges committed
            col = layout.column()
    
            col.prop(cam.pov, "replacement_text", text="")
    
    ###############################################################################
    # Text Povray Settings
    ###############################################################################
    
    class TEXT_OT_povray_insert(bpy.types.Operator):
        """Tooltip"""
        bl_idname = "text.povray_insert"
        bl_label = "Insert"
    
        filepath = bpy.props.StringProperty(name="Filepath", subtype='FILE_PATH')
    
        @classmethod
        def poll(cls, context):
            # context.area.type == 'TEXT_EDITOR'
            return bpy.ops.text.insert.poll()
    
        def execute(self, context):
            if self.filepath and isfile(self.filepath):
                file = open(self.filepath, "r")
                bpy.ops.text.insert(text=file.read())
    
                # places the cursor at the end without scrolling -.-
                # context.space_data.text.write(file.read())
                file.close()
            return {'FINISHED'}
    
    def validinsert(ext):
    
    	return ext in {".txt",".inc",".pov"}
    
    
    class TEXT_MT_insert(bpy.types.Menu):
        bl_label = "Insert"
        bl_idname = "TEXT_MT_insert"
    
        def draw(self, context):
            pov_documents = locate_docpath()
            prop = self.layout.operator("wm.path_open", text="Open folder", icon='FILE_FOLDER')
            prop.filepath = pov_documents
            self.layout.separator()
    
            list=[]
            for root,dirs,files in os.walk(pov_documents):
                list.append(root)
            print(list)
            self.path_menu(list,
                           "text.povray_insert",
                           #{"internal": True},
    					   filter_ext= validinsert
                           )
    
    
    class TEXT_PT_povray_custom_code(TextButtonsPanel, bpy.types.Panel):
    
        bl_label = "POV-Ray"
    
    Thomas Dinges's avatar
    Thomas Dinges committed
            text = context.space_data.text
    
            if not pov_documents :
    
                layout.label(text="Please configure ", icon="INFO")
                layout.label(text="default pov include path ")
                layout.label(text="in addon preferences")
                #layout.separator()
                layout.operator("wm.addon_userpref_show",
                             text="Go to Render: POV-Ray addon",
                             icon="PREFERENCES").module = "render_povray"
    
                #layout.separator()
            else:
                #print(pov_documents)
                layout.menu(TEXT_MT_insert.bl_idname)
    
            if text:
                box = layout.box()
                box.label('Source to render:', icon='RENDER_STILL')
                row = box.row()
                row.prop(text.pov, "custom_code",expand = True)
                if text.pov.custom_code in {'3dview'}:
                    box.operator("render.render", icon='OUTLINER_DATA_POSE')  
                if text.pov.custom_code in {'text'}:
                    rtext = bpy.context.space_data.text
                    box.operator("text.run", icon='POSE_DATA')
                #layout.prop(text.pov, "custom_code")
                elif text.pov.custom_code in {'both'}:
                    box.operator("render.render", icon='POSE_HLT')
                    layout.label(text="Please specify declared", icon="INFO")
                    layout.label(text="items in properties ")
                    #layout.label(text="")                
                    layout.label(text="replacement fields")
    
    
    
    ###############################################
    # Text editor templates from header menu
    
    
    class TEXT_MT_templates_pov(bpy.types.Menu):
        bl_label = "POV-Ray"
    
        # We list templates on file evaluation, we can assume they are static data,
        # and better avoid running this on every draw call.
        import os
        template_paths = [os.path.join(os.path.dirname(__file__), "templates_pov")]
    
        def draw(self, context):
            self.path_menu(
                self.template_paths,
                "text.open",
                props_default={"internal": True},
            )
    
    def menu_func_templates(self, context):
        # Do not depend on POV-Ray being active renderer here...
        self.layout.menu("TEXT_MT_templates_pov")