
Wed, 03/13/2024 - 05:54
Forums:
Hi,
I try to use the AIS_ViewCube to change the view orientation. I write it in my project, but nothing happens when I click the plane of the cube. Does anyone know if there need to set something? The version of occ is 7.5.0, here is my code.
/// <summary>
/// Initialize a viewer
/// </summary>
bool CModeller::InitViewer( void *pWND )
{
try {
Handle( Aspect_DisplayConnection ) aDisplayConnection;
m_pGraphicDriver = new OpenGl_GraphicDriver( aDisplayConnection );
}
catch( Standard_Failure ) {
return false;
}
m_pViewer = new V3d_Viewer( m_pGraphicDriver );
m_pViewer->SetDefaultLights();
m_pViewer->SetLightOn();
m_pView = m_pViewer->CreateView();
Aspect_Handle aHandle = reinterpret_cast<Aspect_Handle>( pWND );
Handle( WNT_Window ) aWNTWindow = new WNT_Window( aHandle );
m_pView->SetWindow( aWNTWindow );
if( !aWNTWindow->IsMapped() ) {
aWNTWindow->Map();
}
m_pAISContext = new AIS_InteractiveContext( m_pViewer );
m_pAISContext->UpdateCurrentViewer();
m_pView->MustBeResized();
// Initialize the cube
InitializeTriedronCube();
return true;
}
/// <summary>
/// Initialize a view cube
/// </summary>
void CModeller::InitializeTriedronCube( void )
{
Handle( AIS_ViewCube ) CoordCube = new AIS_ViewCube();
CoordCube->SetSize( 40 );
// draw text
CoordCube->SetBoxSideLabel( V3d_Xpos, "Right" );
CoordCube->SetBoxSideLabel( V3d_Ypos, "Back" );
CoordCube->SetBoxSideLabel( V3d_Zpos, "Top" );
CoordCube->SetBoxSideLabel( V3d_Xneg, "Left" );
CoordCube->SetBoxSideLabel( V3d_Yneg, "Front" );
CoordCube->SetBoxSideLabel( V3d_Zneg, "Bottom" );
// other initialization
CoordCube->SetTransparency( 0.8 );
CoordCube->SetTextColor( Quantity_Color( Quantity_NOC_MATRABLUE ) );
CoordCube->SetFontHeight( 16 );
CoordCube->SetMaterial( Graphic3d_MaterialAspect( Graphic3d_NOM_ALUMINIUM ) );
CoordCube->SetTransformPersistence( new Graphic3d_TransformPers( Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER, Graphic3d_Vec2i( 80, 80 ) ) );
// setting the color of line
const Handle( Prs3d_Drawer ) &myDrawer = CoordCube->Attributes();
myDrawer->SetDatumAspect( new Prs3d_DatumAspect() );
const Handle( Prs3d_DatumAspect ) &datumAspect = CoordCube->Attributes()->DatumAspect();
datumAspect->ShadingAspect( Prs3d_DP_XAxis )->SetColor( Quantity_NOC_RED );
datumAspect->ShadingAspect( Prs3d_DP_YAxis )->SetColor( Quantity_NOC_GREEN );
datumAspect->ShadingAspect( Prs3d_DP_ZAxis )->SetColor( Quantity_NOC_BLUE );
m_pAISContext->Display( CoordCube, Standard_True );
}
Regards, Steven