Source code for pohlke.utils.ui_shared

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

"""
Contains all ui functions for drawing interfaces
"""

from typing import Union
import bpy


[docs] def draw_axonometric_options( layout: bpy.types.UILayout, props: Union[bpy.types.PropertyGroup, bpy.types.Operator], operator: bool = False, ) -> None: """ Draw the axonometric projection options UI Parameters --------- layout : bpy.types.UILayout The Blender UI layout container in which the elements are drawn props : Union[bpy.types.PropertyGroup, bpy.types.Operator] The property group containing camera projection settings operator : bool If this function is used on Blender operator class (default : False) """ col = layout.column() col.prop(props, "axonometric_type") anglesRow = col.row(align=not operator) anglesRow.prop(props, "alpha") if not operator: anglesRow.operator("view3d.switch_angles", text="", icon="AREA_SWAP") anglesRow.prop(props, "beta") layout.separator() coordsRow = col.row() xCase = coordsRow.row() xCase.enabled = False xCase.prop(props, "normalized_x_value", text="X") yCase = coordsRow.row() yCase.enabled = False yCase.prop(props, "normalized_y_value", text="Y") zCase = coordsRow.row() zCase.enabled = False zCase.prop(props, "normalized_z_value", text="Z") altitudeAttribute = col.row() altitudeAttribute.enabled = False altitudeAttribute.prop(props, "altitude") rotationAttribute = col.row() rotationAttribute.enabled = False rotationAttribute.prop(props, "rotation")
[docs] def draw_oblique_options( layout: bpy.types.UILayout, props: Union[bpy.types.PropertyGroup, bpy.types.Operator], operator: bool = False, ) -> None: """ Draw the oblique projection options UI Parameters --------- layout : bpy.types.UILayout The Blender UI layout container in which the elements are drawn props : Union[bpy.types.PropertyGroup, bpy.types.Operator] The property group containing camera projection settings operator : bool If this function is used on Blender operator class (default : False) """ col = layout.column() col.prop(props, "oblique_type") anglesRow = col.row(align=not operator) anglesRow.prop(props, "alpha") if not operator: anglesRow.operator("view3d.switch_angles", text="", icon="AREA_SWAP") anglesRow.prop(props, "beta") layout.separator() coordsRow = col.row() xCase = coordsRow.row() xCase.enabled = False xCase.prop(props, "x_value", text="X") yCase = coordsRow.row() yCase.enabled = False yCase.prop(props, "y_value", text="Y") coordsRow.prop(props, "z_value", text="Z") obliqueAltitudeCase = col.row() obliqueAltitudeCase.enabled = False obliqueAltitudeCase.prop(props, "altitude_oblique", text="Altitude") obliqueRotationCase = col.row() obliqueRotationCase.enabled = False obliqueRotationCase.prop(props, "rotation")
[docs] def draw_create_cam_content( layout: bpy.types.UILayout, props: Union[bpy.types.PropertyGroup, bpy.types.Operator], containerType: str, ) -> None: """ Draw the projection options onto a Blender container (Operator or PropertyGroup) Parameters --------- layout : bpy.types.UILayout The Blender UI layout container in which the elements are drawn props : Union[bpy.types.PropertyGroup, bpy.types.Operator] The blender container containing camera projection settings containerType : str Type of blender container ("operator" or "property") """ row = layout.row(align=True) row.prop(props, "projection_type", expand=True) layout.separator() if props.projection_type == "AXONOMETRIC": draw_axonometric_options(layout, props, containerType == "operator") else: draw_oblique_options(layout, props, containerType == "operator") layout.separator() if containerType == "operator": col = layout.column() positionRow = col.row(align=True) positionRow.prop(props, "position", expand=True) orientationRow = col.row(align=True) orientationRow.prop(props, "orientation", expand=True) orthoScaleRow = col.row() orthoScaleRow.prop(props, "ortho_scale", expand=True) else: op = layout.operator("view3d.create_parallel_camera") op.projection_type = props.projection_type op.axonometric_type = props.axonometric_type op.oblique_type = props.oblique_type op.alpha = props.alpha op.beta = props.beta op.altitude = props.altitude op.altitude_oblique = props.altitude_oblique op.rotation = props.rotation op.x_value = props.x_value op.y_value = props.y_value op.z_value = props.z_value op.normalized_x_value = props.normalized_x_value op.normalized_y_value = props.normalized_y_value op.normalized_z_value = props.normalized_z_value