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.
This commit is contained in:
Wayne Stambaugh 2011-08-03 11:09:39 -04:00
parent f60c982397
commit 04bf11c229
11 changed files with 178 additions and 133 deletions

View File

@ -48,6 +48,7 @@ void CheckGLError()
} }
} }
/* /*
* Pcb3D_GLCanvas implementation * Pcb3D_GLCanvas implementation
*/ */
@ -65,11 +66,11 @@ EVT_MOTION( Pcb3D_GLCanvas::OnMouseMove )
// other events // other events
EVT_ERASE_BACKGROUND( Pcb3D_GLCanvas::OnEraseBackground ) EVT_ERASE_BACKGROUND( Pcb3D_GLCanvas::OnEraseBackground )
EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END, EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END, Pcb3D_GLCanvas::OnPopUpMenu )
Pcb3D_GLCanvas::OnPopUpMenu )
END_EVENT_TABLE() 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 ) #if wxCHECK_VERSION( 2, 7, 0 )
wxGLCanvas( parent, -1, attribList, wxDefaultPosition, wxDefaultSize, wxGLCanvas( parent, -1, attribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE ) wxFULL_REPAINT_ON_RESIZE )
@ -78,7 +79,7 @@ Pcb3D_GLCanvas::Pcb3D_GLCanvas( WinEDA3D_DrawFrame* parent, int* attribList ) :
wxFULL_REPAINT_ON_RESIZE ) wxFULL_REPAINT_ON_RESIZE )
#endif #endif
{ {
m_init = FALSE; m_init = false;
m_gllist = 0; m_gllist = 0;
m_Parent = parent; m_Parent = parent;
m_ortho = false; m_ortho = false;
@ -96,7 +97,8 @@ Pcb3D_GLCanvas::Pcb3D_GLCanvas( WinEDA3D_DrawFrame* parent, int* attribList ) :
Pcb3D_GLCanvas::~Pcb3D_GLCanvas() Pcb3D_GLCanvas::~Pcb3D_GLCanvas()
{ {
ClearLists(); ClearLists();
m_init = FALSE; m_init = false;
#if wxCHECK_VERSION( 2, 7, 0 ) #if wxCHECK_VERSION( 2, 7, 0 )
delete m_glRC; delete m_glRC;
#endif #endif
@ -107,6 +109,7 @@ void Pcb3D_GLCanvas::ClearLists()
{ {
if( m_gllist > 0 ) if( m_gllist > 0 )
glDeleteLists( m_gllist, 1 ); glDeleteLists( m_gllist, 1 );
m_gllist = 0; m_gllist = 0;
} }
@ -230,7 +233,7 @@ void Pcb3D_GLCanvas::SetView3D( int keycode )
} }
DisplayStatus(); DisplayStatus();
Refresh( FALSE ); Refresh( false );
} }
@ -269,13 +272,15 @@ void Pcb3D_GLCanvas::OnMouseWheel( wxMouseEvent& event )
if( event.GetWheelRotation() > 0 ) if( event.GetWheelRotation() > 0 )
{ {
g_Parm_3D_Visu.m_Zoom /= 1.4; g_Parm_3D_Visu.m_Zoom /= 1.4;
if( g_Parm_3D_Visu.m_Zoom <= 0.01 ) if( g_Parm_3D_Visu.m_Zoom <= 0.01 )
g_Parm_3D_Visu.m_Zoom = 0.01; g_Parm_3D_Visu.m_Zoom = 0.01;
} }
else else
g_Parm_3D_Visu.m_Zoom *= 1.4; g_Parm_3D_Visu.m_Zoom *= 1.4;
DisplayStatus(); DisplayStatus();
Refresh( FALSE ); Refresh( false );
} }
g_Parm_3D_Visu.m_Beginx = event.GetX(); g_Parm_3D_Visu.m_Beginx = event.GetX();
@ -316,7 +321,7 @@ void Pcb3D_GLCanvas::OnMouseMove( wxMouseEvent& event )
/* orientation has changed, redraw mesh */ /* orientation has changed, redraw mesh */
DisplayStatus(); DisplayStatus();
Refresh( FALSE ); Refresh( false );
} }
g_Parm_3D_Visu.m_Beginx = event.GetX(); g_Parm_3D_Visu.m_Beginx = event.GetX();
@ -500,7 +505,7 @@ void Pcb3D_GLCanvas::InitGL()
if( !m_init ) if( !m_init )
{ {
m_init = TRUE; m_init = true;
g_Parm_3D_Visu.m_Zoom = 1.0; g_Parm_3D_Visu.m_Zoom = 1.0;
ZBottom = 1.0; ZTop = 10.0; ZBottom = 1.0; ZTop = 10.0;
@ -534,10 +539,13 @@ void Pcb3D_GLCanvas::InitGL()
if( ModeIsOrtho() ) if( ModeIsOrtho() )
{ {
// OrthoReductionFactor is chosen so as to provide roughly the same size as Perspective View // OrthoReductionFactor is chosen so as to provide roughly the same size as
// Perspective View
const double orthoReductionFactor = 400 / g_Parm_3D_Visu.m_Zoom; const double orthoReductionFactor = 400 / g_Parm_3D_Visu.m_Zoom;
// Initialize Projection Matrix for Ortographic View // 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 else
{ {
@ -601,10 +609,11 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
wxFileName fn( m_Parent->m_Parent->GetScreen()->GetFileName() ); wxFileName fn( m_Parent->m_Parent->GetScreen()->GetFileName() );
wxString FullFileName; wxString FullFileName;
wxString file_ext, mask; wxString file_ext, mask;
bool fmt_is_jpeg = FALSE; bool fmt_is_jpeg = false;
if( event.GetId() == ID_MENU_SCREENCOPY_JPEG ) if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
fmt_is_jpeg = TRUE; fmt_is_jpeg = true;
if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD ) if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
{ {
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" ); 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(); FullFileName = m_Parent->m_Parent->GetScreen()->GetFileName();
fn.SetExt( file_ext ); fn.SetExt( file_ext );
FullFileName = FullFileName = EDA_FileSelector( _( "3D Image filename:" ), wxEmptyString,
EDA_FileSelector( _( "3D Image filename:" ), wxEmptyString,
fn.GetFullName(), file_ext, mask, this, fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, TRUE ); wxFD_SAVE, true );
if( FullFileName.IsEmpty() ) if( FullFileName.IsEmpty() )
return; return;
@ -661,6 +669,7 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
{ {
wxBitmapDataObject* dobjBmp = new wxBitmapDataObject; wxBitmapDataObject* dobjBmp = new wxBitmapDataObject;
dobjBmp->SetBitmap( bitmap ); dobjBmp->SetBitmap( bitmap );
if( wxTheClipboard->Open() ) if( wxTheClipboard->Open() )
{ {
if( !wxTheClipboard->SetData( dobjBmp ) ) if( !wxTheClipboard->SetData( dobjBmp ) )
@ -677,8 +686,7 @@ void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
wxImage image = bitmap.ConvertToImage(); wxImage image = bitmap.ConvertToImage();
if( !image.SaveFile( FullFileName, if( !image.SaveFile( FullFileName,
fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : fmt_is_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
wxBITMAP_TYPE_PNG ) )
wxMessageBox( _( "Can't save file" ) ); wxMessageBox( _( "Can't save file" ) );
image.Destroy(); image.Destroy();

View File

@ -23,22 +23,19 @@ double ZTop;
double DataScale3D; // 3D conversion units. double DataScale3D; // 3D conversion units.
BEGIN_EVENT_TABLE( WinEDA3D_DrawFrame, wxFrame ) BEGIN_EVENT_TABLE( EDA_3D_FRAME, wxFrame )
EVT_ACTIVATE( WinEDA3D_DrawFrame::OnActivate ) EVT_ACTIVATE( EDA_3D_FRAME::OnActivate )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA3D_DrawFrame::Process_Zoom ) 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, EVT_TOOL_RANGE( ID_START_COMMAND_3D, ID_END_COMMAND_3D,
WinEDA3D_DrawFrame::Process_Special_Functions ) EDA_3D_FRAME::Process_Special_Functions )
EVT_MENU( wxID_EXIT, WinEDA3D_DrawFrame::Exit3DFrame ) EVT_MENU( wxID_EXIT, EDA_3D_FRAME::Exit3DFrame )
EVT_MENU( ID_MENU_SCREENCOPY_PNG, EVT_MENU( ID_MENU_SCREENCOPY_PNG, EDA_3D_FRAME::Process_Special_Functions )
WinEDA3D_DrawFrame::Process_Special_Functions ) EVT_MENU( ID_MENU_SCREENCOPY_JPEG, EDA_3D_FRAME::Process_Special_Functions )
EVT_MENU( ID_MENU_SCREENCOPY_JPEG, EVT_CLOSE( EDA_3D_FRAME::OnCloseWindow )
WinEDA3D_DrawFrame::Process_Special_Functions )
EVT_CLOSE( WinEDA3D_DrawFrame::OnCloseWindow )
END_EVENT_TABLE() END_EVENT_TABLE()
WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( PCB_BASE_FRAME* parent,
const wxString& title, EDA_3D_FRAME::EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title, long style ) :
long style ) :
wxFrame( parent, DISPLAY3D_FRAME, title, wxPoint( -1, -1 ), wxSize( -1, -1 ), style ) wxFrame( parent, DISPLAY3D_FRAME, title, wxPoint( -1, -1 ), wxSize( -1, -1 ), style )
{ {
m_FrameName = wxT( "Frame3D" ); m_FrameName = wxT( "Frame3D" );
@ -93,31 +90,37 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( PCB_BASE_FRAME* parent,
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
m_auimgr.Update(); 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(); SaveSettings();
if( m_Parent ) if( m_Parent )
{ {
m_Parent->m_Draw3DFrame = NULL; m_Parent->m_Draw3DFrame = NULL;
} }
Destroy(); Destroy();
} }
void WinEDA3D_DrawFrame::GetSettings() void EDA_3D_FRAME::GetSettings()
{ {
wxString text; wxString text;
wxConfig* config = wxGetApp().m_EDA_Config; // Current config used by wxConfig* config = wxGetApp().m_EDA_Config; // Current config used by application
// application
if( config ) if( config )
{ {
@ -129,12 +132,9 @@ void WinEDA3D_DrawFrame::GetSettings()
config->Read( text, &m_FrameSize.x, 600 ); config->Read( text, &m_FrameSize.x, 600 );
text = m_FrameName + wxT( "Size_y" ); text = m_FrameName + wxT( "Size_y" );
config->Read( text, &m_FrameSize.y, 400 ); config->Read( text, &m_FrameSize.y, 400 );
config->Read( wxT( "BgColor_Red" ), config->Read( wxT( "BgColor_Red" ), &g_Parm_3D_Visu.m_BgColor.m_Red, 0.0 );
&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_Green" ), config->Read( wxT( "BgColor_Blue" ), &g_Parm_3D_Visu.m_BgColor.m_Blue, 0.0 );
&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__ ) #if defined( __WXMAC__ )
// for macOSX, the window must be below system (macOSX) toolbar // 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; wxString text;
wxConfig* Config = wxGetApp().m_EDA_Config; // Current config used by wxConfig* Config = wxGetApp().m_EDA_Config; // Current config used by application
// application
if( !Config ) if( !Config )
return; 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; int ii;
@ -206,34 +205,33 @@ void WinEDA3D_DrawFrame::Process_Zoom( wxCommandEvent& event )
return; return;
} }
m_Canvas->Refresh( FALSE ); m_Canvas->Refresh( false );
m_Canvas->DisplayStatus(); 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, void EDA_3D_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
wxMenu* PopMenu )
{ {
} }
double WinEDA3D_DrawFrame::BestZoom() double EDA_3D_FRAME::BestZoom()
{ {
return 1.0; 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 #define ROT_ANGLE 10.0
@ -327,8 +325,7 @@ void WinEDA3D_DrawFrame::Process_Special_Functions( wxCommandEvent& event )
return; return;
default: default:
wxMessageBox( wxT( "WinEDA3D_DrawFrame::Process_Special_Functions() \ wxMessageBox( wxT( "EDA_3D_FRAME::Process_Special_Functions() error: unknown command" ) );
error: unknown command" ) );
return; return;
} }
@ -337,7 +334,7 @@ error: unknown command" ) );
} }
void WinEDA3D_DrawFrame::NewDisplay() void EDA_3D_FRAME::NewDisplay()
{ {
m_reloadRequest = false; 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, // Reload data if 3D frame shows a footprint,
// because it can be changed since last frame activation // 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 /* called to set the background color of the 3D scene
*/ */
void WinEDA3D_DrawFrame::Set3DBgColor() void EDA_3D_FRAME::Set3DBgColor()
{ {
S3D_Color color; S3D_Color color;
wxColour newcolor, oldcolor; wxColour newcolor, oldcolor;
@ -373,6 +370,7 @@ void WinEDA3D_DrawFrame::Set3DBgColor()
wxRound( g_Parm_3D_Visu.m_BgColor.m_Blue * 255 ) ); wxRound( g_Parm_3D_Visu.m_BgColor.m_Blue * 255 ) );
newcolor = wxGetColourFromUser( this, oldcolor ); newcolor = wxGetColourFromUser( this, oldcolor );
if( newcolor != oldcolor ) if( newcolor != oldcolor )
{ {
g_Parm_3D_Visu.m_BgColor.m_Red = (double) newcolor.Red() / 255.0; 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 ) if( g_Parm_3D_Visu.m_Draw3DAxis )
g_Parm_3D_Visu.m_Draw3DAxis = FALSE; g_Parm_3D_Visu.m_Draw3DAxis = false;
else else
g_Parm_3D_Visu.m_Draw3DAxis = TRUE; g_Parm_3D_Visu.m_Draw3DAxis = true;
NewDisplay(); NewDisplay();
} }
void WinEDA3D_DrawFrame::Set3DModuleOnOff() void EDA_3D_FRAME::Set3DModuleOnOff()
{ {
if( g_Parm_3D_Visu.m_Draw3DModule ) if( g_Parm_3D_Visu.m_Draw3DModule )
g_Parm_3D_Visu.m_Draw3DModule = FALSE; g_Parm_3D_Visu.m_Draw3DModule = false;
else else
g_Parm_3D_Visu.m_Draw3DModule = TRUE; g_Parm_3D_Visu.m_Draw3DModule = true;
NewDisplay(); NewDisplay();
} }
void WinEDA3D_DrawFrame::Set3DZoneOnOff() void EDA_3D_FRAME::Set3DZoneOnOff()
{ {
if( g_Parm_3D_Visu.m_Draw3DZone ) if( g_Parm_3D_Visu.m_Draw3DZone )
g_Parm_3D_Visu.m_Draw3DZone = FALSE; g_Parm_3D_Visu.m_Draw3DZone = false;
else else
g_Parm_3D_Visu.m_Draw3DZone = TRUE; g_Parm_3D_Visu.m_Draw3DZone = true;
NewDisplay(); NewDisplay();
} }
void WinEDA3D_DrawFrame::Set3DCommentsOnOff() void EDA_3D_FRAME::Set3DCommentsOnOff()
{ {
if( g_Parm_3D_Visu.m_Draw3DComments ) if( g_Parm_3D_Visu.m_Draw3DComments )
g_Parm_3D_Visu.m_Draw3DComments = FALSE; g_Parm_3D_Visu.m_Draw3DComments = false;
else else
g_Parm_3D_Visu.m_Draw3DComments = TRUE; g_Parm_3D_Visu.m_Draw3DComments = true;
NewDisplay(); NewDisplay();
} }
void WinEDA3D_DrawFrame::Set3DDrawingsOnOff() void EDA_3D_FRAME::Set3DDrawingsOnOff()
{ {
if( g_Parm_3D_Visu.m_Draw3DDrawings ) if( g_Parm_3D_Visu.m_Draw3DDrawings )
g_Parm_3D_Visu.m_Draw3DDrawings = FALSE; g_Parm_3D_Visu.m_Draw3DDrawings = false;
else else
g_Parm_3D_Visu.m_Draw3DDrawings = TRUE; g_Parm_3D_Visu.m_Draw3DDrawings = true;
NewDisplay(); NewDisplay();
} }
void WinEDA3D_DrawFrame::Set3DEco1OnOff() void EDA_3D_FRAME::Set3DEco1OnOff()
{ {
if( g_Parm_3D_Visu.m_Draw3DEco1 ) if( g_Parm_3D_Visu.m_Draw3DEco1 )
g_Parm_3D_Visu.m_Draw3DEco1 = FALSE; g_Parm_3D_Visu.m_Draw3DEco1 = false;
else else
g_Parm_3D_Visu.m_Draw3DEco1 = TRUE; g_Parm_3D_Visu.m_Draw3DEco1 = true;
NewDisplay(); NewDisplay();
} }
void WinEDA3D_DrawFrame::Set3DEco2OnOff() void EDA_3D_FRAME::Set3DEco2OnOff()
{ {
if( g_Parm_3D_Visu.m_Draw3DEco2 ) if( g_Parm_3D_Visu.m_Draw3DEco2 )
g_Parm_3D_Visu.m_Draw3DEco2 = FALSE; g_Parm_3D_Visu.m_Draw3DEco2 = false;
else else
g_Parm_3D_Visu.m_Draw3DEco2 = TRUE; g_Parm_3D_Visu.m_Draw3DEco2 = true;
NewDisplay(); NewDisplay();
} }

View File

@ -9,7 +9,7 @@
#include "3d_viewer.h" #include "3d_viewer.h"
void WinEDA3D_DrawFrame::ReCreateHToolbar() void EDA_3D_FRAME::ReCreateHToolbar()
{ {
if( m_HToolBar != NULL ) 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; bool full_options = true;
@ -167,6 +167,6 @@ void WinEDA3D_DrawFrame::ReCreateMenuBar()
} }
void WinEDA3D_DrawFrame::SetToolbars() void EDA_3D_FRAME::SetToolbars()
{ {
} }

View File

@ -87,7 +87,7 @@ enum id_3dview_frm
class Pcb3D_GLCanvas; class Pcb3D_GLCanvas;
class WinEDA3D_DrawFrame; class EDA_3D_FRAME;
class Info_3D_Visu; class Info_3D_Visu;
class S3D_Vertex; class S3D_Vertex;
class SEGVIA; class SEGVIA;
@ -116,15 +116,14 @@ public:
wxPoint m_BoardPos; wxPoint m_BoardPos;
wxSize m_BoardSize; wxSize m_BoardSize;
int m_Layers; int m_Layers;
BOARD_DESIGN_SETTINGS* m_BoardSettings; // Link to current board design BOARD_DESIGN_SETTINGS* m_BoardSettings; // Link to current board design settings
// settings double m_Epoxy_Width; // Epoxy thickness (normalized)
double m_Epoxy_Width; /* Epoxy thickness (normalized)
**/
double m_BoardScale; /* Normalization scale for coordinates: double m_BoardScale; /* Normalization scale for coordinates:
* when scaled between -1.0 and +1.0 */ * when scaled between -1.0 and +1.0 */
double m_LayerZcoord[32]; double m_LayerZcoord[32];
double m_ActZpos; double m_ActZpos;
public: Info_3D_Visu(); public: Info_3D_Visu();
~Info_3D_Visu(); ~Info_3D_Visu();
}; };
@ -133,19 +132,21 @@ public: Info_3D_Visu();
class Pcb3D_GLCanvas : public wxGLCanvas class Pcb3D_GLCanvas : public wxGLCanvas
{ {
public: public:
WinEDA3D_DrawFrame* m_Parent; EDA_3D_FRAME* m_Parent;
private: private:
bool m_init; bool m_init;
GLuint m_gllist; GLuint m_gllist;
/// Tracks whether to use Orthographic or Perspective projection /// 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; bool m_ortho;
#if wxCHECK_VERSION( 2, 7, 0 ) #if wxCHECK_VERSION( 2, 7, 0 )
wxGLContext* m_glRC; wxGLContext* m_glRC;
#endif #endif
public: public:
Pcb3D_GLCanvas( WinEDA3D_DrawFrame* parent, int* attribList = 0 ); Pcb3D_GLCanvas( EDA_3D_FRAME* parent, int* attribList = 0 );
~Pcb3D_GLCanvas(); ~Pcb3D_GLCanvas();
void ClearLists(); void ClearLists();
@ -170,9 +171,10 @@ public:
void InitGL(); void InitGL();
void SetLights(); void SetLights();
void Draw3D_Track( TRACK* track ); void Draw3D_Track( TRACK* track );
/** /**
* Function Draw3D_SolidPolygonsInZones * 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 * @param aZone = the zone to draw
*/ */
void Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone ); void Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone );
@ -180,7 +182,7 @@ public:
/** /**
* Function Draw3D_Polygon * Function Draw3D_Polygon
* draw one solid 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 * @param aZpos = the z position in 3D units
*/ */
void Draw3D_Polygon( std::vector<wxPoint>& aCornersList, double aZpos ); void Draw3D_Polygon( std::vector<wxPoint>& aCornersList, double aZpos );
@ -190,6 +192,7 @@ public:
/// Toggles ortographic projection on and off /// Toggles ortographic projection on and off
void ToggleOrtho(){ m_ortho = !m_ortho ; Refresh(true);}; void ToggleOrtho(){ m_ortho = !m_ortho ; Refresh(true);};
/// Returns the orthographic projection flag /// Returns the orthographic projection flag
bool ModeIsOrtho() { return m_ortho ;}; bool ModeIsOrtho() { return m_ortho ;};
@ -200,13 +203,12 @@ public:
}; };
class WinEDA3D_DrawFrame : public wxFrame class EDA_3D_FRAME : public wxFrame
{ {
public: public:
PCB_BASE_FRAME* m_Parent; PCB_BASE_FRAME* m_Parent;
private: private:
wxString m_FrameName; // name used for writing and reading setup wxString m_FrameName; // name used for writing and reading setup. It is "Frame3D"
// It is "Frame3D"
Pcb3D_GLCanvas* m_Canvas; Pcb3D_GLCanvas* m_Canvas;
EDA_TOOLBAR* m_HToolBar; EDA_TOOLBAR* m_HToolBar;
EDA_TOOLBAR* m_VToolBar; EDA_TOOLBAR* m_VToolBar;
@ -217,9 +219,9 @@ private:
bool m_reloadRequest; bool m_reloadRequest;
public: public:
WinEDA3D_DrawFrame( PCB_BASE_FRAME* parent, const wxString& title, EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title,
long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE ); long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
~WinEDA3D_DrawFrame() ~EDA_3D_FRAME()
{ {
m_auimgr.UnInit(); m_auimgr.UnInit();
}; };
@ -232,6 +234,7 @@ public:
void SetToolbars(); void SetToolbars();
void GetSettings(); void GetSettings();
void SaveSettings(); void SaveSettings();
/** /**
* Function ReloadRequest * Function ReloadRequest
* must be called when reloading data from Pcbnew is needed * must be called when reloading data from Pcbnew is needed

View File

@ -408,13 +408,16 @@ void DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame( wxCommandEvent& event )
{ {
if( m_Draw3DFrame ) 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; return;
} }
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ), m_Draw3DFrame = new EDA_3D_FRAME( this, _( "3D Viewer" ), KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
KICAD_DEFAULT_3D_DRAWFRAME_STYLE |
wxFRAME_FLOAT_ON_PARENT );
m_Draw3DFrame->Show( true ); m_Draw3DFrame->Show( true );
} }

View File

@ -27,7 +27,7 @@
void CVPCB_MAINFRAME::CreateScreenCmp() void CVPCB_MAINFRAME::CreateScreenCmp()
{ {
wxString msg, FootprintName; wxString msg, FootprintName;
bool IsNew = FALSE; bool IsNew = false;
FootprintName = m_FootprintList->GetSelectedFootprint(); FootprintName = m_FootprintList->GetSelectedFootprint();
@ -36,10 +36,17 @@ void CVPCB_MAINFRAME::CreateScreenCmp()
DrawFrame = new DISPLAY_FOOTPRINTS_FRAME( this, _( "Module" ), DrawFrame = new DISPLAY_FOOTPRINTS_FRAME( this, _( "Module" ),
wxPoint( 0, 0 ), wxPoint( 0, 0 ),
wxSize( 600, 400 ), wxSize( 600, 400 ),
KICAD_DEFAULT_DRAWFRAME_STYLE | KICAD_DEFAULT_DRAWFRAME_STYLE );
wxFRAME_FLOAT_ON_PARENT ); IsNew = true;
IsNew = TRUE; DrawFrame->Show( 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() ) if( !FootprintName.IsEmpty() )
@ -63,18 +70,21 @@ void CVPCB_MAINFRAME::CreateScreenCmp()
} }
MODULE* mod = DrawFrame->Get_Module( FootprintName ); MODULE* mod = DrawFrame->Get_Module( FootprintName );
if( mod ) if( mod )
DrawFrame->GetBoard()->m_Modules.PushBack( mod ); DrawFrame->GetBoard()->m_Modules.PushBack( mod );
DrawFrame->Zoom_Automatique( FALSE ); DrawFrame->Zoom_Automatique( false );
DrawFrame->DrawPanel->Refresh(); DrawFrame->DrawPanel->Refresh();
DrawFrame->UpdateStatusBar(); /* Display new cursor coordinates and zoom value */ DrawFrame->UpdateStatusBar(); /* Display new cursor coordinates and zoom value */
if( DrawFrame->m_Draw3DFrame ) if( DrawFrame->m_Draw3DFrame )
DrawFrame->m_Draw3DFrame->NewDisplay(); DrawFrame->m_Draw3DFrame->NewDisplay();
} }
else if( !IsNew ) else if( !IsNew )
{ {
DrawFrame->Refresh(); DrawFrame->Refresh();
if( DrawFrame->m_Draw3DFrame ) if( DrawFrame->m_Draw3DFrame )
DrawFrame->m_Draw3DFrame->NewDisplay(); DrawFrame->m_Draw3DFrame->NewDisplay();
} }

View File

@ -34,7 +34,7 @@ class TEXTE_MODULE;
class MIREPCB; class MIREPCB;
class DIMENSION; class DIMENSION;
class EDGE_MODULE; class EDGE_MODULE;
class WinEDA3D_DrawFrame; class EDA_3D_FRAME;
class DRC; class DRC;
class ZONE_CONTAINER; class ZONE_CONTAINER;
class DRAWSEGMENT; class DRAWSEGMENT;
@ -60,7 +60,7 @@ public:
UserUnitType m_UserGridUnit; UserUnitType m_UserGridUnit;
wxRealPoint m_UserGridSize; wxRealPoint m_UserGridSize;
WinEDA3D_DrawFrame* m_Draw3DFrame; EDA_3D_FRAME* m_Draw3DFrame;
WinEDA_ModuleEditFrame* m_ModuleEditFrame; WinEDA_ModuleEditFrame* m_ModuleEditFrame;
protected: protected:

View File

@ -31,7 +31,6 @@ class TEXTE_MODULE;
class MIREPCB; class MIREPCB;
class DIMENSION; class DIMENSION;
class EDGE_MODULE; class EDGE_MODULE;
class WinEDA3D_DrawFrame;
class DRC; class DRC;
class ZONE_CONTAINER; class ZONE_CONTAINER;
class DRAWSEGMENT; class DRAWSEGMENT;

View File

@ -167,7 +167,15 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_ModuleEditFrame->Zoom_Automatique( false ); m_ModuleEditFrame->Zoom_Automatique( false );
} }
else 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; break;
case ID_PCB_GLOBAL_DELETE: case ID_PCB_GLOBAL_DELETE:

View File

@ -325,11 +325,16 @@ void WinEDA_ModuleEditFrame::Show3D_Frame( wxCommandEvent& event )
{ {
if( m_Draw3DFrame ) 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; return;
} }
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ) ); m_Draw3DFrame = new EDA_3D_FRAME( this, _( "3D Viewer" ) );
m_Draw3DFrame->Show( true ); m_Draw3DFrame->Show( true );
} }

View File

@ -483,11 +483,16 @@ void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
{ {
if( m_Draw3DFrame ) 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; return;
} }
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ) ); m_Draw3DFrame = new EDA_3D_FRAME( this, _( "3D Viewer" ) );
m_Draw3DFrame->Show( true ); m_Draw3DFrame->Show( true );
} }