7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 18:11:42 +00:00

Cleanup some left-over vestiages of the legacy canvas architecture.

This commit is contained in:
Jeff Young 2019-06-13 14:34:38 +01:00
parent df08f9921f
commit ce1f35a1be
49 changed files with 229 additions and 904 deletions

View File

@ -54,19 +54,12 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) :
m_Grid.m_CmdId = ID_POPUP_GRID_LEVEL_50;
m_Center = true;
m_IsPrinting = false;
m_ScrollPixelsPerUnitX = 1;
m_ScrollPixelsPerUnitY = 1;
m_FlagModified = false; // Set when any change is made on board.
m_FlagSave = false; // Used in auto save set when an auto save is required.
}
BASE_SCREEN::~BASE_SCREEN()
{
}
void BASE_SCREEN::InitDataPoints( const wxSize& aPageSizeIU )
{
if( m_Center )
@ -86,35 +79,7 @@ void BASE_SCREEN::InitDataPoints( const wxSize& aPageSizeIU )
m_DrawOrg.y = 0;
}
m_O_Curseur.x = m_O_Curseur.y = 0;
}
double BASE_SCREEN::GetScalingFactor() const
{
double scale = 1.0 / GetZoom();
return scale;
}
void BASE_SCREEN::SetScalingFactor( double aScale )
{
// Limit zoom to max and min allowed values:
double zoom = Clamp( GetMinAllowedZoom(), aScale, GetMaxAllowedZoom() );
SetZoom( zoom );
}
bool BASE_SCREEN::SetFirstZoom()
{
return SetZoom( GetMinAllowedZoom() );
}
bool BASE_SCREEN::SetLastZoom()
{
return SetZoom( GetMaxAllowedZoom() );
m_LocalOrigin = { 0, 0 };
}
@ -137,42 +102,6 @@ bool BASE_SCREEN::SetZoom( double iu_per_du )
}
bool BASE_SCREEN::SetNextZoom()
{
// Step must be AT LEAST 1.2
double target = m_Zoom * 1.2;
for( unsigned i=0; i < m_ZoomList.size(); ++i )
{
if( target < m_ZoomList[i] )
{
SetZoom( m_ZoomList[i] );
return true;
}
}
return false;
}
bool BASE_SCREEN::SetPreviousZoom()
{
// Step must be AT LEAST 1.2
double target = m_Zoom / 1.2;
for( unsigned i = m_ZoomList.size(); i != 0; --i )
{
if( target > m_ZoomList[i - 1] )
{
SetZoom( m_ZoomList[i - 1] );
return true;
}
}
return false;
}
int BASE_SCREEN::BuildGridsChoiceList( wxArrayString& aGridsList, bool aMmFirst) const
{
wxString msg;
@ -219,15 +148,6 @@ int BASE_SCREEN::BuildGridsChoiceList( wxArrayString& aGridsList, bool aMmFirst)
}
void BASE_SCREEN::SetGridList( GRIDS& gridlist )
{
if( !m_grids.empty() )
m_grids.clear();
m_grids = gridlist;
}
int BASE_SCREEN::SetGrid( const wxRealPoint& size )
{
wxASSERT( !m_grids.empty() );
@ -235,19 +155,19 @@ int BASE_SCREEN::SetGrid( const wxRealPoint& size )
GRID_TYPE nearest_grid = m_grids[0];
int gridIdx = 0;
for( unsigned i = 0; i < m_grids.size(); i++ )
for( GRID_TYPE& grid : m_grids )
{
if( m_grids[i].m_Size == size )
if( grid.m_Size == size )
{
m_Grid = m_grids[i];
return m_grids[i].m_CmdId - ID_POPUP_GRID_LEVEL_1000;
m_Grid = grid;
return grid.m_CmdId - ID_POPUP_GRID_LEVEL_1000;
}
// keep track of the nearest larger grid size, if the exact size is not found
if ( size.x < m_grids[i].m_Size.x )
if ( size.x < grid.m_Size.x )
{
gridIdx = m_grids[i].m_CmdId - ID_POPUP_GRID_LEVEL_1000;
nearest_grid = m_grids[i];
gridIdx = grid.m_CmdId - ID_POPUP_GRID_LEVEL_1000;
nearest_grid = grid;
}
}
@ -260,12 +180,12 @@ int BASE_SCREEN::SetGrid( int aCommandId )
{
wxASSERT( !m_grids.empty() );
for( unsigned i = 0; i < m_grids.size(); i++ )
for( GRID_TYPE& grid : m_grids )
{
if( m_grids[i].m_CmdId == aCommandId )
if( grid.m_CmdId == aCommandId )
{
m_Grid = m_grids[i];
return m_grids[i].m_CmdId - ID_POPUP_GRID_LEVEL_1000;
m_Grid = grid;
return grid.m_CmdId - ID_POPUP_GRID_LEVEL_1000;
}
}
@ -274,39 +194,29 @@ int BASE_SCREEN::SetGrid( int aCommandId )
}
void BASE_SCREEN::AddGrid( const GRID_TYPE& grid )
void BASE_SCREEN::AddGrid( const GRID_TYPE& aGrid )
{
for( unsigned i = 0; i < m_grids.size(); i++ )
for( GRID_TYPE& existing : m_grids )
{
if( m_grids[i].m_Size == grid.m_Size && grid.m_CmdId != ID_POPUP_GRID_USER )
if( existing.m_Size == aGrid.m_Size && aGrid.m_CmdId != ID_POPUP_GRID_USER )
{
wxLogTrace( traceScreen, "Discarding duplicate grid size( %g, %g ).",
grid.m_Size.x, grid.m_Size.y );
wxLogTrace( traceScreen, "Discarding duplicate grid size( %g, %g ).",
aGrid.m_Size.x, aGrid.m_Size.y );
return;
}
if( m_grids[i].m_CmdId == grid.m_CmdId )
if( existing.m_CmdId == aGrid.m_CmdId )
{
wxLogTrace( traceScreen, wxT( "Changing grid ID %d from size( %g, %g ) to " ) \
wxT( "size( %g, %g )." ),
grid.m_CmdId, m_grids[i].m_Size.x,
m_grids[i].m_Size.y, grid.m_Size.x, grid.m_Size.y );
m_grids[i].m_Size = grid.m_Size;
aGrid.m_CmdId, existing.m_Size.x,
existing.m_Size.y, aGrid.m_Size.x, aGrid.m_Size.y );
existing.m_Size = aGrid.m_Size;
return;
}
}
m_grids.push_back( grid );
}
void BASE_SCREEN::AddGrid( const wxRealPoint& size, int id )
{
GRID_TYPE grid;
grid.m_Size = size;
grid.m_CmdId = id;
AddGrid( grid );
m_grids.push_back( aGrid );
}
@ -336,9 +246,9 @@ GRID_TYPE& BASE_SCREEN::GetGrid( size_t aIndex )
bool BASE_SCREEN::GridExists( int aCommandId )
{
// tests for grid command ID (not an index in grid list, but a wxID) exists in grid list.
for( unsigned i = 0; i < m_grids.size(); i++ )
for( GRID_TYPE& grid : m_grids)
{
if( m_grids[i].m_CmdId == aCommandId )
if( grid.m_CmdId == aCommandId )
return true;
}
@ -347,15 +257,10 @@ bool BASE_SCREEN::GridExists( int aCommandId )
wxPoint BASE_SCREEN::getNearestGridPosition( const wxPoint& aPosition,
const wxPoint& aGridOrigin, wxRealPoint* aGridSize ) const
const wxPoint& aGridOrigin ) const
{
wxPoint pt;
wxRealPoint gridSize;
if( aGridSize )
gridSize = *aGridSize;
else
gridSize = GetGridSize();
wxRealPoint gridSize = GetGridSize();
double offset = fmod( aGridOrigin.x, gridSize.x );
int x = KiROUND( (aPosition.x - offset) / gridSize.x );
@ -371,26 +276,6 @@ wxPoint BASE_SCREEN::getNearestGridPosition( const wxPoint& aPosition,
}
wxPoint BASE_SCREEN::getCursorPosition( bool aOnGrid, const wxPoint& aGridOrigin,
wxRealPoint* aGridSize ) const
{
if( aOnGrid )
return getNearestGridPosition( m_crossHairPosition, aGridOrigin, aGridSize );
return m_crossHairPosition;
}
void BASE_SCREEN::setCrossHairPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin,
bool aSnapToGrid )
{
if( aSnapToGrid )
m_crossHairPosition = getNearestGridPosition( aPosition, aGridOrigin, NULL );
else
m_crossHairPosition = aPosition;
}
void BASE_SCREEN::ClearUndoRedoList()
{
ClearUndoORRedoList( m_UndoList );

View File

@ -155,9 +155,7 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
if( GetParentEDAFrame() && GetParentEDAFrame()->GetScreen() )
{
GetParentEDAFrame()->GetScreen()->SetZoom( GetLegacyZoom() );
VECTOR2D center = GetView()->GetCenter();
GetParentEDAFrame()->SetScrollCenterPosition( wxPoint( center.x, center.y ) );
GetParentEDAFrame()->GetScreen()->m_ScrollCenter = GetView()->GetCenter();
}
if( !m_gal->IsVisible() )
@ -503,18 +501,10 @@ void EDA_DRAW_PANEL_GAL::onShowTimer( wxTimerEvent& aEvent )
void EDA_DRAW_PANEL_GAL::SetCurrentCursor( int aCursor )
{
if ( aCursor > wxCURSOR_NONE && aCursor < wxCURSOR_MAX )
{
m_currentCursor = aCursor;
}
else
{
m_currentCursor = wxCURSOR_ARROW;
}
SetCursor( (wxStockCursor) m_currentCursor );
}
void EDA_DRAW_PANEL_GAL::SetDefaultCursor()
{
SetCurrentCursor( m_defaultCursor );
}

View File

@ -99,10 +99,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
m_currentScreen = NULL;
m_toolId = ID_NO_TOOL_SELECTED;
m_lastDrawToolId = ID_NO_TOOL_SELECTED;
m_showAxis = false; // true to draw axis.
m_showBorderAndTitleBlock = false; // true to display reference sheet.
m_showGridAxis = false; // true to draw the grid axis
m_showOriginAxis = false; // true to draw the grid origin
m_LastGridSizeId = 0;
m_drawGrid = true; // hide/Show grid. default = show
m_gridColor = COLOR4D( DARKGRAY ); // Default grid color
@ -110,7 +107,6 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
// BLACK for Pcbnew, BLACK or WHITE for eeschema
m_MsgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight();
m_movingCursorWithKeyboard = false;
m_zoomLevelCoeff = 1.0;
m_userUnits = MILLIMETRES;
m_PolarCoords = false;
@ -634,52 +630,9 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas
//-----< BASE_SCREEN API moved here >--------------------------------------------
wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const
wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition ) const
{
VECTOR2I cursor = GetGalCanvas()->GetViewControls()->GetCursorPosition();
return wxPoint( cursor.x, aInvertY ? -cursor.y : cursor.y );
}
void EDA_DRAW_FRAME::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid )
{
GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( aPosition, false );
}
wxPoint EDA_DRAW_FRAME::GetCursorPosition( bool , wxRealPoint* ) const
{
wxFAIL_MSG( "Obsolete; use VIEW_CONTROLS instead" );
return wxPoint();
}
wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition,
wxRealPoint* aGridSize ) const
{
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->getNearestGridPosition( aPosition, GetGridOrigin(), aGridSize );
}
wxPoint EDA_DRAW_FRAME::RefPos( bool useMouse ) const
{
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->refPos( useMouse );
}
const wxPoint& EDA_DRAW_FRAME::GetScrollCenterPosition() const
{
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->getScrollCenterPosition();
}
void EDA_DRAW_FRAME::SetScrollCenterPosition( const wxPoint& aPoint )
{
BASE_SCREEN* screen = GetScreen(); // virtual call
screen->setScrollCenterPosition( aPoint );
return GetScreen()->getNearestGridPosition( aPosition, GetGridOrigin() );
}
//-----</BASE_SCREEN API moved here >--------------------------------------------

View File

@ -396,8 +396,8 @@ int COMMON_TOOLS::doGridPreset( int idx )
getView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
// Put cursor on new grid
m_frame->SetCrossHairPosition( m_frame->RefPos( true ) );
VECTOR2D gridCursor = getViewControls()->GetCursorPosition( true );
getViewControls()->SetCrossHairCursorPosition( gridCursor, false );
return 0;
}
@ -461,10 +461,11 @@ int COMMON_TOOLS::ResetLocalCoords( const TOOL_EVENT& aEvent )
auto vcSettings = m_toolMgr->GetCurrentToolVC();
// Use either the active tool forced cursor position or the general settings
VECTOR2I cursorPos = vcSettings.m_forceCursorPosition ? vcSettings.m_forcedPosition :
getViewControls()->GetCursorPosition();
if( vcSettings.m_forceCursorPosition )
m_frame->GetScreen()->m_LocalOrigin = vcSettings.m_forcedPosition;
else
m_frame->GetScreen()->m_LocalOrigin = getViewControls()->GetCursorPosition();
m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
m_frame->UpdateStatusBar();
return 0;

View File

@ -68,8 +68,6 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
wxDefaultPosition, wxDefaultSize,
KICAD_DEFAULT_DRAWFRAME_STYLE, FOOTPRINTVIEWER_FRAME_NAME )
{
m_showAxis = true; // true to draw axis.
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_cvpcb_xpm ) );

View File

@ -72,11 +72,13 @@ END_EVENT_TABLE()
DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
DIALOG_ERC_BASE( parent, ID_DIALOG_ERC // parent looks for this ID explicitly
)
DIALOG_ERC_BASE( parent, ID_DIALOG_ERC ), // parent looks for this ID explicitly
m_buttonList(),
m_initialized( false ),
m_settings()
{
m_parent = parent;
m_lastMarkerFound = NULL;
m_lastMarkerFound = nullptr;
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
@ -213,7 +215,7 @@ void DIALOG_ERC::OnResetMatrixClick( wxCommandEvent& event )
void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event )
{
wxBusyCursor();
wxBusyCursor busy;
m_MarkersList->ClearList();
m_MessagesList->Clear();
@ -236,7 +238,7 @@ void DIALOG_ERC::OnLeftClickMarkersList( wxHtmlLinkEvent& event )
{
wxString link = event.GetLinkInfo().GetHref();
m_lastMarkerFound = NULL;
m_lastMarkerFound = nullptr;
long index;
@ -245,13 +247,13 @@ void DIALOG_ERC::OnLeftClickMarkersList( wxHtmlLinkEvent& event )
const SCH_MARKER* marker = m_MarkersList->GetItem( index );
if( marker == NULL )
if( !marker )
return;
// Search for the selected marker
unsigned i;
SCH_SHEET_LIST sheetList( g_RootSheet );
bool notFound = true;
bool found = false;
for( i = 0; i < sheetList.size(); i++ )
{
@ -261,16 +263,16 @@ void DIALOG_ERC::OnLeftClickMarkersList( wxHtmlLinkEvent& event )
{
if( item == marker )
{
notFound = false;
found = true;
break;
}
}
if( notFound == false )
if( found )
break;
}
if( notFound ) // Error
if( !found ) // Error
{
wxMessageBox( _( "Marker not found" ) );
@ -284,25 +286,22 @@ void DIALOG_ERC::OnLeftClickMarkersList( wxHtmlLinkEvent& event )
m_parent->SetCurrentSheet( sheetList[i] );
m_parent->DisplayCurrentSheet();
sheetList[i].LastScreen()->SetZoom( m_parent->GetScreen()->GetZoom() );
m_parent->RedrawScreen( m_parent->GetScrollCenterPosition(), false );
m_parent->RedrawScreen( (wxPoint) m_parent->GetScreen()->m_ScrollCenter, false );
}
m_lastMarkerFound = marker;
m_parent->FocusOnLocation( marker->m_Pos, false, true );
m_parent->SetCrossHairPosition( marker->m_Pos );
RedrawDrawPanel();
}
void DIALOG_ERC::OnLeftDblClickMarkersList( wxMouseEvent& event )
{
// Remember: OnLeftClickMarkersList was called just before
// and therefore m_lastMarkerFound was initialized.
// (NULL if not found)
// Remember: OnLeftClickMarkersList was called just before and therefore m_lastMarkerFound
// was initialized (NULL if not found).
if( m_lastMarkerFound )
{
m_parent->FocusOnLocation( m_lastMarkerFound->m_Pos, false, true );
m_parent->SetCrossHairPosition( m_lastMarkerFound->m_Pos );
RedrawDrawPanel();
}
@ -333,7 +332,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
// compute the Y pos interval:
pos.y = text_height;
if( m_initialized == false )
if( !m_initialized )
{
std::vector<wxStaticText*> labels;
@ -398,7 +397,7 @@ void DIALOG_ERC::ReBuildMatrixPanel()
void DIALOG_ERC::setDRCMatrixButtonState( wxBitmapButton *aButton, int aState )
{
BITMAP_DEF bitmap_butt = NULL;
BITMAP_DEF bitmap_butt = nullptr;
wxString tooltip;
switch( aState )
@ -417,6 +416,9 @@ void DIALOG_ERC::setDRCMatrixButtonState( wxBitmapButton *aButton, int aState )
bitmap_butt = ercerr_xpm;
tooltip = _( "Generate error" );
break;
default:
break;
}
if( bitmap_butt )
@ -465,33 +467,13 @@ void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event )
void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event )
{
int id, level, ii, x, y;
wxPoint pos;
id = event.GetId();
ii = id - ID_MATRIX_0;
int id = event.GetId();
int ii = id - ID_MATRIX_0;
int x = ii / PINTYPE_COUNT;
int y = ii % PINTYPE_COUNT;
wxBitmapButton* butt = (wxBitmapButton*) event.GetEventObject();
pos = butt->GetPosition();
x = ii / PINTYPE_COUNT; y = ii % PINTYPE_COUNT;
level = DiagErc[y][x];
//change to the next error level
switch( level )
{
case OK:
level = WAR;
break;
case WAR:
level = ERR;
break;
case ERR:
level = OK;
break;
}
int level = ( DiagErc[y][x] + 1 ) % 3;
setDRCMatrixButtonState( butt, level );

View File

@ -109,8 +109,7 @@ void DIALOG_MIGRATE_BUSES::updateUi()
for( unsigned j = 1; j < item.labels.size(); j++ )
old << ", " << item.labels[j];
auto i = m_migration_list->InsertItem( m_migration_list->GetItemCount(),
wxEmptyString );
auto i = m_migration_list->InsertItem( m_migration_list->GetItemCount(), wxEmptyString );
m_migration_list->SetItem( i, 0, item.subgraph->m_sheet.PathHumanReadable() );
m_migration_list->SetItem( i, 1, old );
@ -184,12 +183,12 @@ void DIALOG_MIGRATE_BUSES::onItemSelected( wxListEvent& aEvent )
auto pos = driver->GetPosition();
m_frame->SetCrossHairPosition( pos );
m_frame->GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( pos, false );
m_frame->RedrawScreen( pos, false );
m_cb_new_name->Clear();
for( auto option : m_items[sel].possible_labels )
for( const wxString& option : m_items[sel].possible_labels )
m_cb_new_name->Append( option );
m_cb_new_name->Select( 0 );

View File

@ -45,31 +45,32 @@ static bool lastTextItalic = false;
SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( int aType )
{
SCH_TEXT* textItem = NULL;
wxPoint cursorPos = (wxPoint) GetGalCanvas()->GetViewControls()->GetCursorPosition();
SCH_TEXT* textItem = nullptr;
switch( aType )
{
case LAYER_NOTES:
textItem = new SCH_TEXT( GetCrossHairPosition() );
textItem = new SCH_TEXT( cursorPos );
break;
case LAYER_LOCLABEL:
textItem = new SCH_LABEL( GetCrossHairPosition() );
textItem = new SCH_LABEL( cursorPos );
break;
case LAYER_HIERLABEL:
textItem = new SCH_HIERLABEL( GetCrossHairPosition() );
textItem = new SCH_HIERLABEL( cursorPos );
textItem->SetShape( lastGlobalLabelShape );
break;
case LAYER_GLOBLABEL:
textItem = new SCH_GLOBALLABEL( GetCrossHairPosition() );
textItem = new SCH_GLOBALLABEL( cursorPos );
textItem->SetShape( lastGlobalLabelShape );
break;
default:
DisplayError( this, wxT( "SCH_EDIT_FRAME::CreateNewText() Internal error" ) );
return NULL;
return nullptr;
}
textItem->SetBold( lastTextBold );
@ -83,7 +84,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( int aType )
if( textItem->GetText().IsEmpty() )
{
delete textItem;
return NULL;
return nullptr;
}
lastTextBold = textItem->IsBold();

View File

@ -121,7 +121,6 @@ enum id_eeschema_frm
ID_LIBVIEW_SELECT_PART_NUMBER,
ID_LIBVIEW_LIB_LIST,
ID_LIBVIEW_CMP_LIST,
ID_SET_RELATIVE_OFFSET,
ID_SIM_RUN,
ID_SIM_TUNE,

View File

@ -137,7 +137,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference,
delta = Component->GetTransform().TransformCoordinate( pos );
pos = delta + Component->GetPosition();
SetCrossHairPosition( pos );
GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( pos, false );
CenterScreen( pos, false );
}

View File

@ -279,9 +279,8 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
}
else
{
CenterScreen( GetScrollCenterPosition(), false );
// RedrawScreen() will set zoom to last used
RedrawScreen( GetScrollCenterPosition(), false );
RedrawScreen( (wxPoint) GetScreen()->m_ScrollCenter, false );
}
UpdateTitle();

View File

@ -109,7 +109,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_LIB_EDITOR, _( "Library Editor" ),
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, LIB_EDIT_FRAME_NAME )
{
m_showAxis = true; // true to draw axis
SetShowDeMorgan( false );
m_DrawSpecificConvert = true;
m_DrawSpecificUnit = false;
@ -147,8 +146,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
GetScreen()->m_Center = true;
GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
SetCrossHairPosition( wxPoint( 0, 0 ) );
GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
setupTools();
@ -263,7 +261,7 @@ double LIB_EDIT_FRAME::BestZoom()
if( !part )
{
SetScrollCenterPosition( wxPoint( 0, 0 ) );
GetGalCanvas()->GetView()->SetCenter( VECTOR2D( 0, 0 ) );
return defaultLibraryZoom;
}

View File

@ -186,8 +186,9 @@ void SCH_BASE_FRAME::UpdateStatusBar()
EDA_DRAW_FRAME::UpdateStatusBar();
// Display absolute coordinates:
double dXpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().x );
double dYpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().y );
VECTOR2D cursorPos = GetGalCanvas()->GetViewControls()->GetCursorPosition();
double dXpos = To_User_Unit( GetUserUnits(), cursorPos.x );
double dYpos = To_User_Unit( GetUserUnits(), cursorPos.y );
if ( GetUserUnits() == MILLIMETRES )
{
@ -224,8 +225,8 @@ void SCH_BASE_FRAME::UpdateStatusBar()
SetStatusText( line, 2 );
// Display relative coordinates:
double dx = (double)GetCrossHairPosition().x - (double)screen->m_O_Curseur.x;
double dy = (double)GetCrossHairPosition().y - (double)screen->m_O_Curseur.y;
double dx = cursorPos.x - screen->m_LocalOrigin.x;
double dy = cursorPos.y - screen->m_LocalOrigin.y;
dXpos = To_User_Unit( GetUserUnits(), dx );
dYpos = To_User_Unit( GetUserUnits(), dy );

View File

@ -241,7 +241,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
g_CurrentSheet = new SCH_SHEET_PATH();
g_ConnectionGraph = new CONNECTION_GRAPH( this );
m_showAxis = false; // true to show axis
m_showBorderAndTitleBlock = true; // true to show sheet references
m_DefaultSchematicFileName = NAMELESS_PROJECT;
m_DefaultSchematicFileName += wxT( ".sch" );

View File

@ -387,14 +387,14 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, SCH_HIERLABEL*
if( sheetPin->GetText().IsEmpty() || (response == wxID_CANCEL) )
{
delete sheetPin;
return NULL;
return nullptr;
}
}
m_lastSheetPinType = sheetPin->GetShape();
m_lastSheetPinTextSize = sheetPin->GetTextSize();
sheetPin->SetPosition( GetCrossHairPosition() );
sheetPin->SetPosition( (wxPoint) GetGalCanvas()->GetViewControls()->GetCursorPosition() );
return sheetPin;
}

View File

@ -204,7 +204,7 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType )
}
// Restore cursor after dialog
getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true );
getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
if( item )
{

View File

@ -201,12 +201,12 @@ int SCH_DRAWING_TOOLS::AddJunction( const TOOL_EVENT& aEvent )
if( wire )
{
SEG seg( wire->GetStartPoint(), wire->GetEndPoint() );
VECTOR2I nearest = seg.NearestPoint( m_frame->GetCrossHairPosition() );
m_frame->SetCrossHairPosition( (wxPoint) nearest, false );
VECTOR2I nearest = seg.NearestPoint( getViewControls()->GetCursorPosition() );
getViewControls()->SetCrossHairCursorPosition( nearest, false );
}
getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true );
SCH_JUNCTION* junction = m_frame->AddJunction( m_frame->GetCrossHairPosition() );
getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
SCH_JUNCTION* junction = m_frame->AddJunction( (wxPoint) getViewControls()->GetCursorPosition() );
m_selectionTool->AddItemToSel( junction );
return 0;
@ -345,7 +345,7 @@ int SCH_DRAWING_TOOLS::doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTE
m_frame->GetShowFootprintPreviews());
// Restore cursor after dialog
getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true );
getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
LIB_PART* part = sel.LibId.IsValid() ? m_frame->GetLibPart( sel.LibId ) : nullptr;
@ -469,7 +469,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
continue;
// Restore cursor after dialog
getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true );
getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
wxString fullFilename = dlg.GetPath();
@ -757,7 +757,7 @@ int SCH_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType )
}
// Restore cursor after dialog
getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true );
getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
if( item )
{

View File

@ -319,8 +319,8 @@ int SCH_WIRE_BUS_TOOL::StartWire( const TOOL_EVENT& aEvent )
Activate();
getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true );
SCH_LINE* segment = startSegments( LAYER_WIRE, m_frame->GetCrossHairPosition() );
getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
SCH_LINE* segment = startSegments( LAYER_WIRE, getViewControls()->GetCursorPosition() );
return doDrawSegments( LAYER_WIRE, segment );
}
@ -351,8 +351,8 @@ int SCH_WIRE_BUS_TOOL::StartBus( const TOOL_EVENT& aEvent )
Activate();
getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true );
SCH_LINE* segment = startSegments( LAYER_BUS, m_frame->GetCrossHairPosition() );
getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
SCH_LINE* segment = startSegments( LAYER_BUS, getViewControls()->GetCursorPosition() );
return doDrawSegments( LAYER_BUS, segment );
}
@ -434,7 +434,7 @@ int SCH_WIRE_BUS_TOOL::UnfoldBus( const TOOL_EVENT& aEvent )
SCH_LINE* SCH_WIRE_BUS_TOOL::doUnfoldBus( const wxString& aNet )
{
wxPoint pos = m_frame->GetCrossHairPosition();
wxPoint pos = (wxPoint) getViewControls()->GetCursorPosition();
m_busUnfold.entry = new SCH_BUS_WIRE_ENTRY( pos, '\\' );
m_busUnfold.entry->SetParent( m_frame->GetScreen() );
@ -449,7 +449,7 @@ SCH_LINE* SCH_WIRE_BUS_TOOL::doUnfoldBus( const wxString& aNet )
m_busUnfold.origin = pos;
m_busUnfold.net_name = aNet;
m_frame->SetCrossHairPosition( m_busUnfold.entry->m_End() );
getViewControls()->SetCrossHairCursorPosition( m_busUnfold.entry->m_End(), false );
return startSegments( LAYER_WIRE, m_busUnfold.entry->m_End() );
}
@ -462,8 +462,8 @@ int SCH_WIRE_BUS_TOOL::StartLine( const TOOL_EVENT& aEvent)
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
getViewControls()->WarpCursor( m_frame->GetCrossHairPosition(), true );
SCH_LINE* segment = startSegments( LAYER_NOTES, m_frame->GetCrossHairPosition() );
getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
SCH_LINE* segment = startSegments( LAYER_NOTES, getViewControls()->GetCursorPosition() );
return doDrawSegments( LAYER_BUS, segment );
}
@ -591,7 +591,7 @@ int SCH_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
{
cursorPos = (wxPoint)getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
//------------------------------------------------------------------------
// Handle cancel:
@ -799,16 +799,16 @@ int SCH_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
}
SCH_LINE* SCH_WIRE_BUS_TOOL::startSegments( int aType, const wxPoint& aPos )
SCH_LINE* SCH_WIRE_BUS_TOOL::startSegments( int aType, const VECTOR2D& aPos )
{
SCH_LINE* segment = nullptr;
bool forceHV = m_frame->GetForceHVLines();
switch( aType )
{
default: segment = new SCH_LINE( aPos, LAYER_NOTES ); break;
case LAYER_WIRE: segment = new SCH_LINE( aPos, LAYER_WIRE ); break;
case LAYER_BUS: segment = new SCH_LINE( aPos, LAYER_BUS ); break;
default: segment = new SCH_LINE( (wxPoint) aPos, LAYER_NOTES ); break;
case LAYER_WIRE: segment = new SCH_LINE( (wxPoint) aPos, LAYER_WIRE ); break;
case LAYER_BUS: segment = new SCH_LINE( (wxPoint) aPos, LAYER_BUS ); break;
}
segment->SetFlags( IS_NEW | IS_MOVED );

View File

@ -91,7 +91,7 @@ public:
private:
int doDrawSegments( int aType, SCH_LINE* aSegment );
SCH_LINE* startSegments( int aType, const wxPoint& aPos );
SCH_LINE* startSegments( int aType, const VECTOR2D& aPos );
SCH_LINE* doUnfoldBus( const wxString& aNet );
void finishSegments();

View File

@ -82,7 +82,6 @@ BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME )
// Menu (and/or hotkey) events
EVT_MENU( wxID_EXIT, LIB_VIEW_FRAME::CloseLibraryViewer )
EVT_MENU( ID_SET_RELATIVE_OFFSET, LIB_VIEW_FRAME::OnSetRelativeOffset )
EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings )
EVT_UPDATE_UI( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::onUpdateUnitChoice )
@ -374,13 +373,6 @@ void LIB_VIEW_FRAME::OnSize( wxSizeEvent& SizeEv )
}
void LIB_VIEW_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
{
GetScreen()->m_O_Curseur = GetCrossHairPosition();
UpdateStatusBar();
}
void LIB_VIEW_FRAME::onUpdateUnitChoice( wxUpdateUIEvent& aEvent )
{
LIB_PART* part = GetSelectedSymbol();
@ -414,12 +406,12 @@ void LIB_VIEW_FRAME::onUpdateUnitChoice( wxUpdateUIEvent& aEvent )
double LIB_VIEW_FRAME::BestZoom()
{
LIB_PART* part = NULL;
LIB_PART* part = nullptr;
double defaultLibraryZoom = 7.33;
if( m_libraryName.IsEmpty() || m_entryName.IsEmpty() )
{
SetScrollCenterPosition( wxPoint( 0, 0 ) );
GetGalCanvas()->GetView()->SetCenter( VECTOR2D( 0, 0 ) );
return defaultLibraryZoom;
}
@ -438,7 +430,7 @@ double LIB_VIEW_FRAME::BestZoom()
if( !part )
{
SetScrollCenterPosition( wxPoint( 0, 0 ) );
GetGalCanvas()->GetView()->SetCenter( VECTOR2D( 0, 0 ) );
return defaultLibraryZoom;
}

View File

@ -93,7 +93,6 @@ public:
double BestZoom() override;
void ClickOnLibList( wxCommandEvent& event );
void ClickOnCmpList( wxCommandEvent& event );
void OnSetRelativeOffset( wxCommandEvent& event );
void OnSelectSymbol( wxCommandEvent& aEvent );
void LoadSettings( wxConfigBase* aCfg ) override;

View File

@ -78,7 +78,6 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
m_show_layer_manager_tools = true;
m_showAxis = true; // true to show X and Y axis on screen
m_showBorderAndTitleBlock = false; // true for reference drawings.
m_SelLayerBox = NULL;
m_DCodeSelector = NULL;
@ -993,24 +992,17 @@ void GERBVIEW_FRAME::UpdateStatusBar()
if( !screen )
return;
int dx;
int dy;
double dXpos;
double dYpos;
wxString line;
VECTOR2D cursorPos = GetGalCanvas()->GetViewControls()->GetCursorPosition();
if( GetShowPolarCoords() ) // display relative polar coordinates
{
double theta, ro;
dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
// atan2 in the 0,0 case returns 0
theta = RAD2DEG( atan2( (double) -dy, (double) dx ) );
ro = hypot( dx, dy );
double dx = cursorPos.x - screen->m_LocalOrigin.x;
double dy = cursorPos.y - screen->m_LocalOrigin.y;
double theta = RAD2DEG( atan2( -dy, dx ) );
double ro = hypot( dx, dy );
wxString formatter;
switch( GetUserUnits() )
{
case INCHES: formatter = wxT( "r %.6f theta %.1f" ); break;
@ -1025,8 +1017,8 @@ void GERBVIEW_FRAME::UpdateStatusBar()
}
// Display absolute coordinates:
dXpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().x );
dYpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().y );
double dXpos = To_User_Unit( GetUserUnits(), cursorPos.x );
double dYpos = To_User_Unit( GetUserUnits(), cursorPos.y );
wxString absformatter;
wxString relformatter;
@ -1059,10 +1051,8 @@ void GERBVIEW_FRAME::UpdateStatusBar()
if( !GetShowPolarCoords() ) // display relative cartesian coordinates
{
// Display relative coordinates:
dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
dXpos = To_User_Unit( GetUserUnits(), dx );
dYpos = To_User_Unit( GetUserUnits(), dy );
dXpos = To_User_Unit( GetUserUnits(), cursorPos.x - screen->m_LocalOrigin.x );
dYpos = To_User_Unit( GetUserUnits(), cursorPos.y - screen->m_LocalOrigin.y );
// We already decided the formatter above
line.Printf( relformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );

View File

@ -74,13 +74,8 @@ typedef std::vector<GRID_TYPE> GRIDS;
class BASE_SCREEN : public EDA_ITEM
{
private:
GRIDS m_grids; ///< List of valid grid sizes.
bool m_FlagModified; ///< Indicates current drawing has been modified.
bool m_FlagSave; ///< Indicates automatic file save.
EDA_ITEM* m_CurrentItem; ///< Currently selected object
GRID_TYPE m_Grid; ///< Current grid selection.
wxPoint m_scrollCenter; ///< Current scroll center point in logical units.
wxPoint m_MousePosition; ///< Mouse cursor coordinate in logical units.
int m_UndoRedoCountMax; ///< undo/Redo command Max depth
/**
@ -90,79 +85,22 @@ private:
*/
wxPoint m_crossHairPosition;
GRIDS m_grids; ///< List of valid grid sizes.
GRID_TYPE m_Grid; ///< Current grid selection.
double m_Zoom; ///< Current zoom coefficient.
//----< Old public API now is private, and migratory>------------------------
// called only from EDA_DRAW_FRAME
friend class EDA_DRAW_FRAME;
/**
* Function getCrossHairPosition
* return the current cross hair position in logical (drawing) coordinates.
* @param aInvertY Inverts the Y axis position.
* @return The cross hair position in drawing coordinates.
*/
wxPoint getCrossHairPosition( bool aInvertY ) const
{
if( aInvertY )
return wxPoint( m_crossHairPosition.x, -m_crossHairPosition.y );
return wxPoint( m_crossHairPosition.x, m_crossHairPosition.y );
}
/**
* Function setCrossHairPosition
* sets the screen cross hair position to \a aPosition in logical (drawing) units.
* @param aPosition The new cross hair position.
* @param aGridOrigin Origin point of the snap grid.
* @param aSnapToGrid Sets the cross hair position to the nearest grid position to
* \a aPosition.
*
*/
void setCrossHairPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin, bool aSnapToGrid );
/**
* Function getNearestGridPosition
* returns the nearest \a aGridSize location to \a aPosition.
* @param aPosition The position to check.
* @param aGridOrigin The origin point of the snap grid.
* @param aGridSize The grid size to locate to if provided. If NULL then the current
* grid size is used.
* @return The nearst grid position.
*/
wxPoint getNearestGridPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin,
wxRealPoint* aGridSize ) const;
/**
* Function getCursorPosition
* returns the current cursor position in logical (drawing) units.
* @param aOnGrid Returns the nearest grid position at the current cursor position.
* @param aGridOrigin Origin point of the snap grid.
* @param aGridSize Custom grid size instead of the current grid size. Only valid
* if \a aOnGrid is true.
* @return The current cursor position.
*/
wxPoint getCursorPosition( bool aOnGrid, const wxPoint& aGridOrigin, wxRealPoint* aGridSize ) const;
void setMousePosition( const wxPoint& aPosition ) { m_MousePosition = aPosition; }
/**
* Function RefPos
* Return the reference position, coming from either the mouse position
* or the cursor position.
*
* @param useMouse If true, return mouse position, else cursor's.
*
* @return wxPoint - The reference point, either the mouse position or
* the cursor position.
*/
wxPoint refPos( bool useMouse ) const
{
return useMouse ? m_MousePosition : m_crossHairPosition;
}
const wxPoint& getScrollCenterPosition() const { return m_scrollCenter; }
void setScrollCenterPosition( const wxPoint& aPoint ) { m_scrollCenter = aPoint; }
wxPoint getNearestGridPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin ) const;
//----</Old public API now is private, and migratory>------------------------
@ -173,19 +111,9 @@ public:
wxPoint m_DrawOrg; ///< offsets for drawing the circuit on the screen
wxPoint m_O_Curseur; ///< Relative Screen cursor coordinate (on grid)
VECTOR2D m_LocalOrigin; ///< Relative Screen cursor coordinate (on grid)
///< in user units. (coordinates from last reset position)
// Scrollbars management:
int m_ScrollPixelsPerUnitX; ///< Pixels per scroll unit in the horizontal direction.
int m_ScrollPixelsPerUnitY; ///< Pixels per scroll unit in the vertical direction.
wxSize m_ScrollbarNumber; /**< Current virtual draw area size in scroll units.
* m_ScrollbarNumber * m_ScrollPixelsPerUnit =
* virtual draw area size in pixels */
wxPoint m_ScrollbarPos; ///< Current scroll bar position in scroll units.
wxPoint m_StartVisu; /**< Coordinates in drawing units of the current
* view position (upper left corner of device)
*/
@ -195,6 +123,9 @@ public:
* > 0 except for schematics.
* false: when coordinates can only be >= 0
* Schematic */
VECTOR2D m_ScrollCenter; ///< Current scroll center point in logical units.
bool m_Initialized;
// Undo/redo list of commands
@ -209,7 +140,7 @@ public:
public:
BASE_SCREEN( KICAD_T aType = SCREEN_T );
~BASE_SCREEN();
~BASE_SCREEN() override { }
void InitDataPoints( const wxSize& aPageSizeInternalUnits );
@ -317,11 +248,6 @@ public:
*/
virtual bool SetZoom( double iu_per_du );
bool SetNextZoom();
bool SetPreviousZoom();
bool SetFirstZoom();
bool SetLastZoom();
/**
* Function GetMaxAllowedZoom
* returns the maximum allowed zoom factor, which was established as the last entry
@ -336,32 +262,6 @@ public:
*/
double GetMinAllowedZoom() const { return m_ZoomList.size() ? *m_ZoomList.begin() : 1.0; }
/**
* Function SetScalingFactor
* sets the scaling factor of "internal unit per device unit".
* If the output device is a screen, then "device units" are pixels. The
* "logical unit" is wx terminology, and corresponds to KiCad's "Internal Unit (IU)".
* <p>
* This scaling factor is "internal units per device unit". This function is
* the same thing currently as SetZoom(), but clamps the argument within a
* legal range.
* @param iu_per_du is the current scale used to draw items onto the device
* context wxDC.
*/
void SetScalingFactor( double iu_per_du );
/**
* Function GetScalingFactor
* returns the inverse of the current scale used to draw items on screen.
* <p>
* This function somehow got designed to be the inverse of SetScalingFactor().
* <p>
* device coordinates = user coordinates * GetScalingFactor()
*/
double GetScalingFactor() const;
//----<grid stuff>----------------------------------------------------------
/**
@ -404,9 +304,7 @@ public:
*/
int SetGrid( int aCommandId );
void SetGridList( GRIDS& sizelist );
void AddGrid( const GRID_TYPE& grid );
void AddGrid( const wxRealPoint& size, int id );
void AddGrid( const GRID_TYPE& aGrid );
void AddGrid( const wxRealPoint& size, EDA_UNITS_T aUnit, int id );
/**

View File

@ -23,11 +23,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file class_draw_panel_gal.h:
* @brief EDA_DRAW_PANEL_GAL class definition.
*/
#ifndef PANELGAL_WXSTRUCT_H
#define PANELGAL_WXSTRUCT_H
@ -83,30 +78,21 @@ public:
* Function GetBackend
* Returns the type of backend currently used by GAL canvas.
*/
inline GAL_TYPE GetBackend() const
{
return m_backend;
}
inline GAL_TYPE GetBackend() const { return m_backend; }
/**
* Function GetGAL()
* Returns a pointer to the GAL instance used in the panel.
* @return The instance of GAL.
*/
KIGFX::GAL* GetGAL() const
{
return m_gal;
}
KIGFX::GAL* GetGAL() const { return m_gal; }
/**
* Function GetView()
* Returns a pointer to the VIEW instance used in the panel.
* @return The instance of VIEW.
*/
KIGFX::VIEW* GetView() const
{
return m_view;
}
KIGFX::VIEW* GetView() const { return m_view; }
/**
* Function GetViewControls()
@ -176,10 +162,7 @@ public:
* Function GetParentEDAFrame()
* Returns parent EDA_DRAW_FRAME, if available or NULL otherwise.
*/
EDA_DRAW_FRAME* GetParentEDAFrame() const
{
return m_edaFrame;
}
EDA_DRAW_FRAME* GetParentEDAFrame() const { return m_edaFrame; }
/**
* Function OnShow()
@ -192,20 +175,8 @@ public:
* be true (and is by default) for any primary canvas, but can be false to make
* well-behaved preview panes and the like.
*/
void SetStealsFocus( bool aStealsFocus )
{
m_stealsFocus = aStealsFocus;
}
void SetStealsFocus( bool aStealsFocus ) { m_stealsFocus = aStealsFocus; }
/**
* Get whether focus is taken on certain events (see SetStealsFocus()).
*/
bool GetStealsFocus() const
{
return m_stealsFocus;
}
virtual void SetDefaultCursor();
/**
* Function SetCurrentCursor
* Set the current cursor shape for this panel
@ -224,10 +195,7 @@ public:
*
* @return the default bounding box for the panel
*/
virtual BOX2I GetDefaultViewBBox() const
{
return BOX2I();
}
virtual BOX2I GetDefaultViewBBox() const { return BOX2I(); }
/**
* Used to forward events to the canvas from popups, etc.

View File

@ -99,64 +99,40 @@ protected:
std::unique_ptr<wxSingleInstanceChecker> m_file_checker; ///< prevents opening same file multiple times.
int m_LastGridSizeId; // the command id offset (>= 0) of the last selected grid
int m_LastGridSizeId; // the command id offset (>= 0) of the last selected grid
// 0 is for the grid corresponding to
// a wxCommand ID = ID_POPUP_GRID_LEVEL_1000.
bool m_drawGrid; // hide/Show grid
bool m_showPageLimits; ///< true to display the page limits
COLOR4D m_gridColor; ///< Grid color
COLOR4D m_drawBgColor; ///< the background color of the draw canvas
bool m_drawGrid; // hide/Show grid
bool m_showPageLimits; ///< true to display the page limits
COLOR4D m_gridColor; ///< Grid color
COLOR4D m_drawBgColor; ///< the background color of the draw canvas
///< BLACK for Pcbnew, BLACK or WHITE for eeschema
double m_zoomLevelCoeff; ///< a suitable value to convert the internal zoom scaling factor
double m_zoomLevelCoeff; ///< a suitable value to convert the internal zoom scaling factor
// to a zoom level value which rougly gives 1.0 when the board/schematic
// is at scale = 1
int m_UndoRedoCountMax; ///< default Undo/Redo command Max depth, to be handed
int m_UndoRedoCountMax; ///< default Undo/Redo command Max depth, to be handed
// to screens
bool m_PolarCoords; //< for those frames that support polar coordinates
bool m_PolarCoords; //< for those frames that support polar coordinates
TOOL_DISPATCHER* m_toolDispatcher;
TOOL_DISPATCHER* m_toolDispatcher;
/// Tool ID of previously active draw tool bar button.
int m_lastDrawToolId;
int m_lastDrawToolId;
/// True shows the X and Y axis indicators.
bool m_showAxis;
/// True shows the grid axis indicators.
bool m_showGridAxis;
bool m_showBorderAndTitleBlock; /// Show the worksheet (border and title block).
long m_firstRunDialogSetting; /// Show first run dialog on startup
/// True shows the origin axis used to indicate the coordinate offset for
/// drill, gerber, and component position files.
bool m_showOriginAxis;
wxChoice* m_gridSelectBox;
wxChoice* m_zoomSelectBox;
/// True shows the drawing border and title block.
bool m_showBorderAndTitleBlock;
ACTION_TOOLBAR* m_mainToolBar;
ACTION_TOOLBAR* m_auxiliaryToolBar; // Additional tools under main toolbar
ACTION_TOOLBAR* m_drawToolBar; // Drawing tools (typically on right edge of window)
ACTION_TOOLBAR* m_optionsToolBar; // Options (typically on left edge of window)
/// Key to control whether first run dialog is shown on startup
long m_firstRunDialogSetting;
wxChoice* m_gridSelectBox;
wxChoice* m_zoomSelectBox;
ACTION_TOOLBAR* m_mainToolBar;
/// Auxiliary tool bar typically shown below the main tool bar at the top of the
/// main window.
ACTION_TOOLBAR* m_auxiliaryToolBar;
/// The tool bar that contains the buttons for quick access to the application draw
/// tools. It typically is located on the right side of the main window.
ACTION_TOOLBAR* m_drawToolBar;
/// The options tool bar typcially located on the left edge of the main window.
ACTION_TOOLBAR* m_optionsToolBar;
/// Panel used to display information at the bottom of the main window.
EDA_MSG_PANEL* m_messagePanel;
int m_MsgFrameHeight;
/// One-shot to avoid a recursive mouse event during hotkey movement
bool m_movingCursorWithKeyboard;
EDA_MSG_PANEL* m_messagePanel;
int m_MsgFrameHeight;
/// The current canvas type
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType;
@ -194,10 +170,7 @@ protected:
* the base version returns only CanvasTypeKeyBase.
* Can be overriden to return a key specific of a frame name
*/
virtual wxString GetCanvasTypeKey()
{
return CanvasTypeKeyBase;
}
virtual wxString GetCanvasTypeKey() { return CanvasTypeKeyBase; }
public:
EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
@ -255,56 +228,15 @@ public:
void SetLastGridSizeId( int aId ) { m_LastGridSizeId = aId; }
//-----<BASE_SCREEN API moved here>------------------------------------------
/**
* Return the current cross hair position in logical (drawing) coordinates.
*
* @param aInvertY Inverts the Y axis position.
* @return The cross hair position in drawing coordinates.
*/
wxPoint GetCrossHairPosition( bool aInvertY = false ) const;
/**
* Set the screen cross hair position to \a aPosition in logical (drawing) units.
*
* @param aPosition The new cross hair position.
* @param aSnapToGrid Sets the cross hair position to the nearest grid position to
* \a aPosition.
*/
void SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid = true );
/**
* Return the current cursor position in logical (drawing) units.
*
* @param aOnGrid Returns the nearest grid position at the current cursor position.
* @param aGridSize Custom grid size instead of the current grid size. Only valid
* if \a aOnGrid is true.
* @return The current cursor position.
*/
wxPoint GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize = NULL ) const;
/**
* Return the nearest \a aGridSize location to \a aPosition.
*
* @param aPosition The position to check.
* @param aGridSize The grid size to locate to if provided. If NULL then the current
* grid size is used.
* @return The nearst grid position.
*/
wxPoint GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize = NULL ) const;
wxPoint GetNearestGridPosition( const wxPoint& aPosition ) const;
/**
* Return the reference position, coming from either the mouse position
* or the cursor position.
*
* @param useMouse If true, return mouse position, else cursor's.
*
* @return wxPoint - The reference point, either the mouse position or
* the cursor position.
*/
wxPoint RefPos( bool useMouse ) const;
const wxPoint& GetScrollCenterPosition() const;
void SetScrollCenterPosition( const wxPoint& aPoint );
//-----</BASE_SCREEN API moved here>-----------------------------------------
@ -323,9 +255,6 @@ public:
*/
virtual void SetDrawBgColor( COLOR4D aColor) { m_drawBgColor= aColor ; }
bool GetShowBorderAndTitleBlock() const { return m_showBorderAndTitleBlock; }
void SetShowBorderAndTitleBlock( bool aShow ) { m_showBorderAndTitleBlock = aShow; }
bool ShowPageLimits() const { return m_showPageLimits; }
void SetShowPageLimits( bool aShow ) { m_showPageLimits = aShow; }

Some files were not shown because too many files have changed in this diff Show More