------------------------------------------------------------------------------
| 164 | |
| 165 | //------------------------------------------------------------------------------ |
| 166 | void vtkView::AddRepresentation(vtkDataRepresentation* rep) |
| 167 | { |
| 168 | if (rep != nullptr && !this->IsRepresentationPresent(rep)) |
| 169 | { |
| 170 | // We add the representation to the internal data-structure before calling |
| 171 | // AddToView(). This ensures that if the `rep` itself calls |
| 172 | // AddRepresentation() for an internal representation, the internal |
| 173 | // representation gets added after the `rep` which makes more sense as it |
| 174 | // preserves the order for representations in which AddRepresentation() was |
| 175 | // called. |
| 176 | size_t index = this->Implementation->Representations.size(); |
| 177 | this->Implementation->Representations.emplace_back(rep); |
| 178 | if (rep->AddToView(this)) |
| 179 | { |
| 180 | rep->AddObserver(vtkCommand::SelectionChangedEvent, this->GetObserver()); |
| 181 | |
| 182 | // UpdateEvent is called from push pipeline executions from |
| 183 | // vtkExecutionScheduler. We want to automatically render the view |
| 184 | // when one of our representations is updated. |
| 185 | rep->AddObserver(vtkCommand::UpdateEvent, this->GetObserver()); |
| 186 | |
| 187 | this->AddRepresentationInternal(rep); |
| 188 | } |
| 189 | else |
| 190 | { |
| 191 | this->Implementation->Representations.erase( |
| 192 | this->Implementation->Representations.begin() + index); |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | //------------------------------------------------------------------------------ |
| 198 | void vtkView::SetRepresentation(vtkDataRepresentation* rep) |