diff --git a/README.rst b/README.rst index 5d769f4eb3a9e96f1383c30e95fe66209d6f94eb..a626dcb8c865002eac2205a0f9525795af0f6b8d 100644 --- a/README.rst +++ b/README.rst @@ -110,7 +110,7 @@ Once you have a copy of the source, you can install it with :: Jupyter Canvas Widget --------------------- If you work with jupyter notebook you need to install the Jupyer Canvas Widget. To install the Jupyter Canvas Widget read also -https://github.com/Who8MyLunch/Jupyter_Canvas_Widget#installation +https://github.com/Who8MyLunch/Jupyter_Canvas_Widget#installation Usage ===== diff --git a/examples/demo.py b/examples/demo.py index 1e4a14d3ba6880b904403642bde7a3a3bf4115a2..fa897713e1987082ffecf1b1bc824d1329c44342 100644 --- a/examples/demo.py +++ b/examples/demo.py @@ -164,13 +164,7 @@ class Demo: demo_001 = Demo(Scenario_Generator.load_scenario('complex_scene.pkl')) demo_001.set_record_frames(os.path.join(__file_dirname__, '..', 'rendering', 'frame_{:04d}.bmp')) demo_001.run_demo(120) - - @staticmethod - def run_complex_scene_2(): - demo_001 = Demo(Scenario_Generator.load_scenario('complex_scene_2.pkl')) - demo_001.set_record_frames(os.path.join(__file_dirname__, '..', 'rendering', 'frame_{:04d}.bmp')) - demo_001.run_demo(120) + if __name__ == "__main__": Demo.run_complex_scene() - Demo.run_complex_scene_2() diff --git a/flatland/utils/editor.py b/flatland/utils/editor.py index 6973c94ea8a5d950ef08d2a128c8767348a91f2e..081cf02c804f5a8d64542b2cfdc75c664bc479a9 100644 --- a/flatland/utils/editor.py +++ b/flatland/utils/editor.py @@ -249,6 +249,9 @@ class Controller(object): self.debug("click in cell", rcCell) self.model.debug_cell(rcCell) + if self.model.iSelectedAgent is not None: + self.lrcStroke = [] + def setDebug(self, dEvent): self.model.setDebug(dEvent["new"]) @@ -274,8 +277,35 @@ class Controller(object): # If the mouse is held down, enqueue an event in our own queue # The intention was to avoid too many redraws. + # Reset the lrcStroke list, if ALT, CTRL or SHIFT pressed if event["buttons"] > 0: qEvents.append((time.time(), x, y)) + bShift = event["shiftKey"] + bCtrl = event["ctrlKey"] + bAlt = event["altKey"] + if bShift: + self.lrcStroke = [] + while len(qEvents) > 0: + t, x, y = qEvents.popleft() + return + if bCtrl: + self.lrcStroke = [] + while len(qEvents) > 0: + t, x, y = qEvents.popleft() + return + if bAlt: + self.lrcStroke = [] + while len(qEvents) > 0: + t, x, y = qEvents.popleft() + return + else: + self.lrcStroke = [] + + if self.model.iSelectedAgent is not None: + self.lrcStroke = [] + while len(qEvents) > 0: + t, x, y = qEvents.popleft() + return # Process the events in our queue: # Draw a black square to indicate a trail diff --git a/flatland/utils/graphics_pil.py b/flatland/utils/graphics_pil.py index 6c687667cc4fcc5dcd5035956af91b661e63b111..23f8b8790a44be3d4835a1a9594effaa1ee33164 100644 --- a/flatland/utils/graphics_pil.py +++ b/flatland/utils/graphics_pil.py @@ -433,12 +433,12 @@ class PILSVG(PILGL): if (col + row) % 10 > 7: pilTrack = self.dScenery[0] else: - if (col + row + col * row) % 2 == 0: + if (col + row + col * row) % 3 == 0: a = (a + (col + row + col * row)) % len(self.dBuildings) pilTrack = self.dBuildings[a] - elif (self.background_grid[col][row] > 5) or ((col ** 3 + row ** 2 + col * row) % 10 == 0): - a = int(self.background_grid[col][row]) - 5 - a = a % len(self.dScenery) + elif (self.background_grid[col][row] > 4) or ((col ** 3 + row ** 2 + col * row) % 10 == 0): + a = int(self.background_grid[col][row]) - 4 + a = (a + (col + row + col * row + col ** 3 + row ** 4)) % len(self.dScenery) if (col + row + col * row) % 10 > 2: a = 0 pilTrack = self.dScenery[a] diff --git a/notebooks/Scene_Editor.ipynb b/notebooks/Scene_Editor.ipynb index 728debb3f468f5997548b90b5119b708fa8f3e70..444c1ebf023a06294b04f58a4f180a46608f6d96 100644 --- a/notebooks/Scene_Editor.ipynb +++ b/notebooks/Scene_Editor.ipynb @@ -100,7 +100,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "04f9a225dac149dca9990b271ab3b459", + "model_id": "140f16d2c9a643e39d68c6421e50b9bd", "version_major": 2, "version_minor": 0 }, diff --git a/notebooks/Simple_Rendering_Demo.ipynb b/notebooks/Simple_Rendering_Demo.ipynb index b05b791fea489f04767d7f1b31391838e21d34c2..8b13d860a020829609542e55f9088014ed4783b0 100644 --- a/notebooks/Simple_Rendering_Demo.ipynb +++ b/notebooks/Simple_Rendering_Demo.ipynb @@ -9,7 +9,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -19,7 +19,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -31,7 +31,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -41,7 +41,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -53,9 +53,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "<style>.container { width:90% !important; }</style>" + ], + "text/plain": [ + "<IPython.core.display.HTML object>" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "from IPython.core.display import display, HTML\n", "display(HTML(\"<style>.container { width:90% !important; }</style>\"))" @@ -70,7 +83,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -92,9 +105,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Illegal target rail: 3 13 0001011000000001\n", + "Illegal target rail: 5 13 0100000000000010\n" + ] + } + ], "source": [ "oRT = rt.RenderTool(env,gl=\"PILSVG\")\n", "oRT.renderEnv()\n", @@ -103,9 +125,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "6f5c066c7dff47dbb3d2bfc1f9e77943", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Canvas()" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "jpy_canvas.Canvas(img)" ]