2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file setvisu.cpp
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <bitmaps.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <cvpcb.h>
|
|
|
|
#include <cvpcb_mainframe.h>
|
|
|
|
#include <cvstruct.h>
|
|
|
|
#include <class_DisplayFootprintsFrame.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2009-05-06 11:55:36 +00:00
|
|
|
/*
|
|
|
|
* NOTE: There is something in 3d_viewer.h that causes a compiler error in
|
|
|
|
* <boost/foreach.hpp> in Linux so move it after cvpcb.h where it is
|
2009-11-05 19:26:52 +00:00
|
|
|
* included to prevent the error from occurring.
|
2009-05-06 11:55:36 +00:00
|
|
|
*/
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <3d_viewer.h>
|
2009-05-06 11:55:36 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-05-06 11:55:36 +00:00
|
|
|
/*
|
|
|
|
* Create or Update the frame showing the current highlighted footprint
|
|
|
|
* and (if showed) the 3D display frame
|
2007-10-03 15:21:13 +00:00
|
|
|
*/
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::CreateScreenCmp()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-10-03 15:21:13 +00:00
|
|
|
wxString msg, FootprintName;
|
2011-08-03 15:09:39 +00:00
|
|
|
bool IsNew = false;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
FootprintName = m_FootprintList->GetSelectedFootprint();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-08-04 11:23:19 +00:00
|
|
|
if( m_DisplayFootprintFrame == NULL )
|
2007-10-03 15:21:13 +00:00
|
|
|
{
|
2011-08-04 11:23:19 +00:00
|
|
|
m_DisplayFootprintFrame = new DISPLAY_FOOTPRINTS_FRAME( this, _( "Module" ),
|
2011-08-03 15:09:39 +00:00
|
|
|
wxPoint( 0, 0 ),
|
|
|
|
wxSize( 600, 400 ),
|
|
|
|
KICAD_DEFAULT_DRAWFRAME_STYLE );
|
|
|
|
IsNew = true;
|
2011-08-04 11:23:19 +00:00
|
|
|
m_DisplayFootprintFrame->Show( true );
|
2011-08-03 15:09:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-04 11:23:19 +00:00
|
|
|
// Raising the window does not show the window on Windows if iconized.
|
|
|
|
// This should work on any platform.
|
|
|
|
if( m_DisplayFootprintFrame->IsIconized() )
|
|
|
|
m_DisplayFootprintFrame->Iconize( false );
|
|
|
|
m_DisplayFootprintFrame->Raise();
|
2011-08-03 15:09:39 +00:00
|
|
|
|
|
|
|
// Raising the window does not set the focus on Linux. This should work on any platform.
|
2011-08-04 11:23:19 +00:00
|
|
|
if( wxWindow::FindFocus() != m_DisplayFootprintFrame )
|
|
|
|
m_DisplayFootprintFrame->SetFocus();
|
2007-10-03 15:21:13 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
if( !FootprintName.IsEmpty() )
|
|
|
|
{
|
|
|
|
msg = _( "Footprint: " ) + FootprintName;
|
2011-08-04 11:23:19 +00:00
|
|
|
m_DisplayFootprintFrame->SetTitle( msg );
|
2011-02-22 17:59:46 +00:00
|
|
|
FOOTPRINT_INFO* Module = m_footprints.GetModuleInfo( FootprintName );
|
2007-10-03 15:21:13 +00:00
|
|
|
msg = _( "Lib: " );
|
2007-10-27 12:24:09 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
if( Module )
|
|
|
|
msg += Module->m_LibName;
|
|
|
|
else
|
|
|
|
msg += wxT( "???" );
|
2007-10-27 12:24:09 +00:00
|
|
|
|
2011-08-04 11:23:19 +00:00
|
|
|
m_DisplayFootprintFrame->SetStatusText( msg, 0 );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-08-04 11:23:19 +00:00
|
|
|
if( m_DisplayFootprintFrame->GetBoard()->m_Modules.GetCount() )
|
2007-10-03 15:21:13 +00:00
|
|
|
{
|
|
|
|
// there is only one module in the list
|
2011-08-04 11:23:19 +00:00
|
|
|
m_DisplayFootprintFrame->GetBoard()->m_Modules.DeleteAll();
|
2007-10-03 15:21:13 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-08-04 11:23:19 +00:00
|
|
|
MODULE* mod = m_DisplayFootprintFrame->Get_Module( FootprintName );
|
2011-08-03 15:09:39 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( mod )
|
2011-08-04 11:23:19 +00:00
|
|
|
m_DisplayFootprintFrame->GetBoard()->m_Modules.PushBack( mod );
|
2007-10-03 15:21:13 +00:00
|
|
|
|
2011-08-04 11:23:19 +00:00
|
|
|
m_DisplayFootprintFrame->Zoom_Automatique( false );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_DisplayFootprintFrame->GetCanvas()->Refresh();
|
|
|
|
|
2011-12-18 20:22:16 +00:00
|
|
|
// Display new cursor coordinates and zoom value:
|
|
|
|
m_DisplayFootprintFrame->UpdateStatusBar();
|
2011-08-03 15:09:39 +00:00
|
|
|
|
2011-08-04 11:23:19 +00:00
|
|
|
if( m_DisplayFootprintFrame->m_Draw3DFrame )
|
|
|
|
m_DisplayFootprintFrame->m_Draw3DFrame->NewDisplay();
|
2007-10-03 15:21:13 +00:00
|
|
|
}
|
2011-12-18 20:22:16 +00:00
|
|
|
else if( !IsNew ) // No footprint to display. Erase old footprint, if any
|
2007-10-03 15:21:13 +00:00
|
|
|
{
|
2011-12-18 20:22:16 +00:00
|
|
|
if( m_DisplayFootprintFrame->GetBoard()->m_Modules.GetCount() )
|
|
|
|
{
|
|
|
|
m_DisplayFootprintFrame->GetBoard()->m_Modules.DeleteAll();
|
|
|
|
m_DisplayFootprintFrame->Zoom_Automatique( false );
|
|
|
|
m_DisplayFootprintFrame->SetStatusText( wxEmptyString, 0 );
|
|
|
|
m_DisplayFootprintFrame->UpdateStatusBar();
|
|
|
|
}
|
|
|
|
|
2011-08-04 11:23:19 +00:00
|
|
|
m_DisplayFootprintFrame->Refresh();
|
2011-08-03 15:09:39 +00:00
|
|
|
|
2011-08-04 11:23:19 +00:00
|
|
|
if( m_DisplayFootprintFrame->m_Draw3DFrame )
|
|
|
|
m_DisplayFootprintFrame->m_Draw3DFrame->NewDisplay();
|
2007-10-03 15:21:13 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-27 12:24:09 +00:00
|
|
|
|
2009-05-06 11:55:36 +00:00
|
|
|
/*
|
|
|
|
* Draws the current highlighted footprint.
|
|
|
|
*/
|
2010-02-01 21:23:27 +00:00
|
|
|
void DISPLAY_FOOTPRINTS_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
2007-10-27 12:24:09 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
if( !GetBoard() )
|
2007-10-27 12:24:09 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->DrawBackGround( DC );
|
|
|
|
GetBoard()->Draw( m_canvas, DC, GR_COPY );
|
2007-10-27 12:24:09 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
MODULE* Module = GetBoard()->m_Modules;
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2008-09-27 19:26:29 +00:00
|
|
|
if ( Module )
|
2009-04-17 08:51:02 +00:00
|
|
|
Module->DisplayInfo( this );
|
2010-01-22 18:13:43 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->DrawCrossHair( DC );
|
2007-10-27 12:24:09 +00:00
|
|
|
}
|
2008-09-27 19:26:29 +00:00
|
|
|
|
|
|
|
|
2009-05-06 11:55:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Redraw the BOARD items but not cursors, axis or grid.
|
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, int aDrawMode, const wxPoint& aOffset )
|
2008-09-27 19:26:29 +00:00
|
|
|
{
|
|
|
|
if( m_Modules )
|
|
|
|
{
|
2010-12-21 12:41:17 +00:00
|
|
|
m_Modules->Draw( aPanel, aDC, GR_COPY );
|
2009-05-06 11:55:36 +00:00
|
|
|
}
|
2008-09-27 19:26:29 +00:00
|
|
|
}
|