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.
This commit is contained in:
jean-pierre charras 2011-04-09 20:53:39 +02:00
parent ea7dfc355b
commit c2ff1d9416
8 changed files with 67 additions and 58 deletions

View File

@ -32,6 +32,38 @@ option(USE_BOOST_POLYGON_LIBRARY
"Use boost polygon library instead of Kbool to calculate filled areas in zones (default ON)." "Use boost polygon library instead of Kbool to calculate filled areas in zones (default ON)."
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. # Set flags for GCC.
#================================================ #================================================

View File

@ -6,14 +6,19 @@
#endif #endif
#ifndef KICAD_BUILD_VERSION #ifndef KICAD_BUILD_VERSION
#define KICAD_BUILD_VERSION "(2011-04-05)" #define KICAD_BUILD_VERSION "(2011-04-09)"
#endif #endif
// uncomment this line only when creating a stable version
//#define VERSION_STABILITY "stable"
#ifndef VERSION_STABILITY #if defined KICAD_TESTING_VERSION
#define VERSION_STABILITY "testing" # 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 #endif
/** /**

View File

@ -80,7 +80,6 @@ wxString SCH_EDIT_FRAME::SelectFromLibBrowser( void )
} }
m_ViewlibFrame = new LIB_VIEW_FRAME( this, NULL, &semaphore ); m_ViewlibFrame = new LIB_VIEW_FRAME( this, NULL, &semaphore );
m_ViewlibFrame->AdjustScrollBars( wxPoint( 0 , 0 ) );
// Show the library viewer frame until it is closed // Show the library viewer frame until it is closed
while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event
{ {

View File

@ -699,7 +699,6 @@ void SCH_EDIT_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
else else
{ {
m_ViewlibFrame = new LIB_VIEW_FRAME( this ); m_ViewlibFrame = new LIB_VIEW_FRAME( this );
m_ViewlibFrame->AdjustScrollBars( wxPoint( 0 , 0 ) );
} }
} }

View File

@ -26,7 +26,6 @@ wxString LIB_VIEW_FRAME::m_libraryName;
wxString LIB_VIEW_FRAME::m_entryName; wxString LIB_VIEW_FRAME::m_entryName;
int LIB_VIEW_FRAME::m_unit = 1; int LIB_VIEW_FRAME::m_unit = 1;
int LIB_VIEW_FRAME::m_convert = 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. // When the viewer is used to select a component in schematic, the selected component is here.
wxString LIB_VIEW_FRAME::m_exportToEeschemaCmpName; wxString LIB_VIEW_FRAME::m_exportToEeschemaCmpName;
@ -174,14 +173,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph
if( DrawPanel ) if( DrawPanel )
DrawPanel->SetAcceleratorTable( table ); DrawPanel->SetAcceleratorTable( table );
#ifdef USE_WX_GRAPHICS_CONTEXT
GetScreen()->SetZoom( BestZoom() );
#else
Zoom_Automatique( false );
#endif
Show( TRUE );
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
wxAuiPaneInfo horiz; 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)); pane.MinSize(wxSize(m_CmpListSize.x, -1));
m_auimgr.Update(); 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 LIB_VIEW_FRAME::BestZoom()
{ {
int bestzoom, ii, jj; LIB_COMPONENT* component = NULL;
wxSize size;
LIB_COMPONENT* component;
CMP_LIBRARY* lib; CMP_LIBRARY* lib;
int bestzoom = 16; // default value for bestzoom
GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) );
bestzoom = 16;
lib = CMP_LIBRARY::FindLibrary( m_libraryName ); lib = CMP_LIBRARY::FindLibrary( m_libraryName );
if( lib == NULL ) if( lib )
return bestzoom; component = lib->FindComponent( m_entryName );
component = lib->FindComponent( m_entryName );
if( component == NULL ) if( component == NULL )
{
GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) );
return bestzoom; 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 ); EDA_RECT BoundaryBox = component->GetBoundingBox( m_unit, m_convert );
// Reserve a 25 mils margin around component bounding box. // Reserve a 10% margin around component bounding box.
size -= wxSize( 25, 25 ); double zx =(double) BoundaryBox.GetWidth() / ( 0.8 * (double)size.x ) *
ii = wxRound( ( (double) BoundaryBox.GetWidth() / double( size.x ) ) * (double) GetScreen()->m_ZoomScalar;
(double) GetScreen()->m_ZoomScalar ); double zy = (double) BoundaryBox.GetHeight() / ( 0.8 * (double)size.y) *
jj = wxRound( ( (double) BoundaryBox.GetHeight() / (double) size.y ) * (double) GetScreen()->m_ZoomScalar;
(double) GetScreen()->m_ZoomScalar ); bestzoom = wxRound( MAX( zx, zy ) );
bestzoom = MAX( ii, jj ) + 1;
#if defined( __WINDOWS__ ) && !wxCHECK_VERSION(2, 9, 1) #if defined( __WINDOWS__ ) && !wxCHECK_VERSION(2, 9, 1)
/* This is a workaround: wxWidgets (wxMSW) before version 2.9 seems have /* This is a workaround: wxWidgets (wxMSW) before version 2.9 seems have

View File

@ -44,7 +44,6 @@ protected:
// in schematic, the selected component is here // in schematic, the selected component is here
static int m_unit; static int m_unit;
static int m_convert; static int m_convert;
static wxSize m_clientSize;
public: public:
LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library = NULL, wxSemaphore* semaphore = NULL ); LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library = NULL, wxSemaphore* semaphore = NULL );

View File

@ -17,7 +17,7 @@
; General Product Description Definitions ; General Product Description Definitions
!define PRODUCT_NAME "KiCad" !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 PRODUCT_WEB_SITE "http://iut-tice.ujf-grenoble.fr/kicad/"
!define SOURCEFORGE_WEB_SITE "http://kicad.sourceforge.net/" !define SOURCEFORGE_WEB_SITE "http://kicad.sourceforge.net/"
!define COMPANY_NAME "" !define COMPANY_NAME ""

View File

@ -1,4 +1,4 @@
release version: release version:
2011 apr 05 2011 apr 09
files (.zip,.tgz): files (.zip,.tgz):
kicad-2011-04-05 kicad-2011-04-09