1 # ***** BEGIN GPL LICENSE BLOCK *****
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # ***** END GPL LICENCE BLOCK *****
20 # -----------------------------------------------------------------------
21 # Author: Alan Odom (Clockmender), Rune Morling (ermo) Copyright (c) 2019
22 # -----------------------------------------------------------------------
25 from bpy
.types
import Panel
26 from .pdt_msg_strings
import (
69 """Return the Width of the UI Panel.
78 area
= bpy
.context
.area
79 resolution
= bpy
.context
.preferences
.system
.ui_scale
81 for reg
in area
.regions
:
83 region_width
= reg
.width
88 class PDT_PT_PanelDesign(Panel
):
89 bl_idname
= "PDT_PT_PanelDesign"
90 bl_label
= "PDT Design Operations"
91 bl_space_type
= "VIEW_3D"
94 bl_options
= {'DEFAULT_CLOSED'}
96 def draw(self
, context
):
97 ui_cutoff
= bpy
.context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
99 pdt_pg
= context
.scene
.pdt_pg
103 row
.label(text
=f
"Working {PDT_LAB_PLANE}:")
104 row
.prop(pdt_pg
, "plane", text
="")
108 row
.label(text
=f
"Move {PDT_LAB_MODE}:")
109 row
.prop(pdt_pg
, "select", text
="")
111 # Active or All Selected
114 row
.prop(pdt_pg
, "extend", text
="All Selected Entities (Off: Active Only)")
116 # --------------------
117 # (1) Select Operation
121 row
.label(text
=f
"(1) Select {PDT_LAB_OPERATION}:")
122 row
.prop(pdt_pg
, "operation", text
="")
124 # -----------------------
125 # (a) Set Coordinates box
128 box_1a
.label(text
=f
"(a) Either Set Coordinates + [Place »]")
129 # ^ was PDT_LAB_VARIABLES
131 # cartesian input coordinates in a box
135 split
= row
.split(factor
=0.35, align
=True)
136 split
.label(text
=PDT_LAB_CVALUE
)
137 split
.prop(pdt_pg
, "cartesian_coords", text
="")
139 row
.operator("pdt.absolute", icon
="EMPTY_AXIS", text
=f
"{PDT_LAB_ABS} »")
140 row
.operator("pdt.delta", icon
="EMPTY_AXIS", text
=f
"{PDT_LAB_DEL} »")
142 # directional input coordinates in a box
145 #box.label(text="Directional/Polar Coordinates:")
147 row
.prop(pdt_pg
, "distance", text
=PDT_LAB_DISVALUE
)
148 row
.prop(pdt_pg
, "angle", text
=PDT_LAB_ANGLEVALUE
)
150 row
.operator("pdt.distance", icon
="EMPTY_AXIS", text
=f
"{PDT_LAB_DIR} »")
151 row
.prop(pdt_pg
, "flip_angle", text
=PDT_LAB_FLIPANGLE
)
153 # ---------------------
154 # (b) Miscellaneous box
157 box_1b
.label(text
="(b) Or Select |n| Entities + [Place »]")
159 # normal or arc centre
161 row
.operator("pdt.normal", text
=f
"|3| {PDT_LAB_NOR} »")
162 row
.operator("pdt.centre", text
=f
"|3| {PDT_LAB_ARCCENTRE} »")
167 row
.operator("pdt.intersect", text
=f
"|4| {PDT_LAB_INTERSECT} »")
168 if ui_width() < ui_cutoff
:
170 row
.prop(pdt_pg
, "object_order", text
=PDT_LAB_ORDER
)
175 box
.label(text
=f
"Do (1) at % between selected points")
177 row
.operator("pdt.percent", text
=f
"|2| % »")
178 row
.prop(pdt_pg
, "percent", text
=PDT_LAB_PERCENTS
)
179 if ui_width() < ui_cutoff
:
181 row
.prop(pdt_pg
, "flip_percent", text
=PDT_LAB_FLIPPERCENT
)
183 class PDT_PT_PanelTools(Panel
):
184 bl_idname
= "PDT_PT_PanelTools"
185 bl_label
= "PDT Design Tools"
186 bl_space_type
= "VIEW_3D"
187 bl_region_type
= "UI"
189 bl_options
= {'DEFAULT_CLOSED'}
191 def draw(self
, context
):
192 ui_cutoff
= bpy
.context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
194 pdt_pg
= context
.scene
.pdt_pg
198 row
.label(text
=PDT_LAB_TOOLS
)
200 row
.operator("pdt.origin", text
=PDT_LAB_ORIGINCURSOR
)
202 row
.operator("pdt.angle2", text
=PDT_LAB_AD2D
)
203 row
.operator("pdt.angle3", text
=PDT_LAB_AD3D
)
205 row
.operator("pdt.join", text
=PDT_LAB_JOIN2VERTS
)
206 row
.operator("pdt.linetobisect", text
=PDT_LAB_BISECT
)
208 row
.operator("pdt.edge_to_face", text
=PDT_LAB_EDGETOEFACE
)
209 row
.operator("pdt.intersectall", text
=PDT_LAB_INTERSETALL
)
214 row
.operator("pdt.taper", text
=PDT_LAB_TAPER
)
215 row
.prop(pdt_pg
, "taper", text
=PDT_LAB_TAPERAXES
)
220 row
.operator("pdt.fillet", text
=f
"{PDT_LAB_FILLET}")
221 row
.prop(pdt_pg
, "fillet_intersect", text
="Intersect")
223 row
.prop(pdt_pg
, "fillet_radius", text
=PDT_LAB_RADIUS
)
224 row
.prop(pdt_pg
, "fillet_profile", text
=PDT_LAB_PROFILE
)
226 row
.prop(pdt_pg
, "fillet_segments", text
=PDT_LAB_SEGMENTS
)
227 row
.prop(pdt_pg
, "fillet_vertices_only", text
=PDT_LAB_USEVERTS
)
230 class PDT_PT_PanelPivotPoint(Panel
):
231 bl_idname
= "PDT_PT_PanelPivotPoint"
232 bl_label
= "PDT Pivot Point"
233 bl_space_type
= "VIEW_3D"
234 bl_region_type
= "UI"
236 bl_options
= {'DEFAULT_CLOSED'}
238 def draw(self
, context
):
239 ui_cutoff
= bpy
.context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
240 pdt_pg
= context
.scene
.pdt_pg
244 if context
.window_manager
.pdt_run_opengl
is False:
250 col
.operator("pdt.modaldraw", icon
=icon
, text
=txt
)
252 col
.prop(pdt_pg
, "pivot_size", text
=PDT_LAB_PIVOTSIZE
)
253 if ui_width() < ui_cutoff
:
256 col
.prop(pdt_pg
, "pivot_width", text
=PDT_LAB_PIVOTWIDTH
)
258 col
.prop(pdt_pg
, "pivot_alpha", text
=PDT_LAB_PIVOTALPHA
)
260 split
= row
.split(factor
=0.35, align
=True)
261 split
.label(text
=PDT_LAB_PIVOTLOCH
)
262 split
.prop(pdt_pg
, "pivot_loc", text
=PDT_LAB_PIVOTLOC
)
265 col
.operator("pdt.pivotselected", icon
="EMPTY_AXIS", text
="Selection")
267 col
.operator("pdt.pivotcursor", icon
="EMPTY_AXIS", text
="Cursor")
269 col
.operator("pdt.pivotorigin", icon
="EMPTY_AXIS", text
="Origin")
272 col
.operator("pdt.viewplanerot", icon
="EMPTY_AXIS", text
="Rotate")
274 col
.prop(pdt_pg
, "pivot_ang", text
="Angle")
277 col
.operator("pdt.viewscale", icon
="EMPTY_AXIS", text
="Scale")
279 col
.operator("pdt.cursorpivot", icon
="EMPTY_AXIS", text
="Cursor To Pivot")
282 col
.prop(pdt_pg
, "pivot_dis", text
="Scale Distance")
284 col
.prop(pdt_pg
, "distance", text
="System Distance")
286 split
= row
.split(factor
=0.35, align
=True)
287 split
.label(text
="Scale")
288 split
.prop(pdt_pg
, "pivot_scale", text
="")
291 col
.operator("pdt.pivotwrite", icon
="FILE_TICK", text
="PP Write")
293 col
.operator("pdt.pivotread", icon
="FILE", text
="PP Read")
296 class PDT_PT_PanelPartsLibrary(Panel
):
297 bl_idname
= "PDT_PT_PanelPartsLibrary"
298 bl_label
= "PDT Parts Library"
299 bl_space_type
= "VIEW_3D"
300 bl_region_type
= "UI"
302 bl_options
= {'DEFAULT_CLOSED'}
304 def draw(self
, context
):
305 ui_cutoff
= context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
307 pdt_pg
= context
.scene
.pdt_pg
309 row
.prop(pdt_pg
, "pdt_library_path")
312 col
.operator("pdt.append", text
="Append")
314 col
.operator("pdt.link", text
="Link")
315 if ui_width() < ui_cutoff
:
318 col
.prop(pdt_pg
, "lib_mode", text
="")
322 col
.label(text
="Objects")
324 col
.prop(pdt_pg
, "object_search_string")
326 row
.prop(pdt_pg
, "lib_objects", text
="")
330 col
.label(text
="Collections")
332 col
.prop(pdt_pg
, "collection_search_string")
334 row
.prop(pdt_pg
, "lib_collections", text
="")
338 col
.label(text
="Materials")
340 col
.prop(pdt_pg
, "material_search_string")
342 row
.prop(pdt_pg
, "lib_materials", text
="")
344 #row.operator("pdt.lib_show", text="Load Library File", icon='INFO')
347 class PDT_PT_PanelViewControl(Panel
):
348 bl_idname
= "PDT_PT_PanelViewControl"
349 bl_label
= "PDT View Control"
350 bl_space_type
= "VIEW_3D"
351 bl_region_type
= "UI"
353 bl_options
= {'DEFAULT_CLOSED'}
355 # Sub-layout highlight states
356 _ui_groups
= [False, False]
358 def draw(self
, context
):
359 ui_cutoff
= context
.preferences
.addons
[__package__
].preferences
.pdt_ui_width
361 ui_groups
= self
._ui
_groups
362 pdt_pg
= context
.scene
.pdt_pg
366 col
.label(text
="View Rotation")
368 col
.operator("pdt.viewrot", text
="Rotate Abs")
370 split
= row
.split(factor
=0.35, align
=True)
371 split
.label(text
="Rotation")
372 split
.prop(pdt_pg
, "rotation_coords", text
="")
375 col
.prop(pdt_pg
, "vrotangle", text
="Angle")
376 if ui_width() < ui_cutoff
:
379 col
.operator("pdt.viewleft", text
="", icon
="TRIA_LEFT")
381 col
.operator("pdt.viewright", text
="", icon
="TRIA_RIGHT")
383 col
.operator("pdt.viewup", text
="", icon
="TRIA_UP")
385 col
.operator("pdt.viewdown", text
="", icon
="TRIA_DOWN")
387 col
.operator("pdt.viewroll", text
="", icon
="RECOVER_LAST")
390 col
.operator("pdt.viewiso", text
="Isometric")
392 col
.operator("pdt.reset_3d_view", text
="Reset View")
395 class PDT_PT_PanelCommandLine(Panel
):
396 bl_idname
= "PDT_PT_PanelCommandLine"
397 bl_label
= "PDT Command Line (? for help)"
398 bl_space_type
= "VIEW_3D"
399 bl_region_type
= "UI"
401 bl_options
= {'DEFAULT_CLOSED'}
403 def draw(self
, context
):
405 pdt_pg
= context
.scene
.pdt_pg
408 col
.prop(pdt_pg
, "plane", text
="Plane")
410 col
.prop(pdt_pg
, "select", text
="Mode")
412 row
.label(text
="Comand Line, uses Plane & Mode Options")
414 row
.prop(pdt_pg
, "command", text
="")
416 row
.operator("pdt.command_rerun", text
="", icon
="LOOP_BACK")
418 row
.prop(pdt_pg
, "maths_output", text
="Maths Output")
420 class PDT_PT_PanelTangent(Panel
):
421 bl_idname
= "PDT_PT_PanelTangent"
422 bl_label
= "PDT Tangents"
423 bl_space_type
= "VIEW_3D"
424 bl_region_type
= "UI"
426 bl_options
= {'DEFAULT_CLOSED'}
428 def draw(self
,context
):
430 pdt_pg
= context
.scene
.pdt_pg
432 if pdt_pg
.menu_expand
:
437 row
.label(text
=f
"Working {PDT_LAB_PLANE}:")
438 row
.prop(pdt_pg
, "plane", text
="")
440 row
.label(text
="Tan Mode")
441 row
.prop(pdt_pg
, "tangent_mode", text
="")
443 row
.operator("pdt.tangentoperatesel", text
="Tangents from Selection", icon
="NONE")
445 row
.label(text
="Or Use Tangents From Inputs")
446 row
.operator("pdt.tangentexpandmenu", text
="", icon
=icon_e
)
450 split
= row
.split(factor
=0.35, align
=True)
451 split
.label(text
="Tan Point")
452 split
.prop(pdt_pg
, "tangent_point2", text
="")
454 row
.operator("pdt.tangentset3", text
="from Cursor")
455 row
.operator("pdt.tangentset4", text
="from Vertex")
457 if pdt_pg
.menu_expand
:
460 split
= row
.split(factor
=0.35, align
=True)
461 split
.label(text
="Centre 1")
462 split
.prop(pdt_pg
, "tangent_point0", text
="")
464 split
= row
.split(factor
=0.45, align
=False)
465 split
.operator("pdt.tangentset1", text
="Set From Arc")
466 split
.prop(pdt_pg
, "tangent_radius0", text
="")
468 # Second Centre & Radius
470 split
= row
.split(factor
=0.35, align
=True)
471 split
.label(text
="Centre 2")
472 split
.prop(pdt_pg
, "tangent_point1", text
="")
474 split
= row
.split(factor
=0.45, align
=False)
475 split
.operator("pdt.tangentset2", text
="Set From Arc")
476 split
.prop(pdt_pg
, "tangent_radius1", text
="")
478 row
.operator("pdt.tangentoperate", text
="Tangents From Inputs", icon
="NONE")
480 class PDT_PT_PanelTrig(Panel
):
481 bl_idname
= "PDT_PT_PanelTrig"
482 bl_label
= "PDT Trigonometrical Waves"
483 bl_space_type
= "VIEW_3D"
484 bl_region_type
= "UI"
486 bl_options
= {'DEFAULT_CLOSED'}
488 def draw(self
,context
):
490 pdt_pg
= context
.scene
.pdt_pg
492 row
.label(text
=f
"Working {PDT_LAB_PLANE}:")
493 row
.prop(pdt_pg
, "plane", text
="")
496 split
= row
.split(factor
=0.5, align
=True)
497 split
.prop(pdt_pg
, "trig_type")
498 split
.prop(pdt_pg
, "trig_cycles")
500 split
= row
.split(factor
=0.5, align
=True)
501 split
.prop(pdt_pg
, "trig_amp")
502 split
.prop(pdt_pg
, "trig_len")
504 split
= row
.split(factor
=0.5, align
=True)
505 split
.prop(pdt_pg
, "trig_obj", text
="")
506 split
.prop(pdt_pg
, "trig_del")
508 split
= row
.split(factor
=0.5, align
=True)
509 split
.prop(pdt_pg
, "trig_res")
510 split
.prop(pdt_pg
, "trig_tanmax")
512 row
.prop(pdt_pg
, "trig_off")
514 row
.operator("pdt.wave_generator", icon
="SEQ_LUMA_WAVEFORM")
515 row
.prop(pdt_pg
, "trig_abs")