diff --git a/flatland/core/env.py b/flatland/core/env.py index 5334b22f5762840f400743c80512bc6a118062ee..3c25beea236945b1728959e02ea07f6c0ba7a6ac 100644 --- a/flatland/core/env.py +++ b/flatland/core/env.py @@ -34,7 +34,7 @@ class Environment: "train_0": False, # train_0 is still running "train_1": True, # train_1 is done "__all__": False, # the env is not done - } + }h >>> print(infos) { "train_0": {}, # info for train_0 diff --git a/flatland/utils/editor.py b/flatland/utils/editor.py index 13ec977c9945545f0147e691b2ddb4f118c43639..680695ffd8440ceb349309da9f341cf2873ac28b 100644 --- a/flatland/utils/editor.py +++ b/flatland/utils/editor.py @@ -234,16 +234,19 @@ class Controller(object): def on_click(self, wid, event): x = event['canvasX'] y = event['canvasY'] - self.debug("debug:", event) + self.debug("debug:", x,y) rcCell = self.view.xy_to_rc(x, y) bShift = event["shiftKey"] bCtrl = event["ctrlKey"] - if bCtrl and not bShift: + bAlt = event["altKey"] + if bCtrl and not bShift and not bAlt: self.model.click_agent(rcCell) elif bShift and bCtrl: self.model.add_target(rcCell) + elif bAlt and not bShift and not bCtrl: + self.model.clearCell(rcCell) self.debug("click in cell", rcCell) self.model.debug_cell(rcCell) @@ -263,6 +266,7 @@ class Controller(object): def on_mouse_move(self, wid, event): """Mouse motion event handler for drawing. """ + x = event['canvasX'] y = event['canvasY'] qEvents = self.qEvents @@ -309,6 +313,8 @@ class Controller(object): # # This is the first cell in a mouse stroke # lrcStroke.append(rcCell) self.view.redisplayImage() + + else: self.model.mod_path(not event["shiftKey"]) @@ -609,6 +615,12 @@ class EditorModel(object): self.redraw() + + def clearCell(self,rcCell): + self.debug_cell(rcCell) + self.env.rail.grid[rcCell[0],rcCell[1]] = 0 + self.redraw() + def reset(self, replace_agents=False, nAgents=0): # if replace_agents: # self.env.agents_handles = range(nAgents) diff --git a/notebooks/Editor2.ipynb b/notebooks/Editor2.ipynb index 22bc70746fc7af324a3e7d236171baa9fed48212..0a192f225f9de77b05f6e98f50859160f7ed0445 100644 --- a/notebooks/Editor2.ipynb +++ b/notebooks/Editor2.ipynb @@ -92,7 +92,8 @@ "- ctrl-shift-click to add target for last agent\n", " - target can be moved by repeating\n", "- to Resize the env (cannot preserve work):\n", - " - select \"Regen\" tab, set regen size slider, click regenerate." + " - select \"Regen\" tab, set regen size slider, click regenerate.\n", + "- alt-click remove all rails from cell \n" ] }, { @@ -105,7 +106,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "0f61a1b60a024112ace6ee136b49f20a", + "model_id": "deb9bf5c1c344a5c91f6349802a6ab58", "version_major": 2, "version_minor": 0 }, @@ -131,7 +132,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "d3c56d6d214949e181e45330b00082f8", + "model_id": "01057ff96f9543c8b48cbfdbd385a3d0", "version_major": 2, "version_minor": 0 },