← Back to team overview

kicad-developers team mailing list archive

MacOSX - 3d-viewer - Save/Clipboard working support

 

I've developed a different approach to make work the clipboard and the saveoption.
I'vent tested it on Windows or Linux but should work with all endianess andOS.
Maybe fixes also problems under linux.

Waiting for Feerbacks..
--
Marco

Index: 3d_canvas.cpp
===================================================================
--- 3d_canvas.cpp	(revision 1781)
+++ 3d_canvas.cpp	(working copy)
@@ -627,14 +627,26 @@
}
 
Redraw( true );
- wxSize image_size = GetClientSize();
- 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 );
 
+ struct vieport_params{
+	GLint originx;
+	GLint originy;
+	GLint x;
+	GLint y;
+ } viewport;
+
+ glGetIntegerv(GL_VIEWPORT, (GLint*) &viewport);
+
+ unsigned char* pixelbuffer = (unsigned char*)malloc(3*viewport.x*viewport.y);
+ glReadPixels(0,0,viewport.x,viewport.y, GL_RGB, GL_UNSIGNED_BYTE, pixelbuffer);
+
+ wxImage image(viewport.x ,viewport.y);
+
+ image.SetData(pixelbuffer);
+ image = image.Mirror();
+ image = image.Rotate90().Rotate90();
+ wxBitmap bitmap( image, -1 );
+     
if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
{
wxBitmapDataObject* dobjBmp = new wxBitmapDataObject;
@@ -650,7 +662,6 @@
}
else
{
- wxImage image = bitmap.ConvertToImage();
 
if( !image.SaveFile( FullFileName,
fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
Index: 3d_toolbar.cpp
===================================================================
--- 3d_toolbar.cpp	(revision 1781)
+++ 3d_toolbar.cpp	(working copy)
@@ -31,7 +31,7 @@
m_HToolBar->AddTool( ID_RELOAD3D_BOARD, wxEmptyString,
wxBitmap( import3d_xpm ),
_( "Reload board" ) );
-#ifdef __WINDOWS__ // do not work properly under linux
+#if (defined(__WINDOWS__) || defined(__APPLE__)) // do not work properly under linux
m_HToolBar-> AddSeparator();
 
m_HToolBar->AddTool( ID_TOOL_SCREENCOPY_TOCLIBBOARD, wxEmptyString,