How to change the color of the coordinate system near the viewcube or even erase the coordinate system?

Dear OCCT Community,
I have trouble in changing the color of the coordinate system near the viewcube. At the sametime, due to already having a coordinate system when initializing my view, erasing the coordinate system near the cube maybe also a good choice. Could you please help me with problems above?

Oh...As for the plane's edges, I wonder if there is a way to display them simplier... Because now I build two planes (one to display its content color, the other to display its edge color) just to make sure that the content and the edge have different colors.

Specific question discription is in the png attached, sorry I don't know how to put a picture right after the text. TAT

Thanks in advance!

Attachments: 
Mauro C's picture

Hello, 1. to change the color of the coordinate system near the viewcube :: ( I put red , green , blue ; you may choose the color you want )

        const Handle_Prs3d_DatumAspect& datumAspect = aisViewCube->Attributes()->DatumAspect();
        datumAspect->ShadingAspect(Prs3d_DP_XAxis)->SetColor(Quantity_NOC_RED2);
        datumAspect->ShadingAspect(Prs3d_DP_YAxis)->SetColor(Quantity_NOC_GREEN2);
        datumAspect->ShadingAspect(Prs3d_DP_ZAxis)->SetColor(Quantity_NOC_BLUE2);
  1. To erase the system coordinate near the cubeview::
      aisViewCube->SetDrawAxes  (    false  );

Hope this can help you About last question : can you explain better?

华裔 程's picture

Thanks a looooot, Mauro! You've perfectly solved my first two questions! About the last question, have you downloaded my attachment 'questions.png'? I have made a more specific description in it. At the same time, to explain the last question better: For example, I want to create a squared plane which is blue inside and has black border. Now I choose to create two same planes at the same originpoint. One of them is set blue, the other is set black. My code is presented below:

TopoDS_Face basePlane_inside = BRepBuilderAPI_MakeFace(gp_Pln(original_Point, original_Direction), -600, 0, -600, 0);
TopoDS_Face basePlane_border = BRepBuilderAPI_MakeFace(gp_Pln(original_Point, original_Direction), -600, 0, -600, 0);

Handle(AIS_Shape) hAisShape_plane_inside = new AIS_Shape(basePlane_inside);
Handle(AIS_Shape) hAisShape_plane_border = new AIS_Shape(basePlane_border);

hAisShape_plane_inside->SetColor(Quantity_NOC_BLUE1);
hAisShape_plane_border->SetColor(Quantity_NOC_BLACK);

After creating two planes with different colors, I choose to display the blue one in shaded , and the black one in wireframe.

m_context->Display(hAisShape_plane_inside, 1, 1, Standard_True, Standard_False, AIS_DS_Displayed);
m_context->Display(hAisShape_plane_border, 0, 1, Standard_True, Standard_False, AIS_DS_Displayed);

Now I FINALLY got one blue plane with black border in my context. I think this way is toooooo complicated and inconvenient. So I wonder if there are some easier ways to get a same blue plane with black border. That is, set the plane's content and border with different colors.

If my explanation is still not clear enough, plz let me know! TAT. I will try another way to explain my question better.

And again, thank you Mauro for helping me!!!

华裔 程's picture

Thanks a looooot, Mauro! You've perfectly solved my first two questions! About the last question, have you downloaded my attachment 'questions.png'? I have made a more specific description in it. At the same time, to explain the last question better:
For example, I want to create a squared plane which is blue inside and has black border. Now I choose to create two same planes at the same originpoint. One of them is set blue, the other is set black. My code is presented below:

TopoDS_Face  basePlane_inside = BRepBuilderAPI_MakeFace(gp_Pln(original_Point, original_Direction), -600, 0, -600, 0);
TopoDS_Face  basePlane_border = BRepBuilderAPI_MakeFace(gp_Pln(original_Point, original_Direction), -600, 0, -600, 0);

Handle(AIS_Shape) hAisShape_plane_inside = new AIS_Shape(basePlane_inside);
Handle(AIS_Shape) hAisShape_plane_border = new AIS_Shape(basePlane_border);

hAisShape_plane_inside->SetColor(Quantity_NOC_BLUE1);
hAisShape_plane_border->SetColor(Quantity_NOC_BLACK);

After creating two planes with different colors, I choose to display the blue one in shaded , and the black one in wireframe.

m_context->Display(hAisShape_plane_inside, 1, 1, Standard_True, Standard_False, AIS_DS_Displayed);  
m_context->Display(hAisShape_plane_border, 0, 1, Standard_True, Standard_False, AIS_DS_Displayed);  

Now I FINALLY got one blue plane with black border in my context. I think this way is toooooo complicated and inconvenient. So I wonder if there are some easier ways to get a same blue plane with black border. That is, set the plane's content and border with different colors.

If my explanation is still not clear enough, plz let me know! TAT. I will try another way to explain my question better.

And again, thank you Mauro for helping me!!!

Mauro C's picture

hi, I am not an Opencascade guru ! but I think it is not a good idea to have a double model for wireframe and shaded visualization; it causes a lot of problems, for example in selection, editing etc ... I use this procedure and it seems it works:

check this fragment of code

gp_Pnt Pnt(0.0, 0.0, 0.0);
gp_Dir Original_Direction(0.0, 0.0, 1.0);


TopoDS_Face basePlane_inside = BRepBuilderAPI_MakeFace(gp_Pln(Pnt, Original_Direction),  600, 0,  600, 0);
Handle(AIS_Shape) hAisShape_plane_inside = new AIS_Shape(basePlane_inside);

theCtx->SetColor(hAisShape_plane_inside, Quantity_NOC_GREEN, Standard_False);

Handle(Prs3d_Drawer) drawer = theCtx->DefaultDrawer();
drawer->SetFaceBoundaryAspect(drawer->LineAspect());

hAisShape_plane_inside->SetDisplayMode(AIS_Shaded);
hAisShape_plane_inside->SetMaterial(Graphic3d_NOM_PLASTER);
hAisShape_plane_inside->Attributes()->SetFaceBoundaryDraw(true);
hAisShape_plane_inside->Attributes()->SetFaceBoundaryAspect(new Prs3d_LineAspect(Quantity_NOC_BLACK, Aspect_TOL_SOLID, 2.));
hAisShape_plane_inside->Attributes()->SetIsoOnTriangulation(true);

theCtx->Display(hAisShape_plane_inside, Standard_False);

m_view->Redraw();

attached you find result You can setup yourself (according your needs / preferences) 1. the color of plane (I put green) 2.the color of boundary ( I put black) 3.and also the style (Solid, dashed ect) and the thickness of boundary line ( I put SOLID and a thickness of 2) You can apply this to any AIS_SHAPE in your 3d scene ( see attached box) Hope this can helps you I don't know if it is an optmized code, but it works regards Mauro

Attachments: 
华裔 程's picture

Thanks to your reply Mauro!!! All my questions are perfectly solved!!!
Personally I learn Opencascade on a forum in my country. But sadly there isn't much information about OCC. So I learn OCC slowly and inefficiently TAT.
Would you mind giving me some suggestions on learning OCC more effiently? For example maybe some books or websites......
Anyway, THANKS AGAIN for your timely and fantastic help!!!!! : )