3D viewer save image improvements.
* Set initial path to the current project path. * Remember user selected path and file name between saves. * Prompt user when over writing existing files.
This commit is contained in:
parent
61d699b7c6
commit
63c978d987
|
@ -26,6 +26,8 @@
|
|||
*/
|
||||
#include <fctsys.h>
|
||||
#include <trigo.h>
|
||||
#include <project.h>
|
||||
#include <gestfich.h>
|
||||
|
||||
#include <wx/image.h>
|
||||
|
||||
|
@ -37,8 +39,6 @@
|
|||
#include <wx/clipbrd.h>
|
||||
#include <wx/wupdlock.h>
|
||||
|
||||
#include <gestfich.h>
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
#include <GL/glew.h> // must be included before gl.h
|
||||
#endif
|
||||
|
@ -631,16 +631,17 @@ void EDA_3D_CANVAS::SetLights()
|
|||
}
|
||||
|
||||
|
||||
/* Create a Screenshot of the current 3D view.
|
||||
* Output file format is png or jpeg, or image is copied to the clipboard
|
||||
*/
|
||||
void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event )
|
||||
{
|
||||
wxFileName fn( Parent()->GetDefaultFileName() );
|
||||
static wxFileName fn; // Remember path between saves during this session only.
|
||||
wxString FullFileName;
|
||||
wxString file_ext, mask;
|
||||
bool fmt_is_jpeg = false;
|
||||
|
||||
// First time path is set to the project path.
|
||||
if( !fn.IsOk() )
|
||||
fn = Parent()->Prj().GetProjectFullName();
|
||||
|
||||
if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
|
||||
fmt_is_jpeg = true;
|
||||
|
||||
|
@ -648,16 +649,17 @@ void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event )
|
|||
{
|
||||
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
|
||||
mask = wxT( "*." ) + file_ext;
|
||||
FullFileName = Parent()->GetDefaultFileName();
|
||||
fn.SetExt( file_ext );
|
||||
|
||||
FullFileName = EDA_FileSelector( _( "3D Image filename:" ), wxEmptyString,
|
||||
FullFileName = EDA_FileSelector( _( "3D Image File Name:" ), fn.GetPath(),
|
||||
fn.GetFullName(), file_ext, mask, this,
|
||||
wxFD_SAVE, true );
|
||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT, true );
|
||||
|
||||
if( FullFileName.IsEmpty() )
|
||||
return;
|
||||
|
||||
fn = FullFileName;
|
||||
|
||||
// Be sure the screen area destroyed by the file dialog is redrawn before making
|
||||
// a screen copy.
|
||||
// Without this call, under Linux the screen refresh is made to late.
|
||||
|
|
|
@ -140,6 +140,13 @@ public:
|
|||
void OnMouseMove( wxMouseEvent& event );
|
||||
void OnRightClick( wxMouseEvent& event );
|
||||
void OnPopUpMenu( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Function TakeScreenshot
|
||||
*
|
||||
* creates a screenshot of the current 3D view and save to file as png or jpeg or image
|
||||
* is copied to the clipboard
|
||||
*/
|
||||
void TakeScreenshot( wxCommandEvent& event );
|
||||
void OnEnterWindow( wxMouseEvent& event );
|
||||
|
||||
|
|
Loading…
Reference in New Issue