From 333cbec178a19b0a8a56759c997438002b557315 Mon Sep 17 00:00:00 2001
From: Cory Quammen <cory.quammen@kitware.com>
Date: Wed, 21 Sep 2016 11:01:52 -0400
Subject: [PATCH] Invert the effect of the scale factor

The scale factor was applied in an inverted fashion. The
distance should be scaled and the ruler distance scaled by the
inverse scale factor.
---
 Interaction/Widgets/vtkDistanceRepresentation.h     |  4 ++--
 Interaction/Widgets/vtkDistanceRepresentation2D.cxx | 10 ++++------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/Interaction/Widgets/vtkDistanceRepresentation.h b/Interaction/Widgets/vtkDistanceRepresentation.h
index fa693953575..2c693132697 100644
--- a/Interaction/Widgets/vtkDistanceRepresentation.h
+++ b/Interaction/Widgets/vtkDistanceRepresentation.h
@@ -97,8 +97,8 @@ public:
   // will be defined in terms of the scaled space. For example, if the VTK world
   // coordinates are assumed to be in inches, but the desired distance units
   // should be defined in terms of centimeters, the scale factor should be set
-  // to 0.3937. The ruler marks will then be spaced in terms of centimeters, and
-  // the label will contain the measurement in centimeters.
+  // to 2.54. The ruler marks will then be spaced in terms of centimeters, and
+  // the label will show the measurement in centimeters.
   vtkSetMacro(Scale,double);
   vtkGetMacro(Scale,double);
 
diff --git a/Interaction/Widgets/vtkDistanceRepresentation2D.cxx b/Interaction/Widgets/vtkDistanceRepresentation2D.cxx
index 4c9ab7e240e..7ea56c6a708 100644
--- a/Interaction/Widgets/vtkDistanceRepresentation2D.cxx
+++ b/Interaction/Widgets/vtkDistanceRepresentation2D.cxx
@@ -183,16 +183,14 @@ void vtkDistanceRepresentation2D::BuildRepresentation()
     this->AxisActor->GetPoint1Coordinate()->SetValue(p1);
     this->AxisActor->GetPoint2Coordinate()->SetValue(p2);
     this->AxisActor->SetRulerMode(this->RulerMode);
-    this->AxisActor->SetRulerDistance(this->RulerDistance * this->Scale);
-    this->AxisActor->SetNumberOfLabels(this->NumberOfRulerTicks);
-
-    double scaledDistance = this->Distance;
     if (this->Scale != 0.0)
       {
-      scaledDistance /= this->Scale;
+      this->AxisActor->SetRulerDistance(this->RulerDistance / this->Scale);
       }
+    this->AxisActor->SetNumberOfLabels(this->NumberOfRulerTicks);
+
     char string[512];
-    sprintf(string, this->LabelFormat, scaledDistance);
+    sprintf(string, this->LabelFormat, this->Distance * this->Scale);
     this->AxisActor->SetTitle(string);
 
     this->BuildTime.Modified();
-- 
GitLab