Dimensions for footprints.

Fixes https://gitlab.com/kicad/code/kicad/issues/8441
This commit is contained in:
Jeff Young 2021-12-04 23:52:00 +00:00
parent b84a85f648
commit fa908e1f98
42 changed files with 539 additions and 299 deletions

View File

@ -55,27 +55,36 @@
#include <wx/log.h>
#include <macros.h>
// 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<CALLBACK_DATA*>( 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<FP_TEXT*> 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<PCB_DIMENSION_BASE*>( 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<FP_SHAPE*>( 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 );
}
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* 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<FP_SHAPE*>( 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<PCB_DIMENSION_BASE*>( item );
if( dimension->GetLayer() == aLayer )
{
dimension->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
}
}
}

View File

@ -309,65 +309,70 @@ static struct EDA_ITEM_DESC
{
ENUM_MAP<KICAD_T>::Instance()
.Undefined( TYPE_NOT_INIT )
.Map( NOT_USED, wxT( "<not used>" ) )
.Map( SCREEN_T, _HKI( "Screen" ) )
.Map( NOT_USED, wxT( "<not used>" ) )
.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 );

View File

@ -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:

View File

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

View File

@ -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();

View File

@ -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<PCB_SHAPE*>( 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<FOOTPRINT*>( 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:

View File

@ -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();

View File

@ -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 );

View File

@ -194,7 +194,7 @@ int DRC_TEST_PROVIDER::forEachGeometryItem( const std::vector<KICAD_T>& 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<KICAD_T>& 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;

View File

@ -192,8 +192,7 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run()
static const std::vector<KICAD_T> 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 );

View File

@ -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_ITEM> 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 ) )

View File

@ -178,8 +178,7 @@ bool DRC_TEST_PROVIDER_MECHANICAL_CLEARANCE::Run()
static const std::vector<KICAD_T> 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 );

View File

@ -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<PCB_DIMENSION_BASE*>( aItem ) );
{
DIALOG_DIMENSION_PROPERTIES dlg( this, static_cast<PCB_DIMENSION_BASE*>( 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();
}

View File

@ -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:

View File

@ -36,10 +36,10 @@
#include <fp_shape.h>
#include <macros.h>
#include <pad.h>
#include <pcb_text.h>
#include <pcb_marker.h>
#include <pcb_group.h>
#include <pcb_track.h>
#include <pcb_dimension.h>
#include <footprint.h>
#include <zone.h>
#include <view/view.h>
@ -511,6 +511,11 @@ void FOOTPRINT::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode )
wxASSERT( static_cast<FP_TEXT*>( 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<BOARD_ITEM*>( 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<PCB_DIMENSION_BASE*>( aItem->Duplicate() );
if( aAddToFootprint )
Add( dimension );
new_item = dimension;
break;
}
case PCB_GROUP_T:
new_item = static_cast<const PCB_GROUP*>( aItem )->DeepDuplicate();
break;

View File

@ -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 );

View File

@ -37,6 +37,8 @@
#include <widgets/appearance_controls.h>
#include <widgets/lib_tree.h>
#include <pcb_layer_box_selector.h>
#include <pcb_dimension.h>
#include <dialogs/dialog_dimension_properties.h>
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<PCB_DIMENSION_BASE*>( aItem ) );
dlg.ShowQuasiModal();
break;
}
case PCB_FP_ZONE_T:
{
ZONE* zone = static_cast<ZONE*>( aItem );

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );

View File

@ -27,7 +27,6 @@
#include <bitmaps.h>
#include <pcb_edit_frame.h>
#include <base_units.h>
#include <board.h>
#include <convert_basic_shapes_to_polygon.h>
#include <pcb_dimension.h>
#include <pcb_text.h>
@ -37,7 +36,6 @@
#include <settings/color_settings.h>
#include <settings/settings_manager.h>
#include <trigo.h>
#include <i18n_utility.h>
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<PCB_DIM_ALIGNED*>( aImage )->m_shapes.clear();
@ -720,8 +702,8 @@ void PCB_DIM_ALIGNED::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_P
}
PCB_DIM_ORTHOGONAL::PCB_DIM_ORTHOGONAL( BOARD_ITEM* aParent ) :
PCB_DIM_ALIGNED( aParent, PCB_DIM_ORTHOGONAL_T )
PCB_DIM_ORTHOGONAL::PCB_DIM_ORTHOGONAL( BOARD_ITEM* aParent, bool aInFP ) :
PCB_DIM_ALIGNED( aParent, aInFP ? PCB_FP_DIM_ORTHOGONAL_T : PCB_DIM_ORTHOGONAL_T )
{
// To preserve look of old dimensions, initialize extension height based on default arrow length
m_extensionHeight = static_cast<int>( 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<PCB_DIM_ORTHOGONAL*>( 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<PCB_DIM_LEADER*>( aImage )->m_shapes.clear();
@ -1098,8 +1080,8 @@ void PCB_DIM_LEADER::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PA
}
PCB_DIM_RADIAL::PCB_DIM_RADIAL( BOARD_ITEM* aParent ) :
PCB_DIMENSION_BASE( aParent, PCB_DIM_RADIAL_T )
PCB_DIM_RADIAL::PCB_DIM_RADIAL( BOARD_ITEM* aParent, bool aInFP ) :
PCB_DIMENSION_BASE( aParent, aInFP ? PCB_FP_DIM_RADIAL_T : PCB_DIM_RADIAL_T )
{
m_unitsFormat = DIM_UNITS_FORMAT::NO_SUFFIX;
m_overrideTextEnabled = false;
@ -1118,7 +1100,7 @@ EDA_ITEM* PCB_DIM_RADIAL::Clone() const
void PCB_DIM_RADIAL::SwapData( BOARD_ITEM* aImage )
{
assert( aImage->Type() == PCB_DIM_RADIAL_T );
wxASSERT( aImage->Type() == Type() );
m_shapes.clear();
static_cast<PCB_DIM_RADIAL*>( 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<PCB_DIM_CENTER*>( this ), *static_cast<PCB_DIM_CENTER*>( aImage ) );
}

View File

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

View File

@ -577,7 +577,6 @@ public:
// Properties dialogs
void ShowTargetOptionsDialog( PCB_TARGET* aTarget );
void ShowDimensionPropertiesDialog( PCB_DIMENSION_BASE* aDimension );
void InstallNetlistFrame();
/**

View File

@ -470,9 +470,6 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
break;
case PCB_ZONE_T:
draw( static_cast<const ZONE*>( item ), aLayer );
break;
case PCB_FP_ZONE_T:
draw( static_cast<const ZONE*>( 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<const PCB_DIMENSION_BASE*>( item ), aLayer );
break;

View File

@ -531,10 +531,20 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint )
{
for( const BOARD_ITEM* item : aFootprint->GraphicalItems() )
{
const FP_SHAPE* shape = dynamic_cast<const FP_SHAPE*>( item );
if( item->Type() == PCB_FP_SHAPE_T )
{
const FP_SHAPE* shape = static_cast<const FP_SHAPE*>( 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<const PCB_DIMENSION_BASE*>( item );
if( m_layerMask[ dimension->GetLayer() ] )
PlotDimension( dimension );
}
}
}

View File

@ -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 );

View File

@ -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 );

View File

@ -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 )

View File

@ -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<PCB_DIM_ALIGNED>( nullptr );
dimension = std::make_unique<PCB_DIM_ALIGNED>( 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<PCB_DIM_ALIGNED>( nullptr );
dimension = std::make_unique<PCB_DIM_ALIGNED>( aParent, aInFP ? PCB_FP_DIM_ALIGNED_T
: PCB_DIM_ALIGNED_T );
break;
case T_orthogonal:
dimension = std::make_unique<PCB_DIM_ORTHOGONAL>( nullptr );
dimension = std::make_unique<PCB_DIM_ORTHOGONAL>( aParent, aInFP );
break;
case T_leader:
dimension = std::make_unique<PCB_DIM_LEADER>( nullptr );
dimension = std::make_unique<PCB_DIM_LEADER>( aParent, aInFP );
break;
case T_center:
dimension = std::make_unique<PCB_DIM_CENTER>( nullptr );
dimension = std::make_unique<PCB_DIM_CENTER>( aParent, aInFP );
break;
case T_radial:
dimension = std::make_unique<PCB_DIM_RADIAL>( nullptr );
dimension = std::make_unique<PCB_DIM_RADIAL>( 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<PCB_DIM_ALIGNED*>( 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<PCB_DIM_RADIAL*>( 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<PCB_DIM_ORTHOGONAL*>( 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() );

View File

@ -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 );

View File

@ -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<const PCB_DIMENSION_BASE*>( 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!" ) );

View File

@ -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

View File

@ -2615,9 +2615,10 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
void LEGACY_PLUGIN::loadDIMENSION()
{
std::unique_ptr<PCB_DIM_ALIGNED> dim = std::make_unique<PCB_DIM_ALIGNED>( m_board );
wxPoint crossBarO;
wxPoint crossBarF;
std::unique_ptr<PCB_DIM_ALIGNED> dim = std::make_unique<PCB_DIM_ALIGNED>( m_board,
PCB_DIM_ALIGNED_T );
wxPoint crossBarO;
wxPoint crossBarF;
char* line;

View File

@ -30,7 +30,7 @@
#include <tools/pcb_selection_tool.h>
#include <pcb_layer_box_selector.h>
#include <wx/choice.h>
#include <wx/wupdlock.h>
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 );

View File

@ -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<PCB_DIM_ORTHOGONAL*>( 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<PCB_DIM_RADIAL*>( 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<PCB_DIM_ALIGNED*>( 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<PCB_DIM_ORTHOGONAL*>( dimension );

View File

@ -977,6 +977,14 @@ int PCB_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
std::vector<BOARD_ITEM*> 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<BOARD_ITEM*>& 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<PCB_DIMENSION_BASE*>( item );
if( dim->GetUnitsMode() == DIM_UNITS_MODE::AUTOMATIC )
dim->SetUnits( frame()->GetUserUnits() );
break;
updateDimensionUnits( static_cast<PCB_DIMENSION_BASE*>( item ) );
}
else if( item->Type() == PCB_FOOTPRINT_T )
{
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
case PCB_FOOTPRINT_T:
// Update the footprint path with the new KIID path if the footprint is new
if( aIsNew )
static_cast<FOOTPRINT*>( 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<PCB_DIMENSION_BASE*>( item ) );
}
}
// We only need to add the items that aren't inside a group currently selected

View File

@ -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<const PCB_DIM_ALIGNED*>( 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<const PCB_DIM_CENTER*>( 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<const PCB_DIM_RADIAL*>( 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<const PCB_DIM_LEADER*>( aItem );
addAnchor( leader->GetStart(), CORNER | SNAPPABLE, aItem );

View File

@ -299,6 +299,8 @@ std::shared_ptr<EDIT_POINTS> 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<const PCB_DIM_ALIGNED*>( aItem );
@ -323,6 +325,7 @@ std::shared_ptr<EDIT_POINTS> 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<const PCB_DIM_CENTER*>( aItem );
@ -336,6 +339,7 @@ std::shared_ptr<EDIT_POINTS> 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<const PCB_DIM_RADIAL*>( aItem );
@ -355,6 +359,7 @@ std::shared_ptr<EDIT_POINTS> 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<const PCB_DIM_LEADER*>( 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<PCB_DIM_ALIGNED*>( 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<PCB_DIM_ORTHOGONAL*>( 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<PCB_DIM_CENTER*>( 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<PCB_DIM_RADIAL*>( 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<PCB_DIM_LEADER*>( 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<const PCB_DIM_ALIGNED*>( 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<const PCB_DIM_CENTER*>( 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<const PCB_DIM_RADIAL*>( 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<const PCB_DIM_LEADER*>( 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 );

View File

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

View File

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

View File

@ -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 );