------------------------------------------------------------------------------
| 1175 | |
| 1176 | //------------------------------------------------------------------------------ |
| 1177 | void vtkVRInteractorStyle::UpdateRay(vtkEventDataDevice controller) |
| 1178 | { |
| 1179 | if (!this->Interactor) |
| 1180 | { |
| 1181 | return; |
| 1182 | } |
| 1183 | |
| 1184 | vtkRenderer* ren = this->CurrentRenderer; |
| 1185 | vtkVRRenderWindow* renWin = vtkVRRenderWindow::SafeDownCast(this->Interactor->GetRenderWindow()); |
| 1186 | vtkVRRenderWindowInteractor* iren = vtkVRRenderWindowInteractor::SafeDownCast(this->Interactor); |
| 1187 | |
| 1188 | if (!ren || !renWin || !iren) |
| 1189 | { |
| 1190 | return; |
| 1191 | } |
| 1192 | |
| 1193 | vtkVRModel* mod = renWin->GetModelForDevice(controller); |
| 1194 | if (!mod) |
| 1195 | { |
| 1196 | return; |
| 1197 | } |
| 1198 | |
| 1199 | int idev = static_cast<int>(controller); |
| 1200 | |
| 1201 | // Keep the same ray if a controller is interacting with a prop |
| 1202 | if (this->InteractionProps[idev] != nullptr) |
| 1203 | { |
| 1204 | return; |
| 1205 | } |
| 1206 | |
| 1207 | // Check if interacting with a widget |
| 1208 | vtkPropCollection* props = ren->GetViewProps(); |
| 1209 | |
| 1210 | vtkIdType nbProps = props->GetNumberOfItems(); |
| 1211 | for (vtkIdType i = 0; i < nbProps; i++) |
| 1212 | { |
| 1213 | vtkWidgetRepresentation* rep = vtkWidgetRepresentation::SafeDownCast(props->GetItemAsObject(i)); |
| 1214 | |
| 1215 | if (rep && rep->IsA("vtkQWidgetRepresentation") && rep->GetInteractionState() != 0) |
| 1216 | { |
| 1217 | mod->SetShowRay(true); |
| 1218 | mod->SetRayLength(ren->GetActiveCamera()->GetClippingRange()[1]); |
| 1219 | mod->SetRayColor(0.0, 0.0, 1.0); |
| 1220 | return; |
| 1221 | } |
| 1222 | } |
| 1223 | |
| 1224 | if (this->GetGrabWithRay() || this->InteractionState[idev] == VTKIS_PICK) |
| 1225 | { |
| 1226 | mod->SetShowRay(true); |
| 1227 | } |
| 1228 | else |
| 1229 | { |
| 1230 | mod->SetShowRay(false); |
| 1231 | return; |
| 1232 | } |
| 1233 | |
| 1234 | // Set length to its max if interactive picking is off |
no test coverage detected