diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index e2bfb3a858..a8c3ea3b1e 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -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( 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( item ), layerContainer, diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt index 840152ccae..5152ddd619 100644 --- a/bitmaps_png/CMakeLists.txt +++ b/bitmaps_png/CMakeLists.txt @@ -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 diff --git a/bitmaps_png/png/add_center_dimension_24.png b/bitmaps_png/png/add_center_dimension_24.png index b03451dbac..d212b0513a 100644 Binary files a/bitmaps_png/png/add_center_dimension_24.png and b/bitmaps_png/png/add_center_dimension_24.png differ diff --git a/bitmaps_png/png/add_center_dimension_dark_24.png b/bitmaps_png/png/add_center_dimension_dark_24.png index d6aaa45145..af06781984 100644 Binary files a/bitmaps_png/png/add_center_dimension_dark_24.png and b/bitmaps_png/png/add_center_dimension_dark_24.png differ diff --git a/bitmaps_png/png/add_radial_dimension_24.png b/bitmaps_png/png/add_radial_dimension_24.png new file mode 100644 index 0000000000..4f98a49d86 Binary files /dev/null and b/bitmaps_png/png/add_radial_dimension_24.png differ diff --git a/bitmaps_png/png/add_radial_dimension_dark_24.png b/bitmaps_png/png/add_radial_dimension_dark_24.png new file mode 100644 index 0000000000..25c36555c9 Binary files /dev/null and b/bitmaps_png/png/add_radial_dimension_dark_24.png differ diff --git a/bitmaps_png/sources/dark/add_center_dimension.svg b/bitmaps_png/sources/dark/add_center_dimension.svg index e232a6455b..da8ac0136d 100644 --- a/bitmaps_png/sources/dark/add_center_dimension.svg +++ b/bitmaps_png/sources/dark/add_center_dimension.svg @@ -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)"> - diff --git a/bitmaps_png/sources/dark/add_radial_dimension.svg b/bitmaps_png/sources/dark/add_radial_dimension.svg new file mode 100644 index 0000000000..9d6658e698 --- /dev/null +++ b/bitmaps_png/sources/dark/add_radial_dimension.svg @@ -0,0 +1,98 @@ + + + + + + + + + + image/svg+xml + + add_arc + + + + + + + + + + + + + + + add_center_dimension + + + + + diff --git a/bitmaps_png/sources/light/add_center_dimension.svg b/bitmaps_png/sources/light/add_center_dimension.svg index a6b8b3b2c1..672e3dd83e 100755 --- a/bitmaps_png/sources/light/add_center_dimension.svg +++ b/bitmaps_png/sources/light/add_center_dimension.svg @@ -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)"> - diff --git a/bitmaps_png/sources/light/add_radial_dimension.svg b/bitmaps_png/sources/light/add_radial_dimension.svg new file mode 100755 index 0000000000..75e33507b1 --- /dev/null +++ b/bitmaps_png/sources/light/add_radial_dimension.svg @@ -0,0 +1,98 @@ + + + + + + + + + + image/svg+xml + + add_arc + + + + + + + + + + + + + + + add_center_dimension + + + + + diff --git a/common/eda_item.cpp b/common/eda_item.cpp index 1968c3793a..34a5b28e3e 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -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" ) ) diff --git a/common/pcb.keywords b/common/pcb.keywords index 59c2c7ba0b..c1f95e4ba7 100644 --- a/common/pcb.keywords +++ b/common/pcb.keywords @@ -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 diff --git a/include/bitmaps/bitmap_info.h b/include/bitmaps/bitmap_info.h index 53f26cc465..8fdf15dcfb 100644 --- a/include/bitmaps/bitmap_info.h +++ b/include/bitmaps/bitmap_info.h @@ -169,6 +169,7 @@ const std::vector 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 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" ) }, diff --git a/include/bitmaps/bitmaps_list.h b/include/bitmaps/bitmaps_list.h index 3ac6bcc7ca..4c893dbfb4 100644 --- a/include/bitmaps/bitmaps_list.h +++ b/include/bitmaps/bitmaps_list.h @@ -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, diff --git a/include/core/typeinfo.h b/include/core/typeinfo.h index c95d59af4a..0d11b0241a 100644 --- a/include/core/typeinfo.h +++ b/include/core/typeinfo.h @@ -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; diff --git a/pcbnew/array_creator.cpp b/pcbnew/array_creator.cpp index 914b9a6696..d9481ccde7 100644 --- a/pcbnew/array_creator.cpp +++ b/pcbnew/array_creator.cpp @@ -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: diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 49bf06990e..a4079ff015 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -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: diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index a82aeff949..0141836869 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -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) diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 2728810292..456e7ba031 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -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( item ); diff --git a/pcbnew/dialogs/dialog_dimension_properties.cpp b/pcbnew/dialogs/dialog_dimension_properties.cpp index 43055fe6eb..a79ed27957 100644 --- a/pcbnew/dialogs/dialog_dimension_properties.cpp +++ b/pcbnew/dialogs/dialog_dimension_properties.cpp @@ -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( m_dimension ); - m_cbTextFrame->SetSelection( static_cast( leader->GetTextFrame() ) ); + m_cbTextFrame->SetSelection( static_cast( leader->GetTextBorder() ) ); } return DIALOG_DIMENSION_PROPERTIES_BASE::TransferDataToWindow(); @@ -303,22 +303,22 @@ void DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog( PCB_DIMENSION_BASE* switch( m_cbUnits->GetSelection() ) { - case 0: - aTarget->SetUnitsMode( DIM_UNITS_MODE::INCHES ); - break; + case 0: + aTarget->SetUnitsMode( DIM_UNITS_MODE::INCHES ); + break; - case 1: - aTarget->SetUnitsMode( DIM_UNITS_MODE::MILS ); - break; + case 1: + aTarget->SetUnitsMode( DIM_UNITS_MODE::MILS ); + break; - case 2: - aTarget->SetUnitsMode( DIM_UNITS_MODE::MILLIMETRES ); - break; + case 2: + aTarget->SetUnitsMode( DIM_UNITS_MODE::MILLIMETRES ); + break; - case 3: - aTarget->SetUnitsMode( DIM_UNITS_MODE::AUTOMATIC ); - aTarget->SetUnits( m_frame->GetUserUnits() ); - break; + case 3: + aTarget->SetUnitsMode( DIM_UNITS_MODE::AUTOMATIC ); + aTarget->SetUnits( m_frame->GetUserUnits() ); + break; } aTarget->SetUnitsFormat( static_cast( m_cbUnitsFormat->GetSelection() ) ); @@ -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( aTarget ); - leader->SetTextFrame( static_cast( m_cbTextFrame->GetSelection() ) ); + leader->SetTextBorder( static_cast( m_cbTextFrame->GetSelection())); } aTarget->Update(); diff --git a/pcbnew/drc/drc_test_provider_copper_clearance.cpp b/pcbnew/drc/drc_test_provider_copper_clearance.cpp index 2abc25894b..91e73e545d 100644 --- a/pcbnew/drc/drc_test_provider_copper_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_copper_clearance.cpp @@ -195,7 +195,7 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run() static const std::vector itemTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, PCB_PAD_T, PCB_SHAPE_T, PCB_FP_SHAPE_T, PCB_TEXT_T, PCB_FP_TEXT_T, PCB_DIMENSION_T, PCB_DIM_ALIGNED_T, PCB_DIM_LEADER_T, - PCB_DIM_CENTER_T, PCB_DIM_ORTHOGONAL_T + PCB_DIM_CENTER_T, PCB_DIM_RADIAL_T, PCB_DIM_ORTHOGONAL_T }; forEachGeometryItem( itemTypes, LSET::AllCuMask(), countItems ); diff --git a/pcbnew/drc/drc_test_provider_disallow.cpp b/pcbnew/drc/drc_test_provider_disallow.cpp index b84a0f609b..9437e5b9b4 100644 --- a/pcbnew/drc/drc_test_provider_disallow.cpp +++ b/pcbnew/drc/drc_test_provider_disallow.cpp @@ -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: { diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 5293f525dd..855fa3560a 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -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( aItem ) ); diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index fa9d0369c6..f52d2d1eed 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -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: diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index c1b69654c9..8e077f4366 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -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(); diff --git a/pcbnew/pcb_dimension.cpp b/pcbnew/pcb_dimension.cpp index b77385e071..dedf6241b5 100644 --- a/pcbnew/pcb_dimension.cpp +++ b/pcbnew/pcb_dimension.cpp @@ -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( aImage )->m_shapes.clear(); + std::swap( *static_cast( this ), *static_cast( 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::vectorType() == PCB_DIM_RADIAL_T ); + + m_shapes.clear(); + static_cast( aImage )->m_shapes.clear(); + + std::swap( *static_cast( this ), *static_cast( 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 ) { diff --git a/pcbnew/pcb_dimension.h b/pcbnew/pcb_dimension.h index f4ebafe91d..971e002d79 100644 --- a/pcbnew/pcb_dimension.h +++ b/pcbnew/pcb_dimension.h @@ -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,16 +472,72 @@ 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 - * _ - * |\ - * \ - * b---c TEXT + * a_ + * |\ + * \ + * b---c TEXT * * Point (a) is m_start, point (b) is m_end, point (c) is the end of the "text line" * The b-c line is drawn from b to the text center, and clipped on the text bounding box. @@ -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& aList ) override; @@ -516,7 +572,7 @@ protected: void updateGeometry() override; private: - DIM_TEXT_FRAME m_textFrame; + DIM_TEXT_BORDER m_textBorder; }; diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 835fa4f9c2..e3f4fad9be 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -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 ); diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 5b33ebebae..fb69bcf4cb 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -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( item ), aLayer ); diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index fcc7b47766..183f92b297 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -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 ); diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index 38e86bb3ed..32d1e9b992 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -2847,6 +2847,10 @@ PCB_DIMENSION_BASE* PCB_PARSER::parseDIMENSION() dimension = std::make_unique( nullptr ); break; + case T_radial: + dimension = std::make_unique( 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( 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( textFrame ) ); + leader->SetTextBorder( static_cast( textFrame )); NeedRIGHT(); break; } diff --git a/pcbnew/plugins/kicad/pcb_plugin.cpp b/pcbnew/plugins/kicad/pcb_plugin.cpp index 08a01f16cc..3de9d9c079 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.cpp +++ b/pcbnew/plugins/kicad/pcb_plugin.cpp @@ -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( aItem ), aNestLevel ); @@ -709,6 +710,7 @@ void PCB_PLUGIN::format( const PCB_DIMENSION_BASE* aDimension, int aNestLevel ) const PCB_DIM_ALIGNED* aligned = dynamic_cast( aDimension ); const PCB_DIM_ORTHOGONAL* ortho = dynamic_cast( aDimension ); const PCB_DIM_CENTER* center = dynamic_cast( aDimension ); + const PCB_DIM_RADIAL* radial = dynamic_cast( aDimension ); const PCB_DIM_LEADER* leader = dynamic_cast( 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( leader->GetTextFrame() ) ); + m_out->Print( 0, " (text_frame %d)", static_cast( leader->GetTextBorder() ) ); m_out->Print( 0, " (extension_offset %s)", FormatInternalUnits( aDimension->GetExtensionOffset() ).c_str() ); diff --git a/pcbnew/plugins/kicad/pcb_plugin.h b/pcbnew/plugins/kicad/pcb_plugin.h index 2dd5bcd416..6bc636d5aa 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.h +++ b/pcbnew/plugins/kicad/pcb_plugin.h @@ -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 diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 17ffbe9502..e752258f09 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -409,6 +409,7 @@ void PCB_EDIT_FRAME::ReCreateVToolbar() { &PCB_ACTIONS::drawAlignedDimension, &PCB_ACTIONS::drawOrthogonalDimension, &PCB_ACTIONS::drawCenterDimension, + &PCB_ACTIONS::drawRadialDimension, &PCB_ACTIONS::drawLeader } ); } diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index bf42523ec0..dd7f183007 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -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,34 +954,23 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) { break; } - } case SET_HEIGHT: + assert( dimension->GetStart() != dimension->GetEnd() ); + assert( dimension->GetLineThickness() > 0 ); + + preview.Remove( dimension ); + + commit.Add( dimension ); + commit.Push( _( "Draw a dimension" ) ); + 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 ); - preview.Remove( dimension ); - - commit.Add( dimension ); - commit.Push( _( "Draw a dimension" ) ); - - m_toolMgr->RunAction( PCB_ACTIONS::selectItem, 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( 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( dimension ); + wxPoint textOffset( radialDim->GetArrowLength() * 10, 0 ); - dimension->Update(); + if( radialDim->GetEnd().x < radialDim->GetStart().x ) + textOffset = -textOffset; - if( Is45Limited() || dimension->Type() == PCB_DIM_CENTER_T ) - constrainDimension( dimension ); + 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(); + } break; case SET_HEIGHT: - { if( dimension->Type() == PCB_DIM_ALIGNED_T ) { PCB_DIM_ALIGNED* aligned = static_cast( dimension ); @@ -1038,36 +1046,27 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) { PCB_DIM_ORTHOGONAL* ortho = static_cast( dimension ); - BOX2I bounds( dimension->GetStart(), - dimension->GetEnd() - dimension->GetStart() ); - VECTOR2I direction( cursorPos - bounds.Centre() ); + BOX2I bbox( dimension->GetStart(), + dimension->GetEnd() - dimension->GetStart() ); + 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,16 +1079,8 @@ 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; + + break; } // Show a preview of the item @@ -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() ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index f951885c07..9f6d5eaf74 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -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(); diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index b3dbdea882..4639df01d2 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -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" ), diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index e77bb80c1e..ca40498076 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -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; diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index 18c77ae571..878c1a6105 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -997,6 +997,7 @@ int PCB_CONTROL::placeBoardItems( std::vector& 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: { diff --git a/pcbnew/tools/pcb_grid_helper.cpp b/pcbnew/tools/pcb_grid_helper.cpp index dd4472b83a..ebcb6128fa 100644 --- a/pcbnew/tools/pcb_grid_helper.cpp +++ b/pcbnew/tools/pcb_grid_helper.cpp @@ -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( 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( aItem ); diff --git a/pcbnew/tools/pcb_point_editor.cpp b/pcbnew/tools/pcb_point_editor.cpp index 6907e91c35..ae4a923372 100644 --- a/pcbnew/tools/pcb_point_editor.cpp +++ b/pcbnew/tools/pcb_point_editor.cpp @@ -95,6 +95,7 @@ enum DIMENSION_POINTS DIM_TEXT, DIM_CROSSBARSTART, DIM_CROSSBAREND, + DIM_KNEE = DIM_CROSSBARSTART }; @@ -334,6 +335,25 @@ std::shared_ptr PCB_POINT_EDITOR::makePoints( EDA_ITEM* aItem ) break; } + case PCB_DIM_RADIAL_T: + { + const PCB_DIM_RADIAL* dimension = static_cast( 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( aItem ); @@ -344,6 +364,7 @@ std::shared_ptr 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( 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( item ); @@ -1731,6 +1800,17 @@ void PCB_POINT_EDITOR::updatePoints() break; } + case PCB_DIM_RADIAL_T: + { + const PCB_DIM_RADIAL* dimension = static_cast( 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( 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; } diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index c85b118f61..adb00c0ff9 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -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 )