Commit 623ae37f authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew - ModView: add 3D view, and fix issues.

parent fa470d5c
......@@ -419,7 +419,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetCurItem( NULL );
Clear_Pcb( true );
GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
Load_Module_From_Library( full_libraryfilename, NULL );
Load_Module_From_Library( full_libraryfilename, true );
redraw = true;
}
......
......@@ -161,6 +161,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
GetBoard()->m_Modules.DeleteAll();
GetModuleLibrary( m_libraryName + wxT(".") + ModuleFileExtension,
m_footprintName, true );
Update3D_Frame();
}
DisplayLibInfos();
......
......@@ -29,6 +29,7 @@
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <macros.h>
#include <class_drawpanel.h>
#include <wxPcbStruct.h>
#include <3d_viewer.h>
......@@ -77,6 +78,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
FOOTPRINT_VIEWER_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODVIEW_FOOTPRINT_EXPORT_TO_BOARD,
FOOTPRINT_VIEWER_FRAME::ExportSelectedFootprint )
EVT_TOOL( ID_MODVIEW_SHOW_3D_VIEW, FOOTPRINT_VIEWER_FRAME::Show3D_Frame )
/* listbox events */
EVT_LISTBOX( ID_MODVIEW_LIB_LIST, FOOTPRINT_VIEWER_FRAME::ClickOnLibList )
......@@ -263,6 +265,8 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( wxWindow* parent, wxSemaphore* s
FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME()
{
if( m_Draw3DFrame )
m_Draw3DFrame->Destroy();
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent();
frame->m_ModuleViewerFrame = NULL;
}
......@@ -441,6 +445,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
DisplayLibInfos();
Zoom_Automatique( false );
m_canvas->Refresh();
Update3D_Frame();
}
}
......@@ -605,3 +610,46 @@ void FOOTPRINT_VIEWER_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition
UpdateStatusBar(); /* Display new cursor coordinates */
}
void FOOTPRINT_VIEWER_FRAME::Show3D_Frame( wxCommandEvent& event )
{
if( m_Draw3DFrame )
{
// Raising the window does not show the window on Windows if iconized.
// This should work on any platform.
if( m_Draw3DFrame->IsIconized() )
m_Draw3DFrame->Iconize( false );
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 EDA_3D_FRAME( this, wxEmptyString );
Update3D_Frame();
m_Draw3DFrame->Show( true );
}
/**
* Function Update3D_Frame
* must be called after a footprint selection
* Updates the 3D view and 3D frame title.
*/
void FOOTPRINT_VIEWER_FRAME::Update3D_Frame()
{
if( m_Draw3DFrame == NULL )
return;
wxString frm3Dtitle;
frm3Dtitle.Printf( _( "ModView: 3D Viewer [%s]" ), GetChars( m_footprintName ) );
m_Draw3DFrame->SetTitle( frm3Dtitle );
m_Draw3DFrame->ReloadRequest();
// Force 3D screen refresh immediately
if( GetBoard()->m_Modules )
m_Draw3DFrame->NewDisplay();
}
......@@ -69,6 +69,10 @@ public:
~FOOTPRINT_VIEWER_FRAME();
wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; }
private:
void OnSize( wxSizeEvent& event );
/**
......@@ -119,9 +123,7 @@ public:
void SaveSettings();
wxString& GetFootprintName( void ) const { return m_footprintName; }
wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; }
private:
/**
* Function OnActivate
* is called when the frame frame is activate to reload the libraries and component lists
......@@ -149,6 +151,19 @@ private:
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
/**
* Function Show3D_Frame (virtual)
* displays 3D view of the footprint (module) being edited.
*/
void Show3D_Frame( wxCommandEvent& event );
/**
* Function Update3D_Frame
* must be called after a footprint selection
* Updates the 3D view and 3D frame title.
*/
void Update3D_Frame();
/*
* Virtual functions, not used here, but needed by PCB_BASE_FRAME
* (virtual pure functions )
......
......@@ -362,7 +362,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
if( (DrawStruct == NULL) || (DrawStruct->GetFlags() == 0) )
{
m_canvas->MoveCursorToCrossHair();
DrawStruct = (BOARD_ITEM*) Load_Module_From_Library( wxEmptyString, aDC );
DrawStruct = (BOARD_ITEM*) Load_Module_From_Library( wxEmptyString, true, aDC );
SetCurItem( DrawStruct );
if( DrawStruct )
......
......@@ -321,6 +321,7 @@ enum pcbnew_ids
ID_MODVIEW_SELECT_PART,
ID_MODVIEW_PREVIOUS,
ID_MODVIEW_NEXT,
ID_MODVIEW_SHOW_3D_VIEW,
ID_MODVIEW_FOOTPRINT_EXPORT_TO_BOARD
};
......
......@@ -66,6 +66,11 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar()
KiBitmap( lib_next_xpm ),
_( "Display next footprint" ) );
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_MODVIEW_SHOW_3D_VIEW, wxEmptyString,
KiBitmap( three_d_xpm ),
_( "Show footprint in 3D viewer" ) );
m_mainToolBar->AddSeparator();
msg = AddHotkeyName( _( "Zoom in" ), g_Module_Editor_Hokeys_Descr,
HK_ZOOM_IN, IS_COMMENT );
......
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