diff --git a/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp b/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp index 0c6e5a01c1..59cb289247 100644 --- a/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp +++ b/3d-viewer/3d_cache/dialogs/panel_prev_model.cpp @@ -44,7 +44,7 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE* initPanel(); // Initialize the color settings to draw the board and the footprint - m_dummyBoard->SetColorsSettings( &aFrame->Settings().Colors() ); + m_dummyBoard->SetGeneralSettings( &aFrame->Settings() ); m_parentModelList = aParentModelList; diff --git a/include/class_board_item.h b/include/class_board_item.h index 6290d006ca..607a416e44 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -260,15 +260,16 @@ public: * Function Flip * Flip this object, i.e. change the board side for this object * @param aCentre - the rotation point. + * @param aFlipLeftRight - mirror across Y axis instead of X (the default) */ - virtual void Flip( const wxPoint& aCentre ) + virtual void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) { wxMessageBox( wxT( "virtual BOARD_ITEM::Flip used, should not occur" ), GetClass() ); } - void Flip( const VECTOR2I& aCentre ) + void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) { - Flip( wxPoint( aCentre.x, aCentre.y ) ); + Flip( wxPoint( aCentre.x, aCentre.y ), aFlipLeftRight ); } /** diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 3167ac65fc..bc640f2184 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -30,34 +30,26 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include #include #include - #include #include #include #include #include -#include #include -#include #include #include #include - #include #include - #include #include #include #include #include #include -#include #include -#include #include @@ -100,12 +92,11 @@ DELETED_BOARD_ITEM g_DeletedItem; */ wxPoint BOARD_ITEM::ZeroOffset( 0, 0 ); -// this is a dummy colors settings (defined colors are the vdefulat values) -// used to initialize the board. -// these settings will be overriden later, depending on the draw frame that displays the board. +// Dummy general settings (defined colors are the default values) used to initialize the board. +// These settings will be overriden later, depending on the draw frame that displays the board. // However, when a board is created by a python script, outside a frame, the colors must be set // so dummyColorsSettings provide this default initialization -static COLORS_DESIGN_SETTINGS dummyColorsSettings( FRAME_PCB ); +static PCB_GENERAL_SETTINGS dummyGeneralSettings( FRAME_PCB ); BOARD::BOARD() : BOARD_ITEM_CONTAINER( (BOARD_ITEM*) NULL, PCB_T ), @@ -114,7 +105,8 @@ BOARD::BOARD() : // we have not loaded a board yet, assume latest until then. m_fileFormatVersionAtLoad = LEGACY_BOARD_FILE_VERSION; - m_colorsSettings = &dummyColorsSettings; + m_generalSettings = &dummyGeneralSettings; + m_CurrentZoneContour = NULL; // This ZONE_CONTAINER handle the // zone contour currently in progress diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 3823cbf487..25bc1f74b9 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -22,23 +22,16 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file class_board.h - * @brief Class BOARD to handle a board. - */ - #ifndef CLASS_BOARD_H_ #define CLASS_BOARD_H_ #include - #include - #include #include #include #include -#include +#include #include // PAGE_INFO #include #include @@ -200,7 +193,7 @@ private: BOARD_DESIGN_SETTINGS m_designSettings; ZONE_SETTINGS m_zoneSettings; - COLORS_DESIGN_SETTINGS* m_colorsSettings; + PCB_GENERAL_SETTINGS* m_generalSettings; ///< reference only; I have no ownership PAGE_INFO m_paper; TITLE_BLOCK m_titles; ///< text in lower right of screen and plots PCB_PLOT_PARAMS m_plotOptions; @@ -577,16 +570,15 @@ public: * Function GetColorSettings * @return the current COLORS_DESIGN_SETTINGS in use */ - const COLORS_DESIGN_SETTINGS& Colors() const { return *m_colorsSettings; } + const COLORS_DESIGN_SETTINGS& Colors() const { return m_generalSettings->Colors(); } - /** - * Function SetColorsSettings - * @param aColorsSettings = the new COLORS_DESIGN_SETTINGS to use - */ - void SetColorsSettings( COLORS_DESIGN_SETTINGS* aColorsSettings ) + const PCB_GENERAL_SETTINGS& GeneralSettings() const { return *m_generalSettings; } + + void SetGeneralSettings( PCB_GENERAL_SETTINGS* aGeneralSettings ) { - m_colorsSettings = aColorsSettings; + m_generalSettings = aGeneralSettings; } + /** * Function GetBoardPolygonOutlines * Extracts the board outlines and build a closed polygon diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index a19931d722..6365cf02e6 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -135,7 +135,7 @@ void DIMENSION::Rotate( const wxPoint& aRotCentre, double aAngle ) } -void DIMENSION::Flip( const wxPoint& aCentre ) +void DIMENSION::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) { Mirror( aCentre ); @@ -145,28 +145,49 @@ void DIMENSION::Flip( const wxPoint& aCentre ) } -void DIMENSION::Mirror( const wxPoint& axis_pos ) +void DIMENSION::Mirror( const wxPoint& axis_pos, bool aMirrorLeftRight ) { + int axis = aMirrorLeftRight ? axis_pos.x : axis_pos.y; wxPoint newPos = m_Text.GetTextPos(); -#define INVERT( pos ) (pos) = axis_pos.y - ( (pos) - axis_pos.y ) - INVERT( newPos.y ); +#define INVERT( pos ) (pos) = axis - ( (pos) - axis ) + + if( aMirrorLeftRight ) + INVERT( newPos.x ); + else + INVERT( newPos.y ); m_Text.SetTextPos( newPos ); // invert angle m_Text.SetTextAngle( -m_Text.GetTextAngle() ); - INVERT( m_crossBarO.y ); - INVERT( m_crossBarF.y ); - INVERT( m_featureLineGO.y ); - INVERT( m_featureLineGF.y ); - INVERT( m_featureLineDO.y ); - INVERT( m_featureLineDF.y ); - INVERT( m_arrowG1F.y ); - INVERT( m_arrowG2F.y ); - INVERT( m_arrowD1F.y ); - INVERT( m_arrowD2F.y ); + if( aMirrorLeftRight ) + { + INVERT( m_crossBarO.y ); + INVERT( m_crossBarF.y ); + INVERT( m_featureLineGO.y ); + INVERT( m_featureLineGF.y ); + INVERT( m_featureLineDO.y ); + INVERT( m_featureLineDF.y ); + INVERT( m_arrowG1F.y ); + INVERT( m_arrowG2F.y ); + INVERT( m_arrowD1F.y ); + INVERT( m_arrowD2F.y ); + } + else + { + INVERT( m_crossBarO.y ); + INVERT( m_crossBarF.y ); + INVERT( m_featureLineGO.y ); + INVERT( m_featureLineGF.y ); + INVERT( m_featureLineDO.y ); + INVERT( m_featureLineDF.y ); + INVERT( m_arrowG1F.y ); + INVERT( m_arrowG2F.y ); + INVERT( m_arrowD1F.y ); + INVERT( m_arrowD2F.y ); + } } diff --git a/pcbnew/class_dimension.h b/pcbnew/class_dimension.h index 51215ec1de..f8e0584420 100644 --- a/pcbnew/class_dimension.h +++ b/pcbnew/class_dimension.h @@ -207,7 +207,7 @@ public: */ void Move( const wxPoint& offset ) override; void Rotate( const wxPoint& aRotCentre, double aAngle ) override; - void Flip( const wxPoint& aCentre ) override; + void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override; /** * Function Mirror @@ -216,7 +216,7 @@ public: * the layer is not changed * @param axis_pos : vertical axis position */ - void Mirror( const wxPoint& axis_pos ); + void Mirror( const wxPoint& axis_pos, bool aMirrorLeftRight = false ); void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 799f85e764..1ae08dd217 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -164,10 +164,18 @@ void DRAWSEGMENT::Rotate( const wxPoint& aRotCentre, double aAngle ) } -void DRAWSEGMENT::Flip( const wxPoint& aCentre ) +void DRAWSEGMENT::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) { - m_Start.y = aCentre.y - (m_Start.y - aCentre.y); - m_End.y = aCentre.y - (m_End.y - aCentre.y); + if( aFlipLeftRight ) + { + m_Start.x = aCentre.x - ( m_Start.x - aCentre.x ); + m_End.x = aCentre.x - ( m_End.x - aCentre.x ); + } + else + { + m_Start.y = aCentre.y - ( m_Start.y - aCentre.y ); + m_End.y = aCentre.y - ( m_End.y - aCentre.y ); + } switch ( m_Shape ) { @@ -178,14 +186,25 @@ void DRAWSEGMENT::Flip( const wxPoint& aCentre ) case S_POLYGON: for( auto iter = m_Poly.Iterate(); iter; iter++ ) { - iter->y = aCentre.y - (iter->y - aCentre.y); + if( aFlipLeftRight ) + iter->x = aCentre.x - ( iter->x - aCentre.x ); + else + iter->y = aCentre.y - ( iter->y - aCentre.y ); } break; case S_CURVE: { - m_BezierC1.y = aCentre.y - (m_BezierC1.y - aCentre.y); - m_BezierC2.y = aCentre.y - (m_BezierC2.y - aCentre.y); + if( aFlipLeftRight ) + { + m_BezierC1.x = aCentre.x - ( m_BezierC1.x - aCentre.x ); + m_BezierC2.x = aCentre.x - ( m_BezierC2.x - aCentre.x ); + } + else + { + m_BezierC1.y = aCentre.y - ( m_BezierC1.y - aCentre.y ); + m_BezierC2.y = aCentre.y - ( m_BezierC2.y - aCentre.y ); + } // Rebuild the poly points shape std::vector ctrlPoints = { m_Start, m_BezierC1, m_BezierC2, m_End }; diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h index ef5a307055..07e2051e65 100644 --- a/pcbnew/class_drawsegment.h +++ b/pcbnew/class_drawsegment.h @@ -237,7 +237,7 @@ public: virtual void Rotate( const wxPoint& aRotCentre, double aAngle ) override; - virtual void Flip( const wxPoint& aCentre ) override; + virtual void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override; /** * Function TransformShapeWithClearanceToPolygon diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index ca3d65add0..62b90a3e2e 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -281,7 +281,7 @@ EDA_ITEM* EDGE_MODULE::Clone() const } -void EDGE_MODULE::Flip( const wxPoint& aCentre ) +void EDGE_MODULE::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) { wxPoint pt; @@ -293,21 +293,29 @@ void EDGE_MODULE::Flip( const wxPoint& aCentre ) default: case S_SEGMENT: case S_CURVE: - pt = GetStart(); - MIRROR( pt.y, aCentre.y ); - SetStart( pt ); + if( aFlipLeftRight ) + { + MIRROR( m_Start.x, aCentre.x ); + MIRROR( m_End.x, aCentre.x ); + MIRROR( m_BezierC1.x, aCentre.x ); + MIRROR( m_BezierC2.x, aCentre.x ); + MIRROR( m_Start0.x, 0 ); + MIRROR( m_End0.x, 0 ); + MIRROR( m_Bezier0_C1.x, 0 ); + MIRROR( m_Bezier0_C2.x, 0 ); + } + else + { + MIRROR( m_Start.y, aCentre.y ); + MIRROR( m_End.y, aCentre.y ); + MIRROR( m_BezierC1.y, aCentre.y ); + MIRROR( m_BezierC2.y, aCentre.y ); + MIRROR( m_Start0.y, 0 ); + MIRROR( m_End0.y, 0 ); + MIRROR( m_Bezier0_C1.y, 0 ); + MIRROR( m_Bezier0_C2.y, 0 ); + } - pt = GetEnd(); - MIRROR( pt.y, aCentre.y ); - SetEnd( pt ); - - MIRROR( m_BezierC1.y, aCentre.y ); - MIRROR( m_BezierC2.y, aCentre.y ); - - MIRROR( m_Start0.y, 0 ); - MIRROR( m_End0.y, 0 ); - MIRROR( m_Bezier0_C1.y, 0 ); - MIRROR( m_Bezier0_C2.y, 0 ); RebuildBezierToSegmentsPointsList( m_Width ); break; @@ -316,7 +324,10 @@ void EDGE_MODULE::Flip( const wxPoint& aCentre ) // footprint position, orientation 0 for( auto iter = m_Poly.Iterate(); iter; iter++ ) { - MIRROR( iter->y, 0 ); + if( aFlipLeftRight ) + MIRROR( iter->x, 0 ); + else + MIRROR( iter->y, 0 ); } break; } diff --git a/pcbnew/class_edge_mod.h b/pcbnew/class_edge_mod.h index b4db28a8f3..a49ddf063b 100644 --- a/pcbnew/class_edge_mod.h +++ b/pcbnew/class_edge_mod.h @@ -86,7 +86,7 @@ public: * not usual to flip an item alone, without flipping the parent footprint. * (consider Mirror for a mirror transform). */ - void Flip( const wxPoint& aCentre ) override; + void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override; bool IsParentFlipped() const; diff --git a/pcbnew/class_marker_pcb.cpp b/pcbnew/class_marker_pcb.cpp index eb405996a1..8e13aa7930 100644 --- a/pcbnew/class_marker_pcb.cpp +++ b/pcbnew/class_marker_pcb.cpp @@ -112,9 +112,12 @@ void MARKER_PCB::Rotate(const wxPoint& aRotCentre, double aAngle) } -void MARKER_PCB::Flip(const wxPoint& aCentre ) +void MARKER_PCB::Flip(const wxPoint& aCentre, bool aFlipLeftRight ) { - m_Pos.y = aCentre.y - (m_Pos.y - aCentre.y); + if( aFlipLeftRight ) + m_Pos.x = aCentre.x - ( m_Pos.x - aCentre.x ); + else + m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y ); } diff --git a/pcbnew/class_marker_pcb.h b/pcbnew/class_marker_pcb.h index ac03bd58ed..91506efc91 100644 --- a/pcbnew/class_marker_pcb.h +++ b/pcbnew/class_marker_pcb.h @@ -86,7 +86,7 @@ public: void Rotate( const wxPoint& aRotCentre, double aAngle ) override; - void Flip( const wxPoint& aCentre ) override; + void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override; void Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset = ZeroOffset ) override { diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 645e87bfc4..88a308ab42 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -312,53 +312,6 @@ void MODULE::Remove( BOARD_ITEM* aBoardItem ) } -void MODULE::CopyNetlistSettings( MODULE* aModule, bool aCopyLocalSettings ) -{ - // Don't do anything foolish like trying to copy to yourself. - wxCHECK_RET( aModule != NULL && aModule != this, wxT( "Cannot copy to NULL or yourself." ) ); - - // Not sure what to do with the value field. Use netlist for now. - aModule->SetPosition( GetPosition() ); - - if( aModule->GetLayer() != GetLayer() ) - aModule->Flip( aModule->GetPosition() ); - - if( aModule->GetOrientation() != GetOrientation() ) - aModule->Rotate( aModule->GetPosition(), GetOrientation() ); - - aModule->SetLocked( IsLocked() ); - - if( aCopyLocalSettings ) - { - aModule->SetLocalSolderMaskMargin( GetLocalSolderMaskMargin() ); - aModule->SetLocalClearance( GetLocalClearance() ); - aModule->SetLocalSolderPasteMargin( GetLocalSolderPasteMargin() ); - aModule->SetLocalSolderPasteMarginRatio( GetLocalSolderPasteMarginRatio() ); - aModule->SetZoneConnection( GetZoneConnection() ); - aModule->SetThermalWidth( GetThermalWidth() ); - aModule->SetThermalGap( GetThermalGap() ); - } - - for( auto pad : aModule->Pads() ) - { - // Fix me: if aCopyLocalSettings == true, for "multiple" pads - // (set of pads having the same name/number) this is broken - // because we copy settings from the first pad found. - // When old and new footprints have very few differences, a better - // algo can be used. - D_PAD* oldPad = FindPadByName( pad->GetName() ); - - if( oldPad ) - oldPad->CopyNetlistSettings( pad, aCopyLocalSettings ); - } - - // Not sure about copying description, keywords, 3D models or any other - // local user changes to footprint. Stick with the new footprint settings - // called out in the footprint loaded in the netlist. - aModule->CalculateBoundingBox(); -} - - void MODULE::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset ) { for( auto pad : m_pads ) @@ -1009,11 +962,16 @@ void MODULE::Rotate( const wxPoint& aRotCentre, double aAngle ) } -void MODULE::Flip( const wxPoint& aCentre ) +void MODULE::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) { // Move module to its final position: wxPoint finalPos = m_Pos; - MIRROR( finalPos.y, aCentre.y ); /// Mirror the Y position + + if( aFlipLeftRight ) + MIRROR( finalPos.x, aCentre.x ); /// Mirror the X position + else + MIRROR( finalPos.y, aCentre.y ); /// Mirror the Y position + SetPosition( finalPos ); // Flip layer @@ -1023,13 +981,13 @@ void MODULE::Flip( const wxPoint& aCentre ) m_Orient = -m_Orient; NORMALIZE_ANGLE_POS( m_Orient ); - // Mirror pads to other side of board about the x axis, i.e. vertically. + // Mirror pads to other side of board. for( auto pad : m_pads ) - pad->Flip( m_Pos ); + pad->Flip( m_Pos, aFlipLeftRight ); // Mirror reference and value. - m_Reference->Flip( m_Pos ); - m_Value->Flip( m_Pos ); + m_Reference->Flip( m_Pos, aFlipLeftRight ); + m_Value->Flip( m_Pos, aFlipLeftRight ); // Reverse mirror module graphics and texts. for( auto item : m_drawings ) @@ -1037,11 +995,11 @@ void MODULE::Flip( const wxPoint& aCentre ) switch( item->Type() ) { case PCB_MODULE_EDGE_T: - ( (EDGE_MODULE*) item )->Flip( m_Pos ); + static_cast( item )->Flip( m_Pos, aFlipLeftRight ); break; case PCB_MODULE_TEXT_T: - static_cast( item )->Flip( m_Pos ); + static_cast( item )->Flip( m_Pos, aFlipLeftRight ); break; default: diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 4d0e04b269..28b87407b1 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -241,7 +241,7 @@ public: void Rotate( const wxPoint& aRotCentre, double aAngle ) override; - void Flip( const wxPoint& aCentre ) override; + void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override; /** * Function MoveAnchorPosition @@ -581,23 +581,6 @@ public: virtual const BOX2I ViewBBox() const override; - /** - * Function CopyNetlistSettings - * copies the netlist settings to \a aModule. - * Used to copy some footprint parameters when replacing a footprint by an other - * footprint when reading a netlist, or in exchange footprint dialog - * - * The netlist settings are all of the #MODULE settings not define by a #MODULE in - * a netlist. These setting include placement prms (position, orientation, side) - * and optionally local prms( clearances, zone connection type, etc). - * The reference designator, value, path, and physical geometry settings are not - * copied. - * - * @param aModule is the #MODULE to copy the settings to. - * @param aCopyLocalSettings = false to copy only module placement - */ - void CopyNetlistSettings( MODULE* aModule, bool aCopyLocalSettings ); - /** * static function IsLibNameValid * Test for validity of a name of a footprint to be used in a footprint library diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index b3e5f281eb..083499ff92 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -434,15 +434,22 @@ void D_PAD::SetOrientation( double aAngle ) } -void D_PAD::Flip( const wxPoint& aCentre ) +void D_PAD::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) { - int y = GetPosition().y; - MIRROR( y, aCentre.y ); // invert about x axis. - SetY( y ); - - MIRROR( m_Pos0.y, 0 ); - MIRROR( m_Offset.y, 0 ); - MIRROR( m_DeltaSize.y, 0 ); + if( aFlipLeftRight ) + { + MIRROR( m_Pos.x, aCentre.x ); + MIRROR( m_Pos0.x, 0 ); + MIRROR( m_Offset.x, 0 ); + MIRROR( m_DeltaSize.x, 0 ); + } + else + { + MIRROR( m_Pos.y, aCentre.y ); + MIRROR( m_Pos0.y, 0 ); + MIRROR( m_Offset.y, 0 ); + MIRROR( m_DeltaSize.y, 0 ); + } SetOrientation( -GetOrientation() ); @@ -586,26 +593,6 @@ bool D_PAD::IncrementPadName( bool aSkipUnconnectable, bool aFillSequenceGaps ) } -void D_PAD::CopyNetlistSettings( D_PAD* aPad, bool aCopyLocalSettings ) -{ - // Don't do anything foolish like trying to copy to yourself. - wxCHECK_RET( aPad != NULL && aPad != this, wxT( "Cannot copy to NULL or yourself." ) ); - - aPad->SetNetCode( GetNetCode() ); - - if( aCopyLocalSettings ) - { - aPad->SetLocalClearance( m_LocalClearance ); - aPad->SetLocalSolderMaskMargin( m_LocalSolderMaskMargin ); - aPad->SetLocalSolderPasteMargin( m_LocalSolderPasteMargin ); - aPad->SetLocalSolderPasteMarginRatio( m_LocalSolderPasteMarginRatio ); - aPad->SetZoneConnection( m_ZoneConnection ); - aPad->SetThermalWidth( m_ThermalWidth ); - aPad->SetThermalGap( m_ThermalGap ); - } -} - - int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const { // A pad can have specific clearance parameters that diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index f128905ccd..cd7839a6c9 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -347,7 +347,7 @@ public: */ const SHAPE_POLY_SET& GetCustomShapeAsPolygon() const { return m_customShapeAsPolygon; } - void Flip( const wxPoint& aCentre ) override; + void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override; /** * Flip the basic shapes, in custom pads @@ -788,23 +788,6 @@ public: virtual const BOX2I ViewBBox() const override; - /** - * Function CopyNetlistSettings - * copies the netlist settings to \a aPad, and the net name. - * Used to copy some pad parameters when replacing a footprint by an other - * footprint when reading a netlist, or in exchange footprint dialog - * - * The netlist settings are all of the #D_PAD settings not define by a #D_PAD in - * a netlist. - * The copied settings are the net name and optionally include local clearance, etc. - * The pad physical geometry settings are not copied. - * - * @param aPad is the #D_PAD to copy the settings to. - * @param aCopyLocalSettings = false to copy only the net name - * true to also copy local prms - */ - void CopyNetlistSettings( D_PAD* aPad, bool aCopyLocalSettings ); - virtual void SwapData( BOARD_ITEM* aImage ) override; #if defined(DEBUG) diff --git a/pcbnew/class_pcb_target.cpp b/pcbnew/class_pcb_target.cpp index 5de0aa757b..9551276c62 100644 --- a/pcbnew/class_pcb_target.cpp +++ b/pcbnew/class_pcb_target.cpp @@ -158,9 +158,13 @@ void PCB_TARGET::Rotate(const wxPoint& aRotCentre, double aAngle) } -void PCB_TARGET::Flip(const wxPoint& aCentre ) +void PCB_TARGET::Flip(const wxPoint& aCentre, bool aFlipLeftRight ) { - m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y ); + if( aFlipLeftRight ) + m_Pos.x = aCentre.x - ( m_Pos.x - aCentre.x ); + else + m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y ); + SetLayer( FlipLayer( GetLayer() ) ); } diff --git a/pcbnew/class_pcb_target.h b/pcbnew/class_pcb_target.h index bd4d7780f5..fca9829111 100644 --- a/pcbnew/class_pcb_target.h +++ b/pcbnew/class_pcb_target.h @@ -81,7 +81,7 @@ public: void Rotate( const wxPoint& aRotCentre, double aAngle ) override; - void Flip( const wxPoint& aCentre ) override; + void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override; void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset = ZeroOffset ) override; diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index 756f9351b4..16fb77fd10 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -135,9 +135,12 @@ void TEXTE_PCB::Rotate( const wxPoint& aRotCentre, double aAngle ) } -void TEXTE_PCB::Flip( const wxPoint& aCentre ) +void TEXTE_PCB::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) { - SetTextY( aCentre.y - ( GetTextPos().y - aCentre.y ) ); + if( aFlipLeftRight ) + SetTextX( aCentre.x - ( GetTextPos().x - aCentre.x ) ); + else + SetTextY( aCentre.y - ( GetTextPos().y - aCentre.y ) ); int copperLayerCount = GetBoard()->GetCopperLayerCount(); diff --git a/pcbnew/class_pcb_text.h b/pcbnew/class_pcb_text.h index 5a257fe2be..acf28156d6 100644 --- a/pcbnew/class_pcb_text.h +++ b/pcbnew/class_pcb_text.h @@ -72,7 +72,7 @@ public: void Rotate( const wxPoint& aRotCentre, double aAngle ) override; - void Flip( const wxPoint& aCentre ) override; + void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override; void Print( PCB_BASE_FRAME* aFrame, wxDC* DC, const wxPoint& offset = ZeroOffset ) override; diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index f2da0ebef9..d006323b91 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -147,10 +147,13 @@ void TEXTE_MODULE::Rotate( const wxPoint& aRotCentre, double aAngle ) } -void TEXTE_MODULE::Flip( const wxPoint& aCentre ) +void TEXTE_MODULE::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) { // flipping the footprint is relative to the X axis - SetTextY( ::Mirror( GetTextPos().y, aCentre.y ) ); + if( aFlipLeftRight ) + SetTextX( ::Mirror( GetTextPos().x, aCentre.x ) ); + else + SetTextY( ::Mirror( GetTextPos().y, aCentre.y ) ); SetTextAngle( -GetTextAngle() ); diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index fa994be25f..98523c4101 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -111,7 +111,7 @@ public: void Rotate( const wxPoint& aOffset, double aAngle ) override; /// Flip entity during module flip - void Flip( const wxPoint& aCentre ) override; + void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override; bool IsParentFlipped() const; diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 8a98575efe..09c82a2d09 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -233,19 +233,36 @@ void TRACK::Rotate( const wxPoint& aRotCentre, double aAngle ) } -void TRACK::Flip( const wxPoint& aCentre ) +void TRACK::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) { - m_Start.y = aCentre.y - (m_Start.y - aCentre.y); - m_End.y = aCentre.y - (m_End.y - aCentre.y); + if( aFlipLeftRight ) + { + m_Start.x = aCentre.x - ( m_Start.x - aCentre.x ); + m_End.x = aCentre.x - ( m_End.x - aCentre.x ); + } + else + { + m_Start.y = aCentre.y - ( m_Start.y - aCentre.y ); + m_End.y = aCentre.y - ( m_End.y - aCentre.y ); + } + int copperLayerCount = GetBoard()->GetCopperLayerCount(); SetLayer( FlipLayer( GetLayer(), copperLayerCount ) ); } -void VIA::Flip( const wxPoint& aCentre ) +void VIA::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) { - m_Start.y = aCentre.y - (m_Start.y - aCentre.y); - m_End.y = aCentre.y - (m_End.y - aCentre.y); + if( aFlipLeftRight ) + { + m_Start.x = aCentre.x - ( m_Start.x - aCentre.x ); + m_End.x = aCentre.x - ( m_End.x - aCentre.x ); + } + else + { + m_Start.y = aCentre.y - ( m_Start.y - aCentre.y ); + m_End.y = aCentre.y - ( m_End.y - aCentre.y ); + } if( GetViaType() != VIA_THROUGH ) { diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index 2243c02c79..5324570221 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -86,15 +86,15 @@ public: // Do not create a copy constructor. The one generated by the compiler is adequate. - virtual void Move( const wxPoint& aMoveVector ) override + void Move( const wxPoint& aMoveVector ) override { m_Start += aMoveVector; m_End += aMoveVector; } - virtual void Rotate( const wxPoint& aRotCentre, double aAngle ) override; + void Rotate( const wxPoint& aRotCentre, double aAngle ) override; - virtual void Flip( const wxPoint& aCentre ) override; + void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override; void SetPosition( const wxPoint& aPos ) override { m_Start = aPos; } const wxPoint GetPosition() const override { return m_Start; } @@ -325,14 +325,14 @@ public: EDA_ITEM* Clone() const override; - virtual void ViewGetLayers( int aLayers[], int& aCount ) const override; + void ViewGetLayers( int aLayers[], int& aCount ) const override; - virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; + unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override; - virtual void Flip( const wxPoint& aCentre ) override; + void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override; #if defined (DEBUG) - virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } + void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } #endif VIATYPE_T GetViaType() const { return m_ViaType; } diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index a925e8656f..89749f362a 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -584,36 +584,13 @@ bool ZONE_CONTAINER::HitTest( const EDA_RECT& aRect, bool aContained, int aAccur else // Test for intersection between aBox and the polygon // For a polygon, using its bounding box has no sense here { - // Fast test: if aBox is outside the polygon bounding box, - // rectangles cannot intersect + // Fast test: if aBox is outside the polygon bounding box, rectangles cannot intersect if( !arect.Intersects( bbox ) ) return false; - // aBox is inside the polygon bounding box, - // and can intersect the polygon: use a fine test. - // aBox intersects the polygon if at least one aBox corner - // is inside the polygon - - /* - wxPoint origin = arect.GetOrigin(); - - int w = arect.GetWidth(); - int h = arect.GetHeight(); - - - if ( HitTestInsideZone( origin ) || - HitTestInsideZone( origin + wxPoint( w, 0 ) ) || - HitTestInsideZone( origin + wxPoint( w, h ) ) || - HitTestInsideZone( origin + wxPoint( 0, h ) ) ) - { - return true; - } - */ - - // No corner inside aBox, but outlines can intersect aBox - // if one of outline corners is inside aBox int count = m_Poly->TotalVertices(); - for( int ii =0; ii < count; ii++ ) + + for( int ii = 0; ii < count; ii++ ) { auto vertex = m_Poly->Vertex( ii ); auto vertexNext = m_Poly->Vertex( ( ii + 1 ) % count ); @@ -681,7 +658,7 @@ void ZONE_CONTAINER::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL if( m_CornerSelection != nullptr && m_CornerSelection->m_contour > 0 ) msg << wxT( " " ) << _( "(Cutout)" ); - aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) ); + aList.emplace_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) ); if( GetIsKeepout() ) { @@ -696,7 +673,7 @@ void ZONE_CONTAINER::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL if( GetDoNotAllowCopperPour() ) AccumulateDescription( msg, _("No copper pour") ); - aList.push_back( MSG_PANEL_ITEM( _( "Keepout" ), msg, RED ) ); + aList.emplace_back( MSG_PANEL_ITEM( _( "Keepout" ), msg, RED ) ); } else if( IsOnCopperLayer() ) { @@ -712,25 +689,25 @@ void ZONE_CONTAINER::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL else // a netcode < 0 is an error msg = wxT( "" ); - aList.push_back( MSG_PANEL_ITEM( _( "NetName" ), msg, RED ) ); + aList.emplace_back( MSG_PANEL_ITEM( _( "NetName" ), msg, RED ) ); // Display net code : (useful in test or debug) msg.Printf( wxT( "%d" ), GetNetCode() ); - aList.push_back( MSG_PANEL_ITEM( _( "NetCode" ), msg, RED ) ); + aList.emplace_back( MSG_PANEL_ITEM( _( "NetCode" ), msg, RED ) ); // Display priority level msg.Printf( wxT( "%d" ), GetPriority() ); - aList.push_back( MSG_PANEL_ITEM( _( "Priority" ), msg, BLUE ) ); + aList.emplace_back( MSG_PANEL_ITEM( _( "Priority" ), msg, BLUE ) ); } else { - aList.push_back( MSG_PANEL_ITEM( _( "Non Copper Zone" ), wxEmptyString, RED ) ); + aList.emplace_back( MSG_PANEL_ITEM( _( "Non Copper Zone" ), wxEmptyString, RED ) ); } - aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), BROWN ) ); + aList.emplace_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), BROWN ) ); msg.Printf( wxT( "%d" ), (int) m_Poly->TotalVertices() ); - aList.push_back( MSG_PANEL_ITEM( _( "Vertices" ), msg, BLUE ) ); + aList.emplace_back( MSG_PANEL_ITEM( _( "Vertices" ), msg, BLUE ) ); switch( m_FillMode ) { @@ -742,16 +719,16 @@ void ZONE_CONTAINER::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL msg = _( "Unknown" ); break; } - aList.push_back( MSG_PANEL_ITEM( _( "Fill Mode" ), msg, BROWN ) ); + aList.emplace_back( MSG_PANEL_ITEM( _( "Fill Mode" ), msg, BROWN ) ); // Useful for statistics : msg.Printf( wxT( "%d" ), (int) m_HatchLines.size() ); - aList.push_back( MSG_PANEL_ITEM( _( "Hatch Lines" ), msg, BLUE ) ); + aList.emplace_back( MSG_PANEL_ITEM( _( "Hatch Lines" ), msg, BLUE ) ); if( !m_FilledPolysList.IsEmpty() ) { msg.Printf( wxT( "%d" ), m_FilledPolysList.TotalVertices() ); - aList.push_back( MSG_PANEL_ITEM( _( "Corner Count" ), msg, BLUE ) ); + aList.emplace_back( MSG_PANEL_ITEM( _( "Corner Count" ), msg, BLUE ) ); } } @@ -761,16 +738,16 @@ void ZONE_CONTAINER::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL void ZONE_CONTAINER::Move( const wxPoint& offset ) { /* move outlines */ - m_Poly->Move( VECTOR2I( offset ) ); + m_Poly->Move( offset ); Hatch(); - m_FilledPolysList.Move( VECTOR2I( offset.x, offset.y ) ); + m_FilledPolysList.Move( offset ); - for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ ) + for( SEG& seg : m_FillSegmList ) { - m_FillSegmList[ic].A += VECTOR2I(offset); - m_FillSegmList[ic].B += VECTOR2I(offset); + seg.A += VECTOR2I( offset ); + seg.B += VECTOR2I( offset ); } } @@ -820,9 +797,9 @@ void ZONE_CONTAINER::Rotate( const wxPoint& centre, double angle ) } -void ZONE_CONTAINER::Flip( const wxPoint& aCentre ) +void ZONE_CONTAINER::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) { - Mirror( aCentre ); + Mirror( aCentre, aFlipLeftRight ); int copperLayerCount = GetBoard()->GetCopperLayerCount(); if( GetIsKeepout() ) @@ -836,26 +813,38 @@ void ZONE_CONTAINER::Flip( const wxPoint& aCentre ) } -void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref ) +void ZONE_CONTAINER::Mirror( const wxPoint& aMirrorRef, bool aMirrorLeftRight ) { for( auto iterator = m_Poly->IterateWithHoles(); iterator; iterator++ ) { - int py = mirror_ref.y - iterator->y; - iterator->y = py + mirror_ref.y; + if( aMirrorLeftRight ) + iterator->x = ( aMirrorRef.x - iterator->x ) + aMirrorRef.x; + else + iterator->y = ( aMirrorRef.y - iterator->y ) + aMirrorRef.y; } Hatch(); for( auto ic = m_FilledPolysList.Iterate(); ic; ++ic ) { - int py = mirror_ref.y - ic->y; - ic->y = py + mirror_ref.y; + if( aMirrorLeftRight ) + ic->x = ( aMirrorRef.x - ic->x ) + aMirrorRef.x; + else + ic->y = ( aMirrorRef.y - ic->y ) + aMirrorRef.y; } - for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ ) + for( SEG& seg : m_FillSegmList ) { - MIRROR( m_FillSegmList[ic].A.y, mirror_ref.y ); - MIRROR( m_FillSegmList[ic].B.y, mirror_ref.y ); + if( aMirrorLeftRight ) + { + MIRROR( seg.A.x, aMirrorRef.x ); + MIRROR( seg.B.x, aMirrorRef.x ); + } + else + { + MIRROR( seg.A.y, aMirrorRef.y ); + MIRROR( seg.B.y, aMirrorRef.y ); + } } } @@ -1117,7 +1106,7 @@ void ZONE_CONTAINER::Hatch() // else push 2 small lines if( m_hatchStyle == DIAGONAL_FULL || std::abs( dx ) < 2 * hatch_line_len ) { - m_HatchLines.push_back( SEG( pointbuffer[ip], pointbuffer[ip + 1] ) ); + m_HatchLines.emplace_back( SEG( pointbuffer[ip], pointbuffer[ip + 1] ) ); } else { @@ -1134,9 +1123,9 @@ void ZONE_CONTAINER::Hatch() int y1 = KiROUND( pointbuffer[ip].y + dx * slope ); int y2 = KiROUND( pointbuffer[ip + 1].y - dx * slope ); - m_HatchLines.push_back(SEG(pointbuffer[ip].x, pointbuffer[ip].y, x1, y1)); + m_HatchLines.emplace_back( SEG( pointbuffer[ip].x, pointbuffer[ip].y, x1, y1 ) ); - m_HatchLines.push_back( SEG( pointbuffer[ip+1].x, pointbuffer[ip+1].y, x2, y2 ) ); + m_HatchLines.emplace_back( SEG( pointbuffer[ip+1].x, pointbuffer[ip+1].y, x2, y2 ) ); } } } diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index 47abdcaf40..e42af26374 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -400,15 +400,16 @@ public: * (like Mirror() but changes layer) * @param aCentre - the rotation point. */ - virtual void Flip( const wxPoint& aCentre ) override; + virtual void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override; /** * Function Mirror * Mirror the outlines , relative to a given horizontal axis * the layer is not changed - * @param mirror_ref = vertical axis position + * @param aMirrorRef = axis position + * @param aMirrorLeftRight mirror across Y axis (otherwise mirror across X) */ - void Mirror( const wxPoint& mirror_ref ); + void Mirror( const wxPoint& aMirrorRef, bool aMirrorLeftRight ); /** * Function GetClass diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp index 615a060a6b..ba1372859a 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_BoardEditor.cpp @@ -716,7 +716,7 @@ bool DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataFromWindow() change_layer = true; if( change_layer ) - m_footprint->Flip( m_footprint->GetPosition() ); + m_footprint->Flip( m_footprint->GetPosition(), m_frame->Settings().m_FlipLeftRight ); std::list* draw3D = &m_footprint->Models(); draw3D->clear(); diff --git a/pcbnew/dialogs/dialog_exchange_footprints.cpp b/pcbnew/dialogs/dialog_exchange_footprints.cpp index aab781b664..866f7ef963 100644 --- a/pcbnew/dialogs/dialog_exchange_footprints.cpp +++ b/pcbnew/dialogs/dialog_exchange_footprints.cpp @@ -403,13 +403,28 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aSrc, MODULE* aDest, BOARD_COMMIT& { aDest->SetParent( GetBoard() ); - /* place module without ratsnest refresh: this will be made later - * when all modules are on board */ PlaceModule( aDest, false ); - // Copy full placement and pad net names (when possible) - // but not local settings like clearances (use library values) - aSrc->CopyNetlistSettings( aDest, false ); + // Copy full placement, locked flag and pad net names (when possible) but not local + // settings like clearances (use library values) + // + aDest->SetPosition( aSrc->GetPosition() ); + + if( aDest->GetLayer() != aSrc->GetLayer() ) + aDest->Flip( aDest->GetPosition(), m_configSettings.m_FlipLeftRight ); + + if( aDest->GetOrientation() != aSrc->GetOrientation() ) + aDest->Rotate( aDest->GetPosition(), aSrc->GetOrientation() ); + + aDest->SetLocked( aSrc->IsLocked() ); + + for( auto pad : aDest->Pads() ) + { + D_PAD* oldPad = aSrc->FindPadByName( pad->GetName() ); + + if( oldPad ) + pad->SetNetCode( oldPad->GetNetCode() ); + } // Copy reference processTextItem( aSrc->Reference(), aDest->Reference(), @@ -440,9 +455,10 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aSrc, MODULE* aDest, BOARD_COMMIT& } } - // Updating other parameters + // Updating other parameters aDest->SetTimeStamp( aSrc->GetTimeStamp() ); aDest->SetPath( aSrc->GetPath() ); + aDest->CalculateBoundingBox(); aCommit.Remove( aSrc ); aCommit.Add( aDest ); diff --git a/pcbnew/dialogs/panel_pcbnew_settings.cpp b/pcbnew/dialogs/panel_pcbnew_settings.cpp index 70c6fd77b9..f8d6da4eff 100644 --- a/pcbnew/dialogs/panel_pcbnew_settings.cpp +++ b/pcbnew/dialogs/panel_pcbnew_settings.cpp @@ -62,6 +62,7 @@ bool PANEL_PCBNEW_SETTINGS::TransferDataToWindow() m_magneticGraphicsChoice->SetSelection( !general_opts.m_MagneticGraphics ); m_UseEditKeyForWidth->SetValue( general_opts.m_EditHotkeyChangesTrackWidth ); m_dragSelects->SetValue( general_opts.m_DragSelects ); + m_FlipLeftRight->SetValue( general_opts.m_FlipLeftRight ); m_Show_Page_Limits->SetValue( m_Frame->ShowPageLimits() ); @@ -84,6 +85,7 @@ bool PANEL_PCBNEW_SETTINGS::TransferDataFromWindow() m_Frame->Settings().m_MagneticGraphics = !m_magneticGraphicsChoice->GetSelection(); m_Frame->Settings().m_EditHotkeyChangesTrackWidth = m_UseEditKeyForWidth->GetValue(); m_Frame->Settings().m_DragSelects = m_dragSelects->GetValue(); + m_Frame->Settings().m_FlipLeftRight = m_FlipLeftRight->GetValue(); m_Frame->SetShowPageLimits( m_Show_Page_Limits->GetValue() ); diff --git a/pcbnew/dialogs/panel_pcbnew_settings_base.cpp b/pcbnew/dialogs/panel_pcbnew_settings_base.cpp index f35cff29cf..4bdcf146f8 100644 --- a/pcbnew/dialogs/panel_pcbnew_settings_base.cpp +++ b/pcbnew/dialogs/panel_pcbnew_settings_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 23 2019) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -9,160 +9,169 @@ /////////////////////////////////////////////////////////////////////////// -PANEL_PCBNEW_SETTINGS_BASE::PANEL_PCBNEW_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +PANEL_PCBNEW_SETTINGS_BASE::PANEL_PCBNEW_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) { wxBoxSizer* bPanelSizer; bPanelSizer = new wxBoxSizer( wxHORIZONTAL ); - + wxBoxSizer* bMargins; bMargins = new wxBoxSizer( wxHORIZONTAL ); - + wxBoxSizer* bMiddleLeftSizer; bMiddleLeftSizer = new wxBoxSizer( wxVERTICAL ); - + wxString m_PolarDisplayChoices[] = { _("Cartesian coordinates"), _("Polar coordinates") }; int m_PolarDisplayNChoices = sizeof( m_PolarDisplayChoices ) / sizeof( wxString ); m_PolarDisplay = new wxRadioBox( this, wxID_POLAR_CTRL, _("Coordinates"), wxDefaultPosition, wxDefaultSize, m_PolarDisplayNChoices, m_PolarDisplayChoices, 1, wxRA_SPECIFY_COLS ); m_PolarDisplay->SetSelection( 0 ); m_PolarDisplay->SetToolTip( _("Set display of relative (dx/dy) coordinates to Cartesian (rectangular) or polar (angle/distance).") ); - + bMiddleLeftSizer->Add( m_PolarDisplay, 0, wxALL|wxEXPAND, 5 ); - + wxString m_UnitsSelectionChoices[] = { _("Inches"), _("Millimeters") }; int m_UnitsSelectionNChoices = sizeof( m_UnitsSelectionChoices ) / sizeof( wxString ); m_UnitsSelection = new wxRadioBox( this, wxID_UNITS, _("Units"), wxDefaultPosition, wxDefaultSize, m_UnitsSelectionNChoices, m_UnitsSelectionChoices, 1, wxRA_SPECIFY_COLS ); m_UnitsSelection->SetSelection( 0 ); m_UnitsSelection->SetToolTip( _("Set units used to display dimensions and positions.") ); - + bMiddleLeftSizer->Add( m_UnitsSelection, 0, wxALL|wxEXPAND, 5 ); - + wxStaticBoxSizer* bOptionsSizer; bOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Editing Options") ), wxVERTICAL ); - - m_Show_Page_Limits = new wxCheckBox( bOptionsSizer->GetStaticBox(), wxID_ANY, _("Show page limits"), wxDefaultPosition, wxDefaultSize, 0 ); - m_Show_Page_Limits->SetValue(true); - bOptionsSizer->Add( m_Show_Page_Limits, 0, wxALL, 5 ); - + m_Segments_45_Only_Ctrl = new wxCheckBox( bOptionsSizer->GetStaticBox(), wxID_SEGMENTS45, _("L&imit graphic lines to H, V and 45 degrees"), wxDefaultPosition, wxDefaultSize, 0 ); m_Segments_45_Only_Ctrl->SetToolTip( _("Force line segment directions to H, V or 45 degrees when drawing on technical layers.") ); - + bOptionsSizer->Add( m_Segments_45_Only_Ctrl, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - + m_UseEditKeyForWidth = new wxCheckBox( bOptionsSizer->GetStaticBox(), wxID_ANY, _("Edit hotkey changes track width"), wxDefaultPosition, wxDefaultSize, 0 ); m_UseEditKeyForWidth->SetToolTip( _("When active, hitting Edit hotkey or double-clicking on a track or via changes its width/diameter to the one selected in the main toolbar. ") ); - + bOptionsSizer->Add( m_UseEditKeyForWidth, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - + m_dragSelects = new wxCheckBox( bOptionsSizer->GetStaticBox(), wxID_ANY, _("Prefer selection to dragging"), wxDefaultPosition, wxDefaultSize, 0 ); m_dragSelects->SetToolTip( _("When enabled and nothing is selected, drag gesture will draw a selection box, even if there are items under the cursor that could be immediately dragged.") ); - + bOptionsSizer->Add( m_dragSelects, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); - + + m_FlipLeftRight = new wxCheckBox( bOptionsSizer->GetStaticBox(), wxID_ANY, _("Flip board items L/R (default is T/B)"), wxDefaultPosition, wxDefaultSize, 0 ); + bOptionsSizer->Add( m_FlipLeftRight, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + wxFlexGridSizer* fgSizer12; fgSizer12 = new wxFlexGridSizer( 0, 2, 0, 0 ); fgSizer12->AddGrowableCol( 1 ); fgSizer12->SetFlexibleDirection( wxBOTH ); fgSizer12->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + m_staticTextRotationAngle = new wxStaticText( bOptionsSizer->GetStaticBox(), wxID_ANY, _("&Rotation angle:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextRotationAngle->Wrap( -1 ); fgSizer12->Add( m_staticTextRotationAngle, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - + m_RotationAngle = new wxTextCtrl( bOptionsSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_RotationAngle->SetToolTip( _("Set increment (in degrees) for context menu and hotkey rotation.") ); - + fgSizer12->Add( m_RotationAngle, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); - - + + bOptionsSizer->Add( fgSizer12, 1, wxEXPAND, 5 ); - - + + bMiddleLeftSizer->Add( bOptionsSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - - + + bMargins->Add( bMiddleLeftSizer, 1, wxEXPAND|wxRIGHT, 5 ); - + wxBoxSizer* bRightSizer; bRightSizer = new wxBoxSizer( wxVERTICAL ); - + wxStaticBoxSizer* sbMagnets; sbMagnets = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Magnetic Points") ), wxVERTICAL ); - + wxFlexGridSizer* fgSizer2; fgSizer2 = new wxFlexGridSizer( 0, 2, 3, 0 ); fgSizer2->SetFlexibleDirection( wxBOTH ); fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - + m_staticText2 = new wxStaticText( sbMagnets->GetStaticBox(), wxID_ANY, _("Snap to pads:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText2->Wrap( -1 ); m_staticText2->SetToolTip( _("Capture cursor when the mouse enters a pad area") ); - + fgSizer2->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - + wxString m_magneticPadChoiceChoices[] = { _("Never"), _("When creating tracks"), _("Always") }; int m_magneticPadChoiceNChoices = sizeof( m_magneticPadChoiceChoices ) / sizeof( wxString ); m_magneticPadChoice = new wxChoice( sbMagnets->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_magneticPadChoiceNChoices, m_magneticPadChoiceChoices, 0 ); m_magneticPadChoice->SetSelection( 1 ); m_magneticPadChoice->SetToolTip( _("Capture cursor when the mouse enters a pad area") ); - + fgSizer2->Add( m_magneticPadChoice, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); - + m_staticText21 = new wxStaticText( sbMagnets->GetStaticBox(), wxID_ANY, _("Snap to tracks:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText21->Wrap( -1 ); m_staticText21->SetToolTip( _("Capture cursor when the mouse approaches a track") ); - + fgSizer2->Add( m_staticText21, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - + wxString m_magneticTrackChoiceChoices[] = { _("Never"), _("When creating tracks"), _("Always") }; int m_magneticTrackChoiceNChoices = sizeof( m_magneticTrackChoiceChoices ) / sizeof( wxString ); m_magneticTrackChoice = new wxChoice( sbMagnets->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_magneticTrackChoiceNChoices, m_magneticTrackChoiceChoices, 0 ); m_magneticTrackChoice->SetSelection( 1 ); m_magneticTrackChoice->SetToolTip( _("Capture cursor when the mouse approaches a track") ); - + fgSizer2->Add( m_magneticTrackChoice, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - + m_staticText211 = new wxStaticText( sbMagnets->GetStaticBox(), wxID_ANY, _("Snap to graphics:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText211->Wrap( -1 ); m_staticText211->SetToolTip( _("Capture cursor when the mouse approaches graphical control points") ); - + fgSizer2->Add( m_staticText211, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - + wxString m_magneticGraphicsChoiceChoices[] = { _("Always"), _("Never") }; int m_magneticGraphicsChoiceNChoices = sizeof( m_magneticGraphicsChoiceChoices ) / sizeof( wxString ); m_magneticGraphicsChoice = new wxChoice( sbMagnets->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_magneticGraphicsChoiceNChoices, m_magneticGraphicsChoiceChoices, 0 ); m_magneticGraphicsChoice->SetSelection( 0 ); m_magneticGraphicsChoice->SetToolTip( _("Capture cursor when the mouse approaches graphical control points") ); - + fgSizer2->Add( m_magneticGraphicsChoice, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT, 5 ); - - - sbMagnets->Add( fgSizer2, 1, wxEXPAND, 5 ); - - + + + sbMagnets->Add( fgSizer2, 1, wxEXPAND|wxBOTTOM, 5 ); + + bRightSizer->Add( sbMagnets, 1, wxEXPAND, 5 ); - + wxStaticBoxSizer* sbSizer3; sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Ratsnest") ), wxVERTICAL ); - + m_showGlobalRatsnest = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("Show ratsnest"), wxDefaultPosition, wxDefaultSize, 0 ); - sbSizer3->Add( m_showGlobalRatsnest, 0, wxALL, 5 ); - + sbSizer3->Add( m_showGlobalRatsnest, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_showSelectedRatsnest = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("Always show selected ratsnest"), wxDefaultPosition, wxDefaultSize, 0 ); - sbSizer3->Add( m_showSelectedRatsnest, 0, wxALL, 5 ); - + sbSizer3->Add( m_showSelectedRatsnest, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_OptDisplayCurvedRatsnestLines = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("Show ratsnest with curved lines"), wxDefaultPosition, wxDefaultSize, 0 ); - sbSizer3->Add( m_OptDisplayCurvedRatsnestLines, 0, wxALL, 5 ); - - + sbSizer3->Add( m_OptDisplayCurvedRatsnestLines, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + bRightSizer->Add( sbSizer3, 1, wxEXPAND, 5 ); - - + + wxStaticBoxSizer* sbSizer4; + sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Annotations") ), wxVERTICAL ); + + m_Show_Page_Limits = new wxCheckBox( sbSizer4->GetStaticBox(), wxID_ANY, _("Show page limits"), wxDefaultPosition, wxDefaultSize, 0 ); + m_Show_Page_Limits->SetValue(true); + sbSizer4->Add( m_Show_Page_Limits, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + + bRightSizer->Add( sbSizer4, 1, wxEXPAND, 5 ); + + bMargins->Add( bRightSizer, 1, wxEXPAND|wxTOP|wxRIGHT, 5 ); - - + + bPanelSizer->Add( bMargins, 1, wxRIGHT, 5 ); - - + + this->SetSizer( bPanelSizer ); this->Layout(); bPanelSizer->Fit( this ); diff --git a/pcbnew/dialogs/panel_pcbnew_settings_base.fbp b/pcbnew/dialogs/panel_pcbnew_settings_base.fbp index 1f177f7057..a9eda1fd72 100644 --- a/pcbnew/dialogs/panel_pcbnew_settings_base.fbp +++ b/pcbnew/dialogs/panel_pcbnew_settings_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,8 +14,6 @@ panel_pcbnew_settings_base 1000 none - - 1 PanelPcbnewSettings @@ -26,7 +24,6 @@ 1 1 UI - 0 1 0 @@ -51,6 +48,36 @@ wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bPanelSizer @@ -138,6 +165,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -204,6 +255,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -218,70 +293,7 @@ wxVERTICAL 1 none - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Show page limits - - 0 - - - 0 - - 1 - m_Show_Page_Limits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - + 5 wxBOTTOM|wxLEFT|wxRIGHT @@ -344,6 +356,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -408,6 +444,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -472,6 +532,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Flip board items L/R (default is T/B) + + 0 + + + 0 + + 1 + m_FlipLeftRight + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -523,7 +695,6 @@ 0 wxID_ANY &Rotation angle: - 0 0 @@ -549,6 +720,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -613,6 +807,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -642,11 +863,12 @@ wxVERTICAL 1 none + 5 - wxEXPAND + wxEXPAND|wxBOTTOM 1 - + 2 wxBOTH @@ -691,7 +913,6 @@ 0 wxID_ANY Snap to pads: - 0 0 @@ -717,6 +938,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -781,6 +1025,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -816,7 +1084,6 @@ 0 wxID_ANY Snap to tracks: - 0 0 @@ -842,6 +1109,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -906,6 +1196,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -941,7 +1255,6 @@ 0 wxID_ANY Snap to graphics: - 0 0 @@ -967,6 +1280,29 @@ -1 + + + + + + + + + + + + + + + + + + + + + + + @@ -1031,6 +1367,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -1049,9 +1409,10 @@ wxVERTICAL 1 none + 5 - wxALL + wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -1111,11 +1472,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + 5 - wxALL + wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -1175,11 +1560,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + 5 - wxALL + wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -1239,6 +1648,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + wxID_ANY + Annotations + + sbSizer4 + wxVERTICAL + 1 + none + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Show page limits + + 0 + + + 0 + + 1 + m_Show_Page_Limits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/panel_pcbnew_settings_base.h b/pcbnew/dialogs/panel_pcbnew_settings_base.h index 002e112b62..ed7729b6b9 100644 --- a/pcbnew/dialogs/panel_pcbnew_settings_base.h +++ b/pcbnew/dialogs/panel_pcbnew_settings_base.h @@ -1,11 +1,12 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 23 2019) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#pragma once +#ifndef __PANEL_PCBNEW_SETTINGS_BASE_H__ +#define __PANEL_PCBNEW_SETTINGS_BASE_H__ #include #include @@ -29,10 +30,10 @@ /////////////////////////////////////////////////////////////////////////////// /// Class PANEL_PCBNEW_SETTINGS_BASE /////////////////////////////////////////////////////////////////////////////// -class PANEL_PCBNEW_SETTINGS_BASE : public wxPanel +class PANEL_PCBNEW_SETTINGS_BASE : public wxPanel { private: - + protected: enum { @@ -40,13 +41,13 @@ class PANEL_PCBNEW_SETTINGS_BASE : public wxPanel wxID_UNITS, wxID_SEGMENTS45 }; - + wxRadioBox* m_PolarDisplay; wxRadioBox* m_UnitsSelection; - wxCheckBox* m_Show_Page_Limits; wxCheckBox* m_Segments_45_Only_Ctrl; wxCheckBox* m_UseEditKeyForWidth; wxCheckBox* m_dragSelects; + wxCheckBox* m_FlipLeftRight; wxStaticText* m_staticTextRotationAngle; wxTextCtrl* m_RotationAngle; wxStaticText* m_staticText2; @@ -58,11 +59,13 @@ class PANEL_PCBNEW_SETTINGS_BASE : public wxPanel wxCheckBox* m_showGlobalRatsnest; wxCheckBox* m_showSelectedRatsnest; wxCheckBox* m_OptDisplayCurvedRatsnestLines; - + wxCheckBox* m_Show_Page_Limits; + public: - - PANEL_PCBNEW_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + + PANEL_PCBNEW_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL ); ~PANEL_PCBNEW_SETTINGS_BASE(); - + }; +#endif //__PANEL_PCBNEW_SETTINGS_BASE_H__ diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index 55b596a51c..bc260c9a2e 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -1237,8 +1237,8 @@ ZONE_CONTAINER* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode ) } -void EAGLE_PLUGIN::orientModuleAndText( MODULE* m, const EELEMENT& e, - const EATTR* nameAttr, const EATTR* valueAttr ) +void EAGLE_PLUGIN::orientModuleAndText( MODULE* m, const EELEMENT& e, const EATTR* nameAttr, + const EATTR* valueAttr ) { if( e.rot ) { @@ -1246,7 +1246,7 @@ void EAGLE_PLUGIN::orientModuleAndText( MODULE* m, const EELEMENT& e, { double orientation = e.rot->degrees + 180.0; m->SetOrientation( orientation * 10 ); - m->Flip( m->GetPosition() ); + m->Flip( m->GetPosition(), false ); } else m->SetOrientation( e.rot->degrees * 10 ); diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp index 0e74ecc016..138ad30217 100644 --- a/pcbnew/exporters/export_gencad.cpp +++ b/pcbnew/exporters/export_gencad.cpp @@ -318,7 +318,7 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent ) if( module->GetLayer() == B_Cu ) { - module->Flip( module->GetPosition() ); + module->Flip( module->GetPosition(), Settings().m_FlipLeftRight ); module->SetFlag( 1 ); } } @@ -352,7 +352,7 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent ) { if( module->GetFlag() ) { - module->Flip( module->GetPosition() ); + module->Flip( module->GetPosition(), Settings().m_FlipLeftRight ); module->SetFlag( 0 ); } } diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 62e9472772..e5be5ce441 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -30,7 +30,6 @@ #include #include #include - #include #include #include @@ -44,7 +43,6 @@ #include #include #include - #include #include #include @@ -52,6 +50,7 @@ #include #include #include // for enum RECT_CHAMFER_POSITIONS definition +#include using namespace PCB_KEYS_T; @@ -2087,9 +2086,7 @@ const MODULE* PCB_IO::getFootprint( const wxString& aLibraryPath, MODULE_CITER it = mods.find( aFootprintName ); if( it == mods.end() ) - { - return NULL; - } + return nullptr; return it->second->GetModule(); } @@ -2214,11 +2211,11 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri // and it's time stamp must be 0, it should have no parent, orientation should // be zero, and it should be on the front layer. module->SetTimeStamp( 0 ); - module->SetParent( 0 ); + module->SetParent( nullptr ); module->SetOrientation( 0 ); if( module->GetLayer() != F_Cu ) - module->Flip( module->GetPosition() ); + module->Flip( module->GetPosition(), m_board->GeneralSettings().m_FlipLeftRight ); wxLogTrace( traceKicadPcbPlugin, wxT( "Creating s-expr footprint file '%s'." ), fullPath ); mods.insert( footprintName, new FP_CACHE_ITEM( module, WX_FILENAME( fn.GetPath(), fullName ) ) ); diff --git a/pcbnew/load_select_footprint.cpp b/pcbnew/load_select_footprint.cpp index 908d1aa009..9dd30faf1a 100644 --- a/pcbnew/load_select_footprint.cpp +++ b/pcbnew/load_select_footprint.cpp @@ -134,7 +134,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule ) // Put it on FRONT layer, // because this is the default in ModEdit, and in libs if( newModule->GetLayer() != F_Cu ) - newModule->Flip( newModule->GetPosition() ); + newModule->Flip( newModule->GetPosition(), frame->Settings().m_FlipLeftRight ); // Put it in orientation 0, // because this is the default orientation in ModEdit, and in libs diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index aaf24fa7c3..052586d3f5 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -171,7 +171,7 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard ) { delete m_Pcb; m_Pcb = aBoard; - m_Pcb->SetColorsSettings( &Settings().Colors() ); + m_Pcb->SetGeneralSettings( &Settings() ); } } @@ -191,7 +191,7 @@ void PCB_BASE_FRAME::AddModuleToBoard( MODULE* module ) // Put it on FRONT layer, // (Can be stored flipped if the lib is an archive built from a board) if( module->IsFlipped() ) - module->Flip( module->GetPosition() ); + module->Flip( module->GetPosition(), m_configSettings.m_FlipLeftRight ); // Place it in orientation 0, // even if it is not saved with orientation 0 in lib diff --git a/pcbnew/pcb_general_settings.cpp b/pcbnew/pcb_general_settings.cpp index 4630ebaac2..356177a72e 100644 --- a/pcbnew/pcb_general_settings.cpp +++ b/pcbnew/pcb_general_settings.cpp @@ -29,6 +29,7 @@ PCB_GENERAL_SETTINGS::PCB_GENERAL_SETTINGS( FRAME_T aFrameType ) : m_Use45DegreeGraphicSegments( false ), m_EditHotkeyChangesTrackWidth( false ), m_DragSelects( true ), + m_FlipLeftRight( false ), m_MagneticPads( CAPTURE_CURSOR_IN_TRACK_TOOL ), m_MagneticTracks( CAPTURE_CURSOR_IN_TRACK_TOOL ), m_MagneticGraphics( true ), @@ -44,6 +45,7 @@ PCB_GENERAL_SETTINGS::PCB_GENERAL_SETTINGS( FRAME_T aFrameType ) : Add( "MagneticGraphics", &m_MagneticGraphics, true ); Add( "EditActionChangesTrackWidth", &m_EditHotkeyChangesTrackWidth, false ); Add( "DragSelects", &m_DragSelects, true ); + Add( "FlipLeftRight", &m_FlipLeftRight, false ); break; case FRAME_PCB_MODULE_EDITOR: diff --git a/pcbnew/pcb_general_settings.h b/pcbnew/pcb_general_settings.h index 8967742d85..38924ec175 100644 --- a/pcbnew/pcb_general_settings.h +++ b/pcbnew/pcb_general_settings.h @@ -52,6 +52,8 @@ public: bool m_EditHotkeyChangesTrackWidth; bool m_DragSelects; // True: Drag gesture always draws a selection box, // False: Drag will select an item and move it + bool m_FlipLeftRight; // True: Flip footprints across Y axis + // False: Flip footprints across X axis MAGNETIC_OPTIONS m_MagneticPads; MAGNETIC_OPTIONS m_MagneticTracks; diff --git a/pcbnew/specctra_import_export/specctra_export.cpp b/pcbnew/specctra_import_export/specctra_export.cpp index 0f42a7d9ad..0759727d74 100644 --- a/pcbnew/specctra_import_export/specctra_export.cpp +++ b/pcbnew/specctra_import_export/specctra_export.cpp @@ -1737,7 +1737,7 @@ void SPECCTRA_DB::FlipMODULEs( BOARD* aBoard ) module->SetFlag( 0 ); if( module->GetLayer() == B_Cu ) { - module->Flip( module->GetPosition() ); + module->Flip( module->GetPosition(), aBoard->GeneralSettings().m_FlipLeftRight ); module->SetFlag( 1 ); } } @@ -1757,7 +1757,7 @@ void SPECCTRA_DB::RevertMODULEs( BOARD* aBoard ) { if( module->GetFlag() ) { - module->Flip( module->GetPosition() ); + module->Flip( module->GetPosition(), aBoard->GeneralSettings().m_FlipLeftRight ); module->SetFlag( 0 ); } } diff --git a/pcbnew/specctra_import_export/specctra_import.cpp b/pcbnew/specctra_import_export/specctra_import.cpp index 7aee716e1b..ff9613ee88 100644 --- a/pcbnew/specctra_import_export/specctra_import.cpp +++ b/pcbnew/specctra_import_export/specctra_import.cpp @@ -379,7 +379,8 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) if( module->GetLayer() != F_Cu ) { // module is on copper layer (back) - module->Flip( module->GetPosition() ); + module->Flip( module->GetPosition(), + aBoard->GeneralSettings().m_FlipLeftRight ); } module->SetOrientation( orientation ); @@ -391,7 +392,8 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) if( module->GetLayer() != B_Cu ) { // module is on component layer (front) - module->Flip( module->GetPosition() ); + module->Flip( module->GetPosition(), + aBoard->GeneralSettings().m_FlipLeftRight ); } module->SetOrientation( orientation ); diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 244e2cede9..2005343795 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -789,8 +789,10 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) } else if( evt->IsAction( &PCB_ACTIONS::flip ) ) { + bool leftRight = m_frame->Settings().m_FlipLeftRight; + for( auto item : preview ) - static_cast( item )->Flip( (wxPoint) cursorPos ); + static_cast( item )->Flip( (wxPoint) cursorPos, leftRight); m_view->Update( &preview ); } diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 07830910e6..7a90be9068 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -765,7 +765,8 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent ) return 0; updateModificationPoint( selection ); - auto modPoint = selection.GetReferencePoint(); + VECTOR2I modPoint = selection.GetReferencePoint(); + bool leftRight = frame()->Settings().m_FlipLeftRight; // When editing modules, all items have the same parent if( EditingModules() ) @@ -776,7 +777,7 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent ) if( !item->IsNew() && !EditingModules() ) m_commit->Modify( item ); - static_cast( item )->Flip( modPoint ); + static_cast( item )->Flip( modPoint, leftRight ); } if( !m_dragging ) diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 78656f2523..4ced3a7fb0 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -728,7 +728,7 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent ) // Put it on FRONT layer, // (Can be stored flipped if the lib is an archive built from a board) if( module->IsFlipped() ) - module->Flip( module->GetPosition() ); + module->Flip( module->GetPosition(), m_frame->Settings().m_FlipLeftRight ); module->SetOrientation( 0 ); module->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) ); diff --git a/pcbnew/tools/pcb_tool_base.cpp b/pcbnew/tools/pcb_tool_base.cpp index 23ce38f9d7..29c97198d0 100644 --- a/pcbnew/tools/pcb_tool_base.cpp +++ b/pcbnew/tools/pcb_tool_base.cpp @@ -190,7 +190,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer } else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) ) { - newItem->Flip( newItem->GetPosition() ); + newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight ); view()->Update( &preview ); } } diff --git a/pcbnew/undo_redo.cpp b/pcbnew/undo_redo.cpp index e24dd4e7c6..1f6af0e5ba 100644 --- a/pcbnew/undo_redo.cpp +++ b/pcbnew/undo_redo.cpp @@ -521,7 +521,7 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool case UR_FLIPPED: { BOARD_ITEM* item = (BOARD_ITEM*) eda_item; - item->Flip( aList->m_TransformPoint ); + item->Flip( aList->m_TransformPoint, m_configSettings.m_FlipLeftRight ); view->Update( item, KIGFX::LAYERS ); connectivity->Update( item ); }