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

Method BuildRepresentation

Interaction/Widgets/vtkCaptionRepresentation.cxx:136–184  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

134
135//------------------------------------------------------------------------------
136void vtkCaptionRepresentation::BuildRepresentation()
137{
138 if (this->GetMTime() > this->BuildTime || this->CaptionActor2D->GetMTime() > this->BuildTime ||
139 (this->Renderer && this->Renderer->GetVTKWindow() &&
140 this->Renderer->GetVTKWindow()->GetMTime() > this->BuildTime))
141 {
142
143 // If the text actor's text scaling is off, we still may want to be able
144 // to change the caption's text to respond to changes in the border/box
145 // sizing. This is done using the *relative* font size factor. We will
146 // also need to change the caption's boundary size accordingly. It
147 // depends on the relationship between the fit of the text to the border.
148 if (!this->Moving && this->CaptionActor2D && this->CaptionActor2D->GetCaption() &&
149 this->CaptionActor2D->GetTextActor()->GetTextScaleMode() ==
150 vtkTextActor::TEXT_SCALE_MODE_NONE)
151 {
152 // Create a dummy text mapper for managing font sizes.
153 vtkNew<vtkTextMapper> textMapper;
154 vtkTextProperty* tprop = textMapper->GetTextProperty();
155 tprop->ShallowCopy(this->CaptionActor2D->GetCaptionTextProperty());
156 textMapper->SetInput(this->CaptionActor2D->GetCaption());
157 int textsize[2];
158 int fsize = vtkTextMapper::SetRelativeFontSize(
159 textMapper, this->Renderer, this->Renderer->GetSize(), textsize, 0.015 * this->FontFactor);
160
161 if (this->Fit == VTK_FIT_TO_BORDER)
162 {
163 this->CaptionActor2D->GetCaptionTextProperty()->SetFontSize(fsize);
164 }
165 else // this->Fit == VTK_FIT_TO_TEXT
166 {
167 }
168 this->AdjustCaptionBoundary();
169 }
170
171 // Ask the superclass the size and set the caption
172 int* pos1 = this->PositionCoordinate->GetComputedDisplayValue(this->Renderer);
173 int* pos2 = this->Position2Coordinate->GetComputedDisplayValue(this->Renderer);
174
175 if (this->CaptionActor2D)
176 {
177 this->CaptionActor2D->GetPositionCoordinate()->SetValue(pos1[0], pos1[1]);
178 this->CaptionActor2D->GetPosition2Coordinate()->SetValue(pos2[0], pos2[1]);
179 }
180
181 // Note that the transform is updated by the superclass
182 this->Superclass::BuildRepresentation();
183 }
184}
185
186//------------------------------------------------------------------------------
187void vtkCaptionRepresentation::AdjustCaptionBoundary()

Calls 12

AdjustCaptionBoundaryMethod · 0.95
GetVTKWindowMethod · 0.80
GetCaptionMethod · 0.80
GetTextActorMethod · 0.80
SetFontSizeMethod · 0.80
GetMTimeMethod · 0.45
GetTextPropertyMethod · 0.45
ShallowCopyMethod · 0.45
SetInputMethod · 0.45
GetSizeMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected