GH_Viewport

References
public sealed class GH_Viewport
Provides functionality for panning and zooming in a GH_Canvas environment.

Constructors

GH_Viewport

#
public GH_Viewport()

GH_Viewport

#
public GH_Viewport(
GH_Viewport
viewport
)

GH_Viewport

#
public GH_Viewport(
Point
target,
zoom
)

GH_Viewport

#
public GH_Viewport(
Point
target
)

Fields

ZoomDefault

#
public static readonly float ZoomDefault

ZoomDefaultLower

#
public static readonly float ZoomDefaultLower

ZoomDefaultUpper

#
public static readonly float ZoomDefaultUpper

ZoomMaximum

#
public const float ZoomMaximum = 50

ZoomMinimum

#
public const float ZoomMinimum = 0.05

Properties

ControlMidPoint

#
Gets the point in the exact center of the viewport in control coordinates.
public PointF ControlMidPoint { get; }

Diagonal

#
Gets the length of the diagonal of the viewport in canvas coordinates.
public float Diagonal { get; }

Height

#
Gets or sets the height of the viewport. Typically this is tied to the dimensions of the canvas. Height is not allowed to go below 5 pixels.
public int Height { get; set; }

MidPoint

#
Gets or sets the canvas coordinate that is directly underneath the center of the viewport.
public PointF MidPoint { get; set; }

ScreenPort

#
Gets the dimensions of the viewport in control coordinates.
public Rectangle ScreenPort { get; }

Size

#
Gets or sets the size of the viewport. The size is typically tied to the dimensions of the Canvas.
public Size Size { get; set; }

Target

#
Gets or sets the location of the target pixel. The target represents where the canvas origin is drawn.
public Point Target { get; set; }

TargetRatio

#
Gets or sets the target ratio with respect to the viewport dimensions. This is a useful tool to prevent weird view changes during a canvas resize.
public SizeF TargetRatio { get; set; }

Tx

#
Gets or sets the x-component of the target pixel. The target represents where the canvas origin is drawn.
public int Tx { get; set; }

Ty

#
Gets or sets the y-component of the target pixel. The target represents where the canvas origin is drawn.
public int Ty { get; set; }

VisibleRegion

#
Gets the rectangle in canvas coordinates that is visible in the control.
public RectangleF VisibleRegion { get; }

Width

#
Gets or sets the width of the viewport. Typically this is tied to the dimensions of the canvas. Width is not allowed to go below 5 pixels.
public int Width { get; set; }

Zoom

#
Gets or sets the Zoom factor of the viewport. Please assign only sensible values.
public float Zoom { get; set; }

Zoom

#
Sets the zoom of the viewport with a view anchor.
public float Zoom[bool adjustTarget] { set; }
adjustTarget (bool)If true, the target will be adjusted so that the center point remains the same.

ZoomInverse

#
Gets the inverse of the zoom.
public float ZoomInverse { get; }

Methods

ApplyProjection

#
Apply the current display transformation to a Graphics object.
public void ApplyProjection()

ComputeProjection

#
Forces a recomputation of all cached data.
public void ComputeProjection()

DollyZoom

#
Advanced interface function for mouse 'dolly' zooming.
public bool DollyZoom(
e
Event arguments.
)
True if a change to the viewport was made, otherwise false.

Duplicate

#
public GH_Viewport Duplicate()

Focus

#
Look at a specific object.
public void Focus(
attribute
Object attribute to focus on.
)

Focus

#
Look at a set of specific objects.
public void Focus(
attributes
Object attributes to focus on.
)

Focus

#
Look at a specific point.
public void Focus(
Point
pt
Point to focus on.
)

Focus

#
Look at a specific point.
public void Focus(
PointF
pt
Point to focus on.
)

IsVisible

#
Test visibility of a point.
public bool IsVisible(
ref PointF
pt,
Point in canvas coordinates.
margin = 0
Fuzzy area around point to test.
)
True if the point is visible in the control upon projection.

IsVisible

#
Test visibility of a rectangle.
public bool IsVisible(
rec,
Rectangle in canvas coordinates.
margin = 0
Fuzzy area around rectangle to test.
)
True if the rectangle is visible in the control upon projection.

LimitUnit

#
Utility function for calculating pixel dimensions in a zoom-aware environment. The desired value is put through the zoom projection and if the resulting size (as displayed on the screen) exceeds the visual limits it is clipped. This function can be used for example to make sure that a certain penwidth never exceeds visual limits (i.e. it doesn't get too thin or too thick on the screen).
public float LimitUnit(
guide_value,
Initial value.
no_less_than = -3.4028235E+38,
Minimum allowed visible size on screen.
no_more_than = 3.4028235E+38
Maximum allowed visible size on screen.
)

Project

#
Transform a point from canvas into control coordinate space.
public void Project(
ref PointF
pt
Point to transform.
)

ProjectPoint

#
Project a point from canvas coordinates into control coordinates.
public PointF ProjectPoint(
PointF
pt
The point in canvas coordinates.
)
The associated point in control pixel coordinates.

ProjectRectangle

#
Project a rectangle from canvas coordinates into control coordinates.
public RectangleF ProjectRectangle(
rec
The rectangle in canvas coordinates.
)
The associated rectangle in control pixel coordinates.

ProjectX

#
Project a value along constant X from canvas coordinates into control coordinates.
public float ProjectX(
x
The constant X value in canvas coordinates.
)
The associated X value in control pixel coordinates.

ProjectY

#
Project a value along constant Y from canvas coordinates into control coordinates.
public float ProjectY(
y
The constant Y value in canvas coordinates.
)
The associated Y value in control pixel coordinates.

Set

#
public void Set()

SolveUnit

#
Utility function for calculating graphics dimensions in a zoom-aware environment. This function can be used for example to compute the linewidth of a pen which always needs to appear as 3 pixels thick on the screen regardless of zoom values.
public float SolveUnit(
desired,
Desired value in pixel units.
no_less_than,
Minimum allowed size in graphics coordinates.
no_more_than
Maximum allowed size in graphics coordinates.
)

Unproject

#
Transform a point from control into canvas coordinate space.
public void Unproject(
ref PointF
pt
Point to transform.
)

UnprojectPoint

#
Project a point from control coordinates into canvas coordinates.
public PointF UnprojectPoint(
PointF
pt
The point in control coordinates.
)
The associated point in canvas coordinates.

UnprojectRectangle

#
Project a rectangle from control coordinates into canvas coordinates.
public RectangleF UnprojectRectangle(
rec
The rectangle in control coordinates.
)
The associated rectangle in canvas coordinates.

UnprojectX

#
Project a value along constant X from control coordinates into canvas coordinates.
public float UnprojectX(
x
The constant X value in control coordinates.
)
The associated X value in canvas coordinates.

UnprojectY

#
Project a value along constant Y from control coordinates into canvas coordinates.
public float UnprojectY(
y
The constant Y value in control coordinates.
)
The associated Y value in canvas coordinates.

XFormMatrix

#
Gets the display transformation cached by this viewport.
public Matrix XFormMatrix(
projection
)