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#
The current folder |
|
The full file path |
|
The main instance CAMERA_SETTINGS |
Classes#
Type of camera settings |
|
Catalog of camera presets. |
Module Contents#
- class pohlke.utils.data.CameraPreset[source]#
Bases:
TypedDictType 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 } } }
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