2007-05-06 16:03:28 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
/** setvisu() : initialisations de l'ecran d'affichage du composant **/
|
|
|
|
/*********************************************************************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "id.h"
|
2009-02-05 20:53:08 +00:00
|
|
|
#include "confirm.h"
|
2009-04-05 20:49:15 +00:00
|
|
|
#include "macros.h"
|
2009-02-05 20:53:08 +00:00
|
|
|
|
|
|
|
#include "3d_viewer.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "cvpcb.h"
|
|
|
|
#include "bitmaps.h"
|
|
|
|
#include "protos.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "cvstruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************/
|
|
|
|
/* Construction de la table des evenements pour WinEDA_DrawFrame */
|
|
|
|
/*****************************************************************/
|
|
|
|
|
2009-01-07 15:59:49 +00:00
|
|
|
BEGIN_EVENT_TABLE( WinEDA_DisplayFrame, WinEDA_DrawFrame )
|
2008-12-05 16:03:05 +00:00
|
|
|
EVT_CLOSE( WinEDA_DisplayFrame::OnCloseWindow )
|
|
|
|
EVT_SIZE( WinEDA_DrawFrame::OnSize )
|
2009-01-07 15:59:49 +00:00
|
|
|
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_DisplayFrame::OnZoom )
|
2008-12-05 16:03:05 +00:00
|
|
|
EVT_TOOL( ID_OPTIONS_SETUP, WinEDA_DisplayFrame::InstallOptionsDisplay )
|
2009-02-05 20:53:08 +00:00
|
|
|
EVT_TOOL( ID_CVPCB_SHOW3D_FRAME, WinEDA_DisplayFrame::Show3D_Frame )
|
2007-10-03 15:21:13 +00:00
|
|
|
END_EVENT_TABLE()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2007-10-27 12:24:09 +00:00
|
|
|
/***************************************************************************/
|
|
|
|
/* WinEDA_DisplayFrame: the frame to display the current focused footprint */
|
|
|
|
/***************************************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
WinEDA_DisplayFrame::WinEDA_DisplayFrame( WinEDA_CvpcbFrame* father,
|
2007-10-03 15:21:13 +00:00
|
|
|
const wxString& title,
|
2008-12-05 16:03:05 +00:00
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size, long style ) :
|
2008-12-08 15:27:13 +00:00
|
|
|
WinEDA_BasePcbFrame( father, CVPCB_DISPLAY_FRAME, title, pos,
|
2008-12-05 16:03:05 +00:00
|
|
|
size, style )
|
2007-10-03 15:21:13 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
m_FrameName = wxT( "CmpFrame" );
|
2007-10-27 12:24:09 +00:00
|
|
|
|
|
|
|
// Give an icon
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
SetIcon( wxICON( a_icon_cvpcb ) );
|
|
|
|
#else
|
|
|
|
SetIcon( wxICON( icon_cvpcb ) );
|
|
|
|
#endif
|
2007-10-03 15:21:13 +00:00
|
|
|
SetTitle( title );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
SetBoard( new BOARD( NULL, this ) );
|
2008-12-05 16:03:05 +00:00
|
|
|
SetBaseScreen( new PCB_SCREEN() );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
LoadSettings();
|
2007-10-03 15:21:13 +00:00
|
|
|
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
|
|
|
Show( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-27 12:24:09 +00:00
|
|
|
/******************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
WinEDA_DisplayFrame::~WinEDA_DisplayFrame()
|
2007-10-27 12:24:09 +00:00
|
|
|
/******************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
delete GetBaseScreen();
|
|
|
|
SetBaseScreen( 0 );
|
2007-10-27 12:24:09 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
delete GetBoard();
|
2007-10-27 12:24:09 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
( (WinEDA_CvpcbFrame*) wxGetApp().GetTopWindow() )->DrawFrame = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************/
|
2007-10-03 15:21:13 +00:00
|
|
|
void WinEDA_DisplayFrame::OnCloseWindow( wxCloseEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************************/
|
2007-10-03 15:21:13 +00:00
|
|
|
|
2007-10-27 12:24:09 +00:00
|
|
|
/* Called when the frame is closed
|
|
|
|
* Save current settings (frame position and size
|
2007-10-03 15:21:13 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-10-03 15:21:13 +00:00
|
|
|
wxPoint pos;
|
|
|
|
wxSize size;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
size = GetSize();
|
|
|
|
pos = GetPosition();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
SaveSettings();
|
|
|
|
Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_DisplayFrame::ReCreateVToolbar()
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************/
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_DisplayFrame::ReCreateHToolbar()
|
2007-05-06 16:03:28 +00:00
|
|
|
/************************************************/
|
|
|
|
{
|
2007-10-03 15:21:13 +00:00
|
|
|
if( m_HToolBar != NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_HToolBar = new WinEDA_Toolbar( TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
SetToolBar( m_HToolBar );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
m_HToolBar->AddTool( ID_OPTIONS_SETUP, wxEmptyString,
|
2008-12-05 16:03:05 +00:00
|
|
|
wxBitmap( display_options_xpm ),
|
|
|
|
_( "Display Options" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
m_HToolBar->AddSeparator();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-01-07 15:59:49 +00:00
|
|
|
m_HToolBar->AddTool( ID_ZOOM_IN, wxEmptyString,
|
2008-12-05 16:03:05 +00:00
|
|
|
wxBitmap( zoom_in_xpm ),
|
|
|
|
_( "zoom + (F1)" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-01-07 15:59:49 +00:00
|
|
|
m_HToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString,
|
2008-12-05 16:03:05 +00:00
|
|
|
wxBitmap( zoom_out_xpm ),
|
|
|
|
_( "zoom - (F2)" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-01-07 15:59:49 +00:00
|
|
|
m_HToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString,
|
2008-12-05 16:03:05 +00:00
|
|
|
wxBitmap( zoom_redraw_xpm ),
|
|
|
|
_( "redraw (F3)" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-01-07 15:59:49 +00:00
|
|
|
m_HToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
|
2008-12-05 16:03:05 +00:00
|
|
|
wxBitmap( zoom_auto_xpm ),
|
|
|
|
_( "1:1 zoom" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
m_HToolBar->AddSeparator();
|
2008-12-05 16:03:05 +00:00
|
|
|
m_HToolBar->AddTool( ID_CVPCB_SHOW3D_FRAME, wxEmptyString,
|
|
|
|
wxBitmap( show_3d_xpm ),
|
|
|
|
_( "1:1 zoom" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
// after adding the buttons to the toolbar, must call Realize() to reflect
|
|
|
|
// the changes
|
|
|
|
m_HToolBar->Realize();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_DisplayFrame::SetToolbars()
|
2007-05-06 16:03:28 +00:00
|
|
|
/*******************************************/
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 18:24:15 +00:00
|
|
|
/*************************************************************************/
|
2007-10-03 15:21:13 +00:00
|
|
|
void WinEDA_DisplayFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
|
2007-10-07 18:24:15 +00:00
|
|
|
/*************************************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
|
2007-10-07 18:24:15 +00:00
|
|
|
/*************************************************************************/
|
2007-10-03 15:21:13 +00:00
|
|
|
void WinEDA_DisplayFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
|
2007-10-07 18:24:15 +00:00
|
|
|
/*************************************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
|
2007-10-07 18:24:15 +00:00
|
|
|
/*********************************************************************************/
|
|
|
|
bool WinEDA_DisplayFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
|
|
|
|
/*********************************************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-10-27 12:24:09 +00:00
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
2007-10-27 12:24:09 +00:00
|
|
|
void WinEDA_DisplayFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
|
2007-05-06 16:03:28 +00:00
|
|
|
/****************************************************************/
|
|
|
|
{
|
2009-02-07 08:33:25 +00:00
|
|
|
wxRealPoint delta;
|
2007-10-03 15:21:13 +00:00
|
|
|
int flagcurseur = 0;
|
|
|
|
wxPoint curpos, oldpos;
|
2009-01-07 15:59:49 +00:00
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetEventObject( this );
|
2007-10-03 15:21:13 +00:00
|
|
|
|
|
|
|
curpos = DrawPanel->CursorRealPosition( Mouse );
|
2008-04-17 16:25:29 +00:00
|
|
|
oldpos = GetScreen()->m_Curseur;
|
2007-10-03 15:21:13 +00:00
|
|
|
|
2009-01-29 14:26:20 +00:00
|
|
|
delta = GetScreen()->GetGrid();
|
|
|
|
GetScreen()->Scale( delta );
|
2009-01-17 20:31:19 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
if( delta.x <= 0 )
|
|
|
|
delta.x = 1;
|
|
|
|
if( delta.y <= 0 )
|
|
|
|
delta.y = 1;
|
|
|
|
|
2009-02-05 20:53:08 +00:00
|
|
|
switch( g_KeyPressed )
|
2007-10-03 15:21:13 +00:00
|
|
|
{
|
2009-02-05 20:53:08 +00:00
|
|
|
case WXK_F1:
|
|
|
|
cmd.SetId( ID_POPUP_ZOOM_IN );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
flagcurseur = 2;
|
|
|
|
curpos = GetScreen()->m_Curseur;
|
|
|
|
break;
|
2007-10-03 15:21:13 +00:00
|
|
|
|
2009-02-05 20:53:08 +00:00
|
|
|
case WXK_F2:
|
|
|
|
cmd.SetId( ID_POPUP_ZOOM_OUT );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
flagcurseur = 2;
|
|
|
|
curpos = GetScreen()->m_Curseur;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_F3:
|
|
|
|
cmd.SetId( ID_ZOOM_REDRAW );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
flagcurseur = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_F4:
|
|
|
|
cmd.SetId( ID_POPUP_ZOOM_CENTER );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
flagcurseur = 2;
|
|
|
|
curpos = GetScreen()->m_Curseur;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ' ':
|
|
|
|
GetScreen()->m_O_Curseur = GetScreen()->m_Curseur;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_NUMPAD8: /* cursor moved up */
|
|
|
|
case WXK_UP:
|
2009-04-05 20:49:15 +00:00
|
|
|
Mouse.y -= wxRound(delta.y);
|
2009-02-05 20:53:08 +00:00
|
|
|
DrawPanel->MouseTo( Mouse );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_NUMPAD2: /* cursor moved down */
|
|
|
|
case WXK_DOWN:
|
2009-04-05 20:49:15 +00:00
|
|
|
Mouse.y += wxRound(delta.y);
|
2009-02-05 20:53:08 +00:00
|
|
|
DrawPanel->MouseTo( Mouse );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_NUMPAD4: /* cursor moved left */
|
|
|
|
case WXK_LEFT:
|
2009-04-05 20:49:15 +00:00
|
|
|
Mouse.x -= wxRound(delta.x);
|
2009-02-05 20:53:08 +00:00
|
|
|
DrawPanel->MouseTo( Mouse );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_NUMPAD6: /* cursor moved right */
|
|
|
|
case WXK_RIGHT:
|
2009-04-05 20:49:15 +00:00
|
|
|
Mouse.x += wxRound(delta.x);
|
2009-02-05 20:53:08 +00:00
|
|
|
DrawPanel->MouseTo( Mouse );
|
|
|
|
break;
|
2007-10-03 15:21:13 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->m_Curseur = curpos;
|
2007-10-27 12:24:09 +00:00
|
|
|
/* Put cursor on grid */
|
2008-04-17 16:25:29 +00:00
|
|
|
PutOnGrid( &GetScreen()->m_Curseur );
|
2007-10-03 15:21:13 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
if( GetScreen()->IsRefreshReq() )
|
2007-10-03 15:21:13 +00:00
|
|
|
{
|
|
|
|
flagcurseur = 2;
|
|
|
|
RedrawActiveWindow( DC, TRUE );
|
|
|
|
}
|
|
|
|
|
2009-01-17 20:31:19 +00:00
|
|
|
if( oldpos != GetScreen()->m_Curseur )
|
2007-10-03 15:21:13 +00:00
|
|
|
{
|
|
|
|
if( flagcurseur != 2 )
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
curpos = GetScreen()->m_Curseur;
|
|
|
|
GetScreen()->m_Curseur = oldpos;
|
2007-10-03 15:21:13 +00:00
|
|
|
DrawPanel->CursorOff( DC );
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->m_Curseur = curpos;
|
2007-10-03 15:21:13 +00:00
|
|
|
DrawPanel->CursorOn( DC );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
{
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
UpdateStatusBar(); /* Display new cursor coordinates */
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************************************/
|
2007-10-03 15:21:13 +00:00
|
|
|
void WinEDA_DisplayFrame::Process_Special_Functions( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************************************/
|
2007-10-03 15:21:13 +00:00
|
|
|
|
2007-10-27 12:24:09 +00:00
|
|
|
/* Called when a tool is selected, or when a popup menu is clicked
|
|
|
|
* Currently : no action exists
|
2007-10-03 15:21:13 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-10-27 12:24:09 +00:00
|
|
|
int id = event.GetId();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
wxClientDC dc( DrawPanel );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
DrawPanel->PrepareGraphicContext( &dc );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
wxMessageBox( wxT( "WinEDA_DisplayFrame::Process_Special_Functions error" ) );
|
|
|
|
break;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-03 15:21:13 +00:00
|
|
|
SetToolbars();
|
|
|
|
}
|
2009-02-05 20:53:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Display 3D frame of current footprint selection.
|
|
|
|
*/
|
|
|
|
void WinEDA_DisplayFrame::Show3D_Frame( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_Draw3DFrame )
|
|
|
|
{
|
|
|
|
DisplayInfo( this, _( "3D Frame already opened" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Draw3DFrame = new WinEDA3D_DrawFrame( this, _( "3D Viewer" ),
|
|
|
|
KICAD_DEFAULT_3D_DRAWFRAME_STYLE |
|
|
|
|
wxFRAME_FLOAT_ON_PARENT );
|
|
|
|
m_Draw3DFrame->Show( TRUE );
|
|
|
|
}
|