------------------------------------------------------------------------------ Sets text string for label vectors. Allocates memory if necessary. ------------------------------------------------------------------------------
| 1113 | // Sets text string for label vectors. Allocates memory if necessary. |
| 1114 | //------------------------------------------------------------------------------ |
| 1115 | void 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. |