Commit 2e5a57e1 authored by stambaughw's avatar stambaughw

New zoom implementation and some build optimizations.

parent f1a37af8
......@@ -5,6 +5,15 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2009-Jan-29 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++All
* Replace zoom implementation with a more flexible ( and hopefully useful )
design.
* Removed gr_basic.h from fctsys.h so that the entire project doesn't get
rebuilt unnecessarily.
2009-Jan-29 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++eeschema
......
......@@ -25,14 +25,14 @@ WX_DEFINE_OBJARRAY( GridArray );
BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType )
{
EEDrawList = NULL; /* Schematic items list */
m_ZoomList = NULL;
m_UndoList = NULL;
m_RedoList = NULL;
m_UndoRedoCountMax = 1;
m_FirstRedraw = TRUE;
m_ScreenNumber = 1;
m_NumberOfScreen = 1; /* Hierarchy: Root: ScreenNumber = 1 */
m_Zoom = 32;
m_ZoomScalar = 10;
m_Zoom = 32 * m_ZoomScalar;
m_Grid = wxSize( 50, 50 ); /* Default grid size */
m_UserGridIsON = FALSE;
m_Diviseur_Grille = 1;
......@@ -47,9 +47,6 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType )
BASE_SCREEN::~BASE_SCREEN()
/******************************/
{
if( m_ZoomList )
free( m_ZoomList );
ClearUndoRedoList();
}
......@@ -101,131 +98,174 @@ wxSize BASE_SCREEN::ReturnPageSize( void )
{
int internal_units = GetInternalUnits();
return wxSize( m_CurrentSheetDesc->m_Size.x * (internal_units / 1000),
m_CurrentSheetDesc->m_Size.y * (internal_units / 1000) );
return wxSize( ( m_CurrentSheetDesc->m_Size.x * internal_units ) / 1000,
( m_CurrentSheetDesc->m_Size.y * internal_units ) / 1000 );
}
/******************************************************************/
wxPoint BASE_SCREEN::CursorRealPosition( const wxPoint& ScreenPos )
/******************************************************************/
{
wxPoint curpos;
wxPoint curpos = ScreenPos;
Unscale( curpos );
// D(printf("curpos=%d,%d GetZoom=%d, mDrawOrg=%d,%d\n", curpos.x, curpos.y, GetZoom(), m_DrawOrg.x, m_DrawOrg.y );)
curpos.x = ScreenPos.x * GetZoom();
curpos.y = ScreenPos.y * GetZoom();
// curpos.x = Unscale( ScreenPos.x );
// curpos.y = Unscale( ScreenPos.y );
curpos.x += m_DrawOrg.x;
curpos.y += m_DrawOrg.y;
curpos += m_DrawOrg;
return curpos;
}
/**
* Calculate coordinate value for zooming.
*
* Call this method when drawing on the device context. It scales the
* coordinate using the current zoom settings. Zooming in Kicad occurs
* by actually scaling the entire drawing using the zoom setting.
*
* FIXME: We should probably use wxCoord instead of int here but that would
* require using wxCoord in all of the other code that makes device
* context calls as well.
*/
int BASE_SCREEN::Scale( int coord )
{
#ifdef WX_ZOOM
return coord;
#else
if( !m_Zoom )
return 0;
/**************************************************/
void BASE_SCREEN::SetZoomList( const int* zoomlist )
/**************************************************/
if( !m_ZoomScalar || !m_Zoom )
return 0;
/* init liste des zoom (NULL terminated)
return wxRound( (double) ( coord * m_ZoomScalar ) / (double) m_Zoom );
#endif
}
void BASE_SCREEN::Scale( wxPoint& pt )
{
pt.x = Scale( pt.x );
pt.y = Scale( pt.y );
}
void BASE_SCREEN::Scale( wxSize& sz )
{
sz.SetHeight( Scale( sz.GetHeight() ) );
sz.SetWidth( Scale( sz.GetWidth() ) );
}
/**
* Calculate the physical (unzoomed) location of a coordinate.
*
* Call this method when you want to find the unzoomed (physical) location
* of a coordinate on the drawing.
*/
int BASE_SCREEN::Unscale( int coord )
{
int nbitems;
const int* zoom;
#ifdef WX_ZOOM
return coord;
#else
if( !m_Zoom || !m_ZoomScalar )
return 0;
// get list length
for( nbitems = 1, zoom = zoomlist; ; zoom++, nbitems++ )
{
if( *zoom == 0 )
break;
}
return wxRound( (double) ( coord * m_Zoom ) / (double) m_ZoomScalar );
#endif
}
// resize our list
if( m_ZoomList )
free( m_ZoomList );
void BASE_SCREEN::Unscale( wxPoint& pt )
{
pt.x = Unscale( pt.x );
pt.y = Unscale( pt.y );
}
m_ZoomList = (int*) MyZMalloc( nbitems * sizeof(int) );
int ii;
for( ii = 0, zoom = zoomlist; ii < nbitems; zoom++, ii++ )
{
m_ZoomList[ii] = *zoom;
}
void BASE_SCREEN::Unscale( wxSize& sz )
{
sz.SetHeight( Unscale( sz.GetHeight() ) );
sz.SetWidth( Unscale( sz.GetWidth() ) );
}
void BASE_SCREEN::SetZoomList( const wxArrayInt& zoomlist )
{
if( !m_ZoomList.IsEmpty() )
m_ZoomList.Empty();
m_ZoomList = zoomlist;
}
/***********************************/
void BASE_SCREEN::SetFirstZoom()
/***********************************/
{
m_Zoom = 1;
if( m_ZoomList.IsEmpty() )
m_Zoom = m_ZoomScalar;
else
m_Zoom = m_ZoomList[0];
}
/******************************/
int BASE_SCREEN::GetZoom() const
/******************************/
{
return m_Zoom;
}
/***********************************/
void BASE_SCREEN::SetZoom( int coeff )
/***********************************/
{
m_Zoom = coeff;
if( m_Zoom < 1 )
m_Zoom = 1;
}
/********************************/
void BASE_SCREEN::SetNextZoom()
/********************************/
/* Selectionne le prochain coeff de zoom
*/
{
m_Zoom *= 2;
size_t i;
if( m_ZoomList == NULL )
if( m_ZoomList.IsEmpty() || m_Zoom >= m_ZoomList.Last() )
return;
int ii, zoom_max = 512;
for( ii = 0; m_ZoomList[ii] != 0; ii++ )
zoom_max = m_ZoomList[ii];
if( m_Zoom > zoom_max )
m_Zoom = zoom_max;
for( i = 0; i < m_ZoomList.GetCount(); i++ )
{
if( m_Zoom < m_ZoomList[i] )
{
m_Zoom = m_ZoomList[i];
break;
}
}
}
/*************************************/
void BASE_SCREEN::SetPreviousZoom()
/*************************************/
/* Selectionne le precedent coeff de zoom
*/
{
m_Zoom /= 2;
if( m_Zoom < 1 )
m_Zoom = 1;
size_t i;
if( m_ZoomList.IsEmpty() || m_Zoom <= m_ZoomList[0] )
return;
for( i = m_ZoomList.GetCount(); i != 0; i-- )
{
if( m_Zoom > m_ZoomList[i - 1] )
{
m_Zoom = m_ZoomList[i - 1];
break;
}
}
}
/**********************************/
void BASE_SCREEN::SetLastZoom()
/**********************************/
/* ajuste le coeff de zoom au max
*/
{
if( m_ZoomList == NULL )
if( m_ZoomList.IsEmpty() )
return;
int ii;
for( ii = 0; m_ZoomList[ii] != 0; ii++ )
m_Zoom = m_ZoomList[ii];
m_Zoom = m_ZoomList.Last();
}
......
......@@ -7,6 +7,7 @@
/* Fichier base_struct.cpp */
#include "fctsys.h"
#include "gr_basic.h"
#include "trigo.h"
#include "common.h"
#include "wxstruct.h"
......@@ -272,10 +273,8 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
* @param EDA_Colors aAnchor_color = anchor color ( UNSPECIFIED_COLOR = do not draw anchor ).
*/
{
int zoom;
int width;
zoom = aPanel->GetZoom();
width = m_Width;
if( aDisplayMode == FILAIRE )
width = 0;
......@@ -286,7 +285,7 @@ void EDA_TextStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
/* Draw text anchor, if allowed */
if( aAnchor_color != UNSPECIFIED_COLOR )
{
int anchor_size = 2 * zoom;
int anchor_size = aPanel->GetScreen()->Unscale( 2 );
aAnchor_color = (EDA_Colors) (aAnchor_color & MASKCOLOR);
int cX = m_Pos.x + aOffset.x;
......
......@@ -209,6 +209,7 @@ wxString WinEDA_BasicFrame::GetFileFromHistory( int cmdId,
void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event )
/**************************************************************/
{
wxString msg;
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
if( wxGetApp().m_HtmlCtrl == NULL )
{
......@@ -223,19 +224,28 @@ void WinEDA_BasicFrame::GetKicadHelp( wxCommandEvent& event )
}
else
{
wxString msg;
msg.Printf( _( "Help file %s not found" ), wxGetApp().m_HelpFileName.GetData() );
DisplayError( this, msg );
}
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
wxString fullfilename = FindKicadHelpPath() + wxGetApp().m_HelpFileName;
if ( wxFileExists(fullfilename) )
GetAssociatedDocument( this, wxEmptyString, fullfilename );
else // Try to find file in English format:
// wxString fullfilename = FindKicadHelpPath() + wxGetApp().m_HelpFileName;
// if ( wxFileExists(fullfilename) )
// GetAssociatedDocument( this, wxEmptyString, fullfilename );
// else // Try to find file in English format:
// {
// fullfilename = FindKicadHelpPath() + wxT("../en/") + wxGetApp().m_HelpFileName;;
// GetAssociatedDocument( this, wxEmptyString, fullfilename );
// }
wxString helpFile = wxGetApp().GetHelpFile();
if( !helpFile )
{
fullfilename = FindKicadHelpPath() + wxT("../en/") + wxGetApp().m_HelpFileName;;
GetAssociatedDocument( this, wxEmptyString, fullfilename );
msg.Printf( _( "Help file %s could not be found." ),
wxGetApp().m_HelpFileName.c_str() );
DisplayError( this, msg );
}
else
GetAssociatedDocument( this, wxEmptyString, helpFile );
#else
#error Help files format not defined
......
......@@ -110,8 +110,8 @@ void DrawBlockStruct::SetMessageBlock( WinEDA_DrawFrame* frame )
void DrawBlockStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC )
/**************************************************************/
{
int w = GetWidth() / panel->GetZoom();
int h = GetHeight() / panel->GetZoom();
int w = panel->GetScreen()->Scale( GetWidth() );
int h = panel->GetScreen()->Scale( GetHeight() );
if( w == 0 || h == 0 )
GRLine( &panel->m_ClipBox, DC, GetX(), GetY(),
......@@ -133,8 +133,8 @@ bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key,
{
DrawBlockStruct* Block = & GetBaseScreen()->BlockLocate;
if( (Block->m_Command != BLOCK_IDLE)
|| ( Block->m_State != STATE_NO_BLOCK) )
if( ( Block->m_Command != BLOCK_IDLE )
|| ( Block->m_State != STATE_NO_BLOCK ) )
return FALSE;
Block->m_Flags = 0;
......
......@@ -5,21 +5,9 @@
// Created: 18 aug 2006
// Licence: License GNU
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include <ctype.h>
#include "wx/metafile.h"
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "id.h"
......
......@@ -7,6 +7,7 @@
#endif
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "bitmaps.h"
#include "macros.h"
......@@ -42,7 +43,6 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
m_AuxiliaryToolBar = NULL;
m_SelGridBox = NULL;
m_SelZoomBox = NULL;
m_ZoomMaxValue = 128;
DrawPanel = NULL;
MsgPanel = NULL;
......@@ -56,12 +56,11 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
m_Draw_Auxiliary_Axis = FALSE; // TRUE pour avoir les axes auxiliares dessines
m_UnitType = INTERNAL_UNIT_TYPE; // Internal unit = inch
// Internal units per inch
// = 1000 for schema, = 10000 for PCB
// Internal units per inch: = 1000 for schema, = 10000 for PCB
m_InternalUnits = EESCHEMA_INTERNAL_UNIT;
minsize.x = 470;
minsize.y = 350 + m_MsgFrameHeight;
SetSizeHints( minsize.x, minsize.y, -1, -1, -1, -1 );
/* Verification des parametres de creation */
......@@ -267,42 +266,37 @@ void WinEDA_DrawFrame::OnSelectGrid( wxCommandEvent& event )
}
/********************************************************/
void WinEDA_DrawFrame::OnSelectZoom( wxCommandEvent& event ) // fonction virtuelle
/********************************************************/
/* Set the zoom when selected by the Zoom List Box
/**
* Set the zoom when selected by the Zoom List Box
* Note:
* position 0 = Fit in Page
* position >= 1 = zoom (1 to zoom max)
* last position : special zoom
* virtual function
*/
void WinEDA_DrawFrame::OnSelectZoom( wxCommandEvent& event )
{
if( m_SelZoomBox == NULL )
return; //Ne devrait pas se produire!
int id = m_SelZoomBox->GetChoice();
if( id < 0 )
return; // No selection
if( id < 0 || !( id < (int)m_SelZoomBox->GetCount() ) )
return;
if( id == 0 ) // Auto zoom (Fit in Page)
{
Zoom_Automatique( TRUE );
Zoom_Automatique( true );
}
else if( id == (int) (m_SelZoomBox->GetCount() - 1) ) // Dummy position: unlisted zoom
return;
else // zooml 1 to zoom max
else
{
id--;
int zoom = 1 << id;
if( zoom > m_ZoomMaxValue )
zoom = m_ZoomMaxValue;
if( GetBaseScreen()->GetZoom() == zoom )
int selectedZoom = GetBaseScreen()->m_ZoomList[id];
if( GetBaseScreen()->GetZoom() == selectedZoom )
return;
GetBaseScreen()->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
GetBaseScreen()->SetZoom( zoom );
Recadre_Trace( FALSE );
GetBaseScreen()->SetZoom( selectedZoom );
Recadre_Trace( false );
}
}
......@@ -569,15 +563,12 @@ int WinEDA_DrawFrame::HandleBlockEnd( wxDC* DC )
void WinEDA_DrawFrame::AdjustScrollBars()
/*********************************************/
{
int xUnit, yUnit;
wxSize draw_size, panel_size;
wxSize scrollbar_number;
wxPoint scrollbar_pos;
BASE_SCREEN* screen = GetBaseScreen();
int zoom = screen->GetZoom();
int xUnit, yUnit;
if( screen == NULL || DrawPanel == NULL )
return;
......@@ -586,7 +577,8 @@ void WinEDA_DrawFrame::AdjustScrollBars()
// On utilise le centre de l'ecran comme position de reference, donc
// la surface de trace doit etre augmentee
panel_size = DrawPanel->GetClientSize() * zoom;
panel_size = DrawPanel->GetClientSize();
screen->Unscale( panel_size );
draw_size += panel_size / 2;
......@@ -606,20 +598,18 @@ void WinEDA_DrawFrame::AdjustScrollBars()
screen->m_DrawOrg.y -= screen->m_DrawOrg.y % 256;
// Calcul du nombre de scrolls (en unites de scrool )
scrollbar_number = draw_size / (DrawPanel->m_Scroll_unit * zoom);
xUnit = yUnit = DrawPanel->m_Scroll_unit;
scrollbar_number = draw_size / screen->Unscale( screen->m_ZoomScalar );
xUnit = yUnit = screen->m_ZoomScalar;
if( xUnit <= 1 )
xUnit = 1;
if( yUnit <= 1 )
yUnit = 1;
xUnit *= zoom;
yUnit *= zoom;
xUnit = screen->Unscale( xUnit );
yUnit = screen->Unscale( yUnit );
// Calcul de la position, curseur place au centre d'ecran
scrollbar_pos = screen->m_Curseur;
scrollbar_pos -= screen->m_DrawOrg;
scrollbar_pos = screen->m_Curseur - screen->m_DrawOrg;
scrollbar_pos.x -= panel_size.x / 2;
scrollbar_pos.y -= panel_size.y / 2;
......@@ -634,8 +624,8 @@ void WinEDA_DrawFrame::AdjustScrollBars()
screen->m_ScrollbarPos = scrollbar_pos;
screen->m_ScrollbarNumber = scrollbar_number;
DrawPanel->SetScrollbars( DrawPanel->m_Scroll_unit,
DrawPanel->m_Scroll_unit,
DrawPanel->SetScrollbars( screen->m_ZoomScalar,
screen->m_ZoomScalar,
screen->m_ScrollbarNumber.x,
screen->m_ScrollbarNumber.y,
screen->m_ScrollbarPos.x,
......
......@@ -2,6 +2,7 @@
/* drawpanel.cpp - WinEDA_DrawPanel class */
/******************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "macros.h"
......@@ -48,7 +49,6 @@ WinEDA_DrawPanel::WinEDA_DrawPanel( WinEDA_DrawFrame* parent, int id,
wxBORDER | wxNO_FULL_REPAINT_ON_RESIZE )
{
m_Parent = parent;
m_Scroll_unit = 1;
m_ScrollButt_unit = 40;
SetBackgroundColour( wxColour( ColorRefs[g_DrawBgColor].m_Red,
......@@ -89,13 +89,12 @@ BASE_SCREEN* WinEDA_DrawPanel::GetScreen()
}
/*********************************************************************************/
void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color )
/*********************************************************************************/
/*
/*****************************************************************************
*
* Draw the schematic cursor which is usually on grid
*/
*
*****************************************************************************/
void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color )
{
if( m_CursorLevel != 0 || DC == NULL )
return;
......@@ -105,9 +104,8 @@ void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color )
GRSetDrawMode( DC, GR_XOR );
if( g_CursorShape == 1 ) /* Trace d'un reticule */
{
int dx = m_ClipBox.GetWidth() * GetZoom();
int dy = m_ClipBox.GetHeight() * GetZoom();
int dx = GetScreen()->Unscale( m_ClipBox.GetWidth() );
int dy = GetScreen()->Unscale( m_ClipBox.GetHeight() );
GRLine( &m_ClipBox, DC, Cursor.x - dx, Cursor.y,
Cursor.x + dx, Cursor.y, 0, color ); // axe Y
......@@ -116,7 +114,7 @@ void WinEDA_DrawPanel::Trace_Curseur( wxDC* DC, int color )
}
else
{
int len = CURSOR_SIZE * GetZoom();
int len = GetScreen()->Unscale( CURSOR_SIZE );
GRLine( &m_ClipBox, DC, Cursor.x - len, Cursor.y,
Cursor.x + len, Cursor.y, 0, color );
......@@ -186,11 +184,9 @@ void WinEDA_DrawPanel::PrepareGraphicContext( wxDC* DC )
GRResetPenAndBrush( DC );
DC->SetBackgroundMode( wxTRANSPARENT );
#ifdef WX_ZOOM
int zoom = GetZoom();
double f_scale = 1.0 / (double) zoom;
DC->SetUserScale( f_scale, f_scale );
PrepareDC( *DC );
double scale = 1.0 / (double) GetZoom();
DC->SetUserScale( scale, scale );
DoPrepareDC( *DC );
#endif
SetBoundaryBox();
}
......@@ -233,16 +229,10 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
// Conversion en coord physiques
pos = CalcUnscrolledPosition( display_rect.GetPosition() );
pos.x *= GetZoom();
pos.y *= GetZoom();
GetScreen()->Unscale( pos );
pos += GetScreen()->m_DrawOrg;
display_rect.SetX( pos.x );
display_rect.SetY( pos.y );
display_rect.SetWidth( display_rect.GetWidth() * GetZoom() );
display_rect.SetHeight( display_rect.GetHeight() * GetZoom() );
display_rect.m_Pos = pos;
GetScreen()->Unscale( display_rect.m_Size );
return display_rect.Inside( ref_pos );
}
......@@ -277,11 +267,8 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( EDA_Rect* aRect )
wxPoint pos = aRect->GetPosition();
ConvertPcbUnitsToPixelsUnits( &pos );
aRect->SetOrigin( pos ); // rect origin in pixel units
aRect->m_Size.x /= GetZoom();
aRect->m_Size.y /= GetZoom(); // size in pixel units
GetScreen()->Scale( aRect->m_Size );
}
......@@ -302,8 +289,7 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition )
drwOrig.y *= y_axis_scale;
// Origin in internal units
drwOrig.x *= GetZoom();
drwOrig.y *= GetZoom();
GetScreen()->Unscale( drwOrig );
// Real origin, according to the "plot" origin
drwOrig += GetScreen()->m_DrawOrg;
......@@ -312,8 +298,7 @@ void WinEDA_DrawPanel::ConvertPcbUnitsToPixelsUnits( wxPoint* aPosition )
*aPosition -= drwOrig;
// position in pixels, relative to the visible draw area origin
aPosition->x /= GetZoom();
aPosition->y /= GetZoom();
GetScreen()->Scale( *aPosition );
}
......@@ -325,14 +310,10 @@ wxPoint WinEDA_DrawPanel::CursorScreenPosition()
* @return the curseur position in pixels in the panel draw area on screen )
*/
{
wxPoint curpos = GetScreen()->m_Curseur;
curpos -= GetScreen()->m_DrawOrg;
curpos.x /= GetZoom();
curpos.y /= GetZoom();
return curpos;
wxPoint pos = GetScreen()->m_Curseur;
pos -= GetScreen()->m_DrawOrg;
GetScreen()->Scale( pos );
return pos;
}
......@@ -350,9 +331,7 @@ wxPoint WinEDA_DrawPanel::GetScreenCenterRealPosition( void )
size = GetClientSize() / 2;
realpos = CalcUnscrolledPosition( wxPoint( size.x, size.y ) );
realpos.x *= GetZoom();
realpos.y *= GetZoom();
GetScreen()->Unscale( realpos );
realpos += GetScreen()->m_DrawOrg;
return realpos;
......@@ -381,7 +360,6 @@ void WinEDA_DrawPanel::MouseTo( const wxPoint& Mouse )
*/
{
wxPoint mouse;
#ifdef WX_ZOOM
CalcScrolledPosition( Mouse.x, Mouse.y, &mouse.x, &mouse.y );
#else
......@@ -483,9 +461,7 @@ void WinEDA_DrawPanel::SetBoundaryBox()
wxPoint org;
int ii, jj;
Screen->m_SizeVisu = GetClientSize();
GetViewStart( &org.x, &org.y );
GetScrollPixelsPerUnit( &ii, &jj );
org.x *= ii;
org.y *= jj;
......@@ -496,9 +472,8 @@ void WinEDA_DrawPanel::SetBoundaryBox()
m_ClipBox.SetSize( GetClientSize() );
#ifdef WX_ZOOM
m_ClipBox.m_Pos.x *= GetZoom();
m_ClipBox.m_Pos.y *= GetZoom();
m_ClipBox.m_Size *= GetZoom();
CalcUnscrolledPosition( m_ClipBox.m_Pos.x, m_ClipBox.m_Pos.y,
&m_ClipBox.m_Pos.x, &m_ClipBox.m_Pos.y );
#else
m_ClipBox.m_Pos -= GetScreen()->m_StartVisu;
#endif
......@@ -569,14 +544,12 @@ void WinEDA_DrawPanel::OnPaint( wxPaintEvent& event )
);
#endif
PaintClipBox.x += org.x;
PaintClipBox.y += org.y;
PaintClipBox.Offset( org );
#ifdef WX_ZOOM
m_ClipBox.m_Pos.x = PaintClipBox.x * GetZoom();
m_ClipBox.m_Pos.y = PaintClipBox.y * GetZoom();
m_ClipBox.m_Size.x = PaintClipBox.width * GetZoom();
m_ClipBox.m_Size.y = PaintClipBox.height * GetZoom();
BASE_SCREEN* screen = GetScreen();
screen->Unscale( m_ClipBox.m_Pos );
screen->Unscale( m_ClipBox.m_Size );
#else
m_ClipBox.SetX( PaintClipBox.GetX() );
m_ClipBox.SetY( PaintClipBox.GetY() );
......@@ -636,9 +609,8 @@ void WinEDA_DrawPanel::ReDraw( wxDC* DC, bool erasebg )
}
#ifdef WX_ZOOM
int zoom = GetZoom();
double f_scale = 1.0 / (double) zoom;
DC->SetUserScale( f_scale, f_scale );
double scale = 1.0 / (double) GetZoom();
DC->SetUserScale( scale, scale );
#endif
if( erasebg )
......@@ -675,7 +647,6 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
int ii, jj, xg, yg, color;
wxSize pas_grille_affichee;
bool drawgrid = FALSE;
int zoom = GetZoom();
wxSize size;
wxPoint org;
double pasx, pasy;
......@@ -691,7 +662,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
pas_grille_affichee = screen->GetGrid();
ii = pas_grille_affichee.x / zoom;
ii = screen->Scale( pas_grille_affichee.x );
if( ii < 5 )
{
pas_grille_affichee.x *= 2;
......@@ -700,7 +671,7 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
if( ii < 5 )
drawgrid = FALSE; // The gris is small
ii = pas_grille_affichee.y / zoom;
ii = screen->Scale( pas_grille_affichee.y );
if( ii < 5 )
{
pas_grille_affichee.y *= 2;
......@@ -711,18 +682,18 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
GetViewStart( &org.x, &org.y );
GetScrollPixelsPerUnit( &ii, &jj );
wxLogDebug( _T( "View start: %d, %d, scroll bar PPI: %d, %d" ),
org.x, org.y, ii, jj );
org.x *= ii;
org.y *= jj;
screen->m_StartVisu = org;
org.x *= zoom;
org.y *= zoom;
wxLogDebug( _T( "Scroll bar drawing position: %d. %d" ), org.x, org.y );
screen->Unscale( org );
org += screen->m_DrawOrg;
size = GetClientSize() * zoom;
size = GetClientSize();
screen->Unscale( size );
pasx = screen->m_Grid.x * m_Parent->m_InternalUnits;
pasy = screen->m_Grid.y * m_Parent->m_InternalUnits;
......@@ -1139,8 +1110,8 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
*/
#define BLOCK_MINSIZE_LIMIT 1
bool BlockIsSmall =
( ABS( screen->BlockLocate.GetWidth() / GetZoom() ) < BLOCK_MINSIZE_LIMIT)
&& ( ABS( screen->BlockLocate.GetHeight() / GetZoom() ) < BLOCK_MINSIZE_LIMIT);
( ABS( screen->Scale( screen->BlockLocate.GetWidth() ) ) < BLOCK_MINSIZE_LIMIT)
&& ( ABS( screen->Scale( screen->BlockLocate.GetHeight() ) ) < BLOCK_MINSIZE_LIMIT);
if( (screen->BlockLocate.m_State != STATE_NO_BLOCK) && BlockIsSmall )
{
......
......@@ -51,7 +51,6 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, wxDC* DC,
{
int ii, kk, char_count, AsciiCode, endcar;
int x0, y0;
int zoom;
int size_h, size_v, pitch;
SH_CODE f_cod, plume = 'U';
const SH_CODE* ptcar;
......@@ -63,11 +62,6 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, wxDC* DC,
bool sketch_mode = false;
bool italic_reverse = false; // true for mirrored texts with m_Size.x < 0
if ( aPanel )
zoom = aPanel->GetZoom();
else
zoom = 1;
size_h = aSize.x;
size_v = aSize.y;
......@@ -101,7 +95,7 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, wxDC* DC,
{
int xm, ym, ll, xc, yc;
int textsize = ABS( pitch );
ll = (textsize * char_count) / zoom;
ll = aPanel->GetScreen()->Scale( textsize * char_count );
xc = GRMapX( cX );
yc = GRMapY( cY );
......@@ -195,10 +189,10 @@ void DrawGraphicText( WinEDA_DrawPanel* aPanel, wxDC* DC,
ox = cX - dx;
oy = cY + dy;
if( (aSize.x / zoom) == 0 )
if( aPanel->GetScreen()->Scale( aSize.x ) == 0 )
return;
if( ABS( (aSize.x / zoom) ) < 3 ) /* shapes are too small: connot be drawn */
if( ABS( (aPanel->GetScreen()->Scale( aSize.x ) ) ) < 3 ) /* shapes are too small: connot be drawn */
{ /* insteed the text is drawn as a line */
dx = (pitch * char_count) / 2;
dy = size_v / 2; /* line is always centered */
......
......@@ -15,6 +15,7 @@
#endif
#include "fctsys.h"
#include "gr_basic.h"
#include "wx/html/htmlwin.h"
#include "wx/fs_zip.h"
#include <wx/dir.h>
......@@ -221,8 +222,8 @@ WinEDA_App::WinEDA_App()
m_EDA_Config = NULL;
m_Env_Defined = FALSE;
m_LanguageId = wxLANGUAGE_DEFAULT;
m_Locale = NULL;
m_PdfBrowserIsDefault = TRUE;
m_Locale = NULL;
}
......@@ -317,6 +318,7 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
// Analyse the command line & init binary path
SetBinDir();
SetDefaultSearchPaths();
SetLanguagePath();
ReadPdfBrowserInfos();
// Internationalisation: loading the kicad suitable Dictionnary
......@@ -441,6 +443,10 @@ bool WinEDA_App::SetBinDir()
while( m_BinDir.Last() != '/' )
m_BinDir.RemoveLast();
wxFileName pfn( wxT( "/posix/path/specification" ), wxT( "filename" ) );
wxFileName wfn( wxT( "\\windows\\path\\specification" ), wxT( "filename" ) );
wxLogDebug( wxT( "Posix path: " ) + pfn.GetFullPath() );
wxLogDebug( wxT( "Windows path: " ) + wfn.GetFullPath() );
wxLogDebug( wxT( "Executable path the Kicad way: " ) + m_BinDir );
wxLogDebug( wxT( "Executable path the wxWidgets way: " ) +
GetTraits()->GetStandardPaths().GetExecutablePath() );
......@@ -457,24 +463,22 @@ void WinEDA_App::SetDefaultSearchPaths( void )
wxString path;
wxFileName fn( m_BinDir, wxEmptyString );
/* User environment variable path. */
if( ::wxGetEnv( wxT( "KICAD_SEARCH_PATH" ), NULL ) )
m_searchPaths.AddEnvList( wxT( "KICAD_SEARCH_PATH" ) );
/* User environment variable path is the first search path. Chances are
* if the user is savvy enough to set an environment variable they know
* what they are doing. */
if( ::wxGetEnv( wxT( "KICAD" ), NULL ) )
m_searchPaths.AddEnvList( wxT( "KICAD" ) );
/* Hard coded path defined by the application. */
m_searchPaths.Add( ReturnKicadDatasPath() );
/* Add the user's home path. */
m_searchPaths.Add( GetTraits()->GetStandardPaths().GetUserDataDir() );
/* Standard application data path if it is different from the binary
* path. */
if( fn.GetPath() != GetTraits()->GetStandardPaths().GetDataDir() )
m_searchPaths.Add( GetTraits()->GetStandardPaths().GetDataDir() );
/* Up on level relative to binary path with "share" appended. */
/* Up on level relative to binary path with "share" appended for Windows. */
fn.RemoveLastDir();
fn.AppendDir( wxT( "share" ) );
#ifndef __WXMSW__
fn.AppendDir( wxT( "kicad" ) );
#endif
m_searchPaths.Add( fn.GetPath() );
/* Remove all non-existant paths from the list. */
......@@ -657,38 +661,23 @@ void WinEDA_App::SaveSettings()
bool WinEDA_App::SetLanguage( bool first_time )
/*********************************************/
{
size_t i;
wxString path;
bool retv = true;
// dictionary file name without extend (full name is kicad.mo)
wxString DictionaryName( wxT( "kicad" ) );
if( m_Locale != NULL )
if( m_Locale )
delete m_Locale;
m_Locale = new wxLocale();
/* Add defined search paths to locale paths */
if( !m_searchPaths.IsEmpty() )
{
for( i = 0; i < m_searchPaths.GetCount(); i++ )
{
wxFileName fn( m_searchPaths[i], wxEmptyString );
fn.AppendDir( wxT( "internat" ) );
path = fn.GetPath();
wxLogDebug( wxT( "Adding locale lookup path: " ) + path );
m_Locale->AddCatalogLookupPathPrefix( path );
}
}
m_Locale = new wxLocale;
if( !m_Locale->Init( m_LanguageId, wxLOCALE_CONV_ENCODING ) )
{
wxLogDebug( wxT( "Failed to initialize " ) +
wxLocale::GetLanguageInfo( m_LanguageId )->Description );
delete m_Locale;
m_Locale = new wxLocale();
m_LanguageId = wxLANGUAGE_DEFAULT;
delete m_Locale;
m_Locale = new wxLocale;
m_Locale->Init();
retv = false;
}
......@@ -732,6 +721,35 @@ void WinEDA_App::SetLanguageIdentifier( int menu_id )
}
void WinEDA_App::SetLanguagePath( void )
{
size_t i;
/* Add defined search paths to locale paths */
if( !m_searchPaths.IsEmpty() )
{
for( i = 0; i < m_searchPaths.GetCount(); i++ )
{
wxFileName fn( m_searchPaths[i], wxEmptyString );
fn.AppendDir( wxT( "share" ) );
#ifndef __WXMSW__
/* Up on level relative to binary path with "share/kicad" appended
* for all other platforms. */
fn.AppendDir( wxT( "kicad" ) );
#endif
fn.AppendDir( wxT( "internat" ) );
if( fn.DirExists() )
{
wxLogDebug( wxT( "Adding locale lookup path: " ) +
fn.GetPath() );
wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
}
}
}
}
/** Function AddMenuLanguageList
* Create menu list for language choice, and add it as submenu to a main menu
* @param MasterMenu : The main menu. The sub menu list will be accessible from the menu item with id ID_LANGUAGE_CHOICE
......@@ -782,6 +800,93 @@ void WinEDA_App::AddMenuLanguageList( wxMenu* MasterMenu )
}
/**
* Look in search paths for requested file.
*
*/
wxString WinEDA_App::FindFileInSearchPaths( const wxString& filename,
const wxArrayString* subdirs )
{
size_t i, j;
wxFileName fn;
wxPathList paths;
for( i = 0; i < m_searchPaths.GetCount(); i++ )
{
fn = wxFileName( m_searchPaths[i], wxEmptyString );
if( subdirs )
{
for( j = 0; j < subdirs->GetCount(); j++ )
fn.AppendDir( subdirs->Item( j ) );
}
if( fn.DirExists() )
{
wxLogDebug( _T( "Adding <" ) + fn.GetPath() + _T( "> to " ) +
_T( "file \"" ) + filename + _T( "\" search path." ) );
paths.Add( fn.GetPath() );
}
}
return paths.FindValidPath( filename );
}
/**
* Get the help file path.
*
* Return the Kicad help file with path. The base paths defined in
* m_searchPaths are tested for a valid file. The path returned can
* be relative depending on the paths added to m_searchPaths. See the
* documentation for wxPathList for more information. If the help file
* for the current locale is not found, an attempt to find the English
* version of the help file is made. wxEmptyString is returned if the
* help file is not found.
*/
wxString WinEDA_App::GetHelpFile( void )
{
wxString fn;
wxArrayString subdirs;
/* FIXME: This is not the ideal way to handle this. Unfortunely, the
* CMake install paths seem to be a moving target so this crude
* hack solve the problem of install path differences between
* Windows and non-Windows platforms. */
#ifndef __WXMSW__
subdirs.Add( wxT( "share" ) );
#endif
subdirs.Add( _T( "doc" ) );
#ifndef __WXMSW__
subdirs.Add( wxT( "kicad" ) );
#endif
subdirs.Add( _T( "help" ) );
subdirs.Add( m_Locale->GetCanonicalName() );
fn = FindFileInSearchPaths( m_HelpFileName, &subdirs );
if( !fn && m_Locale->GetCanonicalName() != wxLocale::GetLanguageInfo(wxLANGUAGE_ENGLISH )->CanonicalName )
{
subdirs.RemoveAt( subdirs.GetCount() - 1 );
subdirs.Add( _T( "en" ) );
fn = FindFileInSearchPaths( m_HelpFileName, &subdirs );
}
return fn;
}
wxString WinEDA_App::GetLibraryFile( const wxString& filename )
{
wxArrayString subdirs;
subdirs.Add( wxT( "share" ) );
#ifndef __WXMSW__
/* Up on level relative to binary path with "share/kicad" appended for
* all other platforms. */
subdirs.Add( wxT( "kicad" ) );
#endif
return FindFileInSearchPaths( filename, &subdirs );
}
/**
* Run init scripts
* @return the defualt OnRun() value (exit codes not used in kicad, so value has no special mening)
......
......@@ -21,14 +21,14 @@ extern BASE_SCREEN* ActiveScreen;
static int GRLastMoveToX, GRLastMoveToY;
static int Text_Color = LIGHTGRAY;
static int PenMinWidth = 1;/* largeur minimum de la plume (DOIT etre > 0)
static int PenMinWidth = 1; /* largeur minimum de la plume (DOIT etre > 0)
* (utile pour trace sur imprimante) */
static int ForceBlackPen;/* si != 0 : traces en noir (utilise pour trace
static int ForceBlackPen; /* si != 0 : traces en noir (utilise pour trace
* sur imprimante */
static int xcliplo = 0,
ycliplo = 0,
xcliphi = 2000,
ycliphi = 2000;/* coord de la surface de trace */
ycliphi = 2000; /* coord de la surface de trace */
static int lastcolor = -1;
static int lastwidth = -1;
static int s_Last_Pen_Style = -1;
......@@ -47,27 +47,18 @@ static wxDC* lastDC = NULL;
static inline int USCALE( us arg, us num, us den )
{
#ifndef WX_ZOOM
int ii;
ii = (int) ( ( (float) arg * num ) / den );
return ii;
}
#ifdef WX_ZOOM
#define GET_ZOOM 1
#else
#define GET_ZOOM ActiveScreen->GetZoom()
return arg;
#endif
}
static int inline ZoomValue( int value_to_zoom ) {
int zoom = GET_ZOOM;
if( !zoom ) return 0;
if( value_to_zoom >= 0 )
return ( value_to_zoom + (zoom >> 1 ) ) / zoom;
else
return ( value_to_zoom - (zoom >> 1 ) ) / zoom;
static int inline ZoomValue( int val )
{
return ActiveScreen->Scale( val );
}
/****************************************/
......@@ -75,27 +66,27 @@ static int inline ZoomValue( int value_to_zoom ) {
/****************************************/
int GRMapX( int x )
{
int coord = x - ActiveScreen->m_DrawOrg.x;
#ifndef WX_ZOOM
int coord = x - ActiveScreen->m_DrawOrg.x;
coord = ZoomValue( coord );
coord -= ActiveScreen->m_StartVisu.x;
#endif
return coord;
#else
return x;
#endif
}
int GRMapY( int y )
{
int coord = y - ActiveScreen->m_DrawOrg.y;
#ifndef WX_ZOOM
int coord = y - ActiveScreen->m_DrawOrg.y;
coord = ZoomValue( coord );
coord -= ActiveScreen->m_StartVisu.y;
#endif
return coord;
#else
return y;
#endif
}
......
......@@ -30,9 +30,7 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse )
*/
{
PutOnGrid( &(GetBaseScreen()->m_Curseur) );
AdjustScrollBars();
ReDrawPanel();
/* Move the mouse cursor to the on grid graphic cursor position */
......@@ -69,10 +67,7 @@ void WinEDA_DrawFrame::Zoom_Automatique( bool move_mouse_cursor )
/** Redraw the screen with the zoom level which shows all the page or the board
*/
{
int bestzoom;
bestzoom = BestZoom();
GetBaseScreen()->SetZoom( bestzoom );
GetBaseScreen()->SetZoom( BestZoom() );
Recadre_Trace( move_mouse_cursor );
}
......@@ -100,8 +95,7 @@ void WinEDA_DrawFrame::Window_Zoom( EDA_Rect& Rect )
if( bestzoom <= 0 )
bestzoom = 1;
GetBaseScreen()->SetZoom( bestzoom );
GetBaseScreen()->SetZoom( bestzoom * GetBaseScreen()->m_ZoomScalar );
GetBaseScreen()->m_Curseur = Rect.Centre();
Recadre_Trace( TRUE );
}
......@@ -112,13 +106,14 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
{
if( DrawPanel == NULL )
{
wxLogDebug( wxT( "No DrawPanel object definedin " \
wxLogDebug( wxT( "No DrawPanel object defined in " \
"WinEDA_DrawFrame::OnZoom()." ) );
return;
}
bool zoom_at_cursor = false;
int i;
int id = event.GetId();
bool zoom_at_cursor = false;
BASE_SCREEN* screen = GetBaseScreen();
switch( id )
......@@ -164,70 +159,23 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema();
break;
case ID_POPUP_ZOOM_LEVEL_1:
screen->SetZoom( 1 );
Recadre_Trace( true );
break;
case ID_POPUP_ZOOM_LEVEL_2:
screen->SetZoom( 2 );
Recadre_Trace( true );
break;
case ID_POPUP_ZOOM_LEVEL_4:
screen->SetZoom( 4 );
Recadre_Trace( true );
break;
case ID_POPUP_ZOOM_LEVEL_8:
screen->SetZoom( 8 );
Recadre_Trace( true );
break;
case ID_POPUP_ZOOM_LEVEL_16:
screen->SetZoom( 16 );
Recadre_Trace( true );
break;
case ID_POPUP_ZOOM_LEVEL_32:
screen->SetZoom( 32 );
Recadre_Trace( true );
break;
case ID_POPUP_ZOOM_LEVEL_64:
screen->SetZoom( 64 );
Recadre_Trace( true );
break;
case ID_POPUP_ZOOM_LEVEL_128:
screen->SetZoom( 128 );
Recadre_Trace( true );
break;
case ID_POPUP_ZOOM_LEVEL_256:
screen->SetZoom( 256 );
Recadre_Trace( true );
break;
case ID_POPUP_ZOOM_LEVEL_512:
screen->SetZoom( 512 );
Recadre_Trace( true );
break;
case ID_POPUP_ZOOM_LEVEL_1024:
screen->SetZoom( 1024 );
Recadre_Trace( true );
break;
case ID_POPUP_ZOOM_LEVEL_2048:
screen->SetZoom( 2048 );
Recadre_Trace( true );
break;
default:
wxLogDebug( wxT( "WinEDA_DrawFram::OnZoom() unhandled ID %d" ), id );
i = id - ID_POPUP_ZOOM_LEVEL_START;
if( i < 0 )
{
wxLogDebug( wxT( "WinEDA_DrawFram::OnZoom() invalid ID %d" ), id );
return;
}
if( !( (size_t) i < screen->m_ZoomList.GetCount()) )
{
wxLogDebug( _T( "Requested index %d is outside the bounds of " \
"the zoom list." ), i );
return;
}
screen->SetZoom( screen->m_ZoomList[i] );
Recadre_Trace( true );
}
Affiche_Status_Box();
}
......@@ -247,13 +195,13 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
*/
{
size_t i;
int maxZoomIds;
int zoom;
wxSize grid;
int zoom_value;
wxString msg;
int ii;
wxString line;
GRID_TYPE tmp;
wxMenu* gridMenu;
double gridValue;
ADD_MENUITEM( MasterMenu, ID_POPUP_ZOOM_CENTER, _( "Center" ),
zoom_center_xpm );
......@@ -269,23 +217,27 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
ADD_MENUITEM( MasterMenu, ID_ZOOM_REDRAW, _( "Redraw view" ),
zoom_redraw_xpm );
/* Create the basic zoom list: */
zoom = GetScreen()->GetZoom();
zoom_value = 1;
for( ii = 0; zoom_value <= m_Parent->m_ZoomMaxValue; zoom_value <<= 1, ii++ ) // Create zoom choice 1 .. zoom max
maxZoomIds = ID_POPUP_ZOOM_LEVEL_END - ID_POPUP_ZOOM_LEVEL_START;
maxZoomIds = ( (size_t) maxZoomIds < GetScreen()->m_ZoomList.GetCount() ) ?
maxZoomIds : GetScreen()->m_ZoomList.GetCount();
wxLogDebug( _T( "%d zoom IDs used." ), maxZoomIds );
/* Populate zoom submenu. */
for( i = 0; i < (size_t) maxZoomIds; i++ )
{
line.Printf( wxT( "%u" ), zoom_value );
zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_1 + ii,
_( "Zoom: " ) + line, wxEmptyString, TRUE );
if( zoom == zoom_value )
zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_1 + ii, TRUE );
msg.Printf( wxT( "%u" ), GetScreen()->m_ZoomList[i] );
zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg,
wxEmptyString, wxITEM_CHECK );
if( zoom == GetScreen()->m_ZoomList[i] )
zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_START + i, true );
}
/* Create grid submenu as required. */
if( !GetScreen()->m_GridList.IsEmpty() )
{
wxMenu* grid_choice = new wxMenu;
ADD_MENUITEM_WITH_SUBMENU( MasterMenu, grid_choice,
gridMenu = new wxMenu;
ADD_MENUITEM_WITH_SUBMENU( MasterMenu, gridMenu,
ID_POPUP_GRID_SELECT, _( "Grid Select" ),
grid_select_xpm );
......@@ -294,8 +246,7 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ )
{
tmp = GetScreen()->m_GridList[i];
double grid_value = To_User_Unit( g_UnitMetric,
tmp.m_Size.x,
gridValue = To_User_Unit( g_UnitMetric, tmp.m_Size.x,
( (WinEDA_DrawFrame*)m_Parent )->m_InternalUnits );
if( tmp.m_Id == ID_POPUP_GRID_USER )
{
......@@ -304,14 +255,14 @@ void WinEDA_DrawPanel::AddMenuZoom( wxMenu* MasterMenu )
else
{
if ( g_UnitMetric == 0 ) // inches
line.Printf( wxT( "%g mils" ), grid_value*1000 );
msg.Printf( wxT( "%g mils" ), gridValue * 1000 );
else
line.Printf( wxT( "%g mm" ), grid_value );
msg = _( "Grid: " ) + line;
msg.Printf( wxT( "%g mm" ), gridValue );
msg = _( "Grid: " ) + msg;
}
grid_choice->Append( tmp.m_Id, msg, wxEmptyString, true );
gridMenu->Append( tmp.m_Id, msg, wxEmptyString, true );
if( grid == tmp.m_Size )
grid_choice->Check( tmp.m_Id, true );
gridMenu->Check( tmp.m_Id, true );
}
}
......
......@@ -179,7 +179,6 @@ void WinEDA_DisplayFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
{
wxSize delta;
int flagcurseur = 0;
int zoom = GetScreen()->GetZoom();
wxPoint curpos, oldpos;
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
......@@ -187,7 +186,8 @@ void WinEDA_DisplayFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGrid() / zoom;
delta = GetScreen()->GetGrid();
GetScreen()->Scale( delta );
if( delta.x <= 0 )
delta.x = 1;
......
......@@ -4,7 +4,7 @@
/****************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
......
......@@ -11,18 +11,8 @@
// Licence: License GNU
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
......
......@@ -11,17 +11,6 @@
// Licence:
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "fctsys.h"
#include "gr_basic.h"
......
......@@ -3,7 +3,7 @@
/*****************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
......
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
......@@ -78,7 +78,13 @@ void SCH_ITEM::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
/***********************************************************************/
/* Class SCH_SCREEN: classe de gestion d'un affichage pour schematique */
/***********************************************************************/
static int table_zoom[] = { 1, 2, 4, 8, 16, 32, 64, 128, 0 }; /* Valeurs standards du zoom */
/* Default EESchema zoom values. */
static int SchematicZoomList[] = { 10, 15, 20, 40, 80, 160, 320, 640, 1280 };
#define SCHEMATIC_ZOOM_LIST_CNT ( sizeof( SchematicZoomList ) / \
sizeof( int ) )
/* Default grid sizes for the schematic editor. */
static GRID_TYPE SchematicGridList[] = {
......@@ -101,7 +107,9 @@ SCH_SCREEN::SCH_SCREEN( KICAD_T type ) : BASE_SCREEN( type )
EEDrawList = NULL; /* Schematic items list */
m_Zoom = 32;
SetZoomList( table_zoom );
for( i = 0; i < SCHEMATIC_ZOOM_LIST_CNT; i++ )
m_ZoomList.Add( SchematicZoomList[i] );
for( i = 0; i < SCHEMATIC_GRID_LIST_CNT; i++ )
AddGrid( SchematicGridList[i] );
......
......@@ -222,7 +222,6 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPi
{
wxSize delta;
SCH_SCREEN* screen = GetScreen();
int zoom = screen->GetZoom();
wxPoint curpos, oldpos;
int hotkey = 0;
......@@ -231,7 +230,8 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPi
curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur;
delta = screen->GetGrid() / zoom;
delta = screen->GetGrid();
screen->Scale( delta );
if( delta.x <= 0 )
delta.x = 1;
......@@ -316,7 +316,6 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixe
{
wxSize delta;
SCH_SCREEN* screen = GetScreen();
int zoom = screen->GetZoom();
wxPoint curpos, oldpos;
int hotkey = 0;
......@@ -325,7 +324,8 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixe
curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur;
delta = screen->GetGrid() / zoom;
delta = screen->GetGrid();
screen->Scale( delta );
if( delta.x <= 0 )
delta.x = 1;
......@@ -403,13 +403,12 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixe
SetToolbars();
}
/*************************************************************************************/
void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
/*************************************************************************************/
/*****************************************************************************/
void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC,
wxPoint MousePositionInPixels )
{
wxSize delta;
SCH_SCREEN* screen = GetScreen();
int zoom = screen->GetZoom();
wxPoint curpos, oldpos;
int hotkey = 0;
......@@ -418,7 +417,8 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, wxPoint MousePositionInPixe
curpos = screen->m_MousePosition;
oldpos = screen->m_Curseur;
delta = screen->GetGrid() / zoom;
delta = screen->GetGrid();
screen->Scale( delta );
if( delta.x <= 0 )
delta.x = 1;
......
......@@ -7,7 +7,7 @@
/////////////////////////////////////////////////////////////////////////////
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "dialog_SVG_print_base.h"
......
......@@ -5,6 +5,7 @@
// Set this to 1 if you want to test PostScript printing under MSW.
#define wxTEST_POSTSCRIPT_IN_MSW 1
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
......
......@@ -8,6 +8,7 @@
*/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
......
......@@ -3,6 +3,7 @@
/*******************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
......
......@@ -167,7 +167,7 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC,
}
// Trace de l'ancre
int len = 3 * panel->GetZoom();
int len = panel->GetScreen()->Unscale( 3 );
GRLine( &panel->m_ClipBox, DC, aOffset.x, aOffset.y - len, aOffset.x, aOffset.y + len, 0, color );
GRLine( &panel->m_ClipBox, DC, aOffset.x - len, aOffset.y, aOffset.x + len, aOffset.y, 0, color );
}
......
......@@ -211,14 +211,13 @@ void RedrawOneStruct( WinEDA_DrawPanel* panel, wxDC* DC,
}
/*****************************************************************************************/
void EDA_DrawLineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int DrawMode, int Color )
/*****************************************************************************************/
/****************************************************************************/
/* Draw wires, Bus, and dashed liges.. */
/****************************************************************************/
void EDA_DrawLineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int DrawMode, int Color )
{
int color;
int zoom = panel->GetZoom();
int width = MAX( m_Width, g_DrawMinimunLineWidth );
if( Color >= 0 )
......@@ -227,15 +226,19 @@ void EDA_DrawLineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint&
color = ReturnLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
if( (m_Layer == LAYER_BUS) && (zoom <= 16) )
// FIXME: Not compatable with new zoom.
if( (m_Layer == LAYER_BUS) && panel->GetScreen()->Scale( width ) <= 1 )
width *= 3;
if( m_Layer == LAYER_NOTES )
GRDashedLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, m_Start.y + offset.y,
m_End.x + offset.x, m_End.y + offset.y, width, color );
GRDashedLine( &panel->m_ClipBox, DC, m_Start.x + offset.x,
m_Start.y + offset.y, m_End.x + offset.x,
m_End.y + offset.y, width, color );
else
GRLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, m_Start.y + offset.y,
m_End.x + offset.x, m_End.y + offset.y, width, color );
GRLine( &panel->m_ClipBox, DC, m_Start.x + offset.x,
m_Start.y + offset.y, m_End.x + offset.x, m_End.y + offset.y,
width, color );
if( m_StartIsDangling )
DrawDanglingSymbol( panel, DC, m_Start + offset, color );
......@@ -310,7 +313,6 @@ void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint&
{
int color;
int zoom = panel->GetZoom();
int width = MAX( m_Width, g_DrawMinimunLineWidth );
if( Color >= 0 )
......@@ -319,7 +321,7 @@ void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint&
color = ReturnLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
if( (m_Layer == LAYER_BUS) && (zoom <= 16) )
if( m_Layer == LAYER_BUS )
width *= 3;
GRLine( &panel->m_ClipBox, DC, m_Pos.x + offset.x, m_Pos.y + offset.y,
......@@ -345,7 +347,6 @@ void DrawPolylineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint&
int DrawMode, int Color )
{
int color;
int zoom = panel->GetZoom();
int width = MAX( m_Width, g_DrawMinimunLineWidth );
if( Color >= 0 )
......@@ -355,7 +356,7 @@ void DrawPolylineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint&
GRSetDrawMode( DC, DrawMode );
if( (m_Layer == LAYER_BUS) && (zoom <= 16) )
if( m_Layer == LAYER_BUS )
{
width *= 3;
}
......
......@@ -3,6 +3,7 @@
/**************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
......
......@@ -3,6 +3,7 @@
/*************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
......
......@@ -326,8 +326,8 @@ static bool UpdateScreenFromSheet( WinEDA_SchematicFrame* frame )
// Reinit des parametres d'affichage du nouvel ecran
// assumes m_CurrentSheet has already been updated.
frame->MsgPanel->EraseMsgBox();
frame->DrawPanel->SetScrollbars( frame->DrawPanel->m_Scroll_unit,
frame->DrawPanel->m_Scroll_unit,
frame->DrawPanel->SetScrollbars( NewScreen->m_ZoomScalar,
NewScreen->m_ZoomScalar,
NewScreen->m_ScrollbarNumber.x,
NewScreen->m_ScrollbarNumber.y,
NewScreen->m_ScrollbarPos.x,
......
/****************************/
/* EESchema - libedit.cpp */
/****************************/
/****************************/
/* EESchema - libedit.cpp */
/****************************/
/* Routines de maintenanace des librairies:
sauvegarde, modification de librairies.
creation edition suppression de composants
*/
* sauvegarde, modification de librairies.
* creation edition suppression de composants
*/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -30,44 +30,47 @@ void WinEDA_LibeditFrame::DisplayLibInfos()
/**********************************************/
/* Affiche dans la zone messages la librairie , et le composant edite */
{
wxString msg = wxT("Libedit: ");
wxString msg = wxT( "Libedit: " );
msg += CurrentLib ? CurrentLib->m_FullFileName : wxT("No Lib");
SetTitle(msg);
msg += CurrentLib ? CurrentLib->m_FullFileName : wxT( "No Lib" );
SetTitle( msg );
msg = _(" Part: ");
if ( CurrentLibEntry == NULL )
msg = _( " Part: " );
if( CurrentLibEntry == NULL )
{
msg += _("None");
msg += _( "None" );
}
else
{
msg += CurrentLibEntry->m_Name.m_Text;
if ( !CurrentAliasName.IsEmpty() )
msg << wxT(" Alias ") << CurrentAliasName;
if( !CurrentAliasName.IsEmpty() )
msg << wxT( " Alias " ) << CurrentAliasName;
}
wxChar UnitLetter[] = wxT("?ABCDEFGHIJKLMNOPQRSTUVWXYZ");
msg << wxT(" Unit ") << UnitLetter[CurrentUnit];
wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
msg << wxT( " Unit " ) << UnitLetter[CurrentUnit];
if ( CurrentConvert > 1 ) msg += _(" Convert");
else msg += _(" Normal");
if( CurrentConvert > 1 )
msg += _( " Convert" );
else
msg += _( " Normal" );
if ( CurrentLibEntry && (CurrentLibEntry->m_Options == ENTRY_POWER) )
msg += _(" (Power Symbol)");
if( CurrentLibEntry && (CurrentLibEntry->m_Options == ENTRY_POWER) )
msg += _( " (Power Symbol)" );
SetStatusText(msg, 0);
SetStatusText( msg, 0 );
}
/**************************************************/
void WinEDA_LibeditFrame::SelectActiveLibrary()
/**************************************************/
/* Routine to Select Current library
*/
*/
{
LibraryStruct *Lib;
LibraryStruct* Lib;
Lib = SelectLibraryFromList(this);
Lib = SelectLibraryFromList( this );
if( Lib )
{
CurrentLib = Lib;
......@@ -75,137 +78,157 @@ LibraryStruct *Lib;
DisplayLibInfos();
}
/*************************************************/
/* Routine to Load one selected library content. */
/*************************************************/
bool WinEDA_LibeditFrame::LoadOneLibraryPart()
{
int i;
wxString msg;
wxString CmpName;
EDA_LibComponentStruct *LibEntry = NULL;
int i;
wxString msg;
wxString CmpName;
EDA_LibComponentStruct* LibEntry = NULL;
if( g_ScreenLib->IsModify() )
{
if( ! IsOK(this, _("Current Part not saved.\nContinue?") ) ) return FALSE;
if( !IsOK( this, _( "Current Part not saved.\nContinue?" ) ) )
return FALSE;
}
if(CurrentLib == NULL) SelectActiveLibrary();
if(CurrentLib == NULL) return FALSE;
if( CurrentLib == NULL )
{
SelectActiveLibrary();
return FALSE;
}
i = GetNameOfPartToLoad(this, CurrentLib, CmpName);
if( i == 0) return FALSE;
i = GetNameOfPartToLoad( this, CurrentLib, CmpName );
if( i == 0 )
return FALSE;
g_ScreenLib->ClrModify();
CurrentDrawItem = NULL;
// Effacement ancien composant affich�
if( CurrentLibEntry)
if( CurrentLibEntry )
{
SAFE_DELETE( CurrentLibEntry ) ;
SAFE_DELETE( CurrentLibEntry );
}
/* Chargement du composant */
LibEntry = FindLibPart(CmpName.GetData(),CurrentLib->m_Name, FIND_ALIAS);
LibEntry = FindLibPart( CmpName.GetData(), CurrentLib->m_Name, FIND_ALIAS );
if( LibEntry == NULL)
if( LibEntry == NULL )
{
msg = _("Component \""); msg << CmpName << _("\" not found.");
DisplayError(this, msg, 20);
msg = _( "Component \"" ); msg << CmpName << _( "\" not found." );
DisplayError( this, msg, 20 );
return FALSE;
}
LoadOneLibraryPartAux(LibEntry, CurrentLib);
LoadOneLibraryPartAux( LibEntry, CurrentLib );
ReCreateHToolbar();
Zoom_Automatique(FALSE);
Zoom_Automatique( FALSE );
DrawPanel->Refresh();
return TRUE;
}
/**************************************************************************/
int WinEDA_LibeditFrame::LoadOneLibraryPartAux(EDA_LibComponentStruct *LibEntry,
LibraryStruct *Library, int noMsg)
int WinEDA_LibeditFrame::LoadOneLibraryPartAux(
EDA_LibComponentStruct* LibEntry,
LibraryStruct* Library,
int noMsg )
/**************************************************************************/
/* Routine Pour Charger en memoire la copie de 1 libpart.
retourne
0 si OK
1 si err
CurrentLibEntry pointe la copie ainsi creee
*/
* retourne
* 0 si OK
* 1 si err
* CurrentLibEntry pointe la copie ainsi creee
*/
{
wxString msg;
const wxChar * CmpName, *RootName = NULL;
wxString msg;
const wxChar* CmpName, * RootName = NULL;
if( (LibEntry == NULL) || (Library == NULL) ) return(1);
if( (LibEntry == NULL) || (Library == NULL) )
return 1;
CmpName = LibEntry->m_Name.m_Text.GetData();
CurrentAliasName.Empty();
if( LibEntry->Type != ROOT)
if( LibEntry->Type != ROOT )
{
RootName = ((EDA_LibCmpAliasStruct*)LibEntry)->m_RootName.GetData() ;
RootName = ( (EDA_LibCmpAliasStruct*) LibEntry )->m_RootName.GetData();
if( !noMsg )
{
msg.Printf( wxT("\"<%s>\" is Alias of \"<%s>\""), CmpName, RootName);
msg.Printf( wxT( "\"<%s>\" is Alias of \"<%s>\"" ), CmpName,
RootName );
}
LibEntry = FindLibPart(RootName,Library->m_Name,FIND_ROOT);
LibEntry = FindLibPart( RootName, Library->m_Name, FIND_ROOT );
if( LibEntry == NULL)
if( LibEntry == NULL )
{
msg.Printf( wxT("Root Part \"<%s>\" not found."), RootName);
DisplayError(this, msg, 20);
return(1);
msg.Printf( wxT( "Root Part \"<%s>\" not found." ), RootName );
DisplayError( this, msg, 20 );
return 1;
}
CurrentAliasName = CmpName;
}
if( CurrentLibEntry){ SAFE_DELETE( CurrentLibEntry ) ;}
if( CurrentLibEntry )
{
SAFE_DELETE( CurrentLibEntry );
}
CurrentLibEntry = CopyLibEntryStruct(this, LibEntry);
CurrentLibEntry = CopyLibEntryStruct( this, LibEntry );
CurrentUnit = 1; CurrentConvert = 1;
DisplayLibInfos();
BuildAliasData(Library, CurrentLibEntry);
BuildAliasData( Library, CurrentLibEntry );
g_ScreenLib->ClrModify();
g_AsDeMorgan = 0;
if( LookForConvertPart(CurrentLibEntry) > 1 ) g_AsDeMorgan = 1;
if( LookForConvertPart( CurrentLibEntry ) > 1 )
g_AsDeMorgan = 1;
return(0);
return 0;
}
/*********************************************************************/
void WinEDA_LibeditFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg)
void WinEDA_LibeditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/*********************************************************************/
/* Routine generale d'affichage a l'ecran du "PartLib" en cours d'edition */
{
if( GetScreen() == NULL ) return;
if( GetScreen() == NULL )
return;
ActiveScreen = GetScreen();
DC->SetBackground(*wxBLACK_BRUSH );
DC->SetBackgroundMode(wxTRANSPARENT);
GRResetPenAndBrush(DC); // reinit de la brosse et plume courante
DC->SetBackground( *wxBLACK_BRUSH );
DC->SetBackgroundMode( wxTRANSPARENT );
GRResetPenAndBrush( DC ); // reinit de la brosse et plume courante
DrawPanel->CursorOff(DC); // effacement curseur
if(DrawPanel->ManageCurseur)
DrawPanel->CursorOff( DC ); // effacement curseur
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); // effacement affichage lie au curseur
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); // effacement affichage lie au curseur
}
if (EraseBg ) DrawPanel->EraseScreen(DC);
if( EraseBg )
DrawPanel->EraseScreen( DC );
DrawPanel->DrawBackGround(DC);
DrawPanel->DrawBackGround( DC );
if( CurrentLibEntry)
DrawLibEntry(DrawPanel, DC, CurrentLibEntry, wxPoint(0, 0),
CurrentUnit, CurrentConvert, GR_DEFAULT_DRAWMODE);
if( CurrentLibEntry )
DrawLibEntry( DrawPanel, DC, CurrentLibEntry, wxPoint( 0, 0 ),
CurrentUnit, CurrentConvert, GR_DEFAULT_DRAWMODE );
DrawPanel->CursorOn(DC); // reaffichage curseur
DrawPanel->CursorOn( DC ); // reaffichage curseur
if(DrawPanel->ManageCurseur)
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur(DrawPanel, DC, FALSE); // reaffichage lie au curseur
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); // reaffichage lie au curseur
}
GetScreen()->ClrRefreshReq();
......@@ -217,189 +240,212 @@ void WinEDA_LibeditFrame::RedrawActiveWindow(wxDC * DC, bool EraseBg)
/*************************************************/
void WinEDA_LibeditFrame::SaveActiveLibrary()
/*************************************************/
/* Sauvegarde en fichier la librairie pointee par CurrentLib
une sauvegarde en .bak de l'ancien fichier est egalement cree
*/
* une sauvegarde en .bak de l'ancien fichier est egalement cree
*/
{
wxString Name, msg;
wxString Name, msg;
if(CurrentLib == NULL)
if( CurrentLib == NULL )
{
DisplayError(this, wxT("No Library specified")); return;
DisplayError( this, wxT( "No Library specified" ) );
return;
}
Name = MakeFileName(g_RealLibDirBuffer, CurrentLib->m_Name, g_LibExtBuffer);
Name = MakeFileName( g_RealLibDirBuffer,
CurrentLib->m_Name,
g_LibExtBuffer );
msg = _("Modify Library File \"") + Name + _("\"?");
if( ! IsOK(this, msg) ) return;
msg = _( "Modify Library File \"" ) + Name + _( "\"?" );
if( !IsOK( this, msg ) )
return;
bool success = CurrentLib->SaveLibrary( Name );
MsgPanel->EraseMsgBox();
if ( ! success )
if( !success )
{
msg = _("Error while saving Library File \"") + Name + _("\".");
Affiche_1_Parametre(this, 1, wxT(" *** ERROR : **"), msg,BLUE);
DisplayError(this, msg);
msg = _( "Error while saving Library File \"" ) + Name + _( "\"." );
Affiche_1_Parametre( this, 1, wxT( " *** ERROR : **" ), msg, BLUE );
DisplayError( this, msg );
}
else
{
msg = _("Library File \"") + Name + wxT("\" Ok");
ChangeFileNameExt(Name,DOC_EXT);
wxString msg1 = _("Document File \"") + Name + wxT("\" Ok");
Affiche_1_Parametre(this, 1,msg, msg1,BLUE);
msg = _( "Library File \"" ) + Name + wxT( "\" Ok" );
ChangeFileNameExt( Name, DOC_EXT );
wxString msg1 = _( "Document File \"" ) + Name + wxT( "\" Ok" );
Affiche_1_Parametre( this, 1, msg, msg1, BLUE );
}
}
/**************************************************************/
void WinEDA_LibeditFrame::DisplayCmpDoc(const wxString & Name)
void WinEDA_LibeditFrame::DisplayCmpDoc( const wxString& Name )
/**************************************************************/
/*
Affiche la documentation du composant selectionne
Utilis�e lors de l'affichage de la liste des composants en librairie
*/
* Affiche la documentation du composant selectionne
* Utilis�e lors de l'affichage de la liste des composants en librairie
*/
{
LibCmpEntry * CmpEntry;
LibCmpEntry* CmpEntry;
if( CurrentLib == NULL ) return;
if( CurrentLib == NULL )
return;
MsgPanel->EraseMsgBox();
CmpEntry = FindLibPart(Name.GetData(), CurrentLib->m_Name, FIND_ALIAS);
if ( CmpEntry == NULL ) return;
CmpEntry = FindLibPart( Name.GetData(), CurrentLib->m_Name, FIND_ALIAS );
if( CmpEntry == NULL )
return;
AfficheDoc(this, CmpEntry->m_Doc,CmpEntry->m_KeyWord);
AfficheDoc( this, CmpEntry->m_Doc, CmpEntry->m_KeyWord );
}
/*********************************************/
void WinEDA_LibeditFrame::DeleteOnePart()
/*********************************************/
/* Routine de suppression d'un composant dans la librairie courante
(effacement en memoire uniquement, le fichier n'est pas modifie)
Le composant peut etre un alias, ou la definition de base.
Si c'est un alias:
il est supprime, et la liste des alias de la definition
de base est modifiee
Si c'est le composant de base:
Si la liste des alias est nulle, il est supprime
Sinon le premier alias devient le composant de base, et les autres
alias deviennent dependants de celui ci.
*/
* (effacement en memoire uniquement, le fichier n'est pas modifie)
* Le composant peut etre un alias, ou la definition de base.
* Si c'est un alias:
* il est supprime, et la liste des alias de la definition
* de base est modifiee
* Si c'est le composant de base:
* Si la liste des alias est nulle, il est supprime
* Sinon le premier alias devient le composant de base, et les autres
* alias deviennent dependants de celui ci.
*/
{
wxString CmpName;
int NumOfParts;
EDA_LibComponentStruct *LibEntry;
WinEDAListBox * ListBox;
const wxChar ** ListNames;
wxString msg;
wxString CmpName;
int NumOfParts;
EDA_LibComponentStruct* LibEntry;
WinEDAListBox* ListBox;
const wxChar** ListNames;
wxString msg;
CurrentDrawItem = NULL;
if(CurrentLib == NULL)
if( CurrentLib == NULL )
{
SelectActiveLibrary();
if(CurrentLib == NULL)
if( CurrentLib == NULL )
{
DisplayError(this, _("No Active Library"), 20); return;
DisplayError( this, _( "No Active Library" ), 20 );
return;
}
}
NumOfParts = 0;
PQCompFunc((PQCompFuncType) LibraryEntryCompare);
LibEntry = (EDA_LibComponentStruct *) PQFirst(&CurrentLib->m_Entries, FALSE);
PQCompFunc( (PQCompFuncType) LibraryEntryCompare );
LibEntry = (EDA_LibComponentStruct*) PQFirst( &CurrentLib->m_Entries,
FALSE );
while( LibEntry != NULL )
{
NumOfParts++;
LibEntry = (EDA_LibComponentStruct *)
PQNext(CurrentLib->m_Entries, LibEntry, NULL);
LibEntry = (EDA_LibComponentStruct*)
PQNext( CurrentLib->m_Entries, LibEntry, NULL );
}
ListNames = (const wxChar**) MyZMalloc((NumOfParts+1) * sizeof(wxChar*));
LibEntry = (EDA_LibComponentStruct *) PQFirst(&CurrentLib->m_Entries, FALSE);
msg.Printf( _("Select Component (%d items)"), NumOfParts);
ListNames = (const wxChar**) MyZMalloc( (NumOfParts + 1) * sizeof(wxChar*) );
LibEntry = (EDA_LibComponentStruct*) PQFirst( &CurrentLib->m_Entries,
FALSE );
msg.Printf( _( "Select Component (%d items)" ), NumOfParts );
NumOfParts = 0;
while( LibEntry != NULL )
{
ListNames[NumOfParts] = LibEntry->m_Name.m_Text.GetData();
NumOfParts++;
LibEntry = (EDA_LibComponentStruct *)
PQNext(CurrentLib->m_Entries, LibEntry, NULL);
LibEntry = (EDA_LibComponentStruct*)
PQNext( CurrentLib->m_Entries, LibEntry, NULL );
}
ListBox = new WinEDAListBox(this, msg,
ListNames, wxEmptyString, NULL /*DisplayCmpDoc*/,
wxColour(255,255,255)); // Component listbox background color
ListBox = new WinEDAListBox( this, msg, ListNames, wxEmptyString, NULL,
wxColour( 255, 255, 255 ) );
int ii = ListBox->ShowModal(); ListBox->Destroy();
int ii = ListBox->ShowModal();
ListBox->Destroy();
if( ii >= 0)
if( ii >= 0 )
{
CmpName = ListNames[ii];
LibEntry = FindLibPart(CmpName.GetData(), CurrentLib->m_Name, FIND_ALIAS);
LibEntry = FindLibPart( CmpName.GetData(), CurrentLib->m_Name,
FIND_ALIAS );
if( LibEntry == NULL )
DisplayError(this, _("Component not found"), 20);
DisplayError( this, _( "Component not found" ), 20 );
else
{
msg = _("Delete component \"") + LibEntry->m_Name.m_Text +
_("\" from library \"") + CurrentLib->m_Name + wxT("\"?");
if( IsOK(this, msg) )
msg = _( "Delete component \"" ) + LibEntry->m_Name.m_Text +
_( "\" from library \"" ) + CurrentLib->m_Name + wxT( "\"?" );
if( IsOK( this, msg ) )
{
DeletePartInLib( CurrentLib, LibEntry );
}
}
}
free (ListNames);
free( ListNames );
}
/****************************************************/
void WinEDA_LibeditFrame::CreateNewLibraryPart()
/****************************************************/
/* Routine to create a new library component
If an old component is currently in edit, it is deleted.
*/
* If an old component is currently in edit, it is deleted.
*/
{
wxString msg;
EDA_LibComponentStruct * NewStruct;
int diag;
wxString msg;
EDA_LibComponentStruct* NewStruct;
int diag;
if( CurrentLibEntry )
if( ! IsOK(this, _("Clear old component from screen (changes will be lost)?")) ) return;
if( CurrentLibEntry
&& !IsOK( this, _( "Clear old component from screen (changes will be lost)?" ) ) )
return;
CurrentDrawItem = NULL;
WinEDA_CreateCmpDialog Dialogbox(this);
WinEDA_CreateCmpDialog Dialogbox( this );
diag = Dialogbox.ShowModal();
if ( diag != wxID_OK ) return;
if( diag != wxID_OK )
return;
msg = Dialogbox.ReturnCmpName();
if ( msg.IsEmpty() ) return;
msg.MakeUpper(); msg.Replace(wxT(" "), wxT("_") );
if( msg.IsEmpty() )
return;
msg.MakeUpper();
msg.Replace( wxT( " " ), wxT( "_" ) );
/* Test: y a t-il un composant deja de ce nom */
if(CurrentLib)
if( CurrentLib )
{
if( FindLibPart(msg.GetData(), CurrentLib->m_Name, FIND_ALIAS) )
if( FindLibPart( msg.GetData(), CurrentLib->m_Name, FIND_ALIAS ) )
{
wxString msg;
msg << _("Component \"") << Dialogbox.ReturnCmpName() <<
_("\" exists in library \"") << CurrentLib->m_Name << _("\".");
DisplayError(this, msg);
msg << _( "Component \"" ) << Dialogbox.ReturnCmpName() <<
_( "\" exists in library \"" ) << CurrentLib->m_Name <<
_( "\"." );
DisplayError( this, msg );
return;
}
}
NewStruct = new EDA_LibComponentStruct( msg);
Dialogbox.SetComponentData(*NewStruct);
if ( NewStruct->m_Prefix.m_Text.IsEmpty())
NewStruct->m_Prefix.m_Text = wxT("U");
NewStruct = new EDA_LibComponentStruct( msg );
Dialogbox.SetComponentData( *NewStruct );
if( NewStruct->m_Prefix.m_Text.IsEmpty() )
NewStruct->m_Prefix.m_Text = wxT( "U" );
NewStruct->m_Prefix.m_Text.MakeUpper();
// Effacement ancien composant affich�
if( CurrentLibEntry){ SAFE_DELETE( CurrentLibEntry );}
if( CurrentLibEntry )
{
SAFE_DELETE( CurrentLibEntry );
}
CurrentLibEntry = NewStruct;
CurrentUnit = 1;
CurrentConvert = 1;
......@@ -409,87 +455,96 @@ int diag;
}
/*******************************************************************/
void WinEDA_LibeditFrame::DeletePartInLib( LibraryStruct * Library,
EDA_LibComponentStruct *Entry)
void WinEDA_LibeditFrame::DeletePartInLib( LibraryStruct* Library,
EDA_LibComponentStruct* Entry )
/*******************************************************************/
/* Suppression du composant Entry en librairie Library.
(effacement en memoire uniquement, le fichier n'est pas modifie)
Le composant peut etre un alias, ou la definition de base.
Si c'est un alias:
il est supprime, et la liste des alias de la definition
de base est modifiee
Si c'est le composant de base:
Si la liste des alias est nulle, il est supprime
Sinon le premier alias devient le composant de base, et les autres
alias deviennent dependants de celui ci.
*/
* (effacement en memoire uniquement, le fichier n'est pas modifie)
* Le composant peut etre un alias, ou la definition de base.
* Si c'est un alias:
* il est supprime, et la liste des alias de la definition
* de base est modifiee
* Si c'est le composant de base:
* Si la liste des alias est nulle, il est supprime
* Sinon le premier alias devient le composant de base, et les autres
* alias deviennent dependants de celui ci.
*/
{
EDA_LibComponentStruct *RootEntry;
EDA_LibCmpAliasStruct * AliasEntry;
EDA_LibComponentStruct* RootEntry;
EDA_LibCmpAliasStruct* AliasEntry;
if ( (Library == NULL) || (Entry == NULL) ) return;
if( ( Library == NULL ) || ( Entry == NULL ) )
return;
PQCompFunc((PQCompFuncType) LibraryEntryCompare);
PQCompFunc( (PQCompFuncType) LibraryEntryCompare );
Library->m_Modified = 1;
if( Entry->Type == ALIAS )
{
RootEntry = FindLibPart( ((EDA_LibCmpAliasStruct*)Entry)->m_RootName.GetData(),
Library->m_Name,FIND_ROOT);
RootEntry = FindLibPart(
( (EDA_LibCmpAliasStruct*) Entry )->m_RootName.GetData(),
Library->m_Name, FIND_ROOT );
/* Remove alias name from the root component alias list */
if( RootEntry == NULL )
{
DisplayError(this, wxT("Warning: for Alias, root not found"), 30);
DisplayError( this, wxT( "Warning: for Alias, root not found" ),
30 );
}
else
{
int index = wxNOT_FOUND;
if( RootEntry->m_AliasList.GetCount() != 0)
if( RootEntry->m_AliasList.GetCount() != 0 )
{
index = RootEntry->m_AliasList.Index(Entry->m_Name.m_Text.GetData(), FALSE );
if ( index != wxNOT_FOUND ) RootEntry->m_AliasList.RemoveAt(index);
index = RootEntry->m_AliasList.Index( Entry->m_Name.m_Text.GetData(),
FALSE );
if( index != wxNOT_FOUND )
RootEntry->m_AliasList.RemoveAt( index );
}
if ( index == wxNOT_FOUND )
DisplayError(this, wxT("Warning: Root for Alias as no alias list"), 30);
if( index == wxNOT_FOUND )
DisplayError( this,
wxT( "Warning: Root for Alias as no alias list" ),
30 );
}
/* Effacement memoire pour cet alias */
PQDelete( &Library->m_Entries, (void*) Entry );
SAFE_DELETE( Entry );
if( Library->m_NumOfParts > 0 ) CurrentLib->m_NumOfParts --;
if( Library->m_NumOfParts > 0 )
CurrentLib->m_NumOfParts--;
return;
}
/* Entry is a standard component (not an alias) */
if( Entry->m_AliasList.GetCount() == 0) // Trivial case: no alias, we can safety delete e=this entry
if( Entry->m_AliasList.GetCount() == 0 ) // Trivial case: no alias, we can safety delete e=this entry
{
PQDelete( &Library->m_Entries, Entry );
SAFE_DELETE( Entry );
if( Library->m_NumOfParts > 0 ) Library->m_NumOfParts --;
if( Library->m_NumOfParts > 0 )
Library->m_NumOfParts--;
return;
}
/* Entry is a component with alias
We must change the first alias to a "root" component, and for all the aliases
we must change the root component (which is deleted) by the first alias */
* We must change the first alias to a "root" component, and for all the aliases
* we must change the root component (which is deleted) by the first alias */
wxString AliasName = Entry->m_AliasList[0];
/* The root component is not really deleted, it is renamed with the first alias name */
AliasEntry = (EDA_LibCmpAliasStruct*) FindLibPart(
AliasName.GetData(), Library->m_Name, FIND_ALIAS);
AliasName.GetData(), Library->m_Name, FIND_ALIAS );
if( AliasEntry == NULL )
{
wxString msg;
msg.Printf(wxT("Warning: Alias <%s> not found"), AliasName.GetData());
DisplayError(this, msg, 30);
msg.Printf( wxT( "Warning: Alias <%s> not found" ),
AliasName.GetData() );
DisplayError( this, msg, 30 );
}
else
{
if( Library->m_NumOfParts > 0 ) Library->m_NumOfParts --;
if( Library->m_NumOfParts > 0 )
Library->m_NumOfParts--;
/* remove the root component from library */
PQDelete( &Library->m_Entries, Entry );
......@@ -498,17 +553,17 @@ EDA_LibCmpAliasStruct * AliasEntry;
PQDelete( &Library->m_Entries, AliasEntry );
/* remove the first alias name from alias list: */
Entry->m_AliasList.RemoveAt(0);
Entry->m_AliasList.RemoveAt( 0 );
/* change the old name. New name for "root" is the name of the first alias */
Entry->m_Name.m_Text = AliasName;
Entry->m_Doc = AliasEntry->m_Doc;
Entry->m_KeyWord = AliasEntry->m_KeyWord;
FreeLibraryEntry((EDA_LibComponentStruct *)AliasEntry);
FreeLibraryEntry( (EDA_LibComponentStruct*) AliasEntry );
/* root component (renamed) placed in library */
PQInsert( &Library->m_Entries, Entry);
PQInsert( &Library->m_Entries, Entry );
}
/* Change the "RootName", for other aliases */
......@@ -516,20 +571,23 @@ EDA_LibCmpAliasStruct * AliasEntry;
{
AliasName = Entry->m_AliasList[ii];
AliasEntry = (EDA_LibCmpAliasStruct*) FindLibPart(
AliasName.GetData(), Library->m_Name, FIND_ALIAS);
AliasEntry = (EDA_LibCmpAliasStruct*) FindLibPart( AliasName.GetData(),
Library->m_Name,
FIND_ALIAS );
if( AliasEntry == NULL )
{ // Should not occurs. If happens, this is an error (or bug)
wxString msg;
msg.Printf( wxT("Warning: Alias <%s> not found"), AliasName.GetData());
DisplayError(this, msg, 30);
msg.Printf( wxT( "Warning: Alias <%s> not found" ),
AliasName.GetData() );
DisplayError( this, msg, 30 );
continue;
}
if( AliasEntry->Type != ALIAS )
{ // Should not occurs. If happens, this is an error (or bug)
wxString msg;
msg.Printf( wxT("Warning: <%s> is not an Alias"), AliasName.GetData());
DisplayError(this, msg, 30);
msg.Printf( wxT( "Warning: <%s> is not an Alias" ),
AliasName.GetData() );
DisplayError( this, msg, 30 );
continue;
}
AliasEntry->m_RootName = Entry->m_Name.m_Text;
......@@ -540,78 +598,92 @@ EDA_LibCmpAliasStruct * AliasEntry;
/***************************************************/
void WinEDA_LibeditFrame::SaveOnePartInMemory()
/***************************************************/
/* Routine de sauvegarde de la "partlib" courante dans la librairie courante
Sauvegarde en memoire uniquement, et PAS sur fichier
La routine efface l'ancien composant ( ou / et les alias ) a remplacer
s'il existe, et sauve le nouveau et cree les alias correspondants.
*/
* Sauvegarde en memoire uniquement, et PAS sur fichier
* La routine efface l'ancien composant ( ou / et les alias ) a remplacer
* s'il existe, et sauve le nouveau et cree les alias correspondants.
*/
{
EDA_LibComponentStruct *Entry;
EDA_LibCmpAliasStruct *AliasEntry;
wxString msg;
bool NewCmp = TRUE;
EDA_LibComponentStruct* Entry;
EDA_LibCmpAliasStruct* AliasEntry;
wxString msg;
bool NewCmp = TRUE;
if(CurrentLibEntry == NULL)
if( CurrentLibEntry == NULL )
{
DisplayError(this, _("No component to Save.") ); return;
DisplayError( this, _( "No component to Save." ) );
return;
}
if(CurrentLib == NULL) SelectActiveLibrary();
if( CurrentLib == NULL )
SelectActiveLibrary();
if(CurrentLib == NULL)
if( CurrentLib == NULL )
{
DisplayError(this, _("No Library specified."), 20); return;
DisplayError( this, _( "No Library specified." ), 20 );
return;
}
CurrentLib->m_Modified = 1;
g_ScreenLib->ClrModify();
PQCompFunc((PQCompFuncType) LibraryEntryCompare);
PQCompFunc( (PQCompFuncType) LibraryEntryCompare );
if( (Entry = FindLibPart(CurrentLibEntry->m_Name.m_Text.GetData(),
CurrentLib->m_Name, FIND_ROOT)) != NULL)
if( ( Entry = FindLibPart( CurrentLibEntry->m_Name.m_Text.GetData(),
CurrentLib->m_Name, FIND_ROOT ) ) != NULL )
{
msg.Printf( _("Component \"%s\" exists. Change it?"),
Entry->m_Name.m_Text.GetData());
if( !IsOK(this, msg) ) return;
msg.Printf( _( "Component \"%s\" exists. Change it?" ),
Entry->m_Name.m_Text.GetData() );
if( !IsOK( this, msg ) )
return;
NewCmp = FALSE;
}
/* Effacement des alias deja existants en librairie */
for ( unsigned ii = 0; ii < CurrentLibEntry->m_AliasList.GetCount(); ii += ALIAS_NEXT )
for( unsigned ii = 0;
ii < CurrentLibEntry->m_AliasList.GetCount();
ii += ALIAS_NEXT )
{
EDA_LibComponentStruct * LocalEntry;
wxString aliasname = CurrentLibEntry->m_AliasList[ii+ALIAS_NAME];
while( (LocalEntry = FindLibPart(aliasname.GetData(), CurrentLib->m_Name, FIND_ALIAS)) != NULL )
EDA_LibComponentStruct* LocalEntry;
wxString aliasname = CurrentLibEntry->m_AliasList[ii + ALIAS_NAME];
while( ( LocalEntry = FindLibPart( aliasname.GetData(),
CurrentLib->m_Name,
FIND_ALIAS ) ) != NULL )
{
DeletePartInLib( CurrentLib, LocalEntry );
}
}
if( !NewCmp )DeletePartInLib( CurrentLib, Entry );
if( !NewCmp )
DeletePartInLib( CurrentLib, Entry );
Entry = CopyLibEntryStruct(this, CurrentLibEntry);
Entry = CopyLibEntryStruct( this, CurrentLibEntry );
Entry->m_AliasList.Clear();
PQInsert( &CurrentLib->m_Entries, (void*)Entry );
CurrentLib->m_NumOfParts ++;
PQInsert( &CurrentLib->m_Entries, (void*) Entry );
CurrentLib->m_NumOfParts++;
/* Creation des nouveaux alias */
for ( unsigned ii = 0; ii < CurrentLibEntry->m_AliasList.GetCount(); ii += ALIAS_NEXT )
{
wxString aliasname = CurrentLibEntry->m_AliasList[ii+ALIAS_NAME];
Entry->m_AliasList.Add(aliasname);
AliasEntry = new EDA_LibCmpAliasStruct(aliasname.GetData(), Entry->m_Name.m_Text);
AliasEntry->m_Doc = CurrentLibEntry->m_AliasList[ii+ALIAS_DOC];
AliasEntry->m_KeyWord = CurrentLibEntry->m_AliasList[ii+ALIAS_KEYWORD];
AliasEntry->m_DocFile = CurrentLibEntry->m_AliasList[ii+ALIAS_DOC_FILENAME];
for( unsigned ii = 0;
ii < CurrentLibEntry->m_AliasList.GetCount();
ii += ALIAS_NEXT )
{
wxString aliasname = CurrentLibEntry->m_AliasList[ii + ALIAS_NAME];
Entry->m_AliasList.Add( aliasname );
AliasEntry = new EDA_LibCmpAliasStruct( aliasname.GetData(),
Entry->m_Name.m_Text );
AliasEntry->m_Doc = CurrentLibEntry->m_AliasList[ii + ALIAS_DOC];
AliasEntry->m_KeyWord =
CurrentLibEntry->m_AliasList[ii + ALIAS_KEYWORD];
AliasEntry->m_DocFile =
CurrentLibEntry->m_AliasList[ii + ALIAS_DOC_FILENAME];
/* Placement en liste des composants de l'Alias */
PQInsert( &CurrentLib->m_Entries, (void*) AliasEntry );
CurrentLib->m_NumOfParts ++;
CurrentLib->m_NumOfParts++;
}
msg.Printf( _("Component %s saved in %s"),
Entry->m_Name.m_Text.GetData(), CurrentLib->m_Name.GetData());
Affiche_Message(msg);
msg.Printf( _( "Component %s saved in %s" ),
Entry->m_Name.m_Text.GetData(), CurrentLib->m_Name.GetData() );
Affiche_Message( msg );
}
......@@ -281,7 +281,7 @@ int WinEDA_LibeditFrame::BestZoom()
GetScreen()->m_Curseur.y = 0;
}
return bestzoom;
return bestzoom * GetScreen()->m_ZoomScalar;
}
......
......@@ -280,7 +280,7 @@ void WinEDA_SchematicFrame::CreateScreens()
if( g_ScreenLib == NULL )
g_ScreenLib = new SCH_SCREEN();
g_ScreenLib->SetZoom( 4 );
g_ScreenLib->SetZoom( 4 * g_ScreenLib->m_ZoomScalar );
g_ScreenLib->m_UndoRedoCountMax = 10;
}
......@@ -450,11 +450,10 @@ int WinEDA_SchematicFrame::BestZoom()
jj = dy / size.y;
bestzoom = MAX( ii, jj ) + 1;
GetScreen()->SetZoom( ii );
GetScreen()->m_Curseur.x = dx / 2;
GetScreen()->m_Curseur.y = dy / 2;
return bestzoom;
return bestzoom * GetScreen()->m_ZoomScalar;
}
/*******************************************************************/
......
......@@ -6,6 +6,7 @@
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
......
......@@ -223,7 +223,7 @@ int WinEDA_ViewlibFrame::BestZoom()
GetScreen()->m_Curseur = BoundaryBox.Centre();
return bestzoom;
return bestzoom * GetScreen()->m_ZoomScalar;
}
......
......@@ -3,7 +3,7 @@
/****************************/
#include "fctsys.h"
//#include "gr_basic.h"
#include "gr_basic.h"
#include "common.h"
#include "program.h"
......
......@@ -62,8 +62,9 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur;
delta.x = GetScreen()->GetGrid().x / GetScreen()->GetZoom();
delta.y = GetScreen()->GetGrid().y / GetScreen()->GetZoom();
delta = GetScreen()->GetGrid();
GetScreen()->Scale( delta );
if( delta.x == 0 )
delta.x = 1;
if( delta.y == 0 )
......
......@@ -7,6 +7,7 @@
#endif
#include "fctsys.h"
#include "wxstruct.h"
#include "common.h"
#include "gerbview.h"
......@@ -137,7 +138,6 @@ WinEDA_GerberFrame::WinEDA_GerberFrame( wxWindow* father,
m_Draw_Grid = TRUE; // TRUE pour avoir la axes dessinee
m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessin�
m_Ident = GERBER_FRAME;
m_ZoomMaxValue = 1024;
if( DrawPanel )
DrawPanel->m_Block_Enable = TRUE;
......@@ -305,27 +305,17 @@ void WinEDA_GerberFrame::SetToolbars()
int WinEDA_GerberFrame::BestZoom()
/*************************************/
{
int ii, jj;
int ii, jj, gridX, gridY;
int bestzoom;
wxSize size;
/* calcul du zoom montrant tout le dessim */
GetBoard()->ComputeBoundaryBox();
gridX = GetScreen()->GetGrid().GetWidth() / 2;
gridY = GetScreen()->GetGrid().GetHeight() / 2;
size = DrawPanel->GetClientSize();
ii = GetBoard()->m_BoundaryBox.GetWidth() / size.x;
jj = GetBoard()->m_BoundaryBox.GetHeight() / size.y;
ii = ( GetBoard()->m_BoundaryBox.GetWidth() + gridX ) / size.x;
jj = ( GetBoard()->m_BoundaryBox.GetHeight() + gridY ) / size.y;
bestzoom = MAX( ii, jj ) + 1;
/* determination du zoom existant le plus proche */
for( ii = 1; ii < 2048; ii <<= 1 )
{
if( ii >= bestzoom )
break;
}
bestzoom = ii;
GetScreen()->m_Curseur = GetBoard()->m_BoundaryBox.Centre();
return bestzoom;
return bestzoom * GetScreen()->m_ZoomScalar;
}
......@@ -9,6 +9,7 @@
*/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "gerbview.h"
......
......@@ -3,6 +3,7 @@
/*****************************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "gerbview.h"
......@@ -65,8 +66,9 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
{
int l_piste;
int color;
int zoom;
int fillopt;
int radius;
int halfPenWidth;
static bool show_err;
if( track->m_Flags & DRAW_ERASED ) // draw in background color, used by classs TRACK in gerbview
......@@ -92,22 +94,20 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
GRSetDrawMode( DC, draw_mode );
zoom = panel->GetZoom();
fillopt = DisplayOpt.DisplayPcbTrackFill ? FILLED : SKETCH;
switch( track->m_Shape )
{
case S_CIRCLE:
{
int radius = (int) hypot( (double) (track->m_End.x - track->m_Start.x),
radius = (int) hypot( (double) (track->m_End.x - track->m_Start.x),
(double) (track->m_End.y - track->m_Start.y) );
int halfPenWidth = track->m_Width >> 1;
if( (halfPenWidth / zoom) < L_MIN_DESSIN )
halfPenWidth = track->m_Width >> 1;
if( panel->GetScreen()->Scale( halfPenWidth ) < L_MIN_DESSIN )
{
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
radius, 0, color );
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x,
track->m_Start.y, radius, 0, color );
}
if( fillopt == SKETCH )
......@@ -123,7 +123,6 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
radius, track->m_Width, color );
}
}
break;
case S_ARC:
......@@ -143,25 +142,23 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
break;
case S_SPOT_CIRCLE:
{
int radius = track->m_Width >> 1;
radius = track->m_Width >> 1;
fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH;
if( (radius / zoom) < L_MIN_DESSIN )
if( panel->GetScreen()->Scale( radius ) < L_MIN_DESSIN )
{
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
radius, 0, color );
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x,
track->m_Start.y, radius, 0, color );
}
else if( fillopt == SKETCH )
{
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
radius, 0, color );
GRCircle( &panel->m_ClipBox, DC, track->m_Start.x,
track->m_Start.y, radius, 0, color );
}
else
{
GRFilledCircle( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
radius, 0, color, color );
}
GRFilledCircle( &panel->m_ClipBox, DC, track->m_Start.x,
track->m_Start.y, radius, 0, color, color );
}
break;
......@@ -171,7 +168,7 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
l_piste = track->m_Width >> 1;
fillopt = DisplayOpt.DisplayPadFill ? FILLED : SKETCH;
if( (l_piste / zoom) < L_MIN_DESSIN )
if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN )
{
GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
track->m_End.x, track->m_End.y, 0, color );
......@@ -202,7 +199,7 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
case S_SEGMENT:
l_piste = track->m_Width >> 1;
if( (l_piste / zoom) < L_MIN_DESSIN )
if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN )
{
GRLine( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
track->m_End.x, track->m_End.y, 0, color );
......@@ -212,13 +209,12 @@ void Trace_Segment( WinEDA_DrawPanel* panel, wxDC* DC, TRACK* track, int draw_mo
if( fillopt == SKETCH )
{
GRCSegm( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
track->m_End.x, track->m_End.y,
track->m_Width, color );
track->m_End.x, track->m_End.y, track->m_Width, color );
}
else
{
GRFillCSegm( &panel->m_ClipBox, DC, track->m_Start.x, track->m_Start.y,
track->m_End.x, track->m_End.y,
GRFillCSegm( &panel->m_ClipBox, DC, track->m_Start.x,
track->m_Start.y, track->m_End.x, track->m_End.y,
track->m_Width, color );
}
break;
......
......@@ -17,6 +17,7 @@
/* Use wxFileHistory for most recently used file handling. */
#include <wx/docview.h>
class PARAM_CFG_BASE;
/**********************************************/
/* Class representing the entire Application */
......@@ -70,6 +71,7 @@ public:
*/
void AddMenuLanguageList( wxMenu* MasterMenu );
void SetLanguageIdentifier( int menu_id );
void SetLanguagePath( void );
void InitOnLineHelp();
// Sauvegarde de configurations et options:
......@@ -85,6 +87,12 @@ public:
void ReadPdfBrowserInfos();
void WritePdfBrowserInfos();
wxString FindFileInSearchPaths( const wxString& filename,
const wxArrayString* subdirs = NULL );
wxString GetHelpFile( void );
wxString GetLibraryFile( const wxString& filename );
};
/*
......
......@@ -93,7 +93,7 @@ class EDA_BaseStruct;
class WinEDA_DrawFrame;
class BOARD;
class EDA_Rect;
class WinEDA_DrawPanel;
/**
* Class INSPECTOR
......
......@@ -18,6 +18,8 @@
#include "colors.h"
class SCH_ITEM;
class BASE_SCREEN;
class Ki_PageDescr;
/* Simple class for handling grid arrays. */
class GRID_TYPE
......@@ -43,7 +45,6 @@ public:
WinEDA_DrawFrame* m_Parent;
EDA_Rect m_ClipBox; // the clipbox used in screen redraw (usually gives the visible area in internal units)
wxPoint m_CursorStartPos; // utile dans controles du mouvement curseur
int m_Scroll_unit; // Valeur de l'unite de scroll en pixels pour les barres de scroll
int m_ScrollButt_unit; // Valeur de l'unite de scroll en pixels pour les boutons de scroll
bool m_AbortRequest; // Flag d'arret de commandes longues
......@@ -277,8 +278,9 @@ public:
bool m_UserGridIsON;
int m_Diviseur_Grille;
int* m_ZoomList; /* Liste des coefficients standard de zoom */
int m_Zoom; /* coeff de ZOOM */
wxArrayInt m_ZoomList; /* Array of standard zoom coefficients. */
int m_Zoom; /* Current zoom coefficient. */
int m_ZoomScalar; /* Allow zooming to non-integer increments. */
public:
BASE_SCREEN( KICAD_T aType = SCREEN_STRUCT_TYPE );
......@@ -341,7 +343,14 @@ public:
* sets the list of zoom factors.
* @param aZoomList An array of zoom factors in ascending order, zero terminated
*/
void SetZoomList( const int* zoomlist );
void SetZoomList( const wxArrayInt& zoomlist );
int Scale( int coord );
void Scale( wxPoint& pt );
void Scale( wxSize& sz );
int Unscale( int coord );
void Unscale( wxPoint& pt );
void Unscale( wxSize& sz );
void SetNextZoom(); /* ajuste le prochain coeff de zoom */
void SetPreviousZoom(); /* ajuste le precedent coeff de zoom */
......
......@@ -42,7 +42,6 @@
#define EESCHEMA_INTERNAL_UNIT 1000 // EESCHEMA internal unit = 1/1000 inch
#include "wxstruct.h"
#include "gr_basic.h"
// Old wxWidget compatibility (prior to wxWidget 2.7):
#if !wxCHECK_VERSION( 2, 7, 0 )
......
......@@ -212,20 +212,15 @@ enum main_id {
ID_POPUP_ZOOM_OUT,
ID_POPUP_ZOOM_SELECT,
ID_POPUP_ZOOM_CENTER,
ID_POPUP_ZOOM_LEVEL_1,
ID_POPUP_ZOOM_LEVEL_2,
ID_POPUP_ZOOM_LEVEL_4,
ID_POPUP_ZOOM_LEVEL_8,
ID_POPUP_ZOOM_LEVEL_16,
ID_POPUP_ZOOM_LEVEL_32,
ID_POPUP_ZOOM_LEVEL_64,
ID_POPUP_ZOOM_LEVEL_128,
ID_POPUP_ZOOM_LEVEL_256,
ID_POPUP_ZOOM_LEVEL_512,
ID_POPUP_ZOOM_LEVEL_1024,
ID_POPUP_ZOOM_LEVEL_2048,
ID_POPUP_ZOOM_UNUSED0,
ID_POPUP_ZOOM_UNUSED1,
/* Reserve IDs for popup menu zoom levels. If you need more than 15
* levels of zoom, change ID_POPUP_ZOOM_LEVEL_END. Note that more
* than 15 entries in a context submenu may get too large to display
* cleanly. Add any additional popup zoom IDs above here or the
* zoom event handler will not work properly.
*/
ID_POPUP_ZOOM_LEVEL_START,
ID_POPUP_ZOOM_LEVEL_END = ID_POPUP_ZOOM_LEVEL_START + 15,
ID_POPUP_ZOOM_END_RANGE, // last zoom id
ID_POPUP_GRID_PLUS,
......
......@@ -11,6 +11,8 @@
#define eda_global extern
#endif
#include <vector>
#include <wx/socket.h>
#include "wx/log.h"
#include "wx/config.h"
......@@ -18,7 +20,10 @@
#include <wx/laywin.h>
#include <wx/snglinst.h>
#include <vector>
#include "base_struct.h"
#include "appl_wxstruct.h"
#include "drawpanel_wxstruct.h"
#ifndef SAFE_DELETE
#define SAFE_DELETE(p) delete (p); (p) = NULL; //C++ guarantees that operator delete checks its argument for null-ness
......@@ -32,9 +37,10 @@
// Option for dialog boxes
// #define DIALOG_STYLE wxDEFAULT_DIALOG_STYLE|wxFRAME_FLOAT_ON_PARENT|wxSTAY_ON_TOP
#define DIALOG_STYLE wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT | MAYBE_RESIZE_BORDER
#define DIALOG_STYLE wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT | \
MAYBE_RESIZE_BORDER
#define KICAD_DEFAULT_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE|wxWANTS_CHARS
#define KICAD_DEFAULT_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS
class wxMyDialogModalData;
......@@ -42,8 +48,6 @@ class wxMyDialogModalData;
class WinEDA_DrawPanel;
class WinEDA_DrawFrame;
#include "base_struct.h"
class WinEDA_App;
class WinEDA_MsgPanel;
class COMMAND;
......@@ -108,11 +112,6 @@ enum id_toolbar {
#define MSG_PANEL_DEFAULT_HEIGHT ( 28 ) // height of the infos display window
/**********************************************/
/* Class representing the entire Application */
/**********************************************/
#include "appl_wxstruct.h"
/******************************************************************/
/* Basic frame for kicad, eeschema, pcbnew and gerbview. */
......@@ -183,7 +182,6 @@ public:
WinEDAChoiceBox* m_SelGridBox; // Dialog box to choose the grid size
WinEDAChoiceBox* m_SelZoomBox; // Dialog box to choose the Zoom value
int m_ZoomMaxValue; // Max zoom value: Draw min scale is 1/m_ZoomMaxValue
int m_CurrentCursorShape; // shape for cursor (0 = default cursor)
int m_ID_current_state; // Id of active button on the vertical toolbar
......@@ -322,9 +320,6 @@ public:
/* classe representant un ecran graphique de dessin */
/****************************************************/
#include "drawpanel_wxstruct.h"
/*********************************************************
class WinEDA_MsgPanel : this is a panel to display various infos
and messages on items in eeschema an pcbnew
......
......@@ -406,9 +406,8 @@ bool WinEDA_App::OnInit()
/* Splash screen logo */
#ifdef USE_SPLASH_IMAGE
wxString logoname( wxString( m_BinDir ) + _T( "logokicad.png" ) );
wxBitmap splash_screen;
if( splash_screen.LoadFile( logoname, wxBITMAP_TYPE_PNG ) )
wxBitmap bmp;
if( bmp.LoadFile( m_BinDir + _T( "logokicad.png" ), wxBITMAP_TYPE_PNG ) )
{
wxSplashScreen* splash = new wxSplashScreen( splash_screen,
wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT,
......
......@@ -7,6 +7,7 @@
#endif
#include "fctsys.h"
#include "wxstruct.h"
#include "common.h"
#include "pcbnew.h"
......@@ -89,7 +90,7 @@ int WinEDA_BasePcbFrame::BestZoom( void )
wxSize size;
if( m_Pcb == NULL )
return 32;
return 32 * GetScreen()->m_ZoomScalar;
m_Pcb->ComputeBoundaryBox();
......@@ -100,10 +101,9 @@ int WinEDA_BasePcbFrame::BestZoom( void )
ii = ( dx + (size.x / 2) ) / size.x;
jj = ( dy + (size.y / 2) ) / size.y;
bestzoom = MAX( ii, jj ) + 1;
GetScreen()->m_Curseur = m_Pcb->m_BoundaryBox.Centre();
return bestzoom;
return bestzoom * GetScreen()->m_ZoomScalar;
}
......
......@@ -4,6 +4,7 @@
/****************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
......
......@@ -379,7 +379,6 @@ void COTATION::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
*/
{
int ox, oy, typeaff, width, gcolor;
int zoom = panel->GetScreen()->GetZoom();
ox = offset.x;
oy = offset.y;
......@@ -392,9 +391,9 @@ void COTATION::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
GRSetDrawMode( DC, mode_color );
typeaff = DisplayOpt.DisplayDrawItems;
width = m_Width;
if( width / zoom < 2 )
if( panel->GetScreen()->Scale( width ) < 2 )
typeaff = FILAIRE;
switch( typeaff )
......
......@@ -132,19 +132,19 @@ wxPoint DRAWSEGMENT::GetStart() const
wxPoint DRAWSEGMENT::GetEnd() const
{
wxPoint center; // center point of the arc
wxPoint start; // start of arc
switch( m_Shape )
{
case S_ARC:
{
// rotate the starting point of the arc, given by m_End, through the angle m_Angle
// to get the ending point of the arc.
wxPoint center = m_Start; // center point of the arc
wxPoint start = m_End; // start of arc
// rotate the starting point of the arc, given by m_End, through the
// angle m_Angle to get the ending point of the arc.
center = m_Start; // center point of the arc
start = m_End; // start of arc
RotatePoint( &start.x, &start.y, center.x, center.y, -m_Angle );
return start; // after rotation, the end of the arc.
}
break;
case S_SEGMENT:
......@@ -161,18 +161,12 @@ void DRAWSEGMENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int ux0, uy0, dx, dy;
int l_piste;
int color, mode;
int zoom;
int rayon;
color = g_DesignSettings.m_LayerColor[GetLayer()];
if( color & ITEM_NOT_SHOW )
return;
if( panel )
zoom = panel->GetZoom();
else
zoom = ActiveScreen->GetZoom();
GRSetDrawMode( DC, draw_mode );
l_piste = m_Width >> 1; /* l_piste = demi largeur piste */
......@@ -187,7 +181,7 @@ void DRAWSEGMENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
mode = DisplayOpt.DisplayDrawItems;
if( m_Flags & FORCE_SKETCH )
mode = SKETCH;
if( l_piste < (L_MIN_DESSIN * zoom) )
if( l_piste < panel->GetScreen()->Unscale( L_MIN_DESSIN ) )
mode = FILAIRE;
switch( m_Shape )
......@@ -210,7 +204,6 @@ void DRAWSEGMENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
break;
case S_ARC:
{
int StAngle, EndAngle;
rayon = (int) hypot( (double) (dx - ux0), (double) (dy - uy0) );
StAngle = (int) ArcTangente( dy - uy0, dx - ux0 );
......@@ -229,7 +222,8 @@ void DRAWSEGMENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
if( mode == FILAIRE )
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, color );
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
rayon, color );
else if( mode == SKETCH )
{
......@@ -243,7 +237,6 @@ void DRAWSEGMENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
rayon, m_Width, color );
}
}
break;
default:
......@@ -339,7 +332,7 @@ bool DRAWSEGMENT::HitTest( const wxPoint& ref_pos )
rayon = (int) hypot( (double) (dx), (double) (dy) );
dist = (int) hypot( (double) (spot_cX), (double) (spot_cY) );
if( abs( rayon - dist ) <= (m_Width / 2) )
if( abs( rayon - dist ) <= ( m_Width / 2 ) )
{
if( m_Shape == S_CIRCLE )
return true;
......
......@@ -98,7 +98,6 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
{
int ux0, uy0, dx, dy, rayon, StAngle, EndAngle;
int color, type_trace;
int zoom;
int typeaff;
PCB_SCREEN* screen;
WinEDA_BasePcbFrame* frame;
......@@ -115,8 +114,6 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
screen = frame->GetScreen();
zoom = screen->GetZoom();
type_trace = m_Shape;
ux0 = m_Start.x - offset.x;
......@@ -133,7 +130,7 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
if( !typeaff )
typeaff = SKETCH;
}
if( (m_Width / zoom) < L_MIN_DESSIN )
if( panel->GetScreen()->Scale( m_Width ) < L_MIN_DESSIN )
typeaff = FILAIRE;
switch( type_trace )
......@@ -158,12 +155,15 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
{
if( typeaff == FILLED )
{
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon, m_Width, color );
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon,
m_Width, color );
}
else // SKETCH Mode
{
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon + (m_Width / 2), color );
GRCircle( &panel->m_ClipBox, DC, ux0, uy0, rayon - (m_Width / 2), color );
GRCircle( &panel->m_ClipBox, DC, ux0, uy0,
rayon + (m_Width / 2), color );
GRCircle( &panel->m_ClipBox, DC, ux0, uy0,
rayon - (m_Width / 2), color );
}
}
break;
......@@ -176,7 +176,8 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
EXCHG( StAngle, EndAngle );
if( typeaff == FILAIRE )
{
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle, rayon, color );
GRArc( &panel->m_ClipBox, DC, ux0, uy0, StAngle, EndAngle,
rayon, color );
}
else if( typeaff == FILLED )
{
......@@ -193,7 +194,6 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
break;
case S_POLYGON:
{
// We must compute true coordinates from m_PolyPoints
// which are relative to module position, orientation 0
......@@ -216,7 +216,6 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
GRPoly( &panel->m_ClipBox, DC, points.size(), &points[0],
TRUE, m_Width, color, color );
}
break;
}
}
......
......@@ -161,8 +161,7 @@ bool MARKER::HitTest( const wxPoint& refPos )
wxSize TrueSize = m_Size;
if ( ActiveScreen )
{
TrueSize.x *= ActiveScreen->GetZoom();
TrueSize.y *= ActiveScreen->GetZoom();
ActiveScreen->Unscale( TrueSize );
}
wxPoint pos = GetPosition();
......
......@@ -106,7 +106,6 @@ void MIREPCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int rayon, ox, oy, gcolor, width;
int dx1, dx2, dy1, dy2;
int typeaff;
int zoom;
ox = m_Pos.x + offset.x;
oy = m_Pos.y + offset.y;
......@@ -115,12 +114,10 @@ void MIREPCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
if( (gcolor & ITEM_NOT_SHOW) != 0 )
return;
zoom = panel->GetZoom();
GRSetDrawMode( DC, mode_color );
typeaff = DisplayOpt.DisplayDrawItems;
width = m_Width;
if( width / zoom < 2 )
if( panel->GetScreen()->Scale( width ) < 2 )
typeaff = FILAIRE;
/* Trace du cercle: */
......
......@@ -32,8 +32,7 @@ void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset
* (doit etre fait apres les pads,
* car le trace du trou efface tout donc peut etre l'ancre */
{
int zoom = panel->GetZoom();
int anchor_size = dim_ancre * zoom;
int anchor_size = panel->GetScreen()->Unscale( dim_ancre );
GRSetDrawMode( DC, draw_mode );
......
......@@ -30,7 +30,6 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
xc, yc;
int angle;
wxPoint coord[4];
int zoom;
int fillpad = 0;
wxPoint shape_pos;
......@@ -39,7 +38,6 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
wxASSERT( panel );
zoom = panel->GetZoom();
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->m_Parent;
PCB_SCREEN* screen = frame->GetScreen();
......@@ -341,7 +339,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
switch( m_DrillShape )
{
case PAD_CIRCLE:
if( (hole / zoom) > 1 ) /* draw hole if its size is enought */
if( screen->Scale( hole ) > 1 ) /* draw hole if its size is enought */
GRFilledCircle( &panel->m_ClipBox, DC, cx0, cy0, hole, 0, color, color );
break;
......@@ -435,7 +433,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
int tsize = min( AreaSize.y, AreaSize.x / numpad_len );
#define CHAR_SIZE_MIN 5
if( (tsize / zoom) >= CHAR_SIZE_MIN ) // Not drawable when size too small.
if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable when size too small.
{
tsize = (int) (tsize * 0.8); // reserve room for marges and segments thickness
......@@ -450,7 +448,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
shortname_len = MAX( shortname_len, MIN_CHAR_COUNT);
tsize = min( AreaSize.y, AreaSize.x / shortname_len );
if( (tsize / zoom) >= CHAR_SIZE_MIN ) // Not drawable in size too small.
if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too small.
{
tpos = tpos0;
tpos.y += AreaSize.y / 2;
......
......@@ -353,7 +353,6 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const
* @param draw_mode = GR_OR, GR_XOR..
*/
{
int zoom;
int width, color, orient;
wxSize size;
wxPoint pos; // Centre du texte
......@@ -367,7 +366,6 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const
screen = (PCB_SCREEN*) panel->GetScreen();
frame = (WinEDA_BasePcbFrame*) panel->m_Parent;
zoom = screen->GetZoom();
pos.x = m_Pos.x - offset.x;
pos.y = m_Pos.y - offset.y;
......@@ -376,7 +374,8 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const
orient = GetDrawRotation();
width = m_Width;
if( (frame->m_DisplayModText == FILAIRE) || ( (width / zoom) < L_MIN_DESSIN ) )
if( (frame->m_DisplayModText == FILAIRE)
|| ( screen->Scale( width ) < L_MIN_DESSIN ) )
width = 0;
else if( frame->m_DisplayModText == SKETCH )
width = -width;
......@@ -386,7 +385,7 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const
/* trace du centre du texte */
if( (g_AnchorColor & ITEM_NOT_SHOW) == 0 )
{
int anchor_size = 2 * zoom;
int anchor_size = screen->Unscale( 2 );
GRLine( &panel->m_ClipBox, DC,
pos.x - anchor_size, pos.y,
pos.x + anchor_size, pos.y, 0, g_AnchorColor );
......
......@@ -535,7 +535,6 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
{
int l_piste;
int color;
int zoom;
int rayon;
int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
......@@ -545,7 +544,8 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
if( m_Flags & DRAW_ERASED ) // draw in background color, used by classs TRACK in gerbview
{
color = g_DrawBgColor;
D( printf( "DRAW_ERASED in Track::Draw, g_DrawBgColor=%04X\n", g_DrawBgColor ); )
D( printf( "DRAW_ERASED in Track::Draw, g_DrawBgColor=%04X\n",
g_DrawBgColor ); )
}
else
{
......@@ -579,7 +579,6 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
GRSetDrawMode( DC, draw_mode );
zoom = panel->GetZoom();
l_piste = m_Width >> 1;
......@@ -587,13 +586,13 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
{
rayon = (int) hypot( (double) ( m_End.x - m_Start.x ),
(double) ( m_End.y - m_Start.y ) );
if( (l_piste / zoom) < L_MIN_DESSIN )
if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN )
{
GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color );
}
else
{
if( l_piste <= zoom ) /* Sketch mode if l_piste/zoom <= 1 */
if( panel->GetScreen()->Scale( l_piste ) <= 1 ) /* Sketch mode if l_piste/zoom <= 1 */
{
GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color );
}
......@@ -611,7 +610,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
return;
}
if( (l_piste / zoom) < L_MIN_DESSIN )
if( panel->GetScreen()->Scale( l_piste ) < L_MIN_DESSIN )
{
GRLine( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
m_End.x, m_End.y, 0, color );
......@@ -658,7 +657,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
if( len < THRESHOLD * m_Width )
return;
if( ( m_Width / zoom) < 6 ) // no room to display a text inside track
if( panel->GetScreen()->Scale( m_Width ) < 6 ) // no room to display a text inside track
return;
if( GetNet() == 0 )
......@@ -680,7 +679,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
int angle = 0;
if ( (m_End.x - m_Start.x) == 0 ) // Vertical segment
angle = 900; // angle is in 0.1 degree
if( ( tsize / zoom) >= 6 )
if( panel->GetScreen()->Scale( tsize ) >= 6 )
{
tsize = (tsize * 8) / 10; // small reduction to give a better look
DrawGraphicText( panel, DC, tpos,
......@@ -696,7 +695,6 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi
/*******************************************************************************************/
{
int color;
int zoom;
int rayon;
int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
......@@ -729,18 +727,18 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi
SetAlpha( &color, 150 );
zoom = panel->GetZoom();
rayon = m_Width >> 1;
if( rayon < zoom )
rayon = zoom;
if( panel->GetScreen()->Scale( rayon ) <= 4 )
{
GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color );
if( rayon <= (4 * zoom) ) // Size too small: cannot be drawn
return;
}
GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y, rayon, color );
int drill_rayon = GetDrillValue() / 2;
int inner_rayon = rayon - (2 * zoom);
int inner_rayon = rayon - panel->GetScreen()->Unscale( 2 );
GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
inner_rayon, color );
......@@ -830,7 +828,7 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi
{
// calculate a good size for the text
int tsize = m_Width / len;
if( ( tsize / zoom) >= 6 )
if( panel->GetScreen()->Scale( tsize ) >= 6 )
{
tsize = (tsize * 8) / 10; // small reduction to give a better look, inside via
DrawGraphicText( panel, DC, m_Start,
......
......@@ -6,7 +6,7 @@
#define CLASS_ZONE_H
#include <vector>
#include "gr_basic.h"
#include "PolyLine.h"
......
......@@ -4,7 +4,6 @@
/**********************************************************************/
#include "fctsys.h"
#include "wxstruct.h"
#include "common.h"
#include "pcbnew.h"
......@@ -13,6 +12,13 @@
#include "id.h"
/* Default PCB zoom coefficients. */
static const int PcbZoomList[] = { 5, 10, 15, 20, 40, 80, 160, 320, 640, 1280,
2560, 5120, 10240, 20480 };
#define PCB_ZOOM_LIST_CNT ( sizeof( PcbZoomList ) / sizeof( int ) )
/* Default grid sizes for PCB editor screens. */
static GRID_TYPE PcbGridList[] = {
{ ID_POPUP_GRID_LEVEL_1000, wxSize( 1000, 1000 ) },
......@@ -40,15 +46,13 @@ PCB_SCREEN::PCB_SCREEN( ) : BASE_SCREEN( TYPE_SCREEN )
{
size_t i;
// a zero terminated list
static const int zoom_list[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256,
512, 1024, 2048, 0 };
for( i = 0; i < PCB_ZOOM_LIST_CNT; i++ )
m_ZoomList.Add( PcbZoomList[i] );
for( i = 0; i < PCB_GRID_LIST_CNT; i++ )
AddGrid( PcbGridList[i] );
SetGrid( wxSize( 500, 500 ) ); /* pas de la grille en 1/10000 "*/
SetZoomList( zoom_list );
Init();
}
......
......@@ -482,7 +482,6 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
/*****************************************************************/
{
wxSize delta;
int zoom = GetScreen()->GetZoom();
wxPoint curpos, oldpos;
int hotkey = 0;
......@@ -517,7 +516,8 @@ void WinEDA_BasePcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGrid() / zoom;
delta = GetScreen()->GetGrid();
GetScreen()->Scale( delta );
if( delta.x <= 0 )
delta.x = 1;
......
......@@ -157,7 +157,6 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
m_Draw_Axis = TRUE; // TRUE pour avoir les axes dessines
m_Draw_Grid = TRUE; // TRUE pour avoir la axes dessinee
m_Draw_Sheet_Ref = FALSE; // TRUE pour avoir le cartouche dessin�
m_ZoomMaxValue = 1024;
// Give an icon
SetIcon( wxICON( icon_modedit ) );
......@@ -351,17 +350,15 @@ void WinEDA_ModuleEditFrame::SetToolbars()
if( m_SelZoomBox )
{
int old_choice = m_SelZoomBox->GetChoice();
int new_choice = 1;
int zoom;
for( jj = 1, zoom = 1; zoom <= m_ZoomMaxValue; zoom <<= 1, jj++ )
for( jj = 0; jj < GetScreen()->m_ZoomList.GetCount(); jj++ )
{
if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[jj] )
{
if( GetScreen() && (GetScreen()->GetZoom() == zoom) )
m_SelZoomBox->SetSelection( jj + 1 );
break;
new_choice++;
}
if( old_choice != new_choice )
m_SelZoomBox->SetSelection( new_choice );
}
}
if( m_SelGridBox && GetScreen() )
......
......@@ -207,7 +207,6 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
m_SelTrackWidthBox = NULL;
m_SelViaSizeBox = NULL;
m_SelLayerBox = NULL;
m_ZoomMaxValue = 2048;
m_SelTrackWidthBox_Changed = FALSE;
m_SelViaSizeBox_Changed = FALSE;
......@@ -542,19 +541,14 @@ void WinEDA_PcbFrame::SetToolbars()
if( m_SelZoomBox )
{
int old_choice = m_SelZoomBox->GetChoice();
int new_choice = 1;
int zoom;
for( jj = 1, zoom = 1; zoom <= m_ZoomMaxValue; zoom <<= 1, jj++ )
for( jj = 0; jj < (int)GetScreen()->m_ZoomList.GetCount(); jj++ )
{
if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[jj] )
{
if( GetScreen() && (GetScreen()->GetZoom() == zoom) )
m_SelZoomBox->SetSelection( jj + 1 );
break;
new_choice++;
}
if( old_choice != new_choice )
m_SelZoomBox->SetSelection( new_choice );
}
}
if( m_SelGridBox && GetScreen() )
......@@ -575,8 +569,6 @@ void WinEDA_PcbFrame::SetToolbars()
}
UpdateToolbarLayerInfo();
PrepareLayerIndicator();
DisplayUnitsMsg();
}
......@@ -284,9 +284,9 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar()
wxSize( LISTBOX_WIDTH, -1 ) );
msg = _( "Auto" );
m_SelZoomBox->Append( msg );
for( int jj = 0, ii = 1; ii <= m_ZoomMaxValue; ii <<= 1, jj++ )
for( int i = 0; i < (int)GetScreen()->m_ZoomList.GetCount(); i++ )
{
msg.Printf( _( "Zoom %d" ), ii );
msg.Printf( _( "Zoom %d" ), GetScreen()->m_ZoomList[i] );
m_SelZoomBox->Append( msg );
}
......
......@@ -589,9 +589,10 @@ void WinEDA_PcbFrame::ReCreateAuxiliaryToolbar()
wxSize( LISTBOX_WIDTH, -1 ) );
msg = _( "Auto" );
m_SelZoomBox->Append( msg );
for( int jj = 0, ii = 1; ii <= m_ZoomMaxValue; ii <<= 1, jj++ )
for( int i = 0; i < (int)GetScreen()->m_ZoomList.GetCount(); i++ )
{
msg = _( "Zoom " ); msg << ii;
msg = _( "Zoom " );
msg << GetScreen()->m_ZoomList[i];
m_SelZoomBox->Append( msg );
}
......
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