1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # -----------------------------------------------------------------------
4 # Author: Alan Odom (Clockmender), Rune Morling (ermo) Copyright (c) 2019
5 # -----------------------------------------------------------------------
8 from bpy
.types
import Panel
9 from .pdt_msg_strings
import (
53 """Return the Width of the UI Panel.
62 area
= bpy
.context
.area
63 resolution
= bpy
.context
.preferences
.system
.ui_scale
65 for reg
in area
.regions
:
67 region_width
= reg
.width
72 class PDT_PT_PanelDesign(Panel
):
73 bl_idname
= "PDT_PT_PanelDesign"
74 bl_label
= "PDT Design Operations"
75 bl_space_type
= "VIEW_3D"
78 bl_options
= {'DEFAULT_CLOSED'}
80 def draw(self
, context
):
81 ui_cutoff
= bpy
.context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
83 pdt_pg
= context
.scene
.pdt_pg
87 row
.label(text
=f
"Working {PDT_LAB_PLANE}:")
88 row
.prop(pdt_pg
, "plane", text
="")
92 row
.label(text
=f
"Move {PDT_LAB_MODE}:")
93 row
.prop(pdt_pg
, "select", text
="")
95 # Active or All Selected
98 row
.prop(pdt_pg
, "extend", text
="All Selected Entities (Off: Active Only)")
100 # --------------------
101 # (1) Select Operation
105 row
.label(text
=f
"(1) Select {PDT_LAB_OPERATION}:")
106 row
.prop(pdt_pg
, "operation", text
="")
108 # -----------------------
109 # (a) Set Coordinates box
112 box_1a
.label(text
=f
"(a) Either Set Coordinates + [Place »]")
113 # ^ was PDT_LAB_VARIABLES
115 # cartesian input coordinates in a box
119 split
= row
.split(factor
=0.35, align
=True)
120 split
.label(text
=PDT_LAB_CVALUE
)
121 split
.prop(pdt_pg
, "cartesian_coords", text
="")
123 row
.operator("pdt.absolute", icon
="EMPTY_AXIS", text
=f
"{PDT_LAB_ABS} »")
124 row
.operator("pdt.delta", icon
="EMPTY_AXIS", text
=f
"{PDT_LAB_DEL} »")
126 # directional input coordinates in a box
129 #box.label(text="Directional/Polar Coordinates:")
131 row
.prop(pdt_pg
, "distance", text
=PDT_LAB_DISVALUE
)
132 row
.prop(pdt_pg
, "angle", text
=PDT_LAB_ANGLEVALUE
)
134 row
.operator("pdt.distance", icon
="EMPTY_AXIS", text
=f
"{PDT_LAB_DIR} »")
135 row
.operator("pdt.view_axis", icon
="EMPTY_AXIS", text
=f
"{PDT_LAB_VIEW} »")
137 row
.prop(pdt_pg
, "flip_angle", text
=PDT_LAB_FLIPANGLE
)
139 # ---------------------
140 # (b) Miscellaneous box
143 box_1b
.label(text
="(b) Or Select |n| Entities + [Place »]")
145 # normal or arc centre
147 row
.operator("pdt.normal", text
=f
"|3| {PDT_LAB_NOR} »")
148 row
.operator("pdt.centre", text
=f
"|3| {PDT_LAB_ARCCENTRE} »")
153 row
.operator("pdt.intersect", text
=f
"|4| {PDT_LAB_INTERSECT} »")
154 if ui_width() < ui_cutoff
:
156 row
.prop(pdt_pg
, "object_order", text
=PDT_LAB_ORDER
)
161 box
.label(text
=f
"Do (1) at % between selected points")
163 row
.operator("pdt.percent", text
=f
"|2| % »")
164 row
.prop(pdt_pg
, "percent", text
=PDT_LAB_PERCENTS
)
165 if ui_width() < ui_cutoff
:
167 row
.prop(pdt_pg
, "flip_percent", text
=PDT_LAB_FLIPPERCENT
)
169 class PDT_PT_PanelTools(Panel
):
170 bl_idname
= "PDT_PT_PanelTools"
171 bl_label
= "PDT Design Tools"
172 bl_space_type
= "VIEW_3D"
173 bl_region_type
= "UI"
175 bl_options
= {'DEFAULT_CLOSED'}
177 def draw(self
, context
):
178 ui_cutoff
= bpy
.context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
180 pdt_pg
= context
.scene
.pdt_pg
184 row
.label(text
=PDT_LAB_TOOLS
)
186 row
.operator("pdt.origin", text
=PDT_LAB_ORIGINCURSOR
)
188 row
.operator("pdt.angle2", text
=PDT_LAB_AD2D
)
189 row
.operator("pdt.angle3", text
=PDT_LAB_AD3D
)
191 row
.operator("pdt.join", text
=PDT_LAB_JOIN2VERTS
)
192 row
.operator("pdt.linetobisect", text
=PDT_LAB_BISECT
)
194 row
.operator("pdt.edge_to_face", text
=PDT_LAB_EDGETOEFACE
)
195 row
.operator("pdt.intersectall", text
=PDT_LAB_INTERSETALL
)
200 row
.operator("pdt.taper", text
=PDT_LAB_TAPER
)
201 row
.prop(pdt_pg
, "taper", text
=PDT_LAB_TAPERAXES
)
206 row
.operator("pdt.fillet", text
=f
"{PDT_LAB_FILLET}")
207 row
.prop(pdt_pg
, "fillet_intersect", text
="Intersect")
209 row
.prop(pdt_pg
, "fillet_radius", text
=PDT_LAB_RADIUS
)
210 row
.prop(pdt_pg
, "fillet_profile", text
=PDT_LAB_PROFILE
)
212 row
.prop(pdt_pg
, "fillet_segments", text
=PDT_LAB_SEGMENTS
)
213 row
.prop(pdt_pg
, "fillet_vertices_only", text
=PDT_LAB_USEVERTS
)
216 class PDT_PT_PanelPivotPoint(Panel
):
217 bl_idname
= "PDT_PT_PanelPivotPoint"
218 bl_label
= "PDT Pivot Point"
219 bl_space_type
= "VIEW_3D"
220 bl_region_type
= "UI"
222 bl_options
= {'DEFAULT_CLOSED'}
224 def draw(self
, context
):
225 ui_cutoff
= bpy
.context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
226 pdt_pg
= context
.scene
.pdt_pg
230 if context
.window_manager
.pdt_run_opengl
is False:
236 col
.operator("pdt.modaldraw", icon
=icon
, text
=txt
)
238 col
.prop(pdt_pg
, "pivot_size", text
=PDT_LAB_PIVOTSIZE
)
239 if ui_width() < ui_cutoff
:
242 col
.prop(pdt_pg
, "pivot_width", text
=PDT_LAB_PIVOTWIDTH
)
244 col
.prop(pdt_pg
, "pivot_alpha", text
=PDT_LAB_PIVOTALPHA
)
246 split
= row
.split(factor
=0.35, align
=True)
247 split
.label(text
=PDT_LAB_PIVOTLOCH
)
248 split
.prop(pdt_pg
, "pivot_loc", text
=PDT_LAB_PIVOTLOC
)
251 col
.operator("pdt.pivotselected", icon
="EMPTY_AXIS", text
="Selection")
253 col
.operator("pdt.pivotcursor", icon
="EMPTY_AXIS", text
="Cursor")
255 col
.operator("pdt.pivotorigin", icon
="EMPTY_AXIS", text
="Origin")
258 col
.operator("pdt.viewplanerot", icon
="EMPTY_AXIS", text
="Rotate")
260 col
.prop(pdt_pg
, "pivot_ang", text
="Angle")
263 col
.operator("pdt.viewscale", icon
="EMPTY_AXIS", text
="Scale")
265 col
.operator("pdt.cursorpivot", icon
="EMPTY_AXIS", text
="Cursor To Pivot")
268 col
.prop(pdt_pg
, "pivot_dis", text
="Scale Distance")
270 col
.prop(pdt_pg
, "distance", text
="System Distance")
272 split
= row
.split(factor
=0.35, align
=True)
273 split
.label(text
="Scale")
274 split
.prop(pdt_pg
, "pivot_scale", text
="")
277 col
.operator("pdt.pivotwrite", icon
="FILE_TICK", text
="PP Write")
279 col
.operator("pdt.pivotread", icon
="FILE", text
="PP Read")
282 class PDT_PT_PanelPartsLibrary(Panel
):
283 bl_idname
= "PDT_PT_PanelPartsLibrary"
284 bl_label
= "PDT Parts Library"
285 bl_space_type
= "VIEW_3D"
286 bl_region_type
= "UI"
288 bl_options
= {'DEFAULT_CLOSED'}
290 def draw(self
, context
):
291 ui_cutoff
= context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
293 pdt_pg
= context
.scene
.pdt_pg
295 row
.prop(pdt_pg
, "pdt_library_path")
298 col
.operator("pdt.append", text
="Append")
300 col
.operator("pdt.link", text
="Link")
301 if ui_width() < ui_cutoff
:
304 col
.prop(pdt_pg
, "lib_mode", text
="")
308 col
.label(text
="Objects")
310 col
.prop(pdt_pg
, "object_search_string")
312 row
.prop(pdt_pg
, "lib_objects", text
="")
316 col
.label(text
="Collections")
318 col
.prop(pdt_pg
, "collection_search_string")
320 row
.prop(pdt_pg
, "lib_collections", text
="")
324 col
.label(text
="Materials")
326 col
.prop(pdt_pg
, "material_search_string")
328 row
.prop(pdt_pg
, "lib_materials", text
="")
330 #row.operator("pdt.lib_show", text="Load Library File", icon='INFO')
333 class PDT_PT_PanelViewControl(Panel
):
334 bl_idname
= "PDT_PT_PanelViewControl"
335 bl_label
= "PDT View Control"
336 bl_space_type
= "VIEW_3D"
337 bl_region_type
= "UI"
339 bl_options
= {'DEFAULT_CLOSED'}
341 # Sub-layout highlight states
342 _ui_groups
= [False, False]
344 def draw(self
, context
):
345 ui_cutoff
= context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
347 ui_groups
= self
._ui
_groups
348 pdt_pg
= context
.scene
.pdt_pg
352 col
.label(text
="View Rotation")
354 col
.operator("pdt.viewrot", text
="Rotate Abs")
356 split
= row
.split(factor
=0.35, align
=True)
357 split
.label(text
="Rotation")
358 split
.prop(pdt_pg
, "rotation_coords", text
="")
361 col
.prop(pdt_pg
, "vrotangle", text
="Angle")
362 if ui_width() < ui_cutoff
:
365 col
.operator("pdt.viewleft", text
="", icon
="TRIA_LEFT")
367 col
.operator("pdt.viewright", text
="", icon
="TRIA_RIGHT")
369 col
.operator("pdt.viewup", text
="", icon
="TRIA_UP")
371 col
.operator("pdt.viewdown", text
="", icon
="TRIA_DOWN")
373 col
.operator("pdt.viewroll", text
="", icon
="RECOVER_LAST")
376 col
.operator("pdt.viewiso", text
="Isometric")
378 col
.operator("pdt.reset_3d_view", text
="Reset View")
381 class PDT_PT_PanelCommandLine(Panel
):
382 bl_idname
= "PDT_PT_PanelCommandLine"
383 bl_label
= "PDT Command Line (? for help)"
384 bl_space_type
= "VIEW_3D"
385 bl_region_type
= "UI"
387 bl_options
= {'DEFAULT_CLOSED'}
389 def draw(self
, context
):
391 pdt_pg
= context
.scene
.pdt_pg
394 col
.prop(pdt_pg
, "plane", text
="Plane")
396 col
.prop(pdt_pg
, "select", text
="Mode")
398 row
.label(text
="Command Line, uses Plane & Mode Options")
400 row
.prop(pdt_pg
, "command", text
="")
402 row
.operator("pdt.command_rerun", text
="", icon
="LOOP_BACK")
404 row
.prop(pdt_pg
, "maths_output", text
="Maths Output")
406 class PDT_PT_PanelTangent(Panel
):
407 bl_idname
= "PDT_PT_PanelTangent"
408 bl_label
= "PDT Tangents"
409 bl_space_type
= "VIEW_3D"
410 bl_region_type
= "UI"
412 bl_options
= {'DEFAULT_CLOSED'}
414 def draw(self
,context
):
416 pdt_pg
= context
.scene
.pdt_pg
418 if pdt_pg
.menu_expand
:
423 row
.label(text
=f
"Working {PDT_LAB_PLANE}:")
424 row
.prop(pdt_pg
, "plane", text
="")
426 row
.label(text
="Tangent Mode")
427 row
.prop(pdt_pg
, "tangent_mode", text
="")
429 row
.operator("pdt.tangentoperatesel", text
="Tangents from Selection", icon
="NONE")
431 row
.label(text
="Or Use Tangents From Inputs")
432 row
.operator("pdt.tangentexpandmenu", text
="", icon
=icon_e
)
436 split
= row
.split(factor
=0.35, align
=True)
437 split
.label(text
="Tangent Point")
438 split
.prop(pdt_pg
, "tangent_point2", text
="")
440 row
.operator("pdt.tangentset3", text
="from Cursor")
441 row
.operator("pdt.tangentset4", text
="from Vertex")
443 if pdt_pg
.menu_expand
:
446 split
= row
.split(factor
=0.35, align
=True)
447 split
.label(text
="Centre 1")
448 split
.prop(pdt_pg
, "tangent_point0", text
="")
450 split
= row
.split(factor
=0.45, align
=False)
451 split
.operator("pdt.tangentset1", text
="Set From Arc")
452 split
.prop(pdt_pg
, "tangent_radius0", text
="")
454 # Second Centre & Radius
456 split
= row
.split(factor
=0.35, align
=True)
457 split
.label(text
="Centre 2")
458 split
.prop(pdt_pg
, "tangent_point1", text
="")
460 split
= row
.split(factor
=0.45, align
=False)
461 split
.operator("pdt.tangentset2", text
="Set From Arc")
462 split
.prop(pdt_pg
, "tangent_radius1", text
="")
464 row
.operator("pdt.tangentoperate", text
="Tangents From Inputs", icon
="NONE")
466 class PDT_PT_PanelTrig(Panel
):
467 bl_idname
= "PDT_PT_PanelTrig"
468 bl_label
= "PDT Trigonometrical Waves"
469 bl_space_type
= "VIEW_3D"
470 bl_region_type
= "UI"
472 bl_options
= {'DEFAULT_CLOSED'}
474 def draw(self
,context
):
476 pdt_pg
= context
.scene
.pdt_pg
478 row
.label(text
=f
"Working {PDT_LAB_PLANE}:")
479 row
.prop(pdt_pg
, "plane", text
="")
482 split
= row
.split(factor
=0.5, align
=True)
483 split
.prop(pdt_pg
, "trig_type")
484 split
.prop(pdt_pg
, "trig_cycles")
486 split
= row
.split(factor
=0.5, align
=True)
487 split
.prop(pdt_pg
, "trig_amp")
488 split
.prop(pdt_pg
, "trig_len")
490 split
= row
.split(factor
=0.5, align
=True)
491 split
.prop(pdt_pg
, "trig_obj", text
="")
492 split
.prop(pdt_pg
, "trig_del")
494 split
= row
.split(factor
=0.5, align
=True)
495 split
.prop(pdt_pg
, "trig_res")
496 split
.prop(pdt_pg
, "trig_tanmax")
498 row
.prop(pdt_pg
, "trig_off")
500 row
.operator("pdt.wave_generator", icon
="SEQ_LUMA_WAVEFORM")
501 row
.prop(pdt_pg
, "trig_abs")