------------------------------------------------------------------------------
| 1080 | |
| 1081 | //------------------------------------------------------------------------------ |
| 1082 | void vtkAxisActor2D::UpdateAdjustedRange() |
| 1083 | { |
| 1084 | // Try not to update/adjust the range to often, do not update it |
| 1085 | // if the object has not been modified. |
| 1086 | // Nevertheless, try the following optimization: there is no need to |
| 1087 | // update the range if the position coordinate of this actor have |
| 1088 | // changed. But since vtkActor2D::GetMTime() includes the check for |
| 1089 | // both Position and Position2 coordinates, we will have to bypass |
| 1090 | // it. |
| 1091 | |
| 1092 | // NOLINTNEXTLINE(bugprone-parent-virtual-call) |
| 1093 | if (this->vtkActor2D::Superclass::GetMTime() <= this->AdjustedRangeBuildTime) |
| 1094 | { |
| 1095 | return; |
| 1096 | } |
| 1097 | |
| 1098 | if (this->SnapLabelsToGrid) |
| 1099 | { |
| 1100 | details::AdjustAndSplitRange( |
| 1101 | this->Range, this->NumberOfLabels, this->AdjustedRange, this->AdjustedNumberOfLabels); |
| 1102 | } |
| 1103 | else if (this->AdjustLabels) |
| 1104 | { |
| 1105 | double interval; |
| 1106 | vtkAxisActor2D::ComputeRange(this->Range, this->AdjustedRange, this->NumberOfLabels, |
| 1107 | this->AdjustedNumberOfLabels, interval); |
| 1108 | } |
| 1109 | else |
| 1110 | { |
| 1111 | this->AdjustedNumberOfLabels = this->NumberOfLabels; |
| 1112 | this->AdjustedRange[0] = this->Range[0]; |
| 1113 | this->AdjustedRange[1] = this->Range[1]; |
| 1114 | } |
| 1115 | |
| 1116 | if (this->RulerMode) |
| 1117 | { |
| 1118 | double wp1[3], wp2[3], wp21[3]; |
| 1119 | this->PositionCoordinate->GetValue(wp1); |
| 1120 | this->Position2Coordinate->GetValue(wp2); |
| 1121 | vtkMath::Subtract(wp2, wp1, wp21); |
| 1122 | const double worldLength = vtkMath::Norm(wp21); |
| 1123 | this->AdjustedNumberOfLabels = worldLength / this->RulerDistance; |
| 1124 | if (vtkMathUtilities::FuzzyCompare<double>( |
| 1125 | this->AdjustedNumberOfLabels * this->RulerDistance, worldLength)) |
| 1126 | { |
| 1127 | this->AdjustedNumberOfLabels += 1; |
| 1128 | } |
| 1129 | this->AdjustedNumberOfLabels += 2; |
| 1130 | } |
| 1131 | |
| 1132 | if (this->AdjustedNumberOfLabels < 1) |
| 1133 | { |
| 1134 | vtkWarningMacro( |
| 1135 | "Axis expects to have at least 1 label. Will use 1 instead of the computed number " |
| 1136 | << this->AdjustedNumberOfLabels); |
| 1137 | this->AdjustedNumberOfLabels = 1; |
| 1138 | } |
| 1139 |
no test coverage detected