445 lines
19 KiB
Python
445 lines
19 KiB
Python
#!/usr/bin/env python -------------------------------- -*- coding: utf-8 -*-#
|
|
# 2023 3DMish <Mish7913@gmail.com> #
|
|
|
|
# ----- ##### BEGIN GPL LICENSE BLOCK ##### ----- #
|
|
# #
|
|
# This program is free software; you can redistribute it and/or #
|
|
# modify it under the terms of the GNU General Public License #
|
|
# as published by the Free Software Foundation; either version 2 #
|
|
# of the License, or (at your option) any later version. #
|
|
# #
|
|
# This program is distributed in the hope that it will be useful, #
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
# GNU General Public License for more details. #
|
|
# #
|
|
# ----- ##### END GPL LICENSE BLOCK ##### ----- #
|
|
|
|
import bpy, os, sys;
|
|
|
|
from bpy.types import Panel, Operator;
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)) + "/");
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)) + "/m7a_tool_settings/");
|
|
|
|
import m7a_view3d_header, m7a_view3d_tools, m7a_view3d_panels;
|
|
|
|
from bpy_sys import (
|
|
q_register_class, q_unregister_class, get_prop, ver_more,
|
|
r_register_class, r_unregister_class, lc_cont_x,
|
|
ver_less,
|
|
);
|
|
|
|
bl_conf = {
|
|
|
|
}
|
|
|
|
if ver_less(2,79,5):
|
|
bl_conf["VIEW3D_PT_view3d_meshdisplay"] = None; bl_conf["VIEW3D_PT_transform_orientations"] = None;
|
|
bl_conf["VIEW3D_PT_view3d_display"] = None; bl_conf["VIEW3D_PT_view3d_shading"] = None;
|
|
bl_conf["VIEW3D_PT_background_image"] = None; bl_conf["VIEW3D_PT_view3d_motion_tracking"] = None;
|
|
bl_conf["VIEW3D_PT_view3d_name"] = None;
|
|
else:
|
|
bl_conf["VIEW3D_PT_object_type_visibility"] = None;
|
|
|
|
class ACTIVE_PT_CAMERA_panel (Panel):
|
|
bl_space_type = 'VIEW_3D';
|
|
bl_region_type = 'HEADER';
|
|
bl_label = "Active Camera";
|
|
|
|
def draw(self, context):
|
|
self.draw_items(self, context);
|
|
|
|
@staticmethod
|
|
def draw_items(self, context):
|
|
lc_main = self.layout.column(align=True);
|
|
|
|
camera = bpy.data.scenes["Scene"].camera.data;
|
|
space_data = context.space_data;
|
|
|
|
lc_main.label(text="Active Camera", icon="CAMERA_DATA");
|
|
|
|
lc_main.separator();
|
|
|
|
lc_row = lc_main.row(align = True);
|
|
lc_row.prop(camera, "type", text="");
|
|
if (camera.type == "ORTHO"):
|
|
lc_row.prop(camera, "ortho_scale", text="");
|
|
else:
|
|
lc_row.prop(camera, "lens", text="");
|
|
|
|
lc_main.prop(camera, "lens_unit", text="");
|
|
|
|
lc_main.separator();
|
|
|
|
lc_row = lc_main.row(align = True);
|
|
lc_row.prop(camera, "shift_x", text="Shift X");
|
|
lc_cont_x(lc_row, 0.9).prop(camera, "shift_y", text="Y");
|
|
|
|
lc_main.separator();
|
|
|
|
lc_main.prop(camera, "clip_start", text="Clip Start");
|
|
lc_main.prop(camera, "clip_end", text="End");
|
|
|
|
lc_main.separator();
|
|
|
|
if ver_more(2,79,5):
|
|
lc_main.prop(camera.dof, "use_dof", text="Depth of Field");
|
|
if (camera.dof.use_dof):
|
|
lc_cont_x(lc_main, 0.8).prop(camera.dof, "focus_object", text="");
|
|
lc_row = lc_main.row(align = True);
|
|
lc_row.prop(camera.dof, "focus_distance", text="Distance");
|
|
lc_row.prop(camera, "show_limits", text="", icon="OUTLINER_DATA_EMPTY");
|
|
lc_main.separator();
|
|
lc_cont_x(lc_main, 0.8).prop(camera.dof, "aperture_fstop", text="F-Stop");
|
|
else:
|
|
lc_main.prop(space_data.fx_settings, "use_dof", text="Depth of Field");
|
|
lc_cont_x(lc_main, 0.8).prop(camera, "dof_object", text="");
|
|
lc_row = lc_main.row(align = True);
|
|
lc_row.prop(camera, "dof_distance", text="Distance");
|
|
if (context.scene.render.engine == 'CYCLES'):
|
|
lc_row.prop(camera.cycles, "aperture_size", text="Size");
|
|
lc_row.prop(camera, "show_limits", text="", icon="OUTLINER_DATA_EMPTY");
|
|
lc_main.separator();
|
|
lc_cont_x(lc_main, 0.8).prop(camera.gpu_dof, "fstop", text="F-Stop");
|
|
|
|
lc_main.separator();
|
|
lc_main.prop(camera, "show_safe_areas", text="Show Safe Areas");
|
|
if (camera.show_safe_areas) or ver_less(2,79,5):
|
|
lc_cont_x(lc_main, 1.0).prop(context.scene.safe_areas, "title", text="");
|
|
lc_cont_x(lc_main, 1.0).prop(context.scene.safe_areas, "action", text="");
|
|
|
|
class ACTIVE_PT_CAMERA_SHOW_panel (Operator):
|
|
bl_idname = 'view3d.active_camera_panel';
|
|
bl_label = 'Active Camera Properties';
|
|
bl_description = 'Show active camera properties panel';
|
|
|
|
@staticmethod
|
|
def draw(self, context):
|
|
ACTIVE_PT_CAMERA_panel.draw_items(self, context);
|
|
|
|
def invoke(self, context, event):
|
|
context.window_manager.invoke_popup(self, width=265);
|
|
return {'RUNNING_MODAL'}
|
|
|
|
def execute(self, context): return {'FINISHED'};
|
|
|
|
class VIEWPORT_PT_overlay (Operator):
|
|
bl_idname = 'view3d.viewport_overlay';
|
|
bl_label = 'Viewport Overlay';
|
|
bl_description = 'Show viewport overlay panel';
|
|
|
|
@staticmethod
|
|
def draw(self, context):
|
|
lc_main = self.layout.column(align = True);
|
|
lc_mode = bpy.context.object.mode if (context.active_object) else "NONE";
|
|
|
|
tool_settings = context.scene.tool_settings;
|
|
space_data = context.space_data;
|
|
|
|
lc_main.label(text="Viewport Overlays");
|
|
lc_main.separator(); # ---------------------------
|
|
|
|
lc_main.separator(); # ---------------------------
|
|
lc_main.label(text="Guides");
|
|
lc_row = lc_cont_x(lc_main);
|
|
#lc_row.prop(space_data, "show_grid", text="Grid");
|
|
lc_cont_x(lc_row, 1.2).prop(space_data, "show_floor", text="Floor");
|
|
lc_row.separator(); # ---------------------------
|
|
lc_row.label(text="Axis");
|
|
lc_row.prop(space_data, "show_axis_x", text="X", toggle=True);
|
|
lc_row.prop(space_data, "show_axis_y", text="Y", toggle=True);
|
|
lc_row.prop(space_data, "show_axis_z", text="Z", toggle=True);
|
|
lc_main.separator(); # ---------------------------
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(space_data, "grid_lines");
|
|
lc_row.prop(space_data, "grid_scale");
|
|
lc_main.prop(space_data, "grid_subdivisions");
|
|
lc_main.separator(); # ---------------------------
|
|
lc_main.operator("screen.region_quadview");
|
|
lc_main.separator(); # ---------------------------
|
|
|
|
lc_main.separator(); # ---------------------------
|
|
lc_main.label(text="Objects");
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(space_data, "show_relationship_lines", text="Relationship Lines");
|
|
lc_row.prop(space_data, "show_all_objects_origin", text="Origin (All)");
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(space_data, "show_outline_selected", text="Outline Selected");
|
|
lc_main.separator(); # ---------------------------
|
|
|
|
lc_main.separator(); # ---------------------------
|
|
lc_main.prop(space_data, "show_reconstruction", text="Motion Tracking");
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(space_data, "show_camera_path", text="Camera Path");
|
|
lc_row.prop(space_data, "show_bundle_names", text="Marker Names");
|
|
lc_main.label(text="Track Type and Size");
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_cont_x(lc_row, 0.8).prop(space_data, "tracks_draw_type", text="");
|
|
lc_row.prop(space_data, "tracks_draw_size");
|
|
lc_main.separator(); # ---------------------------
|
|
|
|
if (lc_mode in {'EDIT'}):
|
|
active_mesh = context.active_object.data;
|
|
|
|
lc_main.separator(); # ---------------------------
|
|
lc_main.label(text="Mesh Edit Mode");
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(active_mesh, "show_edges", text="Edges");
|
|
lc_row.prop(active_mesh, "show_faces", text="Faces");
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(active_mesh, "show_edge_crease", text="Creases", toggle=True);
|
|
lc_row.prop(active_mesh, "show_edge_sharp", text="Sharp", toggle=True);
|
|
lc_row.prop(active_mesh, "show_edge_bevel_weight", text="Bevel", toggle=True);
|
|
lc_row.prop(active_mesh, "show_edge_seams", text="Seams", toggle=True);
|
|
lc_main.separator(); # ---------------------------
|
|
lc_main.label(text="Measurement");
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(active_mesh, "show_extra_edge_length", text="Edge Length");
|
|
lc_row.prop(active_mesh, "show_extra_face_area", text="Face Area");
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(active_mesh, "show_extra_edge_angle", text="Edge Angle");
|
|
lc_row.prop(active_mesh, "show_extra_face_angle", text="Face Angle");
|
|
lc_main.separator(); # ---------------------------
|
|
lc_main.label(text="Shading");
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(space_data, "show_occlude_wire", text="Hidden Wire");
|
|
lc_row.prop(active_mesh, "show_weight", text="Show Weight");
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(active_mesh, "show_statvis", text="Mesh Analysis");
|
|
is_active = active_mesh.show_statvis;
|
|
lc_cont_x(lc_row, active=is_active).prop(tool_settings.statvis, "type", text="");
|
|
lc_row = lc_cont_x(lc_main, active=is_active);
|
|
lc_row.prop(tool_settings.statvis, "overhang_min", text="");
|
|
lc_row.prop(tool_settings.statvis, "overhang_max", text="");
|
|
lc_row = lc_cont_x(lc_main, active=is_active);
|
|
lc_row.prop(tool_settings.statvis, "overhang_axis", expand=True);
|
|
lc_main.separator(); # ---------------------------
|
|
lc_main.label(text="Normals");
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(active_mesh, "show_normal_vertex", text="", icon='VERTEXSEL');
|
|
lc_row.prop(active_mesh, "show_normal_loop", text="", icon='LOOPSEL');
|
|
lc_row.prop(active_mesh, "show_normal_face", text="", icon='FACESEL');
|
|
|
|
lc_sub = lc_row.row(align=True);
|
|
lc_sub.active = active_mesh.show_normal_vertex or active_mesh.show_normal_face or active_mesh.show_normal_loop;
|
|
lc_sub.prop(tool_settings, "normal_size", text="Size");
|
|
lc_main.separator(); # ---------------------------
|
|
lc_main.label(text="Freestyle");
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(active_mesh, "show_freestyle_edge_marks", text="Edge Marks");
|
|
lc_row.prop(active_mesh, "show_freestyle_face_marks", text="Face Marks");
|
|
|
|
def invoke(self, context, event):
|
|
context.window_manager.invoke_popup(self, width=240);
|
|
return {'RUNNING_MODAL'}
|
|
|
|
def execute(self, context): return {'FINISHED'};
|
|
|
|
class VIEWPORT_PT_shading (Operator):
|
|
bl_idname = 'view3d.viewport_shading';
|
|
bl_label = 'Viewport Shading';
|
|
bl_description = 'Show viewport shaing panel';
|
|
|
|
@staticmethod
|
|
def draw(self, context):
|
|
lc_main = self.layout.column(align=True);
|
|
|
|
space_data = context.space_data;
|
|
|
|
lc_main.label(text="Viewport Shading");
|
|
lc_main.separator(); # ---------------------------
|
|
|
|
if space_data.viewport_shade == 'SOLID':
|
|
lc_main.separator(); # ---------------------------
|
|
lc_main.label(text="Lightning");
|
|
lc_main.prop(space_data, "use_matcap", text="MatCup", toggle=True);
|
|
lc_main.template_icon_view(space_data, "matcap_icon");
|
|
lc_main.prop(space_data, "show_textured_solid");
|
|
|
|
if space_data.viewport_shade == 'TEXTURED' or context.mode == 'PAINT_TEXTURE':
|
|
lc_main.prop(space_data, "show_textured_shadeless", text="Shadeless");
|
|
|
|
if space_data.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'}:
|
|
lc_main.separator(); # ---------------------------
|
|
lc_main.label(text="Options");
|
|
lc_main.prop(space_data, "show_backface_culling", text="Backface Culling");
|
|
|
|
lc_main.prop(space_data.fx_settings, "use_ssao", text="Ambient Occlusion");
|
|
ssao_settings = space_data.fx_settings.ssao;
|
|
if (space_data.fx_settings.use_ssao):
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(ssao_settings, "factor");
|
|
lc_row.prop(ssao_settings, "distance_max");
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(ssao_settings, "attenuation");
|
|
lc_row.prop(ssao_settings, "samples");
|
|
lc_row = lc_cont_x(lc_main);
|
|
lc_row.prop(ssao_settings, "color");
|
|
|
|
def invoke(self, context, event):
|
|
context.space_data.matcap_icon = context.space_data.matcap_icon;
|
|
context.window_manager.invoke_popup(self, width=240);
|
|
return {'RUNNING_MODAL'};
|
|
|
|
def execute(self, context): return {'FINISHED'};
|
|
|
|
class VIEW3D_PT_object_type_visibility(Panel):
|
|
bl_space_type = 'VIEW_3D';
|
|
bl_region_type = 'HEADER';
|
|
bl_label = "View Object Types";
|
|
bl_ui_units_x = 8;
|
|
|
|
def draw_ex(self, _context, view, show_select):
|
|
lc_main = self.layout;
|
|
lc_main.use_property_split = True;
|
|
lc_main.use_property_decorate = False;
|
|
|
|
lc_main.label(text="Selectability & Visibility");
|
|
lc_main.separator();
|
|
|
|
col = lc_main.column();
|
|
|
|
attr_object_types = (
|
|
# Geometry
|
|
("OUTLINER_DATA_MESH", "mesh", "Mesh"),
|
|
("OUTLINER_DATA_CURVE", "curve", "Curve"),
|
|
("OUTLINER_DATA_SURFACE", "surf", "Surface"),
|
|
("OUTLINER_DATA_META", "meta", "Meta"),
|
|
("OUTLINER_DATA_FONT", "font", "Text"),
|
|
("OUTLINER_DATA_CURVES", "curves", "Hair Curves"),
|
|
("OUTLINER_DATA_POINTCLOUD", "pointcloud", "Point Cloud"),
|
|
("OUTLINER_DATA_VOLUME", "volume", "Volume"),
|
|
("OUTLINER_DATA_GREASEPENCIL", "grease_pencil", "Grease Pencil"),
|
|
# Other
|
|
("OUTLINER_DATA_ARMATURE", "armature", "Armature"),
|
|
("OUTLINER_DATA_LATTICE", "lattice", "Lattice"),
|
|
("OUTLINER_DATA_EMPTY", "empty", "Empty"),
|
|
("OUTLINER_DATA_LIGHT", "light", "Light"),
|
|
("OUTLINER_DATA_LIGHTPROBE", "light_probe", "Light Probe"),
|
|
("OUTLINER_DATA_CAMERA", "camera", "Camera"),
|
|
("OUTLINER_DATA_SPEAKER", "speaker", "Speaker"),
|
|
)
|
|
|
|
for icon, attr, attr_name in attr_object_types:
|
|
if attr is None:
|
|
col.separator()
|
|
continue
|
|
|
|
if attr == "curves" and not hasattr(bpy.data, "hair_curves"):
|
|
continue
|
|
elif attr == "pointcloud" and not hasattr(bpy.data, "pointclouds"):
|
|
continue
|
|
|
|
attr_v = "show_object_viewport_" + attr;
|
|
|
|
row = col.row(align=True);
|
|
|
|
row.label(text=attr_name, icon=icon);
|
|
|
|
lc_active = getattr(view, attr_v);
|
|
attr_s = "show_object_select_" + attr;
|
|
icon_s = 'RESTRICT_SELECT_OFF' if getattr(view, attr_s) else 'RESTRICT_SELECT_ON';
|
|
|
|
rowsub = row.row(align=True);
|
|
rowsub.active = lc_active;
|
|
rowsub.prop(view, attr_s, text="", icon=icon_s, emboss=False);
|
|
|
|
row.prop(view, attr_v, text="", icon='HIDE_OFF' if lc_active else 'HIDE_ON', emboss=False);
|
|
|
|
def draw(self, context):
|
|
view = context.space_data;
|
|
|
|
lc_main = self.layout;
|
|
lc_main.use_property_split = True;
|
|
lc_main.use_property_decorate = False;
|
|
|
|
lc_main.label(text="Selectability & Visibility");
|
|
lc_main.separator();
|
|
|
|
col = lc_main.column();
|
|
|
|
attr_object_types = (
|
|
# Geometry
|
|
("OUTLINER_DATA_MESH", "mesh", "Mesh"),
|
|
("OUTLINER_DATA_CURVE", "curve", "Curve"),
|
|
("OUTLINER_DATA_SURFACE", "surf", "Surface"),
|
|
("OUTLINER_DATA_META", "meta", "Meta"),
|
|
("OUTLINER_DATA_FONT", "font", "Text"),
|
|
("OUTLINER_DATA_CURVES", "curves", "Hair Curves"),
|
|
("OUTLINER_DATA_POINTCLOUD", "pointcloud", "Point Cloud"),
|
|
("OUTLINER_DATA_VOLUME", "volume", "Volume"),
|
|
("OUTLINER_DATA_GREASEPENCIL", "grease_pencil", "Grease Pencil"),
|
|
# Other
|
|
("OUTLINER_DATA_ARMATURE", "armature", "Armature"),
|
|
("OUTLINER_DATA_LATTICE", "lattice", "Lattice"),
|
|
("OUTLINER_DATA_EMPTY", "empty", "Empty"),
|
|
("OUTLINER_DATA_LIGHT", "light", "Light"),
|
|
("OUTLINER_DATA_LIGHTPROBE", "light_probe", "Light Probe"),
|
|
("OUTLINER_DATA_CAMERA", "camera", "Camera"),
|
|
("OUTLINER_DATA_SPEAKER", "speaker", "Speaker"),
|
|
)
|
|
|
|
for icon, attr, attr_name in attr_object_types:
|
|
if attr is None:
|
|
col.separator()
|
|
continue
|
|
|
|
if attr == "curves" and not hasattr(bpy.data, "hair_curves"):
|
|
continue
|
|
elif attr == "pointcloud" and not hasattr(bpy.data, "pointclouds"):
|
|
continue
|
|
|
|
attr_v = "show_object_viewport_" + attr;
|
|
|
|
row = col.row(align=True);
|
|
|
|
row.label(text=attr_name, icon=icon);
|
|
|
|
lc_active = getattr(view, attr_v);
|
|
attr_s = "show_object_select_" + attr;
|
|
icon_s = 'RESTRICT_SELECT_OFF' if getattr(view, attr_s) else 'RESTRICT_SELECT_ON';
|
|
|
|
rowsub = row.row(align=True);
|
|
rowsub.active = lc_active;
|
|
rowsub.prop(view, attr_s, text="", icon=icon_s, emboss=False);
|
|
|
|
row.prop(view, attr_v, text="", icon='HIDE_OFF' if lc_active else 'HIDE_ON', emboss=False);
|
|
|
|
|
|
def register_nodes (self, context):
|
|
if get_prop("upgrade_view3d"):
|
|
m7a_view3d_tools.register_nodes(self, context);
|
|
m7a_view3d_panels.register_nodes(self, context);
|
|
register();
|
|
else:
|
|
m7a_view3d_tools.register_nodes(self, context);
|
|
m7a_view3d_panels.register_nodes(self, context);
|
|
unregister();
|
|
|
|
classes = [
|
|
ACTIVE_PT_CAMERA_panel,
|
|
];
|
|
|
|
if ver_less(2,79,5):
|
|
classes.append(ACTIVE_PT_CAMERA_SHOW_panel);
|
|
classes.append(VIEWPORT_PT_overlay);
|
|
classes.append(VIEWPORT_PT_shading);
|
|
else:
|
|
classes.append(VIEW3D_PT_object_type_visibility);
|
|
|
|
def register():
|
|
global bl_conf;
|
|
|
|
r_unregister_class(bl_conf);
|
|
q_register_class(classes);
|
|
|
|
m7a_view3d_header.register();
|
|
|
|
def unregister():
|
|
global bl_conf;
|
|
|
|
m7a_view3d_header.unregister();
|
|
|
|
q_unregister_class(classes);
|
|
r_register_class(bl_conf); |