END_EVENT_TABLE() EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title, long style ) : EDA_BASE_FRAME( parent, DISPLAY3D_FRAME_TYPE, title, wxDefaultPosition, wxDefaultSize, style, wxT( "Frame3D" ) ) { m_canvas = NULL; m_reloadRequest = false; m_ortho = false; // Give it an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) ); SetIcon( icon ); GetSettings(); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); // Create the status line static const int dims[5] = { -1, 100, 100, 100, 140 }; CreateStatusBar( 5 ); SetStatusWidths( 5, dims ); CreateMenuBar(); ReCreateMainToolbar(); // Make a EDA_3D_CANVAS int attrs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0 }; m_canvas = new EDA_3D_CANVAS( this, attrs ); m_auimgr.SetManagedWindow( this ); EDA_PANEINFO horiztb; horiztb.HorizontalToolbarPane(); m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiztb ).Name( wxT( "m_mainToolBar" ) ).Top() ); m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); m_auimgr.Update(); // Fixes bug in Windows (XP and possibly others) where the canvas requires the focus // in order to receive mouse events. Otherwise, the user has to click somewhere on // the canvas before it will respond to mouse wheel events. m_canvas->SetFocus(); }
EDA_3D_FRAME::EDA_3D_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent, const wxString& aTitle, long style ) : KIWAY_PLAYER( aKiway, aParent, FRAME_PCB_DISPLAY3D, aTitle, wxDefaultPosition, wxDefaultSize, style, wxT( "Frame3D" ) ) { m_canvas = NULL; m_reloadRequest = false; m_ortho = false; // Give it an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) ); SetIcon( icon ); LoadSettings( config() ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); // Create the status line static const int status_dims[4] = { -1, 130, 130, 170 }; CreateStatusBar( DIM( status_dims ) ); SetStatusWidths( DIM( status_dims ), status_dims ); CreateMenuBar(); ReCreateMainToolbar(); // Make a EDA_3D_CANVAS // Note: We try to use anti aliasing if the graphic card allows that, // but only on wxWidgets >= 3.0.0 (this option does not exist on wxWidgets 2.8) int attrs[] = { // This array should be 2*n+1 // Sadly wxwidgets / glx < 13 allowed // a thing named "boolean attributes" that don't take a value. // (See src/unix/glx11.cpp -> wxGLCanvasX11::ConvertWXAttrsToGL() ). // To avoid problems due to this, just specify those attributes twice. // Only WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_STEREO are such boolean // attributes. // Boolean attributes (using itself at padding): WX_GL_RGBA, WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DOUBLEBUFFER, // Normal attributes with values: WX_GL_DEPTH_SIZE, 16, WX_GL_STENCIL_SIZE, 1, WX_GL_SAMPLE_BUFFERS, 1, // Enable multisampling support (antialiasing). WX_GL_SAMPLES, 0, // Disable AA for the start. 0 }; // NULL termination // Check if the canvas supports multisampling. if( EDA_3D_CANVAS::IsDisplaySupported( attrs ) ) { // Check for possible sample sizes, start form the top. int maxSamples = 8; // Any higher doesn't change anything. int samplesOffset = 0; for( unsigned int ii = 0; ii < DIM( attrs ); ii += 2 ) { if( attrs[ii] == WX_GL_SAMPLES ) { samplesOffset = ii+1; break; } } attrs[samplesOffset] = maxSamples; for( ; maxSamples > 0 && !EDA_3D_CANVAS::IsDisplaySupported( attrs ); maxSamples = maxSamples>>1 ) { attrs[samplesOffset] = maxSamples; } } else { // Disable multisampling for( unsigned int ii = 0; ii < DIM( attrs ); ii += 2 )
EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxString &aTitle, long style ) : KIWAY_PLAYER( aKiway, aParent, FRAME_PCB_DISPLAY3D, aTitle, wxDefaultPosition, wxDefaultSize, style, VIEWER3D_FRAMENAME ) { wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER::EDA_3D_VIEWER %s" ), aTitle ); m_canvas = NULL; m_defaultFileName = ""; // Give it an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( icon_3d_xpm ) ); SetIcon( icon ); LoadSettings( config() ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); // Create the status line static const int status_dims[4] = { -1, 130, 130, 170 }; wxStatusBar *status_bar = CreateStatusBar( DIM( status_dims ) ); SetStatusWidths( DIM( status_dims ), status_dims ); CreateMenuBar(); ReCreateMainToolbar(); m_canvas = new EDA_3D_CANVAS( this, COGL_ATT_LIST::GetAttributesList( true ), aParent->GetBoard(), m_settings, Prj().Get3DCacheManager() ); if( m_canvas ) m_canvas->SetStatusBar( status_bar ); m_auimgr.SetManagedWindow( this ); EDA_PANEINFO horiztb; horiztb.HorizontalToolbarPane(); m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiztb ).Name( wxT( "m_mainToolBar" ) ).Top() ); if( m_canvas ) m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); m_auimgr.Update(); m_mainToolBar->EnableTool( ID_RENDER_CURRENT_VIEW, (m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY) ); // Fixes bug in Windows (XP and possibly others) where the canvas requires the focus // in order to receive mouse events. Otherwise, the user has to click somewhere on // the canvas before it will respond to mouse wheel events. if( m_canvas ) m_canvas->SetFocus(); }