Properties and Panel renaming

pull/277/head^2
Rob 2024-12-18 15:37:25 -05:00
rodzic cd6bbc34aa
commit c01edb144c
21 zmienionych plików z 257 dodań i 272 usunięć

Wyświetl plik

@ -0,0 +1,217 @@
"""bas_relief_props.py
"""
from bpy.types import PropertyGroup
from bpy.props import (
BoolProperty,
EnumProperty,
FloatProperty,
IntProperty,
PointerProperty,
StringProperty,
)
from ..constants import PRECISION
class BasReliefSettings(PropertyGroup):
use_image_source: BoolProperty(
name="Use Image Source",
description="",
default=False,
)
source_image_name: StringProperty(
name="Image Source",
description="image source",
)
view_layer_name: StringProperty(
name="View Layer Source",
description="Make a bas-relief from whatever is on this view layer",
)
bit_diameter: FloatProperty(
name="Diameter of Ball End in mm",
description="Diameter of bit which will be used for carving",
min=0.01,
max=50.0,
default=3.175,
precision=PRECISION,
)
pass_per_radius: IntProperty(
name="Passes per Radius",
description="Amount of passes per radius\n(more passes, " "more mesh precision)",
default=2,
min=1,
max=10,
)
widthmm: IntProperty(
name="Desired Width in mm",
default=200,
min=5,
max=4000,
)
heightmm: IntProperty(
name="Desired Height in mm",
default=150,
min=5,
max=4000,
)
thicknessmm: IntProperty(
name="Thickness in mm",
default=15,
min=5,
max=100,
)
justifyx: EnumProperty(
name="X",
items=[("1", "Left", "", 0), ("-0.5", "Centered", "", 1), ("-1", "Right", "", 2)],
default="-1",
)
justifyy: EnumProperty(
name="Y",
items=[
("1", "Bottom", "", 0),
("-0.5", "Centered", "", 2),
("-1", "Top", "", 1),
],
default="-1",
)
justifyz: EnumProperty(
name="Z",
items=[
("-1", "Below 0", "", 0),
("-0.5", "Centered", "", 2),
("1", "Above 0", "", 1),
],
default="-1",
)
depth_exponent: FloatProperty(
name="Depth Exponent",
description="Initial depth map is taken to this power. Higher = " "sharper relief",
min=0.5,
max=10.0,
default=1.0,
precision=PRECISION,
)
silhouette_threshold: FloatProperty(
name="Silhouette Threshold",
description="Silhouette threshold",
min=0.000001,
max=1.0,
default=0.003,
precision=PRECISION,
)
recover_silhouettes: BoolProperty(
name="Recover Silhouettes",
description="",
default=True,
)
silhouette_scale: FloatProperty(
name="Silhouette Scale",
description="Silhouette scale",
min=0.000001,
max=5.0,
default=0.3,
precision=PRECISION,
)
silhouette_exponent: IntProperty(
name="Silhouette Square Exponent",
description="If lower, true depth distances between objects will be "
"more visibe in the relief",
default=3,
min=0,
max=5,
)
attenuation: FloatProperty(
name="Gradient Attenuation",
description="Gradient attenuation",
min=0.000001,
max=100.0,
default=1.0,
precision=PRECISION,
)
min_gridsize: IntProperty(
name="Minimum Grid Size",
default=16,
min=2,
max=512,
)
smooth_iterations: IntProperty(
name="Smooth Iterations",
default=1,
min=1,
max=64,
)
vcycle_iterations: IntProperty(
name="V-Cycle Iterations",
description="Set higher for planar constraint",
default=2,
min=1,
max=128,
)
linbcg_iterations: IntProperty(
name="LINBCG Iterations",
description="Set lower for flatter relief, and when using " "planar constraint",
default=5,
min=1,
max=64,
)
use_planar: BoolProperty(
name="Use Planar Constraint",
description="",
default=False,
)
gradient_scaling_mask_use: BoolProperty(
name="Scale Gradients with Mask",
description="",
default=False,
)
decimate_ratio: FloatProperty(
name="Decimate Ratio",
description="Simplify the mesh using the Decimate modifier. "
"The lower the value the more simplyfied",
min=0.01,
max=1.0,
default=0.1,
precision=PRECISION,
)
gradient_scaling_mask_name: StringProperty(
name="Scaling Mask Name",
description="Mask name",
)
scale_down_before_use: BoolProperty(
name="Scale Down Image Before Processing",
description="",
default=False,
)
scale_down_before: FloatProperty(
name="Image Scale",
description="Image scale",
min=0.025,
max=1.0,
default=0.5,
precision=PRECISION,
)
detail_enhancement_use: BoolProperty(
name="Enhance Details",
description="Enhance details by frequency analysis",
default=False,
)
# detail_enhancement_freq=FloatProperty(name="frequency limit", description="Image scale", min=0.025, max=1.0, default=.5, precision=PRECISION)
detail_enhancement_amount: FloatProperty(
name="Amount",
description="Image scale",
min=0.025,
max=1.0,
default=0.5,
precision=PRECISION,
)
advanced: BoolProperty(
name="Advanced Options",
description="Show advanced options",
default=True,
)

Wyświetl plik

@ -14,7 +14,6 @@ bpy.ops.extensions.package_install(repo_index=0, pkg_id="stl_format_legacy")
bpy.ops.extensions.package_install(repo_index=0, pkg_id="simplify_curves_plus")
bpy.ops.extensions.package_install(repo_index=0, pkg_id="curve_tools")
bpy.ops.wm.save_userpref()
print('waaaaaaaaaaaaaaaaah')
"""
NUM_RETRIES = 10

Wyświetl plik

@ -18,7 +18,7 @@ class CAM_AREA_Panel(CAMButtonsPanel, Panel):
bl_category = "CNC"
bl_label = "[ Operation Area ]"
bl_idname = "WORLD_PT_CAM_OPERATION_AREA"
bl_idname = "FABEX_PT_CAM_OPERATION_AREA"
panel_interface_level = 0
def draw(self, context):

Wyświetl plik

@ -4,227 +4,14 @@
"""
import bpy
from bpy.types import PropertyGroup, Panel
from bpy.props import (
BoolProperty,
EnumProperty,
FloatProperty,
IntProperty,
PointerProperty,
StringProperty,
)
from ...constants import PRECISION
class BasReliefSettings(PropertyGroup):
use_image_source: BoolProperty(
name="Use Image Source",
description="",
default=False,
)
source_image_name: StringProperty(
name="Image Source",
description="image source",
)
view_layer_name: StringProperty(
name="View Layer Source",
description="Make a bas-relief from whatever is on this view layer",
)
bit_diameter: FloatProperty(
name="Diameter of Ball End in mm",
description="Diameter of bit which will be used for carving",
min=0.01,
max=50.0,
default=3.175,
precision=PRECISION,
)
pass_per_radius: IntProperty(
name="Passes per Radius",
description="Amount of passes per radius\n(more passes, " "more mesh precision)",
default=2,
min=1,
max=10,
)
widthmm: IntProperty(
name="Desired Width in mm",
default=200,
min=5,
max=4000,
)
heightmm: IntProperty(
name="Desired Height in mm",
default=150,
min=5,
max=4000,
)
thicknessmm: IntProperty(
name="Thickness in mm",
default=15,
min=5,
max=100,
)
justifyx: EnumProperty(
name="X",
items=[("1", "Left", "", 0), ("-0.5", "Centered", "", 1), ("-1", "Right", "", 2)],
default="-1",
)
justifyy: EnumProperty(
name="Y",
items=[
("1", "Bottom", "", 0),
("-0.5", "Centered", "", 2),
("-1", "Top", "", 1),
],
default="-1",
)
justifyz: EnumProperty(
name="Z",
items=[
("-1", "Below 0", "", 0),
("-0.5", "Centered", "", 2),
("1", "Above 0", "", 1),
],
default="-1",
)
depth_exponent: FloatProperty(
name="Depth Exponent",
description="Initial depth map is taken to this power. Higher = " "sharper relief",
min=0.5,
max=10.0,
default=1.0,
precision=PRECISION,
)
silhouette_threshold: FloatProperty(
name="Silhouette Threshold",
description="Silhouette threshold",
min=0.000001,
max=1.0,
default=0.003,
precision=PRECISION,
)
recover_silhouettes: BoolProperty(
name="Recover Silhouettes",
description="",
default=True,
)
silhouette_scale: FloatProperty(
name="Silhouette Scale",
description="Silhouette scale",
min=0.000001,
max=5.0,
default=0.3,
precision=PRECISION,
)
silhouette_exponent: IntProperty(
name="Silhouette Square Exponent",
description="If lower, true depth distances between objects will be "
"more visibe in the relief",
default=3,
min=0,
max=5,
)
attenuation: FloatProperty(
name="Gradient Attenuation",
description="Gradient attenuation",
min=0.000001,
max=100.0,
default=1.0,
precision=PRECISION,
)
min_gridsize: IntProperty(
name="Minimum Grid Size",
default=16,
min=2,
max=512,
)
smooth_iterations: IntProperty(
name="Smooth Iterations",
default=1,
min=1,
max=64,
)
vcycle_iterations: IntProperty(
name="V-Cycle Iterations",
description="Set higher for planar constraint",
default=2,
min=1,
max=128,
)
linbcg_iterations: IntProperty(
name="LINBCG Iterations",
description="Set lower for flatter relief, and when using " "planar constraint",
default=5,
min=1,
max=64,
)
use_planar: BoolProperty(
name="Use Planar Constraint",
description="",
default=False,
)
gradient_scaling_mask_use: BoolProperty(
name="Scale Gradients with Mask",
description="",
default=False,
)
decimate_ratio: FloatProperty(
name="Decimate Ratio",
description="Simplify the mesh using the Decimate modifier. "
"The lower the value the more simplyfied",
min=0.01,
max=1.0,
default=0.1,
precision=PRECISION,
)
gradient_scaling_mask_name: StringProperty(
name="Scaling Mask Name",
description="Mask name",
)
scale_down_before_use: BoolProperty(
name="Scale Down Image Before Processing",
description="",
default=False,
)
scale_down_before: FloatProperty(
name="Image Scale",
description="Image scale",
min=0.025,
max=1.0,
default=0.5,
precision=PRECISION,
)
detail_enhancement_use: BoolProperty(
name="Enhance Details",
description="Enhance details by frequency analysis",
default=False,
)
# detail_enhancement_freq=FloatProperty(name="frequency limit", description="Image scale", min=0.025, max=1.0, default=.5, precision=PRECISION)
detail_enhancement_amount: FloatProperty(
name="Amount",
description="Image scale",
min=0.025,
max=1.0,
default=0.5,
precision=PRECISION,
)
advanced: BoolProperty(
name="Advanced Options",
description="Show advanced options",
default=True,
)
from bpy.types import Panel
class BASRELIEF_Panel(Panel):
"""Bas Relief Panel"""
bl_label = "[ Bas Relief ]"
bl_idname = "WORLD_PT_BASRELIEF"
bl_idname = "FABEX_PT_BASRELIEF"
bl_options = {"DEFAULT_CLOSED"}
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
@ -272,14 +59,10 @@ class BASRELIEF_Panel(Panel):
layout.use_property_split = True
layout.use_property_decorate = False
# print(dir(layout))
scene = context.scene
br = scene.basreliefsettings
# if br:
# cutter preset
box = layout.box()
col = box.column(align=True)
col.label(text="Source")
@ -316,8 +99,6 @@ class BASRELIEF_Panel(Panel):
col.prop(br, "silhouette_scale", text="Scale")
if br.advanced:
col.prop(br, "silhouette_exponent", text="Square Exponent")
# layout.template_curve_mapping(br,'curva')
# layout.prop(br,'attenuation')
box = layout.box()
col = box.column(align=True)
@ -331,25 +112,13 @@ class BASRELIEF_Panel(Panel):
layout.prop(br, "min_gridsize")
layout.prop(br, "decimate_ratio")
layout.prop(br, "use_planar")
layout.prop(br, "gradient_scaling_mask_use")
if br.advanced:
if br.gradient_scaling_mask_use:
layout.prop_search(br, "gradient_scaling_mask_name", bpy.data, "images")
layout.prop(br, "detail_enhancement_use")
if br.detail_enhancement_use:
# layout.prop(br,'detail_enhancement_freq')
layout.prop(br, "detail_enhancement_amount")
# print(dir(layout))
# layout.prop(s.view_settings.curve_mapping,"curves")
# layout.label('Frequency scaling:')
# s.view_settings.curve_mapping.clip_max_y=2
# layout.template_curve_mapping(s.view_settings, "curve_mapping")
# layout.prop(br,'scale_down_before_use')
# if br.scale_down_before_use:
# layout.prop(br,'scale_down_before')
box = layout.box()
col = box.column()
col.scale_y = 1.2

Wyświetl plik

@ -46,7 +46,7 @@ class CAM_CHAINS_Panel(CAMButtonsPanel, Panel):
bl_context = "render"
bl_label = "[ Chains ]"
bl_idname = "WORLD_PT_CAM_CHAINS"
bl_idname = "FABEX_PT_CAM_CHAINS"
bl_options = {"DEFAULT_CLOSED"}
panel_interface_level = 1
always_show_panel = True

Wyświetl plik

@ -17,7 +17,7 @@ class CAM_CUTTER_Panel(CAMButtonsPanel, Panel):
bl_category = "CNC"
bl_label = "[ Cutter ]"
bl_idname = "WORLD_PT_CAM_CUTTER"
bl_idname = "FABEX_PT_CAM_CUTTER"
panel_interface_level = 0
def draw(self, context):

Wyświetl plik

@ -17,7 +17,7 @@ class CAM_FEEDRATE_Panel(CAMButtonsPanel, Panel):
bl_category = "CNC"
bl_label = "[ Feedrate ]"
bl_idname = "WORLD_PT_CAM_FEEDRATE"
bl_idname = "FABEX_PT_CAM_FEEDRATE"
panel_interface_level = 0
def draw(self, context):

Wyświetl plik

@ -17,7 +17,7 @@ class CAM_GCODE_Panel(CAMButtonsPanel, Panel):
bl_category = "CNC"
bl_label = "[ Operation G-code ]"
bl_idname = "WORLD_PT_CAM_GCODE"
bl_idname = "FABEX_PT_CAM_GCODE"
panel_interface_level = 1
def draw(self, context):

Wyświetl plik

@ -21,7 +21,7 @@ class CAM_INFO_Panel(CAMButtonsPanel, Panel):
bl_options = {"HIDE_HEADER"}
bl_label = "Info & Warnings"
bl_idname = "WORLD_PT_CAM_INFO"
bl_idname = "FABEX_PT_CAM_INFO"
panel_interface_level = 0
always_show_panel = True

Wyświetl plik

@ -119,18 +119,18 @@ def update_layout(self, context):
# Unregister all permanent panels
try:
unregister_classes = [
bpy.types.WORLD_PT_CAM_OPERATION_AREA,
bpy.types.WORLD_PT_CAM_CHAINS,
bpy.types.WORLD_PT_CAM_CUTTER,
bpy.types.WORLD_PT_CAM_FEEDRATE,
bpy.types.WORLD_PT_CAM_GCODE,
bpy.types.WORLD_PT_CAM_INFO,
bpy.types.WORLD_PT_CAM_MACHINE,
bpy.types.WORLD_PT_CAM_MATERIAL,
bpy.types.WORLD_PT_CAM_MOVEMENT,
bpy.types.WORLD_PT_CAM_OPERATION,
bpy.types.WORLD_PT_CAM_OPERATIONS,
bpy.types.WORLD_PT_CAM_OPTIMISATION,
bpy.types.FABEX_PT_CAM_OPERATION_AREA,
bpy.types.FABEX_PT_CAM_CHAINS,
bpy.types.FABEX_PT_CAM_CUTTER,
bpy.types.FABEX_PT_CAM_FEEDRATE,
bpy.types.FABEX_PT_CAM_GCODE,
bpy.types.FABEX_PT_CAM_INFO,
bpy.types.FABEX_PT_CAM_MACHINE,
bpy.types.FABEX_PT_CAM_MATERIAL,
bpy.types.FABEX_PT_CAM_MOVEMENT,
bpy.types.FABEX_PT_CAM_OPERATION,
bpy.types.FABEX_PT_CAM_OPERATIONS,
bpy.types.FABEX_PT_CAM_OPTIMISATION,
bpy.types.VIEW3D_PT_tools_curvetools,
bpy.types.VIEW3D_PT_tools_create,
]

Wyświetl plik

@ -17,7 +17,7 @@ class CAM_MACHINE_Panel(CAMButtonsPanel, Panel):
bl_context = "render"
bl_label = "[ Machine ]"
bl_idname = "WORLD_PT_CAM_MACHINE"
bl_idname = "FABEX_PT_CAM_MACHINE"
panel_interface_level = 0
always_show_panel = True

Wyświetl plik

@ -14,7 +14,7 @@ class CAM_MATERIAL_Panel(CAMButtonsPanel, Panel):
bl_context = "render"
bl_label = "[ Material ]"
bl_idname = "WORLD_PT_CAM_MATERIAL"
bl_idname = "FABEX_PT_CAM_MATERIAL"
panel_interface_level = 0
def draw(self, context):

Wyświetl plik

@ -20,7 +20,7 @@ class CAM_MOVEMENT_Panel(CAMButtonsPanel, Panel):
bl_category = "CNC"
bl_label = "[ Movement ]"
bl_idname = "WORLD_PT_CAM_MOVEMENT"
bl_idname = "FABEX_PT_CAM_MOVEMENT"
panel_interface_level = 0
def draw(self, context):

Wyświetl plik

@ -17,7 +17,7 @@ class CAM_OPERATION_PROPERTIES_Panel(CAMButtonsPanel, Panel):
bl_category = "CNC"
bl_label = "[ Operation Setup ]"
bl_idname = "WORLD_PT_CAM_OPERATION"
bl_idname = "FABEX_PT_CAM_OPERATION"
panel_interface_level = 0
def draw_overshoot(self, col):

Wyświetl plik

@ -17,7 +17,7 @@ class CAM_OPERATIONS_Panel(CAMButtonsPanel, Panel):
bl_context = "render"
bl_label = "[ Operations ]"
bl_idname = "WORLD_PT_CAM_OPERATIONS"
bl_idname = "FABEX_PT_CAM_OPERATIONS"
panel_interface_level = 0
always_show_panel = True

Wyświetl plik

@ -18,7 +18,7 @@ class CAM_OPTIMISATION_Panel(CAMButtonsPanel, Panel):
bl_category = "CNC"
bl_label = "[ Optimisation ]"
bl_idname = "WORLD_PT_CAM_OPTIMISATION"
bl_idname = "FABEX_PT_CAM_OPTIMISATION"
panel_interface_level = 2
def draw(self, context):

Wyświetl plik

@ -17,7 +17,7 @@ class CAM_PACK_Panel(CAMButtonsPanel, Panel):
bl_context = "render"
bl_label = "[ Pack ]"
bl_idname = "WORLD_PT_CAM_PACK"
bl_idname = "FABEX_PT_CAM_PACK"
bl_options = {"DEFAULT_CLOSED"}
panel_interface_level = 2
use_property_split = True

Wyświetl plik

@ -17,7 +17,7 @@ class CAM_SLICE_Panel(CAMButtonsPanel, Panel):
bl_context = "render"
bl_label = "[ Slice ]"
bl_idname = "WORLD_PT_CAM_SLICE"
bl_idname = "FABEX_PT_CAM_SLICE"
bl_options = {"DEFAULT_CLOSED"}
panel_interface_level = 2
use_property_split = True

Wyświetl plik

@ -27,14 +27,14 @@ class VIEW3D_MT_PIE_CAM(Menu):
"wm.call_panel",
text="Machine",
icon="DESKTOP",
).name = "WORLD_PT_CAM_MACHINE"
).name = "FABEX_PT_CAM_MACHINE"
# Right
pie.operator(
"wm.call_panel",
text="Material",
icon="META_CUBE",
).name = "WORLD_PT_CAM_MATERIAL"
).name = "FABEX_PT_CAM_MATERIAL"
# Bottom
if len(scene.cam_operations) < 1:
@ -73,7 +73,7 @@ class VIEW3D_MT_PIE_CAM(Menu):
"wm.call_panel",
text="Info & Warnings",
icon="INFO",
).name = "WORLD_PT_CAM_INFO"
).name = "FABEX_PT_CAM_INFO"
# Top Right
box = pie.box()

Wyświetl plik

@ -25,11 +25,11 @@ class VIEW3D_MT_PIE_Chains(Menu):
# Left
pie.operator("wm.call_panel", text="Operations", icon="MOD_ENVELOPE").name = (
"WORLD_PT_CAM_OPERATIONS"
"FABEX_PT_CAM_OPERATIONS"
)
# Right
pie.operator("wm.call_panel", text="Chains", icon="LINKED").name = "WORLD_PT_CAM_CHAINS"
pie.operator("wm.call_panel", text="Chains", icon="LINKED").name = "FABEX_PT_CAM_CHAINS"
# Bottom
row = pie.row()

Wyświetl plik

@ -24,15 +24,15 @@ class VIEW3D_MT_PIE_Operation(Menu):
# Left
pie.operator("wm.call_panel", text="Area", icon="SHADING_BBOX").name = (
"WORLD_PT_CAM_OPERATION_AREA"
"FABEX_PT_CAM_OPERATION_AREA"
)
# Right
pie.operator("wm.call_panel", text="Optimisation", icon="MODIFIER").name = (
"WORLD_PT_CAM_OPTIMISATION"
"FABEX_PT_CAM_OPTIMISATION"
)
# Bottom
pie.operator("wm.call_panel", text="Setup", icon="PREFERENCES").name = (
"WORLD_PT_CAM_OPERATION"
"FABEX_PT_CAM_OPERATION"
)
# Top
@ -43,18 +43,18 @@ class VIEW3D_MT_PIE_Operation(Menu):
# Top Left
pie.operator("wm.call_panel", text="Movement", icon="ANIM_DATA").name = (
"WORLD_PT_CAM_MOVEMENT"
"FABEX_PT_CAM_MOVEMENT"
)
# Top Right
pie.operator("wm.call_panel", text="Feedrate", icon="AUTO").name = "WORLD_PT_CAM_FEEDRATE"
pie.operator("wm.call_panel", text="Feedrate", icon="AUTO").name = "FABEX_PT_CAM_FEEDRATE"
# Bottom Left
pie.operator("wm.call_panel", text="Cutter", icon="OUTLINER_DATA_GP_LAYER").name = (
"WORLD_PT_CAM_CUTTER"
"FABEX_PT_CAM_CUTTER"
)
# Bottom Right
pie.operator("wm.call_panel", text="G-Code Options", icon="EVENT_G").name = (
"WORLD_PT_CAM_GCODE"
"FABEX_PT_CAM_GCODE"
)