2007-08-20 01:49:24 +00:00
|
|
|
/************/
|
|
|
|
/* zoom.cpp */
|
|
|
|
/************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/*
|
2007-08-20 01:49:24 +00:00
|
|
|
* Fonctions de gestion du zoom, du pas de grille et du
|
|
|
|
* recadrage automatique
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "macros.h"
|
|
|
|
|
|
|
|
#ifdef EESCHEMA
|
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef PCBNEW
|
|
|
|
#include "pcbnew.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CVPCB
|
|
|
|
#include "cvpcb.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "bitmaps.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
#include "id.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************/
|
2007-08-20 01:49:24 +00:00
|
|
|
void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************/
|
2007-08-20 01:49:24 +00:00
|
|
|
|
2007-10-29 10:05:07 +00:00
|
|
|
/** Compute draw offset (scroll bars and draw parameters)
|
|
|
|
* in order to have the current graphic cursor position at the screen center
|
|
|
|
* @param ToMouse if TRUE, the mouse cursor is moved
|
|
|
|
* to the graphic cursor position (which is usually on grid)
|
2008-04-17 16:25:29 +00:00
|
|
|
*
|
2007-08-20 01:49:24 +00:00
|
|
|
* Note: Mac OS ** does not ** allow moving mouse cursor by program.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
PutOnGrid( &(GetBaseScreen()->m_Curseur) );
|
|
|
|
|
2007-08-20 01:49:24 +00:00
|
|
|
AdjustScrollBars();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:49:24 +00:00
|
|
|
ReDrawPanel();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2007-10-29 10:05:07 +00:00
|
|
|
/* Move the mouse cursor to the on grid graphic cursor position */
|
2007-08-20 01:49:24 +00:00
|
|
|
if( ToMouse == TRUE )
|
2007-12-05 17:56:57 +00:00
|
|
|
{
|
2007-08-20 01:49:24 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
2007-12-05 17:56:57 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:49:24 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************/
|
2007-08-20 01:49:24 +00:00
|
|
|
void WinEDA_DrawFrame::PutOnGrid( wxPoint* coord )
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************/
|
2007-10-29 15:51:48 +00:00
|
|
|
/** Adjust the coordinate to the nearest grid value
|
2007-10-29 10:05:07 +00:00
|
|
|
* @param coord = coordinate to adjust
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:49:24 +00:00
|
|
|
double ftmp;
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
if( !GetBaseScreen()->m_UserGridIsON )
|
2007-08-20 01:49:24 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
wxSize grid_size = GetBaseScreen()->GetGrid();
|
|
|
|
|
2007-08-20 01:49:24 +00:00
|
|
|
ftmp = (double) coord->x / grid_size.x;
|
|
|
|
coord->x = ( (int) round( ftmp ) ) * grid_size.x;
|
|
|
|
|
|
|
|
ftmp = (double) coord->y / grid_size.y;
|
|
|
|
coord->y = ( (int) round( ftmp ) ) * grid_size.y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
double pasx = GetBaseScreen()->m_UserGrid.x * m_InternalUnits;
|
|
|
|
double pasy = GetBaseScreen()->m_UserGrid.y * m_InternalUnits;
|
|
|
|
|
|
|
|
if( GetBaseScreen()->m_UserGridUnit != INCHES )
|
2007-08-20 01:49:24 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
pasx /= 25.4;
|
2007-08-20 01:49:24 +00:00
|
|
|
pasy /= 25.4;
|
|
|
|
}
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2007-08-20 01:49:24 +00:00
|
|
|
int nn = (int) round( coord->x / pasx );
|
|
|
|
coord->x = (int) round( pasx * nn );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2007-08-20 01:49:24 +00:00
|
|
|
nn = (int) round( coord->y / pasy );
|
|
|
|
coord->y = (int) round( pasy * nn );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:49:24 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************/
|
2007-08-20 01:49:24 +00:00
|
|
|
void WinEDA_DrawFrame::Zoom_Automatique( bool move_mouse_cursor )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************/
|
2007-08-20 01:49:24 +00:00
|
|
|
|
2007-10-29 10:05:07 +00:00
|
|
|
/** Redraw the screen with the zoom level which shows all the page or the board
|
2007-08-20 01:49:24 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:49:24 +00:00
|
|
|
int bestzoom;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:49:24 +00:00
|
|
|
bestzoom = BestZoom();
|
2008-04-17 16:25:29 +00:00
|
|
|
GetBaseScreen()->SetZoom( bestzoom );
|
2007-08-20 01:49:24 +00:00
|
|
|
Recadre_Trace( move_mouse_cursor );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:49:24 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************/
|
2007-08-20 01:49:24 +00:00
|
|
|
void WinEDA_DrawFrame::Window_Zoom( EDA_Rect& Rect )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************/
|
2007-08-20 01:49:24 +00:00
|
|
|
|
2007-10-29 10:05:07 +00:00
|
|
|
/** Compute the zoom factor and the new draw offset to draw the
|
2007-08-20 01:49:24 +00:00
|
|
|
* selected area (Rect) in full window screen
|
2008-04-03 19:38:24 +00:00
|
|
|
* @param Rect = selected area to show after zooming
|
2007-08-20 01:49:24 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:49:24 +00:00
|
|
|
int ii, jj;
|
|
|
|
int bestzoom;
|
|
|
|
wxSize size;
|
|
|
|
|
|
|
|
/* Compute the best zoom */
|
|
|
|
Rect.Normalize();
|
|
|
|
size = DrawPanel->GetClientSize();
|
2008-04-03 19:38:24 +00:00
|
|
|
// Use ceil to at least show the full rect
|
2008-04-03 18:45:49 +00:00
|
|
|
ii = static_cast<int>( ceil(1.0 * Rect.GetSize().x / size.x) );
|
|
|
|
jj = static_cast<int>( ceil(1.0 * Rect.GetSize().y / size.y) );
|
2007-08-20 01:49:24 +00:00
|
|
|
bestzoom = MAX( ii, jj );
|
|
|
|
if( bestzoom <= 0 )
|
|
|
|
bestzoom = 1;
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
GetBaseScreen()->SetZoom( bestzoom );
|
2007-08-20 01:49:24 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
GetBaseScreen()->m_Curseur = Rect.Centre();
|
2007-08-20 01:49:24 +00:00
|
|
|
Recadre_Trace( TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:49:24 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************************/
|
2007-08-20 01:49:24 +00:00
|
|
|
void WinEDA_DrawPanel::Process_Popup_Zoom( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************************/
|
2007-08-20 01:49:24 +00:00
|
|
|
|
2007-10-29 10:05:07 +00:00
|
|
|
/* Handle only the Popup command zoom and grid level
|
2007-08-20 01:49:24 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:49:24 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
2008-02-17 21:19:13 +00:00
|
|
|
case ID_POPUP_ZOOM_IN:
|
|
|
|
case ID_POPUP_ZOOM_OUT:
|
2007-08-20 01:49:24 +00:00
|
|
|
case ID_POPUP_ZOOM_CENTER:
|
|
|
|
case ID_POPUP_ZOOM_AUTO:
|
|
|
|
case ID_POPUP_ZOOM_REDRAW:
|
|
|
|
m_Parent->OnZoom( id );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_SELECT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_CANCEL:
|
|
|
|
MouseToCursorSchema();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_LEVEL_1:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetZoom( 1 );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->Recadre_Trace( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_LEVEL_2:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetZoom( 2 );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->Recadre_Trace( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_LEVEL_4:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetZoom( 4 );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->Recadre_Trace( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_LEVEL_8:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetZoom( 8 );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->Recadre_Trace( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_LEVEL_16:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetZoom( 16 );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->Recadre_Trace( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_LEVEL_32:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetZoom( 32 );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->Recadre_Trace( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_LEVEL_64:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetZoom( 64 );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->Recadre_Trace( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_LEVEL_128:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetZoom( 128 );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->Recadre_Trace( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_LEVEL_256:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetZoom( 256 );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->Recadre_Trace( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_LEVEL_512:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetZoom( 512 );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->Recadre_Trace( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_LEVEL_1024:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetZoom( 1024 );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->Recadre_Trace( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_LEVEL_2048:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetZoom( 2048 );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->Recadre_Trace( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_GRID_LEVEL_1:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetGrid( wxSize( 1, 1 ) );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->ReDrawPanel();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_GRID_LEVEL_2:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetGrid( wxSize( 2, 2 ) );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->ReDrawPanel();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_GRID_LEVEL_5:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetGrid( wxSize( 5, 5 ) );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->ReDrawPanel();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_GRID_LEVEL_10:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetGrid( wxSize( 10, 10 ) );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->ReDrawPanel();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_GRID_LEVEL_20:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetGrid( wxSize( 20, 20 ) );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->ReDrawPanel();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_GRID_LEVEL_25:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetGrid( wxSize( 25, 25 ) );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->ReDrawPanel();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_GRID_LEVEL_50:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetGrid( wxSize( 50, 50 ) );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->ReDrawPanel();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_GRID_LEVEL_100:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetGrid( wxSize( 100, 100 ) );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->ReDrawPanel();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_GRID_LEVEL_200:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetGrid( wxSize( 200, 200 ) );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->ReDrawPanel();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_GRID_LEVEL_250:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetGrid( wxSize( 250, 250 ) );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->ReDrawPanel();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_GRID_LEVEL_500:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetGrid( wxSize( 500, 500 ) );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->ReDrawPanel();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_GRID_LEVEL_1000:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetGrid( wxSize( 1000, 1000 ) );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->ReDrawPanel();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_GRID_USER:
|
2008-04-17 16:25:29 +00:00
|
|
|
GetScreen()->SetGrid( wxSize( -1, -1 ) );
|
2007-08-20 01:49:24 +00:00
|
|
|
m_Parent->ReDrawPanel();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this, wxT( "WinEDA_DrawPanel::Process_Popup_Zoom() ID error" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Parent->Affiche_Status_Box();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:49:24 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
class grid_list_struct
|
|
|
|
{
|
|
|
|
public:
|
2007-08-27 08:07:44 +00:00
|
|
|
int m_Value;
|
|
|
|
int m_Id;
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************/
|
2007-08-20 01:49:24 +00:00
|
|
|
void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************************/
|
|
|
|
|
2007-08-20 01:49:24 +00:00
|
|
|
/* add the zoom list menu the the MasterMenu.
|
|
|
|
* used in OnRightClick(wxMouseEvent& event)
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:49:24 +00:00
|
|
|
int zoom;
|
|
|
|
wxSize grid;
|
|
|
|
int zoom_value;
|
|
|
|
wxString zoom_msg = _( "Zoom: " );
|
2007-08-27 08:07:44 +00:00
|
|
|
wxString grid_msg = _( "Grid: " ), msg;
|
2007-08-20 01:49:24 +00:00
|
|
|
int ii;
|
|
|
|
wxString line;
|
|
|
|
|
2007-08-22 05:11:01 +00:00
|
|
|
static const grid_list_struct grid_list_pcb[] =
|
2007-08-20 01:49:24 +00:00
|
|
|
{
|
2007-08-27 08:07:44 +00:00
|
|
|
{ 1000, ID_POPUP_GRID_LEVEL_1000 },
|
|
|
|
{ 500, ID_POPUP_GRID_LEVEL_500 },
|
|
|
|
{ 250, ID_POPUP_GRID_LEVEL_250 },
|
|
|
|
{ 200, ID_POPUP_GRID_LEVEL_200 },
|
|
|
|
{ 100, ID_POPUP_GRID_LEVEL_100 },
|
|
|
|
{ 50, ID_POPUP_GRID_LEVEL_50 },
|
|
|
|
{ 25, ID_POPUP_GRID_LEVEL_25 },
|
|
|
|
{ 20, ID_POPUP_GRID_LEVEL_20 },
|
|
|
|
{ 10, ID_POPUP_GRID_LEVEL_10 },
|
|
|
|
{ 5, ID_POPUP_GRID_LEVEL_5 },
|
|
|
|
{ 2, ID_POPUP_GRID_LEVEL_2 },
|
|
|
|
{ 1, ID_POPUP_GRID_LEVEL_1 },
|
|
|
|
{ 0, ID_POPUP_GRID_USER }
|
2007-08-20 01:49:24 +00:00
|
|
|
};
|
|
|
|
|
2007-08-22 05:11:01 +00:00
|
|
|
static const grid_list_struct grid_list_schematic[] =
|
2007-08-20 01:49:24 +00:00
|
|
|
{
|
2007-08-27 08:07:44 +00:00
|
|
|
{ 50, ID_POPUP_GRID_LEVEL_50 },
|
|
|
|
{ 25, ID_POPUP_GRID_LEVEL_25 },
|
|
|
|
{ 10, ID_POPUP_GRID_LEVEL_10 },
|
|
|
|
{ 5, ID_POPUP_GRID_LEVEL_5 },
|
|
|
|
{ 2, ID_POPUP_GRID_LEVEL_2 },
|
|
|
|
{ 1, ID_POPUP_GRID_LEVEL_1 },
|
|
|
|
{ 0, ID_POPUP_GRID_USER }
|
2007-08-20 01:49:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ADD_MENUITEM( MasterMenu, ID_POPUP_ZOOM_CENTER, _( "Center" ), zoom_center_xpm );
|
2008-02-17 21:19:13 +00:00
|
|
|
ADD_MENUITEM( MasterMenu, ID_POPUP_ZOOM_IN, _( "Zoom in" ), zoom_in_xpm );
|
|
|
|
ADD_MENUITEM( MasterMenu, ID_POPUP_ZOOM_OUT, _( "Zoom out" ), zoom_out_xpm );
|
2007-08-20 01:49:24 +00:00
|
|
|
|
|
|
|
wxMenu* zoom_choice = new wxMenu;
|
|
|
|
ADD_MENUITEM_WITH_SUBMENU( MasterMenu, zoom_choice,
|
|
|
|
ID_POPUP_ZOOM_SELECT, _( "Zoom Select" ), zoom_select_xpm );
|
|
|
|
|
|
|
|
ADD_MENUITEM( MasterMenu, ID_POPUP_ZOOM_AUTO, _( "Auto" ), zoom_optimal_xpm );
|
|
|
|
ADD_MENUITEM( MasterMenu, ID_POPUP_ZOOM_REDRAW, _( "Redraw" ), repaint_xpm );
|
|
|
|
|
|
|
|
/* Create the basic zoom list: */
|
2008-04-17 16:25:29 +00:00
|
|
|
zoom = GetScreen()->GetZoom();
|
2007-08-20 01:49:24 +00:00
|
|
|
zoom_value = 1;
|
|
|
|
for( ii = 0; zoom_value <= m_Parent->m_ZoomMaxValue; zoom_value <<= 1, ii++ ) // Create zoom choice 1 .. zoom max
|
|
|
|
{
|
|
|
|
line.Printf( wxT( "%u" ), zoom_value );
|
|
|
|
zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_1 + ii,
|
|
|
|
zoom_msg + line, wxEmptyString, TRUE );
|
|
|
|
if( zoom == zoom_value )
|
|
|
|
zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_1 + ii, TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxMenu* grid_choice = new wxMenu;
|
|
|
|
ADD_MENUITEM_WITH_SUBMENU( MasterMenu, grid_choice,
|
|
|
|
ID_POPUP_GRID_SELECT, _( "Grid Select" ), grid_select_xpm );
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
grid = GetScreen()->GetGrid();
|
2007-08-20 01:49:24 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
// Create grid list
|
2007-08-20 01:49:24 +00:00
|
|
|
switch( m_Parent->m_Ident )
|
|
|
|
{
|
|
|
|
case MODULE_EDITOR_FRAME:
|
|
|
|
case GERBER_FRAME:
|
|
|
|
case PCB_FRAME:
|
|
|
|
case CVPCB_DISPLAY_FRAME:
|
2007-08-27 08:07:44 +00:00
|
|
|
for( ii = 0; ; ii++ )
|
2007-08-20 01:49:24 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
if ( grid_list_pcb[ii].m_Value )
|
|
|
|
{
|
|
|
|
double grid_value = To_User_Unit(g_UnitMetric, grid_list_pcb[ii].m_Value,
|
|
|
|
((WinEDA_DrawFrame*)m_Parent)->m_InternalUnits);
|
|
|
|
if ( g_UnitMetric == 0) // inches
|
|
|
|
line.Printf(wxT("%g mils"), grid_value*1000);
|
|
|
|
else
|
|
|
|
line.Printf(wxT("%g mm"), grid_value);
|
|
|
|
}
|
|
|
|
else line = _("grid user");
|
2007-08-27 08:07:44 +00:00
|
|
|
msg = grid_msg + line;
|
|
|
|
grid_choice->Append( grid_list_pcb[ii].m_Id, msg, wxEmptyString, TRUE );
|
|
|
|
if( grid_list_pcb[ii].m_Value <= 0 )
|
2007-08-20 01:49:24 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
if( GetScreen()->m_UserGridIsON )
|
2007-08-27 08:07:44 +00:00
|
|
|
grid_choice->Check( grid_list_pcb[ii].m_Id, TRUE );
|
2007-08-20 01:49:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-08-27 08:07:44 +00:00
|
|
|
if( grid.x == grid_list_pcb[ii].m_Value )
|
|
|
|
grid_choice->Check( grid_list_pcb[ii].m_Id, TRUE );
|
2007-08-20 01:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCHEMATIC_FRAME:
|
|
|
|
case LIBEDITOR_FRAME:
|
2007-08-27 08:07:44 +00:00
|
|
|
for( ii = 0; ; ii++ )
|
2007-08-20 01:49:24 +00:00
|
|
|
{
|
2007-08-27 08:07:44 +00:00
|
|
|
if( grid_list_schematic[ii].m_Value <= 0 )
|
2007-08-20 01:49:24 +00:00
|
|
|
break;
|
2008-04-17 16:25:29 +00:00
|
|
|
double grid_value = To_User_Unit(g_UnitMetric, grid_list_schematic[ii].m_Value,
|
|
|
|
((WinEDA_DrawFrame*)m_Parent)->m_InternalUnits);
|
|
|
|
if ( g_UnitMetric == 0) // inches
|
|
|
|
line.Printf(wxT("%g mils"), grid_value*1000);
|
|
|
|
else
|
|
|
|
line.Printf(wxT("%g mm"), grid_value);
|
2007-08-27 08:07:44 +00:00
|
|
|
|
|
|
|
msg = grid_msg + line;
|
|
|
|
grid_choice->Append( grid_list_schematic[ii].m_Id,
|
2007-08-20 01:49:24 +00:00
|
|
|
msg, wxEmptyString, TRUE );
|
2007-08-27 08:07:44 +00:00
|
|
|
if( grid.x == grid_list_schematic[ii].m_Value )
|
|
|
|
grid_choice->Check( grid_list_schematic[ii].m_Id, TRUE );
|
2007-08-20 01:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_FRAME:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
MasterMenu->AppendSeparator();
|
|
|
|
ADD_MENUITEM( MasterMenu, ID_POPUP_CANCEL, _( "Close" ), cancel_xpm );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
2007-08-20 01:49:24 +00:00
|
|
|
void WinEDA_DrawFrame::Process_Zoom( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************/
|
2007-08-20 01:49:24 +00:00
|
|
|
|
2007-10-29 10:05:07 +00:00
|
|
|
/* Handle the Zoom commands from the zoom tools in the main toolbar.
|
|
|
|
* Calls the active window Zoom function
|
2007-08-20 01:49:24 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:49:24 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
2008-02-17 21:19:13 +00:00
|
|
|
case ID_ZOOM_IN_BUTT:
|
|
|
|
case ID_ZOOM_OUT_BUTT:
|
2007-08-20 01:49:24 +00:00
|
|
|
case ID_ZOOM_REDRAW_BUTT:
|
|
|
|
case ID_ZOOM_PAGE_BUTT:
|
|
|
|
OnZoom( id );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this, wxT( "WinEDA_DrawFrame::Process_Zoom id Error" ) );
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|