MCPcopy Create free account
hub / github.com/Kitware/VTK / BuildRepresentation

Method BuildRepresentation

Interaction/Widgets/vtkAngleRepresentation2D.cxx:213–344  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

211
212//------------------------------------------------------------------------------
213void vtkAngleRepresentation2D::BuildRepresentation()
214{
215 if (this->Point1Representation == nullptr || this->CenterRepresentation == nullptr ||
216 this->Point2Representation == nullptr)
217 {
218 // for now, return. Could create defaults here.
219 return;
220 }
221
222 if (!(this->GetMTime() > this->BuildTime ||
223 this->Point1Representation->GetMTime() > this->BuildTime ||
224 this->CenterRepresentation->GetMTime() > this->BuildTime ||
225 this->Point2Representation->GetMTime() > this->BuildTime ||
226 (this->Renderer && this->Renderer->GetVTKWindow() &&
227 this->Renderer->GetVTKWindow()->GetMTime() > this->BuildTime)))
228 {
229 return;
230 }
231
232 this->Superclass::BuildRepresentation();
233
234 // Local coordinate values
235 vtkVector3d p1w, p2w, cw;
236 this->GetPoint1WorldPosition(p1w.GetData());
237 this->GetCenterWorldPosition(cw.GetData());
238 this->GetPoint2WorldPosition(p2w.GetData());
239
240 // Update the rays
241 this->Ray1->GetPositionCoordinate()->SetValue(cw.GetData());
242 this->Ray1->GetPosition2Coordinate()->SetValue(p1w.GetData());
243 this->Ray2->GetPositionCoordinate()->SetValue(cw.GetData());
244 this->Ray2->GetPosition2Coordinate()->SetValue(p2w.GetData());
245
246 // Compute the angle.
247 // NOTE: There is some concern that there may be fluctuations in the angle
248 // value as the camera moves, etc. This calculation may have to be dampened.
249
250 vtkVector3d vector1 = p1w - cw;
251 vtkVector3d vector2 = p2w - cw;
252 const double normV1 = vector1.Normalize();
253 const double normV2 = vector2.Normalize();
254 const double angle = vtkMath::DegreesFromRadians(std::acos(vector1.Dot(vector2))) * this->Scale;
255
256 // Construct label
257 std::string labelFormat = this->LabelFormat ? vtk::to_std_format(this->LabelFormat) : "";
258 std::string string;
259 VTK_FORMAT_IF_ERROR_RETURN(string = vtk::format(labelFormat, angle), );
260 if (string.empty())
261 {
262 this->ArcVisibility = 0;
263 vtkWarningMacro("Couldn't format label.");
264 return;
265 }
266 this->Arc->SetLabel(string.c_str());
267
268 // Place the label and place the arc
269 vtkVector3d p1d, p2d, cd;
270 this->GetPoint1DisplayPosition(p1d.GetData());

Callers 7

RenderOverlayMethod · 0.95

Calls 15

to_std_formatFunction · 0.85
GetVTKWindowMethod · 0.80
NormMethod · 0.80
acosFunction · 0.50
formatFunction · 0.50

Tested by

no test coverage detected