1 # SPDX-FileCopyrightText: 2019-2022 Alan Odom (Clockmender)
2 # SPDX-FileCopyrightText: 2019-2022 Rune Morling (ermo)
4 # SPDX-License-Identifier: GPL-2.0-or-later
7 from bpy
.types
import Panel
8 from .pdt_msg_strings
import (
52 """Return the Width of the UI Panel.
61 area
= bpy
.context
.area
62 resolution
= bpy
.context
.preferences
.system
.ui_scale
64 for reg
in area
.regions
:
66 region_width
= reg
.width
71 class PDT_PT_PanelDesign(Panel
):
72 bl_idname
= "PDT_PT_PanelDesign"
73 bl_label
= "PDT Design Operations"
74 bl_space_type
= "VIEW_3D"
77 bl_options
= {'DEFAULT_CLOSED'}
79 def draw(self
, context
):
80 ui_cutoff
= bpy
.context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
82 pdt_pg
= context
.scene
.pdt_pg
86 row
.label(text
=f
"Working {PDT_LAB_PLANE}:")
87 row
.prop(pdt_pg
, "plane", text
="")
91 row
.label(text
=f
"Move {PDT_LAB_MODE}:")
92 row
.prop(pdt_pg
, "select", text
="")
94 # Active or All Selected
97 row
.prop(pdt_pg
, "extend", text
="All Selected Entities (Off: Active Only)")
99 # --------------------
100 # (1) Select Operation
104 row
.label(text
=f
"(1) Select {PDT_LAB_OPERATION}:")
105 row
.prop(pdt_pg
, "operation", text
="")
107 # -----------------------
108 # (a) Set Coordinates box
111 box_1a
.label(text
=f
"(a) Either Set Coordinates + [Place »]")
112 # ^ was PDT_LAB_VARIABLES
114 # cartesian input coordinates in a box
118 split
= row
.split(factor
=0.35, align
=True)
119 split
.label(text
=PDT_LAB_CVALUE
)
120 split
.prop(pdt_pg
, "cartesian_coords", text
="")
122 row
.operator("pdt.absolute", icon
="EMPTY_AXIS", text
=f
"{PDT_LAB_ABS} »")
123 row
.operator("pdt.delta", icon
="EMPTY_AXIS", text
=f
"{PDT_LAB_DEL} »")
125 # directional input coordinates in a box
128 #box.label(text="Directional/Polar Coordinates:")
130 row
.prop(pdt_pg
, "distance", text
=PDT_LAB_DISVALUE
)
131 row
.prop(pdt_pg
, "angle", text
=PDT_LAB_ANGLEVALUE
)
133 row
.operator("pdt.distance", icon
="EMPTY_AXIS", text
=f
"{PDT_LAB_DIR} »")
134 row
.operator("pdt.view_axis", icon
="EMPTY_AXIS", text
=f
"{PDT_LAB_VIEW} »")
136 row
.prop(pdt_pg
, "flip_angle", text
=PDT_LAB_FLIPANGLE
)
138 # ---------------------
139 # (b) Miscellaneous box
142 box_1b
.label(text
="(b) Or Select |n| Entities + [Place »]")
144 # normal or arc centre
146 row
.operator("pdt.normal", text
=f
"|3| {PDT_LAB_NOR} »")
147 row
.operator("pdt.centre", text
=f
"|3| {PDT_LAB_ARCCENTRE} »")
152 row
.operator("pdt.intersect", text
=f
"|4| {PDT_LAB_INTERSECT} »")
153 if ui_width() < ui_cutoff
:
155 row
.prop(pdt_pg
, "object_order", text
=PDT_LAB_ORDER
)
160 box
.label(text
=f
"Do (1) at % between selected points")
162 row
.operator("pdt.percent", text
=f
"|2| % »")
163 row
.prop(pdt_pg
, "percent", text
=PDT_LAB_PERCENTS
)
164 if ui_width() < ui_cutoff
:
166 row
.prop(pdt_pg
, "flip_percent", text
=PDT_LAB_FLIPPERCENT
)
168 class PDT_PT_PanelTools(Panel
):
169 bl_idname
= "PDT_PT_PanelTools"
170 bl_label
= "PDT Design Tools"
171 bl_space_type
= "VIEW_3D"
172 bl_region_type
= "UI"
174 bl_options
= {'DEFAULT_CLOSED'}
176 def draw(self
, context
):
177 ui_cutoff
= bpy
.context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
179 pdt_pg
= context
.scene
.pdt_pg
183 row
.label(text
=PDT_LAB_TOOLS
)
185 row
.operator("pdt.origin", text
=PDT_LAB_ORIGINCURSOR
)
187 row
.operator("pdt.angle2", text
=PDT_LAB_AD2D
)
188 row
.operator("pdt.angle3", text
=PDT_LAB_AD3D
)
190 row
.operator("pdt.join", text
=PDT_LAB_JOIN2VERTS
)
191 row
.operator("pdt.linetobisect", text
=PDT_LAB_BISECT
)
193 row
.operator("pdt.edge_to_face", text
=PDT_LAB_EDGETOEFACE
)
194 row
.operator("pdt.intersectall", text
=PDT_LAB_INTERSETALL
)
199 row
.operator("pdt.taper", text
=PDT_LAB_TAPER
)
200 row
.prop(pdt_pg
, "taper", text
=PDT_LAB_TAPERAXES
)
205 row
.operator("pdt.fillet", text
=f
"{PDT_LAB_FILLET}")
206 row
.prop(pdt_pg
, "fillet_intersect", text
="Intersect")
208 row
.prop(pdt_pg
, "fillet_radius", text
=PDT_LAB_RADIUS
)
209 row
.prop(pdt_pg
, "fillet_profile", text
=PDT_LAB_PROFILE
)
211 row
.prop(pdt_pg
, "fillet_segments", text
=PDT_LAB_SEGMENTS
)
212 row
.prop(pdt_pg
, "fillet_vertices_only", text
=PDT_LAB_USEVERTS
)
215 class PDT_PT_PanelPivotPoint(Panel
):
216 bl_idname
= "PDT_PT_PanelPivotPoint"
217 bl_label
= "PDT Pivot Point"
218 bl_space_type
= "VIEW_3D"
219 bl_region_type
= "UI"
221 bl_options
= {'DEFAULT_CLOSED'}
223 def draw(self
, context
):
224 ui_cutoff
= bpy
.context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
225 pdt_pg
= context
.scene
.pdt_pg
229 if context
.window_manager
.pdt_run_opengl
is False:
235 col
.operator("pdt.modaldraw", icon
=icon
, text
=txt
)
237 col
.prop(pdt_pg
, "pivot_size", text
=PDT_LAB_PIVOTSIZE
)
238 if ui_width() < ui_cutoff
:
241 col
.prop(pdt_pg
, "pivot_width", text
=PDT_LAB_PIVOTWIDTH
)
243 col
.prop(pdt_pg
, "pivot_alpha", text
=PDT_LAB_PIVOTALPHA
)
245 split
= row
.split(factor
=0.35, align
=True)
246 split
.label(text
=PDT_LAB_PIVOTLOCH
)
247 split
.prop(pdt_pg
, "pivot_loc", text
=PDT_LAB_PIVOTLOC
)
250 col
.operator("pdt.pivotselected", icon
="EMPTY_AXIS", text
="Selection")
252 col
.operator("pdt.pivotcursor", icon
="EMPTY_AXIS", text
="Cursor")
254 col
.operator("pdt.pivotorigin", icon
="EMPTY_AXIS", text
="Origin")
257 col
.operator("pdt.viewplanerot", icon
="EMPTY_AXIS", text
="Rotate")
259 col
.prop(pdt_pg
, "pivot_ang", text
="Angle")
262 col
.operator("pdt.viewscale", icon
="EMPTY_AXIS", text
="Scale")
264 col
.operator("pdt.cursorpivot", icon
="EMPTY_AXIS", text
="Cursor To Pivot")
267 col
.prop(pdt_pg
, "pivot_dis", text
="Scale Distance")
269 col
.prop(pdt_pg
, "distance", text
="System Distance")
271 split
= row
.split(factor
=0.35, align
=True)
272 split
.label(text
="Scale")
273 split
.prop(pdt_pg
, "pivot_scale", text
="")
276 col
.operator("pdt.pivotwrite", icon
="FILE_TICK", text
="PP Write")
278 col
.operator("pdt.pivotread", icon
="FILE", text
="PP Read")
281 class PDT_PT_PanelPartsLibrary(Panel
):
282 bl_idname
= "PDT_PT_PanelPartsLibrary"
283 bl_label
= "PDT Parts Library"
284 bl_space_type
= "VIEW_3D"
285 bl_region_type
= "UI"
287 bl_options
= {'DEFAULT_CLOSED'}
289 def draw(self
, context
):
290 ui_cutoff
= context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
292 pdt_pg
= context
.scene
.pdt_pg
294 row
.prop(pdt_pg
, "pdt_library_path")
297 col
.operator("pdt.append", text
="Append")
299 col
.operator("pdt.link", text
="Link")
300 if ui_width() < ui_cutoff
:
303 col
.prop(pdt_pg
, "lib_mode", text
="")
307 col
.label(text
="Objects")
309 col
.prop(pdt_pg
, "object_search_string")
311 row
.prop(pdt_pg
, "lib_objects", text
="")
315 col
.label(text
="Collections")
317 col
.prop(pdt_pg
, "collection_search_string")
319 row
.prop(pdt_pg
, "lib_collections", text
="")
323 col
.label(text
="Materials")
325 col
.prop(pdt_pg
, "material_search_string")
327 row
.prop(pdt_pg
, "lib_materials", text
="")
329 #row.operator("pdt.lib_show", text="Load Library File", icon='INFO')
332 class PDT_PT_PanelViewControl(Panel
):
333 bl_idname
= "PDT_PT_PanelViewControl"
334 bl_label
= "PDT View Control"
335 bl_space_type
= "VIEW_3D"
336 bl_region_type
= "UI"
338 bl_options
= {'DEFAULT_CLOSED'}
340 # Sub-layout highlight states
341 _ui_groups
= [False, False]
343 def draw(self
, context
):
344 ui_cutoff
= context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
346 ui_groups
= self
._ui
_groups
347 pdt_pg
= context
.scene
.pdt_pg
351 col
.label(text
="View Rotation")
353 col
.operator("pdt.viewrot", text
="Rotate Abs")
355 split
= row
.split(factor
=0.35, align
=True)
356 split
.label(text
="Rotation")
357 split
.prop(pdt_pg
, "rotation_coords", text
="")
360 col
.prop(pdt_pg
, "vrotangle", text
="Angle")
361 if ui_width() < ui_cutoff
:
364 col
.operator("pdt.viewleft", text
="", icon
="TRIA_LEFT")
366 col
.operator("pdt.viewright", text
="", icon
="TRIA_RIGHT")
368 col
.operator("pdt.viewup", text
="", icon
="TRIA_UP")
370 col
.operator("pdt.viewdown", text
="", icon
="TRIA_DOWN")
372 col
.operator("pdt.viewroll", text
="", icon
="RECOVER_LAST")
375 col
.operator("pdt.viewiso", text
="Isometric")
377 col
.operator("pdt.reset_3d_view", text
="Reset View")
380 class PDT_PT_PanelCommandLine(Panel
):
381 bl_idname
= "PDT_PT_PanelCommandLine"
382 bl_label
= "PDT Command Line (? for help)"
383 bl_space_type
= "VIEW_3D"
384 bl_region_type
= "UI"
386 bl_options
= {'DEFAULT_CLOSED'}
388 def draw(self
, context
):
390 pdt_pg
= context
.scene
.pdt_pg
393 col
.prop(pdt_pg
, "plane", text
="Plane")
395 col
.prop(pdt_pg
, "select", text
="Mode")
397 row
.label(text
="Command Line, uses Plane & Mode Options")
399 row
.prop(pdt_pg
, "command", text
="")
401 row
.operator("pdt.command_rerun", text
="", icon
="LOOP_BACK")
403 row
.prop(pdt_pg
, "maths_output", text
="Maths Output")
405 class PDT_PT_PanelTangent(Panel
):
406 bl_idname
= "PDT_PT_PanelTangent"
407 bl_label
= "PDT Tangents"
408 bl_space_type
= "VIEW_3D"
409 bl_region_type
= "UI"
411 bl_options
= {'DEFAULT_CLOSED'}
413 def draw(self
,context
):
415 pdt_pg
= context
.scene
.pdt_pg
417 if pdt_pg
.menu_expand
:
422 row
.label(text
=f
"Working {PDT_LAB_PLANE}:")
423 row
.prop(pdt_pg
, "plane", text
="")
425 row
.label(text
="Tangent Mode")
426 row
.prop(pdt_pg
, "tangent_mode", text
="")
428 row
.operator("pdt.tangentoperatesel", text
="Tangents from Selection", icon
="NONE")
430 row
.label(text
="Or Use Tangents From Inputs")
431 row
.operator("pdt.tangentexpandmenu", text
="", icon
=icon_e
)
435 split
= row
.split(factor
=0.35, align
=True)
436 split
.label(text
="Tangent Point")
437 split
.prop(pdt_pg
, "tangent_point2", text
="")
439 row
.operator("pdt.tangentset3", text
="from Cursor")
440 row
.operator("pdt.tangentset4", text
="from Vertex")
442 if pdt_pg
.menu_expand
:
445 split
= row
.split(factor
=0.35, align
=True)
446 split
.label(text
="Centre 1")
447 split
.prop(pdt_pg
, "tangent_point0", text
="")
449 split
= row
.split(factor
=0.45, align
=False)
450 split
.operator("pdt.tangentset1", text
="Set From Arc")
451 split
.prop(pdt_pg
, "tangent_radius0", text
="")
453 # Second Centre & Radius
455 split
= row
.split(factor
=0.35, align
=True)
456 split
.label(text
="Centre 2")
457 split
.prop(pdt_pg
, "tangent_point1", text
="")
459 split
= row
.split(factor
=0.45, align
=False)
460 split
.operator("pdt.tangentset2", text
="Set From Arc")
461 split
.prop(pdt_pg
, "tangent_radius1", text
="")
463 row
.operator("pdt.tangentoperate", text
="Tangents From Inputs", icon
="NONE")
465 class PDT_PT_PanelTrig(Panel
):
466 bl_idname
= "PDT_PT_PanelTrig"
467 bl_label
= "PDT Trigonometrical Waves"
468 bl_space_type
= "VIEW_3D"
469 bl_region_type
= "UI"
471 bl_options
= {'DEFAULT_CLOSED'}
473 def draw(self
,context
):
475 pdt_pg
= context
.scene
.pdt_pg
477 row
.label(text
=f
"Working {PDT_LAB_PLANE}:")
478 row
.prop(pdt_pg
, "plane", text
="")
481 split
= row
.split(factor
=0.5, align
=True)
482 split
.prop(pdt_pg
, "trig_type")
483 split
.prop(pdt_pg
, "trig_cycles")
485 split
= row
.split(factor
=0.5, align
=True)
486 split
.prop(pdt_pg
, "trig_amp")
487 split
.prop(pdt_pg
, "trig_len")
489 split
= row
.split(factor
=0.5, align
=True)
490 split
.prop(pdt_pg
, "trig_obj", text
="")
491 split
.prop(pdt_pg
, "trig_del")
493 split
= row
.split(factor
=0.5, align
=True)
494 split
.prop(pdt_pg
, "trig_res")
495 split
.prop(pdt_pg
, "trig_tanmax")
497 row
.prop(pdt_pg
, "trig_off")
499 row
.operator("pdt.wave_generator", icon
="SEQ_LUMA_WAVEFORM")
500 row
.prop(pdt_pg
, "trig_abs")