------------------------------------------------------------------------------
| 139 | |
| 140 | //------------------------------------------------------------------------------ |
| 141 | void vtkDistanceWidget::SetEnabled(int enabling) |
| 142 | { |
| 143 | // The handle widgets are not actually enabled until they are placed. |
| 144 | // The handle widgets take their representation from the |
| 145 | // vtkDistanceRepresentation. |
| 146 | if (enabling) |
| 147 | { |
| 148 | if (this->WidgetState == vtkDistanceWidget::Start) |
| 149 | { |
| 150 | reinterpret_cast<vtkDistanceRepresentation*>(this->WidgetRep)->VisibilityOff(); |
| 151 | } |
| 152 | else |
| 153 | { |
| 154 | // The interactor must be set prior to enabling the widget. |
| 155 | if (this->Interactor) |
| 156 | { |
| 157 | this->Point1Widget->SetInteractor(this->Interactor); |
| 158 | this->Point2Widget->SetInteractor(this->Interactor); |
| 159 | } |
| 160 | |
| 161 | this->Point1Widget->SetEnabled(1); |
| 162 | this->Point2Widget->SetEnabled(1); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | if (enabling) //---------------- |
| 167 | { |
| 168 | if (this->Enabled) // already enabled, just return |
| 169 | { |
| 170 | return; |
| 171 | } |
| 172 | |
| 173 | if (!this->Interactor) |
| 174 | { |
| 175 | vtkErrorMacro(<< "The interactor must be set prior to enabling the widget"); |
| 176 | return; |
| 177 | } |
| 178 | |
| 179 | int X = this->Interactor->GetEventPosition()[0]; |
| 180 | int Y = this->Interactor->GetEventPosition()[1]; |
| 181 | |
| 182 | if (!this->CurrentRenderer) |
| 183 | { |
| 184 | this->SetCurrentRenderer(this->Interactor->FindPokedRenderer(X, Y)); |
| 185 | if (this->CurrentRenderer == nullptr) |
| 186 | { |
| 187 | return; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | // We're ready to enable |
| 192 | this->Enabled = 1; |
| 193 | this->CreateDefaultRepresentation(); |
| 194 | this->WidgetRep->SetRenderer(this->CurrentRenderer); |
| 195 | |
| 196 | // Set the renderer, interactor and representation on the two handle |
| 197 | // widgets. |
| 198 | this->Point1Widget->SetRepresentation( |
no test coverage detected