Forum archiveIssue archiveVisualization and 3D Viewer

Archived discussion

AIS_VIEWCUBE position

Visualization and 3D ViewerSat, 03/19/2022 - 12:467 replies

Browse this forum
QuestionAuthor

Hello , I am playing around AIS_VIEWCUBE code sample.
I have created a sample application and CubeView is displayed at left/Bottom screen.
I woul like display it at top/Right

I have used this code:
aisViewCube->SetTransformPersistence(
new Graphic3d_TransformPers(Graphic3d_TransformPers(Graphic3d_TMF_TriedronPers, Aspect_TOTP_RIGHT_UPPER , Graphic3d_Vec2i(100,100))));

But this function doesn't move the AIS_CUBEVIEW
Any suggestion?
Thanks in advance

Discussion

7 archived replies

Posts are displayed in their archived order.

01Commenter-1

I guess the code should work, though I don't understand why it calls Graphic3d_TransformPers constructor twice. AIS_ViewCube::SetTransformPersistence() should be called before displaying the object (AIS_InteractiveContext::SetTransformPersistence() could be used afterwards).

Archived image: external image

02Author

ok,it works,sorry for delay.
A last question: I have not found a way to change the color (yellow) of "X","Y",Z"; I have a white backgroung, so the yellow is not readable.
Can show me a function to change text color?
Thanks in advance

03Commenter-1

X/Y/Z labels are drawn by Prs3d_Drawer::DatumAspect(), which defines per-axis text aspects Prs3d_DatumAspect::TextAspect(). The code might look like this:

Handle(AIS_ViewCube) theViewCube = ...;
const Handle(Prs3d_Drawer)& aDrawer = theViewCube->Attributes();
aDrawer->SetDatumAspect (new Prs3d_DatumAspect());
const Handle(Prs3d_DatumAspect)& aDatumAsp = aDrawer->DatumAspect();
aDatumAsp->TextAspect (Prs3d_DatumParts_XAxis)->SetColor (Quantity_NOC_RED);
aDatumAsp->TextAspect (Prs3d_DatumParts_YAxis)->SetColor (Quantity_NOC_GREEN);
aDatumAsp->TextAspect (Prs3d_DatumParts_ZAxis)->SetColor (Quantity_NOC_BLUE);
04Author

Many thanks

05Author

After doing some tests with the CubeView, I try to recall the Top view (or more generally any 2d view)
The 2d View is shown but the X and Y axes, as shown in the image, are positioned incorrectly (they have a conflicting sign: X points towards -x and Y points towards -y)
How can I automatically display the axes int the correct position?
Can I get some C ++ code snippets?
I suppose , it need a rotation of the view,but I don't know how
Many Thanks in advance.

06Commenter-1

 Author Corbo wrote:

After doing some tests with the CubeView, I try to recall the Top view (or more generally any 2d view)
The 2d View is shown but the X and Y axes, as shown in the image, are positioned incorrectly (they have a conflicting sign: X points towards -x and Y points towards -y)

If you click on "Top" side second time it will rotate view to see "Top" label horizontally aligned, if this is what you are looking for.

07Author

ok. thanks Krill, I have checked, it runs!