Conversation
windisch
left a comment
There was a problem hiding this comment.
Thats a pretty awesome feature!
I have the feeling that the Visualization-class may needs some redesign to scale efficiently to new features - lets discuss this synchronously!
| self.view = pygame.Vector2(self.viewpoint.x, self.viewpoint.y) | ||
| self.size = pygame.Vector2(size) | ||
|
|
||
| if viewpoint is not None: |
There was a problem hiding this comment.
how about this:
if viewpoint is not None:
viewpoint = pygame.Vector3(viewpoint)
self.view = pygame.Vector2(viewpoint.x, viewpoint.y)
self.viewpoint = viewpoint
lineflow/simulation/visualization.py
Outdated
| else: | ||
| self.viewpoint = viewpoint | ||
|
|
||
| if self.viewpoint is not None: |
There was a problem hiding this comment.
What if self.viewpoint is None? Then self.view is not created - is this a problem?
There was a problem hiding this comment.
Should not be a problem, since it doesn't get called until self.viewpoint is set. This is one of the reasons I implemented those if-statements in the run() method.
lineflow/simulation/visualization.py
Outdated
| color = 'black' | ||
| if not 'mode' in station: | ||
| pass | ||
| elif station['mode'] == 'working': |
There was a problem hiding this comment.
I think this cries for a mapping:
self.color_mapping = {
'waiting': 'yellow',
...
}And then:
def get_station_color(self, station):
return self.color_mapping[station['mode']](I found get_ better than set_ because the method is not setting colors but returning them)
There was a problem hiding this comment.
What does this do if the station doesn't send a mode?
There was a problem hiding this comment.
Is there a station without a mode?
In that case we probably still need
if not 'mode' in station:
pass
lineflow/simulation/visualization.py
Outdated
| self.line_bounds = None | ||
| self.show_minimap = True | ||
|
|
||
| def find_line_size(self): |
There was a problem hiding this comment.
This function is doing two things: finding something and setting something. I think this should be two functions?
lineflow/simulation/visualization.py
Outdated
| break | ||
|
|
||
| if not self.check_user_input(): | ||
| # Why do we check if the check_user_input returns True? |
There was a problem hiding this comment.
Found out it was for breaking the run() loop.
lineflow/simulation/visualization.py
Outdated
| self.draw_actions() | ||
| self.draw_cursor() | ||
|
|
||
| if self.viewpoint is not None and self.show_minimap: |
There was a problem hiding this comment.
I saw this call a lot of times.
How about a property:
@property
def viewpoint_is_set(self):
return self.viewpoint is not NoneThen this line can be:
if viewpoint_is_set and self.show_minimap:|
Should the minimap be on or off by default? |
Definitely ON! :-) |
Signed-off-by: Tobias Windisch <tobias.windisch@hs-kempten.de>
…visualization Mouse interaction with Visualization
Signed-off-by: Tobias Windisch <tobias.windisch@hs-kempten.de>
Added a minimap to the upper right corner of the visualization. Shows basic information and the current view size and position.
Minimap can be switched on or off by pressing the M-Key.