diff --git a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp index 261a8a3cdd..c829cc4089 100644 --- a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp +++ b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp @@ -55,27 +55,36 @@ #include #include -// These variables are parameters used in addTextSegmToContainer. -// But addTextSegmToContainer is a call-back function, -// so we cannot send them as arguments. -static int s_textWidth; -static CONTAINER_2D_BASE* s_dstcontainer = nullptr; -static float s_biuTo3Dunits; -static const BOARD_ITEM* s_boardItem = nullptr; + +struct CALLBACK_DATA +{ + const BOARD_ITEM* m_BoardItem; + CONTAINER_2D_BASE* m_Container; + int m_TextWidth; + float m_BiuTo3Dunits; +}; // This is a call back function, used by GRText to draw the 3D text shape: void addTextSegmToContainer( int x0, int y0, int xf, int yf, void* aData ) { - const SFVEC2F start3DU( x0 * s_biuTo3Dunits, -y0 * s_biuTo3Dunits ); - const SFVEC2F end3DU ( xf * s_biuTo3Dunits, -yf * s_biuTo3Dunits ); + CALLBACK_DATA* data = static_cast( aData ); + + const SFVEC2F start3DU( x0 * data->m_BiuTo3Dunits, -y0 * data->m_BiuTo3Dunits ); + const SFVEC2F end3DU ( xf * data->m_BiuTo3Dunits, -yf * data->m_BiuTo3Dunits ); if( Is_segment_a_circle( start3DU, end3DU ) ) - s_dstcontainer->Add( new FILLED_CIRCLE_2D( start3DU, ( s_textWidth / 2 ) * s_biuTo3Dunits, - *s_boardItem) ); + { + data->m_Container->Add( new FILLED_CIRCLE_2D( start3DU, + data->m_TextWidth * data->m_BiuTo3Dunits / 2, + *data->m_BoardItem ) ); + } else - s_dstcontainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, s_textWidth * s_biuTo3Dunits, - *s_boardItem ) ); + { + data->m_Container->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, + data->m_TextWidth * data->m_BiuTo3Dunits, + *data->m_BoardItem ) ); + } } @@ -90,10 +99,11 @@ void BOARD_ADAPTER::addShapeWithClearance( const PCB_TEXT* aText, CONTAINER_2D_B if( aText->IsMirrored() ) size.x = -size.x; - s_boardItem = (const BOARD_ITEM *) &aText; - s_dstcontainer = aDstContainer; - s_textWidth = aText->GetEffectiveTextPenWidth() + ( 2 * aClearanceValue ); - s_biuTo3Dunits = m_biuTo3Dunits; + CALLBACK_DATA callbackData; + callbackData.m_BoardItem = aText; + callbackData.m_Container = aDstContainer; + callbackData.m_TextWidth = aText->GetEffectiveTextPenWidth() + ( 2 * aClearanceValue ); + callbackData.m_BiuTo3Dunits = m_biuTo3Dunits; // not actually used, but needed by GRText const COLOR4D dummy_color; @@ -105,7 +115,7 @@ void BOARD_ADAPTER::addShapeWithClearance( const PCB_TEXT* aText, CONTAINER_2D_B GRText( nullptr, aText->GetTextPos(), dummy_color, aText->GetShownText(), aText->GetTextAngle(), size, aText->GetHorizJustify(), aText->GetVertJustify(), - penWidth, aText->IsItalic(), isBold, addTextSegmToContainer ); + penWidth, aText->IsItalic(), isBold, addTextSegmToContainer, &callbackData ); } @@ -165,7 +175,6 @@ void BOARD_ADAPTER::addFootprintShapesWithClearance( const FOOTPRINT* aFootprint PCB_LAYER_ID aLayerId, int aInflateValue ) { std::vector texts; // List of FP_TEXT to convert - FP_SHAPE* outline; for( BOARD_ITEM* item : aFootprint->GraphicalItems() ) { @@ -177,20 +186,33 @@ void BOARD_ADAPTER::addFootprintShapesWithClearance( const FOOTPRINT* aFootprint if( text->GetLayer() == aLayerId && text->IsVisible() ) texts.push_back( text ); - } - break; + break; + } + + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_LEADER_T: + { + PCB_DIMENSION_BASE* dimension = static_cast( item ); + + if( dimension->GetLayer() == aLayerId ) + addShapeWithClearance( dimension, aDstContainer, aLayerId, 0 ); + + break; + } case PCB_FP_SHAPE_T: { - outline = (FP_SHAPE*) item; + FP_SHAPE* shape = static_cast( item ); - if( outline->GetLayer() != aLayerId ) - break; + if( shape->GetLayer() == aLayerId ) + addShapeWithClearance( (const PCB_SHAPE*) shape, aDstContainer, aLayerId, 0 ); - addShapeWithClearance( (const PCB_SHAPE*) outline, aDstContainer, aLayerId, 0 ); + break; } - break; default: break; @@ -204,13 +226,14 @@ void BOARD_ADAPTER::addFootprintShapesWithClearance( const FOOTPRINT* aFootprint if( aFootprint->Value().GetLayer() == aLayerId && aFootprint->Value().IsVisible() ) texts.push_back( &aFootprint->Value() ); - s_boardItem = (const BOARD_ITEM *)&aFootprint->Value(); - s_dstcontainer = aDstContainer; - s_biuTo3Dunits = m_biuTo3Dunits; - for( FP_TEXT* text : texts ) { - s_textWidth = text->GetEffectiveTextPenWidth() + ( 2 * aInflateValue ); + CALLBACK_DATA callbackData; + callbackData.m_BoardItem = &aFootprint->Value(); + callbackData.m_Container = aDstContainer; + callbackData.m_BiuTo3Dunits = m_biuTo3Dunits; + callbackData.m_TextWidth = text->GetEffectiveTextPenWidth() + ( 2 * aInflateValue ); + wxSize size = text->GetTextSize(); bool isBold = text->IsBold(); int penWidth = text->GetEffectiveTextPenWidth(); @@ -220,7 +243,7 @@ void BOARD_ADAPTER::addFootprintShapesWithClearance( const FOOTPRINT* aFootprint GRText( nullptr, text->GetTextPos(), BLACK, text->GetShownText(), text->GetDrawRotation(), size, text->GetHorizJustify(), text->GetVertJustify(), penWidth, text->IsItalic(), - isBold, addTextSegmToContainer ); + isBold, addTextSegmToContainer, &callbackData ); } } diff --git a/3d-viewer/3d_canvas/create_layer_poly.cpp b/3d-viewer/3d_canvas/create_layer_poly.cpp index a725d47dd4..4c47361800 100644 --- a/3d-viewer/3d_canvas/create_layer_poly.cpp +++ b/3d-viewer/3d_canvas/create_layer_poly.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Mario Luzeiro - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -66,12 +66,22 @@ void BOARD_ADAPTER::transformFPShapesToPolygon( const FOOTPRINT* aFootprint, PCB { if( item->Type() == PCB_FP_SHAPE_T ) { - FP_SHAPE* outline = (FP_SHAPE*) item; + FP_SHAPE* shape = static_cast( item ); - if( outline->GetLayer() == aLayer ) + if( shape->GetLayer() == aLayer ) { - outline->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0, - ARC_HIGH_DEF, ERROR_INSIDE ); + shape->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0, + ARC_HIGH_DEF, ERROR_INSIDE ); + } + } + else if( BaseType( item->Type() ) == PCB_DIMENSION_T ) + { + PCB_DIMENSION_BASE* dimension = static_cast( item ); + + if( dimension->GetLayer() == aLayer ) + { + dimension->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0, + ARC_HIGH_DEF, ERROR_INSIDE ); } } } diff --git a/common/eda_item.cpp b/common/eda_item.cpp index 5a93f24903..b7d1193b96 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -309,65 +309,70 @@ static struct EDA_ITEM_DESC { ENUM_MAP::Instance() .Undefined( TYPE_NOT_INIT ) - .Map( NOT_USED, wxT( "" ) ) - .Map( SCREEN_T, _HKI( "Screen" ) ) + .Map( NOT_USED, wxT( "" ) ) + .Map( SCREEN_T, _HKI( "Screen" ) ) - .Map( PCB_FOOTPRINT_T, _HKI( "Footprint" ) ) - .Map( PCB_PAD_T, _HKI( "Pad" ) ) - .Map( PCB_SHAPE_T, _HKI( "Graphic" ) ) - .Map( PCB_TEXT_T, _HKI( "Text" ) ) - .Map( PCB_FP_TEXT_T, _HKI( "Text" ) ) - .Map( PCB_FP_SHAPE_T, _HKI( "Graphic" ) ) - .Map( PCB_FP_ZONE_T, _HKI( "Zone" ) ) - .Map( PCB_TRACE_T, _HKI( "Track" ) ) - .Map( PCB_VIA_T, _HKI( "Via" ) ) - .Map( PCB_MARKER_T, _HKI( "Marker" ) ) - .Map( PCB_DIM_ALIGNED_T, _HKI( "Dimension" ) ) - .Map( PCB_DIM_ORTHOGONAL_T, _HKI( "Dimension" ) ) - .Map( PCB_DIM_CENTER_T, _HKI( "Dimension" ) ) - .Map( PCB_DIM_RADIAL_T, _HKI( "Dimension" ) ) - .Map( PCB_DIM_LEADER_T, _HKI( "Leader" ) ) - .Map( PCB_TARGET_T, _HKI( "Target" ) ) - .Map( PCB_ZONE_T, _HKI( "Zone" ) ) - .Map( PCB_ITEM_LIST_T, _HKI( "ItemList" ) ) - .Map( PCB_NETINFO_T, _HKI( "NetInfo" ) ) - .Map( PCB_GROUP_T, _HKI( "Group" ) ) + .Map( PCB_FOOTPRINT_T, _HKI( "Footprint" ) ) + .Map( PCB_PAD_T, _HKI( "Pad" ) ) + .Map( PCB_SHAPE_T, _HKI( "Graphic" ) ) + .Map( PCB_TEXT_T, _HKI( "Text" ) ) + .Map( PCB_FP_TEXT_T, _HKI( "Text" ) ) + .Map( PCB_FP_SHAPE_T, _HKI( "Graphic" ) ) + .Map( PCB_FP_DIM_ALIGNED_T, _HKI( "Dimension" ) ) + .Map( PCB_FP_DIM_ORTHOGONAL_T, _HKI( "Dimension" ) ) + .Map( PCB_FP_DIM_CENTER_T, _HKI( "Dimension" ) ) + .Map( PCB_FP_DIM_RADIAL_T, _HKI( "Dimension" ) ) + .Map( PCB_FP_DIM_LEADER_T, _HKI( "Leader" ) ) + .Map( PCB_FP_ZONE_T, _HKI( "Zone" ) ) + .Map( PCB_TRACE_T, _HKI( "Track" ) ) + .Map( PCB_VIA_T, _HKI( "Via" ) ) + .Map( PCB_MARKER_T, _HKI( "Marker" ) ) + .Map( PCB_DIM_ALIGNED_T, _HKI( "Dimension" ) ) + .Map( PCB_DIM_ORTHOGONAL_T, _HKI( "Dimension" ) ) + .Map( PCB_DIM_CENTER_T, _HKI( "Dimension" ) ) + .Map( PCB_DIM_RADIAL_T, _HKI( "Dimension" ) ) + .Map( PCB_DIM_LEADER_T, _HKI( "Leader" ) ) + .Map( PCB_TARGET_T, _HKI( "Target" ) ) + .Map( PCB_ZONE_T, _HKI( "Zone" ) ) + .Map( PCB_ITEM_LIST_T, _HKI( "ItemList" ) ) + .Map( PCB_NETINFO_T, _HKI( "NetInfo" ) ) + .Map( PCB_GROUP_T, _HKI( "Group" ) ) - .Map( SCH_MARKER_T, _HKI( "Marker" ) ) - .Map( SCH_JUNCTION_T, _HKI( "Junction" ) ) - .Map( SCH_NO_CONNECT_T, _HKI( "No-Connect Flag" ) ) - .Map( SCH_BUS_WIRE_ENTRY_T, _HKI( "Wire Entry" ) ) - .Map( SCH_BUS_BUS_ENTRY_T, _HKI( "Bus Entry" ) ) - .Map( SCH_LINE_T, _HKI( "Line" ) ) - .Map( SCH_BITMAP_T, _HKI( "Bitmap" ) ) - .Map( SCH_TEXT_T, _HKI( "Text" ) ) - .Map( SCH_LABEL_T, _HKI( "Net Label" ) ) - .Map( SCH_NETCLASS_FLAG_T, _HKI( "Net Class Flag" ) ) - .Map( SCH_GLOBAL_LABEL_T, _HKI( "Global Label" ) ) - .Map( SCH_HIER_LABEL_T, _HKI( "Hierarchical Label" ) ) - .Map( SCH_FIELD_T, _HKI( "Field" ) ) - .Map( SCH_SYMBOL_T, _HKI( "Symbol" ) ) - .Map( SCH_PIN_T, _HKI( "Pin" ) ) - .Map( SCH_SHEET_PIN_T, _HKI( "Sheet Pin" ) ) - .Map( SCH_SHEET_T, _HKI( "Sheet" ) ) + .Map( SCH_MARKER_T, _HKI( "Marker" ) ) + .Map( SCH_JUNCTION_T, _HKI( "Junction" ) ) + .Map( SCH_NO_CONNECT_T, _HKI( "No-Connect Flag" ) ) + .Map( SCH_BUS_WIRE_ENTRY_T, _HKI( "Wire Entry" ) ) + .Map( SCH_BUS_BUS_ENTRY_T, _HKI( "Bus Entry" ) ) + .Map( SCH_LINE_T, _HKI( "Line" ) ) + .Map( SCH_BITMAP_T, _HKI( "Bitmap" ) ) + .Map( SCH_TEXT_T, _HKI( "Text" ) ) + .Map( SCH_LABEL_T, _HKI( "Net Label" ) ) + .Map( SCH_NETCLASS_FLAG_T, _HKI( "Net Class Flag" ) ) + .Map( SCH_GLOBAL_LABEL_T, _HKI( "Global Label" ) ) + .Map( SCH_HIER_LABEL_T, _HKI( "Hierarchical Label" ) ) + .Map( SCH_FIELD_T, _HKI( "Field" ) ) + .Map( SCH_SYMBOL_T, _HKI( "Symbol" ) ) + .Map( SCH_PIN_T, _HKI( "Pin" ) ) + .Map( SCH_SHEET_PIN_T, _HKI( "Sheet Pin" ) ) + .Map( SCH_SHEET_T, _HKI( "Sheet" ) ) // Synthetic search tokens don't need to be included... //.Map( SCH_FIELD_LOCATE_REFERENCE_T, _HKI( "Field Locate Reference" ) ) //.Map( SCH_FIELD_LOCATE_VALUE_T, _HKI( "Field Locate Value" ) ) //.Map( SCH_FIELD_LOCATE_FOOTPRINT_T, _HKI( "Field Locate Footprint" ) ) - .Map( SCH_SCREEN_T, _HKI( "SCH Screen" ) ) + .Map( SCH_SCREEN_T, _HKI( "SCH Screen" ) ) - .Map( LIB_SYMBOL_T, _HKI( "Symbol" ) ) - .Map( LIB_ALIAS_T, _HKI( "Alias" ) ) - .Map( LIB_SHAPE_T, _HKI( "Graphic" ) ) - .Map( LIB_TEXT_T, _HKI( "Text" ) ) - .Map( LIB_PIN_T, _HKI( "Pin" ) ) - .Map( LIB_FIELD_T, _HKI( "Symbol Field" ) ) + .Map( LIB_SYMBOL_T, _HKI( "Symbol" ) ) + .Map( LIB_ALIAS_T, _HKI( "Alias" ) ) + .Map( LIB_SHAPE_T, _HKI( "Graphic" ) ) + .Map( LIB_TEXT_T, _HKI( "Text" ) ) + .Map( LIB_PIN_T, _HKI( "Pin" ) ) + .Map( LIB_FIELD_T, _HKI( "Symbol Field" ) ) - .Map( GERBER_LAYOUT_T, _HKI( "Gerber Layout" ) ) - .Map( GERBER_DRAW_ITEM_T, _HKI( "Draw Item" ) ) - .Map( GERBER_IMAGE_T, _HKI( "Image" ) ); + .Map( GERBER_LAYOUT_T, _HKI( "Gerber Layout" ) ) + .Map( GERBER_DRAW_ITEM_T, _HKI( "Draw Item" ) ) + .Map( GERBER_IMAGE_T, _HKI( "Image" ) ); PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); REGISTER_TYPE( EDA_ITEM ); diff --git a/include/core/typeinfo.h b/include/core/typeinfo.h index 4b36c1d59e..d39709abbf 100644 --- a/include/core/typeinfo.h +++ b/include/core/typeinfo.h @@ -85,28 +85,33 @@ enum KICAD_T SCREEN_T, ///< not really an item, used to identify a screen // Items in pcb - PCB_FOOTPRINT_T, ///< class FOOTPRINT, a footprint - PCB_PAD_T, ///< class PAD, a pad in a footprint - PCB_SHAPE_T, ///< class PCB_SHAPE, a segment not on copper layers - PCB_TEXT_T, ///< class PCB_TEXT, text on a layer - PCB_FP_TEXT_T, ///< class FP_TEXT, text in a footprint - PCB_FP_SHAPE_T, ///< class FP_SHAPE, a footprint edge - PCB_FP_ZONE_T, ///< class ZONE, managed by a footprint - PCB_TRACE_T, ///< class PCB_TRACK, a track segment (segment on a copper layer) - PCB_VIA_T, ///< class PCB_VIA, a via (like a track segment on a copper layer) - PCB_ARC_T, ///< class PCB_ARC, an arc track segment on a copper layer - PCB_MARKER_T, ///< class PCB_MARKER, a marker used to show something - PCB_DIMENSION_T, ///< class PCB_DIMENSION_BASE: abstract dimension meta-type - PCB_DIM_ALIGNED_T, ///< class PCB_DIM_ALIGNED, a linear dimension (graphic item) - PCB_DIM_LEADER_T, ///< class PCB_DIM_LEADER, a leader dimension (graphic item) - PCB_DIM_CENTER_T, ///< class PCB_DIM_CENTER, a center point marking (graphic item) - PCB_DIM_RADIAL_T, ///< class PCB_DIM_RADIAL, a radius or diameter dimension - PCB_DIM_ORTHOGONAL_T, ///< class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y - PCB_TARGET_T, ///< class PCB_TARGET, a target (graphic item) - PCB_ZONE_T, ///< class ZONE, a copper pour area - PCB_ITEM_LIST_T, ///< class BOARD_ITEM_LIST, a list of board items - PCB_NETINFO_T, ///< class NETINFO_ITEM, a description of a net - PCB_GROUP_T, ///< class PCB_GROUP, a set of BOARD_ITEMs + PCB_FOOTPRINT_T, ///< class FOOTPRINT, a footprint + PCB_PAD_T, ///< class PAD, a pad in a footprint + PCB_SHAPE_T, ///< class PCB_SHAPE, a segment not on copper layers + PCB_TEXT_T, ///< class PCB_TEXT, text on a layer + PCB_FP_TEXT_T, ///< class FP_TEXT, text in a footprint + PCB_FP_SHAPE_T, ///< class FP_SHAPE, a footprint edge + PCB_FP_DIM_ALIGNED_T, ///< class PCB_DIM_ALIGNED, a linear dimension (graphic item) + PCB_FP_DIM_LEADER_T, ///< class PCB_DIM_LEADER, a leader dimension (graphic item) + PCB_FP_DIM_CENTER_T, ///< class PCB_DIM_CENTER, a center point marking (graphic item) + PCB_FP_DIM_RADIAL_T, ///< class PCB_DIM_RADIAL, a radius or diameter dimension + PCB_FP_DIM_ORTHOGONAL_T, ///< class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y + PCB_FP_ZONE_T, ///< class ZONE, managed by a footprint + PCB_TRACE_T, ///< class PCB_TRACK, a track segment (segment on a copper layer) + PCB_VIA_T, ///< class PCB_VIA, a via (like a track segment on a copper layer) + PCB_ARC_T, ///< class PCB_ARC, an arc track segment on a copper layer + PCB_MARKER_T, ///< class PCB_MARKER, a marker used to show something + PCB_DIMENSION_T, ///< class PCB_DIMENSION_BASE: abstract dimension meta-type + PCB_DIM_ALIGNED_T, ///< class PCB_DIM_ALIGNED, a linear dimension (graphic item) + PCB_DIM_LEADER_T, ///< class PCB_DIM_LEADER, a leader dimension (graphic item) + PCB_DIM_CENTER_T, ///< class PCB_DIM_CENTER, a center point marking (graphic item) + PCB_DIM_RADIAL_T, ///< class PCB_DIM_RADIAL, a radius or diameter dimension + PCB_DIM_ORTHOGONAL_T, ///< class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y + PCB_TARGET_T, ///< class PCB_TARGET, a target (graphic item) + PCB_ZONE_T, ///< class ZONE, a copper pour area + PCB_ITEM_LIST_T , ///< class BOARD_ITEM_LIST, a list of board items + PCB_NETINFO_T, ///< class NETINFO_ITEM, a description of a net + PCB_GROUP_T, ///< class PCB_GROUP, a set of BOARD_ITEMs PCB_LOCATE_STDVIA_T, PCB_LOCATE_UVIA_T, @@ -264,6 +269,11 @@ constexpr KICAD_T BaseType( const KICAD_T aType ) case PCB_DIM_RADIAL_T: case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_LEADER_T: return PCB_DIMENSION_T; default: @@ -389,6 +399,10 @@ constexpr bool IsPcbnewType( const KICAD_T aType ) case PCB_TEXT_T: case PCB_FP_TEXT_T: case PCB_FP_SHAPE_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_LEADER_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_ORTHOGONAL_T: case PCB_FP_ZONE_T: case PCB_TRACE_T: case PCB_VIA_T: diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 494e34ce8a..b3fa0be7cb 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -309,10 +309,6 @@ void BOARD::Move( const wxPoint& aMoveVector ) // overload PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T, - // PCB_PAD_T, Can't be at board level - // PCB_FP_TEXT_T, Can't be at board level - // PCB_FP_SHAPE_T, Can't be at board level - // PCB_FP_ZONE_T, Can't be at board level PCB_FOOTPRINT_T, PCB_ZONE_T, EOT @@ -1230,6 +1226,11 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T s case PCB_PAD_T: case PCB_FP_TEXT_T: case PCB_FP_SHAPE_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_LEADER_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: case PCB_FP_ZONE_T: // this calls FOOTPRINT::Visit() on each footprint. @@ -1244,6 +1245,11 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T s case PCB_PAD_T: case PCB_FP_TEXT_T: case PCB_FP_SHAPE_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_LEADER_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: case PCB_FP_ZONE_T: continue; diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index d39d26ddf3..c6db5e1e56 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -175,6 +175,11 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a else if( boardItem->Type() == PCB_PAD_T || boardItem->Type() == PCB_FP_TEXT_T || boardItem->Type() == PCB_FP_SHAPE_T || + boardItem->Type() == PCB_FP_DIM_ALIGNED_T || + boardItem->Type() == PCB_FP_DIM_LEADER_T || + boardItem->Type() == PCB_FP_DIM_CENTER_T || + boardItem->Type() == PCB_FP_DIM_RADIAL_T || + boardItem->Type() == PCB_FP_DIM_ORTHOGONAL_T || boardItem->Type() == PCB_FP_ZONE_T ) { wxASSERT( boardItem->GetParent() && @@ -217,6 +222,11 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a case PCB_PAD_T: case PCB_FP_SHAPE_T: case PCB_FP_TEXT_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_LEADER_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: case PCB_FP_ZONE_T: // This level can only handle footprint children in the footprint editor as // only in that case has the entire footprint (and all its children) already @@ -447,6 +457,11 @@ EDA_ITEM* BOARD_COMMIT::parentObject( EDA_ITEM* aItem ) const case PCB_PAD_T: case PCB_FP_SHAPE_T: case PCB_FP_TEXT_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_LEADER_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: case PCB_FP_ZONE_T: return aItem->GetParent(); diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 456e7ba031..b262c41a4b 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -106,6 +106,11 @@ const KICAD_T GENERAL_COLLECTOR::PadsOrTracks[] = { const KICAD_T GENERAL_COLLECTOR::FootprintItems[] = { PCB_FP_TEXT_T, PCB_FP_SHAPE_T, + PCB_FP_DIM_ALIGNED_T, + PCB_FP_DIM_ORTHOGONAL_T, + PCB_FP_DIM_CENTER_T, + PCB_FP_DIM_RADIAL_T, + PCB_FP_DIM_LEADER_T, PCB_PAD_T, PCB_FP_ZONE_T, PCB_GROUP_T, @@ -144,6 +149,11 @@ const KICAD_T GENERAL_COLLECTOR::Dimensions[] = { PCB_DIM_ORTHOGONAL_T, PCB_DIM_CENTER_T, PCB_DIM_RADIAL_T, + PCB_FP_DIM_ALIGNED_T, + PCB_FP_DIM_LEADER_T, + PCB_FP_DIM_ORTHOGONAL_T, + PCB_FP_DIM_CENTER_T, + PCB_FP_DIM_RADIAL_T, EOT }; @@ -287,6 +297,16 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) shape = static_cast( item ); break; + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_LEADER_T: + footprint = static_cast( item->GetParent() ); + + // Fallthrough to get the zone as well + KI_FALLTHROUGH; + case PCB_DIM_ALIGNED_T: case PCB_DIM_CENTER_T: case PCB_DIM_RADIAL_T: diff --git a/pcbnew/dialogs/dialog_dimension_properties.cpp b/pcbnew/dialogs/dialog_dimension_properties.cpp index 4cf40e4c17..e26a8fd3db 100644 --- a/pcbnew/dialogs/dialog_dimension_properties.cpp +++ b/pcbnew/dialogs/dialog_dimension_properties.cpp @@ -54,6 +54,7 @@ DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES( PCB_BASE_EDIT_FRAME* a switch( m_dimension->Type() ) { case PCB_DIM_LEADER_T: + case PCB_FP_DIM_LEADER_T: // Hide the main format controls and keep the leader controls shown m_sizerFormat->GetStaticBox()->Hide(); m_sizerCenter->GetStaticBox()->Hide(); @@ -66,7 +67,8 @@ DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES( PCB_BASE_EDIT_FRAME* a m_cbTextPositionMode->Hide(); break; - case PCB_DIM_CENTER_T: + case PCB_DIM_CENTER_T: + case PCB_FP_DIM_CENTER_T: m_sizerLeader->GetStaticBox()->Hide(); m_sizerFormat->GetStaticBox()->Hide(); m_sizerText->GetStaticBox()->Hide(); diff --git a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp index d2fe414d14..a692e7060b 100644 --- a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -473,7 +473,9 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow() // Go through all other footprint items for( BOARD_ITEM* boardItem : fp->GraphicalItems() ) { - if( boardItem->Type() == PCB_FP_TEXT_T ) + KICAD_T itemType = boardItem->Type(); + + if( itemType == PCB_FP_TEXT_T ) { // We are guaranteed to always get an EDA_TEXT in this statement, but we must // use the dynamic_cast to move through the type tree anyway. @@ -486,7 +488,7 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow() else if( m_otherFields->GetValue() ) visitItem( commit, boardItem ); } - else if( boardItem->Type() == PCB_FP_SHAPE_T ) + else if( itemType == PCB_FP_SHAPE_T || BaseType( itemType ) == PCB_DIMENSION_T ) { if( m_footprintGraphics->GetValue() ) visitItem( commit, boardItem ); diff --git a/pcbnew/drc/drc_test_provider.cpp b/pcbnew/drc/drc_test_provider.cpp index 83f8cd4d3b..7807024cc8 100644 --- a/pcbnew/drc/drc_test_provider.cpp +++ b/pcbnew/drc/drc_test_provider.cpp @@ -194,7 +194,7 @@ int DRC_TEST_PROVIDER::forEachGeometryItem( const std::vector& aTypes, { if( (item->GetLayerSet() & aLayers).any() ) { - if( typeMask[PCB_DIMENSION_T] && BaseType( item->Type() ) == PCB_DIMENSION_T ) + if( typeMask[ PCB_DIMENSION_T ] && BaseType( item->Type() ) == PCB_DIMENSION_T ) { if( !aFunc( item ) ) return n; @@ -280,7 +280,14 @@ int DRC_TEST_PROVIDER::forEachGeometryItem( const std::vector& aTypes, { if( (dwg->GetLayerSet() & aLayers).any() ) { - if( typeMask[ PCB_FP_TEXT_T ] && dwg->Type() == PCB_FP_TEXT_T ) + if( typeMask[ PCB_DIMENSION_T ] && BaseType( dwg->Type() ) == PCB_DIMENSION_T ) + { + if( !aFunc( dwg ) ) + return n; + + n++; + } + else if( typeMask[ PCB_FP_TEXT_T ] && dwg->Type() == PCB_FP_TEXT_T ) { if( !aFunc( dwg ) ) return n; diff --git a/pcbnew/drc/drc_test_provider_copper_clearance.cpp b/pcbnew/drc/drc_test_provider_copper_clearance.cpp index 285065cf79..aa01719817 100644 --- a/pcbnew/drc/drc_test_provider_copper_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_copper_clearance.cpp @@ -192,8 +192,7 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run() static const std::vector itemTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, PCB_PAD_T, PCB_SHAPE_T, PCB_FP_SHAPE_T, - PCB_TEXT_T, PCB_FP_TEXT_T, PCB_DIMENSION_T, PCB_DIM_ALIGNED_T, PCB_DIM_LEADER_T, - PCB_DIM_CENTER_T, PCB_DIM_RADIAL_T, PCB_DIM_ORTHOGONAL_T + PCB_TEXT_T, PCB_FP_TEXT_T, PCB_DIMENSION_T }; forEachGeometryItem( itemTypes, LSET::AllCuMask(), countItems ); diff --git a/pcbnew/drc/drc_test_provider_disallow.cpp b/pcbnew/drc/drc_test_provider_disallow.cpp index f7052a26dd..ccac12fd01 100644 --- a/pcbnew/drc/drc_test_provider_disallow.cpp +++ b/pcbnew/drc/drc_test_provider_disallow.cpp @@ -99,24 +99,12 @@ bool DRC_TEST_PROVIDER_DISALLOW::Run() if( !m_drcEngine->IsErrorLimitExceeded( DRCE_TEXT_ON_EDGECUTS ) && item->GetLayer() == Edge_Cuts ) { - switch( item->Type() ) - { - case PCB_TEXT_T: - case PCB_DIM_ALIGNED_T: - case PCB_DIM_CENTER_T: - case PCB_DIM_RADIAL_T: - case PCB_DIM_ORTHOGONAL_T: - case PCB_DIM_LEADER_T: + if( item->Type() == PCB_TEXT_T || BaseType( item->Type() ) == PCB_DIMENSION_T ) { std::shared_ptr drc = DRC_ITEM::Create( DRCE_TEXT_ON_EDGECUTS ); drc->SetItems( item ); reportViolation( drc, item->GetPosition() ); } - break; - - default: - break; - } } if( m_drcEngine->IsErrorLimitExceeded( DRCE_ALLOWED_ITEMS ) ) diff --git a/pcbnew/drc/drc_test_provider_mechanical_clearance.cpp b/pcbnew/drc/drc_test_provider_mechanical_clearance.cpp index 69421f8ba7..cc3860f868 100644 --- a/pcbnew/drc/drc_test_provider_mechanical_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_mechanical_clearance.cpp @@ -178,8 +178,7 @@ bool DRC_TEST_PROVIDER_MECHANICAL_CLEARANCE::Run() static const std::vector itemTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, PCB_PAD_T, PCB_SHAPE_T, PCB_FP_SHAPE_T, - PCB_TEXT_T, PCB_FP_TEXT_T, PCB_DIMENSION_T, PCB_DIM_ALIGNED_T, PCB_DIM_LEADER_T, - PCB_DIM_CENTER_T, PCB_DIM_RADIAL_T, PCB_DIM_ORTHOGONAL_T + PCB_TEXT_T, PCB_FP_TEXT_T, PCB_DIMENSION_T }; forEachGeometryItem( itemTypes, LSET::AllLayersMask(), countItems ); diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 85e861d6bc..0b491278fb 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -140,8 +140,11 @@ void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem ) case PCB_DIM_RADIAL_T: case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: - ShowDimensionPropertiesDialog( static_cast( aItem ) ); + { + DIALOG_DIMENSION_PROPERTIES dlg( this, static_cast( aItem ) ); + dlg.ShowQuasiModal(); break; + } case PCB_FP_TEXT_T: ShowTextPropertiesDialog( aItem ); @@ -168,13 +171,3 @@ void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem ) } } - -void PCB_EDIT_FRAME::ShowDimensionPropertiesDialog( PCB_DIMENSION_BASE* aDimension ) -{ - if( aDimension == nullptr ) - return; - - DIALOG_DIMENSION_PROPERTIES dlg( this, aDimension ); - dlg.ShowQuasiModal(); -} - diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index f52d2d1eed..3d8d223849 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -197,16 +197,16 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ BRDITEMS_PLOTTER itemplotter( plotter, m_pcb, plot_opts ); itemplotter.SetLayerSet( Edge_Cuts ); - for( auto PtStruct : m_pcb->Drawings() ) + for( BOARD_ITEM* item : m_pcb->Drawings() ) { - switch( PtStruct->Type() ) + switch( item->Type() ) { case PCB_SHAPE_T: - itemplotter.PlotPcbShape( (PCB_SHAPE*) PtStruct ); + itemplotter.PlotPcbShape( (PCB_SHAPE*) item ); break; case PCB_TEXT_T: - itemplotter.PlotPcbText( (PCB_TEXT*) PtStruct ); + itemplotter.PlotPcbText( (PCB_TEXT*) item ); break; case PCB_DIM_ALIGNED_T: diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 8298080a69..f63c08a833 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -36,10 +36,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -511,6 +511,11 @@ void FOOTPRINT::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode ) wxASSERT( static_cast( aBoardItem )->GetType() == FP_TEXT::TEXT_is_DIVERS ); KI_FALLTHROUGH; + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_LEADER_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: case PCB_FP_SHAPE_T: if( aMode == ADD_MODE::APPEND ) m_drawings.push_back( aBoardItem ); @@ -566,6 +571,11 @@ void FOOTPRINT::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode ) "Please report this bug: Invalid remove operation on required text" ); KI_FALLTHROUGH; + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_LEADER_T: case PCB_FP_SHAPE_T: for( auto it = m_drawings.begin(); it != m_drawings.end(); ++it ) { @@ -762,7 +772,7 @@ const EDA_RECT FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisi for( BOARD_ITEM* item : m_drawings ) { - if( item->Type() == PCB_FP_SHAPE_T ) + if( item->Type() == PCB_FP_SHAPE_T || BaseType( item->Type() ) == PCB_DIMENSION_T ) area.Merge( item->GetBoundingBox() ); } @@ -805,12 +815,18 @@ const EDA_RECT FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisi if( ( m_value->IsVisible() && valueLayerIsVisible ) - || aIncludeInvisibleText || noDrawItems ) + || aIncludeInvisibleText + || noDrawItems ) + { area.Merge( m_value->GetBoundingBox() ); + } if( ( m_reference->IsVisible() && refLayerIsVisible ) - || aIncludeInvisibleText || noDrawItems ) + || aIncludeInvisibleText + || noDrawItems ) + { area.Merge( m_reference->GetBoundingBox() ); + } } if( board ) @@ -851,7 +867,7 @@ SHAPE_POLY_SET FOOTPRINT::GetBoundingHull() const for( BOARD_ITEM* item : m_drawings ) { - if( item->Type() == PCB_FP_SHAPE_T ) + if( item->Type() == PCB_FP_SHAPE_T || BaseType( item->Type() ) == PCB_DIMENSION_T ) { item->TransformShapeWithClearanceToPolygon( rawPolys, UNDEFINED_LAYER, 0, ARC_LOW_DEF, ERROR_OUTSIDE ); @@ -1225,6 +1241,11 @@ SEARCH_RESULT FOOTPRINT::Visit( INSPECTOR inspector, void* testData, const KICAD // Intentionally fall through since m_Drawings can hold PCB_FP_SHAPE_T also KI_FALLTHROUGH; + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_LEADER_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: case PCB_FP_SHAPE_T: result = IterateForward( m_drawings, inspector, testData, p ); @@ -1235,6 +1256,11 @@ SEARCH_RESULT FOOTPRINT::Visit( INSPECTOR inspector, void* testData, const KICAD { case PCB_FP_TEXT_T: case PCB_FP_SHAPE_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_LEADER_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: continue; default: @@ -1583,6 +1609,14 @@ void FOOTPRINT::SetPosition( const wxPoint& aPos ) break; } + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_LEADER_T: + item->Move( delta ); + break; + default: wxMessageBox( wxT( "Draw type undefined." ) ); break; @@ -1794,6 +1828,21 @@ BOARD_ITEM* FOOTPRINT::DuplicateItem( const BOARD_ITEM* aItem, bool aAddToFootpr break; } + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_LEADER_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: + { + PCB_DIMENSION_BASE* dimension = static_cast( aItem->Duplicate() ); + + if( aAddToFootprint ) + Add( dimension ); + + new_item = dimension; + break; + } + case PCB_GROUP_T: new_item = static_cast( aItem )->DeepDuplicate(); break; diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index ea8aec71bb..bfae6e1f25 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -1149,6 +1149,11 @@ void FOOTPRINT_EDIT_FRAME::setupUIConditions() CURRENT_EDIT_TOOL( PCB_ACTIONS::drawPolygon ); CURRENT_EDIT_TOOL( PCB_ACTIONS::drawRuleArea ); CURRENT_EDIT_TOOL( PCB_ACTIONS::placeText ); + CURRENT_EDIT_TOOL( PCB_ACTIONS::drawAlignedDimension ); + CURRENT_EDIT_TOOL( PCB_ACTIONS::drawOrthogonalDimension ); + CURRENT_EDIT_TOOL( PCB_ACTIONS::drawCenterDimension ); + CURRENT_EDIT_TOOL( PCB_ACTIONS::drawRadialDimension ); + CURRENT_EDIT_TOOL( PCB_ACTIONS::drawLeader ); CURRENT_EDIT_TOOL( PCB_ACTIONS::setAnchor ); CURRENT_EDIT_TOOL( PCB_ACTIONS::gridSetOrigin ); diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index 14b24703b3..dec8f4efe6 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -37,6 +37,8 @@ #include #include #include +#include +#include using namespace std::placeholders; @@ -192,6 +194,17 @@ void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem ) ShowGraphicItemPropertiesDialog( aItem ); break; + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_LEADER_T: + { + DIALOG_DIMENSION_PROPERTIES dlg( this, static_cast( aItem ) ); + dlg.ShowQuasiModal(); + break; + } + case PCB_FP_ZONE_T: { ZONE* zone = static_cast( aItem ); diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index e68bf39b09..426a6e35e4 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -177,15 +177,22 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool ); placeMenu->Add( PCB_ACTIONS::placePad ); + placeMenu->Add( PCB_ACTIONS::drawRuleArea ); placeMenu->AppendSeparator(); - placeMenu->Add( PCB_ACTIONS::placeText ); placeMenu->Add( PCB_ACTIONS::drawLine ); placeMenu->Add( PCB_ACTIONS::drawArc ); placeMenu->Add( PCB_ACTIONS::drawRectangle ); placeMenu->Add( PCB_ACTIONS::drawCircle ); placeMenu->Add( PCB_ACTIONS::drawPolygon ); - placeMenu->Add( PCB_ACTIONS::drawRuleArea ); + placeMenu->Add( PCB_ACTIONS::placeText ); + + placeMenu->AppendSeparator(); + placeMenu->Add( PCB_ACTIONS::drawAlignedDimension ); + placeMenu->Add( PCB_ACTIONS::drawOrthogonalDimension ); + placeMenu->Add( PCB_ACTIONS::drawCenterDimension ); + placeMenu->Add( PCB_ACTIONS::drawRadialDimension ); + placeMenu->Add( PCB_ACTIONS::drawLeader ); placeMenu->AppendSeparator(); placeMenu->Add( PCB_ACTIONS::setAnchor ); diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 8e077f4366..2b7ccdab57 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -316,12 +316,12 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() placeMenu->Add( muwaveSubmenu ); placeMenu->AppendSeparator(); - placeMenu->Add( PCB_ACTIONS::placeText ); placeMenu->Add( PCB_ACTIONS::drawLine ); placeMenu->Add( PCB_ACTIONS::drawArc ); placeMenu->Add( PCB_ACTIONS::drawRectangle ); placeMenu->Add( PCB_ACTIONS::drawCircle ); placeMenu->Add( PCB_ACTIONS::drawPolygon ); + placeMenu->Add( PCB_ACTIONS::placeText ); placeMenu->AppendSeparator(); placeMenu->Add( PCB_ACTIONS::drawAlignedDimension ); diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 906634ba31..e434ce59c8 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -344,11 +344,16 @@ void PCB_BASE_FRAME::FocusOnItem( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer ) case PCB_FP_ZONE_T: case PCB_TRACE_T: case PCB_ARC_T: - case PCB_DIMENSION_T: case PCB_DIM_ALIGNED_T: case PCB_DIM_LEADER_T: case PCB_DIM_CENTER_T: + case PCB_DIM_RADIAL_T: case PCB_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_LEADER_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: case PCB_ZONE_T: aItem->TransformShapeWithClearanceToPolygon( itemPoly, aLayer, 0, Millimeter2iu( 0.1 ), ERROR_INSIDE ); diff --git a/pcbnew/pcb_dimension.cpp b/pcbnew/pcb_dimension.cpp index 3f5512a5cc..3614314f6d 100644 --- a/pcbnew/pcb_dimension.cpp +++ b/pcbnew/pcb_dimension.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -37,7 +36,6 @@ #include #include #include -#include PCB_DIMENSION_BASE::PCB_DIMENSION_BASE( BOARD_ITEM* aParent, KICAD_T aType ) : @@ -159,15 +157,10 @@ DIM_UNITS_MODE PCB_DIMENSION_BASE::GetUnitsMode() const { switch( m_units ) { - case EDA_UNITS::MILLIMETRES: - return DIM_UNITS_MODE::MILLIMETRES; - - case EDA_UNITS::MILS: - return DIM_UNITS_MODE::MILS; - default: - case EDA_UNITS::INCHES: - return DIM_UNITS_MODE::INCHES; + case EDA_UNITS::INCHES: return DIM_UNITS_MODE::INCHES; + case EDA_UNITS::MILLIMETRES: return DIM_UNITS_MODE::MILLIMETRES; + case EDA_UNITS::MILS: return DIM_UNITS_MODE::MILS; } } } @@ -179,21 +172,10 @@ void PCB_DIMENSION_BASE::SetUnitsMode( DIM_UNITS_MODE aMode ) switch( aMode ) { - case DIM_UNITS_MODE::INCHES: - m_units = EDA_UNITS::INCHES; - break; - - case DIM_UNITS_MODE::MILS: - m_units = EDA_UNITS::MILS; - break; - - case DIM_UNITS_MODE::MILLIMETRES: - m_units = EDA_UNITS::MILLIMETRES; - break; - - case DIM_UNITS_MODE::AUTOMATIC: - m_autoUnits = true; - break; + case DIM_UNITS_MODE::INCHES: m_units = EDA_UNITS::INCHES; break; + case DIM_UNITS_MODE::MILS: m_units = EDA_UNITS::MILS; break; + case DIM_UNITS_MODE::MILLIMETRES: m_units = EDA_UNITS::MILLIMETRES; break; + case DIM_UNITS_MODE::AUTOMATIC: m_autoUnits = true; break; } } @@ -324,7 +306,7 @@ void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, ORIGIN_TRANSFORMS originTransforms = aFrame->GetOriginTransforms(); units = aFrame->GetUserUnits(); - if( Type() == PCB_DIM_CENTER_T ) + if( Type() == PCB_DIM_CENTER_T || Type() == PCB_FP_DIM_CENTER_T ) { wxPoint startCoord = originTransforms.ToDisplayAbs( GetStart() ); wxString start = wxString::Format( "@(%s, %s)", @@ -553,7 +535,7 @@ EDA_ITEM* PCB_DIM_ALIGNED::Clone() const void PCB_DIM_ALIGNED::SwapData( BOARD_ITEM* aImage ) { - assert( aImage->Type() == PCB_DIM_ALIGNED_T ); + wxASSERT( aImage->Type() == Type() ); m_shapes.clear(); static_cast( aImage )->m_shapes.clear(); @@ -720,8 +702,8 @@ void PCB_DIM_ALIGNED::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector( m_arrowLength * std::sin( DEG2RAD( s_arrowAngle ) ) ); @@ -737,7 +719,7 @@ EDA_ITEM* PCB_DIM_ORTHOGONAL::Clone() const void PCB_DIM_ORTHOGONAL::SwapData( BOARD_ITEM* aImage ) { - assert( aImage->Type() == PCB_DIM_ORTHOGONAL_T ); + wxASSERT( aImage->Type() == Type() ); m_shapes.clear(); static_cast( aImage )->m_shapes.clear(); @@ -950,8 +932,8 @@ void PCB_DIM_ORTHOGONAL::Rotate( const wxPoint& aRotCentre, double aAngle ) } -PCB_DIM_LEADER::PCB_DIM_LEADER( BOARD_ITEM* aParent ) : - PCB_DIMENSION_BASE( aParent, PCB_DIM_LEADER_T ), +PCB_DIM_LEADER::PCB_DIM_LEADER( BOARD_ITEM* aParent, bool aInFP ) : + PCB_DIMENSION_BASE( aParent, aInFP ? PCB_FP_DIM_LEADER_T : PCB_DIM_LEADER_T ), m_textBorder( DIM_TEXT_BORDER::NONE ) { m_unitsFormat = DIM_UNITS_FORMAT::NO_SUFFIX; @@ -970,7 +952,7 @@ EDA_ITEM* PCB_DIM_LEADER::Clone() const void PCB_DIM_LEADER::SwapData( BOARD_ITEM* aImage ) { - assert( aImage->Type() == PCB_DIM_LEADER_T ); + wxASSERT( aImage->Type() == Type() ); m_shapes.clear(); static_cast( aImage )->m_shapes.clear(); @@ -1098,8 +1080,8 @@ void PCB_DIM_LEADER::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorType() == PCB_DIM_RADIAL_T ); + wxASSERT( aImage->Type() == Type() ); m_shapes.clear(); static_cast( aImage )->m_shapes.clear(); @@ -1230,8 +1212,8 @@ void PCB_DIM_RADIAL::updateGeometry() } -PCB_DIM_CENTER::PCB_DIM_CENTER( BOARD_ITEM* aParent ) : - PCB_DIMENSION_BASE( aParent, PCB_DIM_CENTER_T ) +PCB_DIM_CENTER::PCB_DIM_CENTER( BOARD_ITEM* aParent, bool aInFP ) : + PCB_DIMENSION_BASE( aParent, aInFP ? PCB_FP_DIM_CENTER_T : PCB_DIM_CENTER_T ) { m_unitsFormat = DIM_UNITS_FORMAT::NO_SUFFIX; m_overrideTextEnabled = true; @@ -1246,7 +1228,7 @@ EDA_ITEM* PCB_DIM_CENTER::Clone() const void PCB_DIM_CENTER::SwapData( BOARD_ITEM* aImage ) { - assert( aImage->Type() == PCB_DIM_CENTER_T ); + wxASSERT( aImage->Type() == Type() ); std::swap( *static_cast( this ), *static_cast( aImage ) ); } diff --git a/pcbnew/pcb_dimension.h b/pcbnew/pcb_dimension.h index 971e002d79..b5811012e3 100644 --- a/pcbnew/pcb_dimension.h +++ b/pcbnew/pcb_dimension.h @@ -250,7 +250,7 @@ public: void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, - bool aIgnoreLineWidth ) const override; + bool aIgnoreLineWidth = false ) const override; #if defined(DEBUG) virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } @@ -344,7 +344,7 @@ protected: class PCB_DIM_ALIGNED : public PCB_DIMENSION_BASE { public: - PCB_DIM_ALIGNED( BOARD_ITEM* aParent, KICAD_T aType = PCB_DIM_ALIGNED_T ); + PCB_DIM_ALIGNED( BOARD_ITEM* aParent, KICAD_T aType ); // Do not create a copy constructor & operator=. // The ones generated by the compiler are adequate. @@ -353,7 +353,8 @@ public: static inline bool ClassOf( const EDA_ITEM* aItem ) { - return aItem && PCB_DIM_ALIGNED_T == aItem->Type(); + return aItem && ( aItem->Type() == PCB_DIM_ALIGNED_T + || aItem->Type() == PCB_FP_DIM_ALIGNED_T ); } EDA_ITEM* Clone() const override; @@ -431,13 +432,14 @@ public: VERTICAL // Aligned with y-axis }; - PCB_DIM_ORTHOGONAL( BOARD_ITEM* aParent ); + PCB_DIM_ORTHOGONAL( BOARD_ITEM* aParent, bool aInFP = false ); ~PCB_DIM_ORTHOGONAL() = default; static inline bool ClassOf( const EDA_ITEM* aItem ) { - return aItem && PCB_DIM_ORTHOGONAL_T == aItem->Type(); + return aItem && ( aItem->Type() == PCB_DIM_ORTHOGONAL_T + || aItem->Type() == PCB_FP_DIM_ORTHOGONAL_T ); } EDA_ITEM* Clone() const override; @@ -495,11 +497,12 @@ private: class PCB_DIM_RADIAL : public PCB_DIMENSION_BASE { public: - PCB_DIM_RADIAL( BOARD_ITEM* aParent ); + PCB_DIM_RADIAL( BOARD_ITEM* aParent, bool aInFP = false ); static inline bool ClassOf( const EDA_ITEM* aItem ) { - return aItem && PCB_DIM_RADIAL_T == aItem->Type(); + return aItem && ( aItem->Type() == PCB_DIM_RADIAL_T + || aItem->Type() == PCB_FP_DIM_RADIAL_T ); } EDA_ITEM* Clone() const override; @@ -545,11 +548,12 @@ private: class PCB_DIM_LEADER : public PCB_DIMENSION_BASE { public: - PCB_DIM_LEADER( BOARD_ITEM* aParent ); + PCB_DIM_LEADER( BOARD_ITEM* aParent, bool aInFP = false ); static inline bool ClassOf( const EDA_ITEM* aItem ) { - return aItem && PCB_DIM_LEADER_T == aItem->Type(); + return aItem && ( aItem->Type() == PCB_DIM_LEADER_T + || aItem->Type() == PCB_FP_DIM_LEADER_T ); } EDA_ITEM* Clone() const override; @@ -585,11 +589,12 @@ private: class PCB_DIM_CENTER : public PCB_DIMENSION_BASE { public: - PCB_DIM_CENTER( BOARD_ITEM* aParent ); + PCB_DIM_CENTER( BOARD_ITEM* aParent, bool aInFP = false ); static inline bool ClassOf( const EDA_ITEM* aItem ) { - return aItem && PCB_DIM_CENTER_T == aItem->Type(); + return aItem && ( aItem->Type() == PCB_DIM_CENTER_T + || aItem->Type() == PCB_FP_DIM_CENTER_T ); } EDA_ITEM* Clone() const override; diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 7df6421477..d3ec83f8dd 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -577,7 +577,6 @@ public: // Properties dialogs void ShowTargetOptionsDialog( PCB_TARGET* aTarget ); - void ShowDimensionPropertiesDialog( PCB_DIMENSION_BASE* aDimension ); void InstallNetlistFrame(); /** diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index a94345dd30..4fd89a3fe6 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -470,9 +470,6 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer ) break; case PCB_ZONE_T: - draw( static_cast( item ), aLayer ); - break; - case PCB_FP_ZONE_T: draw( static_cast( item ), aLayer ); break; @@ -482,6 +479,11 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer ) case PCB_DIM_RADIAL_T: case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_LEADER_T: draw( static_cast( item ), aLayer ); break; diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 519af563ec..67e61ca78d 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -531,10 +531,20 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint ) { for( const BOARD_ITEM* item : aFootprint->GraphicalItems() ) { - const FP_SHAPE* shape = dynamic_cast( item ); + if( item->Type() == PCB_FP_SHAPE_T ) + { + const FP_SHAPE* shape = static_cast( item ); - if( shape && m_layerMask[ shape->GetLayer() ] ) - PlotFootprintGraphicItem( shape ); + if( m_layerMask[ shape->GetLayer() ] ) + PlotFootprintGraphicItem( shape ); + } + else if( BaseType( item->Type() ) == PCB_DIMENSION_T ) + { + const PCB_DIMENSION_BASE* dimension = static_cast( item ); + + if( m_layerMask[ dimension->GetLayer() ] ) + PlotDimension( dimension ); + } } } diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index 5d974b7f5d..7c1516ed97 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -1083,7 +1083,7 @@ void ALTIUM_PCB::HelperParseDimensions6Linear( const ADIMENSION6& aElem ) wxPoint referencePoint0 = aElem.referencePoint.at( 0 ); wxPoint referencePoint1 = aElem.referencePoint.at( 1 ); - PCB_DIM_ALIGNED* dimension = new PCB_DIM_ALIGNED( m_board ); + PCB_DIM_ALIGNED* dimension = new PCB_DIM_ALIGNED( m_board, PCB_DIM_ALIGNED_T ); m_board->Add( dimension, ADD_MODE::APPEND ); dimension->SetPrecision( aElem.textprecision ); diff --git a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp index f43bc7b0ae..f3c9b86864 100644 --- a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp +++ b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp @@ -1391,7 +1391,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadDimensions() } else { - dimension = new PCB_DIM_ALIGNED( m_board ); + dimension = new PCB_DIM_ALIGNED( m_board, PCB_DIM_ALIGNED_T ); } m_board->Add( dimension, ADD_MODE::APPEND ); @@ -1439,7 +1439,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadDimensions() if( csDim.Line.Style == DIMENSION::LINE::STYLE::INTERNAL ) { // "internal" is a simple double sided arrow from start to end (no extension lines) - PCB_DIM_ALIGNED* dimension = new PCB_DIM_ALIGNED( m_board ); + PCB_DIM_ALIGNED* dimension = new PCB_DIM_ALIGNED( m_board, PCB_DIM_ALIGNED_T ); m_board->Add( dimension, ADD_MODE::APPEND ); applyDimensionSettings( csDim, dimension ); diff --git a/pcbnew/plugins/eagle/eagle_plugin.cpp b/pcbnew/plugins/eagle/eagle_plugin.cpp index fe0e022717..cf81b802b2 100644 --- a/pcbnew/plugins/eagle/eagle_plugin.cpp +++ b/pcbnew/plugins/eagle/eagle_plugin.cpp @@ -988,7 +988,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics ) if( layer != UNDEFINED_LAYER ) { const BOARD_DESIGN_SETTINGS& designSettings = m_board->GetDesignSettings(); - PCB_DIM_ALIGNED* dimension = new PCB_DIM_ALIGNED( m_board ); + PCB_DIM_ALIGNED* dimension = new PCB_DIM_ALIGNED( m_board, PCB_DIM_ALIGNED_T ); m_board->Add( dimension, ADD_MODE::APPEND ); if( d.dimensionType ) diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index 2845565109..9133435a4e 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -781,7 +781,7 @@ BOARD* PCB_PARSER::parseBOARD_unchecked() break; case T_dimension: - item = parseDIMENSION(); + item = parseDIMENSION( m_board, false ); m_board->Add( item, ADD_MODE::BULK_APPEND ); bulkAddedItems.push_back( item ); break; @@ -2803,7 +2803,7 @@ PCB_TEXT* PCB_PARSER::parsePCB_TEXT() } -PCB_DIMENSION_BASE* PCB_PARSER::parseDIMENSION() +PCB_DIMENSION_BASE* PCB_PARSER::parseDIMENSION( BOARD_ITEM* aParent, bool aInFP ) { wxCHECK_MSG( CurTok() == T_dimension, nullptr, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as DIMENSION." ) ); @@ -2832,7 +2832,8 @@ PCB_DIMENSION_BASE* PCB_PARSER::parseDIMENSION() if( token == T_width ) { isLegacyDimension = true; - dimension = std::make_unique( nullptr ); + dimension = std::make_unique( aParent, aInFP ? PCB_FP_DIM_ALIGNED_T + : PCB_DIM_ALIGNED_T ); dimension->SetLineThickness( parseBoardUnits( "dimension width value" ) ); NeedRIGHT(); } @@ -2844,23 +2845,24 @@ PCB_DIMENSION_BASE* PCB_PARSER::parseDIMENSION() switch( NextTok() ) { case T_aligned: - dimension = std::make_unique( nullptr ); + dimension = std::make_unique( aParent, aInFP ? PCB_FP_DIM_ALIGNED_T + : PCB_DIM_ALIGNED_T ); break; case T_orthogonal: - dimension = std::make_unique( nullptr ); + dimension = std::make_unique( aParent, aInFP ); break; case T_leader: - dimension = std::make_unique( nullptr ); + dimension = std::make_unique( aParent, aInFP ); break; case T_center: - dimension = std::make_unique( nullptr ); + dimension = std::make_unique( aParent, aInFP ); break; case T_radial: - dimension = std::make_unique( nullptr ); + dimension = std::make_unique( aParent, aInFP ); break; default: @@ -2929,9 +2931,11 @@ PCB_DIMENSION_BASE* PCB_PARSER::parseDIMENSION() case T_height: { - wxCHECK_MSG( dimension->Type() == PCB_DIM_ALIGNED_T || - dimension->Type() == PCB_DIM_ORTHOGONAL_T, nullptr, - wxT( "Invalid height token" ) ); + wxCHECK_MSG( dimension->Type() == PCB_DIM_ALIGNED_T + || dimension->Type() == PCB_DIM_ORTHOGONAL_T + || dimension->Type() == PCB_FP_DIM_ALIGNED_T + || dimension->Type() == PCB_FP_DIM_ORTHOGONAL_T, + nullptr, wxT( "Invalid height token" ) ); PCB_DIM_ALIGNED* aligned = static_cast( dimension.get() ); aligned->SetHeight( parseBoardUnits( "dimension height value" ) ); NeedRIGHT(); @@ -2940,8 +2944,9 @@ PCB_DIMENSION_BASE* PCB_PARSER::parseDIMENSION() case T_leader_length: { - wxCHECK_MSG( dimension->Type() == PCB_DIM_RADIAL_T, nullptr, - wxT( "Invalid leader_length token" ) ); + wxCHECK_MSG( dimension->Type() == PCB_DIM_RADIAL_T + || dimension->Type() == PCB_FP_DIM_RADIAL_T, + nullptr, wxT( "Invalid leader_length token" ) ); PCB_DIM_RADIAL* radial = static_cast( dimension.get() ); radial->SetLeaderLength( parseBoardUnits( "dimension leader length value" ) ); NeedRIGHT(); @@ -2950,8 +2955,9 @@ PCB_DIMENSION_BASE* PCB_PARSER::parseDIMENSION() case T_orientation: { - wxCHECK_MSG( dimension->Type() == PCB_DIM_ORTHOGONAL_T, nullptr, - wxT( "Invalid orientation token" ) ); + wxCHECK_MSG( dimension->Type() == PCB_DIM_ORTHOGONAL_T + || dimension->Type() == PCB_FP_DIM_ORTHOGONAL_T, + nullptr, wxT( "Invalid orientation token" ) ); PCB_DIM_ORTHOGONAL* ortho = static_cast( dimension.get() ); int orientation = parseInt( "orthogonal dimension orientation" ); @@ -3503,6 +3509,13 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments break; } + case T_dimension: + { + PCB_DIMENSION_BASE* dimension = parseDIMENSION( footprint.get(), true ); + footprint->Add( dimension, ADD_MODE::APPEND ); + break; + } + case T_pad: { PAD* pad = parsePAD( footprint.get() ); diff --git a/pcbnew/plugins/kicad/pcb_parser.h b/pcbnew/plugins/kicad/pcb_parser.h index d01af95123..a8d02da8a1 100644 --- a/pcbnew/plugins/kicad/pcb_parser.h +++ b/pcbnew/plugins/kicad/pcb_parser.h @@ -174,7 +174,7 @@ private: PCB_SHAPE* parsePCB_SHAPE(); PCB_TEXT* parsePCB_TEXT(); - PCB_DIMENSION_BASE* parseDIMENSION(); + PCB_DIMENSION_BASE* parseDIMENSION( BOARD_ITEM* aParent, bool aInFP ); // Parse a footprint, but do not replace PARSE_ERROR with FUTURE_FORMAT_ERROR automatically. FOOTPRINT* parseFOOTPRINT_unchecked( wxArrayString* aInitialComments = nullptr ); diff --git a/pcbnew/plugins/kicad/pcb_plugin.cpp b/pcbnew/plugins/kicad/pcb_plugin.cpp index 8df127ea1d..ae214a6203 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.cpp +++ b/pcbnew/plugins/kicad/pcb_plugin.cpp @@ -405,6 +405,11 @@ void PCB_PLUGIN::Format( const BOARD_ITEM* aItem, int aNestLevel ) const case PCB_DIM_RADIAL_T: case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_LEADER_T: format( static_cast( aItem ), aNestLevel ); break; @@ -711,15 +716,15 @@ void PCB_PLUGIN::format( const PCB_DIMENSION_BASE* aDimension, int aNestLevel ) if( aDimension->IsLocked() ) m_out->Print( 0, " locked" ); - if( aDimension->Type() == PCB_DIM_ALIGNED_T ) + if( aligned ) m_out->Print( 0, " (type aligned)" ); - else if( aDimension->Type() == PCB_DIM_LEADER_T ) + else if( leader ) m_out->Print( 0, " (type leader)" ); - else if( aDimension->Type() == PCB_DIM_CENTER_T ) + else if( center ) m_out->Print( 0, " (type center)" ); - else if (aDimension->Type() == PCB_DIM_RADIAL_T ) + else if( radial ) m_out->Print( 0, " (type radial)" ); - else if( aDimension->Type() == PCB_DIM_ORTHOGONAL_T ) + else if( ortho ) m_out->Print( 0, " (type orthogonal)" ); else wxFAIL_MSG( wxT( "Cannot format unknown dimension type!" ) ); diff --git a/pcbnew/plugins/kicad/pcb_plugin.h b/pcbnew/plugins/kicad/pcb_plugin.h index 0ef6b6265f..95c5918b4f 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.h +++ b/pcbnew/plugins/kicad/pcb_plugin.h @@ -106,7 +106,8 @@ class PCB_TEXT; //#define SEXPR_BOARD_FILE_VERSION 20211226 // Add radial dimension //#define SEXPR_BOARD_FILE_VERSION 20211227 // Add thermal relief spoke angle overrides //#define SEXPR_BOARD_FILE_VERSION 20211228 // Add allow_soldermask_bridges footprint attribute -#define SEXPR_BOARD_FILE_VERSION 20211229 // Stroke formatting +//#define SEXPR_BOARD_FILE_VERSION 20211229 // Stroke formatting +#define SEXPR_BOARD_FILE_VERSION 20211230 // Dimensions in footprints #define BOARD_FILE_HOST_VERSION 20200825 ///< Earlier files than this include the host tag #define LEGACY_ARC_FORMATTING 20210925 ///< These were the last to use old arc formatting diff --git a/pcbnew/plugins/legacy/legacy_plugin.cpp b/pcbnew/plugins/legacy/legacy_plugin.cpp index ba40a691cb..81fb52673f 100644 --- a/pcbnew/plugins/legacy/legacy_plugin.cpp +++ b/pcbnew/plugins/legacy/legacy_plugin.cpp @@ -2615,9 +2615,10 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() void LEGACY_PLUGIN::loadDIMENSION() { - std::unique_ptr dim = std::make_unique( m_board ); - wxPoint crossBarO; - wxPoint crossBarF; + std::unique_ptr dim = std::make_unique( m_board, + PCB_DIM_ALIGNED_T ); + wxPoint crossBarO; + wxPoint crossBarF; char* line; diff --git a/pcbnew/toolbars_footprint_editor.cpp b/pcbnew/toolbars_footprint_editor.cpp index df795c7261..e89bd0bc97 100644 --- a/pcbnew/toolbars_footprint_editor.cpp +++ b/pcbnew/toolbars_footprint_editor.cpp @@ -30,7 +30,7 @@ #include #include #include - +#include void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() { @@ -146,6 +146,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() void FOOTPRINT_EDIT_FRAME::ReCreateVToolbar() { + wxWindowUpdateLocker dummy( this ); + if( m_drawToolBar ) { m_drawToolBar->ClearToolbar(); @@ -157,17 +159,33 @@ void FOOTPRINT_EDIT_FRAME::ReCreateVToolbar() m_drawToolBar->SetAuiManager( &m_auimgr ); } + // Groups contained on this toolbar + static ACTION_GROUP* dimensionGroup = nullptr; + + if( !dimensionGroup ) + { + dimensionGroup = new ACTION_GROUP( "group.pcbDimensions", + { &PCB_ACTIONS::drawAlignedDimension, + &PCB_ACTIONS::drawOrthogonalDimension, + &PCB_ACTIONS::drawCenterDimension, + &PCB_ACTIONS::drawRadialDimension, + &PCB_ACTIONS::drawLeader } ); + } + m_drawToolBar->Add( ACTIONS::selectionTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->AddScaledSeparator( this ); m_drawToolBar->Add( PCB_ACTIONS::placePad, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( PCB_ACTIONS::drawRuleArea, ACTION_TOOLBAR::TOGGLE ); + + m_drawToolBar->AddScaledSeparator( this ); m_drawToolBar->Add( PCB_ACTIONS::drawLine, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::drawArc, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::drawRectangle, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::drawCircle, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::drawPolygon, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Add( PCB_ACTIONS::drawRuleArea, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::placeText, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->AddGroup( dimensionGroup, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->AddScaledSeparator( this ); diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index da801e27ae..f96ce916cc 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -746,6 +746,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) PCB_SELECTION preview; // A VIEW_GROUP that serves as a preview for the new item(s) SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION ); int step = SET_ORIGIN; + KICAD_T t = PCB_DIMENSION_T; m_view->Add( &preview ); @@ -884,26 +885,28 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) if( originalEvent.IsAction( &PCB_ACTIONS::drawAlignedDimension ) ) { - dimension = new PCB_DIM_ALIGNED( m_board ); + dimension = new PCB_DIM_ALIGNED( m_frame->GetModel(), + m_isFootprintEditor ? PCB_FP_DIM_ALIGNED_T + : PCB_DIM_ALIGNED_T ); setMeasurementAttributes( dimension ); } else if( originalEvent.IsAction( &PCB_ACTIONS::drawOrthogonalDimension ) ) { - dimension = new PCB_DIM_ORTHOGONAL( m_board ); + dimension = new PCB_DIM_ORTHOGONAL( m_frame->GetModel(), m_isFootprintEditor ); setMeasurementAttributes( dimension ); } else if( originalEvent.IsAction( &PCB_ACTIONS::drawCenterDimension ) ) { - dimension = new PCB_DIM_CENTER( m_board ); + dimension = new PCB_DIM_CENTER( m_frame->GetModel(), m_isFootprintEditor ); } else if( originalEvent.IsAction( &PCB_ACTIONS::drawRadialDimension ) ) { - dimension = new PCB_DIM_RADIAL( m_board ); + dimension = new PCB_DIM_RADIAL( m_frame->GetModel(), m_isFootprintEditor ); setMeasurementAttributes( dimension ); } else if( originalEvent.IsAction( &PCB_ACTIONS::drawLeader ) ) { - dimension = new PCB_DIM_LEADER( m_board ); + dimension = new PCB_DIM_LEADER( m_frame->GetModel(), m_isFootprintEditor ); dimension->Text().SetPosition( wxPoint( cursorPos ) ); } else @@ -911,6 +914,8 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) wxFAIL_MSG( "Unhandled action in DRAWING_TOOL::DrawDimension" ); } + t = dimension->Type(); + dimension->SetLayer( layer ); dimension->Text().SetTextSize( boardSettings.GetTextSize( layer ) ); dimension->Text().SetTextThickness( boardSettings.GetTextThickness( layer ) ); @@ -944,9 +949,8 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) break; } - if( dimension->Type() == PCB_DIM_CENTER_T - || dimension->Type() == PCB_DIM_RADIAL_T - || dimension->Type() == PCB_DIM_LEADER_T ) + if( t == PCB_DIM_CENTER_T || t == PCB_DIM_RADIAL_T || t == PCB_DIM_LEADER_T + || t == PCB_FP_DIM_CENTER_T || t == PCB_FP_DIM_RADIAL_T || t == PCB_FP_DIM_LEADER_T ) { // No separate height step ++step; @@ -966,7 +970,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) commit.Add( dimension ); commit.Push( _( "Draw a dimension" ) ); - if( dimension->Type() == PCB_DIM_LEADER_T ) + if( t == PCB_DIM_LEADER_T || t == PCB_FP_DIM_LEADER_T ) { // Run the edit immediately to set the leader text m_toolMgr->RunAction( PCB_ACTIONS::properties, true, dimension ); @@ -991,10 +995,10 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) case SET_END: dimension->SetEnd( (wxPoint) cursorPos ); - if( Is45Limited() || dimension->Type() == PCB_DIM_CENTER_T ) + if( Is45Limited() || t == PCB_DIM_CENTER_T || t == PCB_FP_DIM_CENTER_T ) constrainDimension( dimension ); - if( dimension->Type() == PCB_DIM_ORTHOGONAL_T ) + if( t == PCB_DIM_ORTHOGONAL_T || t == PCB_FP_DIM_ORTHOGONAL_T ) { PCB_DIM_ORTHOGONAL* ortho = static_cast( dimension ); @@ -1007,7 +1011,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) ortho->SetOrientation( vert ? PCB_DIM_ORTHOGONAL::DIR::VERTICAL : PCB_DIM_ORTHOGONAL::DIR::HORIZONTAL ); } - else if( dimension->Type() == PCB_DIM_RADIAL_T ) + else if( t == PCB_DIM_RADIAL_T || t == PCB_FP_DIM_RADIAL_T ) { PCB_DIM_RADIAL* radialDim = static_cast( dimension ); wxPoint textOffset( radialDim->GetArrowLength() * 10, 0 ); @@ -1018,7 +1022,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) radialDim->Text().SetPosition( radialDim->GetKnee() + textOffset ); radialDim->Update(); } - else if( dimension->Type() == PCB_DIM_LEADER_T ) + else if( t == PCB_DIM_LEADER_T || t == PCB_FP_DIM_LEADER_T ) { wxPoint textOffset( dimension->GetArrowLength() * 10, 0 ); @@ -1032,7 +1036,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) break; case SET_HEIGHT: - if( dimension->Type() == PCB_DIM_ALIGNED_T ) + if( t == PCB_DIM_ALIGNED_T || t == PCB_FP_DIM_ALIGNED_T ) { PCB_DIM_ALIGNED* aligned = static_cast( dimension ); @@ -1044,7 +1048,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) aligned->SetHeight( height ); aligned->Update(); } - else if( dimension->Type() == PCB_DIM_ORTHOGONAL_T ) + else if( t == PCB_DIM_ORTHOGONAL_T || t == PCB_FP_DIM_ORTHOGONAL_T ) { PCB_DIM_ORTHOGONAL* ortho = static_cast( dimension ); diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index 60de899fb0..e4bd661057 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -977,6 +977,14 @@ int PCB_CONTROL::placeBoardItems( std::vector& aItems, bool aIsNew, std::vector itemsToSel; itemsToSel.reserve( aItems.size() ); + auto updateDimensionUnits = + [this]( PCB_DIMENSION_BASE* dimension ) + { + // Dimensions need to have their units updated if they are automatic + if( dimension->GetUnitsMode() == DIM_UNITS_MODE::AUTOMATIC ) + dimension->SetUnits( frame()->GetUserUnits() ); + }; + for( BOARD_ITEM* item : aItems ) { if( aIsNew ) @@ -988,33 +996,23 @@ int PCB_CONTROL::placeBoardItems( std::vector& aItems, bool aIsNew, } // Update item attributes if needed - switch( item->Type() ) + if( BaseType( item->Type() ) == PCB_DIMENSION_T ) { - case PCB_DIMENSION_T: - case PCB_DIM_ALIGNED_T: - case PCB_DIM_CENTER_T: - case PCB_DIM_RADIAL_T: - case PCB_DIM_ORTHOGONAL_T: - case PCB_DIM_LEADER_T: - { - // Dimensions need to have their units updated if they are automatic - PCB_DIMENSION_BASE* dim = static_cast( item ); - - if( dim->GetUnitsMode() == DIM_UNITS_MODE::AUTOMATIC ) - dim->SetUnits( frame()->GetUserUnits() ); - - break; + updateDimensionUnits( static_cast( item ) ); } + else if( item->Type() == PCB_FOOTPRINT_T ) + { + FOOTPRINT* footprint = static_cast( item ); - case PCB_FOOTPRINT_T: // Update the footprint path with the new KIID path if the footprint is new if( aIsNew ) - static_cast( item )->SetPath( KIID_PATH() ); + footprint->SetPath( KIID_PATH() ); - break; - - default: - break; + for( BOARD_ITEM* dwg : footprint->GraphicalItems() ) + { + if( BaseType( dwg->Type() ) == PCB_DIMENSION_T ) + updateDimensionUnits( static_cast( item ) ); + } } // We only need to add the items that aren't inside a group currently selected diff --git a/pcbnew/tools/pcb_grid_helper.cpp b/pcbnew/tools/pcb_grid_helper.cpp index ebcb6128fa..4aa4028a1c 100644 --- a/pcbnew/tools/pcb_grid_helper.cpp +++ b/pcbnew/tools/pcb_grid_helper.cpp @@ -652,6 +652,8 @@ void PCB_GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos case PCB_DIM_ALIGNED_T: case PCB_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_ORTHOGONAL_T: { const PCB_DIM_ALIGNED* dim = static_cast( aItem ); addAnchor( dim->GetCrossbarStart(), CORNER | SNAPPABLE, aItem ); @@ -662,6 +664,7 @@ void PCB_GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos } case PCB_DIM_CENTER_T: + case PCB_FP_DIM_CENTER_T: { const PCB_DIM_CENTER* dim = static_cast( aItem ); addAnchor( dim->GetStart(), CORNER | SNAPPABLE, aItem ); @@ -680,6 +683,7 @@ void PCB_GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos } case PCB_DIM_RADIAL_T: + case PCB_FP_DIM_RADIAL_T: { const PCB_DIM_RADIAL* radialDim = static_cast( aItem ); addAnchor( radialDim->GetStart(), CORNER | SNAPPABLE, aItem ); @@ -690,6 +694,7 @@ void PCB_GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos } case PCB_DIM_LEADER_T: + case PCB_FP_DIM_LEADER_T: { const PCB_DIM_LEADER* leader = static_cast( aItem ); addAnchor( leader->GetStart(), CORNER | SNAPPABLE, aItem ); diff --git a/pcbnew/tools/pcb_point_editor.cpp b/pcbnew/tools/pcb_point_editor.cpp index ae4a923372..1776691568 100644 --- a/pcbnew/tools/pcb_point_editor.cpp +++ b/pcbnew/tools/pcb_point_editor.cpp @@ -299,6 +299,8 @@ std::shared_ptr PCB_POINT_EDITOR::makePoints( EDA_ITEM* aItem ) case PCB_DIM_ALIGNED_T: case PCB_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_ORTHOGONAL_T: { const PCB_DIM_ALIGNED* dimension = static_cast( aItem ); @@ -323,6 +325,7 @@ std::shared_ptr PCB_POINT_EDITOR::makePoints( EDA_ITEM* aItem ) } case PCB_DIM_CENTER_T: + case PCB_FP_DIM_CENTER_T: { const PCB_DIM_CENTER* dimension = static_cast( aItem ); @@ -336,6 +339,7 @@ std::shared_ptr PCB_POINT_EDITOR::makePoints( EDA_ITEM* aItem ) } case PCB_DIM_RADIAL_T: + case PCB_FP_DIM_RADIAL_T: { const PCB_DIM_RADIAL* dimension = static_cast( aItem ); @@ -355,6 +359,7 @@ std::shared_ptr PCB_POINT_EDITOR::makePoints( EDA_ITEM* aItem ) } case PCB_DIM_LEADER_T: + case PCB_FP_DIM_LEADER_T: { const PCB_DIM_LEADER* dimension = static_cast( aItem ); @@ -1340,6 +1345,7 @@ void PCB_POINT_EDITOR::updateItem() const } case PCB_DIM_ALIGNED_T: + case PCB_FP_DIM_ALIGNED_T: { PCB_DIM_ALIGNED* dimension = static_cast( item ); @@ -1404,6 +1410,7 @@ void PCB_POINT_EDITOR::updateItem() const } case PCB_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: { PCB_DIM_ORTHOGONAL* dimension = static_cast( item ); @@ -1469,6 +1476,7 @@ void PCB_POINT_EDITOR::updateItem() const } case PCB_DIM_CENTER_T: + case PCB_FP_DIM_CENTER_T: { PCB_DIM_CENTER* dimension = static_cast( item ); @@ -1483,6 +1491,7 @@ void PCB_POINT_EDITOR::updateItem() const } case PCB_DIM_RADIAL_T: + case PCB_FP_DIM_RADIAL_T: { PCB_DIM_RADIAL* dimension = static_cast( item ); @@ -1531,6 +1540,7 @@ void PCB_POINT_EDITOR::updateItem() const } case PCB_DIM_LEADER_T: + case PCB_FP_DIM_LEADER_T: { PCB_DIM_LEADER* dimension = static_cast( item ); @@ -1780,6 +1790,8 @@ void PCB_POINT_EDITOR::updatePoints() case PCB_DIM_ALIGNED_T: case PCB_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_ORTHOGONAL_T: { const PCB_DIM_ALIGNED* dimension = static_cast( item ); @@ -1792,6 +1804,7 @@ void PCB_POINT_EDITOR::updatePoints() } case PCB_DIM_CENTER_T: + case PCB_FP_DIM_CENTER_T: { const PCB_DIM_CENTER* dimension = static_cast( item ); @@ -1801,6 +1814,7 @@ void PCB_POINT_EDITOR::updatePoints() } case PCB_DIM_RADIAL_T: + case PCB_FP_DIM_RADIAL_T: { const PCB_DIM_RADIAL* dimension = static_cast( item ); @@ -1812,6 +1826,7 @@ void PCB_POINT_EDITOR::updatePoints() } case PCB_DIM_LEADER_T: + case PCB_FP_DIM_LEADER_T: { const PCB_DIM_LEADER* dimension = static_cast( item ); @@ -1919,6 +1934,7 @@ EDIT_POINT PCB_POINT_EDITOR::get45DegConstrainer() const break; case PCB_DIM_ALIGNED_T: + case PCB_FP_DIM_ALIGNED_T: { // Constraint for crossbar if( isModified( m_editPoints->Point( DIM_START ) ) ) @@ -1934,6 +1950,7 @@ EDIT_POINT PCB_POINT_EDITOR::get45DegConstrainer() const } case PCB_DIM_CENTER_T: + case PCB_FP_DIM_CENTER_T: { if( isModified( m_editPoints->Point( DIM_END ) ) ) return m_editPoints->Point( DIM_START ); @@ -1942,6 +1959,7 @@ EDIT_POINT PCB_POINT_EDITOR::get45DegConstrainer() const } case PCB_DIM_RADIAL_T: + case PCB_FP_DIM_RADIAL_T: { if( isModified( m_editPoints->Point( DIM_TEXT ) ) ) return m_editPoints->Point( DIM_KNEE ); diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index adb00c0ff9..cc6b6230cb 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -1596,6 +1596,11 @@ static bool itemIsIncludedByFilter( const BOARD_ITEM& aItem, const BOARD& aBoard case PCB_DIM_RADIAL_T: case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_LEADER_T: if( layer == Edge_Cuts ) include = aFilterOptions.includeBoardOutlineLayer; else @@ -1748,6 +1753,11 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect case PCB_DIM_RADIAL_T: case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: + case PCB_FP_DIM_ALIGNED_T: + case PCB_FP_DIM_CENTER_T: + case PCB_FP_DIM_RADIAL_T: + case PCB_FP_DIM_ORTHOGONAL_T: + case PCB_FP_DIM_LEADER_T: if( !m_filter.dimensions ) return false; diff --git a/pcbnew/tools/pcb_viewer_tools.cpp b/pcbnew/tools/pcb_viewer_tools.cpp index 7bb0bb6d2a..861c1036ca 100644 --- a/pcbnew/tools/pcb_viewer_tools.cpp +++ b/pcbnew/tools/pcb_viewer_tools.cpp @@ -137,7 +137,9 @@ int PCB_VIEWER_TOOLS::GraphicOutlines( const TOOL_EVENT& aEvent ) { for( BOARD_ITEM* item : fp->GraphicalItems() ) { - if( item->Type() == PCB_FP_SHAPE_T ) + KICAD_T t = item->Type(); + + if( t == PCB_FP_SHAPE_T || BaseType( t ) == PCB_DIMENSION_T ) view()->Update( item, KIGFX::REPAINT ); } } diff --git a/qa/pcbnew/test_board_item.cpp b/qa/pcbnew/test_board_item.cpp index a7b98f769a..52da7c1dbc 100644 --- a/qa/pcbnew/test_board_item.cpp +++ b/qa/pcbnew/test_board_item.cpp @@ -69,12 +69,17 @@ public: switch( aType ) { - case PCB_FOOTPRINT_T: return new FOOTPRINT( &m_board ); - case PCB_PAD_T: return new PAD( &m_footprint ); - case PCB_SHAPE_T: return new PCB_SHAPE( &m_board ); - case PCB_TEXT_T: return new PCB_TEXT( &m_board ); - case PCB_FP_TEXT_T: return new FP_TEXT( &m_footprint ); - case PCB_FP_SHAPE_T: return new FP_SHAPE( &m_footprint ); + case PCB_FOOTPRINT_T: return new FOOTPRINT( &m_board ); + case PCB_PAD_T: return new PAD( &m_footprint ); + case PCB_SHAPE_T: return new PCB_SHAPE( &m_board ); + case PCB_TEXT_T: return new PCB_TEXT( &m_board ); + case PCB_FP_TEXT_T: return new FP_TEXT( &m_footprint ); + case PCB_FP_SHAPE_T: return new FP_SHAPE( &m_footprint ); + case PCB_FP_DIM_ALIGNED_T: return new PCB_DIM_ALIGNED( &m_footprint, PCB_FP_DIM_ALIGNED_T ); + case PCB_FP_DIM_LEADER_T: return new PCB_DIM_LEADER( &m_footprint, true ); + case PCB_FP_DIM_CENTER_T: return new PCB_DIM_CENTER( &m_footprint, true ); + case PCB_FP_DIM_RADIAL_T: return new PCB_DIM_RADIAL( &m_footprint, true ); + case PCB_FP_DIM_ORTHOGONAL_T: return new PCB_DIM_ORTHOGONAL( &m_footprint, true ); case PCB_FP_ZONE_T: { FP_ZONE* fpZone = new FP_ZONE( &m_footprint ); @@ -87,16 +92,16 @@ public: return fpZone; } - case PCB_TRACE_T: return new PCB_TRACK( &m_board ); - case PCB_VIA_T: return new PCB_VIA( &m_board ); - case PCB_ARC_T: return new PCB_ARC( &m_board ); - case PCB_MARKER_T: return new PCB_MARKER( m_drcItem, wxPoint( 0, 0 ) ); - case PCB_DIM_ALIGNED_T: return new PCB_DIM_ALIGNED( &m_board ); - case PCB_DIM_LEADER_T: return new PCB_DIM_LEADER( &m_board ); - case PCB_DIM_CENTER_T: return new PCB_DIM_CENTER( &m_board ); - case PCB_DIM_RADIAL_T: return new PCB_DIM_RADIAL( &m_board ); - case PCB_DIM_ORTHOGONAL_T: return new PCB_DIM_ORTHOGONAL( &m_board ); - case PCB_TARGET_T: return new PCB_TARGET( &m_board ); + case PCB_TRACE_T: return new PCB_TRACK( &m_board ); + case PCB_VIA_T: return new PCB_VIA( &m_board ); + case PCB_ARC_T: return new PCB_ARC( &m_board ); + case PCB_MARKER_T: return new PCB_MARKER( m_drcItem, wxPoint( 0, 0 ) ); + case PCB_DIM_ALIGNED_T: return new PCB_DIM_ALIGNED( &m_board, PCB_DIM_ALIGNED_T ); + case PCB_DIM_LEADER_T: return new PCB_DIM_LEADER( &m_board ); + case PCB_DIM_CENTER_T: return new PCB_DIM_CENTER( &m_board ); + case PCB_DIM_RADIAL_T: return new PCB_DIM_RADIAL( &m_board ); + case PCB_DIM_ORTHOGONAL_T: return new PCB_DIM_ORTHOGONAL( &m_board ); + case PCB_TARGET_T: return new PCB_TARGET( &m_board ); case PCB_ZONE_T: { ZONE* zone = new ZONE( &m_board );