How to Display an AIS Shape not Affected by Zoom In/Out

Hello,

I want to create and display a shape that will not be affected by zoom function of v3d_view. Do you have any ideas to achieve that?

For instance if I create 2 shapes, after zooming in or out I want to zoom whole view and one of the shapes will stay in the same size at view. (By the same size I mean one shape will cover the same amount of pixels at view)

Example code is below,

Handle(V3d_View) v3d_view_;
Handle(AIS_InteractiveContext) ais_interactive_context_;

TopoDS_Shape topods_sphere_shape = BRepPrimAPI_MakeSphere(gp_Pnt(100,0,0), 20).Shape();
Handle_AIS_Shape ais_sphere_shape = new AIS_Shape(topods_sphere_shape);

TopoDS_Shape topods_sphere_shape2 = BRepPrimAPI_MakeSphere(gp_Pnt(-100,0,0), 20).Shape();
Handle_AIS_Shape ais_sphere_shape2 = new AIS_Shape(topods_sphere_shape2);

ais_interactive_context_->Display (ais_sphere_shape, AIS_Shaded, 0, true);
ais_interactive_context_->Display (ais_sphere_shape2, AIS_Shaded, 0, true);

v3d_view_->ZoomAtPoint( x, y, x1, y1 ); //Regardless of the zooming point

With this flow is it possible to display a shape immune to zooming?
Thanks in advance

Mauro C's picture

Hi, If I well understand you want have not-zoomable objects.
if so, one solution is to use persistence transform Graphic3d_TMF_ZoomPers.
For example:
aisShape->SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_ZoomPers, Pnt );
Hope this help you

Omer K's picture

Hi Mauro,

Thank you so much for your answer :). It worked, but there is a little problem left. If I create the shape at any point other than origin zooming works incorrectly. What I mean by this is that, in the attached photos both trihedron position and sphere center has been set to gp_Pnt(30,0,0). However while zooming in/out sphere and trihedron centers are displayed at different positions. I guess there is an issue about local and global coordinates however I could not solve it. However it works perfectly at origin point. If you have any comments, I would very much appreciate it. Sample code is below,

auto origin_xyz = gp_Pnt(30,0,0);
TopoDS_Shape topods_sphere_shape = BRepPrimAPI_MakeSphere(origin_xyz, sphere_radius).Shape();
Handle_AIS_Shape ais_sphere_shape = new AIS_Shape(topods_sphere_shape);
ais_sphere_shape->SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_ZoomRotatePers, origin_xyz));

gp_Ax2 Position;
Position.SetLocation(origin_xyz);

Handle_Geom_Axis2Placement axis = new Geom_Axis2Placement(position);
Handle_AIS_Trihedron ais_trihedron_shape = new AIS_Trihedron(axis);

Attachments: 
Mauro C's picture

I try later ( in the evening )and I send you an example.

Mauro C's picture

PS.: just to well understand your requirements :
1.do you need that trihedron position and sphere center must save same location during zoom? Currently you say they don't . Is it right ?
If so, you should apply persistence transform also to ais_trihedron_shape , in the same way you did for sphere. Try this and let me know. You should solve

Omer K's picture

Hi again Mauro, yes sphere and trihedron position must be at the same location. However, the main problem here is that sphere's center is not at gp_Pnt(30,0,0) anymore. If I apply persistence to trihedron as well, I would expect both of them will not be at position (30,0,0).

In other words, lets assume I have a trihedron with no persistence transform and I set its origin (30,0,0). And I have a sphere with transform persistence at gp_Pnt(30,0,0). After I zoom out, I expect sphere's center would be at still gp_Pnt(30,0,0) and cover all of the trihedron. However in the photo I can see that sphere center and trihedron center are different positions in the space. I want to solve this issue. Thank you for you support.

Attachments: 
gkv311 n's picture

The object with zoom transformation persistence is expected to be defined within zero origin geometrically to achieve desired effect (e.g. sphere center should be 0, and local transformation should be also identity).

Maybe this article might be helpful.