Skip to content

Commit

Permalink
Implement zooming to selected region in table
Browse files Browse the repository at this point in the history
  • Loading branch information
davidborland committed Jan 3, 2020
1 parent c847597 commit b5d3fb8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
4 changes: 3 additions & 1 deletion RegionTable.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ void RegionTable::on_cellEntered(int row, int column) {
}

void RegionTable::on_cellClicked(int row, int column) {
emit(selectRegion(rowLabel(row)));
if (column == 0) {
emit(selectRegion(rowLabel(row)));
}
}

void RegionTable::leaveEvent(QEvent* event) {
Expand Down
2 changes: 1 addition & 1 deletion VisualizationContainer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ void VisualizationContainer::SelectRegion(unsigned short label) {

SetCurrentRegion(region);

Render();
volumeView->GetInteractorStyle()->GetInteractor()->FlyTo(volumeView->GetRenderer(), region->GetCenter());
}


Expand Down
19 changes: 16 additions & 3 deletions VolumeView.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ VolumeView::VolumeView(vtkRenderWindowInteractor* interactor) {

regions = nullptr;
currentRegion = nullptr;
highlightRegion = nullptr;

// Rendering
renderer = vtkSmartPointer<vtkRenderer>::New();
Expand Down Expand Up @@ -89,6 +90,7 @@ VolumeView::~VolumeView() {

void VolumeView::Reset() {
SetCurrentRegion(nullptr);
HighlightRegion(nullptr);

probe->VisibilityOff();
plane->VisibilityOff();
Expand All @@ -102,6 +104,7 @@ void VolumeView::SetRegions(vtkImageData* data, RegionCollection* newRegions) {
// Reset
filterRegion = false;
currentRegion = nullptr;
highlightRegion = nullptr;

for (RegionCollection::Iterator it = regions->Begin(); it != regions->End(); it++) {
AddRegion(regions->Get(it));
Expand Down Expand Up @@ -153,13 +156,19 @@ void VolumeView::SetCurrentRegion(Region* region) {
}

void VolumeView::HighlightRegion(Region* region) {
if (!regions) return;

highlightRegion = region;

for (RegionCollection::Iterator it = regions->Begin(); it != regions->End(); it++) {
regions->Get(it)->GetHighlight3D()->GetActor()->VisibilityOff();
}

if (region) {
region->GetHighlight3D()->GetActor()->VisibilityOn();
if (highlightRegion) {
highlightRegion->GetHighlight3D()->GetActor()->VisibilityOn();
}

FilterRegions();
}

void VolumeView::SetShowProbe(bool show) {
Expand Down Expand Up @@ -397,12 +406,16 @@ void VolumeView::FilterRegions() {

if (filterRegion && currentRegion) {
surface->GetActor()->SetVisibility(region == currentRegion);
}
}
else if (!filterPlane) {
surface->GetActor()->VisibilityOn();
}
}

if (highlightRegion) {
highlightRegion->GetSurface()->GetActor()->VisibilityOn();
}

renderer->ResetCameraClippingRange();
Render();
}
1 change: 1 addition & 0 deletions VolumeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class VolumeView {
bool smoothShading;

Region* currentRegion;
Region* highlightRegion;

// Rendering
vtkSmartPointer<vtkRenderer> renderer;
Expand Down

0 comments on commit b5d3fb8

Please sign in to comment.