Advertisement
Guest User

Untitled

a guest
Nov 26th, 2018
962
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 33.71 KB | None | 0 0
  1. import bpy
  2. from bpy.types import Menu
  3. from .. utils.registration import get_prefs
  4. from .. utils.ui import get_icon
  5.  
  6. # TODO: snapping pie
  7. # TODO: orientation/pivot pie, merge it all into the cursor/origin pie?
  8.  
  9.  
  10. class PieModes(Menu):
  11.     bl_idname = "MACHIN3_MT_modes_pie"
  12.     bl_label = "Modes"
  13.  
  14.     def draw(self, context):
  15.         layout = self.layout
  16.         toolsettings = context.tool_settings
  17.  
  18.         active = context.active_object
  19.  
  20.  
  21.         if active:
  22.  
  23.             if active.type == 'MESH':
  24.  
  25.                 if context.area.type == "VIEW_3D":
  26.  
  27.                     pie = layout.menu_pie()
  28.  
  29.                     # 4 - LEFT
  30.                     pie.operator("machin3.vertex_mode", text="Vertex", icon_value=get_icon('vertex'))
  31.  
  32.                     # 6 - RIGHT
  33.                     pie.separator()
  34.  
  35.                     # 2 - BOTTOM
  36.                     pie.operator("machin3.face_mode", text="Face", icon_value=get_icon('face'))
  37.  
  38.                     # 8 - TOP
  39.                     pie.operator("machin3.edge_mode", text="Edge", icon_value=get_icon('edge'))
  40.  
  41.                     # 7 - TOP - LEFT
  42.                     if bpy.context.object.mode == "EDIT":
  43.                         box = pie.split()
  44.                         column = box.column()
  45.                         column.prop(toolsettings, "use_mesh_automerge", text="Auto Merge")
  46.  
  47.                     else:
  48.                         pie.separator()
  49.  
  50.  
  51.                     # 9 - TOP - RIGHT
  52.                    
  53.                     text, icon = ("Edit", get_icon('edit_mesh')) if active.mode == "OBJECT" else ("Object", get_icon('object'))
  54.                     pie.operator("machin3.edit_mode", text=text, icon_value=icon)
  55.  
  56.                     # 1 - BOTTOM - LEFT
  57.                     pie.separator()
  58.  
  59.                     # 3 - BOTTOM - RIGHT
  60.                    
  61.                     if bpy.context.object.mode == "EDIT":
  62.                         pie.prop(context.scene.M3, "pass_through", text="Pass Through" if context.scene.M3.pass_through else "Occlude", icon="XRAY")
  63.                     else:
  64.                         pie.separator()
  65.  
  66.  
  67.                 if context.area.type == "IMAGE_EDITOR":
  68.                     pie = layout.menu_pie()
  69.  
  70.                     toolsettings = context.scene.tool_settings
  71.  
  72.                     if active.mode == "OBJECT":
  73.  
  74.                         # 4 - LEFT
  75.                         pie.operator("machin3.image_mode", text="UV Edit", icon="GROUP_UVS").mode = "UV"
  76.  
  77.                         # 6 - RIGHT
  78.                         pie.operator("machin3.image_mode", text="Paint", icon="TPAINT_HLT").mode = "PAINT"
  79.  
  80.                         # 2 - BOTTOM)
  81.                         pie.operator("machin3.image_mode", text="Mask", icon="MOD_MASK").mode = "MASK"
  82.  
  83.                         # 8 - TOP
  84.                         pie.operator("machin3.image_mode", text="View", icon="FILE_IMAGE").mode = "VIEW"
  85.  
  86.  
  87.                     elif active.mode == "EDIT":
  88.                         # 4 - LEFT
  89.                         pie.operator("machin3.uv_mode", text="Vertex", icon_value=get_icon('vertex')).mode = "VERTEX"
  90.  
  91.                         # 6 - RIGHT
  92.                         pie.operator("machin3.uv_mode", text="Face", icon_value=get_icon('face')).mode = "FACE"
  93.  
  94.                         # 2 - BOTTOM
  95.                         pie.operator("machin3.uv_mode", text="Edge", icon_value=get_icon('edge')).mode = "EDGE"
  96.  
  97.                         # 8 - TOP
  98.                         pie.operator("object.mode_set", text="Object", icon_value=get_icon('object')).mode = "OBJECT"
  99.  
  100.                         # 7 - TOP - LEFT
  101.                         pie.prop(context.scene.M3, "uv_sync_select", text="Sync Selection", icon="UV_SYNC_SELECT")
  102.  
  103.                         # 9 - TOP - RIGHT
  104.                         if toolsettings.use_uv_select_sync:
  105.                             pie.separator()
  106.                         else:
  107.                             pie.operator("machin3.uv_mode", text="Island", icon_value=get_icon('island')).mode = "ISLAND"
  108.  
  109.                         # 1 - BOTTOM - LEFT
  110.                         pie.separator()
  111.  
  112.                         # 3 - BOTTOM - RIGHT
  113.                         pie.separator()
  114.  
  115.  
  116.  
  117.             elif active.type == 'CURVE':
  118.                 pie = layout.menu_pie()
  119.  
  120.                 # 4 - LEFT
  121.                 pie.operator("object.mode_set", text="Edit Mode", icon='EDITMODE_HLT').mode = "EDIT"
  122.  
  123.                 # & - RIGHT
  124.                 pie.separator()
  125.  
  126.                 # 1 - BOTTOM
  127.                 pie.separator()
  128.  
  129.                 # 9 - TOP
  130.                 text, icon = ("Edit", "EDITMODE_HLT") if active.mode == "OBJECT" else ("Object", "OBJECT_DATAMODE")
  131.                 pie.operator("object.editmode_toggle", text=text, icon=icon)
  132.  
  133.  
  134.             elif active.type == 'ARMATURE':
  135.                 pie = layout.menu_pie()
  136.  
  137.                 # 4 - LEFT
  138.                 pie.operator("object.mode_set", text="Edit Mode", icon='EDITMODE_HLT').mode = "EDIT"
  139.  
  140.                 # 6 - RIGHT
  141.                 pie.operator("object.mode_set", text="Pose", icon='POSE_HLT').mode = "POSE"
  142.  
  143.                 # 2 - BOTTOM
  144.                 pie.separator()
  145.  
  146.                 # 8 - TOP
  147.                 text, icon = ("Edit", "EDITMODE_HLT") if active.mode == "OBJECT" else ("Object", "OBJECT_DATAMODE")
  148.                 if active.mode == "POSE":
  149.                     pie.operator("object.posemode_toggle", text=text, icon=icon)
  150.                 else:
  151.                     pie.operator("object.editmode_toggle", text=text, icon=icon)
  152.  
  153.  
  154.             """
  155.  
  156.            elif ob.object.type == 'FONT':
  157.                pie = layout.menu_pie()
  158.                pie.operator("object.editmode_toggle", text="Edit/Object", icon='OBJECT_DATAMODE')
  159.  
  160.            elif ob.object.type == 'SURFACE':
  161.                pie = layout.menu_pie()
  162.                pie.operator("object.editmode_toggle", text="Edit/Object", icon='OBJECT_DATAMODE')
  163.  
  164.            elif ob.object.type == 'META':
  165.                pie = layout.menu_pie()
  166.                pie.operator("object.editmode_toggle", text="Edit/Object", icon='OBJECT_DATAMODE')
  167.  
  168.            elif ob.object.type == 'LATTICE':
  169.                pie = layout.menu_pie()
  170.                pie.operator("object.editmode_toggle", text="Edit/Object", icon='OBJECT_DATAMODE')
  171.  
  172.            else:
  173.                pass
  174.  
  175.            """
  176.  
  177.  
  178. class PieSave(Menu):
  179.     bl_idname = "MACHIN3_MT_save_pie"
  180.     bl_label = "Save, Open, Append"
  181.  
  182.     def draw(self, context):
  183.         layout = self.layout
  184.         pie = layout.menu_pie()
  185.  
  186.         # 4 - LEFT
  187.         pie.operator("wm.open_mainfile", text="Open...", icon_value=get_icon('open'))
  188.  
  189.         # 6 - RIGHT
  190.         pie.operator("machin3.save", text="Save", icon_value=get_icon('save'))
  191.  
  192.         # 2 - BOTTOM
  193.         pie.operator("wm.save_as_mainfile", text="Save As..", icon_value=get_icon('save_as'))
  194.  
  195.         # 8 - TOP
  196.         box = pie.split()
  197.         # box = pie.box().split()
  198.  
  199.         b = box.box()
  200.         column = b.column()
  201.         self.draw_left_column(column)
  202.  
  203.         column = box.column()
  204.         b = column.box()
  205.         self.draw_center_column_top(b)
  206.  
  207.         if bpy.data.filepath:
  208.             b = column.box()
  209.             self.draw_center_column_bottom(b)
  210.  
  211.         b = box.box()
  212.         column = b.column()
  213.         self.draw_right_column(column)
  214.  
  215.         # 7 - TOP - LEFT
  216.         pie.separator()
  217.  
  218.         # 9 - TOP - RIGHT
  219.         pie.separator()
  220.  
  221.         # 1 - BOTTOM - LEFT
  222.         pie.operator("machin3.new", text="New", icon_value=get_icon('new'))
  223.  
  224.         # 3 - BOTTOM - RIGHT
  225.         pie.operator("machin3.save_incremental", text="Incremental Save", icon_value=get_icon('save_incremental'))
  226.  
  227.     def draw_left_column(self, col):
  228.         col.scale_x = 1.1
  229.  
  230.         row = col.row()
  231.         row.scale_y = 1.5
  232.         row.operator("machin3.load_most_recent", text="(R) Most Recent", icon_value=get_icon('open_recent'))
  233.         # row.operator("wm.call_menu", text="All Recent", icon_value=get_icon('open_recent')).name = "INFO_MT_file_open_recent"
  234.         row.operator("wm.call_menu", text="All Recent", icon_value=get_icon('open_recent')).name = "TOPBAR_MT_file_open_recent"
  235.  
  236.         col.separator()
  237.         col.operator("wm.recover_auto_save", text="Recover Auto Save...", icon_value=get_icon('recover_auto_save'))
  238.         # col.operator("wm.recover_last_session", text="Recover Last Session", icon='RECOVER_LAST')
  239.         col.operator("wm.revert_mainfile", text="Revert", icon_value=get_icon('revert'))
  240.  
  241.     def draw_center_column_top(self, col):
  242.         row = col.split(factor=0.25)
  243.         row.label(text="OBJ")
  244.         r = row.row(align=True)
  245.         r.operator("import_scene.obj", text="Import", icon_value=get_icon('import'))
  246.         r.operator("export_scene.obj", text="Export", icon_value=get_icon('export'))
  247.  
  248.         row = col.split(factor=0.25)
  249.         row.label(text="FBX")
  250.         r = row.row(align=True)
  251.         r.operator("import_scene.fbx", text="Import", icon_value=get_icon('import'))
  252.         r.operator("export_scene.fbx", text="Export", icon_value=get_icon('export'))
  253.  
  254.     def draw_center_column_bottom(self, col):
  255.         row = col.split(factor=0.5)
  256.         row.scale_y = 1.25
  257.         row.operator("machin3.load_previous", text="Previous", icon_value=get_icon('open_previous'))
  258.         row.operator("machin3.load_next", text="Next", icon_value=get_icon('open_next'))
  259.  
  260.     def draw_right_column(self, col):
  261.         row = col.row()
  262.         r = row.row(align=True)
  263.         r.operator("wm.append", text="Append", icon_value=get_icon('append'))
  264.         r.operator("wm.link", text="Link", icon_value=get_icon('link'))
  265.         row.operator("wm.call_menu", text="", icon_value=get_icon('external_data')).name = "TOPBAR_MT_file_external_data"
  266.  
  267.         # append world and materials
  268.  
  269.         appendworldpath = get_prefs().appendworldpath
  270.         appendmatspath = get_prefs().appendmatspath
  271.  
  272.         if any([appendworldpath, appendmatspath]):
  273.             col.separator()
  274.  
  275.             if appendworldpath:
  276.                 row = col.split(factor=0.8)
  277.                 row.scale_y = 1.5
  278.                 row.operator("machin3.append_world", text="World", icon_value=get_icon('world'))
  279.                 row.operator("machin3.load_world_source", text="", icon_value=get_icon('open_world'))
  280.  
  281.             if appendmatspath:
  282.                 row = col.split(factor=0.8)
  283.                 row.scale_y = 1.5
  284.                 row.operator("wm.call_menu", text="Material", icon_value=get_icon('material')).name = "MACHIN3_MT_append_materials"
  285.                 row.operator("machin3.load_materials_source", text="", icon_value=get_icon('open_material'))
  286.  
  287.  
  288. class PieShading(Menu):
  289.     bl_idname = "MACHIN3_MT_shading_pie"
  290.     bl_label = "Shading and Overlays"
  291.  
  292.     def draw(self, context):
  293.         layout = self.layout
  294.  
  295.         view = context.space_data
  296.  
  297.         pie = layout.menu_pie()
  298.  
  299.         # 4 - LEFT
  300.         text, icon = self.get_text_icon(context, "SOLID")
  301.         pie.operator("machin3.shade_solid", text=text, icon=icon)
  302.  
  303.         # 6 - RIGHT
  304.         text, icon = self.get_text_icon(context, "MATERIAL")
  305.         pie.operator("machin3.shade_material", text=text, icon=icon)
  306.  
  307.         # 2 - BOTTOM
  308.         pie.separator()
  309.  
  310.         # 8 - TOP
  311.         box = pie.split()
  312.  
  313.         b = box.box()
  314.         column = b.column()
  315.         self.draw_left_column(context, view, column)
  316.  
  317.         b = box.box()
  318.         column = b.column()
  319.         self.draw_center_column(context, view, column)
  320.  
  321.         b = box.box()
  322.         column = b.column()
  323.         self.draw_right_column(context, view, column)
  324.  
  325.         if view.shading.type == "MATERIAL":
  326.             b = box.box()
  327.             column = b.column()
  328.             self.draw_eevee(context, view, column)
  329.  
  330.         # 7 - TOP - LEFT
  331.         pie.separator()
  332.  
  333.         # 9 - TOP - RIGHT
  334.         pie.separator()
  335.  
  336.         # 1 - BOTTOM - LEFT
  337.         text, icon = self.get_text_icon(context, "WIREFRAME")
  338.         pie.operator("machin3.shade_wire", text=text, icon=icon)
  339.  
  340.         # 3 - BOTTOM - RIGHT
  341.         text, icon = self.get_text_icon(context, "RENDERED")
  342.         pie.operator("machin3.shade_rendered", text=text, icon=icon)
  343.  
  344.     def draw_left_column(self, context, view, col):
  345.         row = col.split(factor=0.45)
  346.         row.operator("machin3.toggle_grid", text="Grid Toggle", icon="GRID")
  347.         r = row.split().row(align=True)
  348.         r.active = view.overlay.show_floor
  349.         r.prop(view.overlay, "show_axis_x", text="X", toggle=True)
  350.         r.prop(view.overlay, "show_axis_y", text="Y", toggle=True)
  351.         r.prop(view.overlay, "show_axis_z", text="Z", toggle=True)
  352.  
  353.         # col.separator()
  354.         row = col.split(factor=0.45)
  355.  
  356.         icon = get_icon('wireframe_overlay') if view.overlay.show_wireframes else get_icon('wireframe')
  357.         row.operator("machin3.toggle_wireframe", text="Wire Toggle", icon_value=icon)
  358.  
  359.         r = row.split().row()
  360.         if context.mode == "OBJECT":
  361.             r.active = view.overlay.show_wireframes
  362.             r.prop(view.overlay, "wireframe_threshold", text="Wireframe")
  363.         elif context.mode == "EDIT_MESH":
  364.             r.active = view.shading.show_xray
  365.             r.prop(view.shading, "xray_alpha", text="X-Ray")
  366.  
  367.         row = col.split(factor=0.45)
  368.         row.operator("machin3.toggle_outline", text="(Q) Outline Toggle")
  369.         row.prop(view.shading, "object_outline_color", text="")
  370.  
  371.         row = col.split(factor=0.45)
  372.         row.operator("machin3.toggle_cavity", text="Cavity Toggle")
  373.         r = row.row(align=True)
  374.         # r.prop(view.shading, "cavity_ridge_factor", text="")
  375.         r.prop(view.shading, "cavity_valley_factor", text="")
  376.         r.prop(context.scene.display, "matcap_ssao_distance", text="")
  377.  
  378.  
  379.         active = context.active_object
  380.         if active:
  381.             if active.type == "MESH":
  382.                 mesh = active.data
  383.  
  384.                 col.separator()
  385.                 row = col.split(factor=0.55)
  386.                 r = row.split().row(align=True)
  387.                 r.operator("machin3.shade_smooth", text="Smooth", icon_value=get_icon('smooth'))
  388.                 r.operator("machin3.shade_flat", text="Flat", icon_value=get_icon('flat'))
  389.  
  390.                 icon = "CHECKBOX_HLT" if mesh.use_auto_smooth else "CHECKBOX_DEHLT"
  391.                 row.operator("machin3.toggle_auto_smooth", text="AutoSmooth", icon=icon)
  392.  
  393.                 if mesh.use_auto_smooth:
  394.                     if mesh.has_custom_normals:
  395.                         col.operator("mesh.customdata_custom_splitnormals_clear", text="Clear Custom Normals")
  396.                     else:
  397.                         col.prop(mesh, "auto_smooth_angle")
  398.  
  399.                 if context.mode == "EDIT_MESH":
  400.                     row = col.row(align=True)
  401.                     row.prop(view.overlay, "show_vertex_normals", text="", icon='NORMALS_VERTEX')
  402.                     row.prop(view.overlay, "show_split_normals", text="", icon='NORMALS_VERTEX_FACE')
  403.                     row.prop(view.overlay, "show_face_normals", text="", icon='NORMALS_FACE')
  404.  
  405.                     r = row.row(align=True)
  406.                     r.active = view.overlay.show_vertex_normals or view.overlay.show_face_normals or view.overlay.show_split_normals
  407.                     r.prop(view.overlay, "normals_length", text="Size")
  408.  
  409.  
  410.         if context.mode == "EDIT_MESH":
  411.             col.separator()
  412.             # row = col.row()
  413.             # row.prop(mesh, "show_edges", text="Edges")
  414.             # row.prop(mesh, "show_faces", text="Faces")
  415.  
  416.             row = col.row(align=True)
  417.             row.prop(view.overlay, "show_edge_crease", text="Creases", toggle=True)
  418.             row.prop(view.overlay, "show_edge_sharp", text="Sharp", toggle=True)
  419.             row.prop(view.overlay, "show_edge_bevel_weight", text="Bevel", toggle=True)
  420.  
  421.             if not bpy.app.build_options.freestyle:
  422.                 row.prop(view.overlay, "show_edge_seams", text="Seams", toggle=True)
  423.  
  424.     def draw_center_column(self, context, view, col):
  425.         row = col.split(factor=0.42)
  426.         row.prop(view.overlay, "show_cursor", text="3D Cursor")
  427.         r = row.split().row(align=True)
  428.         r.prop(view.overlay, "show_object_origins", text="Origins")
  429.         r.prop(view.overlay, "show_object_origins_all", text="All")
  430.  
  431.         col.separator()
  432.         row = col.row()
  433.         row.prop(view.overlay, "show_backface_culling")
  434.         row.prop(view.overlay, "show_face_orientation")
  435.         col.prop(view.overlay, "show_relationship_lines")
  436.  
  437.         active = context.active_object
  438.  
  439.         if active:
  440.             col.separator()
  441.  
  442.             row = col.row()
  443.             row.prop(active, "name", text="")
  444.             row.prop(active, "display_type", text="")
  445.  
  446.             row = col.row()
  447.             row.prop(active, "show_name", text="Name")
  448.             row.prop(active, "show_axis", text="Axis")
  449.             row.prop(active, "show_in_front", text="In Front")
  450.  
  451.     def draw_right_column(self, context, view, col):
  452.         if view.shading.type == "SOLID":
  453.  
  454.             # light type
  455.             row = col.row(align=True)
  456.             # row.scale_y = 1.5
  457.             row.prop(view.shading, "light", expand=True)
  458.  
  459.             # studio / matcap selection
  460.             if view.shading.light in ["STUDIO", "MATCAP"]:
  461.                 row = col.row()
  462.                 row.scale_y = 0.6
  463.                 row.template_icon_view(view.shading, "studio_light", show_labels=True, scale=3)
  464.  
  465.             # studio rotation, same at worl rotation in lookdev
  466.             if view.shading.light == "STUDIO":
  467.                 col.prop(view.shading, "studiolight_rotate_z", text="Rotation")
  468.  
  469.             # switch matcap
  470.             if view.shading.light == "MATCAP":
  471.                 row = col.row()
  472.                 row.operator("machin3.matcap_switch", text="(X) Matcap Switch")
  473.                 row.operator('VIEW3D_OT_toggle_matcap_flip', text="Matcap Flip", icon='ARROW_LEFTRIGHT')
  474.  
  475.             # color type
  476.             row = col.row(align=True)
  477.             row.prop(view.shading, "color_type", expand=True)
  478.  
  479.             # single color
  480.             if view.shading.color_type == 'SINGLE':
  481.                 col.prop(view.shading, "single_color", text="")
  482.             elif view.shading.color_type == 'MATERIAL':
  483.                 col.operator("machin3.colorize_materials", icon='MATERIAL')
  484.  
  485.         elif view.shading.type == "MATERIAL":
  486.  
  487.             # use scene lights and world
  488.             studio_worlds = [w for w in context.user_preferences.studio_lights if "datafiles/studiolights/world" in w.path]
  489.  
  490.             if any([bpy.data.lights, studio_worlds]):
  491.                 row = col.row()
  492.                 if bpy.data.lights:
  493.                     row.prop(view.shading, "use_scene_lights")
  494.  
  495.                 if studio_worlds:
  496.                     row.prop(view.shading, "use_scene_world")
  497.  
  498.                     # world hdri selection and manipulation
  499.                     if not view.shading.use_scene_world:
  500.                             row = col.row()
  501.                             row.scale_y = 0.6
  502.                             row.template_icon_view(view.shading, "studio_light")
  503.  
  504.                             col.prop(view.shading, "studiolight_rotate_z", text="Rotation")
  505.                             col.prop(view.shading, "studiolight_background_alpha")
  506.  
  507.             # world background node props
  508.  
  509.             if view.shading.use_scene_world or not studio_worlds:
  510.                 world = context.scene.world
  511.                 if world:
  512.                     if world.use_nodes:
  513.                         tree = context.scene.world.node_tree
  514.                         output = tree.nodes.get("World Output")
  515.  
  516.                         if output:
  517.                             input_surf = output.inputs.get("Surface")
  518.  
  519.                             if input_surf:
  520.                                 if input_surf.links:
  521.                                     node = input_surf.links[0].from_node
  522.  
  523.                                     if node.type == "BACKGROUND":
  524.                                         color = node.inputs['Color']
  525.                                         strength = node.inputs['Strength']
  526.  
  527.                                         if color.links:
  528.                                             col.prop(strength, "default_value", text="Background Strength")
  529.                                         else:
  530.                                             row = col.split(factor=0.7)
  531.                                             row.prop(strength, "default_value", text="Background Strength")
  532.                                             row.prop(color, "default_value", text="")
  533.  
  534.                                         col.separator()
  535.  
  536.             """
  537.  
  538.            # eevee settings
  539.  
  540.            icon = "TRIA_DOWN" if context.scene.eevee.use_ssr else "TRIA_RIGHT"
  541.            col.prop(context.scene.eevee, "use_ssr", icon=icon)
  542.            if context.scene.eevee.use_ssr:
  543.                row = col.row(align=True)
  544.                row.prop(context.scene.eevee, "ssr_thickness")
  545.                row.prop(context.scene.eevee, "use_ssr_halfres")
  546.  
  547.  
  548.            icon = "TRIA_DOWN" if context.scene.eevee.use_gtao else "TRIA_RIGHT"
  549.            col.prop(context.scene.eevee, "use_gtao", icon=icon)
  550.            if context.scene.eevee.use_gtao:
  551.                row = col.row(align=True)
  552.                row.prop(context.scene.eevee, "gtao_distance")
  553.                row.prop(context.scene.eevee, "gtao_factor")
  554.  
  555.            icon = "TRIA_DOWN" if context.scene.eevee.use_bloom else "TRIA_RIGHT"
  556.            col.prop(context.scene.eevee, "use_bloom", icon=icon)
  557.            if context.scene.eevee.use_bloom:
  558.                row = col.row(align=True)
  559.                row.prop(context.scene.eevee, "bloom_threshold")
  560.                row.prop(context.scene.eevee, "bloom_radius")
  561.  
  562.            icon = "TRIA_DOWN" if context.scene.eevee.use_volumetric else "TRIA_RIGHT"
  563.            col.prop(context.scene.eevee, "use_volumetric", icon=icon)
  564.            if context.scene.eevee.use_volumetric:
  565.                row = col.row(align=True)
  566.                row.prop(context.scene.eevee, "volumetric_start")
  567.                row.prop(context.scene.eevee, "volumetric_end")
  568.            """
  569.  
  570.  
  571.         elif view.shading.type == "RENDERED":
  572.             col.prop(context.scene.render, "engine")
  573.  
  574.             if context.scene.render.engine == "CYCLES":
  575.                 col.label(text='TODO: render setting presets')
  576.                 col.label(text='TODO: pack images op?')
  577.  
  578.             if context.scene.render.engine == "BLENDER_EEVEE":
  579.                 self.draw_eevee(context, view, col)
  580.  
  581.  
  582.         elif view.shading.type == "WIREFRAME":
  583.             row = col.row()
  584.             row.prop(view.shading, "show_xray_wireframe", text="")
  585.             row.prop(view.shading, "xray_alpha_wireframe", text="X-Ray")
  586.  
  587.  
  588.     def draw_eevee(self, context, view, col):
  589.         icon = "TRIA_DOWN" if context.scene.eevee.use_ssr else "TRIA_RIGHT"
  590.         col.prop(context.scene.eevee, "use_ssr", icon=icon)
  591.         if context.scene.eevee.use_ssr:
  592.             row = col.row(align=True)
  593.             row.prop(context.scene.eevee, "ssr_thickness")
  594.             row.prop(context.scene.eevee, "use_ssr_halfres")
  595.  
  596.  
  597.         icon = "TRIA_DOWN" if context.scene.eevee.use_gtao else "TRIA_RIGHT"
  598.         col.prop(context.scene.eevee, "use_gtao", icon=icon)
  599.         if context.scene.eevee.use_gtao:
  600.             row = col.row(align=True)
  601.             row.prop(context.scene.eevee, "gtao_distance")
  602.             row.prop(context.scene.eevee, "gtao_factor")
  603.  
  604.         icon = "TRIA_DOWN" if context.scene.eevee.use_bloom else "TRIA_RIGHT"
  605.         col.prop(context.scene.eevee, "use_bloom", icon=icon)
  606.         if context.scene.eevee.use_bloom:
  607.             row = col.row(align=True)
  608.             row.prop(context.scene.eevee, "bloom_threshold")
  609.             row.prop(context.scene.eevee, "bloom_radius")
  610.  
  611.         icon = "TRIA_DOWN" if context.scene.eevee.use_volumetric else "TRIA_RIGHT"
  612.         col.prop(context.scene.eevee, "use_volumetric", icon=icon)
  613.         if context.scene.eevee.use_volumetric:
  614.             row = col.row(align=True)
  615.             row.prop(context.scene.eevee, "volumetric_start")
  616.             row.prop(context.scene.eevee, "volumetric_end")
  617.  
  618.  
  619.     def get_text_icon(self, context, shading):
  620.         if context.space_data.shading.type == shading:
  621.             text = "Toggle Overlays"
  622.             icon = "OVERLAY"
  623.         else:
  624.             if shading == "SOLID":
  625.                 text = "Solid"
  626.                 icon = "SHADING_SOLID"
  627.             elif shading == "MATERIAL":
  628.                 text = "LookDev"
  629.                 icon = "SHADING_TEXTURE"
  630.             elif shading == "RENDERED":
  631.                 text = "Rendered"
  632.                 icon = "SHADING_RENDERED"
  633.             elif shading == "WIREFRAME":
  634.                 text = "Wireframe"
  635.                 icon = "SHADING_WIRE"
  636.  
  637.         return text, icon
  638.  
  639.  
  640. class PieViews(Menu):
  641.     bl_idname = "MACHIN3_MT_views_pie"
  642.     bl_label = "Views and Cams"
  643.  
  644.     def draw(self, context):
  645.         layout = self.layout
  646.         pie = layout.menu_pie()
  647.  
  648.         # ob = bpy.context.object
  649.         # obj = context.object
  650.         scene = context.scene
  651.         view = context.space_data
  652.         r3d = view.region_3d
  653.         # rd = scene.render
  654.  
  655.         # align_active = bpy.context.scene.machin3.pieviewsalignactive
  656.  
  657.         # 4 - LEFT
  658.         op = pie.operator("machin3.view_axis", text="Front")
  659.         op.axis='FRONT'
  660.  
  661.         # 6 - RIGHT
  662.         op = pie.operator("machin3.view_axis", text="Right")
  663.         op.axis='RIGHT'
  664.         # 2 - BOTTOM
  665.         op = pie.operator("machin3.view_axis", text="Top")
  666.         op.axis='TOP'
  667.         # 8 - TOP
  668.  
  669.         box = pie.split()
  670.         # box = pie.box().split()
  671.  
  672.         b = box.box()
  673.         column = b.column()
  674.         self.draw_left_column(scene, view, column)
  675.  
  676.         b = box.box()
  677.         column = b.column()
  678.         self.draw_center_column(column)
  679.  
  680.         b = box.box()
  681.         column = b.column()
  682.         self.draw_right_column(view, r3d, column)
  683.  
  684.  
  685.         # 7 - TOP - LEFT
  686.         pie.separator()
  687.  
  688.         # 9 - TOP - RIGHT
  689.         pie.separator()
  690.  
  691.  
  692.         """
  693.        box = pie.split()
  694.        column = box.column()
  695.        column.scale_x = 0.8
  696.  
  697.  
  698.        row = column.row()
  699.        row.label("Resolution")
  700.        row.prop(context.scene.machin3, "preview_percentage", text="")
  701.        row.prop(context.scene.machin3, "final_percentage", text="")
  702.  
  703.        row = column.row()
  704.        row.label("Samples")
  705.        row.prop(context.scene.machin3, "preview_samples", text="")
  706.        row.prop(context.scene.machin3, "final_samples", text="")
  707.  
  708.        row = column.row(align=True)
  709.        row.label("Set")
  710.        row.operator("machin3.set_preview", text="Preview")
  711.        row.operator("machin3.set_final", text="Final")
  712.  
  713.        column.separator()
  714.        column.operator("machin3.pack_images", text="Pack Images")
  715.        column.separator()
  716.        column.separator()
  717.        column.separator()
  718.        # """
  719.  
  720.         # 1 - BOTTOM - LEFT
  721.         pie.separator()
  722.  
  723.         # 3 - BOTTOM - RIGHT
  724.         pie.separator()
  725.  
  726.     def draw_left_column(self, scene, view, col):
  727.         col.scale_x = 2
  728.  
  729.         row = col.row()
  730.         row.scale_y = 1.5
  731.         row.operator("machin3.smart_view_cam", text="Smart View Cam", icon='VISIBLE_IPO_ON')
  732.  
  733.         if view.region_3d.view_perspective == 'CAMERA':
  734.             cams = [obj for obj in scene.objects if obj.type == "CAMERA"]
  735.  
  736.             if len(cams) > 1:
  737.                 row = col.row()
  738.                 row.operator("machin3.next_cam", text="(Q) Previous Cam").previous = True
  739.                 row.operator("machin3.next_cam", text="(W) Next Cam").previous = False
  740.  
  741.  
  742.         row = col.split()
  743.         row.operator("machin3.make_cam_active")
  744.         row.prop(scene, "camera", text="")
  745.  
  746.  
  747.         row = col.split()
  748.         row.operator("view3d.camera_to_view", text="Cam to view", icon='VIEW_CAMERA')
  749.  
  750.         text, icon = ("Unlock from View", "UNLOCKED") if view.lock_camera else ("Lock to View", "LOCKED")
  751.         row.operator("wm.context_toggle", text=text, icon=icon).data_path = "space_data.lock_camera"
  752.  
  753.     def draw_center_column(self, col):
  754.         col.scale_y = 1.5
  755.         op = col.operator("machin3.view_axis", text="Bottom")
  756.         op.axis='BOTTOM'
  757.  
  758.         row = col.row(align=True)
  759.         op = row.operator("machin3.view_axis", text="Left")
  760.         op.axis='LEFT'
  761.  
  762.         op = row.operator("machin3.view_axis", text="Back")
  763.         op.axis='BACK'
  764.  
  765.     def draw_right_column(self, view, r3d, col):
  766.         row = col.row()
  767.         row.scale_y = 1.5
  768.         text, icon = ("Orthographic", "VIEW_ORTHO") if r3d.is_perspective else ("Perspective", "VIEW_PERSPECTIVE")
  769.         row.operator("view3d.view_persportho", text=text, icon=icon)
  770.  
  771.         col.prop(view, "lens")
  772.  
  773.  
  774. class PieAlign(Menu):
  775.     bl_idname = "MACHIN3_MT_align_pie"
  776.     bl_label = "Align"
  777.  
  778.     def draw(self, context):
  779.         layout = self.layout
  780.         pie = layout.menu_pie()
  781.  
  782.         # 4 - LEFT
  783.         op = pie.operator("machin3.align_editmesh", text="Y min")
  784.         op.axis = "Y"
  785.         op.type = "MIN"
  786.  
  787.         # 6 - RIGHT
  788.         op = pie.operator("machin3.align_editmesh", text="Y max")
  789.         op.axis = "Y"
  790.         op.type = "MAX"
  791.  
  792.         # 2 - BOTTOM
  793.         pie.separator()
  794.  
  795.         # 8 - TOP
  796.         box = pie.split()
  797.         box.scale_y = 1.3
  798.  
  799.         column = box.column(align=True)
  800.         column.label(icon="FREEZE")
  801.         op = column.operator("machin3.align_editmesh", text="X")
  802.         op.axis = "X"
  803.         op.type = "ZERO"
  804.         op = column.operator("machin3.align_editmesh", text="Y")
  805.         op.axis = "Y"
  806.         op.type = "ZERO"
  807.         op = column.operator("machin3.align_editmesh", text="Z")
  808.         op.axis = "Z"
  809.         op.type = "ZERO"
  810.  
  811.         column = box.column(align=True)
  812.         column.label(icon="ARROW_LEFTRIGHT")
  813.         op = column.operator("machin3.align_editmesh", text="X")
  814.         op.axis = "X"
  815.         op.type = "AVERAGE"
  816.         op = column.operator("machin3.align_editmesh", text="Y")
  817.         op.axis = "Y"
  818.         op.type = "AVERAGE"
  819.         op = column.operator("machin3.align_editmesh", text="Z")
  820.         op.axis = "Z"
  821.         op.type = "AVERAGE"
  822.  
  823.         column = box.column(align=True)
  824.         column.label(icon="PIVOT_CURSOR")
  825.         op = column.operator("machin3.align_editmesh", text="X")
  826.         op.axis = "X"
  827.         op.type = "CURSOR"
  828.         op = column.operator("machin3.align_editmesh", text="Y")
  829.         op.axis = "Y"
  830.         op.type = "CURSOR"
  831.         op = column.operator("machin3.align_editmesh", text="Z")
  832.         op.axis = "Z"
  833.         op.type = "CURSOR"
  834.  
  835.         column.separator()
  836.         column.separator()
  837.         column.separator()
  838.  
  839.         # 7 - TOP - LEFT
  840.         op = pie.operator("machin3.align_editmesh", text="X min")
  841.         op.axis = "X"
  842.         op.type = "MIN"
  843.  
  844.         # 9 - TOP - RIGHT
  845.         op = pie.operator("machin3.align_editmesh", text="X max")
  846.         op.axis = "X"
  847.         op.type = "MAX"
  848.  
  849.         # 1 - BOTTOM - LEFT
  850.         op = pie.operator("machin3.align_editmesh", text="Z min")
  851.         op.axis = "Z"
  852.         op.type = "MIN"
  853.  
  854.         # 3 - BOTTOM - RIGHT
  855.         op = pie.operator("machin3.align_editmesh", text="Z max")
  856.         op.axis = "Z"
  857.         op.type = "MAX"
  858.  
  859.  
  860. class PieCursor(Menu):
  861.     bl_idname = "MACHIN3_MT_cursor_pie"
  862.     bl_label = "Cursor and Origin"
  863.  
  864.     def draw(self, context):
  865.         layout = self.layout
  866.         pie = layout.menu_pie()
  867.  
  868.         # 4 - LEFT
  869.         pie.operator("view3d.snap_cursor_to_center", text="to Origin", icon="PIVOT_CURSOR")
  870.  
  871.         # 6 - RIGHT
  872.         pie.operator("view3d.snap_selected_to_cursor", text="to Cursor", icon="RESTRICT_SELECT_OFF").use_offset = False
  873.  
  874.         # 2 - BOTTOM
  875.  
  876.         if context.mode == "OBJECT":
  877.             box = pie.split()
  878.             column = box.column()
  879.  
  880.             column.separator()
  881.  
  882.             row = column.split(factor=0.25)
  883.             row.separator()
  884.             row.label(text="Object Origin")
  885.  
  886.             column.scale_x = 1.1
  887.  
  888.             row = column.split(factor=0.5)
  889.             row.scale_y = 1.5
  890.             row.operator("object.origin_set", text="to Cursor", icon="LAYER_ACTIVE").type = "ORIGIN_CURSOR"
  891.             row.operator("object.origin_set", text="to Geometry", icon="OBJECT_ORIGIN").type = "ORIGIN_GEOMETRY"
  892.  
  893.         else:
  894.             pie.separator()
  895.  
  896.         # 8 - TOP
  897.         pie.separator()
  898.  
  899.         # 7 - TOP - LEFT
  900.         pie.operator("view3d.snap_cursor_to_selected", text="to Selected", icon="PIVOT_CURSOR")
  901.  
  902.         # 9 - TOP - RIGHT
  903.         pie.operator("view3d.snap_selected_to_cursor", text="to Cursor, Offset", icon="RESTRICT_SELECT_OFF").use_offset = True
  904.  
  905.         # 1 - BOTTOM - LEFT
  906.         pie.operator("view3d.snap_cursor_to_grid", text="to Grid", icon="PIVOT_CURSOR")
  907.  
  908.         # 3 - BOTTOM - RIGHT
  909.         pie.operator("view3d.snap_selected_to_grid", text="to Grid", icon="RESTRICT_SELECT_OFF")
  910.  
  911.  
  912. class PieWorkspace(Menu):
  913.     bl_idname = "MACHIN3_MT_workspace_pie"
  914.     bl_label = "Workspaces"
  915.  
  916.     def draw(self, context):
  917.         layout = self.layout
  918.         pie = layout.menu_pie()
  919.  
  920.         # 4 - LEFT
  921.         pie.operator("machin3.switch_workspace", text="MACHIN3", icon='VIEW3D').name="General"
  922.  
  923.         # 6 - RIGHT
  924.         pie.separator()
  925.  
  926.         # 2 - BOTTOM
  927.         pie.operator("machin3.switch_workspace", text="Scripting", icon='CONSOLE').name="Scripting"
  928.  
  929.         # 8 - TOP
  930.         pie.operator("machin3.switch_workspace", text="Material", icon='MATERIAL_DATA').name="Material"
  931.  
  932.         # 7 - TOP - LEFT
  933.         pie.operator("machin3.switch_workspace", text="UVs", icon='GROUP_UVS').name="UVs"
  934.  
  935.         # 9 - TOP - RIGHT
  936.         pie.operator("machin3.switch_workspace", text="World", icon='WORLD').name="World"
  937.  
  938.         # 1 - BOTTOM - LEFT
  939.         pie.separator()
  940.  
  941.         # 3 - BOTTOM - RIGHT
  942.         pie.separator()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement