The NModel class adds support for the following common features shared by all models:
-
Model Bounds - the model bounds define a rectangle, which bounds the model content. By design you can only get the model bounds via the ModelBounds property. The model bounds are always specified in the model (local) coordinate system. The model bounds projection in the scene coordinate system is in this documentation often referred as rotated bounds. The model bounds help you treat each model as a box.
-
Scene Bounds - models implement the INBoundable interface to indicate that they have controllable bounds in scene coordinates. The bounds of a model are computed by calculating the bounds of the model bounds corners projection in scene coordinates. Changing the model scene bounds actually changes the model local transformation (not the model definition).
-
Pin Point - the pin point is a point, whose position is aligned to the model bounds. The alignment of the pin point is controlled by the PinAlignment property. You can get and set the pin point in model and scene coordinates via the ModelPinPoint and PinPoint properties respectively. The set implementation of both properties will alter the pin alignment.
The pin point is used as default anchor (pivot) point in many transform operations. It is also used to define the relative location of a model in respect to its aggregate model. -
Start and End Points - each model has start and end points, which gives the model a certain direction. The start and end points of a model are exposed in model and scene coordinates through the following properties of each model: StartPoint, EndPoint, ModelStartPoint and ModelEndPoint.
By default start and end points of a model are aligned to the left-middle and right-middle sides of the model bounds. Also by default setting the start or end points will scale the model in the direction of the start-end point vector and rotate the model around the opposite point. Certain models can provide different implementation for their start and end points - for example the start and end points of a bezier curve primitive modify the bezier curve model definition. -
Logical Line - since each model has start and end points, you can logically treat it as a line (or curve) connecting these points. A logical line always starts from the start point and ends at the end point. It's length can be obtained from the Length property.
You can obtain a point along the line length, which corresponds to a percent value with the help of the GetLengthLocation method. You can also obtain the tangent angle (the slope of the line) along the length, which corresponds to a percent value with the help of the GetLengthOrientation method.
The logical line of a model can be reversed with the help of the Reverse method. Reversing the logical line of a model always causes the model to swap its' start and end points. In the case of a 1D shape this operation also forces the shape to swap the ports to which the start and end plugs are currently connected.
By default the logical line of a model is a straight line connecting the start and end points. The logical line of certain models however is a curve - for example bezier curve primitives use a logical line, which follows the bezier curve geometry. -
Contour - each model can be treated as a contour. You can intersect the contour with a vector and get the nearest intersection point (if any). This is done with the help of the GetNearestContourLocation method.
By default the contour of a model is a polygon connecting the model bounds corners. The contour of certain models however is bound to the geometry they represent - for example the contour of an ellipse primitive is the ellipse rim. -
Mouse Event Handling - models implement the INMouseEventHandler interface, which is used by views to delegate mouse events to the model. The default implementation fires the respective mouse event for the model. If the event was not handled it bubbles the event to the previous INMouseEventHandler implementor in the scene hierarchy.
-
Keyboard Event Handling - models implement the INKeyboardEventHandler interface, which is used by views to delegate keyboard events to the model if it is the currently focused element (controlled by the FocusedElementUniqueId property of the NDrawingDocument class). The default implementation fires the respective keyboard event for the model. If the event was not handled it bubbles the event to the previous INKeyboardEventHandler implementor in the scene hierarchy.
-
Drag Drop Event Handling - models implement the INDragDropEventHandler interface, which is used by views to delegate drag-drop events to the model. The default implementation fires the respective drag - drop event for the model. If the event was not handled it bubbles the event to the previous INDragDropEventHandler implementor in the scene hierarchy.