Commit 393e0204 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Fix cursor warping out of client when zooming bug.

* Modify algorithm to correctly calculate the virtual drawing size and
  offset required to place the drawing correctly under all conditions.
* Ignore default wxWidgets scroll keys on Windows in EDA_DRAW_PANEL key
  event handler.
parent 7c171870
...@@ -87,13 +87,6 @@ void BASE_SCREEN::InitDatas() ...@@ -87,13 +87,6 @@ void BASE_SCREEN::InitDatas()
} }
/**
* Get screen units scalar.
*
* Default implementation returns scalar used for schematic screen. The
* internal units used by the schematic screen is 1 mil (0.001"). Override
* this in derived classes that require internal units other than 1 mil.
*/
int BASE_SCREEN::GetInternalUnits( void ) int BASE_SCREEN::GetInternalUnits( void )
{ {
return EESCHEMA_INTERNAL_UNIT; return EESCHEMA_INTERNAL_UNIT;
...@@ -119,23 +112,13 @@ void BASE_SCREEN::SetPageSize( wxSize& aPageSize ) ...@@ -119,23 +112,13 @@ void BASE_SCREEN::SetPageSize( wxSize& aPageSize )
} }
/**
* Function GetScalingFactor
* @return the the current scale used to draw items on screen
* draw coordinates are user coordinates * GetScalingFactor( )
*/
double BASE_SCREEN::GetScalingFactor() const double BASE_SCREEN::GetScalingFactor() const
{ {
double scale = 1.0 / GetZoom(); double scale = 1.0 / GetZoom();
return scale; return scale;
} }
/**
* Function SetScalingFactor
* calculates the .m_Zoom member to have a given scaling factor
* @param aScale - the the current scale used to draw items on screen
* draw coordinates are user coordinates * GetScalingFactor()
*/
void BASE_SCREEN::SetScalingFactor(double aScale ) void BASE_SCREEN::SetScalingFactor(double aScale )
{ {
double zoom = aScale; double zoom = aScale;
...@@ -152,6 +135,7 @@ void BASE_SCREEN::SetScalingFactor(double aScale ) ...@@ -152,6 +135,7 @@ void BASE_SCREEN::SetScalingFactor(double aScale )
SetZoom( zoom ); SetZoom( zoom );
} }
void BASE_SCREEN::SetZoomList( const wxArrayDouble& zoomlist ) void BASE_SCREEN::SetZoomList( const wxArrayDouble& zoomlist )
{ {
if( !m_ZoomList.IsEmpty() ) if( !m_ZoomList.IsEmpty() )
...@@ -293,7 +277,6 @@ void BASE_SCREEN::SetGrid( const wxRealPoint& size ) ...@@ -293,7 +277,6 @@ void BASE_SCREEN::SetGrid( const wxRealPoint& size )
} }
/* Set grid size from command ID. */
void BASE_SCREEN::SetGrid( int id ) void BASE_SCREEN::SetGrid( int id )
{ {
wxASSERT( !m_grids.empty() ); wxASSERT( !m_grids.empty() );
...@@ -462,6 +445,7 @@ wxPoint BASE_SCREEN::GetCrossHairScreenPosition() const ...@@ -462,6 +445,7 @@ wxPoint BASE_SCREEN::GetCrossHairScreenPosition() const
return pos; return pos;
} }
void BASE_SCREEN::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid ) void BASE_SCREEN::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid )
{ {
if( aSnapToGrid ) if( aSnapToGrid )
......
/*****************/ /*
/* drawframe.cpp */ * This program source code file is part of KiCad, a free EDA CAD application.
/*****************/ *
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifdef __GNUG__ /**
#pragma implementation * @file drawframe.cpp
#endif */
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
...@@ -23,10 +44,11 @@ ...@@ -23,10 +44,11 @@
#include <wx/fontdlg.h> #include <wx/fontdlg.h>
/* Definitions for enabling and disabling extra debugging output. Please /**
* remember to set these to 0 before committing changes to SVN. * Definition for enabling and disabling scroll bar setting trace output. See the
* wxWidgets documentation on useing the WXTRACE environment variable.
*/ */
#define DEBUG_DUMP_SCROLLBAR_SETTINGS 0 // Set to 1 to print scroll bar settings. static const wxString traceScrollSettings( wxT( "KicadScrollSettings" ) );
/* Configuration entry names. */ /* Configuration entry names. */
...@@ -83,7 +105,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* father, int idtype, const wxString& ti ...@@ -83,7 +105,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* father, int idtype, const wxString& ti
m_Draw_Axis = FALSE; // TRUE to draw axis. m_Draw_Axis = FALSE; // TRUE to draw axis.
m_Draw_Sheet_Ref = FALSE; // TRUE to display reference sheet. m_Draw_Sheet_Ref = FALSE; // TRUE to display reference sheet.
m_Print_Sheet_Ref = TRUE; // TRUE to print reference sheet. m_Print_Sheet_Ref = TRUE; // TRUE to print reference sheet.
m_Draw_Auxiliary_Axis = FALSE; // TRUE draw auxilary axis. m_Draw_Auxiliary_Axis = FALSE; // TRUE draw auxiliary axis.
m_Draw_Grid_Axis = FALSE; // TRUE to draw the grid axis m_Draw_Grid_Axis = FALSE; // TRUE to draw the grid axis
m_CursorShape = 0; m_CursorShape = 0;
m_LastGridSizeId = 0; m_LastGridSizeId = 0;
...@@ -253,44 +275,32 @@ void EDA_DRAW_FRAME::OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent ) ...@@ -253,44 +275,32 @@ void EDA_DRAW_FRAME::OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent )
} }
// Virtual function
void EDA_DRAW_FRAME::ReCreateAuxiliaryToolbar() void EDA_DRAW_FRAME::ReCreateAuxiliaryToolbar()
{ {
} }
// Virtual function
void EDA_DRAW_FRAME::ReCreateMenuBar() void EDA_DRAW_FRAME::ReCreateMenuBar()
{ {
} }
// Virtual function
void EDA_DRAW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem ) void EDA_DRAW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
{ {
} }
// Virtual function
void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event ) void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event )
{ {
} }
/**
* Function PrintPage (virtual)
* used to print a page
* this basic function must be derived to be used for printing
* because EDA_DRAW_FRAME does not know how to print a page
* This is the reason it is a virtual function
*/
void EDA_DRAW_FRAME::PrintPage( wxDC* aDC,int aPrintMask, bool aPrintMirrorMode, void* aData ) void EDA_DRAW_FRAME::PrintPage( wxDC* aDC,int aPrintMask, bool aPrintMirrorMode, void* aData )
{ {
wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") ); wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
} }
// Virtual function
void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
{ {
int* clientData; int* clientData;
...@@ -352,14 +362,6 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) ...@@ -352,14 +362,6 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
} }
/**
* 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 EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
{ {
if( m_SelZoomBox == NULL ) if( m_SelZoomBox == NULL )
...@@ -388,7 +390,6 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) ...@@ -388,7 +390,6 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
} }
/* Return the current zoom level */
double EDA_DRAW_FRAME::GetZoom( void ) double EDA_DRAW_FRAME::GetZoom( void )
{ {
return GetScreen()->GetZoom(); return GetScreen()->GetZoom();
...@@ -401,7 +402,6 @@ void EDA_DRAW_FRAME::OnMouseEvent( wxMouseEvent& event ) ...@@ -401,7 +402,6 @@ void EDA_DRAW_FRAME::OnMouseEvent( wxMouseEvent& event )
} }
// Virtual
void EDA_DRAW_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) void EDA_DRAW_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
{ {
} }
...@@ -413,8 +413,6 @@ void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg ) ...@@ -413,8 +413,6 @@ void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
} }
/* Display current unit Selection on Statusbar
*/
void EDA_DRAW_FRAME::DisplayUnitsMsg() void EDA_DRAW_FRAME::DisplayUnitsMsg()
{ {
wxString msg; wxString msg;
...@@ -439,8 +437,6 @@ void EDA_DRAW_FRAME::DisplayUnitsMsg() ...@@ -439,8 +437,6 @@ void EDA_DRAW_FRAME::DisplayUnitsMsg()
/* Recalculate the size of toolbars and display panel.
*/
void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv ) void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
{ {
m_FrameSize = GetClientSize( ); m_FrameSize = GetClientSize( );
...@@ -470,10 +466,6 @@ void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg ) ...@@ -470,10 +466,6 @@ void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
} }
/*****************************/
/* default virtual functions */
/*****************************/
void EDA_DRAW_FRAME::OnGrid( int grid_type ) void EDA_DRAW_FRAME::OnGrid( int grid_type )
{ {
} }
...@@ -517,41 +509,134 @@ bool EDA_DRAW_FRAME::HandleBlockEnd( wxDC* DC ) ...@@ -517,41 +509,134 @@ bool EDA_DRAW_FRAME::HandleBlockEnd( wxDC* DC )
void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition ) void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
{ {
int unitsX, unitsY, posX, posY; int unitsX, unitsY, posX, posY;
wxSize drawingSize, clientSize; wxSize clientSize, logicalClientSize, virtualSize;
BASE_SCREEN* screen = GetScreen(); BASE_SCREEN* screen = GetScreen();
bool noRefresh = true; bool noRefresh = true;
if( screen == NULL || DrawPanel == NULL ) if( screen == NULL || DrawPanel == NULL )
return; return;
// The drawing size is twice the current page size. double scalar = screen->GetScalingFactor();
drawingSize = screen->ReturnPageSize() * 2;
wxLogTrace( traceScrollSettings, wxT( "Center Position = ( %d, %d ), scalar = %0.5f." ),
aCenterPosition.x, aCenterPosition.y, scalar );
// Calculate the portion of the drawing that can be displayed in the // Calculate the portion of the drawing that can be displayed in the
// client area at the current zoom level. // client area at the current zoom level.
clientSize = DrawPanel->GetClientSize(); clientSize = DrawPanel->GetClientSize();
double scalar = screen->GetScalingFactor(); // The logical size of the client window.
clientSize.x = wxRound( (double) clientSize.x / scalar ); logicalClientSize.x = wxRound( (double) clientSize.x / scalar );
clientSize.y = wxRound( (double) clientSize.y / scalar ); logicalClientSize.y = wxRound( (double) clientSize.y / scalar );
// The upper left corner of the drawing in device units.
int w = screen->ReturnPageSize().x;
int h = screen->ReturnPageSize().y;
/* Adjust drawing size when zooming way out to prevent centering around // The drawing rectangle logical units
* cursor problems. */ wxRect drawingRect( wxPoint( 0, 0 ), wxSize( w, h ) );
if( clientSize.x > drawingSize.x || clientSize.y > drawingSize.y )
drawingSize = clientSize;
drawingSize.x += wxRound( (double) clientSize.x / 2.0 ); wxLogTrace( traceScrollSettings, wxT( "Logical drawing rect = ( %d, %d, %d, %d )." ),
drawingSize.y += wxRound( (double) clientSize.y / 2.0 ); drawingRect.x, drawingRect.y, drawingRect.width, drawingRect.height );
wxLogTrace( traceScrollSettings, wxT( " left %d, right %d, top %d, bottome %d" ),
drawingRect.GetLeft(), drawingRect.GetRight(),
drawingRect.GetTop(), drawingRect.GetBottom() );
// The size of the client rectangle in logical units.
int x = wxRound( (double) aCenterPosition.x - ( (double) logicalClientSize.x / 2.0 ) );
int y = wxRound( (double) aCenterPosition.y - ( (double) logicalClientSize.y / 2.0 ) );
// If drawn around the center, adjust the client rectangle accordingly.
if( screen->m_Center ) if( screen->m_Center )
{ {
screen->m_DrawOrg.x = -wxRound( (double) drawingSize.x / 2.0 ); x += wxRound( (double) drawingRect.width / 2.0 );
screen->m_DrawOrg.y = -wxRound( (double) drawingSize.y / 2.0 ); y += wxRound( (double) drawingRect.height / 2.0 );
}
wxRect logicalClientRect( wxPoint( x, y ), logicalClientSize );
wxLogTrace( traceScrollSettings, wxT( "Logical client rect = ( %d, %d, %d, %d )." ),
logicalClientRect.x, logicalClientRect.y,
logicalClientRect.width, logicalClientRect.height );
wxLogTrace( traceScrollSettings, wxT( " left %d, right %d, top %d, bottome %d" ),
logicalClientRect.GetLeft(), logicalClientRect.GetRight(),
logicalClientRect.GetTop(), logicalClientRect.GetBottom() );
if( drawingRect == logicalClientRect )
{
virtualSize = drawingRect.GetSize();
}
else if( drawingRect.Contains( logicalClientRect ) )
{
virtualSize = drawingRect.GetSize();
} }
else else
{ {
screen->m_DrawOrg.x = -wxRound( (double) clientSize.x / 2.0 ); int drawingCenterX = drawingRect.x + ( drawingRect.width / 2 );
screen->m_DrawOrg.y = -wxRound( (double) clientSize.y / 2.0 ); int clientCenterX = logicalClientRect.x + ( logicalClientRect.width / 2 );
int drawingCenterY = drawingRect.y + ( drawingRect.height / 2 );
int clientCenterY = logicalClientRect.y + ( logicalClientRect.height / 2 );
if( logicalClientRect.width > drawingRect.width )
{
if( drawingCenterX > clientCenterX )
virtualSize.x = ( drawingCenterX - logicalClientRect.GetLeft() ) * 2;
else if( drawingCenterX < clientCenterX )
virtualSize.x = ( logicalClientRect.GetRight() - drawingCenterX ) * 2;
else
virtualSize.x = logicalClientRect.width;
}
else if( logicalClientRect.width < drawingRect.width )
{
if( drawingCenterX > clientCenterX )
virtualSize.x = drawingRect.width +
( (drawingRect.GetLeft() - logicalClientRect.GetLeft() ) * 2 );
else if( drawingCenterX < clientCenterX )
virtualSize.x = drawingRect.width +
( (logicalClientRect.GetRight() - drawingRect.GetRight() ) * 2 );
else
virtualSize.x = drawingRect.width;
}
else
{
virtualSize.x = drawingRect.width;
}
if( logicalClientRect.height > drawingRect.height )
{
if( drawingCenterY > clientCenterY )
virtualSize.y = ( drawingCenterY - logicalClientRect.GetTop() ) * 2;
else if( drawingCenterY < clientCenterY )
virtualSize.y = ( logicalClientRect.GetBottom() - drawingCenterY ) * 2;
else
virtualSize.y = logicalClientRect.height;
}
else if( logicalClientRect.height < drawingRect.height )
{
if( drawingCenterY > clientCenterY )
virtualSize.y = drawingRect.height +
( ( drawingRect.GetTop() - logicalClientRect.GetTop() ) * 2 );
else if( drawingCenterY < clientCenterY )
virtualSize.y = drawingRect.height +
( ( logicalClientRect.GetBottom() - drawingRect.GetBottom() ) * 2 );
else
virtualSize.y = drawingRect.height;
}
else
{
virtualSize.y = drawingRect.height;
}
}
if( screen->m_Center )
{
screen->m_DrawOrg.x = -( wxRound( (double) virtualSize.x / 2.0 ) );
screen->m_DrawOrg.y = -( wxRound( (double) virtualSize.y / 2.0 ) );
}
else
{
screen->m_DrawOrg.x = -( wxRound( (double) (virtualSize.x - drawingRect.width) / 2.0 ) );
screen->m_DrawOrg.y = -( wxRound( (double) (virtualSize.y - drawingRect.height) / 2.0 ) );
} }
/* Always set scrollbar pixels per unit to 1 unless you want the zoom /* Always set scrollbar pixels per unit to 1 unless you want the zoom
...@@ -562,36 +647,57 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition ) ...@@ -562,36 +647,57 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
*/ */
screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1; screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1;
// Calculate the number of scroll bar units for the given zoom level. */ // Calculate the number of scroll bar units for the given zoom level in device units.
unitsX = wxRound( (double) drawingSize.x * scalar ); unitsX = wxRound( (double) virtualSize.x * scalar );
unitsY = wxRound( (double) drawingSize.y * scalar ); unitsY = wxRound( (double) virtualSize.y * scalar );
// Calculate the position, place the cursor at the center of screen. // Calculate the scroll bar position in logical units to place the center position at
// the center of client rectangle.
screen->SetScrollCenterPosition( aCenterPosition ); screen->SetScrollCenterPosition( aCenterPosition );
posX = aCenterPosition.x - screen->m_DrawOrg.x; posX = aCenterPosition.x - wxRound( (double) logicalClientRect.width / 2.0 ) -
posY = aCenterPosition.y - screen->m_DrawOrg.y; screen->m_DrawOrg.x;
posY = aCenterPosition.y - wxRound( (double) logicalClientRect.height / 2.0 ) -
screen->m_DrawOrg.y;
posX -= wxRound( (double) clientSize.x / 2.0 ); // Convert scroll bar position to device units.
posY -= wxRound( (double) clientSize.y / 2.0 ); posX = wxRound( (double) posX * scalar );
posY = wxRound( (double) posY * scalar );
if( posX < 0 ) if( posX < 0 )
{
wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %d" ), posX );
posX = 0; posX = 0;
}
if( posX > unitsX )
{
wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %d" ), posX );
posX = unitsX;
}
if( posY < 0 ) if( posY < 0 )
{
wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %d" ), posY );
posY = 0; posY = 0;
}
posX = wxRound( (double) posX * scalar ); if( posY > unitsY )
posY = wxRound( (double) posY * scalar ); {
wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %d" ), posY );
posY = unitsY;
}
screen->m_ScrollbarPos = wxPoint( posX, posY ); screen->m_ScrollbarPos = wxPoint( posX, posY );
screen->m_ScrollbarNumber = wxSize( unitsX, unitsY ); screen->m_ScrollbarNumber = wxSize( unitsX, unitsY );
#if DEBUG_DUMP_SCROLLBAR_SETTINGS wxLogTrace( traceScrollSettings,
wxLogDebug( wxT( "SetScrollbars(%d, %d, %d, %d, %d, %d)" ), wxT( "Drawing = (%d, %d), Client = (%d, %d), Offset = (%d, %d), \
SetScrollbars(%d, %d, %d, %d, %d, %d)" ),
virtualSize.x, virtualSize.y, logicalClientSize.x, logicalClientSize.y,
screen->m_DrawOrg.x, screen->m_DrawOrg.y,
screen->m_ScrollPixelsPerUnitX, screen->m_ScrollPixelsPerUnitY, screen->m_ScrollPixelsPerUnitX, screen->m_ScrollPixelsPerUnitY,
screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.y, screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.y,
screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.y ); screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.y );
#endif
DrawPanel->SetScrollbars( screen->m_ScrollPixelsPerUnitX, DrawPanel->SetScrollbars( screen->m_ScrollPixelsPerUnitX,
screen->m_ScrollPixelsPerUnitY, screen->m_ScrollPixelsPerUnitY,
...@@ -602,11 +708,6 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition ) ...@@ -602,11 +708,6 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPosition )
} }
/**
* Function SetLanguage
* called on a language menu selection
* when using a derived function, do not forget to call this one
*/
void EDA_DRAW_FRAME::SetLanguage( wxCommandEvent& event ) void EDA_DRAW_FRAME::SetLanguage( wxCommandEvent& event )
{ {
EDA_BASE_FRAME::SetLanguage( event ); EDA_BASE_FRAME::SetLanguage( event );
...@@ -644,15 +745,6 @@ double RoundTo0( double x, double precision ) ...@@ -644,15 +745,6 @@ double RoundTo0( double x, double precision )
} }
/**
* Function UpdateStatusBar
* Displays in the bottom of the main window a stust:
* - Absolute Cursor coordinates
* - Relative Cursor coordinates (relative to the last coordinate stored
* when actiavte the space bar)
* ( in this status is also displayed the zoom level, but this is not made
* by this function )
*/
void EDA_DRAW_FRAME::UpdateStatusBar() void EDA_DRAW_FRAME::UpdateStatusBar()
{ {
wxString Line; wxString Line;
...@@ -740,12 +832,6 @@ void EDA_DRAW_FRAME::UpdateStatusBar() ...@@ -740,12 +832,6 @@ void EDA_DRAW_FRAME::UpdateStatusBar()
} }
/**
* Load draw frame specific configuration settings.
*
* Don't forget to call this base method from any derived classes or the
* settings will not get loaded.
*/
void EDA_DRAW_FRAME::LoadSettings() void EDA_DRAW_FRAME::LoadSettings()
{ {
wxASSERT( wxGetApp().m_EDA_Config != NULL ); wxASSERT( wxGetApp().m_EDA_Config != NULL );
...@@ -768,12 +854,6 @@ void EDA_DRAW_FRAME::LoadSettings() ...@@ -768,12 +854,6 @@ void EDA_DRAW_FRAME::LoadSettings()
} }
/**
* Save draw frame specific configuration settings.
*
* Don't forget to call this base method from any derived classes or the
* settings will not get saved.
*/
void EDA_DRAW_FRAME::SaveSettings() void EDA_DRAW_FRAME::SaveSettings()
{ {
wxASSERT( wxGetApp().m_EDA_Config != NULL ); wxASSERT( wxGetApp().m_EDA_Config != NULL );
......
...@@ -1162,7 +1162,24 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event ) ...@@ -1162,7 +1162,24 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
GetParent()->GeneralControl( &DC, pos, localkey ); GetParent()->GeneralControl( &DC, pos, localkey );
#ifdef __WINDOWS__ #ifdef __WINDOWS__
event.Skip(); // Allow menu shortcut processing on Windows. // Disable the default scrolling command keys which break KiCad's zooming and
// panning. This is also likely the reason skip was disabled for other platforms.
// There probably needs to be some more investigation done here.
switch( event.GetKeyCode() )
{
case WXK_HOME:
case WXK_END:
case WXK_PAGEUP:
case WXK_PAGEDOWN:
case WXK_UP:
case WXK_DOWN:
case WXK_LEFT:
case WXK_RIGHT:
break;
default:
event.Skip(); // Allow menu shortcut processing on Windows.
}
#endif #endif
} }
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/** /**
* @file viewlib_frame.cpp * @file viewlib_frame.cpp
*/ */
...@@ -24,13 +49,11 @@ wxString LIB_VIEW_FRAME::m_entryName; ...@@ -24,13 +49,11 @@ 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;
// 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;
/*****************************/
/* class WinEDA_ViewlibFrame */
/*****************************/
BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME ) BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME )
/* Window events */ /* Window events */
EVT_CLOSE( LIB_VIEW_FRAME::OnCloseWindow ) EVT_CLOSE( LIB_VIEW_FRAME::OnCloseWindow )
...@@ -212,8 +235,8 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph ...@@ -212,8 +235,8 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( wxWindow* father, CMP_LIBRARY* Library, wxSemaph
wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) ); wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) );
/* Now the minimum windows are fixed, set library list /* Now the minimum windows are fixed, set library list
and component list of the previous values from last viewlib use * and component list of the previous values from last viewlib use
*/ */
if( m_LibListWindow ) if( m_LibListWindow )
{ {
wxAuiPaneInfo& pane = m_auimgr.GetPane(m_LibListWindow); wxAuiPaneInfo& pane = m_auimgr.GetPane(m_LibListWindow);
...@@ -253,15 +276,13 @@ void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -253,15 +276,13 @@ void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
// This window will be destroyed by the calling function, // This window will be destroyed by the calling function,
// to avoid side effects // to avoid side effects
} }
else else
{
Destroy(); Destroy();
}
} }
/*
* Resize sub windows when dragging a sash window border
*/
void LIB_VIEW_FRAME::OnSashDrag( wxSashEvent& event ) void LIB_VIEW_FRAME::OnSashDrag( wxSashEvent& event )
{ {
if( event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE ) if( event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE )
...@@ -340,9 +361,9 @@ double LIB_VIEW_FRAME::BestZoom() ...@@ -340,9 +361,9 @@ double LIB_VIEW_FRAME::BestZoom()
// Reserve a 10% margin around component bounding box. // Reserve a 10% margin around component bounding box.
double margin_scale_factor = 0.8; double margin_scale_factor = 0.8;
double zx =(double) BoundaryBox.GetWidth() / double zx =(double) BoundaryBox.GetWidth() /
( margin_scale_factor * (double)size.x ); ( margin_scale_factor * (double)size.x );
double zy = (double) BoundaryBox.GetHeight() / double zy = (double) BoundaryBox.GetHeight() /
( margin_scale_factor * (double)size.y); ( margin_scale_factor * (double)size.y);
// Calculates the best zoom // Calculates the best zoom
bestzoom = MAX( zx, zy ); bestzoom = MAX( zx, zy );
...@@ -358,12 +379,6 @@ double LIB_VIEW_FRAME::BestZoom() ...@@ -358,12 +379,6 @@ double LIB_VIEW_FRAME::BestZoom()
} }
/**
* Function ReCreateListLib
*
* Creates or recreates the list of current loaded libraries.
* This list is sorted, with the library cache always at end of the list
*/
void LIB_VIEW_FRAME::ReCreateListLib() void LIB_VIEW_FRAME::ReCreateListLib()
{ {
if( m_LibList == NULL ) if( m_LibList == NULL )
...@@ -475,10 +490,6 @@ void LIB_VIEW_FRAME::ClickOnCmpList( wxCommandEvent& event ) ...@@ -475,10 +490,6 @@ void LIB_VIEW_FRAME::ClickOnCmpList( wxCommandEvent& event )
} }
/*
* Export the current component to schematic and close the library browser
*/
void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event ) void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event )
{ {
int ii = m_CmpList->GetSelection(); int ii = m_CmpList->GetSelection();
...@@ -496,12 +507,6 @@ void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event ) ...@@ -496,12 +507,6 @@ void LIB_VIEW_FRAME::ExportToSchematicLibraryPart( wxCommandEvent& event )
#define CMPLIST_WIDTH_KEY wxT( "Cmplist_width" ) #define CMPLIST_WIDTH_KEY wxT( "Cmplist_width" )
/**
* Load library viewer frame specific configuration settings.
*
* Don't forget to call this base method from any derived classes or the
* settings will not get loaded.
*/
void LIB_VIEW_FRAME::LoadSettings( ) void LIB_VIEW_FRAME::LoadSettings( )
{ {
wxConfig* cfg ; wxConfig* cfg ;
...@@ -526,12 +531,6 @@ void LIB_VIEW_FRAME::LoadSettings( ) ...@@ -526,12 +531,6 @@ void LIB_VIEW_FRAME::LoadSettings( )
} }
/**
* Save library viewer frame specific configuration settings.
*
* Don't forget to call this base method from any derived classes or the
* settings will not get saved.
*/
void LIB_VIEW_FRAME::SaveSettings() void LIB_VIEW_FRAME::SaveSettings()
{ {
wxConfig* cfg; wxConfig* cfg;
...@@ -547,9 +546,7 @@ void LIB_VIEW_FRAME::SaveSettings() ...@@ -547,9 +546,7 @@ void LIB_VIEW_FRAME::SaveSettings()
cfg->Write( CMPLIST_WIDTH_KEY, m_CmpListSize.x ); cfg->Write( CMPLIST_WIDTH_KEY, m_CmpListSize.x );
} }
/** Called on activate the frame.
* Reload the libraries lists that can be changed by the schematic editor or the library editor
*/
void LIB_VIEW_FRAME::OnActivate( wxActivateEvent& event ) void LIB_VIEW_FRAME::OnActivate( wxActivateEvent& event )
{ {
EDA_DRAW_FRAME::OnActivate( event ); EDA_DRAW_FRAME::OnActivate( event );
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file viewlib_frame.h
*/
#ifndef __LIBVIEWFRM_H__ #ifndef __LIBVIEWFRM_H__
#define __LIBVIEWFRM_H__ #define __LIBVIEWFRM_H__
...@@ -50,8 +79,22 @@ public: ...@@ -50,8 +79,22 @@ public:
~LIB_VIEW_FRAME(); ~LIB_VIEW_FRAME();
void OnSize( wxSizeEvent& event ); void OnSize( wxSizeEvent& event );
/**
* Function OnSashDrag
* resizes the child windows when dragging a sash window border.
*/
void OnSashDrag( wxSashEvent& event ); void OnSashDrag( wxSashEvent& event );
/**
* Function ReCreateListLib
*
* Creates or recreates the list of current loaded libraries.
* This list is sorted, with the library cache always at end of the list
*/
void ReCreateListLib(); void ReCreateListLib();
void ReCreateListCmp(); void ReCreateListCmp();
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
void DisplayLibInfos(); void DisplayLibInfos();
...@@ -69,7 +112,22 @@ public: ...@@ -69,7 +112,22 @@ public:
void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
/**
* Function LoadSettings
* loads the library viewer frame specific configuration settings.
*
* Don't forget to call this base method from any derived classes or the
* settings will not get loaded.
*/
void LoadSettings(); void LoadSettings();
/**
* Function SaveSettings
* save library viewer frame specific configuration settings.
*
* Don't forget to call this base method from any derived classes or the
* settings will not get saved.
*/
void SaveSettings(); void SaveSettings();
wxString& GetEntryName( void ) const { return m_entryName; } wxString& GetEntryName( void ) const { return m_entryName; }
...@@ -79,12 +137,20 @@ public: ...@@ -79,12 +137,20 @@ public:
int GetConvert( void ) { return m_convert; } int GetConvert( void ) { return m_convert; }
private: private:
/** OnActivate event funtion( virtual ) /**
* Function OnActivate
* is called when the frame frame is activate to reload the libraries and component lists
* that can be changed by the schematic editor or the library editor.
*/ */
virtual void OnActivate( wxActivateEvent& event ); virtual void OnActivate( wxActivateEvent& event );
void SelectCurrentLibrary(); void SelectCurrentLibrary();
void SelectAndViewLibraryPart( int option ); void SelectAndViewLibraryPart( int option );
/**
* Function ExportToSchematicLibraryPart
* exports the current component to schematic and close the library browser.
*/
void ExportToSchematicLibraryPart( wxCommandEvent& event ); void ExportToSchematicLibraryPart( wxCommandEvent& event );
void ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag ); void ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag );
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
......
...@@ -171,15 +171,24 @@ public: ...@@ -171,15 +171,24 @@ public:
virtual void SetDrawItems( EDA_ITEM* aItem ) { m_drawList = aItem; } virtual void SetDrawItems( EDA_ITEM* aItem ) { m_drawList = aItem; }
void InitDatas(); void InitDatas();
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; } void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
wxString GetFileName() const { return m_fileName; } wxString GetFileName() const { return m_fileName; }
void SetPageSize( wxSize& aPageSize ); void SetPageSize( wxSize& aPageSize );
wxSize ReturnPageSize( void ); wxSize ReturnPageSize( void );
virtual int GetInternalUnits( void );
/**
* Function GetInternalUnits
* @return the screen units scalar.
*
* Default implementation returns scalar used for schematic screen. The
* internal units used by the schematic screen is 1 mil (0.001"). Override
* this in derived classes that require internal units other than 1 mil.
*/
virtual int GetInternalUnits( void );
/** /**
* Function GetCrossHairPosition * Function GetCrossHairPosition
...@@ -227,7 +236,7 @@ public: ...@@ -227,7 +236,7 @@ public:
* picked items are deleted by ClearUndoORRedoList() according to their * picked items are deleted by ClearUndoORRedoList() according to their
* status * status
*/ */
virtual void ClearUndoRedoList(); virtual void ClearUndoRedoList();
/** /**
* Function PushCommandToUndoList * Function PushCommandToUndoList
...@@ -236,7 +245,7 @@ public: ...@@ -236,7 +245,7 @@ public:
* reached * reached
* ( using ClearUndoORRedoList) * ( using ClearUndoORRedoList)
*/ */
virtual void PushCommandToUndoList( PICKED_ITEMS_LIST* aItem ); virtual void PushCommandToUndoList( PICKED_ITEMS_LIST* aItem );
/** /**
* Function PushCommandToRedoList * Function PushCommandToRedoList
...@@ -245,7 +254,7 @@ public: ...@@ -245,7 +254,7 @@ public:
* reached * reached
* ( using ClearUndoORRedoList) * ( using ClearUndoORRedoList)
*/ */
virtual void PushCommandToRedoList( PICKED_ITEMS_LIST* aItem ); virtual void PushCommandToRedoList( PICKED_ITEMS_LIST* aItem );
/** PopCommandFromUndoList /** PopCommandFromUndoList
* return the last command to undo and remove it from list * return the last command to undo and remove it from list
...@@ -271,12 +280,12 @@ public: ...@@ -271,12 +280,12 @@ public:
} }
void SetModify() { m_FlagModified = true; } void SetModify() { m_FlagModified = true; }
void ClrModify() { m_FlagModified = false;; } void ClrModify() { m_FlagModified = false;; }
void SetSave() { m_FlagSave = true; } void SetSave() { m_FlagSave = true; }
void ClrSave() { m_FlagSave = false; } void ClrSave() { m_FlagSave = false; }
int IsModify() { return m_FlagModified; } int IsModify() { return m_FlagModified; }
int IsSave() { return m_FlagSave; } int IsSave() { return m_FlagSave; }
//----<zoom stuff>--------------------------------------------------------- //----<zoom stuff>---------------------------------------------------------
...@@ -284,16 +293,16 @@ public: ...@@ -284,16 +293,16 @@ public:
/** /**
* Function GetScalingFactor * Function GetScalingFactor
* @return the the current scale used to draw items on screen * @return the the current scale used to draw items on screen
* draw coordinates are user coordinates * GetScalingFactor( ) * draw coordinates are user coordinates * GetScalingFactor()
*/ */
double GetScalingFactor() const; double GetScalingFactor() const;
/** /**
* Function SetScalingFactor * Function SetScalingFactor
* @param aScale = the the current scale used to draw items on screen * @param aScale = the the current scale used to draw items on screen
* draw coordinates are user coordinates * GetScalingFactor( ) * draw coordinates are user coordinates * GetScalingFactor()
*/ */
void SetScalingFactor( double aScale ); void SetScalingFactor( double aScale );
/** /**
* Function GetZoom * Function GetZoom
...@@ -301,26 +310,26 @@ public: ...@@ -301,26 +310,26 @@ public:
* Note: the zoom factor is NOT the scaling factor * Note: the zoom factor is NOT the scaling factor
* the scaling factor is m_ZoomScalar * GetZoom() * the scaling factor is m_ZoomScalar * GetZoom()
*/ */
double GetZoom() const; double GetZoom() const;
/** /**
* Function SetZoom * Function SetZoom
* adjusts the current zoom factor * adjusts the current zoom factor
* @param coeff - Zoom coefficient. * @param coeff - Zoom coefficient.
*/ */
bool SetZoom( double coeff ); bool SetZoom( double coeff );
/** /**
* Function SetZoomList * Function SetZoomList
* sets the list of zoom factors. * sets the list of zoom factors.
* @param aZoomList An array of zoom factors in ascending order, zero terminated * @param aZoomList An array of zoom factors in ascending order, zero terminated
*/ */
void SetZoomList( const wxArrayDouble& aZoomList ); void SetZoomList( const wxArrayDouble& aZoomList );
bool SetNextZoom(); bool SetNextZoom();
bool SetPreviousZoom(); bool SetPreviousZoom();
bool SetFirstZoom(); bool SetFirstZoom();
bool SetLastZoom(); bool SetLastZoom();
//----<grid stuff>---------------------------------------------------------- //----<grid stuff>----------------------------------------------------------
...@@ -329,7 +338,7 @@ public: ...@@ -329,7 +338,7 @@ public:
* *
* @return int - Currently selected grid command ID. * @return int - Currently selected grid command ID.
*/ */
int GetGridId(); int GetGridId();
/** /**
* Return the grid size of the currently selected grid. * Return the grid size of the currently selected grid.
...@@ -343,15 +352,20 @@ public: ...@@ -343,15 +352,20 @@ public:
* *
* @return GRID_TYPE - The currently selected grid. * @return GRID_TYPE - The currently selected grid.
*/ */
GRID_TYPE GetGrid(); GRID_TYPE GetGrid();
const wxPoint& GetGridOrigin(); const wxPoint& GetGridOrigin();
void SetGrid( const wxRealPoint& size ); void SetGrid( const wxRealPoint& size );
void SetGrid( int id );
void SetGridList( GRIDS& sizelist ); /**
void AddGrid( const GRID_TYPE& grid ); * Function SetGrid
void AddGrid( const wxRealPoint& size, int id ); * sets the grid size from command ID.
void AddGrid( const wxRealPoint& size, EDA_UNITS_T aUnit, int id ); */
void SetGrid( int id );
void SetGridList( GRIDS& sizelist );
void AddGrid( const GRID_TYPE& grid );
void AddGrid( const wxRealPoint& size, int id );
void AddGrid( const wxRealPoint& size, EDA_UNITS_T aUnit, int id );
/** /**
* Function GetGridCount(). * Function GetGridCount().
...@@ -359,7 +373,7 @@ public: ...@@ -359,7 +373,7 @@ public:
* *
* @returns - The size of the grid list. * @returns - The size of the grid list.
*/ */
size_t GetGridCount() const { return m_grids.size(); } size_t GetGridCount() const { return m_grids.size(); }
/** /**
* Function GetGrid() * Function GetGrid()
...@@ -368,7 +382,7 @@ public: ...@@ -368,7 +382,7 @@ public:
* @param aIndex - The grid list index. * @param aIndex - The grid list index.
* @return - The grid object at \a aIndex or the current grid if the grid list is empty. * @return - The grid object at \a aIndex or the current grid if the grid list is empty.
*/ */
GRID_TYPE& GetGrid( size_t aIndex ); GRID_TYPE& GetGrid( size_t aIndex );
/** /**
* Function GetGrids(). * Function GetGrids().
...@@ -376,7 +390,7 @@ public: ...@@ -376,7 +390,7 @@ public:
* *
* @param aList - List to copy to. * @param aList - List to copy to.
*/ */
void GetGrids( GRIDS& aList ); void GetGrids( GRIDS& aList );
void SetMousePosition( const wxPoint& aPosition ) { m_MousePosition = aPosition; } void SetMousePosition( const wxPoint& aPosition ) { m_MousePosition = aPosition; }
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/** /**
* @file wxBasePcbFrame.h * @file wxBasePcbFrame.h
* @brief Classes used in Pcbnew, CvPcb and GerbView. * @brief Classes used in Pcbnew, CvPcb and GerbView.
...@@ -100,6 +125,11 @@ public: ...@@ -100,6 +125,11 @@ public:
return (PCB_SCREEN*) EDA_DRAW_FRAME::GetScreen(); return (PCB_SCREEN*) EDA_DRAW_FRAME::GetScreen();
} }
/**
* Function BestZoom
* @return the "best" zoom to show the entire board or footprint on the screen.
*/
virtual double BestZoom(); virtual double BestZoom();
virtual void Show3D_Frame( wxCommandEvent& event ); virtual void Show3D_Frame( wxCommandEvent& event );
......
...@@ -557,6 +557,14 @@ public: ...@@ -557,6 +557,14 @@ public:
* grid size combobox on the toolbar. * grid size combobox on the toolbar.
*/ */
virtual void OnSelectGrid( wxCommandEvent& event ); virtual void OnSelectGrid( wxCommandEvent& event );
/**
* Functions OnSelectZoom
* sets the zoom factor when selected by the zoom list box in the main tool bar.
* @note List position 0 is fit to page
* List position >= 1 = zoom (1 to zoom max)
* Last list position is custom zoom not in zoom list.
*/
virtual void OnSelectZoom( wxCommandEvent& event ); virtual void OnSelectZoom( wxCommandEvent& event );
// Command event handlers shared by all applications derived from EDA_DRAW_FRAME. // Command event handlers shared by all applications derived from EDA_DRAW_FRAME.
...@@ -585,7 +593,12 @@ public: ...@@ -585,7 +593,12 @@ public:
*/ */
virtual void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ) { } virtual void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ) { }
/**
* Function OnSize
* recalculates the size of toolbars and display panel when the frame size changes.
*/
virtual void OnSize( wxSizeEvent& event ); virtual void OnSize( wxSizeEvent& event );
void OnEraseBackground( wxEraseEvent& SizeEvent ); void OnEraseBackground( wxEraseEvent& SizeEvent );
virtual void OnZoom( wxCommandEvent& event ); virtual void OnZoom( wxCommandEvent& event );
...@@ -608,7 +621,10 @@ public: ...@@ -608,7 +621,10 @@ public:
/* Return the zoom level which displays the full page on screen */ /* Return the zoom level which displays the full page on screen */
virtual double BestZoom() = 0; virtual double BestZoom() = 0;
/* Return the current zoom level */ /**
* Function GetZoom
* @return The current zoom level.
*/
double GetZoom( void ); double GetZoom( void );
void TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_width ); void TraceWorkSheet( wxDC* DC, BASE_SCREEN* screen, int line_width );
...@@ -655,6 +671,10 @@ public: ...@@ -655,6 +671,10 @@ public:
*/ */
virtual void UpdateStatusBar(); virtual void UpdateStatusBar();
/**
* Function DisplayUnitsMsg
* displays current unit pane on the status bar.
*/
void DisplayUnitsMsg(); void DisplayUnitsMsg();
/* Handlers for block commands */ /* Handlers for block commands */
...@@ -698,7 +718,22 @@ public: ...@@ -698,7 +718,22 @@ public:
void OnSockRequest( wxSocketEvent& evt ); void OnSockRequest( wxSocketEvent& evt );
void OnSockRequestServer( wxSocketEvent& evt ); void OnSockRequestServer( wxSocketEvent& evt );
/**
* Function LoadSettings
* loads the draw frame specific configuration settings.
*
* Don't forget to call this base method from any derived classes or the
* settings common to the draw frame will not get loaded.
*/
virtual void LoadSettings(); virtual void LoadSettings();
/**
* Funxtion SaveSettings
* saves the draw frame specific configuration settings.
*
* Don't forget to call this base method from any derived classes or the
* settings common to the draw frame will not get saved.
*/
virtual void SaveSettings(); virtual void SaveSettings();
/** /**
...@@ -1056,7 +1091,7 @@ static inline void AddMenuItem( wxMenu* aMenu, ...@@ -1056,7 +1091,7 @@ static inline void AddMenuItem( wxMenu* aMenu,
* Each panel has rows, starting at 0. Each row has positions starting at 0. Each item in a panel * Each panel has rows, starting at 0. Each row has positions starting at 0. Each item in a panel
* can have it's row and position set. * can have it's row and position set.
* *
* Eventually panels will be moveable. Each initialization function sets up the panel for this, * Eventually panels will be movable. Each initialization function sets up the panel for this,
* then after a //==// break has additional calls to anchor toolbars in a way that matches * then after a //==// break has additional calls to anchor toolbars in a way that matches
* present functionality. * present functionality.
*/ */
...@@ -1076,7 +1111,7 @@ public: ...@@ -1076,7 +1111,7 @@ public:
CloseButton( false ); CloseButton( false );
LeftDockable( false ); LeftDockable( false );
RightDockable( false ); RightDockable( false );
//==================== Remove calls below here for moveable toolbars // //==================== Remove calls below here for movable toolbars //
Gripper( false ); Gripper( false );
DockFixed( true ); DockFixed( true );
Movable( false ); Movable( false );
...@@ -1094,7 +1129,7 @@ public: ...@@ -1094,7 +1129,7 @@ public:
CloseButton( false ); CloseButton( false );
TopDockable( false ); TopDockable( false );
BottomDockable( false ); BottomDockable( false );
//==================== Remove calls below here for moveable toolbars // //==================== Remove calls below here for movable toolbars //
Gripper( false ); Gripper( false );
DockFixed( true ); DockFixed( true );
Movable( false ); Movable( false );
......
...@@ -122,9 +122,6 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard ) ...@@ -122,9 +122,6 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
} }
/**
* Return the "best" zoom, i.e. the zoom which shows the entire board on screen
*/
double PCB_BASE_FRAME::BestZoom( void ) double PCB_BASE_FRAME::BestZoom( void )
{ {
int dx, dy; int dx, dy;
...@@ -151,6 +148,7 @@ double PCB_BASE_FRAME::BestZoom( void ) ...@@ -151,6 +148,7 @@ double PCB_BASE_FRAME::BestZoom( void )
jj = 32.0; jj = 32.0;
double bestzoom = MAX( ii, jj ); double bestzoom = MAX( ii, jj );
GetScreen()->SetScrollCenterPosition( m_Pcb->m_BoundaryBox.Centre() ); GetScreen()->SetScrollCenterPosition( m_Pcb->m_BoundaryBox.Centre() );
return bestzoom ; return bestzoom ;
......
...@@ -314,6 +314,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, ...@@ -314,6 +314,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
m_InternalUnits = PCB_INTERNAL_UNIT; // Unites internes = 1/10000 inch m_InternalUnits = PCB_INTERNAL_UNIT; // Unites internes = 1/10000 inch
SetScreen( new PCB_SCREEN() ); SetScreen( new PCB_SCREEN() );
GetScreen()->m_Center = false; // PCB drawings start in the upper left corner.
// LoadSettings() *after* creating m_LayersManager, because LoadSettings() // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
// initialize parameters in m_LayersManager // initialize parameters in m_LayersManager
......
...@@ -156,7 +156,6 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); ...@@ -156,7 +156,6 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
} }
frame->Zoom_Automatique( true ); frame->Zoom_Automatique( true );
frame->GetScreen()->m_FirstRedraw = false;
/* Load file specified in the command line. */ /* Load file specified in the command line. */
if( fn.IsOk() ) if( fn.IsOk() )
......
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