Source code for pohlke.gui

# SPDX-FileCopyrightText: 2021-2026 Julien Rippinger, Ian Bertin <alicelab.be>
#
# SPDX-License-Identifier: GPL-3.0-or-later

"""
Defines the main UI panel and menu entries for the add-on
"""

import bpy
from .utils.ui_shared import draw_create_cam_content
from math import radians

# -------------------------------------------------------------------
# GUI FUNCTIONS
# -------------------------------------------------------------------


[docs] def add_menu_func(self: bpy.types.Menu, context: bpy.types.Context) -> None: """ Add the Pohlke Cameras entry to Blender's camera add menu. Parameters --------- self : bpy.types.Menu The menu instance to which the entry is appended context : bpy.types.Context Blender context """ layout = self.layout layout.separator() op = layout.operator( "view3d.create_parallel_camera", text="Pohlke Camera", icon="CAMERA_DATA" ) op.projection_type = "AXONOMETRIC" op.axonometric_type = "AXONOMETRIC_#1" op.oblique_type = "OBLIQUE_#1" op.alpha = radians(30) op.beta = radians(30) op.altitude = radians(35.26) op.altitude_oblique = 0 op.rotation = radians(45) op.x_value = 0.82 op.y_value = 0.82 op.z_value = 0.82 op.normalized_x_value = 1.0 op.normalized_y_value = 1.0 op.normalized_z_value = 1.0
# ------------------------------------------------------------------- # GUI CLASSES # -------------------------------------------------------------------
[docs] class Pohlke_PT_projectionspanel(bpy.types.Panel): """ Main UI panel for creating parallel cameras in the 3D View sidebar. This panel displays projection options and delegates the UI drawing to shared functions. """ bl_idname = "POHLKE_PT_Camera_Panel" bl_label = "Pohlke Cameras" bl_category = "Pohlke" bl_space_type = "VIEW_3D" bl_region_type = "UI"
[docs] def draw(self, context: bpy.types.Context) -> None: """ Draw the panel interface, thanks to :py:func:`pohlke.utils.ui_shared.draw_create_cam_content`. Parameters --------- context : bpy.types.Context Blender context containing scene and UI state """ layout = self.layout props = context.scene.pohlke_camera_props draw_create_cam_content(layout, props, "property")
# ------------------------------------------------------------------- # REGISTRATION # ------------------------------------------------------------------- _classes = (Pohlke_PT_projectionspanel,) _register, _unregister = bpy.utils.register_classes_factory(_classes)
[docs] def register() -> None: """ Register the panel and menu classes to Blender. Also appends the custom menu entry to the VIEW3D camera add menu. """ _register() bpy.types.VIEW3D_MT_camera_add.append(add_menu_func)
[docs] def unregister() -> None: """ Unregister the panel and menu classes from Blender. Also removes the custom menu entry from the VIEW3D camera add menu. """ _unregister() bpy.types.VIEW3D_MT_camera_add.remove(add_menu_func)