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

Method SetLabels

Rendering/Annotation/vtkAxisActor.cxx:1115–1150  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Sets text string for label vectors. Allocates memory if necessary. ------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1113// Sets text string for label vectors. Allocates memory if necessary.
1114//------------------------------------------------------------------------------
1115void vtkAxisActor::SetLabels(vtkStringArray* labels)
1116{
1117 //
1118 // If the number of labels has changed, re-allocate the correct
1119 // amount of memory.
1120 //
1121 int numLabels = labels->GetNumberOfValues();
1122 if (numLabels < 0)
1123 {
1124 vtkErrorMacro(<< "Number of labels " << numLabels << " is invalid");
1125 return;
1126 }
1127 if (this->NumberOfLabelsBuilt != numLabels)
1128 {
1129 this->LabelProps.clear();
1130 this->LabelProps.reserve(numLabels);
1131
1132 for (int i = 0; i < numLabels; i++)
1133 {
1134 auto currentLabel = std::make_shared<vtkTextActorInterfaceInternal>();
1135 currentLabel->SetAxis(this);
1136 this->LabelProps.push_back(currentLabel);
1137 }
1138 }
1139
1140 //
1141 // Set the label vector text.
1142 //
1143 for (int i = 0; i < numLabels; i++)
1144 {
1145 vtkTextActorInterfaceInternal* currentLabel = this->LabelProps[i].get();
1146 currentLabel->SetInputText(labels->GetValue(i));
1147 }
1148 this->NumberOfLabelsBuilt = numLabels;
1149 this->LabelBuildTime.Modified();
1150}
1151
1152//-----------------------------------------------------------------------------*
1153// Creates Poly data (lines) from tickmarks (minor/major), gridlines, and axis.

Callers 4

RequestDataMethod · 0.45
BuildLabelsMethod · 0.45
InitializeAxisFunction · 0.45

Calls 9

SetInputTextMethod · 0.80
GetNumberOfValuesMethod · 0.45
clearMethod · 0.45
reserveMethod · 0.45
SetAxisMethod · 0.45
push_backMethod · 0.45
getMethod · 0.45
GetValueMethod · 0.45
ModifiedMethod · 0.45

Tested by 1

InitializeAxisFunction · 0.36