<commit_before>import bpy
from bpy.props import EnumProperty, PointerProperty
from ..rman_render import RmanRender
from .. import rman_bl_nodes

__HIDDEN_INTEGRATORS__ = ['PxrValidateBxdf', 'PxrDebugShadingContext']

class RendermanViewportProperties(bpy.types.PropertyGroup):

    def update_viewport_integrator(self, context):
        rman_render = RmanRender.get_rman_render()
        if rman_render.rman_interactive_running:
            rman_render.rman_scene.update_viewport_integrator(context, self.viewport_integrator)

    def update_hider_decidither(self, context):
        rman_render = RmanRender.get_rman_render()
        if rman_render.rman_interactive_running:
            rm = context.scene.renderman
            rm.hider_decidither = int(self.viewport_hider_decidither)
            rman_render.rman_scene.update_hider_options(context) 

    def viewport_integrator_items(self, context):
        items = []
        items.append(('Select Integrator', 'Select Integrator', '', '', 0))
        i = 1
        for node in rman_bl_nodes.__RMAN_INTEGRATOR_NODES__:
            if node.name not in __HIDDEN_INTEGRATORS__:
                items.append((node.name, node.name, '', '', i))
                i += 1
        return items

    viewport_integrator: EnumProperty(name="Viewport Integrator",
                                      description="Quickly change integrators during viewport renders. Does not change the scene integrator.",
                                      items=viewport_integrator_items,
                                      update=update_viewport_integrator
                                    )


    viewport_hider_decidither: EnumProperty(name="Interactive Refinement",
                                      description="This value determines how much refinement (in a dither pattern) will be applied to the image during interactive rendering. 0 means full refinement up to a value of 6 which is the least refinement per iteration.",
                                      items=[
                                          ("0", "0", ""),
                                          ("1", "1", ""),
                                          ("2", "2", ""),
                                          ("3", "3", ""),
                                          ("4", "4", ""),
                                          ("5", "5", ""),
                                          ("6", "6", ""),
                                      ],
                                      default="0",
                                      update=update_hider_decidither
                                    )

def draw_rman_viewport_props(self, context):
    layout = self.layout
    scene = context.scene

    if context.engine == "PRMAN_RENDER":
        view = context.space_data
        rman_render = RmanRender.get_rman_render()
        rm_viewport = scene.renderman_viewport
        if view.shading.type == 'RENDERED':
            # integrators menu
            layout.prop(rm_viewport, 'viewport_integrator', text='')
            # decidither
            layout.prop(rm_viewport, 'viewport_hider_decidither', text='')
            
        else:
            # stop rendering if we're not in viewport rendering
            if rman_render.rman_interactive_running:
                rman_render.stop_render()

classes = [
    RendermanViewportProperties
]

def register():

    for cls in classes:
        bpy.utils.register_class(cls)

    bpy.types.VIEW3D_HT_header.append(draw_rman_viewport_props)
    bpy.types.Scene.renderman_viewport = PointerProperty(
        type=RendermanViewportProperties, name="Renderman Viewport Properties"
    )

def unregister():
<commit_msg>Fix issues with viewport integrator menu reported by aek. Switch the menus from scene properties to an Operator. We don't want the selection values to be saved wtih the scene.<commit_after>import bpy
from bpy.props import EnumProperty
from ..rman_render import RmanRender
from .. import rman_bl_nodes

__HIDDEN_INTEGRATORS__ = ['PxrValidateBxdf', 'PxrDebugShadingContext']

class PRMAN_OT_Viewport_Integrators(bpy.types.Operator):
    bl_idname = "renderman_viewport.change_integrator"
    bl_label = "Select Integrator"
    bl_description = "Quickly change integrators during viewport renders. Does not change the scene integrator."
    bl_options = {"REGISTER", "UNDO"}    

    def viewport_integrator_items(self, context):
        items = []
        items.append(('Select Integrator', 'Select Integrator', '', '', 0))
        i = 1
        for node in rman_bl_nodes.__RMAN_INTEGRATOR_NODES__:
            if node.name not in __HIDDEN_INTEGRATORS__:
                items.append((node.name, node.name, '', '', i))
                i += 1
        return items

    viewport_integrator: EnumProperty(name="Viewport Integrator",
                                      description="Viewport integrator",
                                      items=viewport_integrator_items
                                    )    

    def execute(self, context):
        rman_render = RmanRender.get_rman_render()
        if rman_render.rman_interactive_running:
            rman_render.rman_scene.update_viewport_integrator(context, self.viewport_integrator)

        return {"FINISHED"}    

class PRMAN_OT_Viewport_Refinement(bpy.types.Operator):
    bl_idname = "renderman_viewport.change_refinement"
    bl_label = "Refinement"
    bl_description = "This value determines how much refinement (in a dither pattern) will be applied to the image during interactive rendering. 0 means full refinement up to a value of 6 which is the least refinement per iteration."
    bl_options = {"REGISTER", "UNDO"}    

    viewport_hider_decidither: EnumProperty(name="Interactive Refinement",
                                      description="",
                                      items=[
                                          ("0", "0", ""),
                                          ("1", "1", ""),
                                          ("2", "2", ""),
                                          ("3", "3", ""),
                                          ("4", "4", ""),
                                          ("5", "5", ""),
                                          ("6", "6", ""),
                                      ],
                                      default="0"
                                    )

    def execute(self, context):
        rman_render = RmanRender.get_rman_render()
        if rman_render.rman_interactive_running:
            rm = context.scene.renderman
            rm.hider_decidither = int(self.viewport_hider_decidither)
            rman_render.rman_scene.update_hider_options(context) 

        return {"FINISHED"}                                                   

def draw_rman_viewport_props(self, context):
    layout = self.layout
    scene = context.scene

    if context.engine == "PRMAN_RENDER":
        view = context.space_data
        rman_render = RmanRender.get_rman_render()
        if view.shading.type == 'RENDERED':
            # integrators menu
            layout.operator_menu_enum('renderman_viewport.change_integrator', 'viewport_integrator', text='Select Integrator')
            # decidither
            layout.operator_menu_enum('renderman_viewport.change_refinement', 'viewport_hider_decidither', text='Refinement')
            
        else:
            # stop rendering if we're not in viewport rendering
            if rman_render.rman_interactive_running:
                rman_render.stop_render()

classes = [
    PRMAN_OT_Viewport_Integrators,
    PRMAN_OT_Viewport_Refinement
]

def register():

    for cls in classes:
        bpy.utils.register_class(cls)

    bpy.types.VIEW3D_HT_header.append(draw_rman_viewport_props)

def unregister():

{'fraction_non_alphanumeric': 0.08549422336328627, 'fraction_numerical': 0.005391527599486521, 'mean_word_length': 1.8126353790613718, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 48, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3367451', 'n_tokens_mistral': 2099, 'n_tokens_neox': 2035, 'n_words': 442}