Radial dimensions.

ADDED radial type dimensions.

Fixes https://gitlab.com/kicad/code/kicad/issues/2056
This commit is contained in:
Jeff Young 2021-07-13 19:46:33 +01:00
parent 21eb928218
commit 4b6bf3095a
42 changed files with 657 additions and 119 deletions

View File

@ -623,6 +623,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
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:
addShapeWithClearance( static_cast<PCB_DIMENSION_BASE*>( item ),
@ -929,6 +930,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
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:
addShapeWithClearance( static_cast<PCB_DIMENSION_BASE*>( item ), layerContainer,

View File

@ -152,6 +152,7 @@ set( BMAPS_MID
add_orthogonal_dimension
add_pcb_target
add_power
add_radial_dimension
add_rectangle
add_symbol_to_schematic
add_tracks

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 B

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

View File

@ -12,7 +12,7 @@
viewBox="0 0 24 24"
version="1.1"
sodipodi:docname="add_center_dimension.svg"
inkscape:version="1.0.1 (c497b03c, 2020-09-10)">
inkscape:version="1.0.2 (e86c8708, 2021-01-15)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
@ -22,8 +22,8 @@
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1609"
inkscape:window-height="1035"
inkscape:window-width="1440"
inkscape:window-height="800"
id="namedview30"
showgrid="true"
inkscape:zoom="33.649424"
@ -91,8 +91,4 @@
class="cls-2"
d="m 14.5,11.5 a 3,3 0 1 1 -3,-3 3,3 0 0 1 3,3 z"
id="path27898" />
<path
class="cls-2"
d="m 23,11.5 a 3,3 0 1 1 -3,-3 3,3 0 0 1 3,3 z"
id="path27900" />
</svg>

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="Слой_1"
data-name="Слой 1"
viewBox="0 0 24 24"
version="1.1"
sodipodi:docname="add_radial_dimension.svg"
inkscape:version="1.0.2 (e86c8708, 2021-01-15)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1440"
inkscape:window-height="800"
id="namedview30"
showgrid="true"
inkscape:zoom="33.649424"
inkscape:cx="13.5214"
inkscape:cy="3.5379729"
inkscape:window-x="0"
inkscape:window-y="23"
inkscape:window-maximized="0"
inkscape:document-rotation="0"
inkscape:current-layer="Слой_1">
<inkscape:grid
type="xygrid"
id="grid_kicad"
spacingx="0.5"
spacingy="0.5"
color="#9999ff"
opacity="0.13"
empspacing="2" />
</sodipodi:namedview>
<metadata
id="metadata43">
<rdf:RDF>
<cc:Work
rdf:about="">
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>add_arc</dc:title>
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<defs
id="defs27890">
<style
id="style27888">.cls-1{fill:#DED3DD;}.cls-2{fill:#42B8EB;}</style>
</defs>
<title
id="title27892">add_center_dimension</title>
<path
style="fill:none;stroke:#DED3DD;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 11.5,1.5 v 20"
id="path844" />
<path
style="fill:none;stroke:#DED3DD;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="M 1.5,11.5 H 21"
id="path846" />
<path
class="cls-2"
d="m 14.5,11.5 a 3,3 0 1 1 -3,-3 3,3 0 0 1 3,3 z"
id="path27898" />
<path
class="cls-2"
d="m 21.666667,4 a 3,3 0 1 1 -3,-3 3,3 0 0 1 3,3 z"
id="path27900" />
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -12,7 +12,7 @@
viewBox="0 0 24 24"
version="1.1"
sodipodi:docname="add_center_dimension.svg"
inkscape:version="1.0.1 (c497b03c, 2020-09-10)">
inkscape:version="1.0.2 (e86c8708, 2021-01-15)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
@ -22,8 +22,8 @@
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1609"
inkscape:window-height="1035"
inkscape:window-width="1440"
inkscape:window-height="800"
id="namedview30"
showgrid="true"
inkscape:zoom="33.649424"
@ -91,8 +91,4 @@
class="cls-2"
d="m 14.5,11.5 a 3,3 0 1 1 -3,-3 3,3 0 0 1 3,3 z"
id="path27898" />
<path
class="cls-2"
d="m 23,11.5 a 3,3 0 1 1 -3,-3 3,3 0 0 1 3,3 z"
id="path27900" />
</svg>

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="Слой_1"
data-name="Слой 1"
viewBox="0 0 24 24"
version="1.1"
sodipodi:docname="add_radial_dimension.svg"
inkscape:version="1.0.2 (e86c8708, 2021-01-15)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1440"
inkscape:window-height="800"
id="namedview30"
showgrid="true"
inkscape:zoom="33.649424"
inkscape:cx="14.383227"
inkscape:cy="8.6197835"
inkscape:window-x="0"
inkscape:window-y="23"
inkscape:window-maximized="0"
inkscape:document-rotation="0"
inkscape:current-layer="Слой_1">
<inkscape:grid
type="xygrid"
id="grid_kicad"
spacingx="0.5"
spacingy="0.5"
color="#9999ff"
opacity="0.13"
empspacing="2" />
</sodipodi:namedview>
<metadata
id="metadata43">
<rdf:RDF>
<cc:Work
rdf:about="">
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>add_arc</dc:title>
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<defs
id="defs27890">
<style
id="style27888">.cls-1{fill:#545454;}.cls-2{fill:#1a81c4;}</style>
</defs>
<title
id="title27892">add_center_dimension</title>
<path
style="fill:none;stroke:#545454;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 11.5,1.5 v 20"
id="path844" />
<path
style="fill:none;stroke:#545454;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="M 1.5,11.5 H 21"
id="path846" />
<path
class="cls-2"
d="m 14.5,11.5 a 3,3 0 1 1 -3,-3 3,3 0 0 1 3,3 z"
id="path27898" />
<path
class="cls-2"
d="m 21.666667,4 a 3,3 0 1 1 -3,-3 3,3 0 0 1 3,3 z"
id="path27900" />
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -325,6 +325,7 @@ static struct EDA_ITEM_DESC
.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" ) )

View File

@ -157,6 +157,7 @@ last_trace_width
layer
layers
leader
leader_length
left
linear
links
@ -225,6 +226,7 @@ prefix
primitives
priority
pts
radial
radius
rev
rect

View File

@ -169,6 +169,7 @@ const std::vector<BITMAP_INFO> g_BitmapInfo = {
{ BITMAPS::add_orthogonal_dimension, wxT( "add_orthogonal_dimension_24.png" ), 24, wxT( "light" ) },
{ BITMAPS::add_pcb_target, wxT( "add_pcb_target_24.png" ), 24, wxT( "light" ) },
{ BITMAPS::add_power, wxT( "add_power_24.png" ), 24, wxT( "light" ) },
{ BITMAPS::add_radial_dimension, wxT( "add_radial_dimension_24.png" ), 24, wxT( "light" ) },
{ BITMAPS::add_rectangle, wxT( "add_rectangle_24.png" ), 24, wxT( "light" ) },
{ BITMAPS::add_symbol_to_schematic, wxT( "add_symbol_to_schematic_24.png" ), 24, wxT( "light" ) },
{ BITMAPS::add_tracks, wxT( "add_tracks_24.png" ), 24, wxT( "light" ) },
@ -535,6 +536,7 @@ const std::vector<BITMAP_INFO> g_BitmapInfo = {
{ BITMAPS::add_orthogonal_dimension, wxT( "add_orthogonal_dimension_dark_24.png" ), 24, wxT( "dark" ) },
{ BITMAPS::add_pcb_target, wxT( "add_pcb_target_dark_24.png" ), 24, wxT( "dark" ) },
{ BITMAPS::add_power, wxT( "add_power_dark_24.png" ), 24, wxT( "dark" ) },
{ BITMAPS::add_radial_dimension, wxT( "add_radial_dimension_dark_24.png" ), 24, wxT( "dark" ) },
{ BITMAPS::add_rectangle, wxT( "add_rectangle_dark_24.png" ), 24, wxT( "dark" ) },
{ BITMAPS::add_symbol_to_schematic, wxT( "add_symbol_to_schematic_dark_24.png" ), 24, wxT( "dark" ) },
{ BITMAPS::add_tracks, wxT( "add_tracks_dark_24.png" ), 24, wxT( "dark" ) },

View File

@ -68,6 +68,7 @@ enum class BITMAPS : unsigned int
add_orthogonal_dimension,
add_pcb_target,
add_power,
add_radial_dimension,
add_rectangle,
add_symbol_to_schematic,
add_tracks,

View File

@ -100,6 +100,7 @@ enum KICAD_T
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
@ -257,6 +258,7 @@ constexpr KICAD_T BaseType( const KICAD_T aType )
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:
return PCB_DIMENSION_T;

View File

@ -118,6 +118,7 @@ void ARRAY_CREATOR::Invoke()
case PCB_VIA_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:
case PCB_TARGET_T:

View File

@ -275,6 +275,7 @@ void BOARD::Move( const wxPoint& aMoveVector ) // overload
PCB_DIM_ALIGNED_T,
PCB_DIM_ORTHOGONAL_T,
PCB_DIM_CENTER_T,
PCB_DIM_RADIAL_T,
PCB_DIM_LEADER_T,
PCB_TARGET_T,
PCB_VIA_T,
@ -662,6 +663,7 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode )
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:
case PCB_SHAPE_T:
@ -768,6 +770,7 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aRemoveMode )
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:
case PCB_SHAPE_T:
@ -1241,6 +1244,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T s
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:
case PCB_TARGET_T:
@ -1255,6 +1259,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T s
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:
case PCB_TARGET_T:

View File

@ -248,6 +248,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a
case PCB_VIA_T: // a via (like track segment on a copper layer)
case PCB_DIM_ALIGNED_T: // a dimension (graphic item)
case PCB_DIM_CENTER_T:
case PCB_DIM_RADIAL_T:
case PCB_DIM_ORTHOGONAL_T:
case PCB_DIM_LEADER_T: // a leader dimension
case PCB_TARGET_T: // a target (graphic item)

View File

@ -52,6 +52,7 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
PCB_SHAPE_T, // in m_drawings
PCB_DIM_ALIGNED_T, // in m_drawings
PCB_DIM_CENTER_T, // in m_drawings
PCB_DIM_RADIAL_T, // in m_drawings
PCB_DIM_ORTHOGONAL_T, // in m_drawings
PCB_DIM_LEADER_T, // in m_drawings
PCB_TARGET_T, // in m_drawings
@ -74,6 +75,7 @@ const KICAD_T GENERAL_COLLECTOR::BoardLevelItems[] = {
PCB_DIM_ALIGNED_T,
PCB_DIM_ORTHOGONAL_T,
PCB_DIM_CENTER_T,
PCB_DIM_RADIAL_T,
PCB_DIM_LEADER_T,
PCB_TARGET_T,
PCB_VIA_T,
@ -141,6 +143,7 @@ const KICAD_T GENERAL_COLLECTOR::Dimensions[] = {
PCB_DIM_LEADER_T,
PCB_DIM_ORTHOGONAL_T,
PCB_DIM_CENTER_T,
PCB_DIM_RADIAL_T,
EOT
};
@ -286,6 +289,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
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:
dimension = static_cast<PCB_DIMENSION_BASE*>( item );

View File

@ -196,8 +196,8 @@ bool DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow()
if( m_cbLayerActual->SetLayerSelection( m_dimension->GetLayer() ) < 0 )
{
wxMessageBox( _( "This item was on a non-existing or forbidden layer.\n"
"It has been moved to the first allowed layer." ) );
wxMessageBox( _( "This item was on a non-existing layer.\n"
"It has been moved to the first defined layer." ) );
m_cbLayerActual->SetSelection( 0 );
}
@ -223,6 +223,8 @@ bool DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow()
m_cbKeepAligned->SetValue( m_dimension->GetKeepTextAligned() );
m_cbTextOrientation->Enable( !m_dimension->GetKeepTextAligned() );
m_orientValidator.TransferToWindow();
m_cbItalic->SetValue( text.IsItalic() );
m_cbMirrored->SetValue( text.IsMirrored() );
EDA_TEXT_HJUSTIFY_T hJustify = text.GetHorizJustify();
@ -243,12 +245,10 @@ bool DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow()
m_txtValueActual->SetValue( m_dimension->GetValueText() );
}
m_orientValidator.TransferToWindow();
if( m_dimension->Type() == PCB_DIM_LEADER_T )
{
PCB_DIM_LEADER* leader = static_cast<PCB_DIM_LEADER*>( m_dimension );
m_cbTextFrame->SetSelection( static_cast<int>( leader->GetTextFrame() ) );
m_cbTextFrame->SetSelection( static_cast<int>( leader->GetTextBorder() ) );
}
return DIALOG_DIMENSION_PROPERTIES_BASE::TransferDataToWindow();
@ -354,7 +354,7 @@ void DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog( PCB_DIMENSION_BASE*
if( aTarget->Type() == PCB_DIM_LEADER_T )
{
PCB_DIM_LEADER* leader = static_cast<PCB_DIM_LEADER*>( aTarget );
leader->SetTextFrame( static_cast<DIM_TEXT_FRAME>( m_cbTextFrame->GetSelection() ) );
leader->SetTextBorder( static_cast<DIM_TEXT_BORDER>( m_cbTextFrame->GetSelection()));
}
aTarget->Update();

View File

@ -195,7 +195,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_ORTHOGONAL_T
PCB_DIM_CENTER_T, PCB_DIM_RADIAL_T, PCB_DIM_ORTHOGONAL_T
};
forEachGeometryItem( itemTypes, LSET::AllCuMask(), countItems );

View File

@ -106,6 +106,7 @@ bool DRC_TEST_PROVIDER_DISALLOW::Run()
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:
{

View File

@ -137,6 +137,7 @@ void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem )
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:
ShowDimensionPropertiesDialog( static_cast<PCB_DIMENSION_BASE*>( aItem ) );

View File

@ -211,6 +211,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_
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:
case PCB_TARGET_T:

View File

@ -327,6 +327,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
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();

View File

@ -952,11 +952,13 @@ 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 ),
m_textFrame( DIM_TEXT_FRAME::NONE )
m_textBorder( DIM_TEXT_BORDER::NONE )
{
m_unitsFormat = DIM_UNITS_FORMAT::NO_SUFFIX;
m_overrideTextEnabled = true;
m_keepTextAligned = false;
SetText( _( "Leader" ) );
}
@ -970,7 +972,12 @@ void PCB_DIM_LEADER::SwapData( BOARD_ITEM* aImage )
{
assert( aImage->Type() == PCB_DIM_LEADER_T );
m_shapes.clear();
static_cast<PCB_DIM_LEADER*>( aImage )->m_shapes.clear();
std::swap( *static_cast<PCB_DIM_LEADER*>( this ), *static_cast<PCB_DIM_LEADER*>( aImage ) );
Update();
}
@ -1008,7 +1015,7 @@ void PCB_DIM_LEADER::updateGeometry()
OPT_VECTOR2I arrowSegEnd = boost::make_optional( false, VECTOR2I() );;
OPT_VECTOR2I textSegEnd = boost::make_optional( false, VECTOR2I() );
if( m_textFrame == DIM_TEXT_FRAME::CIRCLE )
if( m_textBorder == DIM_TEXT_BORDER::CIRCLE )
{
double penWidth = m_text.GetEffectiveTextPenWidth() / 2.0;
double radius = ( textBox.GetWidth() / 2.0 ) - penWidth;
@ -1035,16 +1042,16 @@ void PCB_DIM_LEADER::updateGeometry()
double arrowRotNeg = firstLine.Angle() - DEG2RAD( s_arrowAngle );
m_shapes.emplace_back( new SHAPE_SEGMENT( start,
start + wxPoint( arrowEnd.Rotate( arrowRotPos ) ) ) );
start + (wxPoint) arrowEnd.Rotate( arrowRotPos ) ) );
m_shapes.emplace_back( new SHAPE_SEGMENT( start,
start + wxPoint( arrowEnd.Rotate( arrowRotNeg ) ) ) );
start + (wxPoint) arrowEnd.Rotate( arrowRotNeg ) ) );
if( !GetText().IsEmpty() )
{
switch( m_textFrame )
switch( m_textBorder )
{
case DIM_TEXT_FRAME::RECTANGLE:
case DIM_TEXT_BORDER::RECTANGLE:
{
for( SHAPE_POLY_SET::SEGMENT_ITERATOR seg = polyBox.IterateSegments(); seg; seg++ )
m_shapes.emplace_back( new SHAPE_SEGMENT( *seg ) );
@ -1052,7 +1059,7 @@ void PCB_DIM_LEADER::updateGeometry()
break;
}
case DIM_TEXT_FRAME::CIRCLE:
case DIM_TEXT_BORDER::CIRCLE:
{
double penWidth = m_text.GetEffectiveTextPenWidth() / 2.0;
double radius = ( textBox.GetWidth() / 2.0 ) - penWidth;
@ -1091,6 +1098,138 @@ 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 )
{
m_unitsFormat = DIM_UNITS_FORMAT::NO_SUFFIX;
m_overrideTextEnabled = false;
m_keepTextAligned = true;
m_isDiameter = false;
m_prefix = "R ";
m_leaderLength = m_arrowLength * 3;
}
EDA_ITEM* PCB_DIM_RADIAL::Clone() const
{
return new PCB_DIM_RADIAL( *this );
}
void PCB_DIM_RADIAL::SwapData( BOARD_ITEM* aImage )
{
assert( aImage->Type() == PCB_DIM_RADIAL_T );
m_shapes.clear();
static_cast<PCB_DIM_RADIAL*>( aImage )->m_shapes.clear();
std::swap( *static_cast<PCB_DIM_RADIAL*>( this ), *static_cast<PCB_DIM_RADIAL*>( aImage ) );
Update();
}
BITMAPS PCB_DIM_RADIAL::GetMenuImage() const
{
return BITMAPS::add_radial_dimension;
}
wxPoint PCB_DIM_RADIAL::GetKnee() const
{
VECTOR2I radial( m_end - m_start );
return m_end + (wxPoint) radial.Resize( m_leaderLength );
}
void PCB_DIM_RADIAL::updateText()
{
if( m_keepTextAligned )
{
VECTOR2I textLine( Text().GetPosition() - GetKnee() );
double textAngle = 3600 - RAD2DECIDEG( textLine.Angle() );
NORMALIZE_ANGLE_POS( textAngle );
if( textAngle > 900 && textAngle <= 2700 )
textAngle -= 1800;
// Round to nearest degree
m_text.SetTextAngle( KiROUND( textAngle / 10 ) * 10 );
}
PCB_DIMENSION_BASE::updateText();
}
void PCB_DIM_RADIAL::updateGeometry()
{
m_shapes.clear();
VECTOR2I center( m_start );
VECTOR2I centerArm( 0, m_arrowLength );
m_shapes.emplace_back( new SHAPE_SEGMENT( center - centerArm, center + centerArm ) );
centerArm = centerArm.Rotate( DEG2RAD( 90 ) );
m_shapes.emplace_back( new SHAPE_SEGMENT( center - centerArm, center + centerArm ) );
VECTOR2I radius( m_end - m_start );
if( m_isDiameter )
m_measuredValue = KiROUND( radius.EuclideanNorm() * 2 );
else
m_measuredValue = KiROUND( radius.EuclideanNorm() );
updateText();
// Now that we have the text updated, we can determine how to draw the second line
// First we need to create an appropriate bounding polygon to collide with
EDA_RECT textBox = m_text.GetTextBox().Inflate( m_text.GetTextWidth() / 2,
m_text.GetEffectiveTextPenWidth() );
SHAPE_POLY_SET polyBox;
polyBox.NewOutline();
polyBox.Append( textBox.GetOrigin() );
polyBox.Append( textBox.GetOrigin().x, textBox.GetEnd().y );
polyBox.Append( textBox.GetEnd() );
polyBox.Append( textBox.GetEnd().x, textBox.GetOrigin().y );
polyBox.Rotate( -m_text.GetTextAngleRadians(), textBox.GetCenter() );
VECTOR2I radial( m_end - m_start );
radial = radial.Resize( m_leaderLength );
SEG arrowSeg( m_end, m_end + (wxPoint) radial );
SEG textSeg( arrowSeg.B, m_text.GetPosition() );
OPT_VECTOR2I arrowSegEnd = segPolyIntersection( polyBox, arrowSeg );
OPT_VECTOR2I textSegEnd = segPolyIntersection( polyBox, textSeg );
if( arrowSegEnd )
arrowSeg.B = arrowSegEnd.get();
if( textSegEnd )
textSeg.B = textSegEnd.get();
m_shapes.emplace_back( new SHAPE_SEGMENT( arrowSeg ) );
// Add arrows
VECTOR2I arrowEnd( m_arrowLength, 0 );
double arrowRotPos = radial.Angle() + DEG2RAD( s_arrowAngle );
double arrowRotNeg = radial.Angle() - DEG2RAD( s_arrowAngle );
m_shapes.emplace_back( new SHAPE_SEGMENT( m_end,
m_end + (wxPoint) arrowEnd.Rotate( arrowRotPos ) ) );
m_shapes.emplace_back( new SHAPE_SEGMENT( m_end,
m_end + (wxPoint) arrowEnd.Rotate( arrowRotNeg ) ) );
m_shapes.emplace_back( new SHAPE_SEGMENT( textSeg ) );
}
PCB_DIM_CENTER::PCB_DIM_CENTER( BOARD_ITEM* aParent ) :
PCB_DIMENSION_BASE( aParent, PCB_DIM_CENTER_T )
{

View File

@ -65,7 +65,7 @@ enum class DIM_UNITS_MODE
/**
* Frame to show around dimension text
*/
enum class DIM_TEXT_FRAME
enum class DIM_TEXT_BORDER
{
NONE,
RECTANGLE,
@ -472,13 +472,69 @@ private:
};
/**
* A radial dimension indicates either the radius or diameter of an arc or circle.
*
* A guide to the geometry of a circle dimension:
*
* |
* --a--
* |
*
*
* b_
* |\
* \
* c---d TEXT
*
* Point a (the center of the arc or circle) is m_start, point b (a point on the arc or circle)
* is m_end, point c is m_leaderLength away from b on the a-b vector, and point d is the end of
* the "text line". The c-d line is drawn from c to the text center, and clipped on the text
* bounding box.
*/
class PCB_DIM_RADIAL : public PCB_DIMENSION_BASE
{
public:
PCB_DIM_RADIAL( BOARD_ITEM* aParent );
static inline bool ClassOf( const EDA_ITEM* aItem )
{
return aItem && PCB_DIM_RADIAL_T == aItem->Type();
}
EDA_ITEM* Clone() const override;
virtual void SwapData( BOARD_ITEM* aImage ) override;
void SetLeaderLength( int aLength ) { m_leaderLength = aLength; }
int GetLeaderLength() const { return m_leaderLength; }
// Returns the point (c).
wxPoint GetKnee() const;
BITMAPS GetMenuImage() const override;
wxString GetClass() const override
{
return wxT( "PCB_DIM_RADIAL" );
}
protected:
void updateText() override;
void updateGeometry() override;
private:
bool m_isDiameter;
int m_leaderLength;
};
/**
* A leader is a dimension-like object pointing to a specific point.
*
* A guide to the geometry of a leader:
*
* a
* _
* a_
* |\
* \
* b---c TEXT
@ -507,8 +563,8 @@ public:
return wxT( "PCB_DIM_LEADER" );
}
void SetTextFrame( DIM_TEXT_FRAME aFrame ) { m_textFrame = aFrame; }
DIM_TEXT_FRAME GetTextFrame() const { return m_textFrame; }
void SetTextBorder( DIM_TEXT_BORDER aFrame ) { m_textBorder = aFrame; }
DIM_TEXT_BORDER GetTextBorder() const { return m_textBorder; }
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
@ -516,7 +572,7 @@ protected:
void updateGeometry() override;
private:
DIM_TEXT_FRAME m_textFrame;
DIM_TEXT_BORDER m_textBorder;
};

View File

@ -773,6 +773,7 @@ void PCB_EDIT_FRAME::setupUIConditions()
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::placeTarget );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drillOrigin );

View File

@ -528,6 +528,7 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
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:
draw( static_cast<const PCB_DIMENSION_BASE*>( item ), aLayer );

View File

@ -356,6 +356,7 @@ void BRDITEMS_PLOTTER::PlotBoardGraphicItems()
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:
PlotDimension( (PCB_DIMENSION_BASE*) item );

View File

@ -2847,6 +2847,10 @@ PCB_DIMENSION_BASE* PCB_PARSER::parseDIMENSION()
dimension = std::make_unique<PCB_DIM_CENTER>( nullptr );
break;
case T_radial:
dimension = std::make_unique<PCB_DIM_RADIAL>( nullptr );
break;
default:
wxFAIL_MSG( wxT( "Cannot parse unknown dimension type %s" ) +
GetTokenString( CurTok() ) );
@ -2922,6 +2926,16 @@ PCB_DIMENSION_BASE* PCB_PARSER::parseDIMENSION()
break;
}
case T_leader_length:
{
wxCHECK_MSG( dimension->Type() == PCB_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();
break;
}
case T_orientation:
{
wxCHECK_MSG( dimension->Type() == PCB_DIM_ORTHOGONAL_T, nullptr,
@ -3055,7 +3069,7 @@ PCB_DIMENSION_BASE* PCB_PARSER::parseDIMENSION()
int textFrame = parseInt( "dimension text frame mode" );
textFrame = std::max( 0, std::min( 3, textFrame ) );
leader->SetTextFrame( static_cast<DIM_TEXT_FRAME>( textFrame ) );
leader->SetTextBorder( static_cast<DIM_TEXT_BORDER>( textFrame ));
NeedRIGHT();
break;
}

View File

@ -409,6 +409,7 @@ void PCB_PLUGIN::Format( const BOARD_ITEM* aItem, int aNestLevel ) const
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:
format( static_cast<const PCB_DIMENSION_BASE*>( aItem ), aNestLevel );
@ -709,6 +710,7 @@ void PCB_PLUGIN::format( const PCB_DIMENSION_BASE* aDimension, int aNestLevel )
const PCB_DIM_ALIGNED* aligned = dynamic_cast<const PCB_DIM_ALIGNED*>( aDimension );
const PCB_DIM_ORTHOGONAL* ortho = dynamic_cast<const PCB_DIM_ORTHOGONAL*>( aDimension );
const PCB_DIM_CENTER* center = dynamic_cast<const PCB_DIM_CENTER*>( aDimension );
const PCB_DIM_RADIAL* radial = dynamic_cast<const PCB_DIM_RADIAL*>( aDimension );
const PCB_DIM_LEADER* leader = dynamic_cast<const PCB_DIM_LEADER*>( aDimension );
m_out->Print( aNestLevel, "(dimension" );
@ -722,6 +724,8 @@ void PCB_PLUGIN::format( const PCB_DIMENSION_BASE* aDimension, int aNestLevel )
m_out->Print( 0, " (type leader)" );
else if( aDimension->Type() == PCB_DIM_CENTER_T )
m_out->Print( 0, " (type center)" );
else if (aDimension->Type() == PCB_DIM_RADIAL_T )
m_out->Print( 0, " (type radial)" );
else if( aDimension->Type() == PCB_DIM_ORTHOGONAL_T )
m_out->Print( 0, " (type orthogonal)" );
else
@ -745,6 +749,12 @@ void PCB_PLUGIN::format( const PCB_DIMENSION_BASE* aDimension, int aNestLevel )
FormatInternalUnits( aligned->GetHeight() ).c_str() );
}
if( radial )
{
m_out->Print( aNestLevel+1, "(leader_length %s)\n",
FormatInternalUnits( radial->GetLeaderLength() ).c_str() );
}
if( ortho )
{
m_out->Print( aNestLevel+1, "(orientation %d)\n",
@ -789,7 +799,7 @@ void PCB_PLUGIN::format( const PCB_DIMENSION_BASE* aDimension, int aNestLevel )
}
if( leader )
m_out->Print( 0, " (text_frame %d)", static_cast<int>( leader->GetTextFrame() ) );
m_out->Print( 0, " (text_frame %d)", static_cast<int>( leader->GetTextBorder() ) );
m_out->Print( 0, " (extension_offset %s)",
FormatInternalUnits( aDimension->GetExtensionOffset() ).c_str() );

View File

@ -102,7 +102,8 @@ class PCB_TEXT;
//#define SEXPR_BOARD_FILE_VERSION 20210722 // Reading/writing group locked flags
//#define SEXPR_BOARD_FILE_VERSION 20210824 // Opacity in 3D colors
//#define SEXPR_BOARD_FILE_VERSION 20210925 // Locked flag for fp_text
#define SEXPR_BOARD_FILE_VERSION 20211014 // Arc formatting
//#define SEXPR_BOARD_FILE_VERSION 20211014 // Arc formatting
#define SEXPR_BOARD_FILE_VERSION 20211226 // Add radial dimension
#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

@ -409,6 +409,7 @@ void PCB_EDIT_FRAME::ReCreateVToolbar()
{ &PCB_ACTIONS::drawAlignedDimension,
&PCB_ACTIONS::drawOrthogonalDimension,
&PCB_ACTIONS::drawCenterDimension,
&PCB_ACTIONS::drawRadialDimension,
&PCB_ACTIONS::drawLeader } );
}

View File

@ -894,6 +894,11 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
{
dimension = new PCB_DIM_CENTER( m_board );
}
else if( originalEvent.IsAction( &PCB_ACTIONS::drawRadialDimension ) )
{
dimension = new PCB_DIM_RADIAL( m_board );
setMeasurementAttributes( dimension );
}
else if( originalEvent.IsAction( &PCB_ACTIONS::drawLeader ) )
{
dimension = new PCB_DIM_LEADER( m_board );
@ -930,22 +935,18 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
}
case SET_END:
{
dimension->SetEnd( (wxPoint) cursorPos );
dimension->Update();
if( Is45Limited() || dimension->Type() == PCB_DIM_CENTER_T )
constrainDimension( dimension );
// Dimensions that have origin and end in the same spot are not valid
if( dimension->GetStart() == dimension->GetEnd() )
--step;
else if( dimension->Type() == PCB_DIM_LEADER_T )
dimension->SetText( wxT( "?" ) );
if( dimension->Type() == PCB_DIM_CENTER_T )
{
// No separate height/text step
--step;
break;
}
if( dimension->Type() == PCB_DIM_CENTER_T
|| dimension->Type() == PCB_DIM_RADIAL_T
|| dimension->Type() == PCB_DIM_LEADER_T )
{
// No separate height step
++step;
KI_FALLTHROUGH;
}
@ -953,24 +954,8 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
{
break;
}
}
case SET_HEIGHT:
if( dimension->Type() == PCB_DIM_LEADER_T )
{
assert( dimension->GetStart() != dimension->GetEnd() );
assert( dimension->GetLineThickness() > 0 );
preview.Remove( dimension );
commit.Add( dimension );
commit.Push( _( "Draw a leader" ) );
// Run the edit immediately to set the leader text
m_toolMgr->RunAction( PCB_ACTIONS::properties, true, dimension );
}
else if( (wxPoint) cursorPos != dimension->GetPosition() )
{
assert( dimension->GetStart() != dimension->GetEnd() );
assert( dimension->GetLineThickness() > 0 );
@ -979,9 +964,14 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
commit.Add( dimension );
commit.Push( _( "Draw a dimension" ) );
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, dimension );
if( dimension->Type() == PCB_DIM_LEADER_T )
{
// Run the edit immediately to set the leader text
m_toolMgr->RunAction( PCB_ACTIONS::properties, true, dimension );
}
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, dimension );
break;
}
@ -999,6 +989,9 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
case SET_END:
dimension->SetEnd( (wxPoint) cursorPos );
if( Is45Limited() || dimension->Type() == PCB_DIM_CENTER_T )
constrainDimension( dimension );
if( dimension->Type() == PCB_DIM_ORTHOGONAL_T )
{
PCB_DIM_ORTHOGONAL* ortho = static_cast<PCB_DIM_ORTHOGONAL*>( dimension );
@ -1012,16 +1005,31 @@ 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 )
{
PCB_DIM_RADIAL* radialDim = static_cast<PCB_DIM_RADIAL*>( dimension );
wxPoint textOffset( radialDim->GetArrowLength() * 10, 0 );
if( radialDim->GetEnd().x < radialDim->GetStart().x )
textOffset = -textOffset;
radialDim->Text().SetPosition( radialDim->GetKnee() + textOffset );
radialDim->Update();
}
else if( dimension->Type() == PCB_DIM_LEADER_T )
{
wxPoint textOffset( dimension->GetArrowLength() * 10, 0 );
if( dimension->GetEnd().x < dimension->GetStart().x )
textOffset = -textOffset;
dimension->Text().SetPosition( dimension->GetEnd() + textOffset );
dimension->Update();
if( Is45Limited() || dimension->Type() == PCB_DIM_CENTER_T )
constrainDimension( dimension );
}
break;
case SET_HEIGHT:
{
if( dimension->Type() == PCB_DIM_ALIGNED_T )
{
PCB_DIM_ALIGNED* aligned = static_cast<PCB_DIM_ALIGNED*>( dimension );
@ -1038,36 +1046,27 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
{
PCB_DIM_ORTHOGONAL* ortho = static_cast<PCB_DIM_ORTHOGONAL*>( dimension );
BOX2I bounds( dimension->GetStart(),
BOX2I bbox( dimension->GetStart(),
dimension->GetEnd() - dimension->GetStart() );
VECTOR2I direction( cursorPos - bounds.Centre() );
VECTOR2I direction( cursorPos - bbox.Centre() );
bool vert;
// Only change the orientation when we move outside the bounds
if( !bounds.Contains( cursorPos ) )
// Only change the orientation when we move outside the bbox
if( !bbox.Contains( cursorPos ) )
{
// If the dimension is horizontal or vertical, set correct orientation
// otherwise, test if we're left/right of the bounding box or above/below it
if( bounds.GetWidth() == 0 )
{
if( bbox.GetWidth() == 0 )
vert = true;
}
else if( bounds.GetHeight() == 0 )
{
else if( bbox.GetHeight() == 0 )
vert = false;
}
else if( cursorPos.x > bounds.GetLeft() && cursorPos.x < bounds.GetRight() )
{
else if( cursorPos.x > bbox.GetLeft() && cursorPos.x < bbox.GetRight() )
vert = false;
}
else if( cursorPos.y > bounds.GetTop() && cursorPos.y < bounds.GetBottom() )
{
else if( cursorPos.y > bbox.GetTop() && cursorPos.y < bbox.GetBottom() )
vert = true;
}
else
{
vert = std::abs( direction.y ) < std::abs( direction.x );
}
ortho->SetOrientation( vert ? PCB_DIM_ORTHOGONAL::DIR::VERTICAL
: PCB_DIM_ORTHOGONAL::DIR::HORIZONTAL );
}
@ -1080,15 +1079,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
ortho->SetHeight( vert ? heightVector.x : heightVector.y );
ortho->Update();
}
else if( dimension->Type() == PCB_DIM_LEADER_T )
{
// Leader: SET_HEIGHT actually sets the text position directly
VECTOR2I lineVector( cursorPos - dimension->GetEnd() );
dimension->Text().SetPosition( wxPoint( VECTOR2I( dimension->GetEnd() ) +
GetVectorSnapped45( lineVector ) ) );
dimension->Update();
}
}
break;
}
@ -2732,6 +2723,7 @@ void DRAWING_TOOL::setTransitions()
Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawAlignedDimension.MakeEvent() );
Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawOrthogonalDimension.MakeEvent() );
Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawCenterDimension.MakeEvent() );
Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawRadialDimension.MakeEvent() );
Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawLeader.MakeEvent() );
Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawZone.MakeEvent() );
Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawRuleArea.MakeEvent() );

View File

@ -2124,6 +2124,7 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
case PCB_TARGET_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:
dupe_item = orig_item->Duplicate();

View File

@ -134,6 +134,11 @@ TOOL_ACTION PCB_ACTIONS::drawCenterDimension( "pcbnew.InteractiveDrawing.centerD
_( "Add Center Dimension" ), _( "Add a center dimension" ),
BITMAPS::add_center_dimension, AF_ACTIVATE );
TOOL_ACTION PCB_ACTIONS::drawRadialDimension( "pcbnew.InteractiveDrawing.radialDimension",
AS_GLOBAL, 0, "",
_( "Add Radial Dimension" ), _( "Add a radial dimension" ),
BITMAPS::add_radial_dimension, AF_ACTIVATE );
TOOL_ACTION PCB_ACTIONS::drawOrthogonalDimension( "pcbnew.InteractiveDrawing.orthogonalDimension",
AS_GLOBAL, 0, "",
_( "Add Orthogonal Dimension" ), _( "Add an orthogonal dimension" ),

View File

@ -144,6 +144,7 @@ public:
static TOOL_ACTION placeText;
static TOOL_ACTION drawAlignedDimension;
static TOOL_ACTION drawCenterDimension;
static TOOL_ACTION drawRadialDimension;
static TOOL_ACTION drawOrthogonalDimension;
static TOOL_ACTION drawLeader;
static TOOL_ACTION drawZone;

View File

@ -997,6 +997,7 @@ int PCB_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
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:
{

View File

@ -679,6 +679,16 @@ void PCB_GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos
break;
}
case PCB_DIM_RADIAL_T:
{
const PCB_DIM_RADIAL* radialDim = static_cast<const PCB_DIM_RADIAL*>( aItem );
addAnchor( radialDim->GetStart(), CORNER | SNAPPABLE, aItem );
addAnchor( radialDim->GetEnd(), CORNER | SNAPPABLE, aItem );
addAnchor( radialDim->GetKnee(), CORNER | SNAPPABLE, aItem );
addAnchor( radialDim->Text().GetPosition(), CORNER | SNAPPABLE, aItem );
break;
}
case PCB_DIM_LEADER_T:
{
const PCB_DIM_LEADER* leader = static_cast<const PCB_DIM_LEADER*>( aItem );

View File

@ -95,6 +95,7 @@ enum DIMENSION_POINTS
DIM_TEXT,
DIM_CROSSBARSTART,
DIM_CROSSBAREND,
DIM_KNEE = DIM_CROSSBARSTART
};
@ -334,6 +335,25 @@ std::shared_ptr<EDIT_POINTS> PCB_POINT_EDITOR::makePoints( EDA_ITEM* aItem )
break;
}
case PCB_DIM_RADIAL_T:
{
const PCB_DIM_RADIAL* dimension = static_cast<const PCB_DIM_RADIAL*>( aItem );
points->AddPoint( dimension->GetStart() );
points->AddPoint( dimension->GetEnd() );
points->AddPoint( dimension->Text().GetPosition() );
points->AddPoint( dimension->GetKnee() );
points->Point( DIM_KNEE ).SetConstraint( new EC_LINE( points->Point( DIM_START ),
points->Point( DIM_END ) ) );
points->Point( DIM_TEXT ).SetConstraint( new EC_45DEGREE( points->Point( DIM_TEXT ),
points->Point( DIM_KNEE ) ) );
points->Point( DIM_TEXT ).SetGridConstraint( IGNORE_GRID );
break;
}
case PCB_DIM_LEADER_T:
{
const PCB_DIM_LEADER* dimension = static_cast<const PCB_DIM_LEADER*>( aItem );
@ -344,6 +364,7 @@ std::shared_ptr<EDIT_POINTS> PCB_POINT_EDITOR::makePoints( EDA_ITEM* aItem )
points->Point( DIM_TEXT ).SetConstraint( new EC_45DEGREE( points->Point( DIM_TEXT ),
points->Point( DIM_END ) ) );
points->Point( DIM_TEXT ).SetGridConstraint( IGNORE_GRID );
break;
}
@ -1461,6 +1482,54 @@ void PCB_POINT_EDITOR::updateItem() const
break;
}
case PCB_DIM_RADIAL_T:
{
PCB_DIM_RADIAL* dimension = static_cast<PCB_DIM_RADIAL*>( item );
if( isModified( m_editPoints->Point( DIM_START ) ) )
{
dimension->SetStart( (wxPoint) m_editedPoint->GetPosition() );
dimension->Update();
m_editPoints->Point( DIM_KNEE ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_START ),
m_editPoints->Point( DIM_END ) ) );
}
else if( isModified( m_editPoints->Point( DIM_END ) ) )
{
wxPoint oldKnee = dimension->GetKnee();
dimension->SetEnd( (wxPoint) m_editedPoint->GetPosition() );
dimension->Update();
wxPoint kneeDelta = dimension->GetKnee() - oldKnee;
dimension->Text().SetPosition( dimension->Text().GetPosition() + kneeDelta );
dimension->Update();
m_editPoints->Point( DIM_KNEE ).SetConstraint( new EC_LINE( m_editPoints->Point( DIM_START ),
m_editPoints->Point( DIM_END ) ) );
}
else if( isModified( m_editPoints->Point( DIM_KNEE ) ) )
{
wxPoint oldKnee = dimension->GetKnee();
VECTOR2I arrowVec = m_editPoints->Point( DIM_KNEE ).GetPosition()
- m_editPoints->Point( DIM_END ).GetPosition();
dimension->SetLeaderLength( arrowVec.EuclideanNorm() );
dimension->Update();
wxPoint kneeDelta = dimension->GetKnee() - oldKnee;
dimension->Text().SetPosition( dimension->Text().GetPosition() + kneeDelta );
dimension->Update();
}
else if( isModified( m_editPoints->Point( DIM_TEXT ) ) )
{
dimension->Text().SetPosition( (wxPoint) m_editedPoint->GetPosition() );
dimension->Update();
}
break;
}
case PCB_DIM_LEADER_T:
{
PCB_DIM_LEADER* dimension = static_cast<PCB_DIM_LEADER*>( item );
@ -1731,6 +1800,17 @@ void PCB_POINT_EDITOR::updatePoints()
break;
}
case PCB_DIM_RADIAL_T:
{
const PCB_DIM_RADIAL* dimension = static_cast<const PCB_DIM_RADIAL*>( item );
m_editPoints->Point( DIM_START ).SetPosition( dimension->GetStart() );
m_editPoints->Point( DIM_END ).SetPosition( dimension->GetEnd() );
m_editPoints->Point( DIM_TEXT ).SetPosition( dimension->Text().GetPosition() );
m_editPoints->Point( DIM_KNEE ).SetPosition( dimension->GetKnee() );
break;
}
case PCB_DIM_LEADER_T:
{
const PCB_DIM_LEADER* dimension = static_cast<const PCB_DIM_LEADER*>( item );
@ -1861,6 +1941,14 @@ EDIT_POINT PCB_POINT_EDITOR::get45DegConstrainer() const
break;
}
case PCB_DIM_RADIAL_T:
{
if( isModified( m_editPoints->Point( DIM_TEXT ) ) )
return m_editPoints->Point( DIM_KNEE );
break;
}
default:
break;
}

View File

@ -1593,6 +1593,7 @@ static bool itemIsIncludedByFilter( const BOARD_ITEM& aItem, const BOARD& aBoard
case PCB_TARGET_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( layer == Edge_Cuts )
@ -1744,6 +1745,7 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect
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( !m_filter.dimensions )