From c2ff1d9416e19ea0e64d6f7185924d2adf43ef9d Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 9 Apr 2011 20:53:39 +0200 Subject: [PATCH] Viewlib: fix a zoom error (due to a call to BestZoom() made before the full window is built) CMake: add definition KICAD_TESTING_VERSION and KICAD_STABLE_VERSION. One of these 2 options *must* be now defined (i.e. run cmake with option -DKICAD_STABLE_VERSION or -DKICAD_TESTING_VERSION Stable and testing branches should be more easier to maintain. --- CMakeLists.txt | 32 ++++++++++++++ common/build_version.cpp | 15 ++++--- eeschema/getpart.cpp | 1 - eeschema/schframe.cpp | 1 - eeschema/viewlib_frame.cpp | 69 ++++++++++-------------------- eeschema/viewlib_frame.h | 1 - packaging/windows/nsis/install.nsi | 2 +- version.txt | 4 +- 8 files changed, 67 insertions(+), 58 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d26c8532a6..9710d7b588 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,38 @@ option(USE_BOOST_POLYGON_LIBRARY "Use boost polygon library instead of Kbool to calculate filled areas in zones (default ON)." ON ) +#One of these 2 option *must* be set to ON: +option(KICAD_STABLE_VERSION + "set this option to ON to build the stable version of KICAD. mainly used to set version ID (default OFF)" + ) + +option(KICAD_TESTING_VERSION + "set this option to ON to build the stable version of KICAD. mainly used to set version ID (default OFF)" + ) + +#Set version option (stable or testing) + +if (KICAD_STABLE_VERSION ) + if ( KICAD_TESTING_VERSION ) + message( FATAL_ERROR + "Please set to ON only one option KICAD_TESTING_VERSION or KICAD_STABLE_VERSION" ) + endif( KICAD_TESTING_VERSION ) + add_definitions(-DKICAD_STABLE_VERSION) + message( "Build stable version of Kicad" ) +else (KICAD_STABLE_VERSION ) + if (KICAD_TESTING_VERSION ) + add_definitions(-DKICAD_TESTING_VERSION) + message( "Build testing (unstable) version of Kicad" ) + else (KICAD_TESTING_VERSION ) + message( "Please set to ON one option of KICAD_TESTING_VERSION or KICAD_STABLE_VERSION" ) + message( "When calling cmake add option -DKICAD_STABLE_VERSION" ) + message( "or add option -DKICAD_TESTING_VERSION " ) + message( FATAL_ERROR "one option of KICAD_TESTING_VERSION or KICAD_STABLE_VERSION must be defined" ) + endif(KICAD_TESTING_VERSION ) +endif(KICAD_STABLE_VERSION ) + + + #================================================ # Set flags for GCC. #================================================ diff --git a/common/build_version.cpp b/common/build_version.cpp index 95af36f619..93422b828f 100644 --- a/common/build_version.cpp +++ b/common/build_version.cpp @@ -6,14 +6,19 @@ #endif #ifndef KICAD_BUILD_VERSION -#define KICAD_BUILD_VERSION "(2011-04-05)" +#define KICAD_BUILD_VERSION "(2011-04-09)" #endif -// uncomment this line only when creating a stable version -//#define VERSION_STABILITY "stable" -#ifndef VERSION_STABILITY -#define VERSION_STABILITY "testing" +#if defined KICAD_TESTING_VERSION +# define VERSION_STABILITY "testing" +#elif defined KICAD_STABLE_VERSION +# define VERSION_STABILITY "stable" +#else +# define VERSION_STABILITY "unknown" +# warning "unknown version stability" +# warning "please: when running CMAKE, add -DKICAD_TESTING_VERSION=ON" +# warning "or -DKICAD_STABLE_VERSION=ON option" #endif /** diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 0c326ae63c..44bd97b473 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -80,7 +80,6 @@ wxString SCH_EDIT_FRAME::SelectFromLibBrowser( void ) } m_ViewlibFrame = new LIB_VIEW_FRAME( this, NULL, &semaphore ); - m_ViewlibFrame->AdjustScrollBars( wxPoint( 0 , 0 ) ); // Show the library viewer frame until it is closed while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event { diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 47a94b0428..44b5d4e335 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -699,7 +699,6 @@ void SCH_EDIT_FRAME::OnOpenLibraryViewer( wxCommandEvent& event ) else { m_ViewlibFrame = new LIB_VIEW_FRAME( this ); - m_ViewlibFrame->AdjustScrollBars( wxPoint( 0 , 0 ) ); } } diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 286d0383de..692ae8b339 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -26,7 +26,6 @@ wxString LIB_VIEW_FRAME::m_libraryName; wxString LIB_VIEW_FRAME::m_entryName; int LIB_VIEW_FRAME::m_unit = 1; int LIB_VIEW_FRAME::m_convert = 1; -wxSize LIB_VIEW_FRAME::m_clientSize = wxSize( -1, -1 ); // When the viewer is used to select a component in schematic, the selected component is here. wxString LIB_VIEW_FRAME::m_exportToEeschemaCmpName; @@ -174,14 +173,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph if( DrawPanel ) DrawPanel->SetAcceleratorTable( table ); -#ifdef USE_WX_GRAPHICS_CONTEXT - GetScreen()->SetZoom( BestZoom() ); -#else - Zoom_Automatique( false ); -#endif - - Show( TRUE ); - m_auimgr.SetManagedWindow( this ); wxAuiPaneInfo horiz; @@ -233,6 +224,15 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph pane.MinSize(wxSize(m_CmpListSize.x, -1)); m_auimgr.Update(); + + // Now Drawpanel is sized, we can use BestZoom to show the component (if any) +#ifdef USE_WX_GRAPHICS_CONTEXT + GetScreen()->SetZoom( BestZoom() ); +#else + Zoom_Automatique( false ); +#endif + + Show( true ); } @@ -313,56 +313,31 @@ void LIB_VIEW_FRAME::OnSetRelativeOffset( wxCommandEvent& event ) int LIB_VIEW_FRAME::BestZoom() { - int bestzoom, ii, jj; - wxSize size; - LIB_COMPONENT* component; + LIB_COMPONENT* component = NULL; CMP_LIBRARY* lib; - - GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) ); - bestzoom = 16; + int bestzoom = 16; // default value for bestzoom lib = CMP_LIBRARY::FindLibrary( m_libraryName ); - if( lib == NULL ) - return bestzoom; - - component = lib->FindComponent( m_entryName ); + if( lib ) + component = lib->FindComponent( m_entryName ); if( component == NULL ) + { + GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) ); return bestzoom; - - /* - * 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 = m_clientSize; - } + wxSize size = DrawPanel->GetClientSize(); EDA_RECT BoundaryBox = component->GetBoundingBox( m_unit, m_convert ); - // Reserve a 25 mils margin around component bounding box. - size -= wxSize( 25, 25 ); - ii = wxRound( ( (double) BoundaryBox.GetWidth() / double( size.x ) ) * - (double) GetScreen()->m_ZoomScalar ); - jj = wxRound( ( (double) BoundaryBox.GetHeight() / (double) size.y ) * - (double) GetScreen()->m_ZoomScalar ); - bestzoom = MAX( ii, jj ) + 1; + // Reserve a 10% margin around component bounding box. + double zx =(double) BoundaryBox.GetWidth() / ( 0.8 * (double)size.x ) * + (double) GetScreen()->m_ZoomScalar; + double zy = (double) BoundaryBox.GetHeight() / ( 0.8 * (double)size.y) * + (double) GetScreen()->m_ZoomScalar; + 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 diff --git a/eeschema/viewlib_frame.h b/eeschema/viewlib_frame.h index 2ffaba8f28..0df8f72915 100644 --- a/eeschema/viewlib_frame.h +++ b/eeschema/viewlib_frame.h @@ -44,7 +44,6 @@ protected: // in schematic, the selected component is here static int m_unit; static int m_convert; - static wxSize m_clientSize; public: LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library = NULL, wxSemaphore* semaphore = NULL ); diff --git a/packaging/windows/nsis/install.nsi b/packaging/windows/nsis/install.nsi index 92eebd0b62..21706f326e 100644 --- a/packaging/windows/nsis/install.nsi +++ b/packaging/windows/nsis/install.nsi @@ -17,7 +17,7 @@ ; General Product Description Definitions !define PRODUCT_NAME "KiCad" -!define PRODUCT_VERSION "2011.04.05" +!define PRODUCT_VERSION "2011.04.09" !define PRODUCT_WEB_SITE "http://iut-tice.ujf-grenoble.fr/kicad/" !define SOURCEFORGE_WEB_SITE "http://kicad.sourceforge.net/" !define COMPANY_NAME "" diff --git a/version.txt b/version.txt index 324fa4ca16..8a35394076 100644 --- a/version.txt +++ b/version.txt @@ -1,4 +1,4 @@ release version: -2011 apr 05 +2011 apr 09 files (.zip,.tgz): -kicad-2011-04-05 +kicad-2011-04-09