Mercurial > MadButterfly
comparison pyink/FSM_window.py @ 1485:20cf6ea263c6
Rename from_srcs to from_states
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Fri, 29 Apr 2011 23:42:22 +0800 |
parents | aa4137f3141e |
children | 471805e582cc |
comparison
equal
deleted
inserted
replaced
1484:aa4137f3141e | 1485:20cf6ea263c6 |
---|---|
276 state_name = None | 276 state_name = None |
277 state_g = None | 277 state_g = None |
278 _text_node = None | 278 _text_node = None |
279 _circle_node = None | 279 _circle_node = None |
280 transitions = None | 280 transitions = None |
281 from_srcs = None | 281 from_states = None |
282 | 282 |
283 _state_g_hdl_id = None | 283 _state_g_hdl_id = None |
284 _selected_rect = None | 284 _selected_rect = None |
285 | 285 |
286 def __init__(self, state_name): | 286 def __init__(self, state_name): |
287 self.state_name = state_name | 287 self.state_name = state_name |
288 self.transitions = {} | 288 self.transitions = {} |
289 self.from_srcs = set() | 289 self.from_states = set() |
290 pass | 290 pass |
291 | 291 |
292 def init(self, doc, domview, fsm_layer, control_layer): | 292 def init(self, doc, domview, fsm_layer, control_layer): |
293 self._doc = doc | 293 self._doc = doc |
294 self._domview = domview | 294 self._domview = domview |
460 target_state_names = [trn.target for trn in transitions.values()] | 460 target_state_names = [trn.target for trn in transitions.values()] |
461 target_states = [states[target_name] | 461 target_states = [states[target_name] |
462 for target_name in target_state_names] | 462 for target_name in target_state_names] |
463 state_name = self.state_name | 463 state_name = self.state_name |
464 for target_state in target_states: | 464 for target_state in target_states: |
465 target_state.from_srcs.add(state_name) | 465 target_state.from_states.add(state_name) |
466 pass | 466 pass |
467 pass | 467 pass |
468 | 468 |
469 def adjust_transitions(self, states): | 469 def adjust_transitions(self, states): |
470 import itertools | 470 import itertools |
473 trn.adjust_by_ends(states) | 473 trn.adjust_by_ends(states) |
474 trn.update() | 474 trn.update() |
475 pass | 475 pass |
476 | 476 |
477 state_name = self.state_name | 477 state_name = self.state_name |
478 src_states = [states[src_state_name] | 478 from_states = [states[from_state_name] |
479 for src_state_name in self.from_srcs] | 479 for from_state_name in self.from_states] |
480 states_transitions = [state.transitions.values() | 480 states_transitions = [state.transitions.values() |
481 for state in src_states] | 481 for state in from_states] |
482 in_state_transitions = [[trn for trn in state_transitions | 482 in_state_transitions = [[trn for trn in state_transitions |
483 if trn.target == state_name] | 483 if trn.target == state_name] |
484 for state_transitions in states_transitions] | 484 for state_transitions in states_transitions] |
485 in_transitions = itertools.chain(*in_state_transitions) | 485 in_transitions = itertools.chain(*in_state_transitions) |
486 for trn in in_transitions: | 486 for trn in in_transitions: |
810 states = self._states | 810 states = self._states |
811 state = states[state_name] | 811 state = states[state_name] |
812 state.tell_target_states(states) | 812 state.tell_target_states(states) |
813 pass | 813 pass |
814 | 814 |
815 def _rebuild_from_srcs(self): | 815 def _rebuild_from_states(self): |
816 states = self._states | 816 states = self._states |
817 domview = self._domview | 817 domview = self._domview |
818 state_names = domview.all_state_names() | 818 state_names = domview.all_state_names() |
819 for state_name in state_names: | 819 for state_name in state_names: |
820 state = states[state_name] | 820 state = states[state_name] |
830 | 830 |
831 state_names = domview.all_state_names() | 831 state_names = domview.all_state_names() |
832 for state_name in state_names: | 832 for state_name in state_names: |
833 self._load_new_state(state_name) | 833 self._load_new_state(state_name) |
834 pass | 834 pass |
835 self._rebuild_from_srcs() | 835 self._rebuild_from_states() |
836 pass | 836 pass |
837 | 837 |
838 def set_svg_view(self, view): | 838 def set_svg_view(self, view): |
839 self._view_box.add(view) | 839 self._view_box.add(view) |
840 self._view_widget = view | 840 self._view_widget = view |