Skip to content
Merged
12 changes: 6 additions & 6 deletions docs/gui_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,17 @@ Sometimes, the value or visibility of one parameter depends on the value of anot

Example (based on pid):
``` python
def is_parameter_active(self, param_name: str, instance_values: Dict[str, Any]) -> bool:
def is_parameter_active(self, param_name: str, instance_params: Dict[str, Any]) -> bool:
if param_name == "Kp":
return instance_values["controller"] in ["P", "PI", "PD", "PID"]
return instance_params["controller"] in ["P", "PI", "PD", "PID"]
elif param_name == "Ki":
return instance_values["controller"] in ["I", "PI", "PID"]
return instance_params["controller"] in ["I", "PI", "PID"]
elif param_name == "Kd":
return instance_values["controller"] in ["PD", "PID"]
return super().is_parameter_active(param_name, instance_values)
return instance_params["controller"] in ["PD", "PID"]
return super().is_parameter_active(param_name, instance_params)
```
Explanation:
- `instance_values` contains the current values of all parameters for this block instance.
- `instance_params` contains the current values of all parameters for this block instance.
- The `controller` parameter determines which other parameters are active:
- if the controller type includes `P`, then `Kp` is active.
- if it includes `I`, then `Ki` is active.
Expand Down
2 changes: 1 addition & 1 deletion docs/uml/pySimBlocks-GUI.uxf
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ description: str
doc_path: Path | None
--
get_param(param_name: str) -> ParameterMeta | None
is_parameter_active(param_name: str, instance_values: Dict[str, Any]) -> bool
is_parameter_active(param_name: str, instance_params: Dict[str, Any]) -> bool
resolve_port_group(PortMeta, direction: str, BlockInstance) -> list[PortInstance]
build_ports(BlockInstance) -> list[PortInstance)
</panel_attributes>
Expand Down
2 changes: 1 addition & 1 deletion pySimBlocks/gui/addons/sofa/sofa_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from PySide6.QtCore import QProcess, QProcessEnvironment

from pySimBlocks.gui.model.project_state import ProjectState
from pySimBlocks.gui.models.project_state import ProjectState
from pySimBlocks.gui.project_controller import ProjectController
from pySimBlocks.gui.services.yaml_tools import save_yaml
from pySimBlocks.project.generate_sofa_controller import generate_sofa_controller
Expand Down
47 changes: 47 additions & 0 deletions pySimBlocks/gui/blocks/block_dialog_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ******************************************************************************
# pySimBlocks
# Copyright (c) 2026 Université de Lille & INRIA
# ******************************************************************************
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
# for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ******************************************************************************
# Authors: see Authors.txt
# ******************************************************************************

from pathlib import Path
from typing import TYPE_CHECKING

from PySide6.QtWidgets import QLineEdit

from pySimBlocks.gui.models.block_instance import BlockInstance

if TYPE_CHECKING:
from pySimBlocks.gui.blocks.block_meta import BlockMeta


class BlockDialogSession:
def __init__(
self,
meta: "BlockMeta",
instance: BlockInstance,
project_dir: Path | None = None,
):
self.meta = meta
self.instance = instance
self.project_dir = project_dir

# --- STATE UI (par dialog) ---
self.local_params = dict(instance.parameters)
self.param_widgets = {}
self.param_labels = {}
self.name_edit: QLineEdit | None = None
Loading