Skip to content
Snippets Groups Projects
Commit 9a4a1f0b authored by Egli Adrian (IT-SCI-API-PFI)'s avatar Egli Adrian (IT-SCI-API-PFI)
Browse files

editor bug fix : interaction with mouse

parent a154294c
No related branches found
No related tags found
No related merge requests found
......@@ -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
=====
......
......@@ -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"])
......@@ -276,6 +279,33 @@ class Controller(object):
# The intention was to avoid too many redraws.
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
......@@ -298,6 +328,7 @@ class Controller(object):
else:
self.model.mod_path(not event["shiftKey"])
def refresh(self, event):
self.debug("refresh")
self.view.redraw()
......
......@@ -433,13 +433,13 @@ 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)
if (col + row + col * row) % 10 > 2:
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]
......
......@@ -100,7 +100,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "04f9a225dac149dca9990b271ab3b459",
"model_id": "140f16d2c9a643e39d68c6421e50b9bd",
"version_major": 2,
"version_minor": 0
},
......
%% Cell type:markdown id: tags:
# Plot the Env and some trees
%% Cell type:code id: tags:
``` python
%load_ext autoreload
%autoreload 2
```
%% Cell type:code id: tags:
``` python
import jpy_canvas
import random
import time
import sys
```
%% Cell type:code id: tags:
``` python
# in case you need to tweak your PYTHONPATH...
sys.path.append("../flatland")
```
%% Cell type:code id: tags:
``` python
import flatland.core.env
import flatland.utils.rendertools as rt
from flatland.envs.rail_env import RailEnv, random_rail_generator
from flatland.envs.observations import TreeObsForRailEnv
```
%% Cell type:code id: tags:
``` python
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:90% !important; }</style>"))
```
%% Output
%% Cell type:markdown id: tags:
# Generate
%% Cell type:code id: tags:
``` python
nAgents = 3
fnMethod = random_rail_generator(cell_type_relative_proportion=[1] * 11)
env = RailEnv(width=20,
height=10,
rail_generator=fnMethod,
number_of_agents=nAgents,
obs_builder_object=TreeObsForRailEnv(max_depth=2))
```
%% Cell type:markdown id: tags:
# Render
%% Cell type:code id: tags:
``` python
oRT = rt.RenderTool(env,gl="PILSVG")
oRT.renderEnv()
img = oRT.getImage()
```
%% Output
Illegal target rail: 3 13 0001011000000001
Illegal target rail: 5 13 0100000000000010
%% Cell type:code id: tags:
``` python
jpy_canvas.Canvas(img)
```
%% Output
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment