Commit 04bf11c2 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Change PCBNew and CVPCB 3D viewer focus behavior. (fixes lp:818890)

* Raise 3D frame in PCB editor and module editor instead of displaying a message
  dialog indicating that the 3D viewer is already open.
* Raise 3D viewer and module viewer in CVPCB to mimic the behavior changed in
  PCBNew.
* Set focus to OpenGL canvas when creating 3D viewer so mouse wheel events
  are handled on Windows without having to click on the canvas.
* Rename 3D viewer frame class from WinEDA3D_DrawFrame to EDA_3D_FRAME.
* The usual smattering of coding policy fixes.
parent f60c9823
......@@ -48,28 +48,29 @@ void CheckGLError()
}
}
/*
* Pcb3D_GLCanvas implementation
*/
BEGIN_EVENT_TABLE( Pcb3D_GLCanvas, wxGLCanvas )
EVT_PAINT( Pcb3D_GLCanvas::OnPaint )
EVT_PAINT( Pcb3D_GLCanvas::OnPaint )
// key event:
EVT_CHAR( Pcb3D_GLCanvas::OnChar )
// key event:
EVT_CHAR( Pcb3D_GLCanvas::OnChar )
// mouse events
EVT_RIGHT_DOWN( Pcb3D_GLCanvas::OnRightClick )
EVT_MOUSEWHEEL( Pcb3D_GLCanvas::OnMouseWheel )
EVT_MOTION( Pcb3D_GLCanvas::OnMouseMove )
// mouse events
EVT_RIGHT_DOWN( Pcb3D_GLCanvas::OnRightClick )
EVT_MOUSEWHEEL( Pcb3D_GLCanvas::OnMouseWheel )
EVT_MOTION( Pcb3D_GLCanvas::OnMouseMove )
// other events
EVT_ERASE_BACKGROUND( Pcb3D_GLCanvas::OnEraseBackground )
EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END,
Pcb3D_GLCanvas::OnPopUpMenu )
// other events
EVT_ERASE_BACKGROUND( Pcb3D_GLCanvas::OnEraseBackground )
EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END, Pcb3D_GLCanvas::OnPopUpMenu )
END_EVENT_TABLE()
Pcb3D_GLCanvas::Pcb3D_GLCanvas( WinEDA3D_DrawFrame* parent, int* attribList ) :
Pcb3D_GLCanvas::Pcb3D_GLCanvas( EDA_3D_FRAME* parent, int* attribList ) :
#if wxCHECK_VERSION( 2, 7, 0 )
wxGLCanvas( parent, -1, attribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE )
......@@ -78,10 +79,10 @@ Pcb3D_GLCanvas::Pcb3D_GLCanvas( WinEDA3D_DrawFrame* parent, int* attribList ) :
wxFULL_REPAINT_ON_RESIZE )
#endif
{
m_init = FALSE;
m_init = false;
m_gllist = 0;
m_Parent = parent;
m_ortho = false;
m_ortho = false;
#if wxCHECK_VERSION( 2, 7, 0 )
......@@ -96,7 +97,8 @@ Pcb3D_GLCanvas::Pcb3D_GLCanvas( WinEDA3D_DrawFrame* parent, int* attribList ) :
Pcb3D_GLCanvas::~Pcb3D_GLCanvas()
{
ClearLists();
m_init = FALSE;
m_init = false;
#if wxCHECK_VERSION( 2, 7, 0 )
delete m_glRC;
#endif
......@@ -107,6 +109,7 @@ void Pcb3D_GLCanvas::ClearLists()
{
if( m_gllist > 0 )
glDeleteLists( m_gllist, 1 );
m_gllist = 0;
}
......@@ -230,7 +233,7 @@ void Pcb3D_GLCanvas::SetView3D( int keycode )
}
DisplayStatus();
Refresh( FALSE );
Refresh( false );
}
......@@ -269,13 +272,15 @@ void Pcb3D_GLCanvas::OnMouseWheel( wxMouseEvent& event )
if( event.GetWheelRotation() > 0 )
{
g_Parm_3D_Visu.m_Zoom /= 1.4;
if( g_Parm_3D_Visu.m_Zoom <= 0.01 )
g_Parm_3D_Visu.m_Zoom = 0.01;
}
else
g_Parm_3D_Visu.m_Zoom *= 1.4;
DisplayStatus();
Refresh( FALSE );
Refresh( false );
}
g_Parm_3D_Visu.m_Beginx = event.GetX();
......@@ -316,7 +321,7 @@ void Pcb3D_GLCanvas::OnMouseMove( wxMouseEvent& event )
/* orientation has changed, redraw mesh */
DisplayStatus();
Refresh( FALSE );
Refresh( false );
}
g_Parm_3D_Visu.m_Beginx = event.GetX();
......@@ -500,7 +505,7 @@ void Pcb3D_GLCanvas::InitGL()
if( !m_init )
{
m_init = TRUE;
m_init = true;
g_Parm_3D_Visu.m_Zoom = 1.0;
ZBottom = 1.0; ZTop = 10.0;
......@@ -534,10 +539,13 @@ void Pcb3D_GLCanvas::InitGL()
if( ModeIsOrtho() )
{
// OrthoReductionFactor is chosen so as to provide roughly the same size as Perspective View
const double orthoReductionFactor = 400/g_Parm_3D_Visu.m_Zoom;
// OrthoReductionFactor is chosen so as to provide roughly the same size as
// Perspective View
const double orthoReductionFactor = 400 / g_Parm_3D_Visu.m_Zoom;
// Initialize Projection Matrix for Ortographic View
glOrtho(-size.x/orthoReductionFactor, size.x/orthoReductionFactor, -size.y/orthoReductionFactor, size.y/orthoReductionFactor, 1, 10);
glOrtho( -size.x / orthoReductionFactor, size.x / orthoReductionFactor,
-size.y / orthoReductionFactor, size.y / orthoReductionFactor, 1, 10 );
}
else
{
......@@ -601,10 +609,11 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
wxFileName fn( m_Parent->m_Parent->GetScreen()->GetFileName() );
wxString FullFileName;
wxString file_ext, mask;
bool fmt_is_jpeg = FALSE;
bool fmt_is_jpeg = false;
if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
fmt_is_jpeg = TRUE;
fmt_is_jpeg = true;
if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
{
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
......@@ -612,10 +621,9 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
FullFileName = m_Parent->m_Parent->GetScreen()->GetFileName();
fn.SetExt( file_ext );
FullFileName =
EDA_FileSelector( _( "3D Image filename:" ), wxEmptyString,
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, TRUE );
FullFileName = EDA_FileSelector( _( "3D Image filename:" ), wxEmptyString,
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, true );
if( FullFileName.IsEmpty() )
return;
......@@ -661,6 +669,7 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
{
wxBitmapDataObject* dobjBmp = new wxBitmapDataObject;
dobjBmp->SetBitmap( bitmap );
if( wxTheClipboard->Open() )
{
if( !wxTheClipboard->SetData( dobjBmp ) )
......@@ -677,8 +686,7 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
wxImage image = bitmap.ConvertToImage();
if( !image.SaveFile( FullFileName,
fmt_is_jpeg ? wxBITMAP_TYPE_JPEG :
wxBITMAP_TYPE_PNG ) )
fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
wxMessageBox( _( "Can't save file" ) );
image.Destroy();
......
......@@ -23,22 +23,19 @@ double ZTop;
double DataScale3D; // 3D conversion units.
BEGIN_EVENT_TABLE( WinEDA3D_DrawFrame, wxFrame )
EVT_ACTIVATE( WinEDA3D_DrawFrame::OnActivate )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA3D_DrawFrame::Process_Zoom )
BEGIN_EVENT_TABLE( EDA_3D_FRAME, wxFrame )
EVT_ACTIVATE( EDA_3D_FRAME::OnActivate )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, EDA_3D_FRAME::Process_Zoom )
EVT_TOOL_RANGE( ID_START_COMMAND_3D, ID_END_COMMAND_3D,
WinEDA3D_DrawFrame::Process_Special_Functions )
EVT_MENU( wxID_EXIT, WinEDA3D_DrawFrame::Exit3DFrame )
EVT_MENU( ID_MENU_SCREENCOPY_PNG,
WinEDA3D_DrawFrame::Process_Special_Functions )
EVT_MENU( ID_MENU_SCREENCOPY_JPEG,
WinEDA3D_DrawFrame::Process_Special_Functions )
EVT_CLOSE( WinEDA3D_DrawFrame::OnCloseWindow )
EDA_3D_FRAME::Process_Special_Functions )
EVT_MENU( wxID_EXIT, EDA_3D_FRAME::Exit3DFrame )
EVT_MENU( ID_MENU_SCREENCOPY_PNG, EDA_3D_FRAME::Process_Special_Functions )
EVT_MENU( ID_MENU_SCREENCOPY_JPEG, EDA_3D_FRAME::Process_Special_Functions )
EVT_CLOSE( EDA_3D_FRAME::OnCloseWindow )
END_EVENT_TABLE()
WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( PCB_BASE_FRAME* parent,
const wxString& title,
long style ) :
EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title, long style ) :
wxFrame( parent, DISPLAY3D_FRAME, title, wxPoint( -1, -1 ), wxSize( -1, -1 ), style )
{
m_FrameName = wxT( "Frame3D" );
......@@ -68,7 +65,7 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( PCB_BASE_FRAME* parent,
ReCreateVToolbar();
// Make a Pcb3D_GLCanvas
int attrs[] = {WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0};
int attrs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0 };
m_Canvas = new Pcb3D_GLCanvas( this, attrs );
m_auimgr.SetManagedWindow( this );
......@@ -93,31 +90,37 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( PCB_BASE_FRAME* parent,
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();
}
void WinEDA3D_DrawFrame::Exit3DFrame( wxCommandEvent& event )
void EDA_3D_FRAME::Exit3DFrame( wxCommandEvent& event )
{
Close( TRUE );
Close( true );
}
void WinEDA3D_DrawFrame::OnCloseWindow( wxCloseEvent& Event )
void EDA_3D_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
SaveSettings();
if( m_Parent )
{
m_Parent->m_Draw3DFrame = NULL;
}
Destroy();
}
void WinEDA3D_DrawFrame::GetSettings()
void EDA_3D_FRAME::GetSettings()
{
wxString text;
wxConfig* config = wxGetApp().m_EDA_Config; // Current config used by
// application
wxConfig* config = wxGetApp().m_EDA_Config; // Current config used by application
if( config )
{
......@@ -129,12 +132,9 @@ void WinEDA3D_DrawFrame::GetSettings()
config->Read( text, &m_FrameSize.x, 600 );
text = m_FrameName + wxT( "Size_y" );
config->Read( text, &m_FrameSize.y, 400 );
config->Read( wxT( "BgColor_Red" ),
&g_Parm_3D_Visu.m_BgColor.m_Red, 0.0 );
config->Read( wxT( "BgColor_Green" ),
&g_Parm_3D_Visu.m_BgColor.m_Green, 0.0 );
config->Read( wxT( "BgColor_Blue" ),
&g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 );
config->Read( wxT( "BgColor_Red" ), &g_Parm_3D_Visu.m_BgColor.m_Red, 0.0 );
config->Read( wxT( "BgColor_Green" ), &g_Parm_3D_Visu.m_BgColor.m_Green, 0.0 );
config->Read( wxT( "BgColor_Blue" ), &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 );
}
#if defined( __WXMAC__ )
// for macOSX, the window must be below system (macOSX) toolbar
......@@ -144,11 +144,10 @@ void WinEDA3D_DrawFrame::GetSettings()
}
void WinEDA3D_DrawFrame::SaveSettings()
void EDA_3D_FRAME::SaveSettings()
{
wxString text;
wxConfig* Config = wxGetApp().m_EDA_Config; // Current config used by
// application
wxConfig* Config = wxGetApp().m_EDA_Config; // Current config used by application
if( !Config )
return;
......@@ -174,7 +173,7 @@ void WinEDA3D_DrawFrame::SaveSettings()
}
void WinEDA3D_DrawFrame::Process_Zoom( wxCommandEvent& event )
void EDA_3D_FRAME::Process_Zoom( wxCommandEvent& event )
{
int ii;
......@@ -206,34 +205,33 @@ void WinEDA3D_DrawFrame::Process_Zoom( wxCommandEvent& event )
return;
}
m_Canvas->Refresh( FALSE );
m_Canvas->Refresh( false );
m_Canvas->DisplayStatus();
}
void WinEDA3D_DrawFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
void EDA_3D_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{
}
void WinEDA3D_DrawFrame::OnRightClick( const wxPoint& MousePos,
wxMenu* PopMenu )
void EDA_3D_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
{
}
double WinEDA3D_DrawFrame::BestZoom()
double EDA_3D_FRAME::BestZoom()
{
return 1.0;
}
void WinEDA3D_DrawFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
void EDA_3D_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
}
void WinEDA3D_DrawFrame::Process_Special_Functions( wxCommandEvent& event )
void EDA_3D_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
#define ROT_ANGLE 10.0
......@@ -327,8 +325,7 @@ void WinEDA3D_DrawFrame::Process_Special_Functions( wxCommandEvent& event )
return;
default:
wxMessageBox( wxT( "WinEDA3D_DrawFrame::Process_Special_Functions() \
error: unknown command" ) );
wxMessageBox( wxT( "EDA_3D_FRAME::Process_Special_Functions() error: unknown command" ) );
return;
}
......@@ -337,7 +334,7 @@ error: unknown command" ) );
}
void WinEDA3D_DrawFrame::NewDisplay()
void EDA_3D_FRAME::NewDisplay()
{
m_reloadRequest = false;
......@@ -350,7 +347,7 @@ void WinEDA3D_DrawFrame::NewDisplay()
}
void WinEDA3D_DrawFrame::OnActivate( wxActivateEvent& event )
void EDA_3D_FRAME::OnActivate( wxActivateEvent& event )
{
// Reload data if 3D frame shows a footprint,
// because it can be changed since last frame activation
......@@ -363,7 +360,7 @@ void WinEDA3D_DrawFrame::OnActivate( wxActivateEvent& event )
/* called to set the background color of the 3D scene
*/
void WinEDA3D_DrawFrame::Set3DBgColor()
void EDA_3D_FRAME::Set3DBgColor()
{
S3D_Color color;
wxColour newcolor, oldcolor;
......@@ -373,6 +370,7 @@ void WinEDA3D_DrawFrame::Set3DBgColor()
wxRound( g_Parm_3D_Visu.m_BgColor.m_Blue * 255 ) );
newcolor = wxGetColourFromUser( this, oldcolor );
if( newcolor != oldcolor )
{
g_Parm_3D_Visu.m_BgColor.m_Red = (double) newcolor.Red() / 255.0;
......@@ -383,71 +381,77 @@ void WinEDA3D_DrawFrame::Set3DBgColor()
}
void WinEDA3D_DrawFrame::Set3DAxisOnOff()
void EDA_3D_FRAME::Set3DAxisOnOff()
{
if( g_Parm_3D_Visu.m_Draw3DAxis )
g_Parm_3D_Visu.m_Draw3DAxis = FALSE;
g_Parm_3D_Visu.m_Draw3DAxis = false;
else
g_Parm_3D_Visu.m_Draw3DAxis = TRUE;
g_Parm_3D_Visu.m_Draw3DAxis = true;
NewDisplay();
}
void WinEDA3D_DrawFrame::Set3DModuleOnOff()
void EDA_3D_FRAME::Set3DModuleOnOff()
{
if( g_Parm_3D_Visu.m_Draw3DModule )
g_Parm_3D_Visu.m_Draw3DModule = FALSE;
g_Parm_3D_Visu.m_Draw3DModule = false;
else
g_Parm_3D_Visu.m_Draw3DModule = TRUE;
g_Parm_3D_Visu.m_Draw3DModule = true;
NewDisplay();
}
void WinEDA3D_DrawFrame::Set3DZoneOnOff()
void EDA_3D_FRAME::Set3DZoneOnOff()
{
if( g_Parm_3D_Visu.m_Draw3DZone )
g_Parm_3D_Visu.m_Draw3DZone = FALSE;
g_Parm_3D_Visu.m_Draw3DZone = false;
else
g_Parm_3D_Visu.m_Draw3DZone = TRUE;
g_Parm_3D_Visu.m_Draw3DZone = true;
NewDisplay();
}
void WinEDA3D_DrawFrame::Set3DCommentsOnOff()
void EDA_3D_FRAME::Set3DCommentsOnOff()
{
if( g_Parm_3D_Visu.m_Draw3DComments )
g_Parm_3D_Visu.m_Draw3DComments = FALSE;
g_Parm_3D_Visu.m_Draw3DComments = false;
else
g_Parm_3D_Visu.m_Draw3DComments = TRUE;
g_Parm_3D_Visu.m_Draw3DComments = true;
NewDisplay();
}
void WinEDA3D_DrawFrame::Set3DDrawingsOnOff()
void EDA_3D_FRAME::Set3DDrawingsOnOff()
{
if( g_Parm_3D_Visu.m_Draw3DDrawings )
g_Parm_3D_Visu.m_Draw3DDrawings = FALSE;
g_Parm_3D_Visu.m_Draw3DDrawings = false;
else
g_Parm_3D_Visu.m_Draw3DDrawings = TRUE;
g_Parm_3D_Visu.m_Draw3DDrawings = true;
NewDisplay();
}
void WinEDA3D_DrawFrame::Set3DEco1OnOff()
void EDA_3D_FRAME::Set3DEco1OnOff()
{
if( g_Parm_3D_Visu.m_Draw3DEco1 )
g_Parm_3D_Visu.m_Draw3DEco1 = FALSE;
g_Parm_3D_Visu.m_Draw3DEco1 = false;
else
g_Parm_3D_Visu.m_Draw3DEco1 = TRUE;
g_Parm_3D_Visu.m_Draw3DEco1 = true;
NewDisplay();
}
void WinEDA3D_DrawFrame::Set3DEco2OnOff()
void EDA_3D_FRAME::Set3DEco2OnOff()
{
if( g_Parm_3D_Visu.m_Draw3DEco2 )
g_Parm_3D_Visu.m_Draw3DEco2 = FALSE;
g_Parm_3D_Visu.m_Draw3DEco2 = false;
else
g_Parm_3D_Visu.m_Draw3DEco2 = TRUE;
g_Parm_3D_Visu.m_Draw3DEco2 = true;
NewDisplay();
}
......@@ -9,7 +9,7 @@
#include "3d_viewer.h"
void WinEDA3D_DrawFrame::ReCreateHToolbar()
void EDA_3D_FRAME::ReCreateHToolbar()
{
if( m_HToolBar != NULL )
{
......@@ -98,12 +98,12 @@ void WinEDA3D_DrawFrame::ReCreateHToolbar()
}
void WinEDA3D_DrawFrame::ReCreateVToolbar()
void EDA_3D_FRAME::ReCreateVToolbar()
{
}
void WinEDA3D_DrawFrame::ReCreateMenuBar()
void EDA_3D_FRAME::ReCreateMenuBar()
{
bool full_options = true;
......@@ -167,6 +167,6 @@ void WinEDA3D_DrawFrame::ReCreateMenuBar()
}
void WinEDA3D_DrawFrame::SetToolbars()
void EDA_3D_FRAME::SetToolbars()
{
}
......@@ -87,7 +87,7 @@ enum id_3dview_frm
class Pcb3D_GLCanvas;
class WinEDA3D_DrawFrame;
class EDA_3D_FRAME;
class Info_3D_Visu;
class S3D_Vertex;
class SEGVIA;
......@@ -116,15 +116,14 @@ public:
wxPoint m_BoardPos;
wxSize m_BoardSize;
int m_Layers;
BOARD_DESIGN_SETTINGS* m_BoardSettings; // Link to current board design
// settings
double m_Epoxy_Width; /* Epoxy thickness (normalized)
**/
BOARD_DESIGN_SETTINGS* m_BoardSettings; // Link to current board design settings
double m_Epoxy_Width; // Epoxy thickness (normalized)
double m_BoardScale; /* Normalization scale for coordinates:
* when scaled between -1.0 and +1.0 */
double m_LayerZcoord[32];
double m_ActZpos;
public: Info_3D_Visu();
~Info_3D_Visu();
};
......@@ -133,19 +132,21 @@ public: Info_3D_Visu();
class Pcb3D_GLCanvas : public wxGLCanvas
{
public:
WinEDA3D_DrawFrame* m_Parent;
EDA_3D_FRAME* m_Parent;
private:
bool m_init;
GLuint m_gllist;
/// Tracks whether to use Orthographic or Perspective projection
//TODO: Does this belong here, or in WinEDA3D_DrawFrame ???
//TODO: Does this belong here, or in EDA_3D_FRAME ???
bool m_ortho;
#if wxCHECK_VERSION( 2, 7, 0 )
wxGLContext* m_glRC;
#endif
public:
Pcb3D_GLCanvas( WinEDA3D_DrawFrame* parent, int* attribList = 0 );
Pcb3D_GLCanvas( EDA_3D_FRAME* parent, int* attribList = 0 );
~Pcb3D_GLCanvas();
void ClearLists();
......@@ -170,9 +171,10 @@ public:
void InitGL();
void SetLights();
void Draw3D_Track( TRACK* track );
/**
* Function Draw3D_SolidPolygonsInZones
* draw all solid polygons used as filles areas in a zone
* draw all solid polygons used as filled areas in a zone
* @param aZone = the zone to draw
*/
void Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone );
......@@ -180,7 +182,7 @@ public:
/**
* Function Draw3D_Polygon
* draw one solid polygon
* @param aCornersList = a std::vector<wxPoint> liste of corners, in physical coordinates
* @param aCornersList = a std::vector<wxPoint> list of corners, in physical coordinates
* @param aZpos = the z position in 3D units
*/
void Draw3D_Polygon( std::vector<wxPoint>& aCornersList, double aZpos );
......@@ -190,6 +192,7 @@ public:
/// Toggles ortographic projection on and off
void ToggleOrtho(){ m_ortho = !m_ortho ; Refresh(true);};
/// Returns the orthographic projection flag
bool ModeIsOrtho() { return m_ortho ;};
......@@ -200,13 +203,12 @@ public:
};
class WinEDA3D_DrawFrame : public wxFrame
class EDA_3D_FRAME : public wxFrame
{
public:
PCB_BASE_FRAME* m_Parent;
private:
wxString m_FrameName; // name used for writing and reading setup
// It is "Frame3D"
wxString m_FrameName; // name used for writing and reading setup. It is "Frame3D"
Pcb3D_GLCanvas* m_Canvas;
EDA_TOOLBAR* m_HToolBar;
EDA_TOOLBAR* m_VToolBar;
......@@ -217,9 +219,9 @@ private:
bool m_reloadRequest;
public:
WinEDA3D_DrawFrame( PCB_BASE_FRAME* parent, const wxString& title,
long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
~WinEDA3D_DrawFrame()
EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title,
long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
~EDA_3D_FRAME()
{
m_auimgr.UnInit();
};
......@@ -232,6 +234,7 @@ public:
void SetToolbars();
void GetSettings();
void SaveSettings();
/**
* Function ReloadRequest
* must be called when reloading data from Pcbnew is needed
......
......@@ -408,13 +408,16 @@ void DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame( wxCommandEvent& event )
{
if( m_Draw3DFrame )
{
DisplayInfoMessage( this, _( "3D Frame already opened" ) );
m_Draw3DFrame->Raise();
// Raising the window does not set the focus on Linux. This should work on any platform.
if( wxWindow::FindFocus() != m_Draw3DFrame )
m_Draw3DFrame->SetFocus();
return;
}
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ),
KICAD_DEFAULT_3D_DRAWFRAME_STYLE |
wxFRAME_FLOAT_ON_PARENT );
m_Draw3DFrame = new EDA_3D_FRAME( this, _( "3D Viewer" ), KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
m_Draw3DFrame->Show( true );
}
......
......@@ -27,19 +27,26 @@
void CVPCB_MAINFRAME::CreateScreenCmp()
{
wxString msg, FootprintName;
bool IsNew = FALSE;
bool IsNew = false;
FootprintName = m_FootprintList->GetSelectedFootprint();
if( DrawFrame == NULL )
{
DrawFrame = new DISPLAY_FOOTPRINTS_FRAME( this, _( "Module" ),
wxPoint( 0, 0 ),
wxSize( 600, 400 ),
KICAD_DEFAULT_DRAWFRAME_STYLE |
wxFRAME_FLOAT_ON_PARENT );
IsNew = TRUE;
DrawFrame->Show( TRUE );
wxPoint( 0, 0 ),
wxSize( 600, 400 ),
KICAD_DEFAULT_DRAWFRAME_STYLE );
IsNew = true;
DrawFrame->Show( true );
}
else
{
DrawFrame->Raise();
// Raising the window does not set the focus on Linux. This should work on any platform.
if( wxWindow::FindFocus() != DrawFrame )
DrawFrame->SetFocus();
}
if( !FootprintName.IsEmpty() )
......@@ -63,18 +70,21 @@ void CVPCB_MAINFRAME::CreateScreenCmp()
}
MODULE* mod = DrawFrame->Get_Module( FootprintName );
if( mod )
DrawFrame->GetBoard()->m_Modules.PushBack( mod );
DrawFrame->Zoom_Automatique( FALSE );
DrawFrame->Zoom_Automatique( false );
DrawFrame->DrawPanel->Refresh();
DrawFrame->UpdateStatusBar(); /* Display new cursor coordinates and zoom value */
if( DrawFrame->m_Draw3DFrame )
DrawFrame->m_Draw3DFrame->NewDisplay();
}
else if( !IsNew )
{
DrawFrame->Refresh();
if( DrawFrame->m_Draw3DFrame )
DrawFrame->m_Draw3DFrame->NewDisplay();
}
......
......@@ -34,7 +34,7 @@ class TEXTE_MODULE;
class MIREPCB;
class DIMENSION;
class EDGE_MODULE;
class WinEDA3D_DrawFrame;
class EDA_3D_FRAME;
class DRC;
class ZONE_CONTAINER;
class DRAWSEGMENT;
......@@ -60,7 +60,7 @@ public:
UserUnitType m_UserGridUnit;
wxRealPoint m_UserGridSize;
WinEDA3D_DrawFrame* m_Draw3DFrame;
EDA_3D_FRAME* m_Draw3DFrame;
WinEDA_ModuleEditFrame* m_ModuleEditFrame;
protected:
......
......@@ -31,7 +31,6 @@ class TEXTE_MODULE;
class MIREPCB;
class DIMENSION;
class EDGE_MODULE;
class WinEDA3D_DrawFrame;
class DRC;
class ZONE_CONTAINER;
class DRAWSEGMENT;
......
......@@ -167,7 +167,15 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_ModuleEditFrame->Zoom_Automatique( false );
}
else
m_ModuleEditFrame->Iconize( false );
{
m_ModuleEditFrame->Raise();
// Raising the window does not set the focus on Linux. This should work on
// any platform.
if( wxWindow::FindFocus() != m_ModuleEditFrame )
m_ModuleEditFrame->SetFocus();
}
break;
case ID_PCB_GLOBAL_DELETE:
......
......@@ -325,11 +325,16 @@ void WinEDA_ModuleEditFrame::Show3D_Frame( wxCommandEvent& event )
{
if( m_Draw3DFrame )
{
DisplayInfoMessage( this, _( "3D Frame already opened" ) );
m_Draw3DFrame->Raise();
// Raising the window does not set the focus on Linux. This should work on any platform.
if( wxWindow::FindFocus() != m_Draw3DFrame )
m_Draw3DFrame->SetFocus();
return;
}
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ) );
m_Draw3DFrame = new EDA_3D_FRAME( this, _( "3D Viewer" ) );
m_Draw3DFrame->Show( true );
}
......
......@@ -483,11 +483,16 @@ void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
{
if( m_Draw3DFrame )
{
DisplayInfoMessage( this, _( "3D Frame already opened" ) );
m_Draw3DFrame->Raise();
// Raising the window does not set the focus on Linux. This should work on any platform.
if( wxWindow::FindFocus() != m_Draw3DFrame )
m_Draw3DFrame->SetFocus();
return;
}
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ) );
m_Draw3DFrame = new EDA_3D_FRAME( this, _( "3D Viewer" ) );
m_Draw3DFrame->Show( true );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment