Modify my previous patch about zoom issues in eeschema (remove zoom limitations).

Also fix a minor zoom page issue in Libedit.
wxMSW, version 2.8.x must be patched.
Some zoom values smaller than 3 to 5 create artifacts on screen, mainly values < 1.
(corresponding to draw scale factor > 1 )

 * see http://trac.wxwidgets.org/ticket/9554
 
This is fixed in version 2.9.x
Workaround: ( that is not a full fix, but remaining artifacts are acceptable )
edit file  edit file <wxWidgets>/src/msw/dc.cpp
 >> search for line
    static const int VIEWPORT_EXTENT = 1000;
 >> and replace by
    static const int VIEWPORT_EXTENT = 10000;
This commit is contained in:
jean-pierre charras 2011-04-12 14:41:13 +02:00
parent 88118b7523
commit cc36a80e80
7 changed files with 131 additions and 95 deletions

View File

@ -33,8 +33,12 @@ If windows, then try running g++ and make from within your msys bash shell.
Install or Build wxWidgets
--------------------------
WARNING:
see wxWidgets_patch_notes.txt for patches and issues in wxWidgets.
If on windows, download
http://sourceforge.net/projects/wxwindows/files/wxAll/2.8.10/wxWidgets-2.8.10.zip/download
http://sourceforge.net/projects/wxwindows/files/wxAll/2.8.10/wxWidgets-2.8.12.zip/download
or a newer version.
Start msys so you have a bash shell. Decide where your wxWidgets build directory
will be. It must be where you can access it from within the msys environment,
@ -121,7 +125,11 @@ command prompt.
Obtain Sources
--------------
You can use the subversion repository or a tar file for this. See the wiki.
You can use the Launchpad repository or a tar file for this. See the wiki.
Launchpad repository handle 2 branches:
- a testing branch (used by developers)
- a stable branch (a copy of the testing branch, when this testing branch is near a stable state))
Create Makefiles with CMake
@ -183,6 +191,16 @@ Fine-tune Build Process
-----------------------
These should be set from command line:
One of these 2 option *must* be set to ON:
KICAD_STABLE_VERSION or KICAD_TESTING_VERSION
** KICAD_STABLE_VERSION:
set this option to ON to build the stable version of KICAD. mainly used to set version ID
Usually set for kicad version downloaded from stable branch
** KICAD_TESTING_VERSION
set this option to ON to build the stable version of KICAD. mainly used to set version ID
Usually set for kicad version downloaded from testing branch
CMAKE_BUILD_TYPE Release/Debug (REQUIRED)
Choose build type: Release/Debug.

View File

@ -20,6 +20,37 @@ So use a very recent version (>= 2.8.10 (that also solve other bugs)
wxWidgets patch:
wxMSW, version 2.8.x
Some zoom values smaller than 3 to 5 create artifacts on screen, mainly values < 1.
(corresponding to draw scale factor > 1 )
See http://trac.wxwidgets.org/ticket/9554 (and 11669).
This is fixed in version 2.9.x
This is a workaround that is not a full fix, but remaining artifacts are acceptable
edit file edit file <wxWidgets>/src/msw/dc.cpp
>> search for line
static const int VIEWPORT_EXTENT = 1000;
>> and replace by
static const int VIEWPORT_EXTENT = 10000;
wxWidgets 2.9.1 (all platforms)
Has a problem when using the built in string to double conversion:
In countries using a comm instead of a point as floating number separator
after calling this conversion function, the comma is changed in point.
(Happens after reading a parameter stored in a wxConfig structure, if this
parameter is a double)
Workaround:
Use a version > 2.9.2
Currently ( 2011, april 12 ) the 2.9.2 is not yet finalized
(and can be found only on the wxWidgets snv server)
can be fixed by replacing the file <wxWidgets-2.9.1>/src/common/xlocale.cpp
by the corresponding file from the 2.9.2 version (from wxWidgets svn server)
*************************************************************************************
wxGTK version: All
*************************************************************************************

View File

@ -209,8 +209,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
UpdateAliasSelectList();
UpdatePartSelectList();
Show( true );
m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz;
@ -243,6 +241,8 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
m_auimgr.Update();
Show( true );
wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED, ID_ZOOM_PAGE );
wxPostEvent( this, evt );
}
@ -344,7 +344,13 @@ void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
int LIB_EDIT_FRAME::BestZoom()
{
int dx, dy, ii, jj;
/* Please, note: wxMSW before version 2.9 seems have
* problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched:
* edit file <wxWidgets>/src/msw/dc.cpp
* search for line static const int VIEWPORT_EXTENT = 1000;
* and replace by static const int VIEWPORT_EXTENT = 10000;
*/
int dx, dy;
wxSize size;
EDA_RECT BoundaryBox;
@ -353,7 +359,8 @@ int LIB_EDIT_FRAME::BestZoom()
BoundaryBox = m_component->GetBoundingBox( m_unit, m_convert );
dx = BoundaryBox.GetWidth();
dy = BoundaryBox.GetHeight();
GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) );
GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 )
);
}
else
{
@ -362,43 +369,22 @@ int LIB_EDIT_FRAME::BestZoom()
GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) );
}
/*
* This fixes a bug where the client size of the drawing area is not
* correctly reported until after the window is shown. This is most
* likely due to the unmanaged windows ( vertical tool bars and message
* panel ) that are drawn in the main window which wxWidgets knows
* nothing about. When the library editor is reopened with a component
* already loading, the zoom will be calculated correctly.
*/
if( !IsShownOnScreen() )
{
if( m_clientSize != wxSize( -1, -1 ) )
size = m_clientSize;
else
size = DrawPanel->GetClientSize();
}
else
{
if( m_clientSize == wxSize( -1, -1 ) )
m_clientSize = DrawPanel->GetClientSize();
size = DrawPanel->GetClientSize();
size = m_clientSize;
}
// Reserve a 10% margin around component bounding box.
double margin_scale_factor = 0.8;
double zx =(double) dx / ( margin_scale_factor * (double)size.x ) *
(double) GetScreen()->m_ZoomScalar;
double zy = (double) dx / ( margin_scale_factor * (double)size.y) *
(double) GetScreen()->m_ZoomScalar;
size -= wxSize( 25, 25 ); // reserve 100 mils margin
ii = wxRound( ( (double) dx / (double) size.x ) * (double) GetScreen()->m_ZoomScalar );
jj = wxRound( ( (double) dy / (double) size.y ) * (double) GetScreen()->m_ZoomScalar );
int bestzoom = wxRound( MAX( zx, zy ) );
// keep it >= minimal existing zoom (can happen for very small components
// for instance when starting a new component
if( bestzoom < GetScreen()->m_ZoomList[0] )
bestzoom = GetScreen()->m_ZoomList[0];
int bestzoom = MAX( ii + 1, jj + 1 );
#if defined( __WINDOWS__ ) && !wxCHECK_VERSION(2, 9, 1)
/* This is a workaround: wxWidgets (wxMSW) before version 2.9 seems have
* problems with scale values < 1
* corresponding to values < GetScreen()->m_ZoomScalar
* So we keep bestzoom >= GetScreen()->m_ZoomScalar
*/
if( bestzoom < GetScreen()->m_ZoomScalar )
bestzoom = GetScreen()->m_ZoomScalar;
#endif
return bestzoom;
}

View File

@ -1,7 +1,7 @@
/**
* @file eeschema/menubar.cpp
* @brief (Re)Create the main menubar for the schematic frame
*/
*/
#ifdef __GNUG__
#pragma implementation
#endif
@ -230,21 +230,21 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
* using in AddHotkeyName call the option "false" (not a shortcut)
*/
// Zoom in
// Zoom in
text = AddHotkeyName( _( "Zoom In" ), s_Schematic_Hokeys_Descr,
ID_ZOOM_IN, false ); // add comment, not a shortcut
item = new wxMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, wxITEM_NORMAL );
SET_BITMAP( zoom_in_xpm );
viewMenu->Append( item );
// Zoom out
// Zoom out
text = AddHotkeyName( _( "Zoom Out" ), s_Schematic_Hokeys_Descr,
ID_ZOOM_OUT, false ); // add comment, not a shortcut
item = new wxMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, wxITEM_NORMAL );
SET_BITMAP( zoom_out_xpm );
viewMenu->Append( item );
// Fit on screen
// Fit on screen
text = AddHotkeyName( _( "Fit on Screen" ), s_Schematic_Hokeys_Descr, HK_ZOOM_AUTO );
item = new wxMenuItem( viewMenu, ID_ZOOM_PAGE, text, HELP_ZOOM_FIT, wxITEM_NORMAL );
@ -319,7 +319,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
SET_BITMAP( noconn_button );
placeMenu->Append( item );
// Net name
// Net name
text = AddHotkeyName( _( "Label" ), s_Schematic_Hokeys_Descr,
HK_ADD_LABEL, false ); // add comment, not a shortcut
item = new wxMenuItem( placeMenu, ID_LABEL_BUTT, text,
@ -327,7 +327,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
SET_BITMAP( add_line_label_xpm );
placeMenu->Append( item );
// Global label
// Global label
text = AddHotkeyName( _( "Global label" ), s_Schematic_Hokeys_Descr,
HK_ADD_GLABEL, false ); // add comment, not a shortcut
item = new wxMenuItem( placeMenu, ID_GLABEL_BUTT, text,
@ -349,12 +349,14 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
// Hierarchical label
text = AddHotkeyName( _( "Hierarchical label" ), s_Schematic_Hokeys_Descr,
HK_ADD_HLABEL, false ); // add comment, not a shortcut
item = new wxMenuItem( placeMenu, ID_HIERLABEL_BUTT, text,
HELP_PLACE_HIER_LABEL, wxITEM_NORMAL );
SET_BITMAP( add_hierarchical_label_xpm );
placeMenu->Append( item );
text = AddHotkeyName( _( "Hierarchical label" ), s_Schematic_Hokeys_Descr,
HK_ADD_HLABEL, false ); // add comment, not a shortcut
ADD_MENUITEM_WITH_HELP( placeMenu, ID_HIERLABEL_BUTT,
text, HELP_PLACE_HIER_LABEL,
add_hierarchical_label_xpm );
// Hierarchical sheet
// Hierarchical sheet
text = AddHotkeyName( _( "Hierarchical sheet" ), s_Schematic_Hokeys_Descr,
HK_ADD_HIER_SHEET, false ); // add comment, not a shortcut
item = new wxMenuItem( placeMenu, ID_SHEET_SYMBOL_BUTT, text,
@ -362,7 +364,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
SET_BITMAP( add_hierarchical_subsheet_xpm );
placeMenu->Append( item );
// Import hierarchical sheet
// Import hierarchical sheet
item = new wxMenuItem( placeMenu,
ID_IMPORT_HLABEL_BUTT,
_( "Import Hierarchical Label" ),
@ -370,7 +372,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
SET_BITMAP( import_hierarchical_label_xpm );
placeMenu->Append( item );
// Add hierarchical Pin to Sheet
// Add hierarchical Pin to Sheet
item = new wxMenuItem( placeMenu,
ID_SHEET_PIN_BUTT,
_( "Add Hierarchical Pin to Sheet" ),
@ -378,10 +380,10 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
SET_BITMAP( add_hierar_pin_xpm );
placeMenu->Append( item );
// Separator
// Separator
placeMenu->AppendSeparator();
// Graphic line or polygon
// Graphic line or polygon
text = AddHotkeyName( _( "Graphic polyline" ), s_Schematic_Hokeys_Descr,
HK_ADD_GRAPHIC_POLYLINE, false ); // add comment, not a shortcut
item = new wxMenuItem( placeMenu, ID_LINE_COMMENT_BUTT, text,
@ -389,7 +391,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
SET_BITMAP( add_dashed_line_xpm );
placeMenu->Append( item );
// Graphic text
// Graphic text
text = AddHotkeyName( _( "Graphic text" ), s_Schematic_Hokeys_Descr,
HK_ADD_GRAPHIC_TEXT, false ); // add comment, not a shortcut
item = new wxMenuItem( placeMenu, ID_TEXT_COMMENT_BUTT, text,
@ -401,7 +403,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
// Menu Preferences:
wxMenu* preferencesMenu = new wxMenu;
// Library
// Library
item = new wxMenuItem( preferencesMenu,
ID_CONFIG_REQ,
_( "&Library" ),

View File

@ -30,25 +30,18 @@
/* Default EESchema zoom values. Limited to 17 values to keep a decent size
* to menus
*/
#if defined( __WINDOWS__ ) && !wxCHECK_VERSION(2, 9, 1)
/* Please, note: wxWidgets (wxMSW) before version 2.9 seems have
* problems with scale values < 1
* because scale value is SchematicZoomList[x] / 10
* ( in fact is SchematicZoomList[x] / m_ZoomScalar )
* do not use values smaller than 10 without testing them under wxWidgets versions < 2.9
* value like 0.5 seems work
/* Please, note: wxMSW before version 2.9 seems have
* problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched:
* edit file <wxWidgets>/src/msw/dc.cpp
* search for line static const int VIEWPORT_EXTENT = 1000;
* and replace by static const int VIEWPORT_EXTENT = 10000;
* see http://trac.wxwidgets.org/ticket/9554
* This is a workaround that is not a full fix, but remaining artifacts are acceptable
*/
static int SchematicZoomList[] =
{
5, 10, 15, 20, 30, 40, 60, 80, 120, 160, 230, 320, 480, 640, 800, 1280
};
#else
static int SchematicZoomList[] =
{
5, 7, 10, 15, 20, 30, 40, 60, 80, 120, 160, 230, 320, 480, 640, 800, 1280
};
#endif
#define SCHEMATIC_ZOOM_LIST_CNT ( sizeof( SchematicZoomList ) / sizeof( int ) )
#define MM_TO_SCH_UNITS 1000.0 / 25.4 //schematic internal unites are mils

View File

@ -242,6 +242,9 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( wxWindow* father,
m_auimgr.AddPane( MsgPanel, wxAuiPaneInfo( horiz ).Name( wxT( "MsgPanel" ) ).Bottom() );
m_auimgr.Update();
// Now Drawpanel is sized, we can use BestZoom to show the component (if any)
BestZoom();
}
@ -428,22 +431,19 @@ int SCH_EDIT_FRAME::BestZoom()
dy = GetScreen()->m_CurrentSheetDesc->m_Size.y;
size = DrawPanel->GetClientSize();
int ii = wxRound( (double) dx / size.x * (double) GetScreen()->m_ZoomScalar );
int jj = wxRound( (double) dx / size.x * (double) GetScreen()->m_ZoomScalar );
int bestzoom = MAX( ii, jj );
// Reserve no margin because best zoom shows the full page
// and margins are already included in function that draws the sheet refernces
double margin_scale_factor = 1.0;
double zx =(double) dx / ( margin_scale_factor * (double)size.x ) *
(double) GetScreen()->m_ZoomScalar;
double zy = (double) dy / ( margin_scale_factor * (double)size.y) *
(double) GetScreen()->m_ZoomScalar;
int bestzoom = wxRound( MAX( zx, zy ) );
GetScreen()->SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) );
#if defined( __WINDOWS__ ) && !wxCHECK_VERSION(2, 9, 1)
/* This is a workaround: wxWidgets (wxMSW) before version 2.9 seems have
* problems with scale values < 1
* corresponding to values < GetScreen()->m_ZoomScalar
* So we keep bestzoom >= GetScreen()->m_ZoomScalar
*/
if( bestzoom < GetScreen()->m_ZoomScalar )
bestzoom = GetScreen()->m_ZoomScalar;
#endif
return bestzoom;
}

View File

@ -313,6 +313,12 @@ void LIB_VIEW_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
int LIB_VIEW_FRAME::BestZoom()
{
/* Please, note: wxMSW before version 2.9 seems have
* problems with zoom values < 1 ( i.e. userscale > 1) and needs to be patched:
* edit file <wxWidgets>/src/msw/dc.cpp
* search for line static const int VIEWPORT_EXTENT = 1000;
* and replace by static const int VIEWPORT_EXTENT = 10000;
*/
LIB_COMPONENT* component = NULL;
CMP_LIBRARY* lib;
int bestzoom = 16; // default value for bestzoom
@ -333,21 +339,21 @@ int LIB_VIEW_FRAME::BestZoom()
EDA_RECT BoundaryBox = component->GetBoundingBox( m_unit, m_convert );
// Reserve a 10% margin around component bounding box.
double zx =(double) BoundaryBox.GetWidth() / ( 0.8 * (double)size.x ) *
double margin_scale_factor = 0.8;
double zx =(double) BoundaryBox.GetWidth() /
( margin_scale_factor * (double)size.x ) *
(double) GetScreen()->m_ZoomScalar;
double zy = (double) BoundaryBox.GetHeight() / ( 0.8 * (double)size.y) *
double zy = (double) BoundaryBox.GetHeight() /
( margin_scale_factor * (double)size.y) *
(double) GetScreen()->m_ZoomScalar;
// Calculates the best zoom
bestzoom = wxRound( MAX( zx, zy ) );
#if defined( __WINDOWS__ ) && !wxCHECK_VERSION(2, 9, 1)
/* This is a workaround: wxWidgets (wxMSW) before version 2.9 seems have
* problems with scale values < 1
* corresponding to values < GetScreen()->m_ZoomScalar
* So we keep bestzoom >= GetScreen()->m_ZoomScalar
*/
if( bestzoom < GetScreen()->m_ZoomScalar )
bestzoom = GetScreen()->m_ZoomScalar;
#endif
// keep it >= minimal existing zoom (can happen for very small components
// like small power symbols
if( bestzoom < GetScreen()->m_ZoomList[0] )
bestzoom = GetScreen()->m_ZoomList[0];
GetScreen()->SetScrollCenterPosition( BoundaryBox.Centre() );