| 260 | } |
| 261 | |
| 262 | void vtkSplineWidget::SetEnabled(int enabling) |
| 263 | { |
| 264 | if (!this->Interactor) |
| 265 | { |
| 266 | vtkErrorMacro(<< "The interactor must be set prior to enabling/disabling widget"); |
| 267 | return; |
| 268 | } |
| 269 | |
| 270 | if (enabling) //------------------------------------------------------------ |
| 271 | { |
| 272 | vtkDebugMacro(<< "Enabling line widget"); |
| 273 | |
| 274 | if (this->Enabled) // already enabled, just return |
| 275 | { |
| 276 | return; |
| 277 | } |
| 278 | |
| 279 | if (!this->CurrentRenderer) |
| 280 | { |
| 281 | this->SetCurrentRenderer(this->Interactor->FindPokedRenderer( |
| 282 | this->Interactor->GetLastEventPosition()[0], this->Interactor->GetLastEventPosition()[1])); |
| 283 | if (this->CurrentRenderer == nullptr) |
| 284 | { |
| 285 | return; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | this->Enabled = 1; |
| 290 | |
| 291 | // Listen for the following events |
| 292 | vtkRenderWindowInteractor* i = this->Interactor; |
| 293 | i->AddObserver(vtkCommand::MouseMoveEvent, this->EventCallbackCommand, this->Priority); |
| 294 | i->AddObserver(vtkCommand::LeftButtonPressEvent, this->EventCallbackCommand, this->Priority); |
| 295 | i->AddObserver(vtkCommand::LeftButtonReleaseEvent, this->EventCallbackCommand, this->Priority); |
| 296 | i->AddObserver(vtkCommand::MiddleButtonPressEvent, this->EventCallbackCommand, this->Priority); |
| 297 | i->AddObserver( |
| 298 | vtkCommand::MiddleButtonReleaseEvent, this->EventCallbackCommand, this->Priority); |
| 299 | i->AddObserver(vtkCommand::RightButtonPressEvent, this->EventCallbackCommand, this->Priority); |
| 300 | i->AddObserver(vtkCommand::RightButtonReleaseEvent, this->EventCallbackCommand, this->Priority); |
| 301 | |
| 302 | // Add the line |
| 303 | this->CurrentRenderer->AddActor(this->LineActor); |
| 304 | this->LineActor->SetProperty(this->LineProperty); |
| 305 | |
| 306 | // Turn on the handles |
| 307 | for (int j = 0; j < this->NumberOfHandles; ++j) |
| 308 | { |
| 309 | this->CurrentRenderer->AddActor(this->Handle[j]); |
| 310 | this->Handle[j]->SetProperty(this->HandleProperty); |
| 311 | } |
| 312 | this->BuildRepresentation(); |
| 313 | this->SizeHandles(); |
| 314 | |
| 315 | this->InvokeEvent(vtkCommand::EnableEvent, nullptr); |
| 316 | } |
| 317 | |
| 318 | else // disabling---------------------------------------------------------- |
| 319 | { |
nothing calls this directly
no test coverage detected