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

Method Scale

Interaction/Widgets/vtkPointWidget.cxx:574–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

572}
573
574void vtkPointWidget::Scale(double* p1, double* p2, int vtkNotUsed(X), int Y)
575{
576 // Get the motion vector
577 double v[3];
578 v[0] = p2[0] - p1[0];
579 v[1] = p2[1] - p1[1];
580 v[2] = p2[2] - p1[2];
581
582 // int res = this->Cursor3D->GetResolution();
583 double* bounds = this->Cursor3D->GetModelBounds();
584 double* focus = this->Cursor3D->GetFocalPoint();
585
586 // Compute the scale factor
587 double sf = vtkMath::Norm(v) /
588 sqrt((bounds[1] - bounds[0]) * (bounds[1] - bounds[0]) +
589 (bounds[3] - bounds[2]) * (bounds[3] - bounds[2]) +
590 (bounds[5] - bounds[4]) * (bounds[5] - bounds[4]));
591
592 if (Y > this->Interactor->GetLastEventPosition()[1])
593 {
594 sf = 1.0 + sf;
595 }
596 else
597 {
598 sf = 1.0 - sf;
599 }
600
601 // Move the end points
602 double newBounds[6];
603 for (int i = 0; i < 3; i++)
604 {
605 newBounds[2 * i] = sf * (bounds[2 * i] - focus[i]) + focus[i];
606 newBounds[2 * i + 1] = sf * (bounds[2 * i + 1] - focus[i]) + focus[i];
607 }
608
609 this->Cursor3D->SetModelBounds(newBounds);
610 this->Cursor3D->Update();
611}
612
613void vtkPointWidget::CreateDefaultProperties()
614{

Callers 1

OnMouseMoveMethod · 0.95

Calls 4

NormFunction · 0.50
sqrtFunction · 0.50
SetModelBoundsMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected