Interface IView
- Namespace
- CADability
- Assembly
- CADability.dll
Interface of a view that shows a Model (or, in case of the LayoutView, a Layout) and is hosted in an ICanvas. The canvas forwards the paint, mouse, scroll and drag and drop messages of the framework to the view, and the view uses the canvas to invalidate the display and to set the cursor. The actions (Action) use the view to pick and snap objects, to register paint handlers for their feedback and to convert between screen and world coordinates via its Projection. The implementations are ModelView (the normal 3d view), GDI2DView, LayoutView and AnimatedView; the view that currently receives the input is ActiveView.
public interface IView
Properties
AllowContextMenu
Whether a right click in this view opens the context menu of the current action. The ModelView and the GDI2DView take the initial value from the global setting "AllowContextMenu".
bool AllowContextMenu { get; }
Property Value
AllowDrag
Whether objects may be dragged out of this view, e.g. to another view or application. The ModelView and the GDI2DView take the initial value from the global setting "AllowDrag"; the other views return false.
bool AllowDrag { get; }
Property Value
AllowDrop
Whether objects may be dropped on this view. The canvas reports this to the framework. The ModelView and the GDI2DView take the initial value from the global setting "AllowDrop"; the other views return false.
bool AllowDrop { get; }
Property Value
Canvas
The ICanvas this view is currently connected to (see Connect(ICanvas)), null while the view is not displayed.
ICanvas Canvas { get; }
Property Value
DisplayRectangle
The rectangle of the canvas in pixels in which the view is displayed (the ClientRectangle). Actions use it e.g. as the default area for a pick space. The LayoutView returns an empty rectangle while it is not connected to a canvas.
Rectangle DisplayRectangle { get; }
Property Value
LastSnapMode
The kind of snapping that took place in the last call to AdjustPoint(Point, out GeoPoint, GeoObjectList).
SnapPointFinder.DidSnapModes LastSnapMode { get; }
Property Value
LastSnapObject
The object that was snapped to by the last call to AdjustPoint(Point, out GeoPoint, GeoObjectList), null if the last call did not snap to an object.
IGeoObject LastSnapObject { get; }
Property Value
Model
The Model displayed by this view. The LayoutView, which may show several models, returns the active model of the project.
Model Model { get; }
Property Value
Name
The name of the view. It is shown as the label of the view in the property page and used by the frame and the project to identify the view (e.g. in the menu that switches between the views), so it should be unique among the views of a project.
string Name { get; }
Property Value
PaintType
Currently we support two types "GDI" and "3D"
string PaintType { get; }
Property Value
ProjectedModel
The ProjectedModel of this view: the model together with its projection, display lists and visible layers. Only the ModelView has one; the LayoutView and the GDI2DView return null, the AnimatedView throws an exception.
ProjectedModel ProjectedModel { get; }
Property Value
Projection
The Projection of this view, which defines the view direction, the scaling and placement of the model on the canvas and the drawing plane. Setting it replaces the projection of the view (the views keep a clone); the view does not repaint by itself, call InvalidateAll(). The LayoutView has no projection of its own and returns a projection from the top.
Projection Projection { get; set; }
Property Value
Methods
AdjustPoint(GeoPoint, Point, out GeoPoint, GeoObjectList)
Same as AdjustPoint(Point, out GeoPoint, GeoObjectList), but with a base point that enables the snap modes relative to a
point (see SnapPointFinder): snapping to the horizontal, vertical, 30° or 45° directions from BasePoint.
Used by constructions that already know the previous point.
SnapPointFinder.DidSnapModes AdjustPoint(GeoPoint BasePoint, Point MousePoint, out GeoPoint WorldPoint, GeoObjectList ToIgnore)
Parameters
BasePointGeoPointThe reference point in world coordinates, typically the previous point of the construction
MousePointPointMouse position in client coordinates of the canvas
WorldPointGeoPointThe snapped point (or the point on the drawing plane) in world coordinates
ToIgnoreGeoObjectListObjects that are excluded from snapping, may be null
Returns
- SnapPointFinder.DidSnapModes
The kind of snapping that took place
AdjustPoint(Point, out GeoPoint, GeoObjectList)
Snaps the mouse position to the objects of the model according to the current snap settings of the frame (SnapMode: end points, intersections, the grid etc.) and returns the resulting point in world coordinates. If nothing was snapped, the point on the drawing plane under the mouse is returned and the result is DidNotSnap. The snapped object and the snap mode are available afterwards as LastSnapObject and LastSnapMode. Views that do not support snapping (the LayoutView) always return DidNotSnap.
SnapPointFinder.DidSnapModes AdjustPoint(Point MousePoint, out GeoPoint WorldPoint, GeoObjectList ToIgnore)
Parameters
MousePointPointMouse position in client coordinates of the canvas
WorldPointGeoPointThe snapped point (or the point on the drawing plane) in world coordinates
ToIgnoreGeoObjectListObjects that are excluded from snapping (e.g. the object currently being constructed), may be null
Returns
- SnapPointFinder.DidSnapModes
The kind of snapping that took place
Connect(ICanvas)
Called by the canvas when it starts to show this view (ShowView(IView)). The view keeps the canvas and connects its display lists to the paint engine of the canvas (PaintTo3D).
void Connect(ICanvas canvas)
Parameters
canvasICanvasThe canvas that displays the view from now on
Disconnect(ICanvas)
Called by the canvas when it stops showing this view or is disposed. The view releases the display lists it created for the paint engine of this canvas.
void Disconnect(ICanvas canvas)
Parameters
canvasICanvasThe canvas that no longer displays the view
DoDragDrop(GeoObjectList, DragDropEffects)
Starts a drag and drop operation with the provided objects as the data, see DoDragDrop(GeoObjectList, DragDropEffects). Views that do not support dragging return None without doing anything.
DragDropEffects DoDragDrop(GeoObjectList dragList, DragDropEffects all)
Parameters
dragListGeoObjectListThe objects to drag
allDragDropEffectsThe effects (copy, move, link) the source allows
Returns
- DragDropEffects
The effect that was performed by the drop target
GetDataPresent(object)
Extracts the objects from the data of a drag and drop (or clipboard) operation, see GetDataPresent(object).
GeoObjectList GetDataPresent(object data)
Parameters
dataobjectThe data object of the framework, e.g. the data of a drag event
Returns
- GeoObjectList
The objects contained in the data, null if the data does not contain CADability objects
GetShowProperties(IFrame)
Returns the entry that represents this view in the property page (the control center), through which the user changes the settings of the view (projection, visible layers, paper size etc.). The views implement IShowProperty themselves and return this.
IShowProperty GetShowProperties(IFrame Frame)
Parameters
FrameIFrameThe frame that will display the properties
Returns
- IShowProperty
The property entry of the view
HScroll(double)
Scrolls the view horizontally to an absolute position, typically in reaction to a scroll bar. The position refers to the total display extent as reported by ScrollPositionChangedEvent; nothing happens when the whole extent is visible. The LayoutView and the AnimatedView do not scroll this way.
void HScroll(double Position)
Parameters
PositiondoubleScroll position from 0.0 (leftmost) to 1.0 (rightmost)
Invalidate(DrawingAspect, Rectangle)
Requests a repaint. The parameters are a remnant of the former bitmap based display, where each PaintBuffer.DrawingAspect had its own bitmap; all current views ignore them and repaint the whole canvas.
void Invalidate(PaintBuffer.DrawingAspect aspect, Rectangle ToInvalidate)
Parameters
aspectPaintBuffer.DrawingAspectThe aspect (background, drawing, selection, active objects) that needs repainting
ToInvalidateRectangleThe rectangle to repaint in client coordinates of the canvas
InvalidateAll()
Requests a complete repaint of the view. The AnimatedView and the GDI2DView also discard their display lists so that the model is rebuilt on the next paint.
void InvalidateAll()
OnDragDrop(DragEventArgs)
Called by the canvas when data is dropped on it. The ModelView and the GDI2DView add the dropped objects (see GetDataPresent(object)) to their model at the drop position on the drawing plane; the other views ignore the drop.
void OnDragDrop(DragEventArgs drgevent)
Parameters
drgeventDragEventArgsThe drag event with the data, the screen position and the allowed effects
OnDragEnter(DragEventArgs)
Called by the canvas when a drag and drop operation enters its client area. The ModelView and the GDI2DView extract the dragged objects and show them following the mouse until they are dropped or the drag leaves the view; the other views ignore it.
void OnDragEnter(DragEventArgs drgevent)
Parameters
drgeventDragEventArgsThe drag event with the data, the screen position and the allowed effects
OnDragLeave(EventArgs)
Called by the canvas when a drag and drop operation leaves its client area without dropping. The preview of the dragged objects is removed.
void OnDragLeave(EventArgs e)
Parameters
eEventArgsEmpty event arguments
OnDragOver(DragEventArgs)
Called by the canvas while a drag and drop operation moves over its client area. The preview of the dragged objects is moved to the current mouse position and the effect (move or copy) is set according to the allowed effects and the modifier keys.
void OnDragOver(DragEventArgs drgevent)
Parameters
drgeventDragEventArgsThe drag event with the screen position and the allowed effects
OnMouseDoubleClick(MouseEventArgs)
Called by the canvas on a double click. The views only offer the message to their mouse filter events (e.g. MouseDoubleClick).
void OnMouseDoubleClick(MouseEventArgs e)
Parameters
eMouseEventArgsThe mouse event, position in client coordinates of the canvas
OnMouseDown(MouseEventArgs)
Called by the canvas on a mouse down message. The view makes itself the ActiveView, prepares panning (middle button or Ctrl+left button) and forwards the message to the ActionStack of the frame, which hands it to the current action.
void OnMouseDown(MouseEventArgs e)
Parameters
eMouseEventArgsThe mouse event, position in client coordinates of the canvas
OnMouseEnter(EventArgs)
Called by the canvas when the mouse enters its client area. The message is forwarded to the ActionStack of the frame.
void OnMouseEnter(EventArgs e)
Parameters
eEventArgsEmpty event arguments
OnMouseHover(EventArgs)
Called by the canvas when the mouse rests on it for a moment. The message is forwarded to the ActionStack of the frame.
void OnMouseHover(EventArgs e)
Parameters
eEventArgsEmpty event arguments
OnMouseLeave(EventArgs)
Called by the canvas when the mouse leaves its client area. The message is forwarded to the ActionStack of the frame.
void OnMouseLeave(EventArgs e)
Parameters
eEventArgsEmpty event arguments
OnMouseMove(MouseEventArgs)
Called by the canvas on a mouse move message. With the middle button pressed the view pans (with Ctrl: rotates the view direction), otherwise the message is forwarded to the ActionStack of the frame, which hands it to the current action.
void OnMouseMove(MouseEventArgs e)
Parameters
eMouseEventArgsThe mouse event, position in client coordinates of the canvas
OnMouseUp(MouseEventArgs)
Called by the canvas on a mouse up message. The message is forwarded to the ActionStack of the frame. The ModelView and the AnimatedView additionally set the fix point of the view rotation when Ctrl+Shift and the middle button are used, and the ModelView recalculates its display lists after a rotation.
void OnMouseUp(MouseEventArgs e)
Parameters
eMouseEventArgsThe mouse event, position in client coordinates of the canvas
OnMouseWheel(MouseEventArgs)
Called by the canvas on a mouse wheel message. The views zoom in or out around the mouse position by the factor given by the global setting "MouseWheelZoomFactor".
void OnMouseWheel(MouseEventArgs e)
Parameters
eMouseEventArgsThe mouse event with the wheel delta
OnPaint(PaintEventArgs)
Called by the canvas when it has to be repainted. The view clears the canvas with its background color, paints the model with PaintTo3D and then calls the registered paint handlers (see SetPaintHandler(DrawingAspect, PaintView)).
void OnPaint(PaintEventArgs e)
Parameters
ePaintEventArgsThe paint event with the clip rectangle
OnSizeChanged(Rectangle)
Called by the canvas when its size has changed. The ModelView adapts the projection so that the area that was visible before stays visible, the other views just repaint.
void OnSizeChanged(Rectangle oldClientRectangle)
Parameters
oldClientRectangleRectangleThe client rectangle of the canvas before the change
PickObjects(Point, PickMode)
Returns the objects of the model that are hit by a small square (about 10 pixels) around the mouse position, taking only the visible layers
of the view into account. Which objects are returned (the frontmost object only, all objects, only faces, only edges...) depends on
pickMode. The result is empty when nothing was hit; the LayoutView (and the AnimatedView
while the animation is running) return null.
GeoObjectList PickObjects(Point MousePoint, PickMode pickMode)
Parameters
MousePointPointMouse position in client coordinates of the canvas
pickModePickModeHow to pick, see PickMode
Returns
- GeoObjectList
The picked objects
RemovePaintHandler(DrawingAspect, PaintView)
Removes a handler that was registered with SetPaintHandler(DrawingAspect, PaintView).
void RemovePaintHandler(PaintBuffer.DrawingAspect aspect, PaintView PaintHandler)
Parameters
aspectPaintBuffer.DrawingAspectThe aspect the handler was registered for
PaintHandlerPaintViewThe handler to remove
SetCursor(string)
Sets the mouse cursor of the canvas. The cursor is identified by a name, e.g. "Arrow", "Hand", "SizeAll", "WaitCursor" or the names of the cursor resources of CADability; the canvas maps it to a cursor of the framework (see Cursor).
void SetCursor(string cursor)
Parameters
cursorstringName of the cursor
SetPaintHandler(DrawingAspect, PaintView)
Registers a PaintView handler that is called at the end of each paint cycle of the view, so that the caller can draw additional objects on top of the model with the paint engine of the view. Actions use it to show their feedback and the selection (Active and Select). Remove the handler with RemovePaintHandler(DrawingAspect, PaintView) when it is no longer needed. The LayoutView ignores the call.
void SetPaintHandler(PaintBuffer.DrawingAspect aspect, PaintView PaintHandler)
Parameters
aspectPaintBuffer.DrawingAspectThe aspect the handler draws: Background, Select or Active; this determines the order in which the handlers are called
PaintHandlerPaintViewThe handler to add
VScroll(double)
Scrolls the view vertically to an absolute position, typically in reaction to a scroll bar. The position refers to the total display extent as reported by ScrollPositionChangedEvent; nothing happens when the whole extent is visible. The LayoutView and the AnimatedView do not scroll this way.
void VScroll(double Position)
Parameters
PositiondoubleScroll position from 0.0 (bottom) to 1.0 (top)
ZoomDelta(double)
Zooms by the provided factor around the center of the display rectangle: factors smaller than 1.0 zoom in, factors greater than 1.0 zoom out. The frame calls it for the zoom in and zoom out menu commands.
void ZoomDelta(double f)
Parameters
fdoubleFactor by which the visible area is scaled
ZoomToRect(BoundingRect)
Changes the scaling and placement of the Projection so that the provided rectangle fills the DisplayRectangle (the aspect ratio is kept, so the rectangle is centered in the longer direction) and repaints the view. The view direction is not changed.
void ZoomToRect(BoundingRect World2D)
Parameters
World2DBoundingRectThe rectangle to show, in the 2d coordinate system of the projection (world coordinates projected into the view plane)
ZoomTotal(double)
Zooms so that the whole model (for the LayoutView: the whole paper) is visible. The view direction is not changed.
void ZoomTotal(double f)
Parameters
fdoubleFactor by which the extent is enlarged before it is fitted into the display rectangle: 1.1 leaves a small margin, 1.0 fits exactly
Events
ScrollPositionChangedEvent
Raised when the visible part of the display extent changes (zoom, scroll, resize), so that the host can update its scroll bars. See ScrollPositionChanged for the meaning of the parameters. Only the ModelView and the GDI2DView raise it; the LayoutView does not implement it.
event ScrollPositionChanged ScrollPositionChangedEvent