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)
viewport (GH_Viewport)

GH_Viewport

#
public GH_Viewport(Point target, float zoom)
target (Point)
zoom (float)

GH_Viewport

#
public GH_Viewport(Point target)
target (Point)

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

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

Diagonal

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

Height

#
public int Height { get; set; }
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.

MidPoint

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

ScreenPort

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

Size

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

Target

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

TargetRatio

#
public SizeF TargetRatio { get; set; }
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.

Tx

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

Ty

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

VisibleRegion

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

Width

#
public int Width { get; set; }
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.

Zoom

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

Zoom

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

ZoomInverse

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

Methods

ApplyProjection

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

ComputeProjection

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

DollyZoom

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

Duplicate

#
public GH_Viewport Duplicate()

Focus

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

Focus

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

Focus

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

Focus

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

IsVisible

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

IsVisible

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

LimitUnit

#
public float LimitUnit(float guide_value, float no_less_than = -3.4028235E+38, float no_more_than = 3.4028235E+38)
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).
guide_value (float)Initial value.
no_less_than (float = -3.4028235E+38)Minimum allowed visible size on screen.
no_more_than (float = 3.4028235E+38)Maximum allowed visible size on screen.

Project

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

ProjectPoint

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

ProjectRectangle

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

ProjectX

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

ProjectY

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

Set

#
public void Set(GH_Viewport other)
other (GH_Viewport)

SolveUnit

#
public float SolveUnit(float desired, float no_less_than, float no_more_than)
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.
desired (float)Desired value in pixel units.
no_less_than (float)Minimum allowed size in graphics coordinates.
no_more_than (float)Maximum allowed size in graphics coordinates.

Unproject

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

UnprojectPoint

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

UnprojectRectangle

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

UnprojectX

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

UnprojectY

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

XFormMatrix

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