Skip to content

Commit 8de1111

Browse files
committed
add explorer class
1 parent baed424 commit 8de1111

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

src/geometor/explorer/explorer.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
11
"""
22
explorer
3-
"""
3+
"""
4+
from matplotlib.widgets import Button
5+
6+
class Explorer:
7+
"""
8+
The Explorer class encapsulates the interactive exploration of geometric
9+
plots. It extends the functionalities of the Sequencer to allow the user
10+
to navigate through the elements using buttons.
11+
12+
Attributes:
13+
sequencer (Sequencer): The Sequencer object containing the geometric model and plot.
14+
"""
15+
def __init__(self, sequencer: Sequencer):
16+
"""
17+
Initializes the Explorer with the given Sequencer object.
18+
19+
Args:
20+
sequencer (Sequencer): The Sequencer object containing the geometric model and plot.
21+
"""
22+
self.sequencer = sequencer
23+
self.current_index = 0
24+
self.setup_buttons()
25+
26+
def setup_buttons(self):
27+
"""Sets up the buttons for navigation."""
28+
axprev = self.sequencer.fig.add_axes([0.7, 0.05, 0.1, 0.075])
29+
axnext = self.sequencer.fig.add_axes([0.81, 0.05, 0.1, 0.075])
30+
bnext = Button(axnext, 'Next')
31+
bprev = Button(axprev, 'Previous')
32+
bnext.on_clicked(self.next_element)
33+
bprev.on_clicked(self.prev_element)
34+
35+
def next_element(self, event):
36+
"""Callback for the Next button. Moves to the next element."""
37+
self.current_index += 1
38+
self.current_index %= len(self.sequencer.model.items())
39+
self.update_plot()
40+
41+
def prev_element(self, event):
42+
"""Callback for the Previous button. Moves to the previous element."""
43+
self.current_index -= 1
44+
self.current_index %= len(self.sequencer.model.items())
45+
self.update_plot()
46+
47+
def update_plot(self):
48+
"""Updates the plot based on the current index."""
49+
# Logic to update the plot with the current element
50+
pass
51+

0 commit comments

Comments
 (0)