app.ui.creators package#
Submodules#
app.ui.creators.project_creator module#
- class app.ui.creators.project_creator.ProjectCreator(project_folder)[source]#
Bases:
QMainWindowProjectCreator Class#
This class defines the main GUI window for the FlapKine project creation module.
It enables importing or generating scene data, configuring essential parameters such as video resolution, camera and lighting setup, STL output, and reflection properties, and finalizing the project setup with or without default configuration profiles.
- project_folder#
Path to the directory where the new project will be initialized.
- Type:
str
Custom top menu bar that handles application-level actions like exit or minimize.
- Type:
- text_editor_scene#
Input field for the path of the scene file to import.
- Type:
QLineEdit
- open_button#
Opens a file dialog to import a scene.
- Type:
QPushButton
- create_button#
Launches the CreateScene window to generate a new scene.
- Type:
QPushButton
- default_config_checkbox#
Enables or disables using default configuration settings.
- Type:
QCheckBox
- import_config_button#
Button to initiate creation of a custom configuration profile.
- Type:
QPushButton
- config_group#
Group box containing all video, camera, and light configuration controls.
- Type:
QGroupBox
- frame_format#
Dropdown menu for selecting video frame format (e.g., PNG, JPEG).
- Type:
QComboBox
- resolution_x#
Sets the horizontal resolution of the output video.
- Type:
QSpinBox
- resolution_y#
Sets the vertical resolution of the output video.
- Type:
QSpinBox
- camera_location_x#
- Type:
QDoubleSpinBox
- camera_location_y#
- Type:
QDoubleSpinBox
- camera_location_z#
Spin boxes for defining camera position in 3D space.
- Type:
QDoubleSpinBox
- camera_rotation_alpha#
- Type:
QDoubleSpinBox
- camera_rotation_beta#
- Type:
QDoubleSpinBox
- camera_rotation_gamma#
Spin boxes for defining camera rotation angles (Roll α, Pitch ÎČ, Yaw Îł).
- Type:
QDoubleSpinBox
- light_location_x#
- Type:
QDoubleSpinBox
- light_location_y#
- Type:
QDoubleSpinBox
- light_location_z#
Spin boxes for defining light position in 3D space.
- Type:
QDoubleSpinBox
- light_power#
Sets the power level of the scene lighting.
- Type:
QSpinBox
- stl_enable#
Enables STL file generation for the final output.
- Type:
QCheckBox
- reflect_xy#
- Type:
QCheckBox
- reflect_yz#
- Type:
QCheckBox
- reflect_xz#
Checkboxes to enable reflection across the XY, YZ, or XZ planes respectively.
- Type:
QCheckBox
- ok_button#
Finalizes the creation of the project with all selected settings.
- Type:
QPushButton
- __init__(project_folder: str):
Initializes the window and sets up the user interface and interactions.
- initUI():
Composes and organizes the complete interface layout.
- setup_central_widget():
Defines the central widget and primary layout structure.
- setup_scene_import(primary_color: str):
Initializes the section for importing or creating scenes.
- setup_config_options():
Adds toggle options for using default or custom configurations.
- setup_config_group(primary_color: str):
Builds the configuration container for video, camera, and light settings.
- setup_video_settings():
Adds UI elements related to video format and resolution.
- setup_resolution_inputs():
Assembles spin boxes for video resolution input.
- setup_camera_settings():
Adds input fields for configuring camera position and orientation.
- add_camera_controls(location_layout: QHBoxLayout, rotation_layout: QHBoxLayout):
Populates the camera control section with coordinate and rotation controls.
- setup_light_settings():
Adds input fields for configuring light source position and power.
- setup_other_settings():
Adds extra controls for STL export and axis-based reflection.
- import_scene():
Opens a file dialog to allow users to select and import a scene file.
- create_scene():
Opens the CreateScene interface for building new scenes.
- on_scene_created(scene_data: dict):
Callback function that processes newly created scene data.
- process_default_config():
Loads and applies default configuration presets.
- create_new_config():
Opens the interface for defining a new custom configuration.
- create_the_project():
Consolidates all inputs and generates the project directory and metadata.
- center():
Moves the window to the center of the userâs screen.
- toggle_checkboxes(checked_box: QCheckBox):
Ensures only one axis reflection checkbox can be active at a time.
- about_button_fun():
Displays application and author information in an About dialog.
- about_button_fun()[source]#
Displays an âAbout FlapKineâ information dialog.
Shows details about the developer, version, and purpose of the application.
- add_camera_controls(location_layout, rotation_layout)[source]#
Adds camera position and rotation controls to the given layouts.
Dynamically creates labeled QDoubleSpinBox widgets for both camera location (X, Y, Z) and rotation (Roll α, Pitch ÎČ, Yaw Îł), and assigns them to class attributes for access.
- Parameters:
location_layout (QHBoxLayout) â Layout to which camera location widgets are added.
rotation_layout (QHBoxLayout) â Layout to which camera rotation widgets are added.
- SpinBoxes Created:
Location: camera_location_x, camera_location_y, camera_location_z (range: -1000 to 1000)
Rotation: camera_rotation_alpha, camera_rotation_beta, camera_rotation_gamma (range: -360 to 360)
- center()[source]#
Centers the application window on the screen.
Calculates screen and window dimensions, then moves the window to the center position.
- create_new_config()[source]#
Initializes a blank configuration setup for a new project.
When the âNew Configâ toggle button is enabled, this method populates all relevant input fields with baseline default values, effectively clearing any previous data and preparing the UI for a new configuration. If the toggle is disabled, the configuration group is disabled.
- Behavior:
Resets video resolution to 640x480.
Sets all camera position and rotation spinboxes to 0.
Resets light position and power to 0.
Disables all reflection checkboxes and STL saving option.
Enables or disables the configuration group box accordingly.
- UI Elements Updated:
frame_format
resolution_x, resolution_y
camera_location_x/y/z
camera_rotation_alpha/beta/gamma
light_location_x/y/z
light_power
reflect_xy, reflect_yz, reflect_xz
stl_enable
config_group (enabled/disabled)
- create_scene()[source]#
Opens the scene creation window.
Launches a CreateScene dialog and connects its sceneCreated signal to the on_scene_created handler.
- create_the_project()[source]#
Finalizes and creates the project with the configured scene and settings.
This method performs the full setup of the project directory, including: - Directory structure creation for videos, and data. - Copying or serializing the scene file into the project folder. - Saving a configuration JSON file based on current UI state. - Launching the project rendering window.
- Project Structure Created:
- <project_folder>/
âââ scene.pkl âââ config.json âââ data/
âââ videos/
- Configuration Saved (config.json):
- VideoRender:
OutputPath: âdata/imagesâ
STLPath: âdata/stlâ
FrameFormat: selected from dropdown
resolution_x/y: selected resolution values
film_transparent: fixed as False
- Camera:
location: (x, y, z) position
rotation_euler: (alpha, beta, gamma) angles
- Light:
location: (x, y, z) position
energy: integer power value
STL: Boolean, from checkbox
Reflect: âXYâ, âYZâ, âXZâ or None based on user selection
- Behavior:
If scene_data exists, it is pickled and saved.
Otherwise, the provided .pkl scene file is copied to the project folder.
After setup, a new ProjectWindow instance is launched and the current window is closed.
- import_scene()[source]#
Opens a file dialog to import a scene .pkl file.
Sets the selected file path in the scene input field and updates the open buttonâs appearance.
- initUI()[source]#
Sets up the main UI layout for the Project Creator window.
- Constructs and arranges the primary user interface elements required for setting up a FlapKine project:
Scene Import Section: For importing or creating a scene file.
Configuration Options: Enables toggling between default and custom configuration.
Configuration Group: Contains settings for video format, camera, and lighting.
Other Settings: Includes STL export toggle and reflection axis checkboxes.
Final Action Button: âCreate Projectâ button to confirm and finalize project setup.
The method also centers the window on screen and dynamically uses the current paletteâs primary color to style relevant UI sections.
- Components Added to Main Layout:
Scene import widgets
Config options and grouped settings
STL and reflection options
âCreate Projectâ QPushButton (connected to create_the_project)
- on_scene_created(scene_data)[source]#
Handles the scene data returned from the scene creation window.
Stores the scene data and updates the âCreateâ buttonâs appearance to indicate success.
- process_default_config()[source]#
Applies default configuration settings from a JSON file.
If the âUse Default Configâ checkbox is checked, this method loads predefined configuration values from default_config.json and applies them to the respective input fields for video resolution, camera parameters, lighting, reflection axes, and STL export. If the checkbox is unchecked, the configuration section is disabled.
- Behavior:
Loads JSON from src/config/default_config.json.
Sets resolution (X, Y), camera location (X, Y, Z), and camera rotation (α, ÎČ, Îł).
Sets light position (X, Y, Z) and light power.
Configures reflection plane (XY, YZ, XZ) and STL checkbox state.
Enables or disables the configuration group box accordingly.
- UI Elements Updated:
frame_format
resolution_x, resolution_y
camera_location_x/y/z
camera_rotation_alpha/beta/gamma
light_location_x/y/z
light_power
reflect_xy, reflect_yz, reflect_xz
stl_enable
config_group (enabled/disabled)
- setup_camera_settings()[source]#
Sets up the camera configuration section within the config group.
Creates a stylized group box labeled âCamera Settingsâ containing controls for camera position and rotation. The layout is divided into two horizontal sections: one for camera location and another for rotation.
- Subcomponents Added:
Camera Location Controls: via add_camera_controls
Camera Rotation Controls: via add_camera_controls
Styled QGroupBox with bold teal border and custom title padding
The assembled group is added to the main configuration layout.
- setup_central_widget()[source]#
Configures the central widget and main layout of the Project Creator window.
Initializes the main UI container by setting a QWidget as the central widget of the main window. A vertical box layout (QVBoxLayout) is then assigned to this widget, serving as the base layout for all subsequent UI components in the application.
- Components Initialized:
central_widget: Main container widget for all UI elements.
main_layout: Vertical layout used to stack UI sections top-to-bottom.
- setup_config_group(primary_color)[source]#
Sets up the configuration group section.
Initializes the grouped container for all configuration settings including video, camera, and lighting controls. This section is disabled by default and is enabled upon creating a new custom configuration.
- Components Initialized:
config_group: QGroupBox titled âConfigurationsâ
- config_layout: Vertical layout containing:
Video settings (via setup_video_settings())
Camera settings (via setup_camera_settings())
Light settings (via setup_light_settings())
- setup_config_options()[source]#
Sets up configuration option widgets.
Initializes the interface section that allows the user to choose between using default configuration settings or creating a new custom configuration.
- Components Initialized:
default_config_checkbox: A checkbox to enable or disable usage of default config.
import_config_button: A toggle button to create a new custom configuration.
- Connections:
default_config_checkbox.stateChanged â process_default_config()
import_config_button.toggled â create_new_config()
- setup_light_settings()[source]#
Sets up the light configuration panel within the configuration layout.
Creates a styled QGroupBox labeled âLight Settingsâ, including controls for adjusting light location (X, Y, Z) and power level. Each axis input is represented by a QDoubleSpinBox, and power is controlled by a QSpinBox.
- UI Elements Initialized:
- Location:
X, Y, Z SpinBoxes (light_location_x, light_location_y, light_location_z)
Range: -1000 to 1000
- Power:
SpinBox light_power
Range: 0 to 10000
- Visual Styling:
Group title and border styled with orange tones for visual grouping.
- setup_other_settings()[source]#
Sets up additional configuration options under the âOther Settingsâ group.
Adds controls for STL file saving and axis reflection toggles. Includes checkboxes for reflecting the scene geometry about XY, YZ, and XZ planes, as well as a toggle for enabling STL export.
- UI Elements:
Save STL: Checkbox (stl_enable)
- Axis Reflection: Checkboxes (reflect_xy, reflect_yz, reflect_xz)
Each connected to toggle_checkboxes() for handling exclusive selection.
- Styling:
Group box styled in purple tones for clear visual separation.
- setup_resolution_inputs()[source]#
Adds input controls for setting video resolution.
Initializes two spin boxes for specifying horizontal (X) and vertical (Y) resolution values, and appends them to the resolution settings layout with appropriate labels.
- Components Initialized:
resolution_x: Spin box for horizontal resolution (0 to 1920)
resolution_y: Spin box for vertical resolution (0 to 1080)
Title label: âResolutionâ (Times, size 7)
- setup_scene_import(primary_color)[source]#
Creates the scene import section of the Project Creator window.
- Adds UI components for importing an existing scene file or creating a new one. This section includes:
A label indicating the purpose of the section.
A line edit to show or input the path to the scene file.
An âOpenâ button with folder icon to trigger a file dialog for scene selection.
A âCreateâ button with a plus-folder icon to open a scene creation interface.
Button click events are connected to respective handler methods (import_scene, create_scene).
- Components Added:
QLabel: âImport Sceneâ
QLineEdit: text_editor_scene for displaying scene path
QPushButton: open_button to import a file
QPushButton: create_button to create a new scene
HBox Layout: Wraps the above components horizontally and adds to the main layout
- Parameters:
primary_color (str) â The primary UI color used for icons in this section.
app.ui.creators.scene_creator module#
- class app.ui.creators.scene_creator.SceneCreator[source]#
Bases:
QMainWindowSceneCreator Class#
This class defines the GUI window for creating and importing a scene in the FlapKine application.
It allows users to add multiple sprites by either importing pre-saved .pkl scene files or creating new ones via a custom sprite builder. The final scene data is constructed from these sprites and emitted as a Scene object.
- sceneCreated#
Custom signal emitted with a Scene object after the scene is finalized.
- Type:
pyqtSignal
Top-level custom menu bar providing actions like minimize, maximize, restore, exit, and about.
- Type:
- main_widget#
Central widget containing the entire GUI layout.
- Type:
QWidget
- sprites_list_layout#
Layout to which all sprite group widgets (representing individual sprite entries) are added.
- Type:
QVBoxLayout
- sprite_list#
Holds sprite data objects that are either loaded from file or generated via UI.
- Type:
list
- text_editor_scene#
Input field for specifying or displaying the path of a sprite/scene file to import.
- Type:
QLineEdit
- open_button#
Opens a file dialog to import an existing .pkl scene file.
- Type:
QPushButton
- create_button#
Launches the sprite creation interface to build a new sprite and attach it to the scene.
- Type:
QPushButton
- window#
Instance of the SpriteCreator dialog window for generating new sprite data.
- Type:
- __init__():
Initializes the GUI, sets up the menu bar, central layout, and connects signals to handlers.
- initUI() QVBoxLayout:[source]#
Builds the core layout including sprite controls and an import button, and returns the root layout.
- add_sprite():
Dynamically creates a new sprite entry group with input fields and buttons for import or creation.
- import_sprite(sprite_group: QGroupBox):
Opens a file dialog to import a .pkl sprite file and sets the path in the associated input field.
- create_sprite(sprite_group: QGroupBox):
Opens a sprite creation window and connects its result to the current sprite group.
- save_sprite(sprite_group: QGroupBox):
Retrieves created sprite data from the sprite creation dialog and stores it for final scene building.
- drop_sprite():
Removes the last sprite group entry from the list, simulating a stack-based deletion of sprites.
- okay_button_fun():
Gathers all sprite data (from created or imported sources), builds a Scene object, emits it, and closes the window.
- center():
Centers the main window on the userâs screen using screen and window geometry.
- about_button_fun():
Displays an informational dialog with app version, developer info, and a description of FlapKineâs purpose.
- about_button_fun()[source]#
Displays an âAbout FlapKineâ information dialog.
Shows details about the developer, version, and purpose of the application.
- add_sprite()[source]#
Dynamically adds a new sprite input group to the scene creator layout.
Creates a labeled group box for each sprite, allowing the user to either import or create a new sprite scene. Each group includes a text field for naming the scene, along with âOpenâ and âCreateâ buttons connected to their respective handler functions.
- Components Added:
- QGroupBox: Labeled as âSprite <n>â, where n is the current sprite count
Font: Times, size 8
- Layout: QHBoxLayout containing:
- QLineEdit: For entering the scene name
Placeholder: âEnter Scene Nameâ
Font: Times, size 7
Expands horizontally
- QPushButton: âOpenâ
Icon: Folder open icon (color matched to palette foreground)
Connected to import_sprite with sprite group context
- QPushButton: âCreateâ
Icon: Folder plus icon (color matched to palette foreground)
Connected to create_sprite with sprite group context
Updates#
- self.sprites_list_layoutQVBoxLayout
Appends the newly created sprite group to the vertical sprite list layout.
- center()[source]#
Centers the application window on the screen.
Calculates screen and window dimensions, then moves the window to the center position.
- create_sprite(sprite_group)[source]#
Launches the sprite creation interface and connects the result to the given sprite group.
Opens a new SpriteCreator window that allows the user to build a custom sprite. Upon successful sprite creation (signaled via the SpriteCreated signal), the sprite data is passed to the save_sprite() method which updates the associated sprite_group.
- Parameters:
sprite_group (QGroupBox) â The sprite group container that will be updated with the created sprite information.
Behavior
--------
dialog. (- Initializes and displays a SpriteCreator)
that (- Connects the SpriteCreated signal to a lambda function) â
Triggers save_sprite(sprite_group) on sprite creation.
- drop_sprite()[source]#
Removes the most recently added sprite input group from the UI.
This method checks if any sprite input groups exist within the sprites_list_layout. If present, it removes the last added QGroupBox widget and schedules it for deletion, effectively updating the scene creator interface.
Behavior#
Identifies and removes the last widget in self.sprites_list_layout.
Ensures proper memory cleanup by calling deleteLater() on the removed widget.
- import_sprite(sprite_group)[source]#
Handles the import of a sprite scene from a .pkl file into the given sprite group.
Opens a file dialog for the user to select a pickle file representing a pre-saved sprite scene. Upon selection, the file path is displayed in the groupâs QLineEdit, and the corresponding âOpenâ button is visually updated to indicate success.
- Parameters:
sprite_group (QGroupBox) â The container widget representing a single sprite input group whose child widgets (text field and open button) are updated.
Behavior
--------
files. (- Launches a file dialog restricted to .pkl)
selected (- If a valid file is) â
Sets the file path in the QLineEdit of the group.
Changes the background color of the first QPushButton (assumed to be âOpenâ) to green.
- initUI() QVBoxLayout[source]#
Builds the user interface layout for the SceneCreator window.
Assembles the core layout for sprite management and scene import. This includes interactive controls for adding or removing sprite blocks, configuring scene entries, and finalizing the import process. All components are organized using vertical and horizontal layouts to ensure a structured and intuitive interface.
- UI Components:
- Sprite Controls GroupBox:
Title: âSprite Controlsâ
Font: Times, size 9
- Contains:
- Horizontal layout with:
QLabel: âManage Sprites:â
QPushButton: Add (connected to add_sprite)
QPushButton: Drop (connected to drop_sprite)
Vertical layout container for dynamically added sprite groups
- Import Scene Button:
Label: âImport Sceneâ
Font: Times, size 9
Style: Increased font size and padding
Connected to okay_button_fun to finalize and emit the scene
- Returns:
The main vertical layout containing all scene creation controls.
- Return type:
QVBoxLayout
- okay_button_fun()[source]#
Finalizes the scene creation and emits the constructed scene data.
This method processes all sprite input groups in the UI, loads their corresponding .pkl files (if not already loaded), and compiles them into a Scene object. Once constructed, the sceneCreated signal is emitted with the new scene, and the window is closed.
Behavior#
- Checks if self.sprite_list is empty:
If so, iterates through all sprite input widgets.
Extracts file paths from QLineEdit entries and loads corresponding .pkl data.
Appends loaded sprite data to self.sprite_list.
Instantiates a Scene object using the loaded sprite data.
Emits sceneCreated signal with the new Scene instance.
Closes the SceneCreator window.
- save_sprite(sprite_group)[source]#
Saves the newly created sprite and updates the corresponding UI group.
Retrieves the sprite data from the SpriteCreator window and appends it to the internal sprite list. Additionally, visually confirms sprite creation by updating the style of the âCreateâ button in the provided sprite_group.
- Parameters:
sprite_group (QGroupBox) â The UI container representing the sprite entry to be updated with visual feedback.
Behavior
--------
sprite_group. (- Changes the second QPushButton's background color to green within)
self.sprite_list. (- Appends the newly created sprite data (self.window.sprite_data) to)
- sceneCreated#
int = âŠ, arguments: Sequence = âŠ) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signalâs arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = âŠ, revision
app.ui.creators.sprite_creator module#
- class app.ui.creators.sprite_creator.SpriteCreator[source]#
Bases:
QMainWindowSpriteCreator Class#
This class provides the graphical interface for creating and configuring a 3D sprite within the FlapKine application. Users can import STL files, apply transformation types (translation, rotation, flexibility), and optionally use inverse kinematics data for automated rotation specification.
It also supports setting initial pose parameters and provides a 3D visualization of the configured object using VTK.
- SpriteCreated#
Signal emitted when the sprite is fully configured and ready.
- Type:
pyqtSignal
Custom menu bar for handling file-related and application-level actions.
- Type:
- sprite_name#
Input field for naming the 3D sprite.
- Type:
QLineEdit
- sprite_stl_path#
Path input for selecting and displaying the STL file to be imported.
- Type:
QLineEdit
- vtkWidget#
VTK widget used for interactive 3D rendering of the sprite object.
- Type:
QVTKRenderWindowInteractor
- ren#
VTK renderer object responsible for managing the scene display.
- Type:
vtkRenderer
- translation_transform#
Dropdown menu for selecting the translation transformation strategy.
- Type:
QComboBox
- rotation_transform#
Dropdown menu for selecting the rotation transformation strategy.
- Type:
QComboBox
- flexibility_transform#
Dropdown menu for selecting the flexibility transformation method.
- Type:
QComboBox
- enable_checkbox#
Checkbox to enable or disable the use of initial condition settings.
- Type:
QCheckBox
- position_x#
Spin box for specifying the initial X-axis position.
- Type:
QDoubleSpinBox
- position_y#
Spin box for specifying the initial Y-axis position.
- Type:
QDoubleSpinBox
- position_z#
Spin box for specifying the initial Z-axis position.
- Type:
QDoubleSpinBox
- angle_input_alpha#
Spin box for specifying the initial alpha (roll) angle in degrees.
- Type:
QDoubleSpinBox
- angle_input_beta#
Spin box for specifying the initial beta (pitch) angle in degrees.
- Type:
QDoubleSpinBox
- angle_input_gamma#
Spin box for specifying the initial gamma (yaw) angle in degrees.
- Type:
QDoubleSpinBox
- inverse_kinematics#
Boolean flag indicating whether inverse kinematics data is being utilized.
- Type:
bool
- __init__():
Initializes the main window, layout, and signal-slot connections.
- init_ui():
Builds and arranges all UI elements including transformation options and VTK visualization.
- init_menu():
Sets up the applicationâs menu bar and connects its functionalities.
- init_sprite_inputs():
Configures the sprite name and STL file input interface.
- init_transformations():
Builds the UI for configuring translation, rotation, and flexibility transformations.
- init_initial_conditions():
Creates the input controls for manually defining initial orientation and position.
- init_finish_controls():
Adds the âFinishâ button used to trigger the final sprite assembly.
- open_file():
Handles STL file selection and renders the model within the VTK viewport.
- calculate_inverse_kinematics():
Launches the inverse kinematics window and waits for processed data.
- process_inv_data():
Receives and stores the angles and order computed from inverse kinematics.
- finish_button_fun():
Compiles all transformation settings into a Sprite object and emits the creation signal.
- center():
Repositions the window to the center of the screen.
- about_button_fun():
Displays a dialog containing information about the FlapKine application.
- SpriteCreated#
int = âŠ, arguments: Sequence = âŠ) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signalâs arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = âŠ, revision
- about_button_fun()[source]#
Displays an âAbout FlapKineâ information dialog.
Shows details about the developer, version, and purpose of the application.
- calculate_inverse_kinematics()[source]#
Opens the Inverse Kinematics window and connects its output signal to the data processing slot.
This method initializes and displays the InvKineWindow, which is responsible for loading 3D coordinate data and computing Euler angles. Once the data is available, it emits the angle_data signal, which is connected to the process_inv_data method for handling.
Notes
The inverse kinematics data flow is fully asynchronous and signal-driven.
The method assumes process_inv_data is implemented and compatible with the signal payload.
- center()[source]#
Centers the application window on the screen.
Calculates screen and window dimensions, then moves the window to the center position.
- finish_button_fun()[source]#
Finalizes the creation of a Sprite object using user-specified inputs and transformations.
This function performs the following:
Retrieves the sprite name and STL file path from the UI.
Loads the STL mesh using numpy-stl.
- Extracts transformation data for:
Flexibility
Rotation
Translation
4. Optionally applies the inverse transformation to reset the mesh using the initial conditions if the enable_checkbox is checked. 5. Validates and prepares the full time series of rotation angles and COM positions. 6. Creates and emits a Sprite object containing the transformed mesh and associated data.
- Emits:
SpriteCreated (pyqtSignal): Emitted with the finalized Sprite object.
Notes
This method closes the GUI window upon completion.
The transformed mesh is reset using Translation_COM() and ConstantF()
when the inverse transformation option is enabled.
See also
_get_flexibility_transform
_get_rotation_transform
_get_translation_transform
_validate_angles_positions
_get_initial_conditions
- flexibility_transform_fun()[source]#
Handles the dynamic creation and display of flexibility transformation UI elements.
- Based on the selected transformation type, this method:
Removes any previously displayed flexibility transform group.
Checks the current index of the flexibility combo box.
Creates and displays the corresponding flexibility group box
for âFlexibleType1â or âFlexibleType2â.
- Conditions:
Index 1: Displays UI for âFlexibleType1â
Index 2: Displays UI for âFlexibleType2â
Other indices: No UI group is displayed
- UI Elements Managed:
Dynamically created group box via _create_flexibility_group_box
Primary color is derived from the applicationâs current foreground palette
- init_angle_group(parent_layout)[source]#
Initializes the Euler angle input group for the spriteâs initial orientation.
Constructs a QGroupBox titled âInitial Euler Anglesâ containing spin boxes for defining the initial rotational orientation using three Euler angles: Alpha, Beta, and Gamma. Each angle input is provided via a QDoubleSpinBox, allowing values in the range of -360° to 360°.
- Parameters:
parent_layout (The angle_group is added to the supplied) â The layout into which the angle group is inserted.
Initialized (Components) â
angle_input_alpha (QDoubleSpinBox): Input for the Alpha angle (°).
angle_input_beta (QDoubleSpinBox): Input for the Beta angle (°).
angle_input_gamma (QDoubleSpinBox): Input for the Gamma angle (°).
Signals
-------
emits (Each spin box) â
valueChanged: Connected to initial_condition_changed to propagate changes in orientation.
Styling (Visual) â
Purple-themed group box with bold headers and rounded styling.
Employs QFormLayout for structured alignment of angle labels and inputs.
Layout
------
parent_layout
section. (typically as part of the initial conditions)
- init_finish_controls()[source]#
Initializes the final control elements for sprite creation.
Adds a âFinishâ button to the main layout, enabling the user to complete and confirm the sprite configuration process. The button is connected to the finish_button_fun slot which handles the finalization logic.
- Components Initialized:
finish_button (QPushButton): Labeled âFinishâ, triggers completion of sprite setup.
Signals#
clicked: Connected to finish_button_fun to process and finalize sprite parameters.
Layout#
Appended directly to main_layout, positioned after all configuration groups.
- init_initial_conditions()[source]#
Initializes the initial conditions section for sprite setup.
Creates a QGroupBox titled âInitial Conditionsâ containing UI controls for setting the spriteâs starting position and orientation using position coordinates and Euler angles. These controls are grouped and managed through two sub-initialization functions: init_position_group() and init_angle_group().
By default, the entire group is disabled and can be toggled via a checkbox labeled âEnable Initial Conditionsâ, allowing optional setup of initial state parameters.
- Components Initialized:
group_2 (QGroupBox): Container for position and orientation fields.
- enable_checkbox (QCheckBox): Enables or disables the initial conditions group.
Connected to: enable_checkbox_fun()
Position Inputs: Initialized via init_position_group(), includes X, Y, Z spin boxes.
Euler Angle Inputs: Initialized via init_angle_group(), includes α (alpha), ÎČ (beta), Îł (gamma).
- Visual Styling:
Orange-colored themed group box with bold title and rounded border.
Uses QFormLayout for neatly aligned form-style UI.
- Layout:
Checkbox and group box are added to the main vertical layout (main_layout) for integration with the rest of the interface.
Initializes the custom menu bar for the SpriteCreator window.
Sets up a MenuBar instance and binds it to the main window. Connects core window control actions such as exit, minimize, maximize, restore, and about, ensuring responsive GUI behavior.
- Menu Actions Connected:
âexitâ: Closes the window
âminimizeâ: Minimizes the window
âmaximizeâ: Maximizes the window
ârestoreâ: Restores the window to its previous size
âaboutâ: Opens the About FlapKine information dialog
- init_position_group(parent_layout)[source]#
Initializes the position input group for the spriteâs initial body origin.
Creates a QGroupBox titled âInitial Position of Body Originâ that contains spin boxes for specifying the X, Y, and Z coordinates of the spriteâs starting location. Each coordinate input is represented using a QDoubleSpinBox with a value range from -100 to 100 meters.
- Parameters:
parent_layout (The position_group is appended to the) â The layout to which the initialized position group is added.
Initialized (Components) â
position_x (QDoubleSpinBox): Input for X-axis initial position (with âmâ suffix).
position_y (QDoubleSpinBox): Input for Y-axis initial position (with âmâ suffix).
position_z (QDoubleSpinBox): Input for Z-axis initial position (with âmâ suffix).
Signals
-------
to (Each spin box is connected) â
initial_condition_changed: Slot triggered when any position value changes.
Styling (Visual) â
Teal-themed group box with bold title and rounded border.
Uses QFormLayout for compact, readable alignment.
Layout
------
parent_layout
function. (which is passed from the calling)
- init_sprite_inputs()[source]#
Initializes the sprite input group (group_1) for 3D object configuration.
Creates a QGroupBox titled â3DObject Propertiesâ that allows users to input the sprite name and load an STL file. Also sets up a VTK render window for real-time 3D visualization of the imported mesh.
- Components Initialized:
sprite_name (QLineEdit): Input field for specifying the name of the sprite.
sprite_stl_path (QLineEdit): Displays the selected STL file path.
sprite_stl_open (QPushButton): Opens a file dialog to select STL file; uses FontAwesome icon.
vtkWidget (QVTKRenderWindowInteractor): Embedded VTK viewport for rendering the 3D mesh.
ren (vtkRenderer): VTK renderer managing scene rendering and background color.
Layouts: QFormLayout for form-like UI, and QHBoxLayout to hold path input and VTK widget.
- Visual Styling:
Group box styled with bold text, blue borders, and rounded corners.
Labels use âTimesâ font with consistent size and alignment.
- Connected Actions:
sprite_stl_open.clicked: Triggers open_file() to load and visualize the STL file.
- init_transformations()[source]#
Initializes the transformation controls for sprite configuration.
Creates a QGroupBox titled âTransformationsâ containing dropdowns for selecting different transformation modes: Translation, Rotation, and Flexibility. Each dropdown allows the user to choose a transformation strategy for the sprite and triggers an associated update function on change.
- Components Initialized:
- translation_transform (QComboBox): Allows selection of translation type (Constant, Linear).
Connected to: translation_transform_fun()
- rotation_transform (QComboBox): Allows selection of rotation mode (Constant, Euler_Angles, Custom).
Connected to: rotation_transform_fun()
- flexibility_transform (QComboBox): Allows selection of flexibility behavior (Constant, FlexibleType1, FlexibleType2, Custom).
Connected to: flexibility_transform_fun()
- Visual Styling:
Group box styled with teal-colored bold borders and rounded corners.
Labels use âTimesâ font for consistency.
Each control placed using QFormLayout for clean, form-like alignment.
- Layout:
All transformation controls are embedded within the existing layout of group_1.
- init_ui()[source]#
Constructs the main UI layout for the SpriteCreator window.
Initializes and assembles all primary UI sections including menu bar, sprite input fields, transformation configuration, initial conditions, and the finalization button. Also sets the central widget and applies the main layout for the application.
- UI Components Initialized:
primary_color: Derived from the applicationâs foreground role for consistent theming
menu_bar: Setup using init_menu()
main_layout: Vertical layout to stack sections
sprite_inputs: Initialized using init_sprite_inputs() for name and STL import
transformations: Configured using init_transformations() (translation, rotation, flexibility)
initial_conditions: Loaded using init_initial_conditions() for position and angle presets
finish_controls: Finalization controls set via init_finish_controls()
Central widget: Main QWidget container with layout applied
- initial_condition_changed()[source]#
Updates the 3D transform of the actor and body axes based on user-defined initial conditions.
This method reads the initial Euler angles (in degrees) and position vector from the GUI inputs, constructs corresponding VTK rotation and translation transforms, and applies the combined transform to the 3D actor and associated body axes.
Notes
Rotation is performed around X, Y, and Z axes in that order.
Transforms are post-multiplied to ensure correct order of translation followed by rotations.
The scene is re-rendered to reflect the updated transformation in the VTK widget.
- open_file()[source]#
Opens and loads an STL file for rendering using VTK.
This method prompts the user to select an STL file through a file dialog. Upon selection, it performs the following operations:
Sets the STL file path in the corresponding input field.
Loads the STL geometry using a VTK reader.
Creates a VTK actor from the STL data.
Computes bounding box dimensions to determine a suitable axis scale.
Creates and adds coordinate axes for both inertial and body frames.
Renders the scene in the VTK render window.
- Workflow Steps:
Show QFileDialog to select .stl file.
Load geometry using _load_stl_file().
Create visual actor via _create_actor_from_reader().
Generate axes using _create_axes_actor().
Final rendering prepared via _prepare_renderer_with_actors().
- Axes:
Inertial Axes: X, Y, Z (black)
Body Axes: A, B, C (black)
Notes
Early exit occurs if the user cancels file selection.
Actor bounds are used to normalize axis size for consistent visualization.
- open_m_values_fun()[source]#
Open a CSV file for M values and update the input field and button style.
- open_position_file()[source]#
Open a CSV file for COM position and update the input field and button color.
- open_rotation_alpha()[source]#
Open a CSV file for Alpha angle and update the UI with the selected path.
- open_rotation_beta()[source]#
Open a CSV file for Beta angle and update the UI with the selected path.
- open_rotation_gamma()[source]#
Open a CSV file for Gamma angle and update the UI with the selected path.
- process_inv_data()[source]#
Processes the Euler angle results from the inverse kinematics window.
This method retrieves computed angles and their rotation order from the InvKineWindow, disables the manual rotation input section to avoid conflict, and updates the rotation order in the UI.
Notes
Sets self.inverse_kinematics to True, indicating automatic angle data is now active.
Assumes that self.window.inv_result contains a tuple: (angles, order).
UI combo box is updated to reflect the computed rotation order.
- rotation_transform_fun()[source]#
Handle UI logic based on the selected rotation transform option.
If âEuler_Anglesâ is selected, adds an additional group box for configuring Euler angle parameters. If the selection is changed to another mode and a group box exists, it is removed to clean up the layout.
- translation_transform_fun()[source]#
Handles UI logic for the translation transform selection.
Clears any previously added translation UI components and conditionally adds a new group of widgets for configuring the translation transform, based on the current selection in the combo box.
- Behavior:
If the selected option is âLinearâ (index 1), a new translation configuration
group is created and added to the layout. - If âConstantâ (index 0), no additional UI is shown.
- Triggered when:
The user changes the selection in the translation transform combo box.