------------------------------------------------------------------------------
| 124 | |
| 125 | //------------------------------------------------------------------------------ |
| 126 | void vtkVRMenuRepresentation::ComplexInteraction( |
| 127 | vtkRenderWindowInteractor*, vtkAbstractWidget*, unsigned long event, void* calldata) |
| 128 | { |
| 129 | switch (event) |
| 130 | { |
| 131 | case vtkWidgetEvent::Select3D: |
| 132 | { |
| 133 | this->VisibilityOff(); |
| 134 | long count = 0; |
| 135 | for (auto& menu : this->Menus) |
| 136 | { |
| 137 | if (count == std::lround(this->CurrentOption)) |
| 138 | { |
| 139 | menu->Command->Execute(this, vtkWidgetEvent::Select3D, |
| 140 | static_cast<void*>(const_cast<char*>(menu->Name.c_str()))); |
| 141 | } |
| 142 | count++; |
| 143 | } |
| 144 | } |
| 145 | break; |
| 146 | |
| 147 | case vtkWidgetEvent::Move3D: |
| 148 | { |
| 149 | vtkEventData* edata = static_cast<vtkEventData*>(calldata); |
| 150 | vtkEventDataDevice3D* ed = edata->GetAsEventDataDevice3D(); |
| 151 | if (!ed) |
| 152 | { |
| 153 | return; |
| 154 | } |
| 155 | const double* dir = ed->GetWorldDirection(); |
| 156 | // adjust CurrentOption based on controller orientation |
| 157 | vtkVRRenderWindow* renWin = |
| 158 | static_cast<vtkVRRenderWindow*>(this->Renderer->GetRenderWindow()); |
| 159 | double* vup = renWin->GetPhysicalViewUp(); |
| 160 | double dot = vtkMath::Dot(dir, vup); |
| 161 | this->CurrentOption -= dot * 0.12; |
| 162 | if (this->CurrentOption < 0) |
| 163 | { |
| 164 | this->CurrentOption = 0.0; |
| 165 | } |
| 166 | else if (this->CurrentOption > this->Menus.size() - 1) |
| 167 | { |
| 168 | this->CurrentOption = this->Menus.size() - 1; |
| 169 | } |
| 170 | this->BuildRepresentation(); |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | //------------------------------------------------------------------------------ |
| 176 | void vtkVRMenuRepresentation::ReleaseGraphicsResources(vtkWindow* w) |
no test coverage detected