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; }

View File

@ -292,22 +292,6 @@ public:
void InstallPadOptionsFrame( D_PAD* pad );
void AddPad( MODULE* Module, bool draw );
/**
* Function DeletePad
* Delete the pad aPad.
* Refresh the modified screen area
* Refresh modified parameters of the parent module (bounding box, last date)
* @param aPad = the pad to delete
* @param aQuery = true to prompt for confirmation, false to delete silently
*/
void DeletePad( D_PAD* aPad, bool aQuery = true );
void PlacePad( D_PAD* Pad, wxDC* DC );
void Export_Pad_Settings( D_PAD* aPad );
void Import_Pad_Settings( D_PAD* aPad, bool aDraw );
/**
* Function SelectFootprintFromLibTree
* opens a dialog to select a footprint.

View File

@ -81,8 +81,6 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
// obviously depends on the monitor,
// but this is an acceptable value
m_showAxis = false; // true to show X and Y axis on screen
m_showGridAxis = true;
m_showBorderAndTitleBlock = true; // true for reference drawings.
m_originSelectChoice = 0;
SetDrawBgColor( WHITE ); // default value, user option (WHITE/BLACK)
@ -542,9 +540,10 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
}
// Display absolute coordinates:
wxPoint coord = GetCrossHairPosition() - originCoord;
double dXpos = To_User_Unit( GetUserUnits(), coord.x*Xsign );
double dYpos = To_User_Unit( GetUserUnits(), coord.y*Ysign );
VECTOR2D cursorPos = GetGalCanvas()->GetViewControls()->GetCursorPosition();
VECTOR2D coord = cursorPos - originCoord;
double dXpos = To_User_Unit( GetUserUnits(), coord.x * Xsign );
double dYpos = To_User_Unit( GetUserUnits(), coord.y * Ysign );
wxString pagesizeformatter = _( "Page size: width %.4g height %.4g" );
wxString absformatter = wxT( "X %.4g Y %.4g" );
@ -572,8 +571,8 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
SetStatusText( line, 2 );
// Display relative coordinates:
int dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
int dy = GetCrossHairPosition().y - 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 * Xsign );
dYpos = To_User_Unit( GetUserUnits(), dy * Ysign );
line.Printf( locformatter, dXpos, dYpos );
@ -581,7 +580,7 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
// Display corner reference for coord origin
line.Printf( _("coord origin: %s"),
m_originSelectBox->GetString( m_originSelectChoice ). GetData() );
m_originSelectBox->GetString( m_originSelectChoice ).GetData() );
SetStatusText( line, 4 );
// Display units

View File

@ -259,7 +259,6 @@ set( PCBNEW_CLASS_SRCS
menubar_pcb_editor.cpp
microwave.cpp
netlist.cpp
pad_edit_functions.cpp
pad_naming.cpp
pcb_base_edit_frame.cpp
pcb_layer_box_selector.cpp

View File

@ -1477,7 +1477,7 @@ wxString LayerMaskDescribe( const BOARD *aBoard, LSET aMask )
}
void D_PAD::ImportSettingsFromMaster( const D_PAD& aMasterPad )
void D_PAD::ImportSettingsFrom( const D_PAD& aMasterPad )
{
SetShape( aMasterPad.GetShape() );
SetLayerSet( aMasterPad.GetLayerSet() );

View File

@ -165,7 +165,7 @@ public:
* as aMasterPad
* @param aMasterPad = the template pad
*/
void ImportSettingsFromMaster( const D_PAD& aMasterPad );
void ImportSettingsFrom( const D_PAD& aMasterPad );
/**
* @return true if the pad has a footprint parent flipped

View File

@ -183,7 +183,7 @@ void DIALOG_POSITION_RELATIVE::OnUseUserOriginClick( wxCommandEvent& event )
{
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) m_toolMgr->GetEditFrame();
m_anchor_position = frame->GetScreen()->m_O_Curseur;
m_anchor_position = (wxPoint) frame->GetScreen()->m_LocalOrigin;
m_referenceInfo->SetLabel( _( "Reference location: local coordinates origin" ) );
}

View File

@ -110,8 +110,6 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() )
{
m_showBorderAndTitleBlock = false; // true to show the frame references
m_showAxis = true; // true to show X and Y axis on screen
m_showGridAxis = true; // show the grid origin axis
m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
m_canvasType = aBackend;
m_AboutTitle = "ModEdit";

View File

@ -86,7 +86,7 @@ void FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary( LIB_ID aFPID)
if( !Clear_Pcb( true ) )
return;
SetCrossHairPosition( wxPoint( 0, 0 ) );
GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
AddModuleToBoard( module );
auto fp = GetBoard()->GetFirstModule();
@ -167,7 +167,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( !Clear_Pcb( true ) )
break;
SetCrossHairPosition( wxPoint( 0, 0 ) );
GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
AddModuleToBoard( module );
// Initialize data relative to nets and netclasses (for a new
@ -229,8 +229,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
Clear_Pcb( false );
SetCrossHairPosition( wxPoint( 0, 0 ) );
GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
// Add the new object to board
AddModuleToBoard( module );
@ -392,7 +391,7 @@ bool FOOTPRINT_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileS
if( ! Clear_Pcb( true ) )
return false; // //this command is aborted
SetCrossHairPosition( wxPoint( 0, 0 ) );
GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
Import_Module( aFileSet[0] );
if( GetBoard()->GetFirstModule() )

View File

@ -849,13 +849,14 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
}
else // This is an insert command
{
wxPoint cursor_pos = pcbframe->GetCrossHairPosition();
KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetGalCanvas()->GetViewControls();
VECTOR2D cursorPos = viewControls->GetCursorPosition();
commit.Add( newmodule );
pcbframe->SetCrossHairPosition( wxPoint( 0, 0 ) );
viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
pcbframe->PlaceModule( newmodule );
newmodule->SetPosition( wxPoint( 0, 0 ) );
pcbframe->SetCrossHairPosition( cursor_pos );
viewControls->SetCrossHairCursorPosition( cursorPos, false );
newmodule->SetTimeStamp( GetNewTimeStamp() );
commit.Push( wxT( "Insert module" ) );

View File

@ -70,9 +70,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
EVT_SIZE( FOOTPRINT_VIEWER_FRAME::OnSize )
EVT_ACTIVATE( FOOTPRINT_VIEWER_FRAME::OnActivate )
// Menu (and/or hotkey) events
EVT_MENU( wxID_EXIT, FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer )
EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_VIEWER_FRAME::OnSetRelativeOffset )
// Toolbar events
EVT_TOOL( ID_MODVIEW_SELECT_PART, FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint )
@ -133,8 +131,6 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
// but only one configuration is preferable.
m_configName = FOOTPRINT_VIEWER_FRAME_NAME;
m_showAxis = true; // true to draw axis.
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) );
@ -283,13 +279,6 @@ void FOOTPRINT_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
}
void FOOTPRINT_VIEWER_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
{
GetScreen()->m_O_Curseur = GetCrossHairPosition();
UpdateStatusBar();
}
void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList()
{
m_libList->Clear();
@ -472,13 +461,14 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& event )
newmodule->SetParent( pcbframe->GetBoard() );
newmodule->SetLink( 0 );
wxPoint cursor_pos = pcbframe->GetCrossHairPosition();
KIGFX::VIEW_CONTROLS* viewControls = pcbframe->GetGalCanvas()->GetViewControls();
VECTOR2D cursorPos = viewControls->GetCursorPosition();
commit.Add( newmodule );
pcbframe->SetCrossHairPosition( wxPoint( 0, 0 ) );
viewControls->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
pcbframe->PlaceModule( newmodule );
newmodule->SetPosition( wxPoint( 0, 0 ) );
pcbframe->SetCrossHairPosition( cursor_pos );
viewControls->SetCrossHairCursorPosition( cursorPos, false );
newmodule->SetTimeStamp( GetNewTimeStamp() );
commit.Push( wxT( "Insert module" ) );

View File

@ -117,7 +117,6 @@ private:
void ClickOnLibList( wxCommandEvent& event );
void ClickOnFootprintList( wxCommandEvent& event );
void DClickOnFootprintList( wxCommandEvent& event );
void OnSetRelativeOffset( wxCommandEvent& event );
void InstallDisplayOptions( wxCommandEvent& event );

View File

@ -71,8 +71,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList )
EVT_GRID_CMD_CELL_CHANGED( ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
FOOTPRINT_WIZARD_FRAME::ParametersUpdated )
EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset )
END_EVENT_TABLE()
@ -92,8 +90,6 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent
// This frame is always show modal:
SetModal( true );
m_showAxis = true; // true to draw axis.
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) );
@ -294,13 +290,6 @@ void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv )
}
void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
{
GetScreen()->m_O_Curseur = GetCrossHairPosition();
UpdateStatusBar();
}
void FOOTPRINT_WIZARD_FRAME::updateView()
{
auto dp = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );

View File

@ -179,7 +179,6 @@ private:
void ReCreateHToolbar() override;
void ReCreateVToolbar() override;
void ClickOnPageList( wxCommandEvent& event );
void OnSetRelativeOffset( wxCommandEvent& event );
void LoadSettings( wxConfigBase* aCfg ) override;
void SaveSettings( wxConfigBase* aCfg ) override;

View File

@ -33,6 +33,7 @@ using namespace std::placeholders;
#include <kicad_string.h>
#include <pgm_base.h>
#include <kiway.h>
#include <view/view_controls.h>
#include <pcb_edit_frame.h>
#include <dialog_helpers.h>
#include <filter_reader.h>
@ -126,7 +127,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
// so we force the ORPHANED dummy net info for all pads
newModule->ClearAllNets();
SetCrossHairPosition( wxPoint( 0, 0 ) );
GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
PlaceModule( newModule );
newModule->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment
@ -469,8 +470,6 @@ MODULE* PCB_BASE_FRAME::GetFootprintFromBoardByReference()
void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, bool aRecreateRatsnest )
{
wxPoint newpos;
if( aModule == 0 )
return;
@ -499,8 +498,7 @@ void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, bool aRecreateRatsnest )
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
newpos = GetCrossHairPosition();
aModule->SetPosition( newpos );
aModule->SetPosition( (wxPoint) GetGalCanvas()->GetViewControls()->GetCursorPosition() );
aModule->ClearFlags();
delete s_ModuleInitialCopy;

View File

@ -106,7 +106,7 @@ void PCB_EDIT_FRAME::OnNetlistChanged( BOARD_NETLIST_UPDATER& aUpdater,
std::vector<MODULE*> newFootprints = aUpdater.GetAddedComponents();
// Spread new footprints.
wxPoint areaPosition = GetCrossHairPosition();
wxPoint areaPosition = (wxPoint) GetGalCanvas()->GetViewControls()->GetCursorPosition();
EDA_RECT bbox = board->GetBoundingBox();
GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );

View File

@ -1,177 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2018 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
*/
#include <fctsys.h>
#include <confirm.h>
#include <trigo.h>
#include <macros.h>
#include <pcb_base_frame.h>
#include <pcb_edit_frame.h>
#include <footprint_edit_frame.h>
#include <pcbnew.h>
#include <class_board.h>
#include <class_module.h>
#include <class_pad.h>
#include <board_design_settings.h>
#include <dialog_push_pad_properties.h>
/*
* Exports the current pad settings to board design settings.
*/
void PCB_BASE_FRAME::Export_Pad_Settings( D_PAD* aPad )
{
if( aPad == NULL )
return;
SetMsgPanel( aPad );
D_PAD& masterPad = GetDesignSettings().m_Pad_Master;
masterPad.ImportSettingsFromMaster( *aPad );
}
/*
* Imports the board design settings to aPad
* - The position, names, and keys are not modifed.
* The parameters are expected to be correct (i.e. settings are valid)
*/
void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
{
if( aDraw )
{
aPad->SetFlags( DO_NOT_DRAW );
GetGalCanvas()->Refresh();
aPad->ClearFlags( DO_NOT_DRAW );
}
const D_PAD& mp = GetDesignSettings().m_Pad_Master;
aPad->ImportSettingsFromMaster( mp );
if( aDraw )
GetGalCanvas()->Refresh();
aPad->GetParent()->SetLastEditTime();
OnModify();
}
/*
* Compute the 'next' pad number for autoincrement
* aPadName is the last pad name used
* */
static wxString GetNextPadName( wxString aPadName )
{
// Automatically increment the current pad number.
int num = 0;
int ponder = 1;
// Trim and extract the trailing numeric part
while( aPadName.Len() && aPadName.Last() >= '0' && aPadName.Last() <= '9' )
{
num += ( aPadName.Last() - '0' ) * ponder;
aPadName.RemoveLast();
ponder *= 10;
}
num++; // Use next number for the new pad
aPadName << num;
return aPadName;
}
/*
* Add a new pad to aModule.
*/
void PCB_BASE_FRAME::AddPad( MODULE* aModule, bool draw )
{
aModule->SetLastEditTime();
D_PAD* pad = new D_PAD( aModule );
// Add the new pad to end of the module pad list.
aModule->Add( pad );
// Update the pad properties,
// and keep NETINFO_LIST::ORPHANED as net info
// which is the default when nets cannot be handled.
Import_Pad_Settings( pad, false );
pad->SetPosition( GetCrossHairPosition() );
// Set the relative pad position
// ( pad position for module orient, 0, and relative to the module position)
wxPoint pos0 = pad->GetPosition() - aModule->GetPosition();
RotatePoint( &pos0, -aModule->GetOrientation() );
pad->SetPos0( pos0 );
/* NPTH pads take empty pad number (since they can't be connected),
* other pads get incremented from the last one edited */
wxString padName;
if( pad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED )
padName = GetNextPadName( GetDesignSettings().m_Pad_Master.GetName() );
pad->SetName( padName );
GetDesignSettings().m_Pad_Master.SetName( padName );
aModule->CalculateBoundingBox();
SetMsgPanel( pad );
if( draw )
GetGalCanvas()->Refresh();
}
void PCB_BASE_FRAME::DeletePad( D_PAD* aPad, bool aQuery )
{
if( aPad == NULL )
return;
MODULE* module = aPad->GetParent();
module->SetLastEditTime();
// aQuery = true to prompt for confirmation, false to delete silently
if( aQuery )
{
wxString msg = wxString::Format( _( "Delete pad (footprint %s %s)?" ),
module->GetReference(),
module->GetValue() );
if( !IsOK( this, msg ) )
return;
}
GetBoard()->PadDelete( aPad );
// Update the bounding box
module->CalculateBoundingBox();
GetGalCanvas()->Refresh();
OnModify();
}

View File

@ -601,42 +601,30 @@ void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
*/
void PCB_BASE_FRAME::UpdateStatusBar()
{
PCB_SCREEN* screen = GetScreen();
EDA_DRAW_FRAME::UpdateStatusBar();
BASE_SCREEN* screen = GetScreen();
if( !screen )
return;
wxString line;
wxString locformatter;
EDA_DRAW_FRAME::UpdateStatusBar();
VECTOR2D cursorPos = GetGalCanvas()->GetViewControls()->GetCursorPosition();
if( GetShowPolarCoords() ) // display polar coordinates
{
double dx = (double)GetCrossHairPosition().x - (double)screen->m_O_Curseur.x;
double dy = (double)GetCrossHairPosition().y - (double)screen->m_O_Curseur.y;
double theta = ArcTangente( -dy, dx ) / 10;
double 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 = "r %.6f theta %.1f";
break;
case MILLIMETRES:
formatter = "r %.6f theta %.1f";
break;
case UNSCALED_UNITS:
formatter = "r %f theta %f";
break;
case DEGREES:
wxASSERT( false );
break;
case INCHES: formatter = wxT( "r %.6f theta %.1f" ); break;
case MILLIMETRES: formatter = wxT( "r %.6f theta %.1f" ); break;
case UNSCALED_UNITS: formatter = wxT( "r %f theta %f" ); break;
case DEGREES: wxASSERT( false ); break;
}
line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta );
@ -645,11 +633,12 @@ void PCB_BASE_FRAME::UpdateStatusBar()
}
// Display absolute coordinates:
double dXpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().x );
double dYpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().y );
double dXpos = To_User_Unit( GetUserUnits(), cursorPos.x );
double dYpos = To_User_Unit( GetUserUnits(), cursorPos.y );
// The following sadly is an if Eeschema/if Pcbnew
wxString absformatter;
wxString locformatter;
switch( GetUserUnits() )
{
@ -679,10 +668,8 @@ void PCB_BASE_FRAME::UpdateStatusBar()
if( !GetShowPolarCoords() ) // display relative cartesian coordinates
{
// 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;
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( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );

View File

@ -184,9 +184,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PCB_EDIT_FRAME_NAME )
{
m_showBorderAndTitleBlock = true; // true to display sheet references
m_showAxis = false; // true to display X and Y axis
m_showOriginAxis = true;
m_showGridAxis = true;
m_SelTrackWidthBox = NULL;
m_SelViaSizeBox = NULL;
m_SelLayerBox = NULL;

View File

@ -15,7 +15,6 @@ enum pcbnew_ids
{
ID_MAIN_MENUBAR = ID_END_LIST,
ID_MICROWAVE_V_TOOLBAR,
ID_SET_RELATIVE_OFFSET,
ID_COPY_BOARD_AS,
ID_IMPORT_NON_KICAD_BOARD,

View File

@ -1004,9 +1004,9 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
Activate();
bool direction45 = false; // 45 degrees only mode
bool started = false;
bool IsOCurseurSet = ( m_frame->GetScreen()->m_O_Curseur != wxPoint( 0, 0 ) );
bool direction45 = false; // 45 degrees only mode
bool started = false;
bool isLocalOriginSet = ( m_frame->GetScreen()->m_LocalOrigin != VECTOR2D( 0, 0 ) );
VECTOR2I cursorPos = m_controls->GetMousePosition();
if( aStartingPoint )
@ -1015,7 +1015,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
aGraphic->SetShape( (STROKE_T) aShape );
aGraphic->SetWidth( m_lineWidth );
aGraphic->SetLayer( getDrawingLayer() );
aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) );
aGraphic->SetStart( (wxPoint) aStartingPoint.get() );
cursorPos = grid.BestSnapAnchor( cursorPos, aGraphic );
m_controls->ForceCursorPosition( true, cursorPos );
@ -1025,8 +1025,8 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
m_controls->SetAutoPan( true );
m_controls->CaptureCursor( true );
if( !IsOCurseurSet )
m_frame->GetScreen()->m_O_Curseur = wxPoint( aStartingPoint->x, aStartingPoint->y );
if( !isLocalOriginSet )
m_frame->GetScreen()->m_LocalOrigin = aStartingPoint.get();
started = true;
}
@ -1070,9 +1070,11 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
preview.Clear();
m_view->Update( &preview );
delete aGraphic;
aGraphic = NULL;
if( !IsOCurseurSet )
m_frame->GetScreen()->m_O_Curseur = wxPoint( 0, 0 );
aGraphic = nullptr;
if( !isLocalOriginSet )
m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 );
break;
}
else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
@ -1100,8 +1102,8 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
aGraphic->SetEnd( (wxPoint) cursorPos );
aGraphic->SetLayer( getDrawingLayer() );
if( !IsOCurseurSet )
m_frame->GetScreen()->m_O_Curseur = (wxPoint) cursorPos;
if( !isLocalOriginSet )
m_frame->GetScreen()->m_LocalOrigin = cursorPos;
preview.Add( aGraphic );
frame()->SetMsgPanel( aGraphic );
@ -1137,7 +1139,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
commit.Push( _( "Draw a line" ) );
delete aGraphic;
aGraphic = NULL;
aGraphic = nullptr;
}
preview.Clear();
@ -1182,12 +1184,12 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
}
else if( evt->IsAction( &ACTIONS::resetLocalCoords ) )
{
IsOCurseurSet = true;
isLocalOriginSet = true;
}
}
if( !IsOCurseurSet ) // reset the relative coordinte if it was not set before
m_frame->GetScreen()->m_O_Curseur = wxPoint( 0, 0 );
if( !isLocalOriginSet ) // reset the relative coordinte if it was not set before
m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 );
m_view->Remove( &preview );
frame()->SetMsgPanel( board() );

View File

@ -1049,7 +1049,7 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
item->Rotate( selCenter, rotation );
break;
case ROTATE_AROUND_USER_ORIGIN:
item->Rotate( editFrame->GetScreen()->m_O_Curseur, rotation );
item->Rotate( (wxPoint) editFrame->GetScreen()->m_LocalOrigin, rotation );
break;
case ROTATE_AROUND_AUX_ORIGIN:
item->Rotate( editFrame->GetAuxOrigin(), rotation );
@ -1395,7 +1395,7 @@ bool EDIT_TOOL::pickCopyReferencePoint( VECTOR2I& aP )
}
int EDIT_TOOL::doCopyToClipboard( bool withAnchor )
int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent )
{
CLIPBOARD_IO io;
@ -1408,17 +1408,14 @@ int EDIT_TOOL::doCopyToClipboard( bool withAnchor )
if( selection.Empty() )
return 1;
if( withAnchor )
{
VECTOR2I refPoint;
bool rv = pickCopyReferencePoint( refPoint );
frame()->SetMsgPanel( board() );
VECTOR2I refPoint;
bool rv = pickCopyReferencePoint( refPoint );
frame()->SetMsgPanel( board() );
if( !rv )
return 1;
if( !rv )
return 1;
selection.SetReferencePoint( refPoint );
}
selection.SetReferencePoint( refPoint );
io.SetBoard( board() );
io.SaveSelection( selection );
@ -1427,18 +1424,6 @@ int EDIT_TOOL::doCopyToClipboard( bool withAnchor )
}
int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent )
{
return doCopyToClipboard( true );
}
int EDIT_TOOL::copyToClipboardWithAnchor( const TOOL_EVENT& aEvent )
{
return doCopyToClipboard( true );
}
int EDIT_TOOL::cutToClipboard( const TOOL_EVENT& aEvent )
{
if( !copyToClipboard( aEvent ) )

View File

@ -169,10 +169,6 @@ public:
*/
int copyToClipboard( const TOOL_EVENT& aEvent );
int copyToClipboardWithAnchor( const TOOL_EVENT& aEvent );
int doCopyToClipboard( bool withAnchor );
/**
* Function cutToClipboard()
* Cuts the current selection to the clipboard by formatting it as a fake pcb

View File

@ -307,7 +307,7 @@ int MODULE_EDITOR_TOOLS::ImportFootprint( const TOOL_EVENT& aEvent )
if( !m_frame->Clear_Pcb( true ) )
return -1; // this command is aborted
m_frame->SetCrossHairPosition( wxPoint( 0, 0 ) );
getViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
m_frame->Import_Module();
if( m_frame->GetBoard()->GetFirstModule() )
@ -380,7 +380,7 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
std::unique_ptr<BOARD_ITEM> CreateItem() override
{
D_PAD* pad = new D_PAD( m_board->GetFirstModule() );
m_frame->Import_Pad_Settings( pad, false ); // use the global settings for pad
pad->ImportSettingsFrom( m_frame->GetDesignSettings().m_Pad_Master );
pad->IncrementPadName( true, true );
return std::unique_ptr<BOARD_ITEM>( pad );
}
@ -391,7 +391,7 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
if( pad )
{
m_frame->Export_Pad_Settings( pad );
m_frame->GetDesignSettings().m_Pad_Master.ImportSettingsFrom( *pad );
pad->SetLocalCoord();
aCommit.Add( aItem );
return true;

View File

@ -219,7 +219,7 @@ int PAD_TOOL::pastePadProperties( const TOOL_EVENT& aEvent )
if( item->Type() == PCB_PAD_T )
{
commit.Modify( item );
static_cast<D_PAD&>( *item ).ImportSettingsFromMaster( masterPad );
static_cast<D_PAD&>( *item ).ImportSettingsFrom( masterPad );
}
}
@ -247,7 +247,7 @@ int PAD_TOOL::copyPadSettings( const TOOL_EVENT& aEvent )
if( item->Type() == PCB_PAD_T )
{
const auto& selPad = static_cast<const D_PAD&>( *item );
masterPad.ImportSettingsFromMaster( selPad );
masterPad.ImportSettingsFrom( selPad );
m_padCopied = true;
}
}
@ -293,7 +293,7 @@ static void doPushPadProperties( BOARD& board, const D_PAD& aSrcPad, BOARD_COMMI
commit.Modify( pad );
// Apply source pad settings to this pad
pad->ImportSettingsFromMaster( aSrcPad );
pad->ImportSettingsFrom( aSrcPad );
}
}
}