2022-05-10 14:30:57 +00:00
|
|
|
import bpy
|
2024-04-02 15:07:14 +00:00
|
|
|
from bpy.types import Panel
|
|
|
|
|
Import Fix, funcs moved, refs updated, ocl rename
Changed all imports from absolute to relative:
- instead of importing the module 'cam' now imports come from '.' the relative parent folder
- importing the module into itself resulted in a circular import error, relative imports avoid this
Moved Functions, refs updated:
- some functions (and 2 variables) only existed on the base level of the module, in the init file, and could not otherwise be accessed, they were moved into the utils file with other similar functions
- these were primarily called as update functions for Properties scattered across the addon, these have all been updated to reflect the new location and import convention
opencamlib_version rename:
- in 2 files there was a local variable named 'opencamlib_version' that was defined by a function called 'opencamlib_version' that returned the opencamlib_version
- this seemed to confuse Blender into thinking that it was being called before it was defined, and simply changing the variable name to 'ocl_version' while keeping the function name as 'opencamlib_version' fixed the issue
2024-03-22 21:52:18 +00:00
|
|
|
from .buttons_panel import CAMButtonsPanel
|
2024-04-02 15:07:14 +00:00
|
|
|
from ..simple import strInUnits
|
2022-05-10 14:30:57 +00:00
|
|
|
|
2023-10-30 16:11:13 +00:00
|
|
|
|
2024-04-02 15:07:14 +00:00
|
|
|
class CAM_AREA_Panel(CAMButtonsPanel, Panel):
|
2024-04-11 19:06:21 +00:00
|
|
|
"""CAM Operation Area Panel"""
|
|
|
|
bl_label = "CAM Operation Area"
|
2022-05-10 14:30:57 +00:00
|
|
|
bl_idname = "WORLD_PT_CAM_OPERATION_AREA"
|
2023-06-13 18:15:22 +00:00
|
|
|
panel_interface_level = 0
|
2022-05-10 14:30:57 +00:00
|
|
|
|
2023-06-18 11:06:39 +00:00
|
|
|
prop_level = {
|
2023-07-04 17:16:13 +00:00
|
|
|
'draw_use_layers': 0,
|
|
|
|
'draw_maxz': 1,
|
|
|
|
'draw_minz': 1,
|
|
|
|
'draw_ambient': 1,
|
2023-07-30 16:18:04 +00:00
|
|
|
'draw_limit_curve': 1,
|
2024-04-02 15:07:14 +00:00
|
|
|
'draw_first_down': 1,
|
2023-06-18 11:06:39 +00:00
|
|
|
}
|
2023-03-02 15:27:23 +00:00
|
|
|
|
2023-06-18 11:06:39 +00:00
|
|
|
def draw_use_layers(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
return
|
2023-07-30 16:18:04 +00:00
|
|
|
col = self.layout.column(align=True)
|
|
|
|
row = col.row(align=True)
|
2023-07-10 17:56:24 +00:00
|
|
|
row.prop(self.op, 'use_layers')
|
|
|
|
if self.op.use_layers:
|
|
|
|
row.prop(self.op, 'stepdown')
|
2023-07-30 16:18:04 +00:00
|
|
|
self.draw_first_down(col)
|
|
|
|
|
|
|
|
def draw_first_down(self, col):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
return
|
|
|
|
if self.op.strategy in ['CUTOUT', 'POCKET', 'MEDIAL_AXIS']:
|
2023-07-30 16:18:04 +00:00
|
|
|
row = col.row(align=True)
|
|
|
|
row.label(text="")
|
|
|
|
row.prop(self.op, 'first_down')
|
2022-05-10 14:30:57 +00:00
|
|
|
|
2023-06-18 11:06:39 +00:00
|
|
|
def draw_maxz(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
return
|
2023-07-10 17:56:24 +00:00
|
|
|
self.layout.prop(self.op, 'maxz')
|
2023-10-30 16:11:13 +00:00
|
|
|
self.layout.prop(self.op.movement, 'free_height')
|
2023-07-12 17:57:17 +00:00
|
|
|
if self.op.maxz > self.op.movement.free_height:
|
2023-10-30 16:11:13 +00:00
|
|
|
self.layout.label(text='!ERROR! COLLISION!')
|
2024-04-11 19:06:21 +00:00
|
|
|
self.layout.label(text='Depth Start > Free Movement Height')
|
2023-10-30 16:11:13 +00:00
|
|
|
self.layout.label(text='!ERROR! COLLISION!')
|
2022-05-10 14:30:57 +00:00
|
|
|
|
2023-06-18 11:06:39 +00:00
|
|
|
def draw_minz(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
return
|
2023-06-16 13:27:05 +00:00
|
|
|
if self.op.geometry_source in ['OBJECT', 'COLLECTION']:
|
|
|
|
if self.op.strategy == 'CURVE':
|
2024-04-11 19:06:21 +00:00
|
|
|
self.layout.label(text="Cannot Use Depth from Object Using Curves")
|
2022-05-10 14:30:57 +00:00
|
|
|
|
2023-07-30 15:21:48 +00:00
|
|
|
row = self.layout.row(align=True)
|
2024-04-11 19:06:21 +00:00
|
|
|
row.label(text='Set Max Depth from')
|
2023-07-30 15:21:48 +00:00
|
|
|
row.prop(self.op, 'minz_from', text='')
|
|
|
|
if self.op.minz_from == 'CUSTOM':
|
|
|
|
self.layout.prop(self.op, 'minz')
|
|
|
|
|
2022-05-10 14:30:57 +00:00
|
|
|
else:
|
2023-07-10 17:56:24 +00:00
|
|
|
self.layout.prop(self.op, 'source_image_scale_z')
|
|
|
|
self.layout.prop(self.op, 'source_image_size_x')
|
2023-06-16 13:27:05 +00:00
|
|
|
if self.op.source_image_name != '':
|
|
|
|
i = bpy.data.images[self.op.source_image_name]
|
2022-05-10 14:30:57 +00:00
|
|
|
if i is not None:
|
2024-03-23 15:14:38 +00:00
|
|
|
sy = int((self.op.source_image_size_x / i.size[0]) * i.size[1] * 1000000) / 1000
|
2024-04-11 19:06:21 +00:00
|
|
|
self.layout.label(text='Image Size on Y Axis: ' + strInUnits(sy, 8))
|
2022-05-10 14:30:57 +00:00
|
|
|
self.layout.separator()
|
2023-07-10 17:56:24 +00:00
|
|
|
self.layout.prop(self.op, 'source_image_offset')
|
2022-05-10 14:30:57 +00:00
|
|
|
col = self.layout.column(align=True)
|
2024-04-11 19:06:21 +00:00
|
|
|
col.prop(self.op, 'source_image_crop', text='Crop Source Image')
|
2023-07-10 17:56:24 +00:00
|
|
|
if self.op.source_image_crop:
|
2024-04-11 19:06:21 +00:00
|
|
|
col.prop(self.op, 'source_image_crop_start_x', text='Start X')
|
|
|
|
col.prop(self.op, 'source_image_crop_start_y', text='Start Y')
|
|
|
|
col.prop(self.op, 'source_image_crop_end_x', text='End X')
|
|
|
|
col.prop(self.op, 'source_image_crop_end_y', text='End Y')
|
2022-05-10 14:30:57 +00:00
|
|
|
|
2023-06-18 11:06:39 +00:00
|
|
|
def draw_ambient(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
return
|
2023-06-18 11:06:39 +00:00
|
|
|
if self.op.strategy in ['BLOCK', 'SPIRAL', 'CIRCLES', 'PARALLEL', 'CROSS']:
|
2023-07-10 17:56:24 +00:00
|
|
|
self.layout.prop(self.op, 'ambient_behaviour')
|
|
|
|
if self.op.ambient_behaviour == 'AROUND':
|
|
|
|
self.layout.prop(self.op, 'ambient_radius')
|
|
|
|
self.layout.prop(self.op, "ambient_cutter_restrict")
|
2023-06-18 11:06:39 +00:00
|
|
|
|
|
|
|
def draw_limit_curve(self):
|
2024-03-21 12:29:30 +00:00
|
|
|
if not self.has_correct_level():
|
|
|
|
return
|
2023-06-18 11:06:39 +00:00
|
|
|
if self.op.strategy in ['BLOCK', 'SPIRAL', 'CIRCLES', 'PARALLEL', 'CROSS']:
|
2023-07-10 17:56:24 +00:00
|
|
|
self.layout.prop(self.op, 'use_limit_curve')
|
|
|
|
if self.op.use_limit_curve:
|
2024-03-23 15:14:38 +00:00
|
|
|
self.layout.prop_search(self.op, "limit_curve", bpy.data, "objects")
|
2022-05-10 14:30:57 +00:00
|
|
|
|
2023-06-18 11:06:39 +00:00
|
|
|
def draw(self, context):
|
|
|
|
self.context = context
|
2022-05-10 14:30:57 +00:00
|
|
|
|
2023-06-18 11:06:39 +00:00
|
|
|
self.draw_use_layers()
|
|
|
|
self.draw_maxz()
|
|
|
|
self.draw_minz()
|
|
|
|
self.draw_ambient()
|
|
|
|
self.draw_limit_curve()
|