------------------------------------------------------------------------------
| 76 | |
| 77 | //------------------------------------------------------------------------------ |
| 78 | void vtkLineWidget2::SetEnabled(int enabling) |
| 79 | { |
| 80 | int enabled = this->Enabled; |
| 81 | |
| 82 | // We do this step first because it sets the CurrentRenderer |
| 83 | this->Superclass::SetEnabled(enabling); |
| 84 | |
| 85 | // We defer enabling the handles until the selection process begins |
| 86 | if (enabling && !enabled) |
| 87 | { |
| 88 | // Don't actually turn these on until cursor is near the end points or the line. |
| 89 | this->CreateDefaultRepresentation(); |
| 90 | this->Point1Widget->SetRepresentation( |
| 91 | reinterpret_cast<vtkLineRepresentation*>(this->WidgetRep)->GetPoint1Representation()); |
| 92 | this->Point1Widget->SetInteractor(this->Interactor); |
| 93 | this->Point1Widget->GetRepresentation()->SetRenderer(this->CurrentRenderer); |
| 94 | |
| 95 | this->Point2Widget->SetRepresentation( |
| 96 | reinterpret_cast<vtkLineRepresentation*>(this->WidgetRep)->GetPoint2Representation()); |
| 97 | this->Point2Widget->SetInteractor(this->Interactor); |
| 98 | this->Point2Widget->GetRepresentation()->SetRenderer(this->CurrentRenderer); |
| 99 | |
| 100 | this->LineHandle->SetRepresentation( |
| 101 | reinterpret_cast<vtkLineRepresentation*>(this->WidgetRep)->GetLineHandleRepresentation()); |
| 102 | this->LineHandle->SetInteractor(this->Interactor); |
| 103 | this->LineHandle->GetRepresentation()->SetRenderer(this->CurrentRenderer); |
| 104 | |
| 105 | if (this->Parent) |
| 106 | { |
| 107 | this->Parent->AddObserver( |
| 108 | vtkCommand::KeyPressEvent, this->KeyEventCallbackCommand, this->Priority); |
| 109 | this->Parent->AddObserver( |
| 110 | vtkCommand::KeyReleaseEvent, this->KeyEventCallbackCommand, this->Priority); |
| 111 | } |
| 112 | else |
| 113 | { |
| 114 | this->Interactor->AddObserver( |
| 115 | vtkCommand::KeyPressEvent, this->KeyEventCallbackCommand, this->Priority); |
| 116 | this->Interactor->AddObserver( |
| 117 | vtkCommand::KeyReleaseEvent, this->KeyEventCallbackCommand, this->Priority); |
| 118 | } |
| 119 | } |
| 120 | else if (!enabling && enabled) |
| 121 | { |
| 122 | this->Point1Widget->SetEnabled(0); |
| 123 | this->Point2Widget->SetEnabled(0); |
| 124 | this->LineHandle->SetEnabled(0); |
| 125 | |
| 126 | if (this->Parent) |
| 127 | { |
| 128 | this->Parent->RemoveObserver(this->KeyEventCallbackCommand); |
| 129 | } |
| 130 | else |
| 131 | { |
| 132 | this->Interactor->RemoveObserver(this->KeyEventCallbackCommand); |
| 133 | } |
| 134 | } |
| 135 | } |
no test coverage detected