-
Notifications
You must be signed in to change notification settings - Fork 36
Feat/breakpoints #1000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MSherbinii
wants to merge
21
commits into
develop
Choose a base branch
from
feat/breakpoints
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/breakpoints #1000
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
150c5a1
feat(breakpoints): add BreakpointManager for breakpoint tracking
MSherbinii 83ff841
feat(breakpoints): integrate BreakpointManager into ExecutionEngine
MSherbinii 8fe0808
feat(breakpoints): add breakpoint check in State.start() for all stat…
MSherbinii edf7d04
feat(breakpoints): add breakpoints panel view
MSherbinii 5c557aa
feat(breakpoints): add breakpoints panel controller
MSherbinii af79608
feat(breakpoints): integrate breakpoints panel into main window
MSherbinii 2495959
feat(breakpoints): add breakpoint checkbox to state overview panel
MSherbinii 5339279
feat(breakpoints): add visual indicator for breakpointed states
MSherbinii 2279962
refactor(breakpoints): move gui_singletons import to top level
MSherbinii 1edc9a0
fix(breakpoints): pause before state execution
MSherbinii 71a2a19
fix(breakpoints): handle None file_system_path for unsaved state mach…
MSherbinii 8778d57
fix(breakpoints): warn user when setting breakpoint on unsaved state …
MSherbinii 28b9351
feat(breakpoints): add breakpoint toggle to right-click state menu
MSherbinii ee6c12e
feat(breakpoints): instant canvas repaint on breakpoint change
MSherbinii 233b675
fix(breakpoints): improve breakpoint dot size and positioning
MSherbinii f7a0451
test: add unit tests for breakpoints feature
MSherbinii 4825bdb
test(breakpoints): add GUI unit test for breakpoints panel
MSherbinii 2654188
fix(breakpoints): move singleton imports inside test function to avoi…
MSherbinii a055902
test(breakpoints): add individual breakpoint removal test
MSherbinii 77321ae
fix(breakpoints): sync graphical editor and state editor on breakpoin…
MSherbinii 7a3d165
Merge branch 'develop' into feat/breakpoints
flolay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import os | ||
| from rafcon.utils import log | ||
|
|
||
| logger = log.get_logger(__name__) | ||
|
|
||
|
|
||
| class BreakpointManager: | ||
|
|
||
| def __init__(self): | ||
| self._breakpoints = {} | ||
| self._listeners = [] | ||
|
|
||
| def add_listener(self, callback): | ||
| if callback not in self._listeners: | ||
| self._listeners.append(callback) | ||
|
|
||
| def remove_listener(self, callback): | ||
| self._listeners = [l for l in self._listeners if l is not callback] | ||
|
|
||
| def _notify(self): | ||
| for listener in list(self._listeners): | ||
| listener() | ||
|
|
||
| @staticmethod | ||
| def _get_state_id(state): | ||
| if state.file_system_path is None: | ||
| return None | ||
| return os.path.basename(state.file_system_path) | ||
|
|
||
| def add_breakpoint(self, state, display_name): | ||
| state_id = self._get_state_id(state) | ||
| self._breakpoints[state_id] = { | ||
| 'enabled': True, | ||
| 'name': display_name, | ||
| 'display_path': state.file_system_path | ||
| } | ||
| logger.info(f"✓ Breakpoint: {display_name}") | ||
| logger.info(f" Path: {state.file_system_path}") | ||
| self._notify() | ||
|
|
||
| def remove_breakpoint(self, state): | ||
| state_id = self._get_state_id(state) | ||
| self.remove_breakpoint_by_id(state_id) | ||
|
|
||
| def remove_breakpoint_by_id(self, state_id): | ||
| if state_id in self._breakpoints: | ||
| del self._breakpoints[state_id] | ||
| self._notify() | ||
|
|
||
| def toggle_breakpoint(self, state_id): | ||
| if state_id in self._breakpoints: | ||
| self._breakpoints[state_id]['enabled'] = not self._breakpoints[state_id]['enabled'] | ||
| self._notify() | ||
|
|
||
| def clear_all(self): | ||
| self._breakpoints.clear() | ||
| self._notify() | ||
|
|
||
| def should_pause(self, state): | ||
| state_id = self._get_state_id(state) | ||
| if state_id is None: | ||
| return False | ||
| if state_id in self._breakpoints: | ||
| return self._breakpoints[state_id]['enabled'] | ||
| return False | ||
|
|
||
| def get_all_breakpoints(self): | ||
| return dict(self._breakpoints) | ||
|
|
||
| def disable_all(self): | ||
| for bp in self._breakpoints.values(): | ||
| bp['enabled'] = False | ||
| self._notify() | ||
|
|
||
| def enable_all(self): | ||
| for bp in self._breakpoints.values(): | ||
| bp['enabled'] = True | ||
| self._notify() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| from gi.repository import Gtk | ||
| from gi.repository import GObject | ||
|
|
||
| from rafcon.core.singleton import state_machine_execution_engine | ||
| from rafcon.gui.controllers.utils.extended_controller import ExtendedController | ||
| from rafcon.gui.models.state_machine_manager import StateMachineManagerModel | ||
| from rafcon.gui.views.breakpoints import BreakpointsView | ||
| from rafcon.utils import log | ||
|
|
||
| logger = log.get_logger(__name__) | ||
|
|
||
|
|
||
| class BreakpointsController(ExtendedController): | ||
| """Controller for the breakpoints panel. | ||
|
|
||
| Manages the list of breakpoints, allowing users to enable/disable | ||
| or remove them. | ||
| """ | ||
|
|
||
| # TreeStore column indices | ||
| COL_ENABLED = 0 # checkbox | ||
| COL_NAME = 1 # state name | ||
| COL_PATH = 2 # display path | ||
| COL_STATE_ID = 3 # state ID (hidden, used as key) | ||
|
|
||
| def __init__(self, model=None, view=None): | ||
| assert isinstance(model, StateMachineManagerModel) | ||
| assert isinstance(view, BreakpointsView) | ||
|
|
||
| super(BreakpointsController, self).__init__(model, view) | ||
|
|
||
| # Create list store: [enabled (bool), name (str), path (str), state_id (str)] | ||
| self.breakpoints_store = Gtk.ListStore(GObject.TYPE_BOOLEAN, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING) | ||
|
|
||
| # Get tree view from view | ||
| self.breakpoints_tree = view['breakpoints_tree'] | ||
| self.breakpoints_tree.set_model(self.breakpoints_store) | ||
|
|
||
| # Setup columns | ||
| self._setup_tree_columns() | ||
|
|
||
| # Initial update | ||
| self.update() | ||
|
|
||
| def _setup_tree_columns(self): | ||
| """Setup the tree view columns""" | ||
| # Column 1: Enabled checkbox | ||
| renderer_toggle = Gtk.CellRendererToggle() | ||
| renderer_toggle.connect("toggled", self.on_breakpoint_toggled) | ||
| column_enabled = Gtk.TreeViewColumn("Enabled", renderer_toggle, active=self.COL_ENABLED) | ||
| self.breakpoints_tree.append_column(column_enabled) | ||
|
|
||
| # Column 2: State name | ||
| renderer_text = Gtk.CellRendererText() | ||
| column_name = Gtk.TreeViewColumn("State", renderer_text, text=self.COL_NAME) | ||
| column_name.set_expand(True) | ||
| self.breakpoints_tree.append_column(column_name) | ||
|
|
||
| # Column 3: Path (displayed) | ||
| renderer_path = Gtk.CellRendererText() | ||
| column_path = Gtk.TreeViewColumn("Path", renderer_path, text=self.COL_PATH) | ||
| column_path.set_expand(True) | ||
| self.breakpoints_tree.append_column(column_path) | ||
|
|
||
| # Note: COL_STATE_ID (column 4) is hidden, used only as key for lookups | ||
|
|
||
| def register_view(self, view): | ||
| """Connect button signals""" | ||
| super(BreakpointsController, self).register_view(view) | ||
| view['remove_button'].connect('clicked', self.on_remove_selected) | ||
| view['remove_all_button'].connect('clicked', self.on_remove_all) | ||
| view['refresh_button'].connect('clicked', self.on_refresh) | ||
| view['toggle_all_button'].connect('toggled', self.on_toggle_all) | ||
|
|
||
| def update(self): | ||
| """Refresh the breakpoints list from the breakpoint manager""" | ||
| self.breakpoints_store.clear() | ||
|
|
||
| # Get all breakpoints from the execution engine | ||
| breakpoints = state_machine_execution_engine.breakpoint_manager.get_all_breakpoints() | ||
|
|
||
| # Add each breakpoint to the list | ||
| for state_id, info in breakpoints.items(): | ||
| self.breakpoints_store.append([ | ||
| info['enabled'], | ||
| info['name'], | ||
| info.get('display_path', ''), | ||
| state_id | ||
| ]) | ||
|
|
||
| def on_breakpoint_toggled(self, widget, path): | ||
| """Toggle breakpoint enabled/disabled""" | ||
| # Get the row | ||
| tree_iter = self.breakpoints_store.get_iter(path) | ||
| state_id = self.breakpoints_store.get_value(tree_iter, self.COL_STATE_ID) | ||
|
|
||
| # Toggle in breakpoint manager | ||
| state_machine_execution_engine.breakpoint_manager.toggle_breakpoint(state_id) | ||
|
|
||
| # Update display | ||
| self.update() | ||
|
|
||
| def on_remove_selected(self, widget): | ||
| """Remove selected breakpoint""" | ||
| selection = self.breakpoints_tree.get_selection() | ||
| model, tree_iter = selection.get_selected() | ||
|
|
||
| if tree_iter is None: | ||
| logger.info("No breakpoint selected to remove") | ||
| return | ||
|
|
||
| # Get state ID | ||
| state_id = model.get_value(tree_iter, self.COL_STATE_ID) | ||
|
|
||
| # Remove from breakpoint manager (triggers _notify to update graphical editor) | ||
| state_machine_execution_engine.breakpoint_manager.remove_breakpoint_by_id(state_id) | ||
|
|
||
| # Update display | ||
| self.update() | ||
|
|
||
| def on_remove_all(self, widget): | ||
| """Remove all breakpoints""" | ||
| state_machine_execution_engine.breakpoint_manager.clear_all() | ||
| self.update() | ||
| logger.info("All breakpoints removed") | ||
|
|
||
| def on_refresh(self, widget): | ||
| """Refresh the breakpoints list""" | ||
| self.update() | ||
|
|
||
| def on_toggle_all(self, toggle_button): | ||
| """Toggle all breakpoints on/off""" | ||
| if toggle_button.get_active(): | ||
| state_machine_execution_engine.breakpoint_manager.disable_all() | ||
| toggle_button.set_label("Enable All") | ||
| else: | ||
| state_machine_execution_engine.breakpoint_manager.enable_all() | ||
| toggle_button.set_label("Disable All") | ||
| self.update() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.