Aligning views

Technical discussions
Post Reply
MadCAM
Posts: 2
Joined: Fri Feb 24, 2023 3:15 am

Aligning views

Post by MadCAM »

Hi

The Multi View sample looks like would be nice for my application. The application is a bit of design of truss joinery. All surfaces are either flat or cylindrical.
What I want is to align three 2d front/side/top views each similar to one used in Multi View. I mean aligning the objects on the screens. Say, front and side views should show the object with the same height in pixels.

Any suggestions for achieving that?

Thanks in advance.

Prashant Kande
Posts: 121
Joined: Mon Apr 04, 2016 4:55 am

Re: Aligning views

Post by Prashant Kande »

Hello

The problem is not so difficult if you are familiar with the concepts.

It sounds like you display the objects in the standard projections: front, top, etc. And because your surfaces are nice the bounding box (IEntity_DG.GetBoundingBox()) of the entity will give the exact dimensions. So, to align the tops what you need is to figure out the translation to apply to the local frame of the object.

This can be done by getting 3D coordinates of the top from the first object (in the first view), converting it to screen coordinates (in a second how), of then converting the y screen coordinate to 3D vertical coordinate of the second view.

Using bounding box for the second object (second view) you can obtain vertical 3D coordinate of the top of the second bounding box. Difference between the two is the amount of translation in vertical direction to align the tops.

Conversion between 3D coordinates and screen coordinates can be done using IView_DG.ScreenTo3D() and IView_DG.ProjectToScreen(). If your windows are not same size or not aligned, you can adjust screen coordinates for that as well by using your UI framework.

The bottoms will be aligned automatically if scaling used in the views is the same. The easiest way to ensure that, is to make y dimension of the viewing volume the same for both views. You can use IView_DG.ViewingVolume property to copy the y dimension from one view to the other.

In general case when the surfaces are not axes-aligned, one could use the minimal oriented bounding box instead, like one computed in the Cloud sample.

Post Reply