Skip to content

Commit

Permalink
Grid in visualiser now toggleable
Browse files Browse the repository at this point in the history
  • Loading branch information
Ozaq committed Sep 21, 2023
1 parent 99c87dd commit 0312290
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,8 @@ def reset_camera(self):
cam.SetClippingRange(0, 200)
self.iren.Render()

def show_grid(self, state: bool):
self.grid.show(state)

def render(self):
self.iren.Render()
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ def __init__(self, renderer: vtkRenderer, cam: vtkCamera):
actor.GetProperty().SetColor(Colors.e)
actor.GetProperty().SetRepresentationToWireframe()
renderer.AddActor(actor)
self._actor = actor

def show(self, state: bool):
self._actor.SetVisibility(state)
self._actor.Modified()

@staticmethod
def __compute_scale(scale):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ def _build_menu_bar(self) -> None:
)
)
)
self._show_grid = settings_menu.addAction("show grid")
self._show_grid.setCheckable(True)
self._show_grid.toggled.connect(self._toggle_grid)
self._show_grid.setChecked(
bool(
self.settings.value("show_grid", type=bool, defaultValue=False)
)
)

def _build_state_machine(self) -> None:
sm = QStateMachine(self)
Expand Down Expand Up @@ -99,6 +107,12 @@ def _toggle_triangulation(self, state: bool) -> None:
self.tabs.widget(idx).geo.show_triangulation(state)
self.repaint()

def _toggle_grid(self, state: bool) -> None:
self.settings.setValue("show_grid", state)
for idx in range(self.tabs.count()):
self.tabs.widget(idx).render_widget.show_grid(state)
self.repaint()

def _open_wkt(self):
base_path_obj = self.settings.value(
"files/last_wkt_location",
Expand All @@ -125,6 +139,7 @@ def _open_wkt(self):
tab = ViewGeometryWidget(
navi, geo, name_text, info_text, parent=self
)
tab.render_widget.show_grid(self._show_grid.isChecked())
tab_idx = self.tabs.insertTab(0, tab, file.name)
self.tabs.setCurrentIndex(tab_idx)
self.setUpdatesEnabled(True)
Expand Down Expand Up @@ -158,6 +173,7 @@ def _open_replay(self):
geo.show_triangulation(self._show_triangulation.isChecked())
trajectory = Trajectory(rec)
tab = ReplayWidget(navi, rec, geo, trajectory, parent=self)
tab.render_widget.show_grid(self._show_grid.isChecked())
tab_idx = self.tabs.insertTab(0, tab, file.name)
self.tabs.setCurrentIndex(tab_idx)
self.setUpdatesEnabled(True)
Expand Down

0 comments on commit 0312290

Please sign in to comment.