From efb34166ea5a0c7e0dc63d63173b0820f577144b Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Sat, 3 Aug 2013 00:15:23 -0500 Subject: [PATCH 1/6] *) retain grid origin in the BOARD and save it in legacy and kicad board files. *) add hotkey for setting the grid origin as 'S', in board editor, module editor. *) re-position the function interface for cursor movement from BASE_SCREEN into class EDA_DRAW_FRAME. This is a prelude to getting rid of BASE_SCREEN or splitting it up. --- common/base_screen.cpp | 26 +- common/base_units.cpp | 23 +- common/block_commande.cpp | 36 +- common/drawframe.cpp | 82 ++++- common/drawpanel.cpp | 56 ++-- common/pcb.keywords | 1 + common/zoom.cpp | 18 +- cvpcb/class_DisplayFootprintsFrame.cpp | 16 +- eeschema/block.cpp | 20 +- eeschema/block_libedit.cpp | 12 +- eeschema/bus-wire-junction.cpp | 10 +- eeschema/busentry.cpp | 10 +- eeschema/controle.cpp | 47 ++- eeschema/dialogs/dialog_erc.cpp | 4 +- eeschema/edit_bitmap.cpp | 6 +- eeschema/edit_label.cpp | 8 +- eeschema/find.cpp | 9 +- eeschema/getpart.cpp | 2 +- eeschema/hierarch.cpp | 4 +- eeschema/hotkeys.cpp | 28 +- eeschema/libeditframe.cpp | 10 +- eeschema/onrightclick.cpp | 12 +- eeschema/pinedit.cpp | 16 +- eeschema/sch_base_frame.cpp | 17 +- eeschema/schedit.cpp | 20 +- eeschema/schframe.cpp | 2 +- eeschema/sheet.cpp | 19 +- eeschema/symbdraw.cpp | 26 +- eeschema/symbedit.cpp | 6 +- eeschema/viewlib_frame.cpp | 14 +- gerbview/block.cpp | 13 +- gerbview/class_gbr_layout.h | 4 +- gerbview/controle.cpp | 14 +- gerbview/gerbview_frame.cpp | 23 +- gerbview/gerbview_frame.h | 14 +- gerbview/hotkeys.cpp | 44 +-- gerbview/locate.cpp | 2 +- include/class_base_screen.h | 226 ++++++------- include/class_board_design_settings.h | 2 + include/class_drawpanel.h | 74 +++-- include/class_sch_screen.h | 12 +- include/hotkeys_basic.h | 1 + include/sch_base_frame.h | 11 +- include/wxBasePcbFrame.h | 7 +- include/wxstruct.h | 135 ++++++-- pagelayout_editor/class_pl_editor_layout.h | 2 +- pagelayout_editor/controle.cpp | 21 +- pagelayout_editor/events_functions.cpp | 10 +- pagelayout_editor/hotkeys.cpp | 6 +- pagelayout_editor/pl_editor_frame.cpp | 73 +++-- pagelayout_editor/pl_editor_frame.h | 17 +- pcbnew/autorouter/automove.cpp | 18 +- pcbnew/autorouter/autoplac.cpp | 96 +++--- pcbnew/basepcbframe.cpp | 42 ++- pcbnew/block.cpp | 46 +-- pcbnew/block_module_editor.cpp | 46 +-- pcbnew/class_board.h | 22 +- pcbnew/controle.cpp | 28 +- pcbnew/cross-probing.cpp | 4 +- pcbnew/dialogs/dialog_SVG_print.cpp | 6 +- .../dialog_edit_module_for_BoardEditor.cpp | 20 +- .../dialog_edit_module_for_Modedit.cpp | 34 +- pcbnew/dialogs/dialog_gendrill.cpp | 2 +- pcbnew/dialogs/dialog_set_grid.cpp | 6 +- pcbnew/dimension.cpp | 8 +- pcbnew/edgemod.cpp | 10 +- pcbnew/edit.cpp | 30 +- pcbnew/edit_pcb_text.cpp | 8 +- pcbnew/editedge.cpp | 54 +-- pcbnew/editrack.cpp | 28 +- pcbnew/edtxtmod.cpp | 18 +- pcbnew/export_gencad.cpp | 8 +- pcbnew/footprint_wizard_frame.cpp | 36 +- pcbnew/gen_modules_placefile.cpp | 2 +- pcbnew/highlight.cpp | 2 +- pcbnew/hotkeys.cpp | 25 +- pcbnew/hotkeys_board_editor.cpp | 34 +- pcbnew/hotkeys_module_editor.cpp | 11 +- pcbnew/kicad_plugin.cpp | 8 +- pcbnew/legacy_plugin.cpp | 23 +- pcbnew/librairi.cpp | 2 +- pcbnew/loadcmp.cpp | 6 +- pcbnew/magnetic_tracks_functions.cpp | 3 +- pcbnew/mirepcb.cpp | 12 +- pcbnew/modedit.cpp | 308 +++++++++--------- pcbnew/modedit_onclick.cpp | 39 ++- pcbnew/moduleframe.cpp | 14 +- pcbnew/modules.cpp | 4 +- pcbnew/modview_frame.cpp | 18 +- pcbnew/move-drag_pads.cpp | 3 +- pcbnew/move_or_drag_track.cpp | 36 +- pcbnew/muonde.cpp | 11 +- pcbnew/onleftclick.cpp | 10 +- pcbnew/onrightclick.cpp | 16 +- pcbnew/pad_edition_functions.cpp | 2 +- pcbnew/pcb_parser.cpp | 76 +++-- pcbnew/plot_board_layers.cpp | 2 +- pcbnew/xchgmod.cpp | 26 +- pcbnew/zones_by_polygon.cpp | 16 +- scripts/lib_convert.py | 4 +- 100 files changed, 1373 insertions(+), 1181 deletions(-) diff --git a/common/base_screen.cpp b/common/base_screen.cpp index efd6b3efe3..a47f21386d 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -288,10 +288,10 @@ GRID_TYPE& BASE_SCREEN::GetGrid( size_t aIndex ) } -wxPoint BASE_SCREEN::GetNearestGridPosition( const wxPoint& aPosition, - wxRealPoint* aGridSize ) const +wxPoint BASE_SCREEN::getNearestGridPosition( const wxPoint& aPosition, + const wxPoint& aGridOrigin, wxRealPoint* aGridSize ) const { - wxPoint pt; + wxPoint pt; wxRealPoint gridSize; if( aGridSize ) @@ -299,13 +299,13 @@ wxPoint BASE_SCREEN::GetNearestGridPosition( const wxPoint& aPosition, else gridSize = GetGridSize(); - wxPoint gridOrigin = m_GridOrigin; - - double offset = fmod( gridOrigin.x, gridSize.x ); + double offset = fmod( aGridOrigin.x, gridSize.x ); int x = KiROUND( (aPosition.x - offset) / gridSize.x ); + pt.x = KiROUND( x * gridSize.x + offset ); - offset = fmod( gridOrigin.y, gridSize.y ); + offset = fmod( aGridOrigin.y, gridSize.y ); + int y = KiROUND( (aPosition.y - offset) / gridSize.y ); pt.y = KiROUND ( y * gridSize.y + offset ); @@ -313,19 +313,19 @@ wxPoint BASE_SCREEN::GetNearestGridPosition( const wxPoint& aPosition, } -wxPoint BASE_SCREEN::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize ) const +wxPoint BASE_SCREEN::getCursorPosition( bool aOnGrid, const wxPoint& aGridOrigin, wxRealPoint* aGridSize ) const { if( aOnGrid ) - return GetNearestGridPosition( m_crossHairPosition, aGridSize ); + return getNearestGridPosition( m_crossHairPosition, aGridOrigin, aGridSize ); return m_crossHairPosition; } -wxPoint BASE_SCREEN::GetCrossHairScreenPosition() const +wxPoint BASE_SCREEN::getCrossHairScreenPosition() const { wxPoint pos = m_crossHairPosition - m_DrawOrg; - double scalar = GetScalingFactor(); + double scalar = GetScalingFactor(); pos.x = KiROUND( (double) pos.x * scalar ); pos.y = KiROUND( (double) pos.y * scalar ); @@ -334,10 +334,10 @@ wxPoint BASE_SCREEN::GetCrossHairScreenPosition() const } -void BASE_SCREEN::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid ) +void BASE_SCREEN::setCrossHairPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin, bool aSnapToGrid ) { if( aSnapToGrid ) - m_crossHairPosition = GetNearestGridPosition( aPosition ); + m_crossHairPosition = getNearestGridPosition( aPosition, aGridOrigin ); else m_crossHairPosition = aPosition; } diff --git a/common/base_units.cpp b/common/base_units.cpp index e0d602812e..76dcc5d8c1 100644 --- a/common/base_units.cpp +++ b/common/base_units.cpp @@ -34,6 +34,7 @@ * depending on the application. */ +#include #include #include #include @@ -187,7 +188,7 @@ void StripTrailingZeros( wxString& aStringValue, unsigned aTrailingZeroAllowed ) /* Convert a value to a string using double notation. - * For readability, the mantissa has 3 or more digits (max 8 digits), + * For readability, the mantissa has 3 or more digits, * the trailing 0 are removed if the mantissa has more than 3 digits * and some trailing 0 * This function should be used to display values in dialogs because a value @@ -198,23 +199,19 @@ void StripTrailingZeros( wxString& aStringValue, unsigned aTrailingZeroAllowed ) */ wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol ) { - wxString stringValue; - double value_to_print; - - value_to_print = To_User_Unit( aUnit, aValue ); + double value_to_print = To_User_Unit( aUnit, aValue ); #if defined( EESCHEMA ) - stringValue.Printf( wxT( "%.3f" ), value_to_print ); -#else - #if defined( USE_PCBNEW_NANOMETRES ) - stringValue.Printf( wxT( "%.8f" ), value_to_print ); - #else - stringValue.Printf( wxT( "%.4f" ), value_to_print ); - #endif + wxString stringValue = wxString::Format( wxT( "%.3f" ), value_to_print ); // Strip trailing zeros. However, keep at least 3 digits in mantissa // For readability StripTrailingZeros( stringValue, 3 ); + +#else + std::string s = Double2Str( value_to_print ); + wxString stringValue = FROM_UTF8( s.c_str() ); + #endif if( aAddUnitSymbol ) @@ -269,8 +266,6 @@ double From_User_Unit( EDA_UNITS_T aUnit, double aValue ) } - - int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue ) { double value; diff --git a/common/block_commande.cpp b/common/block_commande.cpp index cc0ae64629..19a7a0ccfa 100644 --- a/common/block_commande.cpp +++ b/common/block_commande.cpp @@ -42,8 +42,8 @@ BLOCK_SELECTOR::BLOCK_SELECTOR() : EDA_RECT() { - m_state = STATE_NO_BLOCK; /* State (enum BLOCK_STATE_T) of block. */ - m_command = BLOCK_IDLE; /* Type (enum BLOCK_COMMAND_T) of operation. */ + m_state = STATE_NO_BLOCK; // State (enum BLOCK_STATE_T) of block. + m_command = BLOCK_IDLE; // Type (enum BLOCK_COMMAND_T) of operation. m_color = BROWN; } @@ -62,24 +62,24 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame ) case BLOCK_IDLE: break; - case BLOCK_MOVE: /* Move */ - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + case BLOCK_MOVE: // Move + case BLOCK_PRESELECT_MOVE: // Move with preselection list msg = _( "Block Move" ); break; - case BLOCK_DRAG: /* Drag */ + case BLOCK_DRAG: // Drag msg = _( "Block Drag" ); break; - case BLOCK_COPY: /* Copy */ + case BLOCK_COPY: // Copy msg = _( "Block Copy" ); break; - case BLOCK_DELETE: /* Delete */ + case BLOCK_DELETE: // Delete msg = _( "Block Delete" ); break; - case BLOCK_SAVE: /* Save */ + case BLOCK_SAVE: // Save msg = _( "Block Save" ); break; @@ -87,20 +87,20 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame ) msg = _( "Block Paste" ); break; - case BLOCK_ZOOM: /* Window Zoom */ + case BLOCK_ZOOM: // Window Zoom msg = _( "Win Zoom" ); break; - case BLOCK_ROTATE: /* Rotate 90 deg */ + case BLOCK_ROTATE: // Rotate 90 deg msg = _( "Block Rotate" ); break; - case BLOCK_FLIP: /* Flip */ + case BLOCK_FLIP: // Flip msg = _( "Block Flip" ); break; case BLOCK_MIRROR_X: - case BLOCK_MIRROR_Y: /* mirror */ + case BLOCK_MIRROR_Y: // mirror msg = _( "Block Mirror" ); break; @@ -185,15 +185,15 @@ void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoin if( aErase ) block->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, block->GetColor() ); - block->SetLastCursorPosition( aPanel->GetScreen()->GetCrossHairPosition() ); - block->SetEnd( aPanel->GetScreen()->GetCrossHairPosition() ); + block->SetLastCursorPosition( aPanel->GetParent()->GetCrossHairPosition() ); + block->SetEnd( aPanel->GetParent()->GetCrossHairPosition() ); block->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, block->GetColor() ); if( block->GetState() == STATE_BLOCK_INIT ) { if( block->GetWidth() || block->GetHeight() ) - /* 2nd point exists: the rectangle is not surface anywhere */ + // 2nd point exists: the rectangle is not surface anywhere block->SetState( STATE_BLOCK_END ); } } @@ -203,14 +203,14 @@ void AbortBlockCurrentCommand( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) { BASE_SCREEN* screen = aPanel->GetScreen(); - if( aPanel->IsMouseCaptured() ) /* Erase current drawing on screen */ + if( aPanel->IsMouseCaptured() ) // Erase current drawing on screen { - /* Clear block outline. */ + // Clear block outline. aPanel->CallMouseCapture( aDC, wxDefaultPosition, false ); aPanel->SetMouseCapture( NULL, NULL ); screen->SetCurItem( NULL ); - /* Delete the picked wrapper if this is a picked list. */ + // Delete the picked wrapper if this is a picked list. if( screen->m_BlockLocate.GetCommand() != BLOCK_PASTE ) screen->m_BlockLocate.ClearItemsList(); } diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 56ac99c931..a05a9d8fc3 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -114,26 +114,18 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* aParent, m_snapToGrid = true; m_MsgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight(); - - //#define ZOOM_DISPLAY_SIZE 60 - //#define COORD_DISPLAY_SIZE 165 - //#define DELTA_DISPLAY_SIZE 245 - //#define UNITS_DISPLAY_SIZE 65 - #define FUNCTION_DISPLAY_SIZE 110 - CreateStatusBar( 6 ); // set the size of the status bar subwindows: wxWindow* stsbar = GetStatusBar(); - int dims[] = { - // balance of status bar on far left is set to a default or whatever is left over. + // remainder of status bar on far left is set to a default or whatever is left over. -1, - // When using GetTextSize() remember the width of '1' is not the same + // When using GetTextSize() remember the width of character '1' is not the same // as the width of '0' unless the font is fixed width, and it usually won't be. // zoom: @@ -148,7 +140,9 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* aParent, // units display, Inches is bigger than mm GetTextSize( _( "Inches" ), stsbar ).x + 10, - FUNCTION_DISPLAY_SIZE, + // Size for the panel used as "Current tool in play": will take longest string from + // void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) in pcbnew/edit.cpp + GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + 10, }; SetStatusWidths( DIM( dims ), dims ); @@ -381,7 +375,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event ) */ m_LastGridSizeId = id - ID_POPUP_GRID_LEVEL_1000; screen->SetGrid( id ); - screen->SetCrossHairPosition( screen->RefPos( true ) ); + SetCrossHairPosition( RefPos( true ) ); Refresh(); } @@ -409,7 +403,7 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event ) return; GetScreen()->SetZoom( selectedZoom ); - RedrawScreen( GetScreen()->GetScrollCenterPosition(), false ); + RedrawScreen( GetScrollCenterPosition(), false ); } } @@ -495,7 +489,7 @@ wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const wxPoint pos = aPosition; if( m_currentScreen != NULL && m_snapToGrid ) - pos = m_currentScreen->GetNearestGridPosition( aPosition ); + pos = GetNearestGridPosition( aPosition ); return pos; } @@ -878,7 +872,7 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU ) // Calculate the scroll bar position in internal units to place the // center position at the center of client rectangle. - screen->SetScrollCenterPosition( centerPositionIU ); + SetScrollCenterPosition( centerPositionIU ); double posX = centerPositionIU.x - clientRectIU.width /2.0 - screen->m_DrawOrg.x; double posY = centerPositionIU.y - clientRectIU.height/2.0 - screen->m_DrawOrg.y; @@ -931,3 +925,61 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU ) screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.y, noRefresh ); } + +//-----< BASE_SCREEN API moved here >-------------------------------------------- + +wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const +{ + return GetScreen()->getCrossHairPosition(); +} + + +void EDA_DRAW_FRAME::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid ) +{ + GetScreen()->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid ); +} + + +wxPoint EDA_DRAW_FRAME::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize ) const +{ + return GetScreen()->getCursorPosition( aOnGrid, GetGridOrigin(), aGridSize ); +} + + +wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize ) const +{ + return GetScreen()->getNearestGridPosition( aPosition, GetGridOrigin(), aGridSize ); +} + + +wxPoint EDA_DRAW_FRAME::GetCrossHairScreenPosition() const +{ + return GetScreen()->getCrossHairScreenPosition(); +} + + +void EDA_DRAW_FRAME::SetMousePosition( const wxPoint& aPosition ) +{ + GetScreen()->setMousePosition( aPosition ); +} + + +wxPoint EDA_DRAW_FRAME::RefPos( bool useMouse ) const +{ + return GetScreen()->refPos( useMouse ); +} + + +const wxPoint& EDA_DRAW_FRAME::GetScrollCenterPosition() const +{ + return GetScreen()->getScrollCenterPosition(); +} + + +void EDA_DRAW_FRAME::SetScrollCenterPosition( const wxPoint& aPoint ) +{ + GetScreen()->setScrollCenterPosition( aPoint ); +} + +//------------------------------------------------- + diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index 1e47b8e8c5..521c73e771 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -181,7 +181,7 @@ void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, EDA_COLOR_T aColor ) if( m_cursorLevel != 0 || aDC == NULL || !m_showCrossHair ) return; - wxPoint cursor = GetScreen()->GetCrossHairPosition(); + wxPoint cursor = GetParent()->GetCrossHairPosition(); GRSetDrawMode( aDC, GR_XOR ); @@ -297,7 +297,7 @@ wxPoint EDA_DRAW_PANEL::GetScreenCenterLogicalPosition() void EDA_DRAW_PANEL::MoveCursorToCrossHair() { - MoveCursor( GetScreen()->GetCrossHairPosition() ); + MoveCursor( GetParent()->GetCrossHairPosition() ); } @@ -433,10 +433,10 @@ void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event ) double scale = GetParent()->GetScreen()->GetScalingFactor(); - wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition(); + wxPoint center = GetParent()->GetScrollCenterPosition(); center.x += KiROUND( (double) ( x - tmpX ) / scale ); center.y += KiROUND( (double) ( y - tmpY ) / scale ); - GetParent()->GetScreen()->SetScrollCenterPosition( center ); + GetParent()->SetScrollCenterPosition( center ); Scroll( x, y ); event.Skip(); @@ -609,7 +609,7 @@ void EDA_DRAW_PANEL::DrawBackGround( wxDC* DC ) DrawAuxiliaryAxis( DC, GR_COPY ); if( GetParent()->m_showGridAxis ) - DrawGridAxis( DC, GR_COPY ); + DrawGridAxis( DC, GR_COPY, GetParent()->GetGridOrigin() ); } @@ -645,7 +645,7 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC ) if( screenGridSize.x < MIN_GRID_SIZE || screenGridSize.y < MIN_GRID_SIZE ) return; - org = screen->GetNearestGridPosition( org, &gridSize ); + org = GetParent()->GetNearestGridPosition( org, &gridSize ); // Setting the nearest grid position can select grid points outside the clip box. // Incrementing the start point by one grid step should prevent drawing grid points @@ -740,7 +740,7 @@ void EDA_DRAW_PANEL::DrawGrid( wxDC* aDC ) void EDA_DRAW_PANEL::DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode ) { - wxPoint origin = GetParent()->GetOriginAxisPosition(); + wxPoint origin = GetParent()->GetAuxOrigin(); if( origin == wxPoint( 0, 0 ) ) return; @@ -768,33 +768,30 @@ void EDA_DRAW_PANEL::DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode ) } -void EDA_DRAW_PANEL::DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode ) +void EDA_DRAW_PANEL::DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aGridOrigin ) { - BASE_SCREEN* screen = GetScreen(); - - if( !GetParent()->m_showGridAxis - || ( screen->m_GridOrigin.x == 0 && screen->m_GridOrigin.y == 0 ) ) + if( !GetParent()->m_showGridAxis || ( !aGridOrigin.x && !aGridOrigin.y ) ) return; - EDA_COLOR_T color = GetParent()->GetGridColor(); - wxSize pageSize = GetParent()->GetPageSizeIU(); + EDA_COLOR_T color = GetParent()->GetGridColor(); + wxSize pageSize = GetParent()->GetPageSizeIU(); GRSetDrawMode( aDC, aDrawMode ); // Draw the Y axis GRDashedLine( &m_ClipBox, aDC, - screen->m_GridOrigin.x, + aGridOrigin.x, -pageSize.y, - screen->m_GridOrigin.x, + aGridOrigin.x, pageSize.y, 0, color ); // Draw the X axis GRDashedLine( &m_ClipBox, aDC, -pageSize.x, - screen->m_GridOrigin.y, + aGridOrigin.y, pageSize.x, - screen->m_GridOrigin.y, + aGridOrigin.y, 0, color ); } @@ -846,7 +843,7 @@ void EDA_DRAW_PANEL::OnMouseLeaving( wxMouseEvent& event ) cross_hair_pos.x = dc.DeviceToLogicalX( cross_hair_pos.x ); cross_hair_pos.y = dc.DeviceToLogicalY( cross_hair_pos.y ); - GetScreen()->SetCrossHairPosition( cross_hair_pos ); + GetParent()->SetCrossHairPosition( cross_hair_pos ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_POPUP_ZOOM_CENTER ); cmd.SetEventObject( this ); @@ -876,7 +873,7 @@ void EDA_DRAW_PANEL::OnMouseWheel( wxMouseEvent& event ) } INSTALL_UNBUFFERED_DC( dc, this ); - GetScreen()->SetCrossHairPosition( event.GetLogicalPosition( dc ) ); + GetParent()->SetCrossHairPosition( event.GetLogicalPosition( dc ) ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); @@ -970,7 +967,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) DC.SetBackground( *wxBLACK_BRUSH ); // Compute the cursor position in drawing (logical) units. - screen->SetMousePosition( event.GetLogicalPosition( DC ) ); + GetParent()->SetMousePosition( event.GetLogicalPosition( DC ) ); int kbstat = 0; @@ -986,7 +983,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) // Calling Double Click and Click functions : if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) ) { - GetParent()->OnLeftDClick( &DC, screen->RefPos( true ) ); + GetParent()->OnLeftDClick( &DC, GetParent()->RefPos( true ) ); // inhibit a response to the mouse left button release, // because we have a double click, and we do not want a new @@ -1003,7 +1000,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) m_ignoreNextLeftButtonRelease = false; if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK && !ignoreEvt ) - GetParent()->OnLeftClick( &DC, screen->RefPos( true ) ); + GetParent()->OnLeftClick( &DC, GetParent()->RefPos( true ) ); } else if( !event.LeftIsDown() ) @@ -1027,7 +1024,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) m_PanStartCenter.y *= ppuy; } else - m_PanStartCenter = GetParent()->GetScreen()->GetScrollCenterPosition(); + m_PanStartCenter = GetParent()->GetScrollCenterPosition(); m_PanStartEventPosition = event.GetPosition(); @@ -1101,10 +1098,10 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) double scale = GetParent()->GetScreen()->GetScalingFactor(); - wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition(); + wxPoint center = GetParent()->GetScrollCenterPosition(); center.x += KiROUND( (double) ( x - tmpX ) / scale ) / ppux; center.y += KiROUND( (double) ( y - tmpY ) / scale ) / ppuy; - GetParent()->GetScreen()->SetScrollCenterPosition( center ); + GetParent()->SetScrollCenterPosition( center ); Refresh(); Update(); @@ -1164,7 +1161,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) * (a filter creates a delay for the real block command start, and * we must remember this point) */ - m_CursorStartPos = screen->GetCrossHairPosition(); + m_CursorStartPos = GetParent()->GetCrossHairPosition(); } if( m_enableBlockCommands && !(localbutt & GR_M_DCLICK) ) @@ -1323,17 +1320,14 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event ) INSTALL_UNBUFFERED_DC( DC, this ); - BASE_SCREEN* Screen = GetScreen(); - // Some key commands use the current mouse position: refresh it. pos = wxGetMousePosition() - GetScreenPosition(); // Compute the cursor position in drawing units. Also known as logical units to wxDC. pos = wxPoint( DC.DeviceToLogicalX( pos.x ), DC.DeviceToLogicalY( pos.y ) ); - Screen->SetMousePosition( pos ); + GetParent()->SetMousePosition( pos ); GetParent()->GeneralControl( &DC, pos, localkey ); - } diff --git a/common/pcb.keywords b/common/pcb.keywords index 1a7d902e68..93809b5d3a 100644 --- a/common/pcb.keywords +++ b/common/pcb.keywords @@ -76,6 +76,7 @@ fp_poly fp_text full general +grid_origin gr_arc gr_circle gr_curve diff --git a/common/zoom.cpp b/common/zoom.cpp index 2c25c7a19f..13db514edb 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -57,7 +57,7 @@ void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointe void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore ) { wxPoint dPos = posBefore - m_canvas->GetClientSize() / 2; // relative screen position to center before zoom - wxPoint newScreenPos = m_canvas->ToDeviceXY( GetScreen()->GetCrossHairPosition() ); // screen position of crosshair after zoom + wxPoint newScreenPos = m_canvas->ToDeviceXY( GetCrossHairPosition() ); // screen position of crosshair after zoom wxPoint newCenter = m_canvas->ToLogicalXY( newScreenPos - dPos ); AdjustScrollBars( newCenter ); @@ -80,9 +80,9 @@ void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer ) screen->SetScalingFactor( bestzoom ); if( screen->m_FirstRedraw ) - screen->SetCrossHairPosition( screen->GetScrollCenterPosition() ); + SetCrossHairPosition( GetScrollCenterPosition() ); - RedrawScreen( screen->GetScrollCenterPosition(), aWarpPointer ); + RedrawScreen( GetScrollCenterPosition(), aWarpPointer ); } @@ -120,19 +120,19 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) int id = event.GetId(); bool zoom_at_cursor = false; BASE_SCREEN* screen = GetScreen(); - wxPoint center = screen->GetScrollCenterPosition(); + wxPoint center = GetScrollCenterPosition(); switch( id ) { case ID_OFFCENTER_ZOOM_IN: - center = m_canvas->ToDeviceXY( screen->GetCrossHairPosition() ); + center = m_canvas->ToDeviceXY( GetCrossHairPosition() ); if( screen->SetPreviousZoom() ) RedrawScreen2( center ); break; case ID_POPUP_ZOOM_IN: zoom_at_cursor = true; - center = screen->GetCrossHairPosition(); + center = GetCrossHairPosition(); // fall thru case ID_ZOOM_IN: @@ -141,14 +141,14 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) break; case ID_OFFCENTER_ZOOM_OUT: - center = m_canvas->ToDeviceXY( screen->GetCrossHairPosition() ); + center = m_canvas->ToDeviceXY( GetCrossHairPosition() ); if( screen->SetNextZoom() ) RedrawScreen2( center ); break; case ID_POPUP_ZOOM_OUT: zoom_at_cursor = true; - center = screen->GetCrossHairPosition(); + center = GetCrossHairPosition(); // fall thru case ID_ZOOM_OUT: @@ -161,7 +161,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event ) break; case ID_POPUP_ZOOM_CENTER: - center = screen->GetCrossHairPosition(); + center = GetCrossHairPosition(); RedrawScreen( center, true ); break; diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 7f006ca337..b868985389 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -339,8 +339,8 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPositi wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); - pos = screen->GetNearestGridPosition( pos ); - oldpos = screen->GetCrossHairPosition(); + pos = GetNearestGridPosition( pos ); + oldpos = GetCrossHairPosition(); gridSize = screen->GetGridSize(); switch( aHotKey ) @@ -371,7 +371,7 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPositi break; case ' ': - screen->m_O_Curseur = screen->GetCrossHairPosition(); + screen->m_O_Curseur = GetCrossHairPosition(); break; case WXK_NUMPAD8: /* cursor moved up */ @@ -399,14 +399,14 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPositi break; } - screen->SetCrossHairPosition( pos ); + SetCrossHairPosition( pos ); - if( oldpos != screen->GetCrossHairPosition() ) + if( oldpos != GetCrossHairPosition() ) { - pos = screen->GetCrossHairPosition(); - screen->SetCrossHairPosition( oldpos ); + pos = GetCrossHairPosition(); + SetCrossHairPosition( oldpos ); m_canvas->CrossHairOff( aDC ); - screen->SetCrossHairPosition( pos ); + SetCrossHairPosition( pos ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) diff --git a/eeschema/block.cpp b/eeschema/block.cpp index ad288b2538..ffe41aa98c 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -215,7 +215,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) block->SetState( state ); block->SetCommand( command ); m_canvas->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand ); - GetScreen()->SetCrossHairPosition( block->GetEnd() ); + SetCrossHairPosition( block->GetEnd() ); if( block->GetCommand() != BLOCK_ABORT ) m_canvas->MoveCursorToCrossHair(); @@ -237,8 +237,8 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) { // Compute the rotation center and put it on grid: wxPoint rotationPoint = block->Centre(); - rotationPoint = GetScreen()->GetNearestGridPosition( rotationPoint ); - GetScreen()->SetCrossHairPosition( rotationPoint ); + rotationPoint = GetNearestGridPosition( rotationPoint ); + SetCrossHairPosition( rotationPoint ); SaveCopyInUndoList( block->GetItems(), UR_ROTATED, rotationPoint ); RotateListOfItems( block->GetItems(), rotationPoint ); OnModify(); @@ -433,8 +433,8 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC ) { /* Compute the rotation center and put it on grid */ wxPoint rotationPoint = block->Centre(); - rotationPoint = GetScreen()->GetNearestGridPosition( rotationPoint ); - GetScreen()->SetCrossHairPosition( rotationPoint ); + rotationPoint = GetNearestGridPosition( rotationPoint ); + SetCrossHairPosition( rotationPoint ); SaveCopyInUndoList( block->GetItems(), UR_ROTATED, rotationPoint ); RotateListOfItems( block->GetItems(), rotationPoint ); OnModify(); @@ -452,8 +452,8 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC ) { /* Compute the mirror center and put it on grid */ wxPoint mirrorPoint = block->Centre(); - mirrorPoint = GetScreen()->GetNearestGridPosition( mirrorPoint ); - GetScreen()->SetCrossHairPosition( mirrorPoint ); + mirrorPoint = GetNearestGridPosition( mirrorPoint ); + SetCrossHairPosition( mirrorPoint ); SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_X, mirrorPoint ); MirrorX( block->GetItems(), mirrorPoint ); OnModify(); @@ -471,8 +471,8 @@ void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC ) { /* Compute the mirror center and put it on grid */ wxPoint mirrorPoint = block->Centre(); - mirrorPoint = GetScreen()->GetNearestGridPosition( mirrorPoint ); - GetScreen()->SetCrossHairPosition( mirrorPoint ); + mirrorPoint = GetNearestGridPosition( mirrorPoint ); + SetCrossHairPosition( mirrorPoint ); SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_Y, mirrorPoint ); MirrorY( block->GetItems(), mirrorPoint ); OnModify(); @@ -519,7 +519,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx } /* Repaint new view. */ - block->SetMoveVector( screen->GetCrossHairPosition() - block->GetLastCursorPosition() ); + block->SetMoveVector( aPanel->GetParent()->GetCrossHairPosition() - block->GetLastCursorPosition() ); block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() ); for( unsigned ii = 0; ii < block->GetCount(); ii++ ) diff --git a/eeschema/block_libedit.cpp b/eeschema/block_libedit.cpp index 5f099321b1..b1eb193217 100644 --- a/eeschema/block_libedit.cpp +++ b/eeschema/block_libedit.cpp @@ -99,8 +99,8 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) GetScreen()->m_BlockLocate.SetState( state ); GetScreen()->m_BlockLocate.SetCommand( command ); m_canvas->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand ); - GetScreen()->SetCrossHairPosition( wxPoint( GetScreen()->m_BlockLocate.GetRight(), - GetScreen()->m_BlockLocate.GetBottom() ) ); + SetCrossHairPosition( wxPoint( GetScreen()->m_BlockLocate.GetRight(), + GetScreen()->m_BlockLocate.GetBottom() ) ); m_canvas->MoveCursorToCrossHair(); } @@ -171,7 +171,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) SaveCopyInUndoList( m_component ); pt = GetScreen()->m_BlockLocate.Centre(); - pt = GetScreen()->GetNearestGridPosition( pt ); + pt = GetNearestGridPosition( pt ); NEGATE( pt.y ); if ( m_component ) @@ -183,7 +183,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) m_component->MirrorSelectedItemsH( pt ); else if( block_cmd == BLOCK_MIRROR_X) m_component->MirrorSelectedItemsV( pt ); - else if( block_cmd == BLOCK_ROTATE) + else if( block_cmd == BLOCK_ROTATE ) m_component->RotateSelectedItems( pt ); } @@ -275,7 +275,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) SaveCopyInUndoList( m_component ); pt = GetScreen()->m_BlockLocate.Centre(); - pt = GetScreen()->GetNearestGridPosition( pt ); + pt = GetNearestGridPosition( pt ); NEGATE( pt.y ); if ( m_component ) @@ -342,7 +342,7 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& } // Repaint new view - block->SetMoveVector( screen->GetCrossHairPosition() - block->GetLastCursorPosition() ); + block->SetMoveVector( parent->GetCrossHairPosition() - block->GetLastCursorPosition() ); GRSetDrawMode( aDC, g_XorMode ); block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() ); diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 3419efcd9e..72890bee3e 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -81,8 +81,9 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi } } - wxPoint endpos = aPanel->GetScreen()->GetCrossHairPosition(); - SCH_EDIT_FRAME * frame = ( SCH_EDIT_FRAME * ) aPanel->GetParent(); + SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) aPanel->GetParent(); + + wxPoint endpos = frame->GetCrossHairPosition(); if( frame->GetForceHVLines() ) /* Coerce the line to vertical or horizontal one: */ ComputeBreakPoint( (SCH_LINE*) s_wires.GetLast()->Back(), endpos ); @@ -105,7 +106,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) { SCH_LINE* segment; SCH_LINE* nextSegment; - wxPoint cursorpos = GetScreen()->GetCrossHairPosition(); + wxPoint cursorpos = GetCrossHairPosition(); // We should know if a segment is currently in progress segment = (SCH_LINE*) GetScreen()->GetCurItem(); @@ -426,8 +427,9 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) if( m_itemToRepeat->Type() == SCH_COMPONENT_T ) // If repeat component then put in move mode { - wxPoint pos = GetScreen()->GetCrossHairPosition() - + wxPoint pos = GetCrossHairPosition() - ( (SCH_COMPONENT*) m_itemToRepeat )->GetPosition(); + m_itemToRepeat->SetFlags( IS_NEW ); ( (SCH_COMPONENT*) m_itemToRepeat )->SetTimeStamp( GetNewTimeStamp() ); m_itemToRepeat->Move( pos ); diff --git a/eeschema/busentry.cpp b/eeschema/busentry.cpp index a9f6f70755..2e83b8866e 100644 --- a/eeschema/busentry.cpp +++ b/eeschema/busentry.cpp @@ -45,10 +45,9 @@ static int s_LastShape = '\\'; SCH_BUS_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusBusEntry( wxDC* aDC ) { - SCH_SCREEN* screen = GetScreen(); - // Create and place a new bus entry at cursor position - SCH_BUS_BUS_ENTRY* busEntry = new SCH_BUS_BUS_ENTRY( screen->GetCrossHairPosition(), s_LastShape ); + SCH_BUS_BUS_ENTRY* busEntry = new SCH_BUS_BUS_ENTRY( GetCrossHairPosition(), s_LastShape ); + busEntry->SetFlags( IS_NEW ); GetScreen()->SetCurItem( busEntry ); addCurrentItemToList( aDC ); @@ -57,10 +56,9 @@ SCH_BUS_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusBusEntry( wxDC* aDC ) SCH_BUS_WIRE_ENTRY* SCH_EDIT_FRAME::CreateBusWireEntry( wxDC* aDC ) { - SCH_SCREEN* screen = GetScreen(); - // Create and place a new bus entry at cursor position - SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( screen->GetCrossHairPosition(), s_LastShape ); + SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( GetCrossHairPosition(), s_LastShape ); + busEntry->SetFlags( IS_NEW ); GetScreen()->SetCurItem( busEntry ); addCurrentItemToList( aDC ); diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index 3573aad8bb..0ae2642e9a 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -56,7 +56,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC wxString msg; LIB_PIN* Pin = NULL; SCH_COMPONENT* LibItem = NULL; - wxPoint gridPosition = GetScreen()->GetNearestGridPosition( aPosition ); + wxPoint gridPosition = GetNearestGridPosition( aPosition ); // Check the on grid position first. There is more likely to be multiple items on // grid than off grid. @@ -222,9 +222,9 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH snapToGrid = true; if( snapToGrid ) - pos = screen->GetNearestGridPosition( pos ); + pos = GetNearestGridPosition( pos ); - oldpos = screen->GetCrossHairPosition(); + oldpos = GetCrossHairPosition(); gridSize = screen->GetGridSize(); switch( aHotKey ) @@ -261,14 +261,14 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH } // Update cursor position. - screen->SetCrossHairPosition( pos, snapToGrid ); + SetCrossHairPosition( pos, snapToGrid ); - if( oldpos != screen->GetCrossHairPosition() ) + if( oldpos != GetCrossHairPosition() ) { - pos = screen->GetCrossHairPosition(); - screen->SetCrossHairPosition( oldpos, false); + pos = GetCrossHairPosition(); + SetCrossHairPosition( oldpos, false); m_canvas->CrossHairOff( aDC ); - screen->SetCrossHairPosition( pos, snapToGrid ); + SetCrossHairPosition( pos, snapToGrid ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) @@ -304,7 +304,6 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { wxRealPoint gridSize; - SCH_SCREEN* screen = GetScreen(); wxPoint oldpos; wxPoint pos = aPosition; @@ -320,10 +319,10 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH snapToGrid = true; if( snapToGrid ) - pos = screen->GetNearestGridPosition( pos ); + pos = GetNearestGridPosition( pos ); - oldpos = screen->GetCrossHairPosition(); - gridSize = screen->GetGridSize(); + oldpos = GetCrossHairPosition(); + gridSize = GetScreen()->GetGridSize(); switch( aHotKey ) { @@ -359,14 +358,14 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH } // Update the cursor position. - screen->SetCrossHairPosition( pos, snapToGrid ); + SetCrossHairPosition( pos, snapToGrid ); - if( oldpos != screen->GetCrossHairPosition() ) + if( oldpos != GetCrossHairPosition() ) { - pos = screen->GetCrossHairPosition(); - screen->SetCrossHairPosition( oldpos, false ); + pos = GetCrossHairPosition(); + SetCrossHairPosition( oldpos, false ); m_canvas->CrossHairOff( aDC ); - screen->SetCrossHairPosition( pos, snapToGrid ); + SetCrossHairPosition( pos, snapToGrid ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) @@ -403,8 +402,8 @@ void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH wxPoint oldpos; wxPoint pos = aPosition; - pos = screen->GetNearestGridPosition( pos ); - oldpos = screen->GetCrossHairPosition(); + pos = GetNearestGridPosition( pos ); + oldpos = GetCrossHairPosition(); gridSize = screen->GetGridSize(); switch( aHotKey ) @@ -441,14 +440,14 @@ void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH } // Update cursor position. - screen->SetCrossHairPosition( pos ); + SetCrossHairPosition( pos ); - if( oldpos != screen->GetCrossHairPosition() ) + if( oldpos != GetCrossHairPosition() ) { - pos = screen->GetCrossHairPosition(); - screen->SetCrossHairPosition( oldpos ); + pos = GetCrossHairPosition(); + SetCrossHairPosition( oldpos ); m_canvas->CrossHairOff( aDC ); - screen->SetCrossHairPosition( pos ); + SetCrossHairPosition( pos ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 9b0b7e4d44..3bc9498da5 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -205,7 +205,7 @@ void DIALOG_ERC::OnLeftClickMarkersList( wxCommandEvent& event ) } m_lastMarkerFound = marker; - m_parent->GetScreen()->SetCrossHairPosition( marker->m_Pos ); + m_parent->SetCrossHairPosition( marker->m_Pos ); m_parent->RedrawScreen( marker->m_Pos, false); } @@ -218,7 +218,7 @@ void DIALOG_ERC::OnLeftDblClickMarkersList( wxCommandEvent& event ) // (NULL if not found) if( m_lastMarkerFound ) { - m_parent->GetScreen()->SetCrossHairPosition( m_lastMarkerFound->m_Pos ); + m_parent->SetCrossHairPosition( m_lastMarkerFound->m_Pos ); m_parent->RedrawScreen( m_lastMarkerFound->m_Pos, true); // prevent a mouse left button release event in // coming from the ERC dialog double click diff --git a/eeschema/edit_bitmap.cpp b/eeschema/edit_bitmap.cpp index 4ff2aeac24..e3fdd42c99 100644 --- a/eeschema/edit_bitmap.cpp +++ b/eeschema/edit_bitmap.cpp @@ -93,7 +93,7 @@ static void moveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosit } // Draw the bitmap at it's new position. - image->SetPosition( screen->GetCrossHairPosition() ); + image->SetPosition( aPanel->GetParent()->GetCrossHairPosition() ); image->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); } @@ -116,7 +116,7 @@ SCH_BITMAP* SCH_EDIT_FRAME::CreateNewImage( wxDC* aDC ) return NULL; } - wxPoint pos = GetScreen()->GetCrossHairPosition(); + wxPoint pos = GetCrossHairPosition(); SCH_BITMAP* image = new SCH_BITMAP( pos ); @@ -149,7 +149,7 @@ void SCH_EDIT_FRAME::MoveImage( SCH_BITMAP* aImageItem, wxDC* aDC ) SetUndoItem( aImageItem ); m_canvas->CrossHairOff( aDC ); - GetScreen()->SetCrossHairPosition( aImageItem->GetPosition() ); + SetCrossHairPosition( aImageItem->GetPosition() ); m_canvas->MoveCursorToCrossHair(); m_canvas->CrossHairOn( aDC ); diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index b29ccaef2c..855a313bca 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -77,20 +77,20 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType ) switch( aType ) { case LAYER_NOTES: - textItem = new SCH_TEXT( GetScreen()->GetCrossHairPosition() ); + textItem = new SCH_TEXT( GetCrossHairPosition() ); break; case LAYER_LOCLABEL: - textItem = new SCH_LABEL( GetScreen()->GetCrossHairPosition() ); + textItem = new SCH_LABEL( GetCrossHairPosition() ); break; case LAYER_HIERLABEL: - textItem = new SCH_HIERLABEL( GetScreen()->GetCrossHairPosition() ); + textItem = new SCH_HIERLABEL( GetCrossHairPosition() ); textItem->SetShape( lastGlobalLabelShape ); break; case LAYER_GLOBLABEL: - textItem = new SCH_GLOBALLABEL( GetScreen()->GetCrossHairPosition() ); + textItem = new SCH_GLOBALLABEL( GetCrossHairPosition() ); textItem->SetShape( lastGlobalLabelShape ); break; diff --git a/eeschema/find.cpp b/eeschema/find.cpp index 0349a84603..e81ba6c3ff 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -90,7 +90,7 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event ) m_CurrentSheet->UpdateAllScreenReferences(); } - sheetFoundIn->LastScreen()->SetCrossHairPosition( lastMarker->GetPosition() ); + SetCrossHairPosition( lastMarker->GetPosition() ); RedrawScreen( lastMarker->GetPosition(), warpCursor ); @@ -213,7 +213,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference, if( centerAndRedraw ) { - GetScreen()->SetCrossHairPosition(pos); + SetCrossHairPosition( pos ); RedrawScreen( pos, aWarpMouse ); } @@ -226,7 +226,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference, if( aWarpMouse ) m_canvas->MoveCursor( pos ); - GetScreen()->SetCrossHairPosition(pos); + SetCrossHairPosition( pos ); m_canvas->CrossHairOn( &dc ); } @@ -351,7 +351,8 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& aEvent ) SetScreen( sheet->LastScreen() ); } - sheet->LastScreen()->SetCrossHairPosition( data.GetPosition() ); + // careful here + SetCrossHairPosition( data.GetPosition() ); RedrawScreen( data.GetPosition(), warpCursor ); diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 78ef00e207..6fbf348769 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -231,7 +231,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aDC, SCH_COMPONENT* component; component = new SCH_COMPONENT( *Entry, m_CurrentSheet, unit, convert, - GetScreen()->GetCrossHairPosition(), true ); + GetCrossHairPosition(), true ); // Set the m_ChipName value, from component name in lib, for aliases // Note if Entry is found, and if Name is an alias of a component, diff --git a/eeschema/hierarch.cpp b/eeschema/hierarch.cpp index 07c9b5aa8b..7ac4adbca1 100644 --- a/eeschema/hierarch.cpp +++ b/eeschema/hierarch.cpp @@ -284,12 +284,12 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet() { Zoom_Automatique( false ); screen->m_FirstRedraw = false; - screen->SetCrossHairPosition( screen->GetScrollCenterPosition() ); + SetCrossHairPosition( GetScrollCenterPosition() ); m_canvas->MoveCursorToCrossHair(); } else { - RedrawScreen( screen->GetScrollCenterPosition(), true ); + RedrawScreen( GetScrollCenterPosition(), true ); } // Now refresh m_canvas. Should be not necessary, but because screen has changed diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index b5c5dc454f..4afdebe397 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -74,14 +74,14 @@ */ -/* local variables */ -/* Hotkey list: */ +// local variables +// Hotkey list: /** * Common commands */ -/* Fit on Screen */ +// Fit on Screen #if !defined( __WXMAC__ ) static EDA_HOTKEY HkZoomAuto( wxT( "Fit on Screen" ), HK_ZOOM_AUTO, WXK_HOME, ID_ZOOM_PAGE ); #else @@ -92,7 +92,7 @@ static EDA_HOTKEY HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, GR_KB_CTRL + '0' static EDA_HOTKEY HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4, ID_POPUP_ZOOM_CENTER ); -/* Refresh Screen */ +// Refresh Screen #if !defined( __WXMAC__ ) static EDA_HOTKEY HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3, ID_ZOOM_REDRAW ); #else @@ -100,14 +100,14 @@ static EDA_HOTKEY HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, GR_KB_CTRL ID_ZOOM_REDRAW ); #endif -/* Zoom In */ +// Zoom In #if !defined( __WXMAC__ ) static EDA_HOTKEY HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1, ID_POPUP_ZOOM_IN ); #else static EDA_HOTKEY HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, GR_KB_CTRL + '+', ID_POPUP_ZOOM_IN ); #endif -/* Zoom Out */ +// Zoom Out #if !defined( __WXMAC__ ) static EDA_HOTKEY HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2, ID_POPUP_ZOOM_OUT ); #else @@ -115,13 +115,13 @@ static EDA_HOTKEY HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, GR_KB_CTRL + '-', I #endif static EDA_HOTKEY HkHelp( wxT( "Help (this window)" ), HK_HELP, '?' ); -static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), - HK_RESET_LOCAL_COORD, ' ' ); +static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' ); -/* Undo */ + +// Undo static EDA_HOTKEY HkUndo( wxT( "Undo" ), HK_UNDO, GR_KB_CTRL + 'Z', (int) wxID_UNDO ); -/* Redo */ +// Redo #if !defined( __WXMAC__ ) static EDA_HOTKEY HkRedo( wxT( "Redo" ), HK_REDO, GR_KB_CTRL + 'Y', (int) wxID_REDO ); #else @@ -358,8 +358,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, DisplayHotkeyList( this, s_Schematic_Hokeys_Descr ); break; - case HK_RESET_LOCAL_COORD: /* Reset the relative coord */ - GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); + case HK_RESET_LOCAL_COORD: // Reset the relative coord + GetScreen()->m_O_Curseur = GetCrossHairPosition(); break; case HK_ZOOM_IN: @@ -561,8 +561,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, DisplayHotkeyList( this, s_Libedit_Hokeys_Descr ); break; - case HK_RESET_LOCAL_COORD: /* Reset the relative coord */ - GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); + case HK_RESET_LOCAL_COORD: // Reset the relative coord + GetScreen()->m_O_Curseur = GetCrossHairPosition(); break; case HK_ZOOM_IN: diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 24eef58c2c..6cb15a3e6e 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -218,7 +218,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent, GetScreen()->m_Center = true; - GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); + SetCrossHairPosition( wxPoint( 0, 0 ) ); LoadSettings(); @@ -402,7 +402,7 @@ double LIB_EDIT_FRAME::BestZoom() BoundaryBox = m_component->GetBoundingBox( m_unit, m_convert ); dx = BoundaryBox.GetWidth(); dy = BoundaryBox.GetHeight(); - GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) ); + SetScrollCenterPosition( wxPoint( 0, 0 ) ); } else { @@ -411,7 +411,7 @@ double LIB_EDIT_FRAME::BestZoom() dx = pageInfo.GetSizeIU().x; dy = pageInfo.GetSizeIU().y; - GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) ); + SetScrollCenterPosition( wxPoint( 0, 0 ) ); } size = m_canvas->GetClientSize(); @@ -753,7 +753,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) STATUS_FLAGS oldFlags = m_drawItem->GetFlags(); m_drawItem->ClearFlags(); m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform ); - ( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetScreen()->GetCrossHairPosition( true ) ); + ( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetCrossHairPosition( true ) ); m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform ); m_drawItem->SetFlags( oldFlags ); m_lastDrawItem = NULL; @@ -1139,7 +1139,7 @@ LIB_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPosition, if( item == NULL ) return NULL; - wxPoint pos = GetScreen()->GetNearestGridPosition( aPosition ); + wxPoint pos = GetNearestGridPosition( aPosition ); if( item == NULL && aPosition != pos ) item = locateItem( pos, aFilterList ); diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index 85fb879095..c6f9661197 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -663,8 +663,8 @@ void SCH_EDIT_FRAME::addJunctionMenuEntries( wxMenu* aMenu, SCH_JUNCTION* aJunct void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame ) { SCH_SCREEN* screen = frame->GetScreen(); - wxPoint pos = screen->GetCrossHairPosition(); - wxString msg; + wxPoint pos = frame->GetCrossHairPosition(); + wxString msg; if( Wire == NULL ) { @@ -691,9 +691,9 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame ) AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ), KiBitmap( delete_connection_xpm ) ); - SCH_LINE* line = screen->GetWireOrBus( screen->GetCrossHairPosition() ); + SCH_LINE* line = screen->GetWireOrBus( frame->GetCrossHairPosition() ); - if( line && !line->IsEndPoint( screen->GetCrossHairPosition() ) ) + if( line && !line->IsEndPoint( frame->GetCrossHairPosition() ) ) AddMenuItem( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), KiBitmap( break_line_xpm ) ); @@ -713,8 +713,8 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame ) void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame ) { - wxPoint pos = frame->GetScreen()->GetCrossHairPosition(); - wxString msg; + wxPoint pos = frame->GetCrossHairPosition(); + wxString msg; if( Bus == NULL ) { diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 56f5f5c5ac..eee9cf5dca 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -210,7 +210,7 @@ void LIB_EDIT_FRAME::PlacePin() return; } - newpos = GetScreen()->GetCrossHairPosition( true ); + newpos = GetCrossHairPosition( true ); // Test for an other pin in same new position: for( Pin = m_component->GetNextPin(); Pin != NULL; Pin = m_component->GetNextPin( Pin ) ) @@ -308,7 +308,7 @@ void LIB_EDIT_FRAME::StartMovePin( wxDC* DC ) startPos.x = OldPos.x; startPos.y = -OldPos.y; // m_canvas->CrossHairOff( DC ); - GetScreen()->SetCrossHairPosition( startPos ); + SetCrossHairPosition( startPos ); m_canvas->MoveCursorToCrossHair(); MSG_PANEL_ITEMS items; @@ -350,7 +350,7 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi } // Redraw pin in new position - CurrentPin->Move( aPanel->GetScreen()->GetCrossHairPosition( true ) ); + CurrentPin->Move( aPanel->GetParent()->GetCrossHairPosition( true ) ); CurrentPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, &showPinText, DefaultTransform ); @@ -388,7 +388,7 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC ) if( SynchronizePins() ) pin->SetFlags( IS_LINKED ); - pin->Move( GetScreen()->GetCrossHairPosition( true ) ); + pin->Move( GetCrossHairPosition( true ) ); pin->SetLength( LastPinLength ); pin->SetOrientation( LastPinOrient ); pin->SetType( LastPinType ); @@ -555,10 +555,10 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin ) if( SynchronizePins() ) Pin->SetFlags( IS_LINKED ); - wxPoint savepos = GetScreen()->GetCrossHairPosition(); + wxPoint savepos = GetCrossHairPosition(); m_canvas->CrossHairOff( DC ); - GetScreen()->SetCrossHairPosition( wxPoint( Pin->GetPosition().x, - -Pin->GetPosition().y ) ); + + SetCrossHairPosition( wxPoint( Pin->GetPosition().x, -Pin->GetPosition().y ) ); // Add this new pin in list, and creates pins for others parts if needed m_drawItem = Pin; @@ -566,7 +566,7 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin ) PlacePin(); m_lastDrawItem = Pin; - GetScreen()->SetCrossHairPosition( savepos ); + SetCrossHairPosition( savepos ); m_canvas->CrossHairOn( DC ); MSG_PANEL_ITEMS items; diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 7f2a9357f7..891a1c1f29 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -73,17 +73,17 @@ const wxSize SCH_BASE_FRAME::GetPageSizeIU() const } -const wxPoint& SCH_BASE_FRAME::GetOriginAxisPosition() const +const wxPoint& SCH_BASE_FRAME::GetAuxOrigin() const { wxASSERT( GetScreen() ); - return GetScreen()->GetOriginAxisPosition(); + return GetScreen()->GetAuxOrigin(); } -void SCH_BASE_FRAME::SetOriginAxisPosition( const wxPoint& aPosition ) +void SCH_BASE_FRAME::SetAuxOrigin( const wxPoint& aPosition ) { wxASSERT( GetScreen() ); - GetScreen()->SetOriginAxisPosition( aPosition ); + GetScreen()->SetAuxOrigin( aPosition ); } @@ -113,8 +113,8 @@ void SCH_BASE_FRAME::UpdateStatusBar() EDA_DRAW_FRAME::UpdateStatusBar(); // Display absolute coordinates: - double dXpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().x ); - double dYpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().y ); + double dXpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().x ); + double dYpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().y ); if ( g_UserUnit == MILLIMETRES ) { @@ -147,8 +147,9 @@ void SCH_BASE_FRAME::UpdateStatusBar() SetStatusText( line, 2 ); // Display relative coordinates: - dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x; - dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y; + dx = GetCrossHairPosition().x - screen->m_O_Curseur.x; + dy = GetCrossHairPosition().y - screen->m_O_Curseur.y; + dXpos = To_User_Unit( g_UserUnit, dx ); dYpos = To_User_Unit( g_UserUnit, dy ); diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 3f509a6b55..7eeaac888d 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -132,7 +132,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case wxID_PASTE: - HandleBlockBegin( &dc, BLOCK_PASTE, screen->GetCrossHairPosition() ); + HandleBlockBegin( &dc, BLOCK_PASTE, GetCrossHairPosition() ); break; case ID_POPUP_SCH_ENTRY_SELECT_SLASH: @@ -165,12 +165,12 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_BEGIN_WIRE: m_canvas->MoveCursorToCrossHair(); - OnLeftClick( &dc, screen->GetCrossHairPosition() ); + OnLeftClick( &dc, GetCrossHairPosition() ); break; case ID_POPUP_SCH_BEGIN_BUS: m_canvas->MoveCursorToCrossHair(); - OnLeftClick( &dc, screen->GetCrossHairPosition() ); + OnLeftClick( &dc, GetCrossHairPosition() ); break; case ID_POPUP_SCH_SET_SHAPE_TEXT: @@ -194,7 +194,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) oldWires.SetOwnership( false ); // Prevent DLIST for deleting items in destructor. m_canvas->MoveCursorToCrossHair(); screen->ExtractWires( oldWires, true ); - screen->BreakSegment( screen->GetCrossHairPosition() ); + screen->BreakSegment( GetCrossHairPosition() ); if( oldWires.GetCount() != 0 ) { @@ -344,7 +344,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_ADD_JUNCTION: m_canvas->MoveCursorToCrossHair(); - screen->SetCurItem( AddJunction( &dc, screen->GetCrossHairPosition(), true ) ); + screen->SetCurItem( AddJunction( &dc, GetCrossHairPosition(), true ) ); screen->TestDanglingEnds( m_canvas, &dc ); screen->SetCurItem( NULL ); break; @@ -588,7 +588,7 @@ void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection ) { PICKED_ITEMS_LIST pickList; SCH_SCREEN* screen = GetScreen(); - wxPoint pos = screen->GetCrossHairPosition(); + wxPoint pos = GetCrossHairPosition(); if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 ) { @@ -603,7 +603,7 @@ bool SCH_EDIT_FRAME::DeleteItemAtCrossHair( wxDC* DC ) SCH_ITEM* item; SCH_SCREEN* screen = GetScreen(); - item = LocateItem( screen->GetCrossHairPosition(), SCH_COLLECTOR::ParentItems ); + item = LocateItem( GetCrossHairPosition(), SCH_COLLECTOR::ParentItems ); if( item ) { @@ -637,7 +637,7 @@ static void moveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositio item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); #endif - item->SetPosition( screen->GetCrossHairPosition() ); + item->SetPosition( aPanel->GetParent()->GetCrossHairPosition() ); // Draw the item item at it's new position. item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); @@ -713,7 +713,7 @@ void SCH_EDIT_FRAME::MoveItem( SCH_ITEM* aItem, wxDC* aDC ) m_canvas->CrossHairOff( aDC ); if( aItem->Type() != SCH_SHEET_PIN_T ) - GetScreen()->SetCrossHairPosition( aItem->GetPosition() ); + SetCrossHairPosition( aItem->GetPosition() ); m_canvas->MoveCursorToCrossHair(); @@ -959,7 +959,7 @@ void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent ) // is to simulate a block drag command if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK ) { - if( !HandleBlockBegin( &dc, BLOCK_DRAG, screen->GetCrossHairPosition() ) ) + if( !HandleBlockBegin( &dc, BLOCK_DRAG, GetCrossHairPosition() ) ) break; // Give a non null size to the search block: diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 653709f516..d6432c0fdb 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -501,7 +501,7 @@ double SCH_EDIT_FRAME::BestZoom() double bestzoom = std::max( zx, zy ); - GetScreen()->SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) ); + SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) ); return bestzoom; } diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index a3805ddbc2..3d59b19197 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -244,8 +244,8 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& if( sheet->IsResized() ) { - int width = screen->GetCrossHairPosition().x - sheet->GetPosition().x; - int height = screen->GetCrossHairPosition().y - sheet->GetPosition().y; + int width = aPanel->GetParent()->GetCrossHairPosition().x - sheet->GetPosition().x; + int height = aPanel->GetParent()->GetCrossHairPosition().y - sheet->GetPosition().y; // If the sheet doesn't have any pins, clamp the minimum size to the default values. width = ( width < MIN_SHEET_WIDTH ) ? MIN_SHEET_WIDTH : width; @@ -263,12 +263,13 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& sheet->GetMinWidth() + gridSizeX : width; } - wxPoint grid = screen->GetNearestGridPosition( wxPoint( pos.x + width, pos.y + height ) ); + wxPoint grid = aPanel->GetParent()->GetNearestGridPosition( + wxPoint( pos.x + width, pos.y + height ) ); sheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) ); } else if( sheet->IsMoving() ) { - moveVector = screen->GetCrossHairPosition() - pos; + moveVector = aPanel->GetParent()->GetCrossHairPosition() - pos; sheet->Move( moveVector ); } @@ -324,7 +325,7 @@ SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC ) { m_itemToRepeat = NULL; - SCH_SHEET* sheet = new SCH_SHEET( GetScreen()->GetCrossHairPosition() ); + SCH_SHEET* sheet = new SCH_SHEET( GetCrossHairPosition() ); sheet->SetFlags( IS_NEW | IS_RESIZED ); sheet->SetTimeStamp( GetNewTimeStamp() ); @@ -338,7 +339,9 @@ SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC ) m_canvas->SetMouseCapture( MoveOrResizeSheet, ExitSheet ); m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false ); m_canvas->CrossHairOff( aDC ); - GetScreen()->SetCrossHairPosition( sheet->GetResizePosition() ); + + SetCrossHairPosition( sheet->GetResizePosition() ); + m_canvas->MoveCursorToCrossHair(); m_canvas->CrossHairOn( aDC ); @@ -356,7 +359,7 @@ void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC ) GetChars( aSheet->GetClass() ) ) ); m_canvas->CrossHairOff( aDC ); - GetScreen()->SetCrossHairPosition( aSheet->GetResizePosition() ); + SetCrossHairPosition( aSheet->GetResizePosition() ); m_canvas->MoveCursorToCrossHair(); m_canvas->CrossHairOn( aDC ); @@ -377,7 +380,7 @@ void SCH_EDIT_FRAME::StartMoveSheet( SCH_SHEET* aSheet, wxDC* aDC ) return; m_canvas->CrossHairOff( aDC ); - GetScreen()->SetCrossHairPosition( aSheet->GetPosition() ); + SetCrossHairPosition( aSheet->GetPosition() ); m_canvas->MoveCursorToCrossHair(); if( !aSheet->IsNew() ) diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index 04186c83e9..619db5b46b 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -136,7 +136,7 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC ) return; bool newItem = item->IsNew(); - item->EndEdit( parent->GetScreen()->GetCrossHairPosition( true ), true ); + item->EndEdit( parent->GetCrossHairPosition( true ), true ); if( newItem ) { @@ -153,7 +153,7 @@ static void AbortSymbolTraceOn( EDA_DRAW_PANEL* Panel, wxDC* DC ) LIB_ITEM* LIB_EDIT_FRAME::CreateGraphicItem( LIB_COMPONENT* LibEntry, wxDC* DC ) { m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn ); - wxPoint drawPos = GetScreen()->GetCrossHairPosition( true ); + wxPoint drawPos = GetCrossHairPosition( true ); // no temp copy -> the current version of component will be used for Undo // This is normal when adding new items to the current component @@ -239,7 +239,7 @@ void LIB_EDIT_FRAME::GraphicItemBeginDraw( wxDC* DC ) if( m_drawItem == NULL ) return; - wxPoint pos = GetScreen()->GetCrossHairPosition( true ); + wxPoint pos = GetCrossHairPosition( true ); if( m_drawItem->ContinueEdit( pos ) ) { @@ -264,21 +264,20 @@ static void RedrawWhileMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx if( item == NULL ) return; - BASE_SCREEN* Screen = aPanel->GetScreen(); - item->SetEraseLastDrawItem( aErase ); // if item is the reference field, we must add the current unit id if( item->Type() == LIB_FIELD_T ) { - int unit = ((LIB_EDIT_FRAME*)aPanel->GetParent())->GetUnit(); - wxString text = ((LIB_FIELD*)item)->GetFullText( unit ); - item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), + int unit = ((LIB_EDIT_FRAME*)aPanel->GetParent())->GetUnit(); + wxString text = ((LIB_FIELD*)item)->GetFullText( unit ); + + item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ), UNSPECIFIED_COLOR, g_XorMode, &text, DefaultTransform ); } else - item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), + item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform ); } @@ -298,7 +297,7 @@ void LIB_EDIT_FRAME::StartMoveDrawSymbol( wxDC* DC ) if( m_drawItem->Type() == LIB_FIELD_T ) m_drawItem->BeginEdit( IS_MOVED, m_drawItem->GetPosition() ); else - m_drawItem->BeginEdit( IS_MOVED, GetScreen()->GetCrossHairPosition( true ) ); + m_drawItem->BeginEdit( IS_MOVED, GetCrossHairPosition( true ) ); m_canvas->SetMouseCapture( RedrawWhileMovingCursor, AbortSymbolTraceOn ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, true ); @@ -312,7 +311,7 @@ void LIB_EDIT_FRAME::StartModifyDrawSymbol( wxDC* DC ) return; TempCopyComponent(); - m_drawItem->BeginEdit( IS_RESIZED, GetScreen()->GetCrossHairPosition( true ) ); + m_drawItem->BeginEdit( IS_RESIZED, GetCrossHairPosition( true ) ); m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, true ); } @@ -322,14 +321,13 @@ void LIB_EDIT_FRAME::StartModifyDrawSymbol( wxDC* DC ) static void SymbolDisplayDraw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { - BASE_SCREEN* Screen = aPanel->GetScreen(); LIB_ITEM* item = ( (LIB_EDIT_FRAME*) aPanel->GetParent() )->GetDrawItem(); if( item == NULL ) return; item->SetEraseLastDrawItem( aErase ); - item->Draw( aPanel, aDC, Screen->GetCrossHairPosition( true ), UNSPECIFIED_COLOR, g_XorMode, NULL, + item->Draw( aPanel, aDC, aPanel->GetParent()->GetCrossHairPosition( true ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform ); } @@ -357,7 +355,7 @@ void LIB_EDIT_FRAME::EndDrawGraphicItem( wxDC* DC ) if( m_drawItem->IsNew() ) m_component->AddDrawItem( m_drawItem ); - m_drawItem->EndEdit( GetScreen()->GetCrossHairPosition( true ) ); + m_drawItem->EndEdit( GetCrossHairPosition( true ) ); m_drawItem = NULL; diff --git a/eeschema/symbedit.cpp b/eeschema/symbedit.cpp index 0e22eff8ff..95309e6757 100644 --- a/eeschema/symbedit.cpp +++ b/eeschema/symbedit.cpp @@ -65,7 +65,7 @@ void LIB_EDIT_FRAME::LoadOneSymbol() if( dlg.ShowModal() == wxID_CANCEL ) return; - GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); + SetCrossHairPosition( wxPoint( 0, 0 ) ); m_canvas->MoveCursorToCrossHair(); m_canvas->SetIgnoreMouseEvents( false ); @@ -238,7 +238,9 @@ void LIB_EDIT_FRAME::PlaceAnchor() if( m_component == NULL ) return; - wxPoint offset( -GetScreen()->GetCrossHairPosition().x, GetScreen()->GetCrossHairPosition().y ); + const wxPoint& cross_hair = GetCrossHairPosition(); + + wxPoint offset( -cross_hair.x, cross_hair.y ); OnModify( ); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 14051141d0..3300c5a923 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -335,7 +335,7 @@ void LIB_VIEW_FRAME::OnSize( wxSizeEvent& SizeEv ) void LIB_VIEW_FRAME::OnSetRelativeOffset( wxCommandEvent& event ) { - GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); + GetScreen()->m_O_Curseur = GetCrossHairPosition(); UpdateStatusBar(); } @@ -348,18 +348,16 @@ double LIB_VIEW_FRAME::BestZoom() * search for line static const int VIEWPORT_EXTENT = 1000; * and replace by static const int VIEWPORT_EXTENT = 10000; */ - LIB_COMPONENT* component = NULL; - CMP_LIBRARY* lib; - double bestzoom = 16.0; // default value for bestzoom - - lib = CMP_LIBRARY::FindLibrary( m_libraryName ); + LIB_COMPONENT* component = NULL; + double bestzoom = 16.0; // default value for bestzoom + CMP_LIBRARY* lib = CMP_LIBRARY::FindLibrary( m_libraryName ); if( lib ) component = lib->FindComponent( m_entryName ); if( component == NULL ) { - GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) ); + SetScrollCenterPosition( wxPoint( 0, 0 ) ); return bestzoom; } @@ -382,7 +380,7 @@ double LIB_VIEW_FRAME::BestZoom() if( bestzoom < GetScreen()->m_ZoomList[0] ) bestzoom = GetScreen()->m_ZoomList[0]; - GetScreen()->SetScrollCenterPosition( BoundaryBox.Centre() ); + SetScrollCenterPosition( BoundaryBox.Centre() ); return bestzoom; } diff --git a/gerbview/block.cpp b/gerbview/block.cpp index 774e5dde2a..d973ac9a03 100644 --- a/gerbview/block.cpp +++ b/gerbview/block.cpp @@ -171,10 +171,11 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx if( screen->m_BlockLocate.GetState() != STATE_BLOCK_STOP ) { - screen->m_BlockLocate.SetMoveVector( wxPoint( screen->GetCrossHairPosition().x - - screen->m_BlockLocate.GetRight(), - screen->GetCrossHairPosition().y - - screen->m_BlockLocate.GetBottom() ) ); + const wxPoint& cross_hair = aPanel->GetParent()->GetCrossHairPosition(); + + screen->m_BlockLocate.SetMoveVector( + wxPoint( cross_hair.x - screen->m_BlockLocate.GetRight(), + cross_hair.y - screen->m_BlockLocate.GetBottom() ) ); } screen->m_BlockLocate.Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, Color ); @@ -195,10 +196,10 @@ void GERBVIEW_FRAME::Block_Move( wxDC* DC ) wxPoint delta; wxPoint oldpos; - oldpos = GetScreen()->GetCrossHairPosition(); + oldpos = GetCrossHairPosition(); m_canvas->SetMouseCaptureCallback( NULL ); - GetScreen()->SetCrossHairPosition( oldpos ); + SetCrossHairPosition( oldpos ); m_canvas->MoveCursorToCrossHair(); GetScreen()->SetModify(); GetScreen()->m_BlockLocate.Normalize(); diff --git a/gerbview/class_gbr_layout.h b/gerbview/class_gbr_layout.h index c192fff890..ac97e87eb2 100644 --- a/gerbview/class_gbr_layout.h +++ b/gerbview/class_gbr_layout.h @@ -38,12 +38,12 @@ public: const PAGE_INFO& GetPageSettings() const { return m_paper; } void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; } - const wxPoint& GetOriginAxisPosition() const + const wxPoint& GetAuxOrigin() const { return m_originAxisPosition; } - void SetOriginAxisPosition( const wxPoint& aPosition ) + void SetAuxOrigin( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; } diff --git a/gerbview/controle.cpp b/gerbview/controle.cpp index 8c058fa3f8..fedb66b381 100644 --- a/gerbview/controle.cpp +++ b/gerbview/controle.cpp @@ -38,9 +38,9 @@ void GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH wxPoint oldpos; wxPoint pos = aPosition; - pos = GetScreen()->GetNearestGridPosition( pos ); + pos = GetNearestGridPosition( pos ); - oldpos = GetScreen()->GetCrossHairPosition(); + oldpos = GetCrossHairPosition(); gridSize = GetScreen()->GetGridSize(); switch( aHotKey ) @@ -73,14 +73,14 @@ void GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH break; } - GetScreen()->SetCrossHairPosition( pos ); + SetCrossHairPosition( pos ); - if( oldpos != GetScreen()->GetCrossHairPosition() ) + if( oldpos != GetCrossHairPosition() ) { - pos = GetScreen()->GetCrossHairPosition(); - GetScreen()->SetCrossHairPosition( oldpos ); + pos = GetCrossHairPosition(); + SetCrossHairPosition( oldpos ); m_canvas->CrossHairOff( aDC ); - GetScreen()->SetCrossHairPosition( pos ); + SetCrossHairPosition( pos ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 40580a1c84..9bfac36737 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -196,7 +196,7 @@ double GERBVIEW_FRAME::BestZoom() double x = (double) bbox.GetWidth() / (double) size.x; double y = (double) bbox.GetHeight() / (double) size.y; - GetScreen()->SetScrollCenterPosition( bbox.Centre() ); + SetScrollCenterPosition( bbox.Centre() ); double best_zoom = std::max( x, y ); return best_zoom; @@ -733,17 +733,17 @@ void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) } -const wxPoint& GERBVIEW_FRAME::GetOriginAxisPosition() const +const wxPoint& GERBVIEW_FRAME::GetAuxOrigin() const { wxASSERT( m_gerberLayout ); - return m_gerberLayout->GetOriginAxisPosition(); + return m_gerberLayout->GetAuxOrigin(); } -void GERBVIEW_FRAME::SetOriginAxisPosition( const wxPoint& aPosition ) +void GERBVIEW_FRAME::SetAuxOrigin( const wxPoint& aPosition ) { wxASSERT( m_gerberLayout ); - m_gerberLayout->SetOriginAxisPosition( aPosition ); + m_gerberLayout->SetAuxOrigin( aPosition ); } @@ -800,8 +800,8 @@ void GERBVIEW_FRAME::UpdateStatusBar() { double theta, ro; - dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x; - dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y; + 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( -dy, dx ) ); @@ -829,9 +829,8 @@ void GERBVIEW_FRAME::UpdateStatusBar() } // Display absolute coordinates: - dXpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().x ); - dYpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().y ); - + dXpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().x ); + dYpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().y ); wxString absformatter; @@ -859,8 +858,8 @@ void GERBVIEW_FRAME::UpdateStatusBar() if( !m_DisplayOptions.m_DisplayPolarCood ) // display relative cartesian coordinates { // Display relative coordinates: - dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x; - dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y; + dx = GetCrossHairPosition().x - screen->m_O_Curseur.x; + dy = GetCrossHairPosition().y - screen->m_O_Curseur.y; dXpos = To_User_Unit( g_UserUnit, dx ); dYpos = To_User_Unit( g_UserUnit, dy ); diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 98cf6fe83d..6a69191706 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -82,7 +82,9 @@ public: class GERBVIEW_FRAME : public EDA_DRAW_FRAME // PCB_BASE_FRAME { - GBR_LAYOUT* m_gerberLayout; + GBR_LAYOUT* m_gerberLayout; + wxPoint m_grid_origin; + public: GBR_DISPLAY_OPTIONS m_DisplayOptions; @@ -126,8 +128,14 @@ public: const PAGE_INFO& GetPageSettings() const; // overload const wxSize GetPageSizeIU() const; // overload - const wxPoint& GetOriginAxisPosition() const; // overload - void SetOriginAxisPosition( const wxPoint& aPosition ); // overload + const wxPoint& GetAuxOrigin() const; // overload + void SetAuxOrigin( const wxPoint& aPoint ); // overload + + const wxPoint& GetGridOrigin() const { return m_grid_origin; } // overload + void SetGridOrigin( const wxPoint& aPoint ) // overload + { + m_grid_origin = aPoint; + } const TITLE_BLOCK& GetTitleBlock() const; // overload void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload diff --git a/gerbview/hotkeys.cpp b/gerbview/hotkeys.cpp index c07a42854e..29082a6349 100644 --- a/gerbview/hotkeys.cpp +++ b/gerbview/hotkeys.cpp @@ -31,30 +31,28 @@ * and see this list for some ascii keys (space ...) */ -/* local variables */ -/* Hotkey list: */ -static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), - HK_RESET_LOCAL_COORD, ' ' ); -static EDA_HOTKEY HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME ); -static EDA_HOTKEY HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 ); -static EDA_HOTKEY HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 ); -static EDA_HOTKEY HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 ); -static EDA_HOTKEY HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 ); -static EDA_HOTKEY HkHelp( wxT( "Help (this window)" ), HK_HELP, '?' ); -static EDA_HOTKEY HkSwitchUnits( wxT( "Switch Units" ), HK_SWITCH_UNITS, 'U' ); -static EDA_HOTKEY HkTrackDisplayMode( wxT( "Track Display Mode" ), - HK_SWITCH_GBR_ITEMS_DISPLAY_MODE, 'F' ); +// local variables +// Hotkey list: +static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' ); +static EDA_HOTKEY HkSetGridOrigin( wxT("Set Grid Origin"), HK_SET_GRID_ORIGIN, 'S' ); -static EDA_HOTKEY HkSwitch2NextCopperLayer( wxT( "Switch to Next Layer" ), - HK_SWITCH_LAYER_TO_NEXT, '+' ); -static EDA_HOTKEY HkSwitch2PreviousCopperLayer( wxT( "Switch to Previous Layer" ), - HK_SWITCH_LAYER_TO_PREVIOUS, '-' ); +static EDA_HOTKEY HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME ); +static EDA_HOTKEY HkZoomCenter( wxT( "Zoom Center" ), HK_ZOOM_CENTER, WXK_F4 ); +static EDA_HOTKEY HkZoomRedraw( wxT( "Zoom Redraw" ), HK_ZOOM_REDRAW, WXK_F3 ); +static EDA_HOTKEY HkZoomOut( wxT( "Zoom Out" ), HK_ZOOM_OUT, WXK_F2 ); +static EDA_HOTKEY HkZoomIn( wxT( "Zoom In" ), HK_ZOOM_IN, WXK_F1 ); +static EDA_HOTKEY HkHelp( wxT( "Help (this window)" ), HK_HELP, '?' ); +static EDA_HOTKEY HkSwitchUnits( wxT( "Switch Units" ), HK_SWITCH_UNITS, 'U' ); +static EDA_HOTKEY HkTrackDisplayMode( wxT( "Track Display Mode" ), HK_SWITCH_GBR_ITEMS_DISPLAY_MODE, 'F' ); + +static EDA_HOTKEY HkSwitch2NextCopperLayer( wxT( "Switch to Next Layer" ), HK_SWITCH_LAYER_TO_NEXT, '+' ); +static EDA_HOTKEY HkSwitch2PreviousCopperLayer( wxT( "Switch to Previous Layer" ), HK_SWITCH_LAYER_TO_PREVIOUS, '-' ); // List of common hotkey descriptors EDA_HOTKEY* s_Gerbview_Hotkey_List[] = { &HkHelp, - &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, - &HkZoomAuto, &HkSwitchUnits, &HkResetLocalCoord, + &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, + &HkZoomAuto, &HkSwitchUnits, &HkResetLocalCoord, &HkSetGridOrigin, &HkTrackDisplayMode, &HkSwitch2NextCopperLayer, &HkSwitch2PreviousCopperLayer, @@ -130,8 +128,12 @@ void GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit GetEventHandler()->ProcessEvent( cmd ); break; - case HK_RESET_LOCAL_COORD: /*Reset the relative coord */ - GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); + case HK_RESET_LOCAL_COORD: // Reset the relative coord + GetScreen()->m_O_Curseur = GetCrossHairPosition(); + break; + + case HK_SET_GRID_ORIGIN: + SetGridOrigin( GetCrossHairPosition() ); break; case HK_SWITCH_UNITS: diff --git a/gerbview/locate.cpp b/gerbview/locate.cpp index 4a16337f68..7e6ba30737 100644 --- a/gerbview/locate.cpp +++ b/gerbview/locate.cpp @@ -44,7 +44,7 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc bool found = false; if( aTypeloc == CURSEUR_ON_GRILLE ) - ref = GetScreen()->GetNearestGridPosition( ref ); + ref = GetNearestGridPosition( ref ); LAYER_NUM layer = getActiveLayer(); diff --git a/include/class_base_screen.h b/include/class_base_screen.h index 4da7754539..537b277bfe 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -75,53 +75,134 @@ 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. - + 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. /** * The cross hair position in logical (drawing) units. The cross hair is not the cursor * position. It is an addition indicator typically drawn on grid to indicate to the * user where the current action will be performed. */ - wxPoint m_crossHairPosition; + wxPoint m_crossHairPosition; - double m_Zoom; ///< Current zoom coefficient. + 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 = false ) 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 = true ); + + /** + * Function getCursorScreenPosition + * returns the cross hair position in device (display) units.b + * @return The current cross hair position. + */ + wxPoint getCrossHairScreenPosition() const; + + /** + * 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 = NULL ) 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 = NULL ) 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; } + + //---------------------------- public: static wxString m_PageLayoutDescrFileName; ///< the name of the page layout descr file, ///< or emty to used the default pagelayout - wxPoint m_DrawOrg; ///< offsets for drawing the circuit on the screen - wxPoint m_O_Curseur; ///< Relative Screen cursor coordinate (on grid) - ///< in user units. (coordinates from last reset position) + wxPoint m_DrawOrg; ///< offsets for drawing the circuit on the screen + + wxPoint m_O_Curseur; ///< 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. + 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. + 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_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) - */ + wxPoint m_StartVisu; /**< Coordinates in drawing units of the current + * view position (upper left corner of device) + */ - bool m_Center; /* Center on screen. If true (0.0) is centered - * on screen coordinates can be < 0 and - * > 0 except for schematics. - * false: when coordinates can only be >= 0 - * Schematic */ - bool m_FirstRedraw; + bool m_Center; /**< Center on screen. If true (0.0) is centered + * on screen coordinates can be < 0 and + * > 0 except for schematics. + * false: when coordinates can only be >= 0 + * Schematic */ + bool m_FirstRedraw; // Undo/redo list of commands UNDO_REDO_CONTAINER m_UndoList; ///< Objects list for the undo command (old data) @@ -134,8 +215,6 @@ public: int m_ScreenNumber; int m_NumberOfScreens; - wxPoint m_GridOrigin; - std::vector m_ZoomList; ///< standard zoom (i.e. scale) coefficients. bool m_IsPrinting; @@ -164,30 +243,6 @@ public: */ virtual int MilsToIuScalar() { return 1; } - /** - * 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 = false ) 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 aSnapToGrid Sets the cross hair position to the nearest grid position to - * \a aPosition. - * - */ - void SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid = true ); - /* general Undo/Redo command control */ /** @@ -247,19 +302,17 @@ public: return m_UndoList.m_CommandsList.size(); } - int GetRedoCommandCount() const { return m_RedoList.m_CommandsList.size(); } - - void SetModify() { m_FlagModified = true; } - void ClrModify() { m_FlagModified = false;; } - void SetSave() { m_FlagSave = true; } - void ClrSave() { m_FlagSave = false; } - bool IsModify() const { return m_FlagModified; } - bool IsSave() const { return m_FlagSave; } + void SetModify() { m_FlagModified = true; } + void ClrModify() { m_FlagModified = false; } + void SetSave() { m_FlagSave = true; } + void ClrSave() { m_FlagSave = false; } + bool IsModify() const { return m_FlagModified; } + bool IsSave() const { return m_FlagSave; } //------------------------------------------------------------- @@ -349,8 +402,6 @@ public: */ const GRID_TYPE& GetGrid() const { return m_Grid; } - const wxPoint& GetGridOrigin() const { return m_GridOrigin; } - void SetGrid( const wxRealPoint& size ); /** @@ -388,51 +439,6 @@ public: */ void GetGrids( GRIDS& aList ); - 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; - } - - /** - * Function GetCursorPosition - * returns 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; - - /** - * Function GetCursorScreenPosition - * returns the cross hair position in device (display) units.b - * @return The current cross hair position. - */ - wxPoint GetCrossHairScreenPosition() const; - - /** - * Function GetNearestGridPosition - * returns 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; - /** * Function GetClass * returns the class name. @@ -447,12 +453,6 @@ public: void ClearBlockCommand() { m_BlockLocate.Clear(); } - const wxPoint& GetScrollCenterPosition() const { return m_scrollCenter; } - void SetScrollCenterPosition( const wxPoint& aCenterPosition ) - { - m_scrollCenter = aCenterPosition; - } - #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const; // overload #endif diff --git a/include/class_board_design_settings.h b/include/class_board_design_settings.h index 0eedc23d22..3e18736f50 100644 --- a/include/class_board_design_settings.h +++ b/include/class_board_design_settings.h @@ -45,6 +45,8 @@ public: wxSize m_ModuleTextSize; ///< Default footprint texts size int m_ModuleTextWidth; int m_ModuleSegmentWidth; + wxPoint m_AuxOrigin; ///< origin for plot exports + wxPoint m_GridOrigin; ///< origin for grid offsets D_PAD m_Pad_Master; diff --git a/include/class_drawpanel.h b/include/class_drawpanel.h index 0e3fe4cf22..46439257c9 100644 --- a/include/class_drawpanel.h +++ b/include/class_drawpanel.h @@ -55,52 +55,55 @@ typedef void ( *END_MOUSE_CAPTURE_CALLBACK )( EDA_DRAW_PANEL* aPanel, wxDC* aDC class EDA_DRAW_PANEL : public wxScrolledWindow { private: - int m_currentCursor; ///< Current mouse cursor shape id. - int m_defaultCursor; ///< The default mouse cursor shape id. - bool m_showCrossHair; ///< Indicate if cross hair is to be shown. - int m_cursorLevel; ///< Index for cursor redraw in XOR mode. - int m_scrollIncrementX; ///< X axis scroll increment in pixels per unit. - int m_scrollIncrementY; ///< Y axis scroll increment in pixels per unit. - wxPoint m_CursorStartPos; ///< Used for testing the cursor movement. - wxPoint m_PanStartCenter; ///< Initial scroll center position when pan started - wxPoint m_PanStartEventPosition; ///< Initial position of mouse event when pan started + int m_currentCursor; ///< Current mouse cursor shape id. + int m_defaultCursor; ///< The default mouse cursor shape id. + bool m_showCrossHair; ///< Indicate if cross hair is to be shown. + int m_cursorLevel; ///< Index for cursor redraw in XOR mode. + int m_scrollIncrementX; ///< X axis scroll increment in pixels per unit. + int m_scrollIncrementY; ///< Y axis scroll increment in pixels per unit. + + wxPoint m_CursorStartPos; ///< Used for testing the cursor movement. + wxPoint m_PanStartCenter; ///< Initial scroll center position when pan started + wxPoint m_PanStartEventPosition; ///< Initial position of mouse event when pan started /// The drawing area used to redraw the screen which is usually the visible area /// of the drawing in internal units. - EDA_RECT m_ClipBox; + EDA_RECT m_ClipBox; - bool m_abortRequest; ///< Flag used to abort long commands. + bool m_abortRequest; ///< Flag used to abort long commands. - bool m_enableZoomNoCenter; ///< True to enable zooming around the crosshair instead of the center - bool m_enableMiddleButtonPan; ///< True to enable middle mouse button panning. - bool m_panScrollbarLimits; ///< has meaning only if m_enableMiddleButtonPan = true - ///< true to limit panning to scrollbar current limits - ///< false to used unlimited pan + bool m_enableZoomNoCenter; ///< True to enable zooming around the crosshair instead of the center + bool m_enableMiddleButtonPan; ///< True to enable middle mouse button panning. + bool m_panScrollbarLimits; ///< has meaning only if m_enableMiddleButtonPan = true + ///< true to limit panning to scrollbar current limits + ///< false to used unlimited pan - bool m_enableAutoPan; ///< True to enable automatic panning. + bool m_enableAutoPan; ///< True to enable automatic panning. - /// true to request an auto pan. Valid only when m_enableAutoPan = true. - bool m_requestAutoPan; + bool m_requestAutoPan; ///< true to request an auto pan. Valid only when m_enableAutoPan = true. - bool m_ignoreMouseEvents; ///< Ignore mouse events when true. + bool m_ignoreMouseEvents; ///< Ignore mouse events when true. /* Used to inhibit a response to a mouse left button release, after a double click * (when releasing the left button at the end of the second click. Used in Eeschema * to inhibit a mouse left release command when switching between hierarchical sheets * on a double click. */ - bool m_ignoreNextLeftButtonRelease; ///< Ignore the next mouse left button release when true. + bool m_ignoreNextLeftButtonRelease; ///< Ignore the next mouse left button release when true. - bool m_enableBlockCommands; ///< True enables block commands. + bool m_enableBlockCommands; ///< True enables block commands. - int m_minDragEventCount; /* Count the drag events. Used to filter mouse moves before starting a - * block command. A block command can be started only if - * MinDragEventCount > MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND - * in order to avoid spurious block commands. */ + /** + * Count the drag events. Used to filter mouse moves before starting a + * block command. A block command can be started only if + * MinDragEventCount > MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND in order to avoid + * spurious block commands. + */ + int m_minDragEventCount; /// True when drawing in mirror mode. Used by the draw arc function, because arcs /// are oriented, and in mirror mode, orientations are reversed. - bool m_PrintIsMirrored; + bool m_PrintIsMirrored; /// Mouse capture move callback function. MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback; @@ -108,9 +111,10 @@ private: /// Abort mouse capture callback function. END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback; - // useful to avoid false start block in certain cases - // (like switch from a sheet to an other sheet - int m_canStartBlock; // >= 0 (or >= n) if a block can start + /// useful to avoid false start block in certain cases + /// (like switch from a sheet to an other sheet + /// >= 0 (or >= n) if a block can start + int m_canStartBlock; public: @@ -155,9 +159,8 @@ public: void SetEnableBlockCommands( bool aEnable ) { m_enableBlockCommands = aEnable; } - bool GetPrintMirrored() const { return m_PrintIsMirrored; } - - void SetPrintMirrored( bool aMirror ) { m_PrintIsMirrored = aMirror; } + bool GetPrintMirrored() const { return m_PrintIsMirrored; } + void SetPrintMirrored( bool aMirror ) { m_PrintIsMirrored = aMirror; } void SetCanStartBlock( int aStartBlock ) { m_canStartBlock = aStartBlock; } @@ -196,8 +199,9 @@ public: * the grid origin is set by user, and is not (0,0) * @param aDC = current Device Context * @param aDrawMode = draw mode (GR_COPY, GR_OR ..) + * @param aGridOrigin = the absolute coordinate of grid origin for snap. */ - void DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode ); + void DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aGridOrigin ); void OnEraseBackground( wxEraseEvent& event ) { } @@ -324,7 +328,7 @@ public: * warps the cursor to the current cross hair position. */ void MoveCursorToCrossHair(); - + /** * Function ToDeviceXY * transforms logical to device coordinates diff --git a/include/class_sch_screen.h b/include/class_sch_screen.h index b04dc3871b..02a6787679 100644 --- a/include/class_sch_screen.h +++ b/include/class_sch_screen.h @@ -73,8 +73,8 @@ private: TITLE_BLOCK m_titles; - /// Position of the origin axis, which is used in exports mostly, but not yet in EESCHEMA - wxPoint m_originAxisPosition; + /// Origin of the auxilliary axis, which is used in exports mostly, but not yet in EESCHEMA + wxPoint m_aux_origin; DLIST< SCH_ITEM > m_drawList; ///< Object list for the screen. /// @todo use DLIST or superior container @@ -108,12 +108,12 @@ public: const PAGE_INFO& GetPageSettings() const { return m_paper; } void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; } - void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; } + void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; } - const wxString& GetFileName() const { return m_fileName; } + const wxString& GetFileName() const { return m_fileName; } - const wxPoint& GetOriginAxisPosition() const { return m_originAxisPosition; } - void SetOriginAxisPosition( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; } + const wxPoint& GetAuxOrigin() const { return m_aux_origin; } + void SetAuxOrigin( const wxPoint& aPosition ) { m_aux_origin = aPosition; } const TITLE_BLOCK& GetTitleBlock() const { return m_titles; } //TITLE_BLOCK& GetTitleBlock() const { return (TITLE_BLOCK&) m_titles; } diff --git a/include/hotkeys_basic.h b/include/hotkeys_basic.h index 8e355188f7..65f53dc483 100644 --- a/include/hotkeys_basic.h +++ b/include/hotkeys_basic.h @@ -217,6 +217,7 @@ void ParseHotkeyConfig( const wxString& data, struct EDA_HOTKEY_CONFIG* aDescLis enum common_hotkey_id_commnand { HK_NOT_FOUND = 0, HK_RESET_LOCAL_COORD, + HK_SET_GRID_ORIGIN, HK_HELP, HK_ZOOM_IN, HK_ZOOM_OUT, diff --git a/include/sch_base_frame.h b/include/sch_base_frame.h index 2265ed2ec9..e53634a28d 100644 --- a/include/sch_base_frame.h +++ b/include/sch_base_frame.h @@ -58,8 +58,15 @@ public: const PAGE_INFO& GetPageSettings () const; // overload EDA_DRAW_FRAME const wxSize GetPageSizeIU() const; // overload EDA_DRAW_FRAME - const wxPoint& GetOriginAxisPosition() const; // overload EDA_DRAW_FRAME - void SetOriginAxisPosition( const wxPoint& aPosition ); // overload EDA_DRAW_FRAME + const wxPoint& GetAuxOrigin() const; // overload EDA_DRAW_FRAME + void SetAuxOrigin( const wxPoint& aPosition ); // overload EDA_DRAW_FRAME + + const wxPoint& GetGridOrigin() const // overload EDA_DRAW_FRAME + { + static wxPoint zero; + return zero; + } + void SetGridOrigin( const wxPoint& aPoint ) {} // overload EDA_DRAW_FRAME const TITLE_BLOCK& GetTitleBlock() const; // overload EDA_DRAW_FRAME void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload EDA_DRAW_FRAME diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index 2b15bfa611..7118ff8867 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -131,8 +131,11 @@ public: const PAGE_INFO& GetPageSettings() const; // overload const wxSize GetPageSizeIU() const; // overload - const wxPoint& GetOriginAxisPosition() const; // overload - void SetOriginAxisPosition( const wxPoint& aPosition ); // overload + const wxPoint& GetAuxOrigin() const; // overload + void SetAuxOrigin( const wxPoint& aPoint ); // overload + + const wxPoint& GetGridOrigin() const; // overload + void SetGridOrigin( const wxPoint& aPoint ); // overload const TITLE_BLOCK& GetTitleBlock() const; // overload void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload diff --git a/include/wxstruct.h b/include/wxstruct.h index 3b9b0b6bcf..4c3144ea28 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -113,15 +113,15 @@ extern const wxChar* traceAutoSave; class EDA_BASE_FRAME : public wxFrame { protected: - ID_DRAWFRAME_TYPE m_Ident; // Id Type (pcb, schematic, library..) + ID_DRAWFRAME_TYPE m_Ident; ///< Id Type (pcb, schematic, library..) wxPoint m_FramePos; wxSize m_FrameSize; - wxAuiToolBar* m_mainToolBar; // Standard horizontal Toolbar + wxAuiToolBar* m_mainToolBar; ///< Standard horizontal Toolbar bool m_FrameIsActive; - wxString m_FrameName; // name used for writing and reading setup - // It is "SchematicFrame", "PcbFrame" .... - wxString m_AboutTitle; // Name of program displayed in About. + wxString m_FrameName; ///< name used for writing and reading setup + ///< It is "SchematicFrame", "PcbFrame" .... + wxString m_AboutTitle; ///< Name of program displayed in About. wxAuiManager m_auimgr; @@ -404,47 +404,47 @@ protected: EDA_DRAW_PANEL* m_canvas; /// Tool ID of previously active draw tool bar button. - int m_lastDrawToolId; + int m_lastDrawToolId; /// The shape of the KiCad cursor. The default value (0) is the normal cross /// hair cursor. Set to non-zero value to draw the full screen cursor. /// @note This is not the system mouse cursor. - int m_cursorShape; + int m_cursorShape; /// True shows the X and Y axis indicators. - bool m_showAxis; + bool m_showAxis; /// True shows the grid axis indicators. - bool m_showGridAxis; + bool m_showGridAxis; /// True shows the origin axis used to indicate the coordinate offset for /// drill, gerber, and component position files. - bool m_showOriginAxis; + bool m_showOriginAxis; /// True shows the drawing border and title block. - bool m_showBorderAndTitleBlock; + bool m_showBorderAndTitleBlock; /// Choice box to choose the grid size. - wxComboBox* m_gridSelectBox; + wxComboBox* m_gridSelectBox; /// Choice box to choose the zoom value. - wxComboBox* m_zoomSelectBox; + wxComboBox* m_zoomSelectBox; /// 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. - wxAuiToolBar* m_drawToolBar; + wxAuiToolBar* m_drawToolBar; /// The options tool bar typcially located on the left edge of the main window. - wxAuiToolBar* m_optionsToolBar; + wxAuiToolBar* m_optionsToolBar; /// Panel used to display information at the bottom of the main window. - EDA_MSG_PANEL* m_messagePanel; + EDA_MSG_PANEL* m_messagePanel; - int m_MsgFrameHeight; + int m_MsgFrameHeight; #ifdef USE_WX_OVERLAY // MAC Uses overlay to workaround the wxINVERT and wxXOR miss - wxOverlay m_overlay; + wxOverlay m_overlay; #endif protected: @@ -480,8 +480,89 @@ public: */ virtual const wxSize GetPageSizeIU() const = 0; - virtual const wxPoint& GetOriginAxisPosition() const = 0; - virtual void SetOriginAxisPosition( const wxPoint& aPosition ) = 0; + /** + * Function GetAuxOrigin + * returns the origin of the axis used for plotting and various exports. + */ + virtual const wxPoint& GetAuxOrigin() const = 0; + virtual void SetAuxOrigin( const wxPoint& aPosition ) = 0; + + /** + * Function GetGridOrigin + * returns the absolute coordinates of the origin of the snap grid. This is + * treated as a relative offset, and snapping will occur at multiples of the grid + * size relative to this point. + */ + virtual const wxPoint& GetGridOrigin() const = 0; + virtual void SetGridOrigin( const wxPoint& aPosition ) = 0; + + //----------------------------------------------- + /** + * 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 = false ) const; + + /** + * 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, bool aSnapToGrid = true ); + + /** + * 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, wxRealPoint* aGridSize = NULL ) const; + + /** + * Function GetNearestGridPosition + * returns 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; + + /** + * Function GetCursorScreenPosition + * returns the cross hair position in device (display) units.b + * @return The current cross hair position. + */ + wxPoint GetCrossHairScreenPosition() const; + + void SetMousePosition( const wxPoint& 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; + + const wxPoint& GetScrollCenterPosition() const; + void SetScrollCenterPosition( const wxPoint& aPoint ); + + //---------------------------------------------- + virtual const TITLE_BLOCK& GetTitleBlock() const = 0; virtual void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) = 0; @@ -718,13 +799,13 @@ public: void DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, double aScale, const wxString &aFilename ); - void DisplayToolMsg( const wxString& msg ); - virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) = 0; - virtual void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) = 0; - virtual void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); - virtual bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) = 0; - virtual void ToolOnRightClick( wxCommandEvent& event ); - void AdjustScrollBars( const wxPoint& aCenterPosition ); + void DisplayToolMsg( const wxString& msg ); + virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) = 0; + virtual void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) = 0; + virtual void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); + virtual bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) = 0; + virtual void ToolOnRightClick( wxCommandEvent& event ); + void AdjustScrollBars( const wxPoint& aCenterPosition ); /** * Function OnActivate (virtual) diff --git a/pagelayout_editor/class_pl_editor_layout.h b/pagelayout_editor/class_pl_editor_layout.h index 5d589ff1b1..0a418b7dbe 100644 --- a/pagelayout_editor/class_pl_editor_layout.h +++ b/pagelayout_editor/class_pl_editor_layout.h @@ -33,7 +33,7 @@ public: m_paper = aPageSettings; } - const wxPoint& GetOriginAxisPosition() const + const wxPoint& GetAuxOrigin() const { static wxPoint zero( 0, 0 ); return zero; diff --git a/pagelayout_editor/controle.cpp b/pagelayout_editor/controle.cpp index dfb674d8d3..415c0fad1c 100644 --- a/pagelayout_editor/controle.cpp +++ b/pagelayout_editor/controle.cpp @@ -35,14 +35,9 @@ void PL_EDITOR_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { - wxRealPoint gridSize; - wxPoint oldpos; - wxPoint pos = aPosition; - - pos = GetScreen()->GetNearestGridPosition( pos ); - - oldpos = GetScreen()->GetCrossHairPosition(); - gridSize = GetScreen()->GetGridSize(); + wxPoint pos = GetNearestGridPosition( aPosition ); + wxPoint oldpos = GetCrossHairPosition(); + wxRealPoint gridSize = GetScreen()->GetGridSize(); switch( aHotKey ) { @@ -74,14 +69,14 @@ void PL_EDITOR_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, break; } - GetScreen()->SetCrossHairPosition( pos ); + SetCrossHairPosition( pos ); - if( oldpos != GetScreen()->GetCrossHairPosition() ) + if( oldpos != GetCrossHairPosition() ) { - pos = GetScreen()->GetCrossHairPosition(); - GetScreen()->SetCrossHairPosition( oldpos ); + pos = GetCrossHairPosition(); + SetCrossHairPosition( oldpos ); m_canvas->CrossHairOff( aDC ); - GetScreen()->SetCrossHairPosition( pos ); + SetCrossHairPosition( pos ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) diff --git a/pagelayout_editor/events_functions.cpp b/pagelayout_editor/events_functions.cpp index bf65fd48f9..68c3d2285c 100644 --- a/pagelayout_editor/events_functions.cpp +++ b/pagelayout_editor/events_functions.cpp @@ -250,7 +250,7 @@ static void moveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositio WORKSHEET_DATAITEM *item = screen->GetCurItem(); wxCHECK_RET( (item != NULL), wxT( "Cannot move NULL item." ) ); - wxPoint position = screen->GetCrossHairPosition() + wxPoint position = aPanel->GetParent()->GetCrossHairPosition() - ( initialCursorPosition - initialPositionUi ); if( (item->GetFlags() & LOCATE_STARTPOINT) ) @@ -285,12 +285,13 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) aPanel->Refresh(); } + void PL_EDITOR_FRAME::MoveItem( WORKSHEET_DATAITEM* aItem ) { wxCHECK_RET( aItem != NULL, wxT( "Cannot move NULL item" ) ); initialPosition = aItem->GetStartPos(); initialPositionUi = aItem->GetStartPosUi(); - initialCursorPosition = GetScreen()->GetCrossHairPosition(); + initialCursorPosition = GetCrossHairPosition(); if( (aItem->GetFlags() & LOCATE_ENDPOINT) ) { @@ -300,8 +301,8 @@ void PL_EDITOR_FRAME::MoveItem( WORKSHEET_DATAITEM* aItem ) if( aItem->GetFlags() & (LOCATE_STARTPOINT|LOCATE_ENDPOINT) ) { - GetScreen()->SetCrossHairPosition( initialPositionUi, false ); - initialCursorPosition = GetScreen()->GetCrossHairPosition(); + SetCrossHairPosition( initialPositionUi, false ); + initialCursorPosition = GetCrossHairPosition(); if( m_canvas->IsPointOnDisplay( initialCursorPosition ) ) { m_canvas->MoveCursorToCrossHair(); @@ -317,6 +318,7 @@ void PL_EDITOR_FRAME::MoveItem( WORKSHEET_DATAITEM* aItem ) GetScreen()->SetCurItem( aItem ); } + /** * Save in Undo list the layout, and place an item being moved. * @param aItem is the item moved diff --git a/pagelayout_editor/hotkeys.cpp b/pagelayout_editor/hotkeys.cpp index a0ba6da265..ab8045fac6 100644 --- a/pagelayout_editor/hotkeys.cpp +++ b/pagelayout_editor/hotkeys.cpp @@ -180,7 +180,11 @@ void PL_EDITOR_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, break; case HK_RESET_LOCAL_COORD: // Reset the relative coord - GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); + GetScreen()->m_O_Curseur = GetCrossHairPosition(); + break; + + case HK_SET_GRID_ORIGIN: + SetGridOrigin( GetCrossHairPosition() ); break; case HK_MOVE_ITEM: diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 5d8b36f052..3e18ba0ee8 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -254,7 +254,7 @@ double PL_EDITOR_FRAME::BestZoom() double bestzoom = std::max( zx, zy ); - GetScreen()->SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) ); + SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) ); return bestzoom; } @@ -369,42 +369,44 @@ void PL_EDITOR_FRAME::UpdateStatusBar() wxPoint originCoord; int Xsign = 1; int Ysign = 1; + WORKSHEET_DATAITEM dummy( WORKSHEET_DATAITEM::WS_SEGMENT ); + switch( m_originSelectChoice ) { - default: - case 0: // Origin = paper Left Top corner - break; + default: + case 0: // Origin = paper Left Top corner + break; - case 1: // Origin = page Right Bottom corner - Xsign = -1; - Ysign = -1; - dummy.SetStart( 0, 0, RB_CORNER ); - originCoord = dummy.GetStartPosUi(); - break; + case 1: // Origin = page Right Bottom corner + Xsign = -1; + Ysign = -1; + dummy.SetStart( 0, 0, RB_CORNER ); + originCoord = dummy.GetStartPosUi(); + break; - case 2: // Origin = page Left Bottom corner - Ysign = -1; - dummy.SetStart( 0, 0, LB_CORNER ); - originCoord = dummy.GetStartPosUi(); - break; + case 2: // Origin = page Left Bottom corner + Ysign = -1; + dummy.SetStart( 0, 0, LB_CORNER ); + originCoord = dummy.GetStartPosUi(); + break; - case 3: // Origin = page Right Top corner - Xsign = -1; - dummy.SetStart( 0, 0, RT_CORNER ); - originCoord = dummy.GetStartPosUi(); - break; + case 3: // Origin = page Right Top corner + Xsign = -1; + dummy.SetStart( 0, 0, RT_CORNER ); + originCoord = dummy.GetStartPosUi(); + break; - case 4: // Origin = page Left Top corner - dummy.SetStart( 0, 0, LT_CORNER ); - originCoord = dummy.GetStartPosUi(); - break; + case 4: // Origin = page Left Top corner + dummy.SetStart( 0, 0, LT_CORNER ); + originCoord = dummy.GetStartPosUi(); + break; } - screen->m_GridOrigin = originCoord; + SetGridOrigin( originCoord ); // Display absolute coordinates: - wxPoint coord = screen->GetCrossHairPosition() - originCoord; + wxPoint coord = GetCrossHairPosition() - originCoord; double dXpos = To_User_Unit( g_UserUnit, coord.x*Xsign ); double dYpos = To_User_Unit( g_UserUnit, coord.y*Ysign ); @@ -441,8 +443,8 @@ void PL_EDITOR_FRAME::UpdateStatusBar() SetStatusText( line, 2 ); // Display relative coordinates: - int dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x; - int dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y; + int dx = GetCrossHairPosition().x - screen->m_O_Curseur.x; + int dy = GetCrossHairPosition().y - screen->m_O_Curseur.y; dXpos = To_User_Unit( g_UserUnit, dx * Xsign ); dYpos = To_User_Unit( g_UserUnit, dy * Ysign ); line.Printf( locformatter, dXpos, dYpos ); @@ -594,10 +596,11 @@ WORKSHEET_DATAITEM * PL_EDITOR_FRAME::GetSelectedItem() */ WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( const wxPoint& aPosition ) { - const PAGE_INFO& pageInfo = GetPageSettings(); - TITLE_BLOCK t_block = GetTitleBlock(); - EDA_COLOR_T color = RED; // Needed, not used - PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) GetScreen(); + const PAGE_INFO& pageInfo = GetPageSettings(); + TITLE_BLOCK t_block = GetTitleBlock(); + EDA_COLOR_T color = RED; // Needed, not used + PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) GetScreen(); + screen-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2; WS_DRAW_ITEM_LIST drawList; @@ -623,9 +626,9 @@ WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( const wxPoint& aPosition ) // Choose item in list if more than 1 item if( list.size() > 1 ) { - wxArrayString choices; + wxArrayString choices; wxString text; - wxPoint cursPos = screen->GetCrossHairPosition(); + wxPoint cursPos = GetCrossHairPosition(); for( unsigned ii = 0; ii < list.size(); ++ii ) { @@ -656,7 +659,7 @@ WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( const wxPoint& aPosition ) if( selection < 0 ) return NULL; - screen->SetCrossHairPosition( cursPos ); + SetCrossHairPosition( cursPos ); m_canvas->MoveCursorToCrossHair(); drawitem = list[selection]; } diff --git a/pagelayout_editor/pl_editor_frame.h b/pagelayout_editor/pl_editor_frame.h index 8b1e85c72f..660e02d1b8 100644 --- a/pagelayout_editor/pl_editor_frame.h +++ b/pagelayout_editor/pl_editor_frame.h @@ -58,6 +58,8 @@ class PL_EDITOR_FRAME : public EDA_DRAW_FRAME // usefull when there are some items which are // only on page 1, not on page 1 + wxPoint m_grid_origin; + protected: /// The last filename chosen to be proposed to the user wxString m_lastFileName; @@ -90,12 +92,21 @@ public: return (PL_EDITOR_SCREEN*) m_canvas->GetScreen(); } - const wxPoint& GetOriginAxisPosition() const // overload EDA_DRAW_FRAME + const wxPoint& GetAuxOrigin() const // overload EDA_DRAW_FRAME { - static wxPoint dummy( 0,0 ); + static wxPoint dummy; // ( 0,0 ); return dummy; } - void SetOriginAxisPosition( const wxPoint& aPosition ) {} // overload EDA_DRAW_FRAME + void SetAuxOrigin( const wxPoint& aPosition ) {} // overload EDA_DRAW_FRAME + + const wxPoint& GetGridOrigin() const // overload EDA_DRAW_FRAME + { + return m_grid_origin; + } + void SetGridOrigin( const wxPoint& aPoint ) // overload EDA_DRAW_FRAME + { + m_grid_origin = aPoint; + } const TITLE_BLOCK& GetTitleBlock() const; // overload EDA_DRAW_FRAME void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload EDA_DRAW_FRAME diff --git a/pcbnew/autorouter/automove.cpp b/pcbnew/autorouter/automove.cpp index 401b7d8606..19d04e5885 100644 --- a/pcbnew/autorouter/automove.cpp +++ b/pcbnew/autorouter/automove.cpp @@ -106,7 +106,7 @@ void PCB_EDIT_FRAME::AutoPlace( wxCommandEvent& event ) break; } - /* Erase ratsnest if needed */ + // Erase ratsnest if needed if( GetBoard()->IsElementVisible(RATSNEST_VISIBLE) ) DrawGeneralRatsnest( &dc ); @@ -191,7 +191,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) return; } - /* Confirmation */ + // Confirmation if( !IsOK( this, _( "Move modules?" ) ) ) return; @@ -223,15 +223,15 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) */ if( PlaceModulesHorsPcb && edgesExist ) { - if( GetScreen()->GetCrossHairPosition().y < (bbbox.GetBottom() + 2000) ) + if( GetCrossHairPosition().y < (bbbox.GetBottom() + 2000) ) { - wxPoint pos = GetScreen()->GetCrossHairPosition(); + wxPoint pos = GetCrossHairPosition(); pos.y = bbbox.GetBottom() + 2000; - GetScreen()->SetCrossHairPosition( pos ); + SetCrossHairPosition( pos ); } } - /* calculate the area needed by footprints */ + // calculate the area needed by footprints surface = 0.0; for( unsigned ii = 0; ii < moduleList.size(); ii++ ) @@ -249,7 +249,7 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) Xsize_allowed = (int) ( sqrt( surface ) * 4.0 / 3.0 ); - start = current = GetScreen()->GetCrossHairPosition(); + start = current = GetCrossHairPosition(); Ymax_size = 0; for( unsigned ii = 0; ii < moduleList.size(); ii++ ) @@ -276,8 +276,8 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) Ymax_size = 0; } - GetScreen()->SetCrossHairPosition( current + Module->GetPosition() - - Module->GetBoundingBox().GetPosition() ); + SetCrossHairPosition( current + Module->GetPosition() - + Module->GetBoundingBox().GetPosition() ); Ymax_size = std::max( Ymax_size, Module->GetBoundingBox().GetHeight() ); diff --git a/pcbnew/autorouter/autoplac.cpp b/pcbnew/autorouter/autoplac.cpp index 1baf7097e7..5aa3db6d0d 100644 --- a/pcbnew/autorouter/autoplac.cpp +++ b/pcbnew/autorouter/autoplac.cpp @@ -62,20 +62,20 @@ */ static const double OrientPenality[11] = { - 2.0f, /* CntRot = 0 rotation prohibited */ - 1.9f, /* CntRot = 1 */ - 1.8f, /* CntRot = 2 */ - 1.7f, /* CntRot = 3 */ - 1.6f, /* CntRot = 4 */ - 1.5f, /* CntRot = 5 */ - 1.4f, /* CntRot = 5 */ - 1.3f, /* CntRot = 7 */ - 1.2f, /* CntRot = 8 */ - 1.1f, /* CntRot = 9 */ - 1.0f /* CntRot = 10 rotation authorized, no penalty */ + 2.0f, // CntRot = 0 rotation prohibited + 1.9f, // CntRot = 1 + 1.8f, // CntRot = 2 + 1.7f, // CntRot = 3 + 1.6f, // CntRot = 4 + 1.5f, // CntRot = 5 + 1.4f, // CntRot = 5 + 1.3f, // CntRot = 7 + 1.2f, // CntRot = 8 + 1.1f, // CntRot = 9 + 1.0f // CntRot = 10 rotation authorized, no penalty }; -/* Cell states. */ +// Cell states. #define OUT_OF_BOARD -2 #define OCCUPED_By_MODULE -1 @@ -149,7 +149,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) if( RoutingMatrix.m_GridRouting < 10*IU_PER_MILS ) RoutingMatrix.m_GridRouting = 10*IU_PER_MILS; // Min value = 1/1000 inch - /* Compute module parameters used in auto place */ + // Compute module parameters used in auto place if( GenPlaceBoard() == 0 ) return; @@ -245,7 +245,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) msg.Printf( _("Place module %d of %d"), cnt, moduleCount ); SetStatusText( msg ); - /* Display fill area of interest, barriers, penalties. */ + // Display fill area of interest, barriers, penalties. DrawInfoPlace( DC ); error = GetOptimalModulePlacement( Module, DC ); @@ -255,7 +255,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) if( error == ESC ) goto end_of_tst; - /* Determine if the best orientation of a module is 180. */ + // Determine if the best orientation of a module is 180. ii = Module->GetPlacementCost180() & 0x0F; if( ii != 0 ) @@ -266,7 +266,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) error = GetOptimalModulePlacement( Module, DC ); MinCout *= OrientPenality[ii]; - if( BestScore > MinCout ) /* This orientation is best. */ + if( BestScore > MinCout ) // This orientation is best. { PosOK = CurrPosition; BestScore = MinCout; @@ -281,7 +281,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) goto end_of_tst; } - /* Determine if the best orientation of a module is 90. */ + // Determine if the best orientation of a module is 90. ii = Module->GetPlacementCost90() & 0x0F; if( ii != 0 ) @@ -291,7 +291,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) error = GetOptimalModulePlacement( Module, DC ); MinCout *= OrientPenality[ii]; - if( BestScore > MinCout ) /* This orientation is best. */ + if( BestScore > MinCout ) // This orientation is best. { PosOK = CurrPosition; BestScore = MinCout; @@ -306,7 +306,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) goto end_of_tst; } - /* Determine if the best orientation of a module is 270. */ + // Determine if the best orientation of a module is 270. ii = (Module->GetPlacementCost90() >> 4 ) & 0x0F; if( ii != 0 ) @@ -316,7 +316,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) error = GetOptimalModulePlacement( Module, DC ); MinCout *= OrientPenality[ii]; - if( BestScore > MinCout ) /* This orientation is best. */ + if( BestScore > MinCout ) // This orientation is best. { PosOK = CurrPosition; BestScore = MinCout; @@ -336,11 +336,11 @@ end_of_tst: if( error == ESC ) break; - /* Place module. */ - CurrPosition = GetScreen()->GetCrossHairPosition(); - GetScreen()->SetCrossHairPosition( PosOK ); + // Place module. + CurrPosition = GetCrossHairPosition(); + SetCrossHairPosition( PosOK ); PlaceModule( Module, DC ); - GetScreen()->SetCrossHairPosition( CurrPosition ); + SetCrossHairPosition( CurrPosition ); Module->CalculateBoundingBox(); @@ -393,14 +393,14 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC ) if( top_state & CELL_is_ZONE ) color = BLUE; - /* obstacles */ + // obstacles if( ( top_state & CELL_is_EDGE ) || ( bottom_state & CELL_is_EDGE ) ) color = WHITE; else if( top_state & ( HOLE | CELL_is_MODULE ) ) color = LIGHTRED; else if( bottom_state & (HOLE | CELL_is_MODULE) ) color = LIGHTGREEN; - else /* Display the filling and keep out regions. */ + else // Display the filling and keep out regions. { if( RoutingMatrix.GetDist( ii, jj, TOP ) || RoutingMatrix.GetDist( ii, jj, BOTTOM ) ) @@ -438,12 +438,12 @@ int PCB_EDIT_FRAME::GenPlaceBoard() msg.Printf( wxT( "%d" ), nbCells ); m_messagePanel->SetMessage( 14, _( "Cells." ), msg, YELLOW ); - /* Choose the number of board sides. */ + // Choose the number of board sides. RoutingMatrix.m_RoutingLayersCount = 2; RoutingMatrix.InitRoutingMatrix(); - /* Display memory usage. */ + // Display memory usage. msg.Printf( wxT( "%d" ), RoutingMatrix.m_MemSize / 1024 ); m_messagePanel->SetMessage( 24, wxT( "Mem(Kb)" ), msg, CYAN ); @@ -454,7 +454,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard() g_Route_Layer_TOP = LAYER_N_FRONT; - /* Place the edge layer segments */ + // Place the edge layer segments TRACK TmpSegm( NULL ); TmpSegm.SetLayer( UNDEFINED_LAYER ); @@ -561,7 +561,7 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module ) int trackWidth = GetBoard()->m_NetClasses.GetDefault()->GetTrackWidth(); int clearance = GetBoard()->m_NetClasses.GetDefault()->GetClearance(); - /* Trace pads and surface safely. */ + // Trace pads and surface safely. marge = trackWidth + clearance; for( Pad = Module->Pads(); Pad != NULL; Pad = Pad->Next() ) @@ -569,7 +569,7 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module ) ::PlacePad( Pad, CELL_is_MODULE, marge, WRITE_OR_CELL ); } - /* Trace clearance. */ + // Trace clearance. marge = ( RoutingMatrix.m_GridRouting * Module->GetPadCount() ) / GAIN; CreateKeepOutRectangle( ox, oy, fx, fy, marge, KEEP_OUT_MARGIN, layerMask ); } @@ -578,7 +578,7 @@ void PCB_EDIT_FRAME::GenModuleOnBoard( MODULE* Module ) int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC ) { int cx, cy; - int ox, oy, fx, fy; /* occupying part of the module focuses on the cursor */ + int ox, oy, fx, fy; // occupying part of the module focuses on the cursor int error = 1; int showRat = 0; wxPoint LastPosOK; @@ -604,7 +604,7 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC ) CurrPosition.x = RoutingMatrix.m_BrdBox.GetX() - ox; CurrPosition.y = RoutingMatrix.m_BrdBox.GetY() - oy; - /* Module placement on grid. */ + // Module placement on grid. CurrPosition.x -= CurrPosition.x % RoutingMatrix.m_GridRouting; CurrPosition.y -= CurrPosition.y % RoutingMatrix.m_GridRouting; @@ -664,7 +664,7 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC ) g_Offset_Module.x = cx - CurrPosition.x; CurrPosition.y = RoutingMatrix.m_BrdBox.GetY() - oy; - /* Placement on grid. */ + // Placement on grid. CurrPosition.y -= CurrPosition.y % RoutingMatrix.m_GridRouting; DrawModuleOutlines( m_canvas, aDC, aModule ); @@ -673,7 +673,7 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC ) CurrPosition.y += RoutingMatrix.m_GridRouting ) { #ifndef USE_WX_OVERLAY - /* Erase traces. */ + // Erase traces. DrawModuleOutlines( m_canvas, aDC, aModule ); if( showRat ) @@ -717,14 +717,14 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC ) } } - DrawModuleOutlines( m_canvas, aDC, aModule ); /* erasing the last traces */ + DrawModuleOutlines( m_canvas, aDC, aModule ); // erasing the last traces g_Show_Module_Ratsnest = showRats; if( showRat ) Compute_Ratsnest_PlaceModule( aDC ); - /* Regeneration of the modified variable. */ + // Regeneration of the modified variable. aModule->GetBoundingBox().SetX( ox + cx ); aModule->GetBoundingBox().SetY( oy + cy ); CurrPosition = LastPosOK; @@ -926,7 +926,7 @@ double PCB_EDIT_FRAME::Compute_Ratsnest_PlaceModule( wxDC* DC ) GRLine( m_canvas->GetClipBox(), DC, start, end, 0, color ); } #endif - /* Cost of the ratsnest. */ + // Cost of the ratsnest. dx = end.x - start.x; dy = end.y - start.y; @@ -970,10 +970,10 @@ void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1, int lgain, cgain; if( aLayerMask & GetLayerMask( g_Route_Layer_BOTTOM ) ) - trace = 1; /* Trace on bottom layer. */ + trace = 1; // Trace on bottom layer. if( ( aLayerMask & GetLayerMask( g_Route_Layer_TOP ) ) && RoutingMatrix.m_RoutingLayersCount ) - trace |= 2; /* Trace on top layer. */ + trace |= 2; // Trace on top layer. if( trace == 0 ) return; @@ -991,7 +991,7 @@ void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1, if( pmarge < 1 ) pmarge = 1; - /* Calculate the coordinate limits of the rectangle. */ + // Calculate the coordinate limits of the rectangle. row_max = uy1 / RoutingMatrix.m_GridRouting; col_max = ux1 / RoutingMatrix.m_GridRouting; row_min = uy0 / RoutingMatrix.m_GridRouting; @@ -1057,7 +1057,7 @@ void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1, } -/* Sort routines */ +// Sort routines static bool Tri_PlaceModules( MODULE* ref, MODULE* compare ) { double ff1, ff2; @@ -1114,7 +1114,7 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC ) pcbframe->SetMsgPanel( Module ); pcbframe->build_ratsnest_module( Module ); - /* Calculate external ratsnest. */ + // Calculate external ratsnest. for( unsigned ii = 0; ii < pcbframe->GetBoard()->m_LocalRatsnest.size(); ii++ ) { if( ( pcbframe->GetBoard()->m_LocalRatsnest[ii].m_Status & @@ -1127,7 +1127,7 @@ static MODULE* PickModule( PCB_EDIT_FRAME* pcbframe, wxDC* DC ) sort( moduleList.begin(), moduleList.end(), Tri_RatsModules ); - /* Search for "best" module. */ + // Search for "best" module. MODULE* bestModule = NULL; MODULE* altModule = NULL; @@ -1199,7 +1199,7 @@ int propagate() { current_cell = RoutingMatrix.GetCell( row, col, BOTTOM ) & NO_CELL_ZONE; - if( current_cell == 0 ) /* a free cell is found */ + if( current_cell == 0 ) // a free cell is found { if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[col] & CELL_is_ZONE) ) { @@ -1224,7 +1224,7 @@ int propagate() { current_cell = RoutingMatrix.GetCell( row, col, BOTTOM ) & NO_CELL_ZONE; - if( current_cell == 0 ) /* a free cell is found */ + if( current_cell == 0 ) // a free cell is found { if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[col] & CELL_is_ZONE) ) { @@ -1249,7 +1249,7 @@ int propagate() { current_cell = RoutingMatrix.GetCell( row, col, BOTTOM ) & NO_CELL_ZONE; - if( current_cell == 0 ) /* a free cell is found */ + if( current_cell == 0 ) // a free cell is found { if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[row] & CELL_is_ZONE) ) { @@ -1274,7 +1274,7 @@ int propagate() { current_cell = RoutingMatrix.GetCell( row, col, BOTTOM ) & NO_CELL_ZONE; - if( current_cell == 0 ) /* a free cell is found */ + if( current_cell == 0 ) // a free cell is found { if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[row] & CELL_is_ZONE) ) { diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index fc7d20a57d..1cd6d4663d 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -148,17 +148,31 @@ const wxSize PCB_BASE_FRAME::GetPageSizeIU() const } -const wxPoint& PCB_BASE_FRAME::GetOriginAxisPosition() const +const wxPoint& PCB_BASE_FRAME::GetAuxOrigin() const { wxASSERT( m_Pcb ); - return m_Pcb->GetOriginAxisPosition(); + return m_Pcb->GetAuxOrigin(); } -void PCB_BASE_FRAME::SetOriginAxisPosition( const wxPoint& aPosition ) +void PCB_BASE_FRAME::SetAuxOrigin( const wxPoint& aPoint ) { wxASSERT( m_Pcb ); - m_Pcb->SetOriginAxisPosition( aPosition ); + m_Pcb->SetAuxOrigin( aPoint ); +} + + +const wxPoint& PCB_BASE_FRAME::GetGridOrigin() const +{ + wxASSERT( m_Pcb ); + return m_Pcb->GetGridOrigin(); +} + + +void PCB_BASE_FRAME::SetGridOrigin( const wxPoint& aPoint ) +{ + wxASSERT( m_Pcb ); + m_Pcb->SetGridOrigin( aPoint ); } @@ -258,7 +272,7 @@ double PCB_BASE_FRAME::BestZoom() double bestzoom = std::max( iu_per_du_X, iu_per_du_Y ); - GetScreen()->SetScrollCenterPosition( ibbbox.Centre() ); + SetScrollCenterPosition( ibbbox.Centre() ); return bestzoom; } @@ -268,21 +282,19 @@ void PCB_BASE_FRAME::CursorGoto( const wxPoint& aPos, bool aWarp ) { // factored out of pcbnew/find.cpp - PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen(); - INSTALL_UNBUFFERED_DC( dc, m_canvas ); // There may be need to reframe the drawing. if( !m_canvas->IsPointOnDisplay( aPos ) ) { - screen->SetCrossHairPosition( aPos ); + SetCrossHairPosition( aPos ); RedrawScreen( aPos, aWarp ); } else { // Put cursor on item position m_canvas->CrossHairOff( &dc ); - screen->SetCrossHairPosition( aPos ); + SetCrossHairPosition( aPos ); if( aWarp ) m_canvas->MoveCursorToCrossHair(); @@ -560,8 +572,8 @@ void PCB_BASE_FRAME::UpdateStatusBar() { double theta, ro; - dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x; - dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y; + dx = GetCrossHairPosition().x - screen->m_O_Curseur.x; + dy = GetCrossHairPosition().y - screen->m_O_Curseur.y; theta = ArcTangente( -dy, dx ) / 10; @@ -598,8 +610,8 @@ void PCB_BASE_FRAME::UpdateStatusBar() } // Display absolute coordinates: - dXpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().x ); - dYpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().y ); + dXpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().x ); + dYpos = To_User_Unit( g_UserUnit, GetCrossHairPosition().y ); // The following sadly is an if Eeschema/if Pcbnew wxString absformatter; @@ -642,8 +654,8 @@ void PCB_BASE_FRAME::UpdateStatusBar() if( !DisplayOpt.DisplayPolarCood ) // display relative cartesian coordinates { // Display relative coordinates: - dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x; - dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y; + dx = GetCrossHairPosition().x - screen->m_O_Curseur.x; + dy = GetCrossHairPosition().y - screen->m_O_Curseur.y; dXpos = To_User_Unit( g_UserUnit, dx ); dYpos = To_User_Unit( g_UserUnit, dy ); diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index 88e96f8abf..20c6b848a3 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -120,7 +120,7 @@ private: static bool InstallBlockCmdFrame( PCB_BASE_FRAME* parent, const wxString& title ) { - wxPoint oldpos = parent->GetScreen()->GetCrossHairPosition(); + wxPoint oldpos = parent->GetCrossHairPosition(); parent->GetCanvas()->SetIgnoreMouseEvents( true ); DIALOG_BLOCK_OPTIONS * dlg = new DIALOG_BLOCK_OPTIONS( parent, title ); @@ -128,7 +128,7 @@ static bool InstallBlockCmdFrame( PCB_BASE_FRAME* parent, const wxString& title int cmd = dlg->ShowModal(); dlg->Destroy(); - parent->GetScreen()->SetCrossHairPosition( oldpos ); + parent->SetCrossHairPosition( oldpos ); parent->GetCanvas()->MoveCursorToCrossHair(); parent->GetCanvas()->SetIgnoreMouseEvents( false ); @@ -232,9 +232,9 @@ void PCB_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) case BLOCK_IDLE: break; - case BLOCK_DRAG: /* Drag */ - case BLOCK_MOVE: /* Move */ - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + case BLOCK_DRAG: // Drag + case BLOCK_MOVE: // Move + case BLOCK_PRESELECT_MOVE: // Move with preselection list if( m_canvas->IsMouseCaptured() ) m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); @@ -242,7 +242,7 @@ void PCB_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) GetScreen()->m_BlockLocate.ClearItemsList(); break; - case BLOCK_COPY: /* Copy */ + case BLOCK_COPY: // Copy if( m_canvas->IsMouseCaptured() ) m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); @@ -315,35 +315,35 @@ bool PCB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); break; - case BLOCK_DRAG: /* Drag (not used, for future enhancements)*/ - case BLOCK_MOVE: /* Move */ - case BLOCK_COPY: /* Copy */ - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + case BLOCK_DRAG: // Drag (not used, for future enhancements) + case BLOCK_MOVE: // Move + case BLOCK_COPY: // Copy + case BLOCK_PRESELECT_MOVE: // Move with preselection list GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE ); nextcmd = true; m_canvas->SetMouseCaptureCallback( drawMovingBlock ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); break; - case BLOCK_DELETE: /* Delete */ + case BLOCK_DELETE: // Delete m_canvas->SetMouseCaptureCallback( NULL ); GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP ); Block_Delete(); break; - case BLOCK_ROTATE: /* Rotation */ + case BLOCK_ROTATE: // Rotation m_canvas->SetMouseCaptureCallback( NULL ); GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP ); Block_Rotate(); break; - case BLOCK_FLIP: /* Flip */ + case BLOCK_FLIP: // Flip m_canvas->SetMouseCaptureCallback( NULL ); GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP ); Block_Flip(); break; - case BLOCK_SAVE: /* Save (not used, for future enhancements)*/ + case BLOCK_SAVE: // Save (not used, for future enhancements) GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP ); if( GetScreen()->m_BlockLocate.GetCount() ) @@ -355,7 +355,7 @@ bool PCB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) case BLOCK_PASTE: break; - case BLOCK_ZOOM: /* Window Zoom */ + case BLOCK_ZOOM: // Window Zoom // Turn off the redraw block routine now so it is not displayed // with one corner at the new center of the screen @@ -577,7 +577,7 @@ static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& a if( screen->m_BlockLocate.GetState() != STATE_BLOCK_STOP ) { - screen->m_BlockLocate.SetMoveVector( screen->GetCrossHairPosition() - + screen->m_BlockLocate.SetMoveVector( aPanel->GetParent()->GetCrossHairPosition() - screen->m_BlockLocate.GetLastCursorPosition() ); } @@ -600,7 +600,7 @@ void PCB_EDIT_FRAME::Block_Delete() PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems(); itemsList->m_Status = UR_DELETED; - /* unlink items and clear flags */ + // unlink items and clear flags for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ ) { BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii ); @@ -658,7 +658,7 @@ void PCB_EDIT_FRAME::Block_Rotate() wxPoint centre; // rotation cent-re for the rotation transform int rotAngle = 900; // rotation angle in 0.1 deg. - oldpos = GetScreen()->GetCrossHairPosition(); + oldpos = GetCrossHairPosition(); centre = GetScreen()->m_BlockLocate.Centre(); OnModify(); @@ -680,7 +680,7 @@ void PCB_EDIT_FRAME::Block_Rotate() m_Pcb->m_Status_Pcb = 0; break; - /* Move and rotate the track segments */ + // Move and rotate the track segments case PCB_TRACE_T: // a track segment (segment on a copper layer) case PCB_VIA_T: // a via (like track segment on a copper layer) m_Pcb->m_Status_Pcb = 0; @@ -716,14 +716,14 @@ void PCB_EDIT_FRAME::Block_Flip() { #define INVERT( pos ) (pos) = center.y - ( (pos) - center.y ) wxPoint memo; - wxPoint center; /* Position of the axis for inversion of all elements */ + wxPoint center; // Position of the axis for inversion of all elements OnModify(); PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems(); itemsList->m_Status = UR_FLIPPED; - memo = GetScreen()->GetCrossHairPosition(); + memo = GetCrossHairPosition(); center = GetScreen()->m_BlockLocate.Centre(); @@ -741,7 +741,7 @@ void PCB_EDIT_FRAME::Block_Flip() m_Pcb->m_Status_Pcb = 0; break; - /* Move and rotate the track segments */ + // Move and rotate the track segments case PCB_TRACE_T: // a track segment (segment on a copper layer) case PCB_VIA_T: // a via (like track segment on a copper layer) m_Pcb->m_Status_Pcb = 0; @@ -795,7 +795,7 @@ void PCB_EDIT_FRAME::Block_Move() item->ClearFlags(); break; - /* Move track segments */ + // Move track segments case PCB_TRACE_T: // a track segment (segment on a copper layer) case PCB_VIA_T: // a via (like a track segment on a copper layer) m_Pcb->m_Status_Pcb = 0; diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp index 0301a8c1b5..01e18f6fbb 100644 --- a/pcbnew/block_module_editor.cpp +++ b/pcbnew/block_module_editor.cpp @@ -127,12 +127,14 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) { BLOCK_STATE_T state = GetScreen()->m_BlockLocate.GetState(); BLOCK_COMMAND_T command = GetScreen()->m_BlockLocate.GetCommand(); + m_canvas->CallEndMouseCapture( DC ); GetScreen()->m_BlockLocate.SetState( state ); GetScreen()->m_BlockLocate.SetCommand( command ); m_canvas->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand ); - GetScreen()->SetCrossHairPosition( wxPoint( GetScreen()->m_BlockLocate.GetRight(), - GetScreen()->m_BlockLocate.GetBottom() ) ); + + SetCrossHairPosition( wxPoint( GetScreen()->m_BlockLocate.GetRight(), + GetScreen()->m_BlockLocate.GetBottom() ) ); m_canvas->MoveCursorToCrossHair(); } @@ -142,9 +144,9 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); break; - case BLOCK_DRAG: /* Drag */ - case BLOCK_MOVE: /* Move */ - case BLOCK_COPY: /* Copy */ + case BLOCK_DRAG: // Drag + case BLOCK_MOVE: // Move + case BLOCK_COPY: // Copy itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) @@ -164,13 +166,13 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) break; - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + case BLOCK_PRESELECT_MOVE: // Move with preselection list nextcmd = true; m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines ); GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE ); break; - case BLOCK_DELETE: /* Delete */ + case BLOCK_DELETE: // Delete itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) @@ -179,7 +181,7 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) DeleteMarkedItems( currentModule ); break; - case BLOCK_SAVE: /* Save */ + case BLOCK_SAVE: // Save case BLOCK_PASTE: break; @@ -195,7 +197,7 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) case BLOCK_MIRROR_X: case BLOCK_MIRROR_Y: - case BLOCK_FLIP: /* mirror */ + case BLOCK_FLIP: // mirror itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) @@ -204,7 +206,7 @@ bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() ); break; - case BLOCK_ZOOM: /* Window Zoom */ + case BLOCK_ZOOM: // Window Zoom Window_Zoom( GetScreen()->m_BlockLocate ); break; @@ -249,28 +251,28 @@ void FOOTPRINT_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) case BLOCK_IDLE: break; - case BLOCK_DRAG: /* Drag */ - case BLOCK_MOVE: /* Move */ - case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ + case BLOCK_DRAG: // Drag + case BLOCK_MOVE: // Move + case BLOCK_PRESELECT_MOVE: // Move with preselection list GetScreen()->m_BlockLocate.ClearItemsList(); SaveCopyInUndoList( currentModule, UR_MODEDIT ); MoveMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector() ); m_canvas->Refresh( true ); break; - case BLOCK_COPY: /* Copy */ + case BLOCK_COPY: // Copy GetScreen()->m_BlockLocate.ClearItemsList(); SaveCopyInUndoList( currentModule, UR_MODEDIT ); CopyMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector() ); break; - case BLOCK_PASTE: /* Paste */ + case BLOCK_PASTE: // Paste GetScreen()->m_BlockLocate.ClearItemsList(); break; case BLOCK_MIRROR_X: case BLOCK_MIRROR_Y: - case BLOCK_FLIP: /* Mirror by popup menu, from block move */ + case BLOCK_FLIP: // Mirror by popup menu, from block move SaveCopyInUndoList( currentModule, UR_MODEDIT ); MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() ); break; @@ -304,8 +306,8 @@ void FOOTPRINT_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { - BASE_SCREEN* screen = aPanel->GetScreen(); - FOOTPRINT_EDIT_FRAME * moduleEditFrame = FOOTPRINT_EDIT_FRAME::GetActiveFootprintEditor(); + BASE_SCREEN* screen = aPanel->GetScreen(); + FOOTPRINT_EDIT_FRAME* moduleEditFrame = FOOTPRINT_EDIT_FRAME::GetActiveFootprintEditor(); wxASSERT( moduleEditFrame ); MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules; @@ -319,7 +321,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx if( currentModule ) { - wxPoint move_offset = -block->GetMoveVector(); + wxPoint move_offset = -block->GetMoveVector(); BOARD_ITEM* item = currentModule->GraphicalItems(); for( ; item != NULL; item = item->Next() ) @@ -351,15 +353,15 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx } } - /* Repaint new view. */ - block->SetMoveVector( screen->GetCrossHairPosition() - block->GetLastCursorPosition() ); + // Repaint new view. + block->SetMoveVector( moduleEditFrame->GetCrossHairPosition() - block->GetLastCursorPosition() ); block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() ); if( currentModule ) { BOARD_ITEM* item = currentModule->GraphicalItems(); - wxPoint move_offset = - block->GetMoveVector(); + wxPoint move_offset = - block->GetMoveVector(); for( ; item != NULL; item = item->Next() ) { diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index dc4dcdad5b..67917a52b1 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -215,6 +215,8 @@ private: ZONE_CONTAINERS m_ZoneDescriptorList; LAYER m_Layer[NB_LAYERS]; + + wxPoint m_grid_origin; // if true m_highLight_NetCode is used HIGH_LIGHT_INFO m_highLight; // current high light data HIGH_LIGHT_INFO m_highLightPrevious; // a previously stored high light data @@ -231,9 +233,6 @@ private: TITLE_BLOCK m_titles; ///< text in lower right of screen and plots PCB_PLOT_PARAMS m_plotOptions; - /// Position of the origin axis, which is used in exports mostly - wxPoint m_originAxisPosition; - /// Number of pads connected to the current net. int m_nodeCount; @@ -387,6 +386,20 @@ public: return (int) m_markers.size(); } + /** + * Function SetAuxOrigin + * sets the origin point used for plotting. + */ + void SetAuxOrigin( const wxPoint& aPoint ) { m_designSettings.m_AuxOrigin = aPoint; } + const wxPoint& GetAuxOrigin() const { return m_designSettings.m_AuxOrigin; } + + /** + * Function SetGridOrigin + * sets the origin point of the grid. + */ + void SetGridOrigin( const wxPoint& aPoint ) { m_designSettings.m_GridOrigin = aPoint; } + const wxPoint& GetGridOrigin() const { return m_designSettings.m_GridOrigin; } + /** * Function ResetHighLight * Reset all high light data to the init state @@ -594,9 +607,6 @@ public: const PCB_PLOT_PARAMS& GetPlotOptions() const { return m_plotOptions; } void SetPlotOptions( const PCB_PLOT_PARAMS& aOptions ) { m_plotOptions = aOptions; } - const wxPoint& GetOriginAxisPosition() const { return m_originAxisPosition; } - void SetOriginAxisPosition( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; } - TITLE_BLOCK& GetTitleBlock() { return m_titles; } void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; } diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index accad0fd10..05b6ef9523 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -141,7 +141,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode ) } } - m_Collector->Collect( m_Pcb, scanList, GetScreen()->RefPos( true ), guide ); + m_Collector->Collect( m_Pcb, scanList, RefPos( true ), guide ); #if 0 // debugging: print out the collected items, showing their priority order too. @@ -161,7 +161,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode ) if( item->Type() != PCB_ZONE_T ) continue; - /* Found a TYPE ZONE */ + // Found a TYPE ZONE if( item->GetTimeStamp() == timestampzone ) // Remove it, redundant, zone already found { m_Collector->Remove( ii ); @@ -200,7 +200,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode ) { wxMenu itemMenu; - /* Give a title to the selection menu. This is also a cancel menu item */ + // Give a title to the selection menu. This is also a cancel menu item wxMenuItem * item_title = new wxMenuItem( &itemMenu, -1, _( "Selection Clarification" ) ); #ifdef __WINDOWS__ @@ -269,9 +269,9 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH snapToGrid = false; if( snapToGrid ) - pos = GetScreen()->GetNearestGridPosition( pos ); + pos = GetNearestGridPosition( pos ); - oldpos = GetScreen()->GetCrossHairPosition(); + oldpos = GetCrossHairPosition(); gridSize = GetScreen()->GetGridSize(); @@ -306,7 +306,7 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH } // Put cursor in new position, according to the zoom keys (if any). - GetScreen()->SetCrossHairPosition( pos, snapToGrid ); + SetCrossHairPosition( pos, snapToGrid ); /* Put cursor on grid or a pad centre if requested. If the tool DELETE is active the * cursor is left off grid this is better to reach items to delete off grid, @@ -326,7 +326,7 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH if( Magnetize( this, GetToolId(), igridsize, curs_pos, &pos ) ) { - GetScreen()->SetCrossHairPosition( pos, false ); + SetCrossHairPosition( pos, false ); } else { @@ -335,19 +335,19 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH if( !g_Drc_On || !g_CurrentTrackSegment || (BOARD_ITEM*)g_CurrentTrackSegment != this->GetCurItem() || !LocateIntrusion( m_Pcb->m_Track, g_CurrentTrackSegment, - GetScreen()->m_Active_Layer, GetScreen()->RefPos( true ) ) ) + GetScreen()->m_Active_Layer, RefPos( true ) ) ) { - GetScreen()->SetCrossHairPosition( curs_pos, snapToGrid ); + SetCrossHairPosition( curs_pos, snapToGrid ); } } - if( oldpos != GetScreen()->GetCrossHairPosition() ) + if( oldpos != GetCrossHairPosition() ) { - pos = GetScreen()->GetCrossHairPosition(); - GetScreen()->SetCrossHairPosition( oldpos, false ); + pos = GetCrossHairPosition(); + SetCrossHairPosition( oldpos, false ); m_canvas->CrossHairOff( aDC ); - GetScreen()->SetCrossHairPosition( pos, false ); + SetCrossHairPosition( pos, false ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) @@ -373,5 +373,5 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH OnHotKey( aDC, aHotKey, aPosition ); } - UpdateStatusBar(); /* Display new cursor coordinates */ + UpdateStatusBar(); // Display new cursor coordinates } diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index ced4db35dd..39e50e34a1 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -96,7 +96,7 @@ void RemoteCommand( const char* cmdline ) pos = pad->GetPosition(); } - if( netcode > 0 ) /* highlight the pad net*/ + if( netcode > 0 ) // highlight the pad net { pcb->HighLightON(); pcb->SetHighLightNet( netcode ); @@ -127,7 +127,7 @@ void RemoteCommand( const char* cmdline ) if( module ) // if found, center the module on screen, and redraw the screen. { - frame->GetScreen()->SetCrossHairPosition(pos); + frame->SetCrossHairPosition( pos ); frame->RedrawScreen( pos, false ); } } diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp index a467b328f1..f8eec0ad5b 100644 --- a/pcbnew/dialogs/dialog_SVG_print.cpp +++ b/pcbnew/dialogs/dialog_SVG_print.cpp @@ -317,7 +317,7 @@ bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName ) m_plotOpts.SetValueColor( color ); PAGE_INFO pageInfo = m_board->GetPageSettings(); - wxPoint axisorigin = m_board->GetOriginAxisPosition(); + wxPoint axisorigin = m_board->GetAuxOrigin(); if( PageIsBoardBoundarySize() ) { @@ -328,7 +328,7 @@ bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName ) m_board->SetPageSettings( currpageInfo ); m_plotOpts.SetUseAuxOrigin( true ); wxPoint origin = bbox.GetOrigin(); - m_board->SetOriginAxisPosition( origin ); + m_board->SetAuxOrigin( origin ); } LOCALE_IO toggle; @@ -344,7 +344,7 @@ bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName ) } delete plotter; - m_board->SetOriginAxisPosition( axisorigin ); + m_board->SetAuxOrigin( axisorigin ); m_board->SetPageSettings( pageInfo ); return true; diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index fa6fe3c351..5e0dbc7c13 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -85,7 +85,7 @@ DIALOG_MODULE_BOARD_EDITOR::~DIALOG_MODULE_BOARD_EDITOR() } -/* Creation of the panel properties of the module editor. */ +// Creation of the panel properties of the module editor. void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties() { PutValueInLocalUnits( *m_ModPositionX, m_CurrentModule->GetPosition().x ); @@ -244,7 +244,7 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties() m_LastSelected3DShapeIndex = -1; - /* Init 3D shape list */ + // Init 3D shape list S3D_MASTER* draw3D = m_CurrentModule->Models(); while( draw3D ) @@ -276,7 +276,7 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties() _( "Use this attribute for \"virtual\" components drawn on board\n" "(like a old ISA PC bus connector)" ) ); - /* Controls on right side of the dialog */ + // Controls on right side of the dialog switch( m_CurrentModule->GetAttributes() & 255 ) { case 0: @@ -601,7 +601,7 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event ) if( change_layer ) m_CurrentModule->Flip( m_CurrentModule->GetPosition() ); - /* Update 3D shape list */ + // Update 3D shape list int ii = m_3D_ShapeNameListBox->GetSelection(); if( ii >= 0 ) @@ -660,23 +660,23 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event ) void DIALOG_MODULE_BOARD_EDITOR::OnEditReference( wxCommandEvent& event ) { - wxPoint tmp = m_Parent->GetScreen()->GetCrossHairPosition(); + wxPoint tmp = m_Parent->GetCrossHairPosition(); - m_Parent->GetScreen()->SetCrossHairPosition( m_ReferenceCopy->GetTextPosition() ); + m_Parent->SetCrossHairPosition( m_ReferenceCopy->GetTextPosition() ); m_ReferenceCopy->SetParent( m_CurrentModule ); m_Parent->InstallTextModOptionsFrame( m_ReferenceCopy, NULL ); - m_Parent->GetScreen()->SetCrossHairPosition( tmp ); + m_Parent->SetCrossHairPosition( tmp ); m_ReferenceCtrl->SetValue( m_ReferenceCopy->GetText() ); } void DIALOG_MODULE_BOARD_EDITOR::OnEditValue( wxCommandEvent& event ) { - wxPoint tmp = m_Parent->GetScreen()->GetCrossHairPosition(); + wxPoint tmp = m_Parent->GetCrossHairPosition(); - m_Parent->GetScreen()->SetCrossHairPosition( m_ValueCopy->GetTextPosition() ); + m_Parent->SetCrossHairPosition( m_ValueCopy->GetTextPosition() ); m_ValueCopy->SetParent( m_CurrentModule ); m_Parent->InstallTextModOptionsFrame( m_ValueCopy, NULL ); - m_Parent->GetScreen()->SetCrossHairPosition( tmp ); + m_Parent->SetCrossHairPosition( tmp ); m_ValueCtrl->SetValue( m_ValueCopy->GetText() ); } diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index 56aeb185a6..1268a15f04 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -84,9 +84,7 @@ DIALOG_MODULE_MODULE_EDITOR::~DIALOG_MODULE_MODULE_EDITOR() } -/********************************************************/ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties() -/********************************************************/ { SetFocus(); @@ -213,8 +211,7 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties() } -/* Initialize 3D info displayed in dialog box from values in aStruct3DSource - */ +// Initialize 3D info displayed in dialog box from values in aStruct3DSource void DIALOG_MODULE_MODULE_EDITOR::Transfert3DValuesToDisplay( S3D_MASTER * aStruct3DSource ) { if( aStruct3DSource ) @@ -247,9 +244,8 @@ void DIALOG_MODULE_MODULE_EDITOR::TransfertDisplayTo3DValues( int aIndexSelectio struct3DDest->m_MatPosition = m_3D_Offset->GetValue(); } -/***********************************************************/ + void DIALOG_MODULE_MODULE_EDITOR::On3DShapeNameSelected(wxCommandEvent& event) -/***********************************************************/ { if( m_lastSelected3DShapeIndex >= 0 ) TransfertDisplayTo3DValues( m_lastSelected3DShapeIndex ); @@ -268,9 +264,7 @@ void DIALOG_MODULE_MODULE_EDITOR::On3DShapeNameSelected(wxCommandEvent& event) } -/***********************************************************/ void DIALOG_MODULE_MODULE_EDITOR::Remove3DShape(wxCommandEvent& event) -/***********************************************************/ { if( m_lastSelected3DShapeIndex >= 0 ) TransfertDisplayTo3DValues( m_lastSelected3DShapeIndex ); @@ -293,9 +287,7 @@ void DIALOG_MODULE_MODULE_EDITOR::Remove3DShape(wxCommandEvent& event) } -/*********************************************************************/ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DLib( wxCommandEvent& event ) -/*********************************************************************/ { wxString fullfilename, shortfilename; wxString fullpath; @@ -364,16 +356,13 @@ void DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DLib( wxCommandEvent& event ) } -/**********************************************************************/ void DIALOG_MODULE_MODULE_EDITOR::OnCancelClick( wxCommandEvent& event ) -/**********************************************************************/ { EndModal( -1 ); } -/******************************************************************************/ + void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event ) -/******************************************************************************/ { // First, test for invalid chars in module name wxString footprintName = m_FootprintNameCtrl->GetValue(); @@ -486,25 +475,22 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event ) } -/***********************************************************************/ void DIALOG_MODULE_MODULE_EDITOR::OnEditReference(wxCommandEvent& event) -/***********************************************************************/ { - wxPoint tmp = m_parent->GetScreen()->GetCrossHairPosition(); - m_parent->GetScreen()->SetCrossHairPosition( m_referenceCopy->GetTextPosition() ); + wxPoint tmp = m_parent->GetCrossHairPosition(); + m_parent->SetCrossHairPosition( m_referenceCopy->GetTextPosition() ); m_parent->InstallTextModOptionsFrame( m_referenceCopy, NULL ); - m_parent->GetScreen()->SetCrossHairPosition( tmp ); + m_parent->SetCrossHairPosition( tmp ); m_ReferenceCtrl->SetValue( m_referenceCopy->GetText() ); } -/***********************************************************/ + void DIALOG_MODULE_MODULE_EDITOR::OnEditValue(wxCommandEvent& event) -/***********************************************************/ { - wxPoint tmp = m_parent->GetScreen()->GetCrossHairPosition(); - m_parent->GetScreen()->SetCrossHairPosition( m_valueCopy->GetTextPosition() ); + wxPoint tmp = m_parent->GetCrossHairPosition(); + m_parent->SetCrossHairPosition( m_valueCopy->GetTextPosition() ); m_parent->InstallTextModOptionsFrame( m_valueCopy, NULL ); - m_parent->GetScreen()->SetCrossHairPosition( tmp ); + m_parent->SetCrossHairPosition( tmp ); m_ValueCtrl->SetValue( m_valueCopy->GetText() ); } diff --git a/pcbnew/dialogs/dialog_gendrill.cpp b/pcbnew/dialogs/dialog_gendrill.cpp index fe53f3b8b0..c8a4b81c2c 100644 --- a/pcbnew/dialogs/dialog_gendrill.cpp +++ b/pcbnew/dialogs/dialog_gendrill.cpp @@ -321,7 +321,7 @@ void DIALOG_GENDRILL::SetParams() if( m_Choice_Drill_Offset->GetSelection() == 0 ) m_FileDrillOffset = wxPoint( 0, 0 ); else - m_FileDrillOffset = m_parent->GetOriginAxisPosition(); + m_FileDrillOffset = m_parent->GetAuxOrigin(); if( m_UnitDrillIsInch ) m_Precision = precisionListForInches; diff --git a/pcbnew/dialogs/dialog_set_grid.cpp b/pcbnew/dialogs/dialog_set_grid.cpp index 36527c6df6..154088cd3a 100644 --- a/pcbnew/dialogs/dialog_set_grid.cpp +++ b/pcbnew/dialogs/dialog_set_grid.cpp @@ -201,14 +201,18 @@ void DIALOG_SET_GRID::OnOkClick( wxCommandEvent& event ) bool PCB_BASE_FRAME::InvokeDialogGrid() { + wxPoint grid_origin = GetGridOrigin(); + DIALOG_SET_GRID dlg( this, &m_UserGridUnit, g_UserUnit, &m_UserGridSize, - &GetScreen()->m_GridOrigin, &m_FastGrid1, &m_FastGrid2, + &grid_origin, &m_FastGrid1, &m_FastGrid2, m_gridSelectBox->GetStrings() ); int ret = dlg.ShowModal(); if( ret == wxID_OK ) { + SetGridOrigin( grid_origin ); + GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); // If the user grid is the current option, recall SetGrid() diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp index 391addb6f9..85de08fee1 100644 --- a/pcbnew/dimension.cpp +++ b/pcbnew/dimension.cpp @@ -240,7 +240,7 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC ) if( aDimension == NULL ) { status_dimension = 1; - pos = GetScreen()->GetCrossHairPosition(); + pos = GetCrossHairPosition(); aDimension = new DIMENSION( GetBoard() ); aDimension->SetFlags( IS_NEW ); @@ -302,7 +302,7 @@ static void BuildDimension( EDA_DRAW_PANEL* aPanel, wxDC* aDC, { PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen(); DIMENSION* Dimension = (DIMENSION*) screen->GetCurItem(); - wxPoint pos = screen->GetCrossHairPosition(); + wxPoint pos = aPanel->GetParent()->GetCrossHairPosition(); if( Dimension == NULL ) return; @@ -386,7 +386,7 @@ void PCB_EDIT_FRAME::BeginMoveDimensionText( DIMENSION* aItem, wxDC* DC ) aItem->SetFlags( IS_MOVED ); SetMsgPanel( aItem ); - GetScreen()->SetCrossHairPosition( aItem->Text().GetTextPosition() ); + SetCrossHairPosition( aItem->Text().GetTextPosition() ); m_canvas->MoveCursorToCrossHair(); m_canvas->SetMouseCapture( MoveDimensionText, AbortMoveDimensionText ); @@ -407,7 +407,7 @@ static void MoveDimensionText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& if( aErase ) dimension->Draw( aPanel, aDC, GR_XOR ); - dimension->Text().SetTextPosition( aPanel->GetScreen()->GetCrossHairPosition() ); + dimension->Text().SetTextPosition( aPanel->GetParent()->GetCrossHairPosition() ); dimension->Draw( aPanel, aDC, GR_XOR ); } diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp index 1fdaf78378..870e9e710a 100644 --- a/pcbnew/edgemod.cpp +++ b/pcbnew/edgemod.cpp @@ -66,7 +66,7 @@ void FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod( EDGE_MODULE* aEdge, wxDC* DC ) aEdge->Draw( m_canvas, DC, GR_XOR ); aEdge->SetFlags( IS_MOVED ); MoveVector.x = MoveVector.y = 0; - CursorInitialPosition = GetScreen()->GetCrossHairPosition(); + CursorInitialPosition = GetCrossHairPosition(); m_canvas->SetMouseCapture( ShowCurrentOutlineWhileMoving, Abort_Move_ModuleOutline ); SetCurItem( aEdge ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); @@ -115,7 +115,7 @@ static void ShowCurrentOutlineWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC, edge->Draw( aPanel, aDC, GR_XOR, MoveVector ); } - MoveVector = -(screen->GetCrossHairPosition() - CursorInitialPosition); + MoveVector = -(aPanel->GetParent()->GetCrossHairPosition() - CursorInitialPosition); edge->Draw( aPanel, aDC, GR_XOR, MoveVector ); @@ -142,7 +142,7 @@ static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& edge->Draw( aPanel, aDC, GR_XOR ); } - edge->SetEnd( screen->GetCrossHairPosition() ); + edge->SetEnd( aPanel->GetParent()->GetCrossHairPosition() ); // Update relative coordinate. edge->SetEnd0( edge->GetEnd() - module->GetPosition() ); @@ -346,7 +346,7 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* aEdge, aEdge->SetLayer( SILKSCREEN_N_FRONT ); // Initialize the starting point of the new segment or arc - aEdge->SetStart( GetScreen()->GetCrossHairPosition() ); + aEdge->SetStart( GetCrossHairPosition() ); // Initialize the ending point of the new segment or arc aEdge->SetEnd( aEdge->GetStart() ); @@ -383,7 +383,7 @@ EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* aEdge, aEdge->SetFlags( IS_NEW ); aEdge->SetWidth( GetDesignSettings().m_ModuleSegmentWidth ); - aEdge->SetStart( GetScreen()->GetCrossHairPosition() ); + aEdge->SetStart( GetCrossHairPosition() ); aEdge->SetEnd( aEdge->GetStart() ); // Update relative coordinate. diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 0a2fb5434f..93d380fee9 100755 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -56,7 +56,7 @@ #include -/* Handles the selection of command events. */ +// Handles the selection of command events. void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) { int id = event.GetId(); @@ -153,7 +153,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) m_canvas->EndMouseCapture(); } - /* Should not be executed, just in case */ + // Should not be executed, just in case if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE ) { GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE ); @@ -544,7 +544,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) { m_canvas->MoveCursorToCrossHair(); ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem(); - wxPoint pos = GetScreen()->GetCrossHairPosition(); + wxPoint pos = GetCrossHairPosition(); /* add corner between zone_cont->m_CornerSelection * and zone_cont->m_CornerSelection+1 @@ -644,12 +644,12 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) } SendMessageToEESCHEMA( module ); - GetScreen()->SetCrossHairPosition( module->GetPosition() ); + SetCrossHairPosition( module->GetPosition() ); m_canvas->MoveCursorToCrossHair(); StartMoveModule( module, &dc, id == ID_POPUP_PCB_DRAG_MODULE_REQUEST ); break; - case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: /* get module by name and move it */ + case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: // get module by name and move it SetCurItem( GetModuleByName() ); module = (MODULE*) GetCurItem(); @@ -658,9 +658,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( module->IsLocked() ) { - wxString msg; - msg.Printf( _( "Footprint %s found, but it is locked" ), - module->GetReference().GetData() ); + wxString msg = wxString::Format( + _( "Footprint %s found, but it is locked" ), + module->GetReference().GetData() ); DisplayInfoMessage( this, msg ); break; } @@ -719,7 +719,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; } - /* This is a simple rotation, no other editing in progress */ + // This is a simple rotation, no other editing in progress if( !GetCurItem()->IsMoving() ) SaveCopyInUndoList( GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->GetPosition() ); @@ -747,7 +747,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; } - /* This is a simple rotation, no other editing in progress */ + // This is a simple rotation, no other editing in progress if( !GetCurItem()->IsMoving() ) SaveCopyInUndoList( GetCurItem(), UR_ROTATED_CLOCKWISE, ((MODULE*)GetCurItem())->GetPosition() ); @@ -776,7 +776,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; } - /* This is a simple flip, no other editing in progress */ + // This is a simple flip, no other editing in progress if( !GetCurItem()->IsMoving() ) SaveCopyInUndoList( GetCurItem(), UR_FLIPPED, ((MODULE*)GetCurItem())->GetPosition() ); @@ -1108,14 +1108,18 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) m_canvas->MoveCursorToCrossHair(); { TRACK* track = (TRACK*) GetScreen()->GetCurItem(); - wxPoint pos = GetScreen()->GetCrossHairPosition(); + wxPoint pos = GetCrossHairPosition(); + track->Draw( m_canvas, &dc, GR_XOR ); PICKED_ITEMS_LIST itemsListPicker; + TRACK* newtrack = GetBoard()->CreateLockPoint( pos, track, &itemsListPicker ); + SaveCopyInUndoList( itemsListPicker, UR_UNSPECIFIED ); track->Draw( m_canvas, &dc, GR_XOR ); newtrack->Draw( m_canvas, &dc, GR_XOR ); - /* compute the new ratsnest, because connectivity could change */ + + // compute the new ratsnest, because connectivity could change TestNetConnection( &dc, track->GetNet() ); } break; diff --git a/pcbnew/edit_pcb_text.cpp b/pcbnew/edit_pcb_text.cpp index c7a62aaa01..7c518322e4 100644 --- a/pcbnew/edit_pcb_text.cpp +++ b/pcbnew/edit_pcb_text.cpp @@ -147,7 +147,7 @@ void PCB_EDIT_FRAME::StartMoveTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC, bool aE m_canvas->Refresh(); #endif - GetScreen()->SetCrossHairPosition( aTextePcb->GetTextPosition() ); + SetCrossHairPosition( aTextePcb->GetTextPosition() ); m_canvas->MoveCursorToCrossHair(); m_canvas->SetMouseCapture( Move_Texte_Pcb, Abort_Edit_Pcb_Text ); @@ -156,7 +156,7 @@ void PCB_EDIT_FRAME::StartMoveTextePcb( TEXTE_PCB* aTextePcb, wxDC* aDC, bool aE } -/* Move PCB text following the cursor. */ +// Move PCB text following the cursor. static void Move_Texte_Pcb( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { @@ -168,7 +168,7 @@ static void Move_Texte_Pcb( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aP if( aErase ) TextePcb->Draw( aPanel, aDC, GR_XOR ); - TextePcb->SetTextPosition( aPanel->GetScreen()->GetCrossHairPosition() ); + TextePcb->SetTextPosition( aPanel->GetParent()->GetCrossHairPosition() ); TextePcb->Draw( aPanel, aDC, GR_XOR ); } @@ -214,7 +214,7 @@ TEXTE_PCB* PCB_EDIT_FRAME::CreateTextePcb( wxDC* aDC, TEXTE_PCB* aText ) textePcb->SetMirrored( true ); textePcb->SetSize( GetBoard()->GetDesignSettings().m_PcbTextSize ); - textePcb->SetTextPosition( GetScreen()->GetCrossHairPosition() ); + textePcb->SetTextPosition( GetCrossHairPosition() ); textePcb->SetThickness( GetBoard()->GetDesignSettings().m_PcbTextWidth ); InstallTextPCBOptionsFrame( textePcb, aDC ); diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp index acc881c687..a85a0bf26e 100644 --- a/pcbnew/editedge.cpp +++ b/pcbnew/editedge.cpp @@ -43,7 +43,7 @@ #include -static void Abort_EditEdge( EDA_DRAW_PANEL* Panel, wxDC* DC ); +static void Abort_EditEdge( EDA_DRAW_PANEL* aPanel, wxDC* DC ); static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ); static void Move_Segment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ); @@ -61,7 +61,7 @@ void PCB_EDIT_FRAME::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC ) drawitem->Draw( m_canvas, DC, GR_XOR ); drawitem->SetFlags( IS_MOVED ); - s_InitialPosition = s_LastPosition = GetScreen()->GetCrossHairPosition(); + s_InitialPosition = s_LastPosition = GetCrossHairPosition(); SetMsgPanel( drawitem ); m_canvas->SetMouseCapture( Move_Segment, Abort_EditEdge ); SetCurItem( drawitem ); @@ -100,12 +100,12 @@ static void Move_Segment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos segment->Draw( aPanel, aDC, GR_XOR ); wxPoint delta; - delta = aPanel->GetScreen()->GetCrossHairPosition() - s_LastPosition; + delta = aPanel->GetParent()->GetCrossHairPosition() - s_LastPosition; segment->SetStart( segment->GetStart() + delta ); segment->SetEnd( segment->GetEnd() + delta ); - s_LastPosition = aPanel->GetScreen()->GetCrossHairPosition(); + s_LastPosition = aPanel->GetParent()->GetCrossHairPosition(); segment->Draw( aPanel, aDC, GR_XOR ); } @@ -153,17 +153,17 @@ void PCB_EDIT_FRAME::Delete_Drawings_All_Layer( LAYER_NUM aLayer ) return; } - wxString msg; - msg.Printf( _( "Delete everything on layer %s?" ), - GetChars( GetBoard()->GetLayerName( aLayer ) ) ); + wxString msg = wxString::Format( + _( "Delete everything on layer %s?" ), + GetChars( GetBoard()->GetLayerName( aLayer ) ) ); if( !IsOK( this, msg ) ) return; - PICKED_ITEMS_LIST pickList; - ITEM_PICKER picker(NULL, UR_DELETED); + PICKED_ITEMS_LIST pickList; + ITEM_PICKER picker( NULL, UR_DELETED ); + BOARD_ITEM* PtNext; - BOARD_ITEM* PtNext; for( BOARD_ITEM* item = GetBoard()->m_Drawings; item; item = PtNext ) { PtNext = item->Next(); @@ -202,38 +202,38 @@ void PCB_EDIT_FRAME::Delete_Drawings_All_Layer( LAYER_NUM aLayer ) } -static void Abort_EditEdge( EDA_DRAW_PANEL* Panel, wxDC* DC ) +static void Abort_EditEdge( EDA_DRAW_PANEL* aPanel, wxDC* DC ) { - DRAWSEGMENT* Segment = (DRAWSEGMENT*) Panel->GetScreen()->GetCurItem(); + DRAWSEGMENT* Segment = (DRAWSEGMENT*) aPanel->GetScreen()->GetCurItem(); if( Segment == NULL ) { - Panel->SetMouseCapture( NULL, NULL ); + aPanel->SetMouseCapture( NULL, NULL ); return; } if( Segment->IsNew() ) { - Panel->CallMouseCapture( DC, wxDefaultPosition, false ); + aPanel->CallMouseCapture( DC, wxDefaultPosition, false ); Segment ->DeleteStructure(); Segment = NULL; } else { - wxPoint pos = Panel->GetScreen()->GetCrossHairPosition(); - Panel->GetScreen()->SetCrossHairPosition( s_InitialPosition ); - Panel->CallMouseCapture( DC, wxDefaultPosition, true ); - Panel->GetScreen()->SetCrossHairPosition( pos ); + wxPoint pos = aPanel->GetParent()->GetCrossHairPosition(); + aPanel->GetParent()->SetCrossHairPosition( s_InitialPosition ); + aPanel->CallMouseCapture( DC, wxDefaultPosition, true ); + aPanel->GetParent()->SetCrossHairPosition( pos ); Segment->ClearFlags(); - Segment->Draw( Panel, DC, GR_OR ); + Segment->Draw( aPanel, DC, GR_OR ); } #ifdef USE_WX_OVERLAY - Panel->Refresh(); + aPanel->Refresh(); #endif - - Panel->SetMouseCapture( NULL, NULL ); - ( (PCB_EDIT_FRAME*) Panel->GetParent() )->SetCurItem( NULL ); + + aPanel->SetMouseCapture( NULL, NULL ); + ( (PCB_EDIT_FRAME*) aPanel->GetParent() )->SetCurItem( NULL ); } @@ -259,8 +259,8 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T s Segment->SetWidth( s_large ); Segment->SetShape( shape ); Segment->SetAngle( 900 ); - Segment->SetStart( GetScreen()->GetCrossHairPosition() ); - Segment->SetEnd( GetScreen()->GetCrossHairPosition() ); + Segment->SetStart( GetCrossHairPosition() ); + Segment->SetEnd( GetCrossHairPosition() ); m_canvas->SetMouseCapture( DrawSegment, Abort_EditEdge ); } else /* The ending point ccordinate Segment->m_End was updated by he function @@ -350,14 +350,14 @@ static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi { wxPoint pt; - CalculateSegmentEndPoint( aPanel->GetScreen()->GetCrossHairPosition(), + CalculateSegmentEndPoint( aPanel->GetParent()->GetCrossHairPosition(), Segment->GetStart().x, Segment->GetStart().y, &pt.x, &pt.y ); Segment->SetEnd( pt ); } else // here the angle is arbitrary { - Segment->SetEnd( aPanel->GetScreen()->GetCrossHairPosition() ); + Segment->SetEnd( aPanel->GetParent()->GetCrossHairPosition() ); } Segment->Draw( aPanel, aDC, GR_XOR ); diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index ab538b6a9c..b3ea13790d 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -101,7 +101,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) TRACK* TrackOnStartPoint = NULL; LAYER_MSK layerMask = GetLayerMask( GetScreen()->m_Active_Layer ); BOARD_CONNECTED_ITEM* LockPoint; - wxPoint pos = GetScreen()->GetCrossHairPosition(); + wxPoint pos = GetCrossHairPosition(); if( aTrack == NULL ) // Starting a new track segment { @@ -595,17 +595,17 @@ TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack, LAYER_NUM aLayer, const */ static void PushTrack( EDA_DRAW_PANEL* panel ) { - PCB_SCREEN* screen = ( (PCB_BASE_FRAME*) (panel->GetParent()) )->GetScreen(); - BOARD* pcb = ( (PCB_BASE_FRAME*) (panel->GetParent()) )->GetBoard(); - wxPoint cursor = screen->GetCrossHairPosition(); - wxPoint cv, vec, n; - TRACK* track = g_CurrentTrackSegment; - TRACK* other; - double det; - int dist; - double f; + PCB_SCREEN* screen = (PCB_SCREEN*) panel->GetParent()->GetScreen(); + BOARD* pcb = ( (PCB_BASE_FRAME*) (panel->GetParent()) )->GetBoard(); + wxPoint cursor = panel->GetParent()->GetCrossHairPosition(); + wxPoint cv, vec, n; + TRACK* track = g_CurrentTrackSegment; + TRACK* other; + double det; + int dist; + double f; - other = LocateIntrusion( pcb->m_Track, track, screen->m_Active_Layer, screen->RefPos( true ) ); + other = LocateIntrusion( pcb->m_Track, track, screen->m_Active_Layer, panel->GetParent()->RefPos( true ) ); // are we currently pointing into a conflicting trace ? if( !other ) @@ -735,7 +735,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo { if( g_TwoSegmentTrackBuild ) { - g_CurrentTrackSegment->SetEnd( screen->GetCrossHairPosition() ); + g_CurrentTrackSegment->SetEnd( frame->GetCrossHairPosition() ); if( g_Drc_On ) PushTrack( aPanel ); @@ -750,7 +750,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo * horizontal, vertical or 45 degrees. */ wxPoint hp = g_CurrentTrackSegment->GetEnd(); - CalculateSegmentEndPoint( screen->GetCrossHairPosition(), + CalculateSegmentEndPoint( frame->GetCrossHairPosition(), g_CurrentTrackSegment->GetStart().x, g_CurrentTrackSegment->GetStart().y, &hp.x, @@ -760,7 +760,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo } else // Here the angle is arbitrary { - g_CurrentTrackSegment->SetEnd( screen->GetCrossHairPosition() ); + g_CurrentTrackSegment->SetEnd( frame->GetCrossHairPosition() ); } // Redraw the new track diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp index 01869ae06f..d180cd00cd 100644 --- a/pcbnew/edtxtmod.cpp +++ b/pcbnew/edtxtmod.cpp @@ -68,7 +68,7 @@ TEXTE_MODULE* PCB_BASE_FRAME::CreateTextModule( MODULE* Module, wxDC* DC ) Text = new TEXTE_MODULE( Module ); - /* Add the new text object to the beginning of the draw item list. */ + // Add the new text object to the beginning of the draw item list. if( Module ) Module->GraphicalItems().PushFront( Text ); @@ -80,7 +80,7 @@ TEXTE_MODULE* PCB_BASE_FRAME::CreateTextModule( MODULE* Module, wxDC* DC ) std::min( GetDesignSettings().m_ModuleTextSize.x, GetDesignSettings().m_ModuleTextSize.y ), true ); Text->SetSize( GetDesignSettings().m_ModuleTextSize ); Text->SetThickness( GetDesignSettings().m_ModuleTextWidth ); - Text->SetTextPosition( GetScreen()->GetCrossHairPosition() ); + Text->SetTextPosition( GetCrossHairPosition() ); Text->SetLocalCoord(); InstallTextModOptionsFrame( Text, NULL ); @@ -175,7 +175,7 @@ static void AbortMoveTextModule( EDA_DRAW_PANEL* Panel, wxDC* DC ) if( Text->IsMoving() ) Text->SetOrientation( TextInitialOrientation ); - /* Redraw the text */ + // Redraw the text Panel->RefreshDrawingRect( Text->GetBoundingBox() ); // leave it at (0,0) so we can use it Rotate when not moving. @@ -208,7 +208,7 @@ void PCB_BASE_FRAME::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC ) TextInitialOrientation = Text->GetOrientation(); // Center cursor on initial position of text - GetScreen()->SetCrossHairPosition( TextInitialPosition ); + SetCrossHairPosition( TextInitialPosition ); m_canvas->MoveCursorToCrossHair(); SetMsgPanel( Text ); @@ -227,7 +227,7 @@ void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) m_canvas->RefreshDrawingRect( Text->GetBoundingBox() ); Text->DrawUmbilical( m_canvas, DC, GR_XOR, -MoveVector ); - /* Update the coordinates for anchor. */ + // Update the coordinates for anchor. MODULE* Module = (MODULE*) Text->GetParent(); if( Module ) @@ -244,7 +244,7 @@ void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) Text->SetOrientation( tmp ); // Set the new position for text. - Text->SetTextPosition( GetScreen()->GetCrossHairPosition() ); + Text->SetTextPosition( GetCrossHairPosition() ); wxPoint textRelPos = Text->GetTextPosition() - Module->GetPosition(); RotatePoint( &textRelPos, -Module->GetOrientation() ); Text->SetPos0( textRelPos ); @@ -253,12 +253,12 @@ void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC ) Module->SetLastEditTime(); OnModify(); - /* Redraw text. */ + // Redraw text. m_canvas->RefreshDrawingRect( Text->GetBoundingBox() ); } else { - Text->SetTextPosition( GetScreen()->GetCrossHairPosition() ); + Text->SetTextPosition( GetCrossHairPosition() ); } } @@ -285,7 +285,7 @@ static void Show_MoveTexte_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo Text->Draw( aPanel, aDC, GR_XOR, MoveVector ); } - MoveVector = TextInitialPosition - screen->GetCrossHairPosition(); + MoveVector = TextInitialPosition - aPanel->GetParent()->GetCrossHairPosition(); // Draw umbilical if text moved if( MoveVector.x || MoveVector.y ) diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp index fbe33bcab0..59cecd1869 100644 --- a/pcbnew/export_gencad.cpp +++ b/pcbnew/export_gencad.cpp @@ -146,8 +146,8 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent ) GetBoard()->ComputeBoundingBox(); // Save the auxiliary origin for the rest of the module - GencadOffsetX = GetOriginAxisPosition().x; - GencadOffsetY = GetOriginAxisPosition().y; + GencadOffsetX = GetAuxOrigin().x; + GencadOffsetY = GetAuxOrigin().y; // No idea on *why* this should be needed... maybe to fix net names? Compile_Ratsnest( NULL, true ); @@ -708,8 +708,8 @@ static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame ) fputs( "UNITS INCH\n", aFile ); msg.Printf( wxT( "ORIGIN %g %g\n" ), - MapXTo( aFrame->GetOriginAxisPosition().x ), - MapYTo( aFrame->GetOriginAxisPosition().y ) ); + MapXTo( aFrame->GetAuxOrigin().x ), + MapYTo( aFrame->GetAuxOrigin().y ) ); fputs( TO_UTF8( msg ), aFile ); fputs( "INTERTRACK 0\n", aFile ); diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index 73fe27b054..f5e10d9b50 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -53,16 +53,16 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME ) -/* Window events */ +// Window events EVT_CLOSE( FOOTPRINT_WIZARD_FRAME::OnCloseWindow ) EVT_SIZE( FOOTPRINT_WIZARD_FRAME::OnSize ) EVT_ACTIVATE( FOOTPRINT_WIZARD_FRAME::OnActivate ) -/* Sash drag events */ +// Sash drag events EVT_SASH_DRAGGED( ID_FOOTPRINT_WIZARD_PAGES, FOOTPRINT_WIZARD_FRAME::OnSashDrag ) EVT_SASH_DRAGGED( ID_FOOTPRINT_WIZARD_PARAMETERS, FOOTPRINT_WIZARD_FRAME::OnSashDrag ) -/* Toolbar events */ +// Toolbar events EVT_TOOL( ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard ) @@ -78,7 +78,7 @@ EVT_TOOL( ID_FOOTPRINT_WIZARD_DONE, EVT_TOOL( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW, FOOTPRINT_WIZARD_FRAME::Show3D_Frame ) -/* listbox events */ +// listbox events EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList ) EVT_GRID_CMD_CELL_CHANGE( ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ParametersUpdated ) @@ -374,7 +374,7 @@ void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv ) */ void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event ) { - GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); + GetScreen()->m_O_Curseur = GetCrossHairPosition(); UpdateStatusBar(); } @@ -587,8 +587,8 @@ void FOOTPRINT_WIZARD_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition cmd.SetEventObject( this ); - pos = screen->GetNearestGridPosition( pos ); - oldpos = screen->GetCrossHairPosition(); + pos = GetNearestGridPosition( pos ); + oldpos = GetCrossHairPosition(); gridSize = screen->GetGridSize(); switch( aHotKey ) @@ -619,42 +619,42 @@ void FOOTPRINT_WIZARD_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition break; case ' ': - screen->m_O_Curseur = screen->GetCrossHairPosition(); + screen->m_O_Curseur = GetCrossHairPosition(); break; - case WXK_NUMPAD8: /* cursor moved up */ + case WXK_NUMPAD8: // cursor moved up case WXK_UP: pos.y -= KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; - case WXK_NUMPAD2: /* cursor moved down */ + case WXK_NUMPAD2: // cursor moved down case WXK_DOWN: pos.y += KiROUND( gridSize.y ); m_canvas->MoveCursor( pos ); break; - case WXK_NUMPAD4: /* cursor moved left */ + case WXK_NUMPAD4: // cursor moved left case WXK_LEFT: pos.x -= KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; - case WXK_NUMPAD6: /* cursor moved right */ + case WXK_NUMPAD6: // cursor moved right case WXK_RIGHT: pos.x += KiROUND( gridSize.x ); m_canvas->MoveCursor( pos ); break; } - screen->SetCrossHairPosition( pos ); + SetCrossHairPosition( pos ); - if( oldpos != screen->GetCrossHairPosition() ) + if( oldpos != GetCrossHairPosition() ) { - pos = screen->GetCrossHairPosition(); - screen->SetCrossHairPosition( oldpos ); + pos = GetCrossHairPosition(); + SetCrossHairPosition( oldpos ); m_canvas->CrossHairOff( aDC ); - screen->SetCrossHairPosition( pos ); + SetCrossHairPosition( pos ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) @@ -663,7 +663,7 @@ void FOOTPRINT_WIZARD_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition } } - UpdateStatusBar(); /* Display new cursor coordinates */ + UpdateStatusBar(); // Display new cursor coordinates } diff --git a/pcbnew/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp index f78316ef81..32503e63a0 100644 --- a/pcbnew/gen_modules_placefile.cpp +++ b/pcbnew/gen_modules_placefile.cpp @@ -359,7 +359,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName, MODULE* module; char line[1024]; - File_Place_Offset = GetOriginAxisPosition(); + File_Place_Offset = GetAuxOrigin(); // Calculating the number of useful modules (CMS attribute, not VIRTUAL) int moduleCount = 0; diff --git a/pcbnew/highlight.cpp b/pcbnew/highlight.cpp index ef7d7cd599..d288a4f287 100644 --- a/pcbnew/highlight.cpp +++ b/pcbnew/highlight.cpp @@ -133,7 +133,7 @@ int PCB_EDIT_FRAME::SelectHighLight( wxDC* DC ) // optionally, modify the "guide" here as needed using its member functions m_Collector->Collect( GetBoard(), GENERAL_COLLECTOR::PadsTracksOrZones, - GetScreen()->RefPos( true ), guide ); + RefPos( true ), guide ); BOARD_ITEM* item = (*m_Collector)[0]; diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index 5487510c30..8186af3d14 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -24,7 +24,7 @@ * This can be useful if the new function cannot be executed while an item is currently * being edited ( For example, one cannot start a new wire when a component is moving.) * - * Note: If an hotkey is a special key, be sure the corresponding wxWidget keycode (WXK_XXXX) + * Note: If a hotkey is a special key, be sure the corresponding wxWidget keycode (WXK_XXXX) * is handled in the hotkey_name_descr s_Hotkey_Name_List list (see hotkeys_basic.cpp) * and see this list for some ascii keys (space ...) */ @@ -60,10 +60,8 @@ static EDA_HOTKEY HkFindItem( wxT( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL static EDA_HOTKEY HkBackspace( wxT( "Delete track segment" ), HK_BACK_SPACE, WXK_BACK ); static EDA_HOTKEY HkAddNewTrack( wxT( "Add new track" ), HK_ADD_NEW_TRACK, 'X' ); static EDA_HOTKEY HkAddVia( wxT( "Add Via" ), HK_ADD_VIA, 'V' ); -static EDA_HOTKEY HkSwitchTrackPosture( wxT( "Switch Track Posture" ), - HK_SWITCH_TRACK_POSTURE, '/' ); -static EDA_HOTKEY HkDragTrackKeepSlope( wxT( "Drag track keep slope" ), - HK_DRAG_TRACK_KEEP_SLOPE, 'D' ); +static EDA_HOTKEY HkSwitchTrackPosture( wxT( "Switch Track Posture" ), HK_SWITCH_TRACK_POSTURE, '/' ); +static EDA_HOTKEY HkDragTrackKeepSlope( wxT( "Drag track keep slope" ), HK_DRAG_TRACK_KEEP_SLOPE, 'D' ); static EDA_HOTKEY HkPlaceItem( wxT( "Place Item" ), HK_PLACE_ITEM, 'P' ); static EDA_HOTKEY HkAddMicroVia( wxT( "Add MicroVia" ), HK_ADD_MICROVIA, 'V' + GR_KB_CTRL ); static EDA_HOTKEY HkEndTrack( wxT( "End Track" ), HK_END_TRACK, WXK_END ); @@ -73,15 +71,14 @@ static EDA_HOTKEY HkRotateItem( wxT( "Rotate Item" ), HK_ROTATE_ITEM, 'R' ); static EDA_HOTKEY HkMoveItem( wxT( "Move Item" ), HK_MOVE_ITEM, 'M' ); static EDA_HOTKEY HkCopyItem( wxT( "Copy Item" ), HK_COPY_ITEM, 'C' ); static EDA_HOTKEY HkDragFootprint( wxT( "Drag Footprint" ), HK_DRAG_ITEM, 'G' ); -static EDA_HOTKEY HkGetAndMoveFootprint( wxT( "Get and Move Footprint" ), - HK_GET_AND_MOVE_FOOTPRINT, 'T' ); -static EDA_HOTKEY HkLock_Unlock_Footprint( wxT( "Lock/Unlock Footprint" ), - HK_LOCK_UNLOCK_FOOTPRINT, 'L' ); +static EDA_HOTKEY HkGetAndMoveFootprint( wxT( "Get and Move Footprint" ), HK_GET_AND_MOVE_FOOTPRINT, 'T' ); +static EDA_HOTKEY HkLock_Unlock_Footprint( wxT( "Lock/Unlock Footprint" ), HK_LOCK_UNLOCK_FOOTPRINT, 'L' ); static EDA_HOTKEY HkDelete( wxT( "Delete Track or Footprint" ), HK_DELETE, WXK_DELETE ); -static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), - HK_RESET_LOCAL_COORD, ' ' ); -static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"), - HK_SWITCH_HIGHCONTRAST_MODE,'H'); +static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), HK_RESET_LOCAL_COORD, ' ' ); +static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"), HK_SWITCH_HIGHCONTRAST_MODE,'H'); + +static EDA_HOTKEY HkSetGridOrigin( wxT("Set Grid Origin"), HK_SET_GRID_ORIGIN, 'S' ); + /* Fit on Screen */ #if !defined( __WXMAC__ ) static EDA_HOTKEY HkZoomAuto( wxT( "Zoom Auto" ), HK_ZOOM_AUTO, WXK_HOME ); @@ -198,7 +195,7 @@ EDA_HOTKEY* common_Hotkey_List[] = { &HkHelp, &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, &HkZoomAuto, - &HkSwitchUnits, &HkResetLocalCoord, + &HkSwitchUnits, &HkResetLocalCoord, &HkSetGridOrigin, &HkUndo, &HkRedo, NULL }; diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index 0a155643f4..2d46178a47 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -30,7 +30,7 @@ void PCB_EDIT_FRAME::RecordMacros(wxDC* aDC, int aNumber) if( m_RecordingMacros < 0 ) { m_RecordingMacros = aNumber; - m_Macros[aNumber].m_StartPosition = GetScreen()->GetCrossHairPosition( false ); + m_Macros[aNumber].m_StartPosition = GetCrossHairPosition( false ); m_Macros[aNumber].m_Record.clear(); msg.Printf( _( "Recording macro %d" ), aNumber ); @@ -48,7 +48,6 @@ void PCB_EDIT_FRAME::RecordMacros(wxDC* aDC, int aNumber) void PCB_EDIT_FRAME::CallMacros( wxDC* aDC, const wxPoint& aPosition, int aNumber ) { - PCB_SCREEN* screen = GetScreen(); wxPoint tPosition; wxString msg; @@ -59,19 +58,19 @@ void PCB_EDIT_FRAME::CallMacros( wxDC* aDC, const wxPoint& aPosition, int aNumbe wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); - tPosition = screen->GetNearestGridPosition( aPosition ); + tPosition = GetNearestGridPosition( aPosition ); m_canvas->CrossHairOff( aDC ); - screen->SetMousePosition( tPosition ); + SetMousePosition( tPosition ); GeneralControl( aDC, tPosition ); for( std::list::iterator i = m_Macros[aNumber].m_Record.begin(); i != m_Macros[aNumber].m_Record.end(); i++ ) { - wxPoint tmpPos = screen->GetNearestGridPosition( tPosition + i->m_Position ); + wxPoint tmpPos = GetNearestGridPosition( tPosition + i->m_Position ); - screen->SetMousePosition( tmpPos ); + SetMousePosition( tmpPos ); GeneralControl( aDC, tmpPos, i->m_HotkeyCode ); } @@ -117,8 +116,8 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit MACROS_RECORD macros_record; macros_record.m_HotkeyCode = aHotkeyCode; macros_record.m_Idcommand = HK_Descr->m_Idcommand; - macros_record.m_Position = screen->GetNearestGridPosition( aPosition ) - - m_Macros[m_RecordingMacros].m_StartPosition; + macros_record.m_Position = GetNearestGridPosition( aPosition ) - + m_Macros[m_RecordingMacros].m_StartPosition; m_Macros[m_RecordingMacros].m_Record.push_back( macros_record ); wxString msg; msg.Printf( _( "Add key [%c] in macro %d" ), aHotkeyCode, m_RecordingMacros ); @@ -162,8 +161,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit case HK_CALL_MACROS_7: case HK_CALL_MACROS_8: case HK_CALL_MACROS_9: - CallMacros( aDC, screen->GetCrossHairPosition( false ), - hk_id - HK_CALL_MACROS_0 ); + CallMacros( aDC, GetCrossHairPosition( false ), hk_id - HK_CALL_MACROS_0 ); break; case HK_SWITCH_TRACK_WIDTH_TO_NEXT: @@ -222,7 +220,6 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit cmd.SetEventType( wxEVT_COMMAND_COMBOBOX_SELECTED ); OnSelectGrid( cmd ); } - break; case HK_SWITCH_GRID_TO_PREVIOUS: @@ -344,8 +341,14 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit break; - case HK_RESET_LOCAL_COORD: /*Reset the relative coord */ - GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); + case HK_RESET_LOCAL_COORD: // Set the relative coord + GetScreen()->m_O_Curseur = GetCrossHairPosition(); + break; + + case HK_SET_GRID_ORIGIN: + SetGridOrigin( GetCrossHairPosition() ); + OnModify(); // because grid origin is saved in board, show as modified + m_canvas->Refresh(); break; case HK_SWITCH_UNITS: @@ -498,7 +501,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit // get any module, locked or not locked and toggle its locked status if( !itemCurrentlyEdited ) { - wxPoint pos = screen->RefPos( true ); + wxPoint pos = RefPos( true ); module = GetBoard()->GetFootprint( pos, screen->m_Active_Layer, true ); } else if( GetCurItem()->Type() == PCB_MODULE_T ) @@ -513,7 +516,6 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit OnModify(); SetMsgPanel( module ); } - break; case HK_DRAG_ITEM: // Start drag module or track segment @@ -586,7 +588,7 @@ bool PCB_EDIT_FRAME::OnHotkeyDeleteItem( wxDC* aDC ) case ID_PCB_MODULE_BUTT: if( ItemFree ) { - wxPoint pos = GetScreen()->RefPos( false ); + wxPoint pos = RefPos( false ); MODULE* module = GetBoard()->GetFootprint( pos, UNDEFINED_LAYER, false ); if( module == NULL ) diff --git a/pcbnew/hotkeys_module_editor.cpp b/pcbnew/hotkeys_module_editor.cpp index cba541ea59..978f8a3a3c 100644 --- a/pcbnew/hotkeys_module_editor.cpp +++ b/pcbnew/hotkeys_module_editor.cpp @@ -51,12 +51,17 @@ void FOOTPRINT_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPos return; break; - case HK_HELP: // Display Current hotkey list + case HK_HELP: // Display Current hotkey list DisplayHotkeyList( this, g_Module_Editor_Hokeys_Descr ); break; - case HK_RESET_LOCAL_COORD: /*Reset the relative coord */ - GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); + case HK_RESET_LOCAL_COORD: // set local (relative) coordinate origin + GetScreen()->m_O_Curseur = GetCrossHairPosition(); + break; + + case HK_SET_GRID_ORIGIN: + SetGridOrigin( GetCrossHairPosition() ); + m_canvas->Refresh(); break; case HK_SWITCH_UNITS: diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 287deee5cb..d987948d71 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -557,8 +557,12 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const Double2Str( aBoard->GetDesignSettings().m_SolderPasteMarginRatio ).c_str() ); m_out->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n", - FMTIU( aBoard->GetOriginAxisPosition().x ).c_str(), - FMTIU( aBoard->GetOriginAxisPosition().y ).c_str() ); + FMTIU( aBoard->GetAuxOrigin().x ).c_str(), + FMTIU( aBoard->GetAuxOrigin().y ).c_str() ); + + m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n", + FMTIU( aBoard->GetGridOrigin().x ).c_str(), + FMTIU( aBoard->GetGridOrigin().y ).c_str() ); m_out->Print( aNestLevel+1, "(visible_elements %X)\n", aBoard->GetDesignSettings().GetVisibleElements() ); diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 12a5ba39d2..03a1fd8313 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -649,7 +649,8 @@ void LEGACY_PLUGIN::loadSETUP() BIU gx = biuParse( line + SZ( "AuxiliaryAxisOrg" ), &data ); BIU gy = biuParse( data ); - m_board->SetOriginAxisPosition( wxPoint( gx, gy ) ); + // m_board->SetAuxOrigin( wxPoint( gx, gy ) ); gets overwritten by SetDesignSettings() below + bds.m_AuxOrigin = wxPoint( gx, gy ); } else if( TESTLINE( "Layers" ) ) @@ -851,13 +852,11 @@ void LEGACY_PLUGIN::loadSETUP() else if( TESTLINE( "GridOrigin" ) ) { - /* @todo - BIU gx = biuParse( line + SZ( "GridOrigin" ), &data ); - BIU gy = biuParse( data ); + BIU x = biuParse( line + SZ( "GridOrigin" ), &data ); + BIU y = biuParse( data ); - GetScreen()->m_GridOrigin.x = Ox; - GetScreen()->m_GridOrigin.y = Oy; - */ + // m_board->SetGridOrigin( wxPoint( x, y ) ); gets overwritten by SetDesignSettings() below + bds.m_GridOrigin = wxPoint( x, y ); } else if( TESTLINE( "VisibleElements" ) ) @@ -3071,14 +3070,8 @@ void LEGACY_PLUGIN::saveSETUP( const BOARD* aBoard ) const if( bds.m_SolderPasteMarginRatio != 0 ) fprintf( m_fp, "Pad2PasteClearanceRatio %g\n", bds.m_SolderPasteMarginRatio ); - /* @todo no aFrame - if ( aFrame->GetScreen()->m_GridOrigin != wxPoint( 0, 0 ) ) - { - fprintf( m_fp, "GridOrigin %s\n", fmtBIUPoint( aFrame->GetScreen()->m_GridOrigin ).c_str() ); - } - */ - - fprintf( m_fp, "AuxiliaryAxisOrg %s\n", fmtBIUPoint( aBoard->GetOriginAxisPosition() ).c_str() ); + fprintf( m_fp, "GridOrigin %s\n", fmtBIUPoint( aBoard->GetGridOrigin() ).c_str() ); + fprintf( m_fp, "AuxiliaryAxisOrg %s\n", fmtBIUPoint( aBoard->GetAuxOrigin() ).c_str() ); fprintf( m_fp, "VisibleElements %X\n", bds.GetVisibleElements() ); diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 7c4aa15d20..fb0752d45a 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -725,7 +725,7 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName ) GetBoard()->Add( module ); // Update parameters: position, timestamp ... - newpos = GetScreen()->GetCrossHairPosition(); + newpos = GetCrossHairPosition(); module->SetPosition( newpos ); module->SetLastEditTime(); diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index ae766cd6cc..fbdfdd5a29 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -93,7 +93,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule ) GetBoard()->BuildListOfNets(); - GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); + SetCrossHairPosition( wxPoint( 0, 0 ) ); PlaceModule( aModule, NULL ); // Put it on FRONT layer, @@ -155,7 +155,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary, wxDC* aDC ) { MODULE* module; - wxPoint curspos = GetScreen()->GetCrossHairPosition(); + wxPoint curspos = GetCrossHairPosition(); wxString moduleName, keys; wxString libName = aLibrary; bool allowWildSeach = true; @@ -277,7 +277,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary, } } - GetScreen()->SetCrossHairPosition( curspos ); + SetCrossHairPosition( curspos ); m_canvas->MoveCursorToCrossHair(); if( module ) diff --git a/pcbnew/magnetic_tracks_functions.cpp b/pcbnew/magnetic_tracks_functions.cpp index 684ee374a5..8f7a8e5064 100644 --- a/pcbnew/magnetic_tracks_functions.cpp +++ b/pcbnew/magnetic_tracks_functions.cpp @@ -116,7 +116,7 @@ bool Magnetize( PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize aGridSize, TRACK* currTrack = g_CurrentTrackSegment; BOARD_ITEM* currItem = frame->GetCurItem(); PCB_SCREEN* screen = frame->GetScreen(); - wxPoint pos = screen->RefPos( true ); + wxPoint pos = frame->RefPos( true ); // D( printf( "currTrack=%p currItem=%p currTrack->Type()=%d currItem->Type()=%d\n", currTrack, currItem, currTrack ? currTrack->Type() : 0, currItem ? currItem->Type() : 0 ); ) @@ -133,7 +133,6 @@ bool Magnetize( PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize aGridSize, currTrack = NULL; } - if( g_MagneticPadOption == capture_always ) doPad = true; diff --git a/pcbnew/mirepcb.cpp b/pcbnew/mirepcb.cpp index 61aa0f55ff..ca9101ae9b 100644 --- a/pcbnew/mirepcb.cpp +++ b/pcbnew/mirepcb.cpp @@ -16,14 +16,14 @@ #include -/* Routines Locales */ +// Routines Locales static void AbortMoveAndEditTarget( EDA_DRAW_PANEL* Panel, wxDC* DC ); static void ShowTargetShapeWhileMovingMouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ); -/* Local variables : */ +// Local variables : static int MireDefaultSize = 5000; static PCB_TARGET s_TargetCopy( NULL ); /* Used to store "old" values of the * current item parameters before @@ -93,7 +93,7 @@ TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR( PCB_EDIT_FRAME MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 ); MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - /* Create of the command buttons. */ + // Create of the command buttons. Button = new wxButton( this, wxID_OK, _( "OK" ) ); RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); @@ -215,7 +215,7 @@ PCB_TARGET* PCB_EDIT_FRAME::CreateTarget( wxDC* DC ) target->SetLayer( EDGE_N ); target->SetWidth( GetDesignSettings().m_EdgeSegmentWidth ); target->SetSize( MireDefaultSize ); - target->SetPosition( m_canvas->GetScreen()->GetCrossHairPosition() ); + target->SetPosition( GetCrossHairPosition() ); PlaceTarget( target, DC ); @@ -273,7 +273,7 @@ void PCB_EDIT_FRAME::PlaceTarget( PCB_TARGET* aTarget, wxDC* DC ) } -/* Redraw the contour of the track while moving the mouse */ +// Redraw the contour of the track while moving the mouse static void ShowTargetShapeWhileMovingMouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { @@ -286,7 +286,7 @@ static void ShowTargetShapeWhileMovingMouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC, if( aErase ) target->Draw( aPanel, aDC, GR_XOR ); - target->SetPosition( screen->GetCrossHairPosition() ); + target->SetPosition( aPanel->GetParent()->GetCrossHairPosition() ); target->Draw( aPanel, aDC, GR_XOR ); } diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index fb1b5f1035..c140224549 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -87,9 +87,9 @@ BOARD_ITEM* FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay( int aHotKeyCode ) scanList = GENERAL_COLLECTOR::ModulesAndTheirItems; } - m_Collector->Collect( GetBoard(), scanList, GetScreen()->RefPos( true ), guide ); + m_Collector->Collect( GetBoard(), scanList, RefPos( true ), guide ); - /* Remove redundancies: when an item is found, we can remove the module from list */ + // Remove redundancies: when an item is found, we can remove the module from list if( m_Collector->GetCount() > 1 ) { for( int ii = 0; ii < m_Collector->GetCount(); ii++ ) @@ -113,7 +113,7 @@ BOARD_ITEM* FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay( int aHotKeyCode ) { wxMenu itemMenu; - /* Give a title to the selection menu. This is also a cancel menu item **/ + // Give a title to the selection menu. This is also a cancel menu item * wxMenuItem* item_title = new wxMenuItem( &itemMenu, -1, _( "Selection Clarification" ) ); #ifdef __WINDOWS__ @@ -255,100 +255,100 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_OPEN_MODULE_VIEWER: - { - FOOTPRINT_VIEWER_FRAME * viewer = FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer(); - - if( viewer == NULL ) { - viewer = new FOOTPRINT_VIEWER_FRAME( this, m_footprintLibTable, NULL ); - viewer->Show( true ); - viewer->Zoom_Automatique( false ); - } - else - { - if( viewer->IsIconized() ) - viewer->Iconize( false ); + FOOTPRINT_VIEWER_FRAME * viewer = FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer(); - viewer->Raise(); + if( viewer == NULL ) + { + viewer = new FOOTPRINT_VIEWER_FRAME( this, m_footprintLibTable, NULL ); + viewer->Show( true ); + viewer->Zoom_Automatique( false ); + } + else + { + if( viewer->IsIconized() ) + viewer->Iconize( false ); - // Raising the window does not set the focus on Linux. This should work on - // any platform. - if( wxWindow::FindFocus() != viewer ) - viewer->SetFocus(); + viewer->Raise(); + + // Raising the window does not set the focus on Linux. This should work on + // any platform. + if( wxWindow::FindFocus() != viewer ) + viewer->SetFocus(); + } } - } - break; + break; case ID_MODEDIT_DELETE_PART: DeleteModuleFromCurrentLibrary(); break; case ID_MODEDIT_NEW_MODULE: - { - Clear_Pcb( true ); - GetScreen()->ClearUndoRedoList(); - SetCurItem( NULL ); - GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); - - MODULE* module = Create_1_Module( wxEmptyString ); - - if( module ) // i.e. if create module command not aborted { - // Initialize data relative to nets and netclasses (for a new - // module the defaults are used) - // This is mandatory to handle and draw pads - GetBoard()->BuildListOfNets(); - redraw = true; - module->SetPosition( wxPoint( 0, 0 ) ); + Clear_Pcb( true ); + GetScreen()->ClearUndoRedoList(); + SetCurItem( NULL ); + SetCrossHairPosition( wxPoint( 0, 0 ) ); - if( GetBoard()->m_Modules ) - GetBoard()->m_Modules->ClearFlags(); + MODULE* module = Create_1_Module( wxEmptyString ); - Zoom_Automatique( false ); + if( module ) // i.e. if create module command not aborted + { + // Initialize data relative to nets and netclasses (for a new + // module the defaults are used) + // This is mandatory to handle and draw pads + GetBoard()->BuildListOfNets(); + redraw = true; + module->SetPosition( wxPoint( 0, 0 ) ); + + if( GetBoard()->m_Modules ) + GetBoard()->m_Modules->ClearFlags(); + + Zoom_Automatique( false ); + } } - } - break; + break; case ID_MODEDIT_NEW_MODULE_FROM_WIZARD: - { - Clear_Pcb( true ); - GetScreen()->ClearUndoRedoList(); - SetCurItem( NULL ); - GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); - - wxSemaphore semaphore( 0, 1 ); - FOOTPRINT_WIZARD_FRAME *wizard = new FOOTPRINT_WIZARD_FRAME( this, &semaphore, - KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT ); - wizard->Show( true ); - wizard->Zoom_Automatique( false ); - - while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event { - wxYield(); - wxMilliSleep( 50 ); + Clear_Pcb( true ); + GetScreen()->ClearUndoRedoList(); + SetCurItem( NULL ); + SetCrossHairPosition( wxPoint( 0, 0 ) ); + + wxSemaphore semaphore( 0, 1 ); + FOOTPRINT_WIZARD_FRAME *wizard = new FOOTPRINT_WIZARD_FRAME( this, &semaphore, + KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT ); + wizard->Show( true ); + wizard->Zoom_Automatique( false ); + + while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event + { + wxYield(); + wxMilliSleep( 50 ); + } + + MODULE* module = wizard->GetBuiltFootprint(); + + if( module ) // i.e. if create module command not aborted + { + // Here we should make a copy of the object before adding to board + module->SetParent( (EDA_ITEM*)GetBoard() ); + GetBoard()->m_Modules.Append( module ); + + // Initialize data relative to nets and netclasses (for a new + // module the defaults are used) + // This is mandatory to handle and draw pads + GetBoard()->BuildListOfNets(); + redraw = true; + module->SetPosition( wxPoint( 0, 0 ) ); + + if( GetBoard()->m_Modules ) + GetBoard()->m_Modules->ClearFlags(); + } + + wizard->Destroy(); } - - MODULE* module = wizard->GetBuiltFootprint(); - - if( module ) // i.e. if create module command not aborted - { - /* Here we should make a copy of the object before adding to board*/ - module->SetParent( (EDA_ITEM*)GetBoard() ); - GetBoard()->m_Modules.Append( module ); - - // Initialize data relative to nets and netclasses (for a new - // module the defaults are used) - // This is mandatory to handle and draw pads - GetBoard()->BuildListOfNets(); - redraw = true; - module->SetPosition( wxPoint( 0, 0 ) ); - - if( GetBoard()->m_Modules ) - GetBoard()->m_Modules->ClearFlags(); - } - - wizard->Destroy(); - } break; case ID_MODEDIT_SAVE_LIBMODULE: @@ -361,84 +361,84 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_MODEDIT_INSERT_MODULE_IN_BOARD: case ID_MODEDIT_UPDATE_MODULE_IN_BOARD: - { - // update module in the current board, - // not just add it to the board with total disregard for the netlist... - PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) GetParent(); - BOARD* mainpcb = pcbframe->GetBoard(); - MODULE* source_module = NULL; - MODULE* module_in_edit = GetBoard()->m_Modules; - - // Search the old module (source) if exists - // Because this source could be deleted when editing the main board... - if( module_in_edit->GetLink() ) // this is not a new module ... { - source_module = mainpcb->m_Modules; + // update module in the current board, + // not just add it to the board with total disregard for the netlist... + PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) GetParent(); + BOARD* mainpcb = pcbframe->GetBoard(); + MODULE* source_module = NULL; + MODULE* module_in_edit = GetBoard()->m_Modules; - for( ; source_module != NULL; source_module = (MODULE*) source_module->Next() ) + // Search the old module (source) if exists + // Because this source could be deleted when editing the main board... + if( module_in_edit->GetLink() ) // this is not a new module ... { - if( module_in_edit->GetLink() == source_module->GetTimeStamp() ) - break; + source_module = mainpcb->m_Modules; + + for( ; source_module != NULL; source_module = (MODULE*) source_module->Next() ) + { + if( module_in_edit->GetLink() == source_module->GetTimeStamp() ) + break; + } } + + if( ( source_module == NULL ) + && ( id == ID_MODEDIT_UPDATE_MODULE_IN_BOARD ) ) // source not found + { + wxString msg; + msg.Printf( _( "Unable to find the footprint source on the main board" ) ); + msg << _( "\nCannot update the footprint" ); + DisplayError( this, msg ); + break; + } + + if( ( source_module != NULL ) + && ( id == ID_MODEDIT_INSERT_MODULE_IN_BOARD ) ) // source not found + { + wxString msg; + msg.Printf( _( "A footprint source was found on the main board" ) ); + msg << _( "\nCannot insert this footprint" ); + DisplayError( this, msg ); + break; + } + + // Create the "new" module + MODULE* newmodule = new MODULE( *module_in_edit ); + newmodule->SetParent( mainpcb ); + newmodule->SetLink( 0 ); + + // Put the footprint in the main pcb linked list. + mainpcb->Add( newmodule ); + + if( source_module ) // this is an update command + { + // In the main board, + // the new module replace the old module (pos, orient, ref, value + // and connexions are kept) + // and the source_module (old module) is deleted + PICKED_ITEMS_LIST pickList; + pcbframe->Exchange_Module( source_module, newmodule, &pickList ); + newmodule->SetTimeStamp( module_in_edit->GetLink() ); + + if( pickList.GetCount() ) + pcbframe->SaveCopyInUndoList( pickList, UR_UNSPECIFIED ); + } + else // This is an insert command + { + wxPoint cursor_pos = pcbframe->GetCrossHairPosition(); + pcbframe->SetCrossHairPosition( wxPoint( 0, 0 ) ); + pcbframe->PlaceModule( newmodule, NULL ); + pcbframe->SetCrossHairPosition( cursor_pos ); + newmodule->SetTimeStamp( GetNewTimeStamp() ); + pcbframe->SaveCopyInUndoList( newmodule, UR_NEW ); + } + + newmodule->ClearFlags(); + GetScreen()->ClrModify(); + pcbframe->SetCurItem( NULL ); + mainpcb->m_Status_Pcb = 0; } - - if( ( source_module == NULL ) - && ( id == ID_MODEDIT_UPDATE_MODULE_IN_BOARD ) ) // source not found - { - wxString msg; - msg.Printf( _( "Unable to find the footprint source on the main board" ) ); - msg << _( "\nCannot update the footprint" ); - DisplayError( this, msg ); - break; - } - - if( ( source_module != NULL ) - && ( id == ID_MODEDIT_INSERT_MODULE_IN_BOARD ) ) // source not found - { - wxString msg; - msg.Printf( _( "A footprint source was found on the main board" ) ); - msg << _( "\nCannot insert this footprint" ); - DisplayError( this, msg ); - break; - } - - // Create the "new" module - MODULE* newmodule = new MODULE( *module_in_edit ); - newmodule->SetParent( mainpcb ); - newmodule->SetLink( 0 ); - - // Put the footprint in the main pcb linked list. - mainpcb->Add( newmodule ); - - if( source_module ) // this is an update command - { - // In the main board, - // the new module replace the old module (pos, orient, ref, value - // and connexions are kept) - // and the source_module (old module) is deleted - PICKED_ITEMS_LIST pickList; - pcbframe->Exchange_Module( source_module, newmodule, &pickList ); - newmodule->SetTimeStamp( module_in_edit->GetLink() ); - - if( pickList.GetCount() ) - pcbframe->SaveCopyInUndoList( pickList, UR_UNSPECIFIED ); - } - else // This is an insert command - { - wxPoint cursor_pos = pcbframe->GetScreen()->GetCrossHairPosition(); - pcbframe->GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); - pcbframe->PlaceModule( newmodule, NULL ); - pcbframe->GetScreen()->SetCrossHairPosition( cursor_pos ); - newmodule->SetTimeStamp( GetNewTimeStamp() ); - pcbframe->SaveCopyInUndoList( newmodule, UR_NEW ); - } - - newmodule->ClearFlags(); - GetScreen()->ClrModify(); - pcbframe->SetCurItem( NULL ); - mainpcb->m_Status_Pcb = 0; - } - break; + break; case ID_MODEDIT_IMPORT_PART: if( ! Clear_Pcb( true ) ) @@ -446,7 +446,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) GetScreen()->ClearUndoRedoList(); SetCurItem( NULL ); - GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); + SetCrossHairPosition( wxPoint( 0, 0 ) ); Import_Module(); redraw = true; @@ -485,7 +485,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) GetScreen()->ClearUndoRedoList(); SetCurItem( NULL ); Clear_Pcb( true ); - GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) ); + SetCrossHairPosition( wxPoint( 0, 0 ) ); #if !defined( USE_FP_LIB_TABLE ) LoadModuleFromLibrary( getLibPath(), m_footprintLibTable, true ); diff --git a/pcbnew/modedit_onclick.cpp b/pcbnew/modedit_onclick.cpp index 4628f1ba80..145959aa6d 100644 --- a/pcbnew/modedit_onclick.cpp +++ b/pcbnew/modedit_onclick.cpp @@ -132,32 +132,31 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) break; case ID_MODEDIT_ANCHOR_TOOL: - { - MODULE* module = GetBoard()->m_Modules; + { + MODULE* module = GetBoard()->m_Modules; - if( module == NULL // No module loaded - || (module->GetFlags() != 0) ) - break; + if( module == NULL // No module loaded + || (module->GetFlags() != 0) ) + break; - SaveCopyInUndoList( module, UR_MODEDIT ); + SaveCopyInUndoList( module, UR_MODEDIT ); - // set the new relative internal local coordinates of footprint items - wxPoint moveVector = module->GetPosition() - - GetScreen()->GetCrossHairPosition(); - module->MoveAnchorPosition( moveVector ); + // set the new relative internal local coordinates of footprint items + wxPoint moveVector = module->GetPosition() - GetCrossHairPosition(); + module->MoveAnchorPosition( moveVector ); - // Usually, we do not need to change twice the anchor position, - // so deselect the active tool - SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); - SetCurItem( NULL ); - m_canvas->Refresh(); - } - break; + // Usually, we do not need to change twice the anchor position, + // so deselect the active tool + SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString ); + SetCurItem( NULL ); + m_canvas->Refresh(); + } + break; case ID_MODEDIT_PLACE_GRID_COORD: - m_canvas->DrawGridAxis( DC, GR_XOR ); - GetScreen()->m_GridOrigin = GetScreen()->GetCrossHairPosition(); - m_canvas->DrawGridAxis( DC, GR_COPY ); + m_canvas->DrawGridAxis( DC, GR_XOR, GetBoard()->GetGridOrigin() ); + SetGridOrigin( GetCrossHairPosition() ); + m_canvas->DrawGridAxis( DC, GR_COPY, GetBoard()->GetGridOrigin() ); GetScreen()->SetModify(); break; diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 44d5d122fa..4e9834fb72 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -497,9 +497,9 @@ void FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, snapToGrid = false; if( snapToGrid ) - pos = GetScreen()->GetNearestGridPosition( pos ); + pos = GetNearestGridPosition( pos ); - oldpos = GetScreen()->GetCrossHairPosition(); + oldpos = GetCrossHairPosition(); gridSize = GetScreen()->GetGridSize(); switch( aHotKey ) @@ -532,14 +532,14 @@ void FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, break; } - GetScreen()->SetCrossHairPosition( pos, snapToGrid ); + SetCrossHairPosition( pos, snapToGrid ); - if( oldpos != GetScreen()->GetCrossHairPosition() ) + if( oldpos != GetCrossHairPosition() ) { - pos = GetScreen()->GetCrossHairPosition(); - GetScreen()->SetCrossHairPosition( oldpos, false ); + pos = GetCrossHairPosition(); + SetCrossHairPosition( oldpos, false ); m_canvas->CrossHairOff( aDC ); - GetScreen()->SetCrossHairPosition( pos, snapToGrid ); + SetCrossHairPosition( pos, snapToGrid ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index f19e944a9b..477feacaf6 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -244,7 +244,7 @@ void MoveFootprint( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, } /* Redraw the module at the new position. */ - g_Offset_Module = module->GetPosition() - aPanel->GetScreen()->GetCrossHairPosition(); + g_Offset_Module = module->GetPosition() - aPanel->GetParent()->GetCrossHairPosition(); DrawModuleOutlines( aPanel, aDC, module ); DrawSegmentWhileMovingFootprint( aPanel, aDC ); @@ -391,7 +391,7 @@ void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, wxDC* aDC, bool aDoNotRecreat if( g_Show_Module_Ratsnest && ( GetBoard()->m_Status_Pcb & LISTE_PAD_OK ) && aDC ) TraceModuleRatsNest( aDC ); - newpos = GetScreen()->GetCrossHairPosition(); + newpos = GetCrossHairPosition(); aModule->SetPosition( newpos ); aModule->ClearFlags(); diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index a051ea942d..b8cf54629f 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -369,7 +369,7 @@ void FOOTPRINT_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv ) void FOOTPRINT_VIEWER_FRAME::OnSetRelativeOffset( wxCommandEvent& event ) { - GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); + GetScreen()->m_O_Curseur = GetCrossHairPosition(); UpdateStatusBar(); } @@ -644,8 +644,8 @@ void FOOTPRINT_VIEWER_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); cmd.SetEventObject( this ); - pos = screen->GetNearestGridPosition( pos ); - oldpos = screen->GetCrossHairPosition(); + pos = GetNearestGridPosition( pos ); + oldpos = GetCrossHairPosition(); gridSize = screen->GetGridSize(); switch( aHotKey ) @@ -676,7 +676,7 @@ void FOOTPRINT_VIEWER_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition break; case ' ': - screen->m_O_Curseur = screen->GetCrossHairPosition(); + screen->m_O_Curseur = GetCrossHairPosition(); break; case WXK_NUMPAD8: /* cursor moved up */ @@ -704,14 +704,14 @@ void FOOTPRINT_VIEWER_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition break; } - screen->SetCrossHairPosition( pos ); + SetCrossHairPosition( pos ); - if( oldpos != screen->GetCrossHairPosition() ) + if( oldpos != GetCrossHairPosition() ) { - pos = screen->GetCrossHairPosition(); - screen->SetCrossHairPosition( oldpos ); + pos = GetCrossHairPosition(); + SetCrossHairPosition( oldpos ); m_canvas->CrossHairOff( aDC ); - screen->SetCrossHairPosition( pos ); + SetCrossHairPosition( pos ); m_canvas->CrossHairOn( aDC ); if( m_canvas->IsMouseCaptured() ) diff --git a/pcbnew/move-drag_pads.cpp b/pcbnew/move-drag_pads.cpp index b7dd439d7e..eae74d2662 100644 --- a/pcbnew/move-drag_pads.cpp +++ b/pcbnew/move-drag_pads.cpp @@ -63,7 +63,6 @@ static void Show_Pad_Move( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo bool aErase ) { TRACK* Track; - BASE_SCREEN* screen = aPanel->GetScreen(); D_PAD* pad = s_CurrentSelectedPad; if( pad == NULL ) // Should not occur @@ -72,7 +71,7 @@ static void Show_Pad_Move( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo if( aErase ) pad->Draw( aPanel, aDC, GR_XOR ); - pad->SetPosition( screen->GetCrossHairPosition() ); + pad->SetPosition( aPanel->GetParent()->GetCrossHairPosition() ); pad->Draw( aPanel, aDC, GR_XOR ); for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 877edfcd03..3a5b1bb271 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -85,7 +85,7 @@ static void Abort_MoveTrack( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) frame->SetCurItem( NULL ); aPanel->SetMouseCapture( NULL, NULL ); - /* Undo move and redraw trace segments. */ + // Undo move and redraw trace segments. for( unsigned jj=0 ; jj < g_DragSegmentList.size(); jj++ ) { TRACK* track = g_DragSegmentList[jj].m_Track; @@ -101,12 +101,11 @@ static void Abort_MoveTrack( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) } -/* Redraw the moved node according to the mouse cursor position */ +// Redraw the moved node according to the mouse cursor position static void Show_MoveNode( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { wxPoint moveVector; - BASE_SCREEN* screen = aPanel->GetScreen(); int tmp = DisplayOpt.DisplayPcbTrackFill; GR_DRAWMODE draw_mode = GR_XOR | GR_HIGHLIGHT; @@ -118,8 +117,8 @@ static void Show_MoveNode( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo aErase = false; #endif - /* set the new track coordinates */ - wxPoint Pos = screen->GetCrossHairPosition(); + // set the new track coordinates + wxPoint Pos = aPanel->GetParent()->GetCrossHairPosition(); moveVector = Pos - s_LastPos; s_LastPos = Pos; @@ -202,7 +201,6 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( EDA_DRAW_PANEL* aPanel, wxDC double xi1 = 0, yi1 = 0, xi2 = 0, yi2 = 0; // calculated intersection points double tx1, tx2, ty1, ty2; // temporary storage of points int dx, dy; - BASE_SCREEN* screen = aPanel->GetScreen(); bool update = true; TRACK* Track; TRACK* tSegmentToStart = NULL, * tSegmentToEnd = NULL; @@ -243,7 +241,7 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( EDA_DRAW_PANEL* aPanel, wxDC GR_DRAWMODE draw_mode = GR_XOR | GR_HIGHLIGHT; - /* Undraw the current moved track segments before modification*/ + // Undraw the current moved track segments before modification #ifndef USE_WX_OVERLAY // if( erase ) @@ -258,13 +256,13 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( EDA_DRAW_PANEL* aPanel, wxDC } #endif - /* Compute the new track segment position */ - wxPoint Pos = screen->GetCrossHairPosition(); + // Compute the new track segment position + wxPoint Pos = aPanel->GetParent()->GetCrossHairPosition(); dx = Pos.x - s_LastPos.x; dy = Pos.y - s_LastPos.y; - //move the line by dx and dy + // move the line by dx and dy tx1 = (double) ( Track->GetStart().x + dx ); ty1 = (double) ( Track->GetStart().y + dy ); tx2 = (double) ( Track->GetEnd().x + dx ); @@ -613,13 +611,13 @@ void PCB_EDIT_FRAME::StartMoveOneNodeOrSegment( TRACK* aTrack, wxDC* aDC, int aC EraseDragList(); - /* Change highlighted net: the new one will be highlighted */ + // Change highlighted net: the new one will be highlighted GetBoard()->PushHighLight(); if( GetBoard()->IsHighLightNetON() ) HighLight( aDC ); - PosInit = GetScreen()->GetCrossHairPosition(); + PosInit = GetCrossHairPosition(); if( aTrack->Type() == PCB_VIA_T ) { @@ -637,7 +635,7 @@ void PCB_EDIT_FRAME::StartMoveOneNodeOrSegment( TRACK* aTrack, wxDC* aDC, int aC } else { - STATUS_FLAGS diag = aTrack->IsPointOnEnds( GetScreen()->GetCrossHairPosition(), -1 ); + STATUS_FLAGS diag = aTrack->IsPointOnEnds( GetCrossHairPosition(), -1 ); wxPoint pos; switch( aCommand ) @@ -754,7 +752,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC if( !TrackToEndPoint || ( TrackToEndPoint->Type() != PCB_TRACE_T ) ) s_EndSegmentPresent = false; - /* Change high light net: the new one will be highlighted */ + // Change high light net: the new one will be highlighted GetBoard()->PushHighLight(); if( GetBoard()->IsHighLightNetON() ) @@ -791,8 +789,8 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC UndrawAndMarkSegmentsToDrag( m_canvas, DC ); - PosInit = GetScreen()->GetCrossHairPosition(); - s_LastPos = GetScreen()->GetCrossHairPosition(); + PosInit = GetCrossHairPosition(); + s_LastPos = GetCrossHairPosition(); m_canvas->SetMouseCapture( Show_Drag_Track_Segment_With_Cte_Slope, Abort_MoveTrack ); GetBoard()->SetHighLightNet( track->GetNet() ); @@ -823,7 +821,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC } -/* Place a dragged (or moved) track segment or via */ +// Place a dragged (or moved) track segment or via bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) { int errdrc; @@ -841,7 +839,7 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) if( errdrc == BAD_DRC ) return false; - /* Redraw the dragged segments */ + // Redraw the dragged segments for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { errdrc = m_drc->Drc( g_DragSegmentList[ii].m_Track, GetBoard()->m_Track ); @@ -855,7 +853,7 @@ bool PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC ) Track->ClearFlags(); Track->SetState( IN_EDIT, false ); - /* Draw dragged tracks */ + // Draw dragged tracks for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { Track = g_DragSegmentList[ii].m_Track; diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index 494cd8430c..6bf21028c7 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -123,7 +123,7 @@ static void ShowBoundingBoxMicroWaveInductor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GRPoly( aPanel->GetClipBox(), aDC, 5, poly, false, 0, YELLOW, YELLOW ); } - Mself.m_End = aPanel->GetScreen()->GetCrossHairPosition(); + Mself.m_End = aPanel->GetParent()->GetCrossHairPosition(); pt = Mself.m_End - Mself.m_Start; angle = -ArcTangente( pt.y, pt.x ); len = KiROUND( EuclideanNorm( pt ) ); @@ -161,13 +161,13 @@ void PCB_EDIT_FRAME::Begin_Self( wxDC* DC ) return; } - Mself.m_Start = GetScreen()->GetCrossHairPosition(); + Mself.m_Start = GetCrossHairPosition(); Mself.m_End = Mself.m_Start; Self_On = 1; // Update the initial coordinates. - GetScreen()->m_O_Curseur = GetScreen()->GetCrossHairPosition(); + GetScreen()->m_O_Curseur = GetCrossHairPosition(); UpdateStatusBar(); m_canvas->SetMouseCapture( ShowBoundingBoxMicroWaveInductor, Exit_Self ); @@ -192,7 +192,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC ) Self_On = 0; - Mself.m_End = GetScreen()->GetCrossHairPosition(); + Mself.m_End = GetCrossHairPosition(); wxPoint pt = Mself.m_End - Mself.m_Start; int min_len = KiROUND( EuclideanNorm( pt ) ); @@ -751,7 +751,8 @@ private: wxRadioBox* m_ShapeOptionCtrl; EDA_SIZE_CTRL* m_SizeCtrl; -public: WinEDA_SetParamShapeFrame( PCB_EDIT_FRAME* parent, const wxPoint& pos ); +public: + WinEDA_SetParamShapeFrame( PCB_EDIT_FRAME* parent, const wxPoint& pos ); ~WinEDA_SetParamShapeFrame() { }; private: diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index f655b1a6a0..53703e3166 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -394,7 +394,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) break; case ID_PCB_DELETE_ITEM_BUTT: - if( !DrawStruct || (DrawStruct->GetFlags() == 0) ) + if( !DrawStruct || !DrawStruct->GetFlags() ) { DrawStruct = PcbGeneralLocateAndDisplay(); @@ -409,15 +409,15 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case ID_PCB_PLACE_OFFSET_COORD_BUTT: m_canvas->DrawAuxiliaryAxis( aDC, GR_XOR ); - SetOriginAxisPosition( GetScreen()->GetCrossHairPosition() ); + SetAuxOrigin( GetCrossHairPosition() ); m_canvas->DrawAuxiliaryAxis( aDC, GR_COPY ); OnModify(); break; case ID_PCB_PLACE_GRID_COORD_BUTT: - m_canvas->DrawGridAxis( aDC, GR_XOR ); - GetScreen()->m_GridOrigin = GetScreen()->GetCrossHairPosition(); - m_canvas->DrawGridAxis( aDC, GR_COPY ); + m_canvas->DrawGridAxis( aDC, GR_XOR, GetBoard()->GetGridOrigin() ); + SetGridOrigin( GetCrossHairPosition() ); + m_canvas->DrawGridAxis( aDC, GR_COPY, GetBoard()->GetGridOrigin() ); break; default: diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 5df6ea1d61..1d482743fe 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -101,12 +101,12 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) } } - /* Select a proper item */ + // Select a proper item - wxPoint cursorPos = GetScreen()->GetCrossHairPosition(); + wxPoint cursorPos = GetCrossHairPosition(); wxPoint selectPos = m_Collector->GetRefPos(); - selectPos = GetScreen()->GetNearestGridPosition( selectPos ); + selectPos = GetNearestGridPosition( selectPos ); /* We can reselect another item only if there are no item being edited * because ALL moving functions use GetCurItem(), therefore GetCurItem() @@ -312,7 +312,7 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) msg, KiBitmap( move_module_xpm ) ); } - /* Display context sensitive commands: */ + // Display context sensitive commands: switch( GetToolId() ) { case ID_PCB_ZONES_BUTT: @@ -455,7 +455,7 @@ void PCB_EDIT_FRAME::createPopUpBlockMenu( wxMenu* menu ) */ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) { - wxPoint cursorPosition = GetScreen()->GetCrossHairPosition(); + wxPoint cursorPosition = GetCrossHairPosition(); wxString msg; GetBoard()->SetCurrentNetClass( Track->GetNetClassName() ); @@ -635,14 +635,14 @@ void PCB_EDIT_FRAME::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* edge_zone->GetIsKeepout() ? _("Keepout Area") : _( "Zones" ), KiBitmap( add_zone_xpm ) ); - if( edge_zone->HitTestForCorner( GetScreen()->RefPos( true ) ) ) + if( edge_zone->HitTestForCorner( RefPos( true ) ) ) { AddMenuItem( zones_menu, ID_POPUP_PCB_MOVE_ZONE_CORNER, _( "Move Corner" ), KiBitmap( move_xpm ) ); AddMenuItem( zones_menu, ID_POPUP_PCB_DELETE_ZONE_CORNER, _( "Delete Corner" ), KiBitmap( delete_xpm ) ); } - else if( edge_zone->HitTestForEdge( GetScreen()->RefPos( true ) ) ) + else if( edge_zone->HitTestForEdge( RefPos( true ) ) ) { AddMenuItem( zones_menu, ID_POPUP_PCB_ADD_ZONE_CORNER, _( "Create Corner" ), KiBitmap( add_corner_xpm ) ); @@ -862,7 +862,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForFpPads( D_PAD* Pad, wxMenu* menu ) } -/* Create pop menu for pcb texts */ +// Create pop menu for pcb texts void PCB_EDIT_FRAME::createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu ) { wxMenu* sub_menu_Text; diff --git a/pcbnew/pad_edition_functions.cpp b/pcbnew/pad_edition_functions.cpp index 51eab2a6f2..b99bd1580a 100644 --- a/pcbnew/pad_edition_functions.cpp +++ b/pcbnew/pad_edition_functions.cpp @@ -143,7 +143,7 @@ void PCB_BASE_FRAME::AddPad( MODULE* aModule, bool draw ) Import_Pad_Settings( pad, false ); pad->SetNetname( wxEmptyString ); - pad->SetPosition( GetScreen()->GetCrossHairPosition() ); + pad->SetPosition( GetCrossHairPosition() ); // Set the relative pad position // ( pad position for module orient, 0, and relative to the module position) diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 6de537f87e..bd255e84b2 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -883,12 +883,12 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR ) break; case T_user_via: - { - int viaSize = parseBoardUnits( "user via size" ); - int viaDrill = parseBoardUnits( "user via drill" ); - m_board->m_ViasDimensionsList.push_back( VIA_DIMENSION( viaSize, viaDrill ) ); - NeedRIGHT(); - } + { + int viaSize = parseBoardUnits( "user via size" ); + int viaDrill = parseBoardUnits( "user via drill" ); + m_board->m_ViasDimensionsList.push_back( VIA_DIMENSION( viaSize, viaDrill ) ); + NeedRIGHT(); + } break; case T_uvia_size: @@ -944,21 +944,21 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR ) break; case T_pad_size: - { - wxSize sz; - sz.SetWidth( parseBoardUnits( "master pad width" ) ); - sz.SetHeight( parseBoardUnits( "master pad height" ) ); - designSettings.m_Pad_Master.SetSize( sz ); - NeedRIGHT(); + { + wxSize sz; + sz.SetWidth( parseBoardUnits( "master pad width" ) ); + sz.SetHeight( parseBoardUnits( "master pad height" ) ); + designSettings.m_Pad_Master.SetSize( sz ); + NeedRIGHT(); + } break; - } case T_pad_drill: - { - int drillSize = parseBoardUnits( T_pad_drill ); - designSettings.m_Pad_Master.SetDrillSize( wxSize( drillSize, drillSize ) ); - NeedRIGHT(); - } + { + int drillSize = parseBoardUnits( T_pad_drill ); + designSettings.m_Pad_Master.SetDrillSize( wxSize( drillSize, drillSize ) ); + NeedRIGHT(); + } break; case T_pad_to_mask_clearance: @@ -982,14 +982,24 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR ) break; case T_aux_axis_origin: - { - int x = parseBoardUnits( "auxiliary origin X" ); - int y = parseBoardUnits( "auxiliary origin Y" ); - // x, y are not evaluated left to right, since they are push on stack right to left - m_board->SetOriginAxisPosition( wxPoint( x, y ) ); - NeedRIGHT(); + { + int x = parseBoardUnits( "auxiliary origin X" ); + int y = parseBoardUnits( "auxiliary origin Y" ); + // m_board->SetAuxOrigin( wxPoint( x, y ) ); gets overwritten via SetDesignSettings below + designSettings.m_AuxOrigin = wxPoint( x, y ); + NeedRIGHT(); + } + break; + + case T_grid_origin: + { + int x = parseBoardUnits( "grid origin X" ); + int y = parseBoardUnits( "grid origin Y" ); + // m_board->SetGridOrigin( wxPoint( x, y ) ); gets overwritten SetDesignSettings below + designSettings.m_GridOrigin = wxPoint( x, y ); + NeedRIGHT(); + } break; - } case T_visible_elements: designSettings.SetVisibleElements( parseHex() ); @@ -997,17 +1007,17 @@ void PCB_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR ) break; case T_pcbplotparams: - { - PCB_PLOT_PARAMS plotParams; - PCB_PLOT_PARAMS_PARSER parser( reader ); + { + PCB_PLOT_PARAMS plotParams; + PCB_PLOT_PARAMS_PARSER parser( reader ); - plotParams.Parse( &parser ); - m_board->SetPlotOptions( plotParams ); + plotParams.Parse( &parser ); + m_board->SetPlotOptions( plotParams ); - // I don't know why but this seems to fix a problem in PCB_PLOT_PARAMS::Parse(). - NextTok(); + // I don't know why but this seems to fix a problem in PCB_PLOT_PARAMS::Parse(). + NextTok(); + } break; - } default: Unexpected( CurText() ); diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index a20e33fde7..2897af7bb3 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -683,7 +683,7 @@ static void initializePlotter( PLOTTER *aPlotter, BOARD * aBoard, else { if( aPlotOpts->GetUseAuxOrigin() ) - offset = aBoard->GetOriginAxisPosition(); + offset = aBoard->GetAuxOrigin(); } /* Configure the plotter object with all the stuff computed and diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index 32ee549465..d40a95a8b6 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -181,7 +181,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, if( old_name == new_name ) return 0; - /* Build CMP file name by changing the extension of NetList filename */ + // Build CMP file name by changing the extension of NetList filename fn = m_Parent->GetBoard()->GetFileName(); fn.SetExt( ComponentFileExtension ); @@ -456,11 +456,11 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module, wxBusyCursor dummy; - /* Copy parameters from the old module. */ + // Copy parameters from the old module. oldnamecmp = Module->GetLibRef(); namecmp = new_module; - /* Load module. */ + // Load module. line.Printf( _( "Change module %s (from %s) " ), GetChars( Module->GetReference() ), GetChars( oldnamecmp ) ); @@ -470,7 +470,7 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module, namecmp.Trim( false ); NewModule = m_Parent->GetModuleLibrary( wxEmptyString, namecmp, ShowError ); - if( NewModule == NULL ) /* New module not found, redraw the old one. */ + if( NewModule == NULL ) // New module not found, redraw the old one. { m_WinMessages->AppendText( wxT( "No\n" ) ); return false; @@ -507,36 +507,36 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule, aNewModule->SetParent( GetBoard() ); GetBoard()->m_Status_Pcb = 0; - oldpos = GetScreen()->GetCrossHairPosition(); - GetScreen()->SetCrossHairPosition( aOldModule->GetPosition(), false ); + oldpos = GetCrossHairPosition(); + SetCrossHairPosition( aOldModule->GetPosition(), false ); /* place module without ratsnest refresh: this will be made later * when all modules are on board */ PlaceModule( aNewModule, NULL, true ); - GetScreen()->SetCrossHairPosition( oldpos, false ); + SetCrossHairPosition( oldpos, false ); - /* Flip footprint if needed */ + // Flip footprint if needed if( aOldModule->GetLayer() != aNewModule->GetLayer() ) { aNewModule->Flip( aNewModule->GetPosition() ); } - /* Rotate footprint if needed */ + // Rotate footprint if needed if( aOldModule->GetOrientation() != aNewModule->GetOrientation() ) { Rotate_Module( NULL, aNewModule, aOldModule->GetOrientation(), false ); } - /* Update reference and value */ + // Update reference and value aNewModule->SetReference( aOldModule->GetReference() ); aNewModule->SetValue( aOldModule->GetValue() ); - /* Updating other parameters */ + // Updating other parameters aNewModule->SetTimeStamp( aOldModule->GetTimeStamp() ); aNewModule->SetPath( aOldModule->GetPath() ); - /* Update pad netnames ( when possible) */ + // Update pad netnames ( when possible) pad = aNewModule->Pads(); for( ; pad != NULL; pad = pad->Next() ) @@ -604,7 +604,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent ) return; } - /* Calculation file name by changing the extension name to NetList */ + // Calculation file name by changing the extension name to NetList fn = GetBoard()->GetFileName(); fn.SetExt( ComponentFileExtension ); wildcard = wxGetTranslation( ComponentFileWildcard ); diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index 9effa3977c..19dcfe5f2a 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -272,7 +272,7 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge( wxDC* DC, aZone->SetSelectedCorner( corner_id ); m_canvas->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse, Abort_Zone_Move_Corner_Or_Outlines ); - s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->GetCrossHairPosition(); + s_CursorLastPosition = s_CornerInitialPosition = GetCrossHairPosition(); s_AddCutoutToCurrentZone = false; s_CurrentZone = NULL; @@ -309,7 +309,7 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* aZone ) aZone->SetFlags( IS_MOVED ); m_canvas->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse, Abort_Zone_Move_Corner_Or_Outlines ); - s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->GetCrossHairPosition(); + s_CursorLastPosition = s_CornerInitialPosition = GetCrossHairPosition(); s_CornerIsNew = false; s_AddCutoutToCurrentZone = false; s_CurrentZone = NULL; @@ -470,7 +470,7 @@ void Show_Zone_Corner_Or_Outline_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* zone->Draw( aPanel, aDC, GR_XOR ); } - wxPoint pos = pcbframe->GetScreen()->GetCrossHairPosition(); + wxPoint pos = pcbframe->GetCrossHairPosition(); if( zone->IsMoving() ) { @@ -651,11 +651,11 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) zoneInfo.ExportSetting( *zone ); zone->Outline()->Start( zoneInfo.m_CurrentZone_Layer, - GetScreen()->GetCrossHairPosition().x, - GetScreen()->GetCrossHairPosition().y, + GetCrossHairPosition().x, + GetCrossHairPosition().y, zone->GetHatchStyle() ); - zone->AppendCorner( GetScreen()->GetCrossHairPosition() ); + zone->AppendCorner( GetCrossHairPosition() ); if( g_Drc_On && (m_drc->Drc( zone, 0 ) == BAD_DRC) && zone->IsOnCopperLayer() ) { @@ -687,7 +687,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) // Ok, we can add a new corner if( m_canvas->IsMouseCaptured() ) m_canvas->CallMouseCapture( DC, wxPoint(0,0), false ); - zone->AppendCorner( GetScreen()->GetCrossHairPosition() ); + zone->AppendCorner( GetCrossHairPosition() ); SetCurItem( zone ); // calls DisplayInfo(). if( m_canvas->IsMouseCaptured() ) m_canvas->CallMouseCapture( DC, wxPoint(0,0), false ); @@ -810,7 +810,7 @@ static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) aPanel->GetParent(); - wxPoint c_pos = pcbframe->GetScreen()->GetCrossHairPosition(); + wxPoint c_pos = pcbframe->GetCrossHairPosition(); ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour; if( !zone ) diff --git a/scripts/lib_convert.py b/scripts/lib_convert.py index 569b4ec26c..18abc72e19 100755 --- a/scripts/lib_convert.py +++ b/scripts/lib_convert.py @@ -13,8 +13,8 @@ # 3) Entered following command line, script takes to arguments: oldLibPath & newLibPath # $ PYTHONPATH=. /lib_convert.py /usr/local/share/kicad/modules/smd_dil.mod /tmp/smd_dil.pretty -# 4) inspect one footprint found in new librarypath /tmp/smd_dil -# $ less /tmp/smd_dil/msoic-10.kicad_mod +# 4) inspect one footprint found in new librarypath /tmp/smd_dil.pretty +# $ less /tmp/smd_dil.pretty/msoic-10.kicad_mod from __future__ import print_function From 76a604bc3536b4bf529dacfb92d5b1524aa71a77 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Sat, 3 Aug 2013 01:36:51 -0500 Subject: [PATCH 2/6] split expression into two lines for verification while using debugger that GetScreen() is a virtualized call. --- common/drawframe.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/common/drawframe.cpp b/common/drawframe.cpp index a05a9d8fc3..5c29adcfdd 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -930,55 +930,66 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU ) wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const { - return GetScreen()->getCrossHairPosition(); + // subject to change, borrow from old BASE_SCREEN for now. + + BASE_SCREEN* screen = GetScreen(); // virtual call + return screen->getCrossHairPosition(); } void EDA_DRAW_FRAME::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid ) { - GetScreen()->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid ); + BASE_SCREEN* screen = GetScreen(); // virtual call + screen->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid ); } wxPoint EDA_DRAW_FRAME::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize ) const { - return GetScreen()->getCursorPosition( aOnGrid, GetGridOrigin(), aGridSize ); + BASE_SCREEN* screen = GetScreen(); // virtual call + return screen->getCursorPosition( aOnGrid, GetGridOrigin(), aGridSize ); } wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize ) const { - return GetScreen()->getNearestGridPosition( aPosition, GetGridOrigin(), aGridSize ); + BASE_SCREEN* screen = GetScreen(); // virtual call + return screen->getNearestGridPosition( aPosition, GetGridOrigin(), aGridSize ); } wxPoint EDA_DRAW_FRAME::GetCrossHairScreenPosition() const { - return GetScreen()->getCrossHairScreenPosition(); + BASE_SCREEN* screen = GetScreen(); // virtual call + return screen->getCrossHairScreenPosition(); } void EDA_DRAW_FRAME::SetMousePosition( const wxPoint& aPosition ) { - GetScreen()->setMousePosition( aPosition ); + BASE_SCREEN* screen = GetScreen(); // virtual call + screen->setMousePosition( aPosition ); } wxPoint EDA_DRAW_FRAME::RefPos( bool useMouse ) const { - return GetScreen()->refPos( useMouse ); + BASE_SCREEN* screen = GetScreen(); // virtual call + return screen->refPos( useMouse ); } const wxPoint& EDA_DRAW_FRAME::GetScrollCenterPosition() const { - return GetScreen()->getScrollCenterPosition(); + BASE_SCREEN* screen = GetScreen(); // virtual call + return screen->getScrollCenterPosition(); } void EDA_DRAW_FRAME::SetScrollCenterPosition( const wxPoint& aPoint ) { - GetScreen()->setScrollCenterPosition( aPoint ); + BASE_SCREEN* screen = GetScreen(); // virtual call + screen->setScrollCenterPosition( aPoint ); } //------------------------------------------------- From d68c727b0fd6dc5023e2537f0002b1d9dfbbc530 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 3 Aug 2013 18:16:57 +0200 Subject: [PATCH 3/6] Pcbnew: add hotkey Z to reset grid origin. Save grid origin in .kicad_pcb files only if not 0,0 (to keep compatibility with previous versions of pcbnew, mainly the stable version) Very minor other fixes (set modify flag when grid origin is moved from the dialog grid) --- include/hotkeys_basic.h | 1 + pcbnew/dialogs/dialog_set_grid.cpp | 3 +++ pcbnew/hotkeys.cpp | 6 ++++-- pcbnew/hotkeys.h | 4 +++- pcbnew/hotkeys_board_editor.cpp | 6 ++++++ pcbnew/hotkeys_module_editor.cpp | 5 +++++ pcbnew/kicad_plugin.cpp | 7 ++++--- pcbnew/menubar_pcbframe.cpp | 4 ++-- 8 files changed, 28 insertions(+), 8 deletions(-) diff --git a/include/hotkeys_basic.h b/include/hotkeys_basic.h index 65f53dc483..f070441de4 100644 --- a/include/hotkeys_basic.h +++ b/include/hotkeys_basic.h @@ -218,6 +218,7 @@ enum common_hotkey_id_commnand { HK_NOT_FOUND = 0, HK_RESET_LOCAL_COORD, HK_SET_GRID_ORIGIN, + HK_RESET_GRID_ORIGIN, HK_HELP, HK_ZOOM_IN, HK_ZOOM_OUT, diff --git a/pcbnew/dialogs/dialog_set_grid.cpp b/pcbnew/dialogs/dialog_set_grid.cpp index 154088cd3a..d22890b572 100644 --- a/pcbnew/dialogs/dialog_set_grid.cpp +++ b/pcbnew/dialogs/dialog_set_grid.cpp @@ -211,6 +211,9 @@ bool PCB_BASE_FRAME::InvokeDialogGrid() if( ret == wxID_OK ) { + if( GetGridOrigin() != grid_origin && IsType( PCB_FRAME_TYPE ) ) + OnModify(); // because grid origin is saved in board, show as modified + SetGridOrigin( grid_origin ); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index 8186af3d14..c0a3830388 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -55,6 +55,7 @@ static EDA_HOTKEY HkSwitch2PreviousCopperLayer( wxT( "Switch to Previous Layer" static EDA_HOTKEY HkSaveModule( wxT( "Save Module" ), HK_SAVE_MODULE, 'S' + GR_KB_CTRL ); static EDA_HOTKEY HkSavefile( wxT( "Save board" ), HK_SAVE_BOARD, 'S' + GR_KB_CTRL ); +static EDA_HOTKEY HkSavefileAs( wxT( "Save board as" ), HK_SAVE_BOARD_AS, 'S' + GR_KB_CTRL + GR_KB_SHIFT ); static EDA_HOTKEY HkLoadfile( wxT( "Load board" ), HK_LOAD_BOARD, 'L' + GR_KB_CTRL ); static EDA_HOTKEY HkFindItem( wxT( "Find Item" ), HK_FIND_ITEM, 'F' + GR_KB_CTRL ); static EDA_HOTKEY HkBackspace( wxT( "Delete track segment" ), HK_BACK_SPACE, WXK_BACK ); @@ -78,6 +79,7 @@ static EDA_HOTKEY HkResetLocalCoord( wxT( "Reset Local Coordinates" ), HK_RESET_ static EDA_HOTKEY HkSwitchHighContrastMode( wxT("Switch Highcontrast mode"), HK_SWITCH_HIGHCONTRAST_MODE,'H'); static EDA_HOTKEY HkSetGridOrigin( wxT("Set Grid Origin"), HK_SET_GRID_ORIGIN, 'S' ); +static EDA_HOTKEY HkResetGridOrigin( wxT("Reset Grid Origin"), HK_RESET_GRID_ORIGIN, 'Z' ); /* Fit on Screen */ #if !defined( __WXMAC__ ) @@ -195,7 +197,7 @@ EDA_HOTKEY* common_Hotkey_List[] = { &HkHelp, &HkZoomIn, &HkZoomOut, &HkZoomRedraw, &HkZoomCenter, &HkZoomAuto, - &HkSwitchUnits, &HkResetLocalCoord, &HkSetGridOrigin, + &HkSwitchUnits, &HkResetLocalCoord, &HkSetGridOrigin, &HkResetGridOrigin, &HkUndo, &HkRedo, NULL }; @@ -211,7 +213,7 @@ EDA_HOTKEY* board_edit_Hotkey_List[] = &HkPlaceItem, &HkCopyItem, &HkEndTrack, &HkMoveItem, &HkFlipItem, &HkRotateItem, &HkDragFootprint, - &HkGetAndMoveFootprint, &HkLock_Unlock_Footprint, &HkSavefile, + &HkGetAndMoveFootprint, &HkLock_Unlock_Footprint, &HkSavefile, &HkSavefileAs, &HkLoadfile, &HkFindItem, &HkEditBoardItem, &HkSwitch2CopperLayer, &HkSwitch2InnerLayer1, &HkSwitch2InnerLayer2, &HkSwitch2InnerLayer3, &HkSwitch2InnerLayer4, diff --git a/pcbnew/hotkeys.h b/pcbnew/hotkeys.h index 98e18fb565..dca43f3aa0 100644 --- a/pcbnew/hotkeys.h +++ b/pcbnew/hotkeys.h @@ -26,7 +26,9 @@ enum hotkey_id_commnand { HK_SWITCH_TRACK_POSTURE, HK_DRAG_TRACK_KEEP_SLOPE, HK_END_TRACK, - HK_SAVE_BOARD, HK_LOAD_BOARD, + HK_SAVE_BOARD, + HK_SAVE_BOARD_AS, + HK_LOAD_BOARD, HK_SAVE_MODULE, HK_SWITCH_UNITS, HK_SWITCH_TRACK_DISPLAY_MODE, diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index 2d46178a47..b3cc0893b0 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -351,6 +351,12 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit m_canvas->Refresh(); break; + case HK_RESET_GRID_ORIGIN: + SetGridOrigin( wxPoint(0,0) ); + OnModify(); // because grid origin is saved in board, show as modified + m_canvas->Refresh(); + break; + case HK_SWITCH_UNITS: evt_type = (g_UserUnit == INCHES) ? ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH; diff --git a/pcbnew/hotkeys_module_editor.cpp b/pcbnew/hotkeys_module_editor.cpp index 978f8a3a3c..0bff61af9e 100644 --- a/pcbnew/hotkeys_module_editor.cpp +++ b/pcbnew/hotkeys_module_editor.cpp @@ -64,6 +64,11 @@ void FOOTPRINT_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPos m_canvas->Refresh(); break; + case HK_RESET_GRID_ORIGIN: + SetGridOrigin( wxPoint(0,0) ); + m_canvas->Refresh(); + break; + case HK_SWITCH_UNITS: cmd.SetId( (g_UserUnit == INCHES) ? ID_TB_OPTIONS_SELECT_UNIT_MM : ID_TB_OPTIONS_SELECT_UNIT_INCH ); diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index d987948d71..d6bc8f87e7 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -560,9 +560,10 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const FMTIU( aBoard->GetAuxOrigin().x ).c_str(), FMTIU( aBoard->GetAuxOrigin().y ).c_str() ); - m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n", - FMTIU( aBoard->GetGridOrigin().x ).c_str(), - FMTIU( aBoard->GetGridOrigin().y ).c_str() ); + if( aBoard->GetGridOrigin().x || aBoard->GetGridOrigin().y ) + m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n", + FMTIU( aBoard->GetGridOrigin().x ).c_str(), + FMTIU( aBoard->GetGridOrigin().y ).c_str() ); m_out->Print( aNestLevel+1, "(visible_elements %X)\n", aBoard->GetDesignSettings().GetVisibleElements() ); diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index b3d732d934..a63c652b5a 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -105,8 +105,8 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() KiBitmap( save_xpm ) ); // Save As - AddMenuItem( filesMenu, ID_SAVE_BOARD_AS, - _( "Sa&ve As...\tCtrl+Shift+S" ), + text = AddHotkeyName( _( "Sa&ve As..." ), g_Board_Editor_Hokeys_Descr, HK_SAVE_BOARD_AS ); + AddMenuItem( filesMenu, ID_SAVE_BOARD_AS, text, _( "Save the current board as..." ), KiBitmap( save_as_xpm ) ); filesMenu->AppendSeparator(); From 1b5a1b74fac1b5e23820c4318ffbb8bfb4f01431 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Sat, 3 Aug 2013 13:57:15 -0500 Subject: [PATCH 4/6] fix interface mapping slip-up in wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const --- common/drawframe.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 5c29adcfdd..ac0669ef7d 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -720,12 +720,9 @@ void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU ) { BASE_SCREEN* screen = GetScreen(); - if( screen == NULL || m_canvas == NULL ) + if( !screen || !m_canvas ) return; - // There are no safety limits on these calculations, so in NANOMETRES build it - // still blows up. This is incomplete work. - double scale = screen->GetScalingFactor(); wxLogTrace( traceScrollSettings, wxT( "Center Position = ( %d, %d ), scale = %.10g" ), @@ -933,7 +930,7 @@ wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const // subject to change, borrow from old BASE_SCREEN for now. BASE_SCREEN* screen = GetScreen(); // virtual call - return screen->getCrossHairPosition(); + return screen->getCrossHairPosition( aInvertY ); } From 790e0ef36cb6172d0b34dc4d4adb06f5945e2502 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Sat, 3 Aug 2013 15:20:55 -0500 Subject: [PATCH 5/6] ReturnStringFromValue() refinements --- common/base_screen.cpp | 2 +- common/base_units.cpp | 24 ++++++++++++++++++++++-- include/class_base_screen.h | 8 ++++---- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/common/base_screen.cpp b/common/base_screen.cpp index a47f21386d..717154b2e3 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -337,7 +337,7 @@ wxPoint BASE_SCREEN::getCrossHairScreenPosition() const void BASE_SCREEN::setCrossHairPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin, bool aSnapToGrid ) { if( aSnapToGrid ) - m_crossHairPosition = getNearestGridPosition( aPosition, aGridOrigin ); + m_crossHairPosition = getNearestGridPosition( aPosition, aGridOrigin, NULL ); else m_crossHairPosition = aPosition; } diff --git a/common/base_units.cpp b/common/base_units.cpp index 76dcc5d8c1..09a2ab9bd0 100644 --- a/common/base_units.cpp +++ b/common/base_units.cpp @@ -209,8 +209,28 @@ wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymb StripTrailingZeros( stringValue, 3 ); #else - std::string s = Double2Str( value_to_print ); - wxString stringValue = FROM_UTF8( s.c_str() ); + + char buf[50]; + int len; + + if( value_to_print != 0.0 && fabs( value_to_print ) <= 0.0001 ) + { + len = sprintf( buf, "%.10f", value_to_print ); + + while( --len > 0 && buf[len] == '0' ) + buf[len] = '\0'; + + if( buf[len]=='.' || buf[len]==',' ) + buf[len] = '\0'; + else + ++len; + } + else + { + len = sprintf( buf, "%.10g", value_to_print ); + } + + wxString stringValue( buf, wxConvUTF8 ); #endif diff --git a/include/class_base_screen.h b/include/class_base_screen.h index 537b277bfe..6d133982a9 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -102,7 +102,7 @@ private: * @param aInvertY Inverts the Y axis position. * @return The cross hair position in drawing coordinates. */ - wxPoint getCrossHairPosition( bool aInvertY = false ) const + wxPoint getCrossHairPosition( bool aInvertY ) const { if( aInvertY ) return wxPoint( m_crossHairPosition.x, -m_crossHairPosition.y ); @@ -119,7 +119,7 @@ private: * \a aPosition. * */ - void setCrossHairPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin, bool aSnapToGrid = true ); + void setCrossHairPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin, bool aSnapToGrid ); /** * Function getCursorScreenPosition @@ -138,7 +138,7 @@ private: * @return The nearst grid position. */ wxPoint getNearestGridPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin, - wxRealPoint* aGridSize = NULL ) const; + wxRealPoint* aGridSize ) const; /** * Function getCursorPosition @@ -149,7 +149,7 @@ private: * if \a aOnGrid is true. * @return The current cursor position. */ - wxPoint getCursorPosition( bool aOnGrid, const wxPoint& aGridOrigin, wxRealPoint* aGridSize = NULL ) const; + wxPoint getCursorPosition( bool aOnGrid, const wxPoint& aGridOrigin, wxRealPoint* aGridSize ) const; void setMousePosition( const wxPoint& aPosition ) { m_MousePosition = aPosition; } From c99243ffc5c9e700e35dfc83fd1a3b9677174837 Mon Sep 17 00:00:00 2001 From: Brian Sidebotham Date: Sun, 4 Aug 2013 21:31:14 +0100 Subject: [PATCH 6/6] * Added modified CMake FindPython... modules to support using Python-a-mingw-us distribution when building Windows scripting support using MinGW --- CMakeLists.txt | 2 +- CMakeModules/CMakeFindFrameworks.cmake | 32 ++ .../FindPackageHandleStandardArgs.cmake | 260 ++++++++++++++ CMakeModules/FindPythonInterp.cmake | 175 +++++++++ CMakeModules/FindPythonLibs.cmake | 338 ++++++++++++++++++ CMakeModules/PerformFeatureChecks.cmake | 12 + .../SelectLibraryConfigurations.cmake | 87 +++++ 7 files changed, 905 insertions(+), 1 deletion(-) create mode 100644 CMakeModules/CMakeFindFrameworks.cmake create mode 100644 CMakeModules/FindPackageHandleStandardArgs.cmake create mode 100644 CMakeModules/FindPythonInterp.cmake create mode 100644 CMakeModules/FindPythonLibs.cmake create mode 100644 CMakeModules/SelectLibraryConfigurations.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 559397b60b..0dbf597ebf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -323,7 +323,7 @@ if(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES) mark_as_advanced(PYTHON_DEST) message( STATUS "Python module install path: ${PYTHON_DEST}") find_package(PythonLibs) - include_directories(${PYTHON_INCLUDE_PATH} + include_directories(${PYTHON_INCLUDE_DIRS} ./scripting) endif(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES) diff --git a/CMakeModules/CMakeFindFrameworks.cmake b/CMakeModules/CMakeFindFrameworks.cmake new file mode 100644 index 0000000000..7fdeb84bef --- /dev/null +++ b/CMakeModules/CMakeFindFrameworks.cmake @@ -0,0 +1,32 @@ +# - helper module to find OSX frameworks + +#============================================================================= +# Copyright 2003-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +if(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED) + set(CMAKE_FIND_FRAMEWORKS_INCLUDED 1) + macro(CMAKE_FIND_FRAMEWORKS fwk) + set(${fwk}_FRAMEWORKS) + if(APPLE) + foreach(dir + ~/Library/Frameworks/${fwk}.framework + /Library/Frameworks/${fwk}.framework + /System/Library/Frameworks/${fwk}.framework + /Network/Library/Frameworks/${fwk}.framework) + if(EXISTS ${dir}) + set(${fwk}_FRAMEWORKS ${${fwk}_FRAMEWORKS} ${dir}) + endif() + endforeach() + endif() + endmacro() +endif() diff --git a/CMakeModules/FindPackageHandleStandardArgs.cmake b/CMakeModules/FindPackageHandleStandardArgs.cmake new file mode 100644 index 0000000000..1acb021e80 --- /dev/null +++ b/CMakeModules/FindPackageHandleStandardArgs.cmake @@ -0,0 +1,260 @@ +# FIND_PACKAGE_HANDLE_STANDARD_ARGS( ... ) +# +# This function is intended to be used in FindXXX.cmake modules files. +# It handles the REQUIRED, QUIET and version-related arguments to FIND_PACKAGE(). +# It also sets the _FOUND variable. +# The package is considered found if all variables ... listed contain +# valid results, e.g. valid filepaths. +# +# There are two modes of this function. The first argument in both modes is +# the name of the Find-module where it is called (in original casing). +# +# The first simple mode looks like this: +# FIND_PACKAGE_HANDLE_STANDARD_ARGS( (DEFAULT_MSG|"Custom failure message") ... ) +# If the variables to are all valid, then _FOUND +# will be set to TRUE. +# If DEFAULT_MSG is given as second argument, then the function will generate +# itself useful success and error messages. You can also supply a custom error message +# for the failure case. This is not recommended. +# +# The second mode is more powerful and also supports version checking: +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME [REQUIRED_VARS ...] +# [VERSION_VAR +# [CONFIG_MODE] +# [FAIL_MESSAGE "Custom failure message"] ) +# +# As above, if through are all valid, _FOUND +# will be set to TRUE. +# After REQUIRED_VARS the variables which are required for this package are listed. +# Following VERSION_VAR the name of the variable can be specified which holds +# the version of the package which has been found. If this is done, this version +# will be checked against the (potentially) specified required version used +# in the find_package() call. The EXACT keyword is also handled. The default +# messages include information about the required version and the version +# which has been actually found, both if the version is ok or not. +# Use the option CONFIG_MODE if your FindXXX.cmake module is a wrapper for +# a find_package(... NO_MODULE) call, in this case all the information +# provided by the config-mode of find_package() will be evaluated +# automatically. +# Via FAIL_MESSAGE a custom failure message can be specified, if this is not +# used, the default message will be displayed. +# +# Example for mode 1: +# +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) +# +# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and +# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE. +# If it is not found and REQUIRED was used, it fails with FATAL_ERROR, +# independent whether QUIET was used or not. +# If it is found, success will be reported, including the content of . +# On repeated Cmake runs, the same message won't be printed again. +# +# Example for mode 2: +# +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(BISON REQUIRED_VARS BISON_EXECUTABLE +# VERSION_VAR BISON_VERSION) +# In this case, BISON is considered to be found if the variable(s) listed +# after REQUIRED_VAR are all valid, i.e. BISON_EXECUTABLE in this case. +# Also the version of BISON will be checked by using the version contained +# in BISON_VERSION. +# Since no FAIL_MESSAGE is given, the default messages will be printed. +# +# Another example for mode 2: +# +# FIND_PACKAGE(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(Automoc4 CONFIG_MODE) +# In this case, FindAutmoc4.cmake wraps a call to FIND_PACKAGE(Automoc4 NO_MODULE) +# and adds an additional search directory for automoc4. +# The following FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper +# success/error message. + +#============================================================================= +# Copyright 2007-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +INCLUDE(FindPackageMessage) +INCLUDE(CMakeParseArguments) + +# internal helper macro +MACRO(_FPHSA_FAILURE_MESSAGE _msg) + IF (${_NAME}_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "${_msg}") + ELSE (${_NAME}_FIND_REQUIRED) + IF (NOT ${_NAME}_FIND_QUIETLY) + MESSAGE(STATUS "${_msg}") + ENDIF (NOT ${_NAME}_FIND_QUIETLY) + ENDIF (${_NAME}_FIND_REQUIRED) +ENDMACRO(_FPHSA_FAILURE_MESSAGE _msg) + + +# internal helper macro to generate the failure message when used in CONFIG_MODE: +MACRO(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) + # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: + IF(${_NAME}_CONFIG) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") + ELSE(${_NAME}_CONFIG) + # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. + # List them all in the error message: + IF(${_NAME}_CONSIDERED_CONFIGS) + SET(configsText "") + LIST(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) + MATH(EXPR configsCount "${configsCount} - 1") + FOREACH(currentConfigIndex RANGE ${configsCount}) + LIST(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) + LIST(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) + SET(configsText "${configsText} ${filename} (version ${version})\n") + ENDFOREACH(currentConfigIndex) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") + + ELSE(${_NAME}_CONSIDERED_CONFIGS) + # Simple case: No Config-file was found at all: + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") + ENDIF(${_NAME}_CONSIDERED_CONFIGS) + ENDIF(${_NAME}_CONFIG) +ENDMACRO(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) + + +FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) + +# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in +# new extended or in the "old" mode: + SET(options CONFIG_MODE) + SET(oneValueArgs FAIL_MESSAGE VERSION_VAR) + SET(multiValueArgs REQUIRED_VARS) + SET(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) + LIST(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) + + IF(${INDEX} EQUAL -1) + SET(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) + SET(FPHSA_REQUIRED_VARS ${ARGN}) + SET(FPHSA_VERSION_VAR) + ELSE(${INDEX} EQUAL -1) + + CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) + + IF(FPHSA_UNPARSED_ARGUMENTS) + MESSAGE(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") + ENDIF(FPHSA_UNPARSED_ARGUMENTS) + + IF(NOT FPHSA_FAIL_MESSAGE) + SET(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") + ENDIF(NOT FPHSA_FAIL_MESSAGE) + ENDIF(${INDEX} EQUAL -1) + +# now that we collected all arguments, process them + + IF("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") + SET(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") + ENDIF("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") + + # In config-mode, we rely on the variable _CONFIG, which is set by find_package() + # when it successfully found the config-file, including version checking: + IF(FPHSA_CONFIG_MODE) + LIST(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) + LIST(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) + SET(FPHSA_VERSION_VAR ${_NAME}_VERSION) + ENDIF(FPHSA_CONFIG_MODE) + + IF(NOT FPHSA_REQUIRED_VARS) + MESSAGE(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") + ENDIF(NOT FPHSA_REQUIRED_VARS) + + LIST(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) + + STRING(TOUPPER ${_NAME} _NAME_UPPER) + STRING(TOLOWER ${_NAME} _NAME_LOWER) + + # collect all variables which were not found, so they can be printed, so the + # user knows better what went wrong (#6375) + SET(MISSING_VARS "") + SET(DETAILS "") + SET(${_NAME_UPPER}_FOUND TRUE) + # check if all passed variables are valid + FOREACH(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) + IF(NOT ${_CURRENT_VAR}) + SET(${_NAME_UPPER}_FOUND FALSE) + SET(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}") + ELSE(NOT ${_CURRENT_VAR}) + SET(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]") + ENDIF(NOT ${_CURRENT_VAR}) + ENDFOREACH(_CURRENT_VAR) + + + # version handling: + SET(VERSION_MSG "") + SET(VERSION_OK TRUE) + SET(VERSION ${${FPHSA_VERSION_VAR}} ) + IF (${_NAME}_FIND_VERSION) + + IF(VERSION) + + IF(${_NAME}_FIND_VERSION_EXACT) # exact version required + IF (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + SET(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") + SET(VERSION_OK FALSE) + ELSE (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + SET(VERSION_MSG "(found suitable exact version \"${VERSION}\")") + ENDIF (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + + ELSE(${_NAME}_FIND_VERSION_EXACT) # minimum version specified: + IF ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + SET(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") + SET(VERSION_OK FALSE) + ELSE ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + SET(VERSION_MSG "(found suitable version \"${VERSION}\", required is \"${${_NAME}_FIND_VERSION}\")") + ENDIF ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + ENDIF(${_NAME}_FIND_VERSION_EXACT) + + ELSE(VERSION) + + # if the package was not found, but a version was given, add that to the output: + IF(${_NAME}_FIND_VERSION_EXACT) + SET(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") + ELSE(${_NAME}_FIND_VERSION_EXACT) + SET(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") + ENDIF(${_NAME}_FIND_VERSION_EXACT) + + ENDIF(VERSION) + ELSE (${_NAME}_FIND_VERSION) + IF(VERSION) + SET(VERSION_MSG "(found version \"${VERSION}\")") + ENDIF(VERSION) + ENDIF (${_NAME}_FIND_VERSION) + + IF(VERSION_OK) + SET(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]") + ELSE(VERSION_OK) + SET(${_NAME_UPPER}_FOUND FALSE) + ENDIF(VERSION_OK) + + + # print the result: + IF (${_NAME_UPPER}_FOUND) + FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG}" "${DETAILS}") + ELSE (${_NAME_UPPER}_FOUND) + + IF(FPHSA_CONFIG_MODE) + _FPHSA_HANDLE_FAILURE_CONFIG_MODE() + ELSE(FPHSA_CONFIG_MODE) + IF(NOT VERSION_OK) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") + ELSE(NOT VERSION_OK) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") + ENDIF(NOT VERSION_OK) + ENDIF(FPHSA_CONFIG_MODE) + + ENDIF (${_NAME_UPPER}_FOUND) + + SET(${_NAME_UPPER}_FOUND ${${_NAME_UPPER}_FOUND} PARENT_SCOPE) + +ENDFUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _FIRST_ARG) diff --git a/CMakeModules/FindPythonInterp.cmake b/CMakeModules/FindPythonInterp.cmake new file mode 100644 index 0000000000..b2261f1466 --- /dev/null +++ b/CMakeModules/FindPythonInterp.cmake @@ -0,0 +1,175 @@ +# - Find python interpreter +# This module finds if Python interpreter is installed and determines where the +# executables are. This code sets the following variables: +# +# PYTHONINTERP_FOUND - Was the Python executable found +# PYTHON_EXECUTABLE - path to the Python interpreter +# +# PYTHON_VERSION_STRING - Python version found e.g. 2.5.2 +# PYTHON_VERSION_MAJOR - Python major version found e.g. 2 +# PYTHON_VERSION_MINOR - Python minor version found e.g. 5 +# PYTHON_VERSION_PATCH - Python patch version found e.g. 2 +# +# The Python_ADDITIONAL_VERSIONS variable can be used to specify a list of +# version numbers that should be taken into account when searching for Python. +# You need to set this variable before calling find_package(PythonInterp). +# +# You can point to a preferred python install to use by setting the following +# to the point at the root directory of the python install: +# +# PYTHON_ROOT_DIR - The root directory of the python install +#============================================================================= +# Copyright 2005-2010 Kitware, Inc. +# Copyright 2011 Bjoern Ricks +# Copyright 2012 Rolf Eike Beer +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +unset(_Python_NAMES) + +set(_PYTHON1_VERSIONS 1.6 1.5) +set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) +set(_PYTHON3_VERSIONS 3.3 3.2 3.1 3.0) + +if(PythonInterp_FIND_VERSION) + if(PythonInterp_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$") + string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" _PYTHON_FIND_MAJ_MIN "${PythonInterp_FIND_VERSION}") + string(REGEX REPLACE "^([0-9]+).*" "\\1" _PYTHON_FIND_MAJ "${_PYTHON_FIND_MAJ_MIN}") + list(APPEND _Python_NAMES python${_PYTHON_FIND_MAJ_MIN} python${_PYTHON_FIND_MAJ}) + unset(_PYTHON_FIND_OTHER_VERSIONS) + if(NOT PythonInterp_FIND_VERSION_EXACT) + foreach(_PYTHON_V ${_PYTHON${_PYTHON_FIND_MAJ}_VERSIONS}) + if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN) + list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V}) + endif() + endforeach() + endif() + unset(_PYTHON_FIND_MAJ_MIN) + unset(_PYTHON_FIND_MAJ) + else() + list(APPEND _Python_NAMES python${PythonInterp_FIND_VERSION}) + set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonInterp_FIND_VERSION}_VERSIONS}) + endif() +else() + set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS}) +endif() + +list(APPEND _Python_NAMES python) + +# Search for the preferred executable first +if( ${PYTHON_ROOT_DIR} ) + # Search for any of the executable names solely in the directory we've + # been pointed to. Failure to find the python executable here is a fatal + # fail. + find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES} + PATHS ${PYTHON_ROOT_DIR} + NO_DEFAULT_PATH ) +else() + # If there is no specific path given, look for python in the path + find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES}) +endif() + +# Set up the versions we know about, in the order we will search. Always add +# the user supplied additional versions to the front. +set(_Python_VERSIONS + ${Python_ADDITIONAL_VERSIONS} + ${_PYTHON_FIND_OTHER_VERSIONS} + ) + +unset(_PYTHON_FIND_OTHER_VERSIONS) +unset(_PYTHON1_VERSIONS) +unset(_PYTHON2_VERSIONS) +unset(_PYTHON3_VERSIONS) + +# Search for newest python version if python executable isn't found +if(NOT PYTHON_EXECUTABLE) + + # If using the MINGW compiler, we mustn't find the standard python + # distribution because of multiple C-Runtime errors. We must instead + # use the Python-a-mingw-us distribution + if(MINGW) + list( APPEND _Python_PPATHS ${PYTHON_ROOT_DIR} ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.9" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.8" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.7" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.6" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.5" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.4" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.3" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.2" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.1" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.0" ) + else() + list( APPEND _Python_PPATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] ) + endif() + + foreach(_CURRENT_VERSION ${_Python_VERSIONS}) + set(_Python_NAMES python${_CURRENT_VERSION}) + if(WIN32) + list(APPEND _Python_NAMES python) + endif() + find_program(PYTHON_EXECUTABLE + NAMES ${_Python_NAMES} + PATHS ${_Python_PPATHS} + ) + endforeach() +endif() + +# determine python version string +if(PYTHON_EXECUTABLE) + execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c + "import sys; sys.stdout.write(';'.join([str(x) for x in sys.version_info[:3]]))" + OUTPUT_VARIABLE _VERSION + RESULT_VARIABLE _PYTHON_VERSION_RESULT + ERROR_QUIET) + if(NOT _PYTHON_VERSION_RESULT) + string(REPLACE ";" "." PYTHON_VERSION_STRING "${_VERSION}") + list(GET _VERSION 0 PYTHON_VERSION_MAJOR) + list(GET _VERSION 1 PYTHON_VERSION_MINOR) + list(GET _VERSION 2 PYTHON_VERSION_PATCH) + if(PYTHON_VERSION_PATCH EQUAL 0) + # it's called "Python 2.7", not "2.7.0" + string(REGEX REPLACE "\\.0$" "" PYTHON_VERSION_STRING "${PYTHON_VERSION_STRING}") + endif() + else() + # sys.version predates sys.version_info, so use that + execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.version)" + OUTPUT_VARIABLE _VERSION + RESULT_VARIABLE _PYTHON_VERSION_RESULT + ERROR_QUIET) + if(NOT _PYTHON_VERSION_RESULT) + string(REGEX REPLACE " .*" "" PYTHON_VERSION_STRING "${_VERSION}") + string(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}") + string(REGEX REPLACE "^[0-9]+\\.([0-9])+.*" "\\1" PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}") + if(PYTHON_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+.*") + string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PYTHON_VERSION_PATCH "${PYTHON_VERSION_STRING}") + else() + set(PYTHON_VERSION_PATCH "0") + endif() + else() + # sys.version was first documented for Python 1.5, so assume + # this is older. + set(PYTHON_VERSION_STRING "1.4") + set(PYTHON_VERSION_MAJOR "1") + set(PYTHON_VERSION_MAJOR "4") + set(PYTHON_VERSION_MAJOR "0") + endif() + endif() + unset(_PYTHON_VERSION_RESULT) + unset(_VERSION) +endif() + +# handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if +# all listed variables are TRUE +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonInterp REQUIRED_VARS PYTHON_EXECUTABLE VERSION_VAR PYTHON_VERSION_STRING) + +mark_as_advanced(PYTHON_EXECUTABLE) diff --git a/CMakeModules/FindPythonLibs.cmake b/CMakeModules/FindPythonLibs.cmake new file mode 100644 index 0000000000..e2f73d8ea4 --- /dev/null +++ b/CMakeModules/FindPythonLibs.cmake @@ -0,0 +1,338 @@ +# - Find python libraries +# This module finds if Python is installed and determines where the +# include files and libraries are. It also determines what the name of +# the library is. This code sets the following variables: +# +# PYTHONLIBS_FOUND - have the Python libs been found +# PYTHON_LIBRARIES - path to the python library +# PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated) +# PYTHON_INCLUDE_DIRS - path to where Python.h is found +# PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated) +# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8) +# +# The Python_ADDITIONAL_VERSIONS variable can be used to specify a list of +# version numbers that should be taken into account when searching for Python. +# You need to set this variable before calling find_package(PythonLibs). +# +# You can point to a preferred python install to use by setting the following +# to the point at the root directory of the python install: +# +# PYTHON_ROOT_DIR - The root directory of the python install +# +# If you'd like to specify the installation of Python to use, you should modify +# the following cache variables: +# PYTHON_LIBRARY - path to the python library +# PYTHON_INCLUDE_DIR - path to where Python.h is found + +#============================================================================= +# Copyright 2001-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindFrameworks.cmake) +# Search for the python framework on Apple. +CMAKE_FIND_FRAMEWORKS(Python) + +set(_PYTHON1_VERSIONS 1.6 1.5) +set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) +set(_PYTHON3_VERSIONS 3.3 3.2 3.1 3.0) + +if(PythonLibs_FIND_VERSION) + if(PythonLibs_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$") + string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" _PYTHON_FIND_MAJ_MIN "${PythonLibs_FIND_VERSION}") + string(REGEX REPLACE "^([0-9]+).*" "\\1" _PYTHON_FIND_MAJ "${_PYTHON_FIND_MAJ_MIN}") + unset(_PYTHON_FIND_OTHER_VERSIONS) + if(PythonLibs_FIND_VERSION_EXACT) + if(_PYTHON_FIND_MAJ_MIN STREQUAL PythonLibs_FIND_VERSION) + set(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}") + else() + set(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}" "${_PYTHON_FIND_MAJ_MIN}") + endif() + else() + foreach(_PYTHON_V ${_PYTHON${_PYTHON_FIND_MAJ}_VERSIONS}) + if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN) + list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V}) + endif() + endforeach() + endif() + unset(_PYTHON_FIND_MAJ_MIN) + unset(_PYTHON_FIND_MAJ) + else() + set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonLibs_FIND_VERSION}_VERSIONS}) + endif() +else() + set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS}) +endif() + +# Set up the versions we know about, in the order we will search. Always add +# the user supplied additional versions to the front. +set(_Python_VERSIONS + ${Python_ADDITIONAL_VERSIONS} + ${_PYTHON_FIND_OTHER_VERSIONS} + ) + +unset(_PYTHON_FIND_OTHER_VERSIONS) +unset(_PYTHON1_VERSIONS) +unset(_PYTHON2_VERSIONS) +unset(_PYTHON3_VERSIONS) + +foreach(_CURRENT_VERSION ${_Python_VERSIONS}) + string(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION}) + if(WIN32) + if(MINGW) + find_library(PYTHON_DEBUG_LIBRARY + NAMES python{$_CURRENT_VERSION}_d + PATHS + "${PYTHON_ROOT_DIR}" + "C:/python/${_CURRENT_VERSION}.9" + "C:/python/${_CURRENT_VERSION}.8" + "C:/python/${_CURRENT_VERSION}.7" + "C:/python/${_CURRENT_VERSION}.6" + "C:/python/${_CURRENT_VERSION}.5" + "C:/python/${_CURRENT_VERSION}.4" + "C:/python/${_CURRENT_VERSION}.3" + "C:/python/${_CURRENT_VERSION}.2" + "C:/python/${_CURRENT_VERSION}.1" + "C:/python/${_CURRENT_VERSION}.0" + NO_SYSTEM_ENVIRONMENT_PATH + ) + else() + find_library(PYTHON_DEBUG_LIBRARY + NAMES python${_CURRENT_VERSION_NO_DOTS}_d python + PATHS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + ) + endif() + endif() + + if(MINGW) + find_library(PYTHON_LIBRARY + NAMES python${_CURRENT_VERSION} + PATHS + "${PYTHON_ROOT_DIR}" + "C:/python/${_CURRENT_VERSION}.9" + "C:/python/${_CURRENT_VERSION}.8" + "C:/python/${_CURRENT_VERSION}.7" + "C:/python/${_CURRENT_VERSION}.6" + "C:/python/${_CURRENT_VERSION}.5" + "C:/python/${_CURRENT_VERSION}.4" + "C:/python/${_CURRENT_VERSION}.3" + "C:/python/${_CURRENT_VERSION}.2" + "C:/python/${_CURRENT_VERSION}.1" + "C:/python/${_CURRENT_VERSION}.0" + NO_SYSTEM_ENVIRONMENT_PATH + ) + else() + find_library(PYTHON_LIBRARY + NAMES + python${_CURRENT_VERSION_NO_DOTS} + python${_CURRENT_VERSION}mu + python${_CURRENT_VERSION}m + python${_CURRENT_VERSION}u + python${_CURRENT_VERSION} + PATHS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + # Avoid finding the .dll in the PATH. We want the .lib. + NO_SYSTEM_ENVIRONMENT_PATH + ) + endif() + + # Look for the static library in the Python config directory + find_library(PYTHON_LIBRARY + NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION} + # Avoid finding the .dll in the PATH. We want the .lib. + NO_SYSTEM_ENVIRONMENT_PATH + # This is where the static library is usually located + PATH_SUFFIXES python${_CURRENT_VERSION}/config + ) + + + # For backward compatibility, honour value of PYTHON_INCLUDE_PATH, if + # PYTHON_INCLUDE_DIR is not set. + if(DEFINED PYTHON_INCLUDE_PATH AND NOT DEFINED PYTHON_INCLUDE_DIR) + set(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}" CACHE PATH + "Path to where Python.h is found" FORCE) + endif() + + set(PYTHON_FRAMEWORK_INCLUDES) + if(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR) + foreach(dir ${Python_FRAMEWORKS}) + set(PYTHON_FRAMEWORK_INCLUDES ${PYTHON_FRAMEWORK_INCLUDES} + ${dir}/Versions/${_CURRENT_VERSION}/include/python${_CURRENT_VERSION}) + endforeach() + endif() + + if(MINGW) + find_path(PYTHON_INCLUDE_DIR + NAMES Python.h + PATHS + "${PYTHON_ROOT_DIR}/include" + "C:/python/${_CURRENT_VERSION}.9/include" + "C:/python/${_CURRENT_VERSION}.8/include" + "C:/python/${_CURRENT_VERSION}.7/include" + "C:/python/${_CURRENT_VERSION}.6/include" + "C:/python/${_CURRENT_VERSION}.5/include" + "C:/python/${_CURRENT_VERSION}.4/include" + "C:/python/${_CURRENT_VERSION}.3/include" + "C:/python/${_CURRENT_VERSION}.2/include" + "C:/python/${_CURRENT_VERSION}.1/include" + "C:/python/${_CURRENT_VERSION}.0/include" + ) + else() + find_path(PYTHON_INCLUDE_DIR + NAMES Python.h + PATHS + ${PYTHON_FRAMEWORK_INCLUDES} + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include + PATH_SUFFIXES + python${_CURRENT_VERSION}mu + python${_CURRENT_VERSION}m + python${_CURRENT_VERSION}u + python${_CURRENT_VERSION} + ) + endif() + + # For backward compatibility, set PYTHON_INCLUDE_PATH. + set(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}") + + if(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}/patchlevel.h") + file(STRINGS "${PYTHON_INCLUDE_DIR}/patchlevel.h" python_version_str + REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"") + string(REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1" + PYTHONLIBS_VERSION_STRING "${python_version_str}") + unset(python_version_str) + endif() + + if(PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR) + break() + endif() +endforeach() + +mark_as_advanced( + PYTHON_DEBUG_LIBRARY + PYTHON_LIBRARY + PYTHON_INCLUDE_DIR +) + +# We use PYTHON_INCLUDE_DIR, PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the +# cache entries because they are meant to specify the location of a single +# library. We now set the variables listed by the documentation for this +# module. +set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") +set(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") + +# These variables have been historically named in this module different from +# what SELECT_LIBRARY_CONFIGURATIONS() expects. +set(PYTHON_LIBRARY_DEBUG "${PYTHON_DEBUG_LIBRARY}") +set(PYTHON_LIBRARY_RELEASE "${PYTHON_LIBRARY}") +include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) +SELECT_LIBRARY_CONFIGURATIONS(PYTHON) +# SELECT_LIBRARY_CONFIGURATIONS() sets ${PREFIX}_FOUND if it has a library. +# Unset this, this prefix doesn't match the module prefix, they are different +# for historical reasons. +unset(PYTHON_FOUND) + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs + REQUIRED_VARS PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS + VERSION_VAR PYTHONLIBS_VERSION_STRING) + +# PYTHON_ADD_MODULE( src1 src2 ... srcN) is used to build modules for python. +# PYTHON_WRITE_MODULES_HEADER() writes a header file you can include +# in your sources to initialize the static python modules +function(PYTHON_ADD_MODULE _NAME ) + get_property(_TARGET_SUPPORTS_SHARED_LIBS + GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) + option(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE) + option(PYTHON_MODULE_${_NAME}_BUILD_SHARED + "Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS}) + + # Mark these options as advanced + mark_as_advanced(PYTHON_ENABLE_MODULE_${_NAME} + PYTHON_MODULE_${_NAME}_BUILD_SHARED) + + if(PYTHON_ENABLE_MODULE_${_NAME}) + if(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + set(PY_MODULE_TYPE MODULE) + else() + set(PY_MODULE_TYPE STATIC) + set_property(GLOBAL APPEND PROPERTY PY_STATIC_MODULES_LIST ${_NAME}) + endif() + + set_property(GLOBAL APPEND PROPERTY PY_MODULES_LIST ${_NAME}) + add_library(${_NAME} ${PY_MODULE_TYPE} ${ARGN}) +# target_link_libraries(${_NAME} ${PYTHON_LIBRARIES}) + + if(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + set_target_properties(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}") + if(WIN32 AND NOT CYGWIN) + set_target_properties(${_NAME} PROPERTIES SUFFIX ".pyd") + endif() + endif() + + endif() +endfunction() + +function(PYTHON_WRITE_MODULES_HEADER _filename) + + get_property(PY_STATIC_MODULES_LIST GLOBAL PROPERTY PY_STATIC_MODULES_LIST) + + get_filename_component(_name "${_filename}" NAME) + string(REPLACE "." "_" _name "${_name}") + string(TOUPPER ${_name} _nameUpper) + set(_filename ${CMAKE_CURRENT_BINARY_DIR}/${_filename}) + + set(_filenameTmp "${_filename}.in") + file(WRITE ${_filenameTmp} "/*Created by cmake, do not edit, changes will be lost*/\n") + file(APPEND ${_filenameTmp} +"#ifndef ${_nameUpper} +#define ${_nameUpper} + +#include + +#ifdef __cplusplus +extern \"C\" { +#endif /* __cplusplus */ + +") + + foreach(_currentModule ${PY_STATIC_MODULES_LIST}) + file(APPEND ${_filenameTmp} "extern void init${PYTHON_MODULE_PREFIX}${_currentModule}(void);\n\n") + endforeach() + + file(APPEND ${_filenameTmp} +"#ifdef __cplusplus +} +#endif /* __cplusplus */ + +") + + + foreach(_currentModule ${PY_STATIC_MODULES_LIST}) + file(APPEND ${_filenameTmp} "int ${_name}_${_currentModule}(void) \n{\n static char name[]=\"${PYTHON_MODULE_PREFIX}${_currentModule}\"; return PyImport_AppendInittab(name, init${PYTHON_MODULE_PREFIX}${_currentModule});\n}\n\n") + endforeach() + + file(APPEND ${_filenameTmp} "void ${_name}_LoadAllPythonModules(void)\n{\n") + foreach(_currentModule ${PY_STATIC_MODULES_LIST}) + file(APPEND ${_filenameTmp} " ${_name}_${_currentModule}();\n") + endforeach() + file(APPEND ${_filenameTmp} "}\n\n") + file(APPEND ${_filenameTmp} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n ${_name}_LoadAllPythonModules();\n}\n#endif\n\n#endif\n") + +# with configure_file() cmake complains that you may not use a file created using file(WRITE) as input file for configure_file() + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_filenameTmp}" "${_filename}" OUTPUT_QUIET ERROR_QUIET) + +endfunction() diff --git a/CMakeModules/PerformFeatureChecks.cmake b/CMakeModules/PerformFeatureChecks.cmake index 3dcae68b30..e1cc304ab6 100644 --- a/CMakeModules/PerformFeatureChecks.cmake +++ b/CMakeModules/PerformFeatureChecks.cmake @@ -56,6 +56,18 @@ macro(perform_feature_checks) # mean won't fail somewhere down the line. check_include_file("iso646.h" HAVE_ISO646_H) + # The STDINT header file test is required because MinGW under Windows + # doesn't define HAVE_STDINT_H even though it does have it. + # + # We need to add it to the global compiler definitions as config.h is not + # included in pyport.h which is where the problem ocurrs without this + # fix. + check_include_file("stdint.h" HAVE_STDINT_H) + + if( HAVE_STDINT_H ) + add_definitions( -DHAVE_STDINT_H ) + endif() + # no place is this used, and "HAVE_STRINGS_H", if present in config.h then # conflicts with /usr/include/python2.6/Python.h. Please rename the macro if # re-introduce this. diff --git a/CMakeModules/SelectLibraryConfigurations.cmake b/CMakeModules/SelectLibraryConfigurations.cmake new file mode 100644 index 0000000000..5bca064f5a --- /dev/null +++ b/CMakeModules/SelectLibraryConfigurations.cmake @@ -0,0 +1,87 @@ +# select_library_configurations( basename ) +# +# This macro takes a library base name as an argument, and will choose good +# values for basename_LIBRARY, basename_LIBRARIES, basename_LIBRARY_DEBUG, and +# basename_LIBRARY_RELEASE depending on what has been found and set. If only +# basename_LIBRARY_RELEASE is defined, basename_LIBRARY, basename_LIBRARY_DEBUG, +# and basename_LIBRARY_RELEASE will be set to the release value. If only +# basename_LIBRARY_DEBUG is defined, then basename_LIBRARY, +# basename_LIBRARY_DEBUG and basename_LIBRARY_RELEASE will take the debug value. +# +# If the generator supports configuration types, then basename_LIBRARY and +# basename_LIBRARIES will be set with debug and optimized flags specifying the +# library to be used for the given configuration. If no build type has been set +# or the generator in use does not support configuration types, then +# basename_LIBRARY and basename_LIBRARIES will take only the release values. + +#============================================================================= +# Copyright 2009 Will Dicharry +# Copyright 2005-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This macro was adapted from the FindQt4 CMake module and is maintained by Will +# Dicharry . + +# Utility macro to check if one variable exists while another doesn't, and set +# one that doesn't exist to the one that exists. +macro( _set_library_name basename GOOD BAD ) + if( ${basename}_LIBRARY_${GOOD} AND NOT ${basename}_LIBRARY_${BAD} ) + set( ${basename}_LIBRARY_${BAD} ${${basename}_LIBRARY_${GOOD}} ) + set( ${basename}_LIBRARY ${${basename}_LIBRARY_${GOOD}} ) + set( ${basename}_LIBRARIES ${${basename}_LIBRARY_${GOOD}} ) + endif() +endmacro() + +macro( select_library_configurations basename ) + # if only the release version was found, set the debug to be the release + # version. + _set_library_name( ${basename} RELEASE DEBUG ) + # if only the debug version was found, set the release value to be the + # debug value. + _set_library_name( ${basename} DEBUG RELEASE ) + + # Set a default case, which will come into effect if + # -no build type is set and the generator only supports one build type + # at a time (i.e. CMAKE_CONFIGURATION_TYPES is false) + # -${basename}_LIBRARY_DEBUG and ${basename}_LIBRARY_RELEASE are the same + # -${basename}_LIBRARY_DEBUG and ${basename}_LIBRARY_RELEASE are both empty + set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} ) + set( ${basename}_LIBRARIES ${${basename}_LIBRARY_RELEASE} ) + + if( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE AND + NOT ${basename}_LIBRARY_DEBUG STREQUAL ${basename}_LIBRARY_RELEASE ) + # if the generator supports configuration types or CMAKE_BUILD_TYPE + # is set, then set optimized and debug options. + if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) + set( ${basename}_LIBRARY "" ) + foreach( _libname IN LISTS ${basename}_LIBRARY_RELEASE ) + list( APPEND ${basename}_LIBRARY optimized "${_libname}" ) + endforeach() + foreach( _libname IN LISTS ${basename}_LIBRARY_DEBUG ) + list( APPEND ${basename}_LIBRARY debug "${_libname}" ) + endforeach() + set( ${basename}_LIBRARIES "${${basename}_LIBRARY}" ) + endif() + endif() + + set( ${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH + "The ${basename} library" ) + + if( ${basename}_LIBRARY ) + set( ${basename}_FOUND TRUE ) + endif() + + mark_as_advanced( ${basename}_LIBRARY + ${basename}_LIBRARY_RELEASE + ${basename}_LIBRARY_DEBUG + ) +endmacro()