Skip to content

33 implement mini map in visualization#36

Merged
windisch merged 15 commits intomainfrom
33-implement-mini-map-in-visualization
Apr 11, 2026
Merged

33 implement mini map in visualization#36
windisch merged 15 commits intomainfrom
33-implement-mini-map-in-visualization

Conversation

@HSMarieK
Copy link
Copy Markdown
Collaborator

@HSMarieK HSMarieK commented Apr 2, 2026

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.

@HSMarieK HSMarieK requested a review from windisch April 2, 2026 13:39
@HSMarieK HSMarieK linked an issue Apr 2, 2026 that may be closed by this pull request
@windisch windisch requested a review from peerplexit April 2, 2026 13:51
Copy link
Copy Markdown
Contributor

@windisch windisch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about this:

if viewpoint is not None:
    viewpoint = pygame.Vector3(viewpoint)
    self.view = pygame.Vector2(viewpoint.x, viewpoint.y)
self.viewpoint = viewpoint

else:
self.viewpoint = viewpoint

if self.viewpoint is not None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if self.viewpoint is None? Then self.view is not created - is this a problem?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

color = 'black'
if not 'mode' in station:
pass
elif station['mode'] == 'working':
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do if the station doesn't send a mode?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a station without a mode?

In that case we probably still need

if not 'mode' in station:
            pass

self.line_bounds = None
self.show_minimap = True

def find_line_size(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is doing two things: finding something and setting something. I think this should be two functions?

break

if not self.check_user_input():
# Why do we check if the check_user_input returns True?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found out it was for breaking the run() loop.

self.draw_actions()
self.draw_cursor()

if self.viewpoint is not None and self.show_minimap:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw this call a lot of times.

How about a property:

@property
def viewpoint_is_set(self):
    return self.viewpoint is not None

Then this line can be:

 if viewpoint_is_set and self.show_minimap:

@HSMarieK
Copy link
Copy Markdown
Collaborator Author

HSMarieK commented Apr 8, 2026

Should the minimap be on or off by default?

@HSMarieK HSMarieK requested a review from windisch April 8, 2026 16:02
@windisch
Copy link
Copy Markdown
Contributor

windisch commented Apr 8, 2026

Should the minimap be on or off by default?

Definitely ON! :-)

windisch and others added 6 commits April 8, 2026 20:51
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>
@windisch windisch merged commit 8b0f445 into main Apr 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement mini-map in visualization

2 participants