Skip to content

Commit 754fa59

Browse files
committed
Set lighting propreties when pressing 's' or 'w' in a PCLVisualizer and using setRepresentationTo*ForAllActors()
1 parent a97e60c commit 754fa59

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

visualization/src/interactor_style.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,24 @@ pcl::visualization::PCLVisualizerInteractorStyle::OnKeyDown ()
831831
}
832832
break;
833833
}
834+
835+
// Switch representation to wireframe (override default behavior)
836+
case 'w': case 'W':
837+
{
838+
vtkSmartPointer<vtkActorCollection> ac = CurrentRenderer->GetActors ();
839+
vtkCollectionSimpleIterator ait;
840+
for (ac->InitTraversal (ait); vtkActor* actor = ac->GetNextActor (ait); )
841+
{
842+
for (actor->InitPathTraversal (); vtkAssemblyPath* path = actor->GetNextPath (); )
843+
{
844+
vtkSmartPointer<vtkActor> apart = reinterpret_cast <vtkActor*> (path->GetLastNode ()->GetViewProp ());
845+
apart->GetProperty ()->SetRepresentationToWireframe ();
846+
apart->GetProperty ()->SetLighting (false);
847+
}
848+
}
849+
break;
850+
}
851+
834852
// Save a PNG snapshot with the current screen
835853
case 'j': case 'J':
836854
{
@@ -992,7 +1010,20 @@ pcl::visualization::PCLVisualizerInteractorStyle::OnKeyDown ()
9921010
Interactor->Render ();
9931011
}
9941012
else
995-
Superclass::OnKeyDown ();
1013+
{
1014+
Superclass::OnKeyDown();
1015+
vtkSmartPointer<vtkActorCollection> ac = CurrentRenderer->GetActors();
1016+
vtkCollectionSimpleIterator ait;
1017+
for (ac->InitTraversal(ait); vtkActor* actor = ac->GetNextActor(ait);)
1018+
{
1019+
for (actor->InitPathTraversal(); vtkAssemblyPath* path = actor->GetNextPath();)
1020+
{
1021+
vtkSmartPointer<vtkActor> apart = reinterpret_cast<vtkActor*>(path->GetLastNode()->GetViewProp());
1022+
apart->GetProperty()->SetRepresentationToSurface();
1023+
apart->GetProperty()->SetLighting(true);
1024+
}
1025+
}
1026+
}
9961027
break;
9971028
}
9981029

visualization/src/pcl_visualizer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3238,6 +3238,7 @@ pcl::visualization::PCLVisualizer::setRepresentationToSurfaceForAllActors ()
32383238
while ((actor = actors->GetNextActor ()) != NULL)
32393239
{
32403240
actor->GetProperty ()->SetRepresentationToSurface ();
3241+
actor->GetProperty ()->SetLighting(true);
32413242
}
32423243
}
32433244
}
@@ -3276,6 +3277,7 @@ pcl::visualization::PCLVisualizer::setRepresentationToWireframeForAllActors ()
32763277
while ((actor = actors->GetNextActor ()) != NULL)
32773278
{
32783279
actor->GetProperty ()->SetRepresentationToWireframe ();
3280+
actor->GetProperty ()->SetLighting(false);
32793281
}
32803282
}
32813283
}

0 commit comments

Comments
 (0)