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

Method Scale

Interaction/Widgets/vtkLineWidget.cxx:879–920  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

877
878//------------------------------------------------------------------------------
879void vtkLineWidget::Scale(double* p1, double* p2, int vtkNotUsed(X), int Y)
880{
881 // Get the motion vector
882 double v[3];
883 v[0] = p2[0] - p1[0];
884 v[1] = p2[1] - p1[1];
885 v[2] = p2[2] - p1[2];
886
887 // int res = this->LineSource->GetResolution();
888 double* pt1 = this->LineSource->GetPoint1();
889 double* pt2 = this->LineSource->GetPoint2();
890
891 double center[3];
892 center[0] = (pt1[0] + pt2[0]) / 2.0;
893 center[1] = (pt1[1] + pt2[1]) / 2.0;
894 center[2] = (pt1[2] + pt2[2]) / 2.0;
895
896 // Compute the scale factor
897 double sf = vtkMath::Norm(v) / sqrt(vtkMath::Distance2BetweenPoints(pt1, pt2));
898 if (Y > this->Interactor->GetLastEventPosition()[1])
899 {
900 sf = 1.0 + sf;
901 }
902 else
903 {
904 sf = 1.0 - sf;
905 }
906
907 // Move the end points
908 double point1[3], point2[3];
909 for (int i = 0; i < 3; i++)
910 {
911 point1[i] = sf * (pt1[i] - center[i]) + center[i];
912 point2[i] = sf * (pt2[i] - center[i]) + center[i];
913 }
914
915 this->LineSource->SetPoint1(point1);
916 this->LineSource->SetPoint2(point2);
917 this->LineSource->Update();
918
919 this->BuildRepresentation();
920}
921
922//------------------------------------------------------------------------------
923void vtkLineWidget::CreateDefaultProperties()

Callers 1

OnMouseMoveMethod · 0.95

Calls 8

BuildRepresentationMethod · 0.95
NormFunction · 0.50
sqrtFunction · 0.50
GetPoint1Method · 0.45
GetPoint2Method · 0.45
SetPoint1Method · 0.45
SetPoint2Method · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected