RhinoViewport
ReferencesDisplays geometry with a given projection. In standard modeling views there is a one to one relationship between RhinoView and RhinoViewports. In a page layout, there may be multiple RhinoViewports for a single layout.
Constructors
public RhinoViewport()
Finalizer
~RhinoViewport
#~RhinoViewport()
Properties
Gets the size and location of the viewport, in pixels, relative to the parent view.
Gets or sets the 1/2 of smallest subtended view angle.
The value of change counter is incremented every time the view projection or construction plane changes. The user can the mouse and nestable view manipulation commands to change a view at any time. The value of change counter can be used to detect these changes in code that is sensitive to the view projection.
Gets the width/height ratio of the frustum.
true if construction plane z axis is parallel to camera direction.
If true, the camera location, camera direction, and lens angle should not be changed.
Gets the parent view, if there is one Every RhinoView has an associated RhinoViewport that does all the 3d display work. Those associated viewports return the RhinoView as their parent view. However, RhinoViewports are used in other image creating contexts that do not have a parent RhinoView. If you call ParentView, you MUST check for NULL return values.
Get or set the height and width of the viewport (in pixels)
Methods
Use this function to change projections of valid viewports from perspective to parallel. It will make common additional adjustments to the frustum so the resulting views are similar. The camera location and direction will not be changed.
Parameters:
| symmetricFrustum (bool) | true if you want the resulting frustum to be symmetric. |
Returns: If the current projection is parallel and bSymmetricFrustum, FrustumIsLeftRightSymmetric() and FrustumIsTopBottomSymmetric() are all equal, then no changes are made and true is returned.
When a viewport is set to Parallel Reflected projection, the geometry on the ceiling is shown as if it is mirrored to the floor below.
Use this function to change projections of valid viewports from parallel to perspective. It will make common additional adjustments to the frustum and camera location so the resulting views are similar. The camera direction and target point are not be changed.
Parameters:
| symmetricFrustum (bool) | true if you want the resulting frustum to be symmetric. |
| lensLength (double) | (pass 50.0 when in doubt) 35 mm lens length to use when changing from parallel to perspective projections. If the current projection is perspective or lens_length is <= 0.0, then this parameter is ignored. |
Returns: If the current projection is perspective and bSymmetricFrustum, FrustumIsLeftRightSymmetric() and FrustumIsTopBottomSymmetric() are all equal, then no changes are made and true is returned.
public bool ChangeToPerspectiveProjection(double targetDistance, bool symmetricFrustum, double lensLength)
Use this function to change projections of valid viewports from parallel to perspective. It will make common additional adjustments to the frustum and camera location so the resulting views are similar. The camera direction and target point are not be changed.
Parameters:
| targetDistance (double) | If RhinoMath.UnsetValue this parameter is ignored. Otherwise it must be > 0 and indicates which plane in the current view frustum should be preserved. |
| symmetricFrustum (bool) | true if you want the resulting frustum to be symmetric. |
| lensLength (double) | (pass 50.0 when in doubt) 35 mm lens length to use when changing from parallel to perspective projections. If the current projection is perspective or lens_length is <= 0.0, then this parameter is ignored. |
Returns: If the current projection is perspective and bSymmetricFrustum, FrustumIsLeftRightSymmetric() and FrustumIsTopBottomSymmetric() are all equal, then no changes are made and true is returned.
Use this function to change projections of valid viewports to a two point perspective. It will make common additional adjustments to the frustum and camera location and direction so the resulting views are similar.
Parameters:
| lensLength (double) | (pass 50.0 when in doubt) 35 mm lens length to use when changing from parallel to perspective projections. If the current projection is perspective or lens_length is <= 0.0, then this parameter is ignored. |
Returns: If the current projection is perspective and bSymmetricFrustum, FrustumIsLeftRightSymmetric() and FrustumIsTopBottomSymmetric() are all equal, then no changes are made and true is returned.
public bool ChangeToTwoPointPerspectiveProjection(double targetDistance, Vector3d up, double lensLength)
Use this function to change projections of valid viewports to a two point perspective. It will make common additional adjustments to the frustum and camera location and direction so the resulting views are similar.
Parameters:
| targetDistance (double) | If RhinoMath.UnsetValue this parameter is ignored. Otherwise it must be > 0 and indicates which plane in the current view frustum should be preserved. |
| up (Vector3d) | This direction will be the locked up direction. Pass ON_3dVector::ZeroVector if you want to use the world axis direction that is closest to the current up direction. Pass CameraY() if you want to preserve the current up direction. |
| lensLength (double) | (pass 50.0 when in doubt) 35 mm lens length to use when changing from parallel to perspective projections. If the current projection is perspective or lens_length is <= 0.0, then this parameter is ignored. |
Returns: If the current projection is perspective and bSymmetricFrustum, FrustumIsLeftRightSymmetric() and FrustumIsTopBottomSymmetric() are all equal, then no changes are made and true is returned.
public void ClearTraceImage()
Remove trace image (background bitmap) for this viewport if one exists.
Parameters:
| clientPoint (Point) |
Parameters:
| clientPoint (Point2d) |
Parameters:
| clientPoint (Point2d) |
Simple plane information for this viewport's construction plane. If you want detailed construction plane information, use GetConstructionPlane.
public void DeleteAllUserStrings()
public void Dispose()
Call this method to get the viewport with the specified Id.
Parameters:
| id (Guid) | Id to search for. |
Returns: Returns a RhinoViewport if the Id is found otherwise null.
Parameters:
| points (IEnumerable<Point3d>) |
Gets the camera plane.
Parameters:
| frame (out Plane) | A plane is assigned to this out parameter during the call, if the operation succeeded. |
Returns: true if current camera orientation is valid.
Gets near and far clipping distances of a bounding box.
Parameters:
| bbox (BoundingBox) | The bounding box. |
| nearDistance (out double) | The near distance is assigned to this out parameter during this call. |
| farDistance (out double) | The far distance is assigned to this out parameter during this call. |
Returns: true if the bounding box intersects the view frustum and near_dist/far_dist were set. false if the bounding box does not intersect the view frustum.
Gets clipping distance of a point.
Gets near and far clipping distances of a sphere.
Parameters:
| sphere (Sphere) | The sphere. |
| nearDistance (out double) | The near distance is assigned to this out parameter during this call. |
| farDistance (out double) | The far distance is assigned to this out parameter during this call. |
Returns: true if the sphere intersects the view frustum and near_dist/far_dist were set. false if the sphere does not intersect the view frustum.
Get corners of far clipping plane rectangle.
Returns: [left_bottom, right_bottom, left_top, right_top] points on success null on failure.
public bool GetFrustum(out double left, out double right, out double bottom, out double top, out double nearDistance, out double farDistance)
Gets the view frustum.
Get bottom world frustum clipping plane.
Parameters:
| plane (out Plane) | frustum bottom side clipping plane. The normal points into the visible region of the frustum. If the projection is perspective, the origin is at the camera location, otherwise the origin is the point on the plane that is closest to the camera location. |
Returns: true if camera and frustum are valid and plane was set.
Returns world coordinates of frustum's center.
Parameters:
| center (out Point3d) | The center coordinate is assigned to this out parameter if this call succeeds. |
Returns: true if the center was successfully computed.
Get far clipping plane.
Parameters:
| plane (out Plane) | far clipping plane if camera and frustum are valid. The plane's frame is the same as the camera's frame. The origin is located at the intersection of the camera direction ray and the far clipping plane. |
Returns: true if camera and frustum are valid.
Get left world frustum clipping plane.
Parameters:
| plane (out Plane) | frustum left side clipping plane. The normal points into the visible region of the frustum. If the projection is perspective, the origin is at the camera location, otherwise the origin is the point on the plane that is closest to the camera location. |
Returns: true if camera and frustum are valid and plane was set.
Gets the world coordinate line in the view frustum that projects to a point on the screen.
Parameters:
| screenX (double) | (screenx,screeny) = screen location. |
| screenY (double) | (screenx,screeny) = screen location. |
| worldLine (out Line) | 3d world coordinate line segment starting on the near clipping plane and ending on the far clipping plane. |
Returns: true if successful. false if view projection or frustum is invalid.
Get near clipping plane.
Parameters:
| plane (out Plane) | near clipping plane if camera and frustum are valid. The plane's frame is the same as the camera's frame. The origin is located at the intersection of the camera direction ray and the near clipping plane. |
Returns: true if camera and frustum are valid.
Get right world frustum clipping plane.
Parameters:
| plane (out Plane) | frustum right side clipping plane. The normal points into the visible region of the frustum. If the projection is perspective, the origin is at the camera location, otherwise the origin is the point on the plane that is closest to the camera location. |
Returns: true if camera and frustum are valid and plane was set.
Get top world frustum clipping plane.
Parameters:
| plane (out Plane) | frustum top side clipping plane. The normal points into the visible region of the frustum. If the projection is perspective, the origin is at the camera location, otherwise the origin is the point on the plane that is closest to the camera location. |
Returns: true if camera and frustum are valid and plane was set.
Get corners of near clipping plane rectangle.
Returns: [left_bottom, right_bottom, left_top, right_top] points on success null on failure.
Takes a rectangle in screen coordinates and returns a transformation that maps the 3d frustum defined by the rectangle to a -1/+1 clipping coordinate box. This takes a single point and inflates it by Rhino.ApplicationSettings.ModelAidSettings.MousePickBoxRadius to define the screen rectangle.
Takes a rectangle in screen coordinates and returns a transformation that maps the 3d frustum defined by the rectangle to a -1/+1 clipping coordinate box. This takes a single point and inflates it by Rhino.ApplicationSettings.ModelAidSettings.MousePickBoxRadius to define the screen rectangle.
Parameters:
| clientPoint (Point) | The client point. |
Returns: A transformation matrix.
Takes a rectangle in screen coordinates and returns a transformation that maps the 3d frustum defined by the rectangle to a -1/+1 clipping coordinate box.
Parameters:
| clientRectangle (Rectangle) | The client rectangle. |
Returns: A transformation matrix.
public bool GetScreenPort(out int portLeft, out int portRight, out int portBottom, out int portTop, out int portNear, out int portFar)
Location of viewport in pixels. These are provided so you can set the port you are using and get the appropriate transformations to and from screen space.
Parameters:
| portLeft (out int) | portLeft != portRight. |
| portRight (out int) | portLeft != portRight. |
| portBottom (out int) | portTop != portBottom. |
| portTop (out int) | portTop != portBottom. |
| portNear (out int) | The viewport near value. |
| portFar (out int) | The viewport far value. |
Returns: true if the operation is successful.
Gets a transform from origin coordinate system to a target coordinate system.
Parameters:
| sourceSystem (CoordinateSystem) | The origin coordinate system. |
| destinationSystem (CoordinateSystem) | The target coordinate system. |
Returns: 4x4 transformation matrix (acts on the left) Identity matrix is returned if this function fails.
Gets a user string.
Parameters:
| key (string) | id used to retrieve the string. |
Returns: string associated with the key if successful. null if no key was found.
Gets an independent copy of the collection of (user text key, user text value) pairs attached to this object.
Returns: A collection of key strings and values strings. This
Gets the world to screen size scaling factor at a point in frustum.
Returns true if some portion of a world coordinate bounding box is potentially visible in the viewing frustum.
Parameters:
| bbox (BoundingBox) | A bounding box that is tested for visibility. |
Returns: true if the box is potentially visible; otherwise false.
Determines if a world coordinate point is visible in the viewing frustum.
Parameters:
| point (Point3d) | A point that is tested for visibility. |
Returns: true if the point is visible; otherwise false.
Emulates the keyboard arrow key in terms of interaction.
Emulates the keyboard arrow key in terms of interaction.
Parameters:
| amount (double) | The dolly amount. |
Returns: true if operation succeeded; otherwise false.
Emulates the keyboard arrow key in terms of interaction.
Returns the lens length of this viewport the last time it was using perspective projection in this session.
Zooms or dollies in order to scale the viewport projection of observed objects.
Parameters:
| magnificationFactor (double) | The scale factor. |
| mode (bool) | false = perform a "dolly" magnification by moving the camera towards/away from the target so that the amount of the screen subtended by an object changes. true = perform a "zoom" magnification by adjusting the "lens" angle |
| fixedScreenPoint (Point) | A point in the screen that should remain fixed. |
Returns: true if operation succeeded; otherwise false.
Zooms or dollies in order to scale the viewport projection of observed objects.
Parameters:
| magnificationFactor (double) | The scale factor. |
| mode (bool) | false = perform a "dolly" magnification by moving the camera towards/away from the target so that the amount of the screen subtended by an object changes. true = perform a "zoom" magnification by adjusting the "lens" angle |
Returns: true if operation succeeded; otherwise false.
public bool MouseAdjustLensLength(Point mousePreviousPoint, Point mouseCurrentPoint, bool moveTarget)
Adjusts the camera lens length.
Zooms lens (thus adjusting the field of view) while moving the camera.
Moves the camera towards or away from the view maintaining focus on the view.
Pans the camera
Moves the camera towards or away from the view.
Rotates the viewport around target.
Rotates the view around the camera location.
Tilts the camera view.
Sets the construction plane to the plane that was active before the last call to PreviousConstructionPlane.
Returns: true if successful.
Sets the view projection and target to the settings that were active before the last call to PrevView.
Returns: true if the view stack was popped.
Sets the construction plane to the plane that was active before the last call to PushConstructionPlane.
Returns: true if a construction plane was popped.
Sets the view projection and target to the settings at the top of the view stack and removes those settings from the view stack.
Returns: true if there were settings that could be popped from the stack.
Sets the construction plane to the plane that was active before the last call to NextConstructionPlane or SetConstructionPlane.
Returns: true if successful.
Sets the view projection and target to the settings that were active before the last call to NextViewProjection.
Returns: true if the view stack was popped.
Pushes the current construction plane on the viewport's construction plane stack and sets the construction plane to cplane.
Parameters:
| cplane (ConstructionPlane) | The construction plane to push. |
public void PushViewProjection()
Appends the current view projection and target to the viewport's view stack.
Rotates about the specified axis. A positive rotation angle results in a counter-clockwise rotation about the axis (right hand rule).
Parameters:
| screenPoint (Point) |
Set viewport camera direction. By default the target location is changed so that the vector from the camera location to the target is parallel to the camera direction.
Parameters:
| cameraDirection (Vector3d) | new camera direction. |
| updateTargetLocation (bool) | if true, the target location is changed so that the vector from the camera location to the target is parallel to the camera direction. If false, the target location is not changed. See the remarks section of RhinoViewport.SetTarget for important details. |
Set viewport camera location. By default the target location is changed so that the vector from the camera location to the target is parallel to the camera direction vector.
Parameters:
| cameraLocation (Point3d) | new camera location. |
| updateTargetLocation (bool) | if true, the target location is changed so that the vector from the camera location to the target is parallel to the camera direction vector. If false, the target location is not changed. See the remarks section of RhinoViewport.SetTarget for important details. |
Set viewport camera location and target location. The camera direction vector is changed so that it is parallel to the vector from the camera location to the target location.
Set viewport target point. By default the camera location is translated so that the camera direction vector is parallel to the vector from the camera location to the target location.
Remarks: In general, Rhino users expect to have the camera direction vector and the vector from the camera location to the target location to be parallel. If you use the RhinoViewport functions to set the camera location, camera direction, and target point, then the relationship between these three points and vectors is automatically maintained. If you directly manipulate the camera properties, then you should carefully set the target by calling SetTarget() with updateCameraLocation=false.
Sets optimal clipping planes to view objects in a world coordinate 3d bounding box.
Parameters:
| box (BoundingBox) | The bounding box |
Sets the construction plane to cplane.
Parameters:
| cplane (ConstructionPlane) | The construction plane to set. |
Parameters:
| plane (Plane) |
public bool SetProjection(DefinedViewportProjection projection, string viewName, bool updateConstructionPlane)
Set viewport to a defined projection.
Parameters:
| projection (DefinedViewportProjection) | The "standard" projection type. |
| viewName (string) | If not null or empty, the name is set. |
| updateConstructionPlane (bool) | If true, the construction plane is set to the viewport plane. |
Returns: true if successful.
public bool SetProjection(IsometricCamera projection, string viewName, bool updateConstructionPlane)
Set viewport to a defined projection.
Parameters:
| projection (IsometricCamera) | The "isometric" projection type. |
| viewName (string) | If not null or empty, the name is set. |
| updateConstructionPlane (bool) | If true, the construction plane is set to the viewport plane. |
Returns: true if successful.
public bool SetScreenPort(int portLeft, int portRight, int portBottom, int portTop, int portNear = 0, int portFar = 0)
Location of viewport in pixels. These are provided so you can set the port you are using and get the appropriate transformations to and from screen space.
public bool SetTraceImage(string bitmapFileName, Plane plane, double width, double height, bool grayscale, bool filtered)
Set trace image (background bitmap) for this viewport.
Parameters:
| bitmapFileName (string) | The bitmap file name. |
| plane (Plane) | A picture plane. |
| width (double) | The picture width. |
| height (double) | The picture height. |
| grayscale (bool) | true if the picture should be in grayscale. |
| filtered (bool) | true if image should be filtered (bilinear) before displayed. |
Returns: true if successful.
Attach a user string (key,value combination) to this geometry.
Attach a user string (key,value combination) to this viewport.
Parameters:
| items (IEnumerable<KeyValuePair<string, string>>) | collection of key-value pairs to set. |
| replace (bool) | If True, the previous user string will be removed |
Returns: true on success.
Sets the viewport camera projection.
Parameters:
| projection (ViewportInfo) | The "standard" projection type. |
| updateTargetLocation (bool) | if true, the target location is changed so that the vector from the camera location to the target is parallel to the camera direction vector. If false, the target location is not changed. |
Returns: true on success.
Convert a point from world coordinates in the viewport to a 2d screen point in the local coordinates of the viewport (X/Y of point is relative to top left corner of viewport on screen)
Parameters:
| worldPoint (Point3d) | The 3D point in world coordinates. |
Returns: The 2D point on the screen.
Zooms the viewport to the given bounding box.
Parameters:
| box (BoundingBox) | The bounding box to zoom. |
Returns: true if operation succeeded; otherwise false.
Dollies the camera location and so that the view frustum contains all of the selected document objects that can be seen in view. If the projection is perspective, the camera angle is not changed.
Returns: true if successful.
Dollies the camera location and so that the view frustum contains all of the selected document objects that can be seen in view. If the projection is perspective, the camera angle is not changed.
Returns: true if successful.
Zooms the viewport to the given rectangle.
Parameters:
| rect (Rectangle) | A 2d screen rectangle in client coordinates of the parent Rhino view, where 0,0 is the upper left corner of the view window. |
Returns: true if operation succeeded; otherwise false.