pohlke.utils.data#

Defines projection presets used by the Parallel Cameras add-on.

This module centralizes all predefined projection configurations. Each preset defines angular parameters and projection mode metadata.

Attributes#

current_folder

The current folder

toml_file_path

The full file path

CAMERA_SETTINGS

The main instance CAMERA_SETTINGS

Classes#

CameraPreset

Type of camera settings

CameraSettings

Catalog of camera presets.

Module Contents#

class pohlke.utils.data.CameraPreset[source]#

Bases: TypedDict

Type of camera settings

Attributes#

namestr

Human-readable preset name displayed in UI.

alphafloat

First projection angle in a plane, between Z and X (radians).

betafloat

Second projection angle in a plane, between Z and Y (radians).

isObliquebool
  • False → Axonometric projection

  • True → Oblique projection

shorteningfloat

Reduction factor for the Z axis (only for oblique projection)

Examples#

>>> example_of_camera: CameraPreset = {
>>>     "name" : "Isometric",
>>>     "alpha" : radians(30),
>>>     "beta" : radians(30),
>>>     "isOblique": False
>>>     "shortening": 0
>>> }
class pohlke.utils.data.CameraSettings(file_path: pathlib.Path)[source]#

Catalog of camera presets. It reads and processes a TOML file containing projection data.

Attributes#

presets: dict[str, dict[str, CameraPreset]]

The dictionnary of all projections, regrouped by type “AXONOMETRIC” or “OBLIQUE”

Examples#

>>> # Example of presets.toml :
>>> #
>>> # [AXONOMETRIC]
>>> # "Isometric (30°/30°)" = { alpha = 30, beta = 30 }
>>> #
>>> # [OBLIQUE]
>>> # "Military" = {alpha = 60, beta = 30, shortening = 1 }
>>> # "Military Shortened" = {alpha = 60, beta = 30, shortening = 0.75 }
>>>
>>> current_folder = pathlib.Path(__file__).resolve().parent
>>> toml_file_path = current_folder / "presets.toml"
>>> CAMERA_SETTINGS = CameraSettings.from_toml(toml_file_path)
>>> print(CAMERA_SETTINGS.get_presets)
{
    "AXONOMETRIC": {
        'Isometric (30°/30°)': {
            'alpha': 30,
            'beta': 30
        }
    },
    "OBLIQUE": {
        'Military': {
            'alpha': 60,
            'beta': 30,
            'shortening': 1
        },
        'Military Shortened': {
            'alpha': 60,
            'beta': 30,
            'shortening': 0.75
        }
    }
}
classmethod from_toml(file_path) None[source]#
property axonometric: dict[source]#

Get the axonometric presets

property oblique: dict[source]#

Get the oblique presets

property get_presets: dict[str, dict[str, CameraPreset]][source]#

Get the presets

get_preset_menu_items(preset_type: str) dict[str, CameraPreset][source]#

Build the axonometric or oblique presets dropdown menu list.

Parameters#

preset_type: str

The type of projection (“AXONOMETRIC” or “OBLIQUE”)

Returns#

dict[str, CameraPreset]

The dropdown list of presets of the requested type

Examples#

>>> # Example of presets.toml :
>>> #
>>> # [AXONOMETRIC]
>>> # "Isometric (30°/30°)" = { alpha = 30, beta = 30 }
>>> #
>>> # [OBLIQUE]
>>> # "Military" = {alpha = 60, beta = 30, shortening = 1 }
>>> # "Military Shortened" = {alpha = 60, beta = 30, shortening = 0.75 }
>>>
>>> #Initialization of CAMERA_SETTINGS
>>> current_folder = pathlib.Path(__file__).resolve().parent
>>> toml_file_path = current_folder / "presets.toml"
>>> CAMERA_SETTINGS = CameraSettings.from_toml(toml_file_path)
>>>
>>> print(CAMERA_SETTINGS.get_preset_menu_items("AXONOMETRIC"))
"AXONOMETRIC_#1": {
    name :'Isometric (30°/30°)',
    'alpha': radians(30),
    'beta': radians(30),
    'isOblique': False
    'shortening': 0
},
>>> print(CAMERA_SETTINGS.get_preset_menu_items("OBLIQUE"))
"OBLIQUE_#1": {
    name :'Military',
    'alpha': radians(60),
    'beta': radians(30),
    'isOblique': True
    'shortening': 1.0
},
"OBLIQUE_#2": {
    name :'Military Shortened',
    'alpha': radians(60),
    'beta': radians(30),
    'isOblique': True
    'shortening': 0.75
}
get_preset_name(preset_type, alpha_rad: float, beta_rad: float, shortening: float) str[source]#

Get the preset associated with alpha and beta angles

Parameters#

projection_typestr

THe type of projection (AXONOMETRIC or OBLIQUE)

alpha_radfloat

The alpha angle of the plan (in radians)

beta_radfloat

The beta angle of the plan (in radians)

shorteningfloat

Reduction factor for the Z axis (only for oblique projection, 0 for axonometric projection)

Returns#

str

The preset associated with the parameters or “CUSTOM” if no corresponding preset

Example#

>>> from math import radians
>>> #Initialization of parameters
>>> projection_type = "AXONOMETRIC"
>>> alpha_rad = radians(30)
>>> beta_rad = radians(30)
>>> #Initialization of CAMERA_SETTINGS
>>> current_folder = pathlib.Path(__file__).resolve().parent
>>> toml_file_path = current_folder / "presets.toml"
>>> CAMERA_SETTINGS = CameraSettings.from_toml(toml_file_path)
>>> camera_type = CAMERA_SETTINGS.get_preset_name(projection_type, alpha_rad, beta_rad, 0)
>>> print(camera_type)
ISOMETRIC
>>> alpha_rad = radians(38)
>>> beta_rad = radians(30)
>>> projection_type = "OBLIQUE"
>>> camera_type = CAMERA_SETTINGS.get_preset_name(projection_type, alpha_rad, beta_rad, 0)
>>> print(camera_type)
CUSTOM
pohlke.utils.data.current_folder[source]#

The current folder

pohlke.utils.data.toml_file_path[source]#

The full file path

pohlke.utils.data.CAMERA_SETTINGS[source]#

The main instance CAMERA_SETTINGS