From aa0fdb1c8635aaf25a63a901c96b2a8cb15c6701 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 4 Oct 2010 13:50:43 +0200 Subject: [PATCH] fixed issues in 3D viewer --- 3d-viewer/3d_canvas.cpp | 42 +++++++++++--------------------------- 3d-viewer/3d_read_mesh.cpp | 10 ++------- 3d-viewer/3d_toolbar.cpp | 13 +++++++++--- 3 files changed, 24 insertions(+), 41 deletions(-) diff --git a/3d-viewer/3d_canvas.cpp b/3d-viewer/3d_canvas.cpp index 05019ed0f6..b61464aa66 100644 --- a/3d-viewer/3d_canvas.cpp +++ b/3d-viewer/3d_canvas.cpp @@ -568,9 +568,9 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) fmt_is_jpeg = TRUE; if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD ) { - file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" ); - mask = wxT( "*." ) + file_ext; - FullFileName = m_Parent->m_Parent->GetScreen()->m_FileName; + file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" ); + mask = wxT( "*." ) + file_ext; + FullFileName = m_Parent->m_Parent->GetScreen()->m_FileName; fn.SetExt( file_ext ); FullFileName = @@ -582,17 +582,7 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) return; } - Redraw( true ); - - wxSize image_size = GetClientSize(); - #ifndef __WXMAC__ - wxClientDC dc( this ); - wxBitmap bitmap( image_size.x, image_size.y ); - wxMemoryDC memdc; - memdc.SelectObject( bitmap ); - memdc.Blit( 0, 0, image_size.x, image_size.y, &dc, 0, 0 ); - memdc.SelectObject( wxNullBitmap ); -#else + wxSize image_size = GetClientSize(); struct vieport_params { GLint originx; @@ -600,7 +590,8 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) GLint x; GLint y; } viewport; - + + // Build image from the 3D buffer wxWindowUpdateLocker noUpdates( this ); glGetIntegerv( GL_VIEWPORT, (GLint*) &viewport ); @@ -610,27 +601,18 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event ) glPixelStorei( GL_PACK_ALIGNMENT, 1 ); glReadBuffer( GL_BACK_LEFT ); - glReadPixels( viewport.originx, - viewport.originy, - viewport.x, - viewport.y, - GL_RGB, - GL_UNSIGNED_BYTE, - pixelbuffer ); - glReadPixels( viewport.originx, - viewport.originy, - viewport.x, - viewport.y, - GL_ALPHA, - GL_UNSIGNED_BYTE, - alphabuffer ); + glReadPixels( viewport.originx, viewport.originy, + viewport.x, viewport.y, + GL_RGB, GL_UNSIGNED_BYTE, pixelbuffer ); + glReadPixels( viewport.originx, viewport.originy, + viewport.x, viewport.y, + GL_ALPHA, GL_UNSIGNED_BYTE, alphabuffer ); image.SetData( pixelbuffer ); image.SetAlpha( alphabuffer ); image = image.Mirror( false ); wxBitmap bitmap( image ); -#endif if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD ) { diff --git a/3d-viewer/3d_read_mesh.cpp b/3d-viewer/3d_read_mesh.cpp index 4b43b1e043..a33c143bbe 100644 --- a/3d-viewer/3d_read_mesh.cpp +++ b/3d-viewer/3d_read_mesh.cpp @@ -2,12 +2,6 @@ // Name: 3d_read_mesh.cpp ///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation -#pragma interface -#endif - #include "fctsys.h" #include "common.h" #include "macros.h" @@ -417,7 +411,7 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) int coord_number; double* buf_points = ReadCoordsList( file, line, &coord_number, LineNum ); - continue; + // Do something if needed free( buf_points ); continue; } @@ -445,7 +439,7 @@ int S3D_MASTER::ReadGeometry( FILE* file, int* LineNum ) int coord_number; double* buf_points = ReadCoordsList( file, line, &coord_number, LineNum ); - continue; + // Do something if needed free( buf_points ); continue; } diff --git a/3d-viewer/3d_toolbar.cpp b/3d-viewer/3d_toolbar.cpp index da068788fd..b9c10478b9 100644 --- a/3d-viewer/3d_toolbar.cpp +++ b/3d-viewer/3d_toolbar.cpp @@ -104,9 +104,9 @@ void WinEDA3D_DrawFrame::ReCreateMenuBar() // If called from the display frame of cvpcb, only some options are // relevant - if( m_Parent->m_FrameName == wxT( "CmpFrame" ) ) // Called from cvpcb ! - full_options = false; // Do not display all - // options + if( m_Parent->m_FrameName == wxT( "CmpFrame" ) ) + // Called from cvpcb: do not display all options + full_options = false; wxMenuBar* menuBar = new wxMenuBar; @@ -118,6 +118,13 @@ void WinEDA3D_DrawFrame::ReCreateMenuBar() _( "Create Image (png format)" ) ); fileMenu->Append( ID_MENU_SCREENCOPY_JPEG, _( "Create Image (jpeg format)" ) ); + +#if (defined(__WINDOWS__) || defined(__APPLE__ ) ) + // Does not work properly under linux + fileMenu->AppendSeparator(); + fileMenu->Append( ID_TOOL_SCREENCOPY_TOCLIBBOARD, + _( "Copy 3D Image to Clipboard" ) ); +#endif fileMenu->AppendSeparator(); fileMenu->Append( wxID_EXIT, _( "&Exit" ) );