Table of Contents

CadView

from OpenCAD2D import CadView

class CadView(System.Object) ยท CadView in the .NET reference

What part of a space the canvas shows and at what zoom: the point of the drawing at the centre of the canvas and the pixels one drawing unit takes, and the angle the drawing is turned by on the canvas, nought but through a twisted viewport. Zooming about the cursor and panning are arithmetic on these numbers, so they are tested here with no window.

Constructors

__init__

.NET

def __init__(self, width: float, height: float) -> None

Makes a view of a canvas of a size, showing the origin at 1 pixel to the unit.

Properties and fields

CenterX

.NET

@property
def CenterX(self) -> float

Gets the X of the point of the drawing at the centre of the canvas.

CenterY

.NET

@property
def CenterY(self) -> float

Gets the Y of the point of the drawing at the centre of the canvas.

DrawingToScreen

.NET

@property
def DrawingToScreen(self) -> Affine2

Gets the transformation from the drawing to the pixels of the canvas, Y up in the drawing becoming Y down on the screen.

Height

.NET

@property
def Height(self) -> float

Gets the height of the canvas in pixels.

PixelsPerUnit

.NET

@property
def PixelsPerUnit(self) -> float

Gets the pixels one drawing unit takes.

Twist

.NET

@property
def Twist(self) -> float

Gets the angle the drawing is turned by on the canvas, in radians, counter-clockwise: nought but for model space seen through a viewport whose view is twisted, as a viewport twisted by 30 degrees shows the X axis of the world rising at 30 degrees.

VisibleBox

.NET

@property
def VisibleBox(self) -> DisplayBox

Gets the box of the drawing the canvas shows: through a twisted viewport the box about the canvas turned.

Width

.NET

@property
def Width(self) -> float

Gets the width of the canvas in pixels.

Methods

DrawingToPixel

.NET

def DrawingToPixel(self, x: float, y: float) -> tuple[float, float]

Gets the pixel of a point of the drawing.

Pan

.NET

def Pan(self, dx: float, dy: float) -> None

Pans: moves the drawing under the canvas by a number of pixels, as dragging with the middle button does.

Resize

.NET

def Resize(self, width: float, height: float) -> None

Changes the size of the canvas, keeping the centre of the view where it is.

ScreenToDrawing

.NET

def ScreenToDrawing(self, px: float, py: float) -> tuple[float, float]

Gets the point of the drawing under a pixel.

ZoomAt

.NET

def ZoomAt(self, px: float, py: float, factor: float) -> None

Zooms about a pixel: the point of the drawing under it stays under it.

ZoomTo

.NET

def ZoomTo(self, box: DisplayBox, marginFraction: float = ...) -> None

Shows a box wholly, with a margin, as ZOOM Extents does; through a twisted viewport the box turned.

ZoomToHeight

.NET

def ZoomToHeight(self, centerX: float, centerY: float, height: float) -> None

Shows a view given by its centre and its height, as AutoCAD keeps the view of a viewport in a drawing (the VPORT record's groups 12, 22 and 40): the height of the canvas covers height units, whatever the canvas's width, so that a canvas twice as wide shows twice the width. The turn of the view is kept.