------------------------------------------------------------------------------
| 60 | |
| 61 | //------------------------------------------------------------------------------ |
| 62 | void vtkInteractorObserver::SetCurrentRenderer(vtkRenderer* _arg) |
| 63 | { |
| 64 | if (this->CurrentRenderer == _arg) |
| 65 | { |
| 66 | return; |
| 67 | } |
| 68 | |
| 69 | if (this->CurrentRenderer != nullptr) |
| 70 | { |
| 71 | this->CurrentRenderer->UnRegister(this); |
| 72 | } |
| 73 | |
| 74 | // WARNING: see .h, if the DefaultRenderer is set, whatever the value |
| 75 | // of _arg (except nullptr), we are going to use DefaultRenderer |
| 76 | // Normally when the widget is activated (SetEnabled(1) or when |
| 77 | // keypress activation takes place), the renderer over which the mouse |
| 78 | // pointer is positioned is used to call SetCurrentRenderer(). |
| 79 | // Alternatively, we may want to specify a user-defined renderer to bind the |
| 80 | // interactor to when the interactor observer is activated. |
| 81 | // The problem is that in many 3D widgets, when SetEnabled(0) is called, |
| 82 | // the CurrentRender is set to nullptr. In that case, the next time |
| 83 | // SetEnabled(1) is called, the widget will try to set CurrentRenderer |
| 84 | // to the renderer over which the mouse pointer is positioned, and we |
| 85 | // will use our user-defined renderer. To solve that, we introduced the |
| 86 | // DefaultRenderer ivar, which will be used to force the value of |
| 87 | // CurrentRenderer each time SetCurrentRenderer is called (i.e., no matter |
| 88 | // if SetCurrentRenderer is called with the renderer that was poked at |
| 89 | // the mouse coords, the DefaultRenderer will be used). |
| 90 | |
| 91 | if (_arg && this->DefaultRenderer) |
| 92 | { |
| 93 | _arg = this->DefaultRenderer; |
| 94 | } |
| 95 | |
| 96 | this->CurrentRenderer = _arg; |
| 97 | |
| 98 | if (this->CurrentRenderer != nullptr) |
| 99 | { |
| 100 | this->CurrentRenderer->Register(this); |
| 101 | } |
| 102 | |
| 103 | this->Modified(); |
| 104 | } |
| 105 | |
| 106 | //------------------------------------------------------------------------------ |
| 107 | // This adds the keypress event observer and the delete event observer |