diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index a40a450494..15ffe9b5fa 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -629,6 +629,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) break; case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: AddShapeWithClearanceToContainer( (DIMENSION*) item, layerContainer, @@ -913,6 +915,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) break; case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: AddShapeWithClearanceToContainer( (DIMENSION*) item, layerContainer, diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt index 75a3dec183..07484f3022 100644 --- a/bitmaps_png/CMakeLists.txt +++ b/bitmaps_png/CMakeLists.txt @@ -116,6 +116,7 @@ set( BMAPS_MID add_board add_bus2bus add_bus + add_center_dimension add_circle add_component add_corner diff --git a/bitmaps_png/cpp_26/add_center_dimension.cpp b/bitmaps_png/cpp_26/add_center_dimension.cpp new file mode 100644 index 0000000000..87f1cdd87f --- /dev/null +++ b/bitmaps_png/cpp_26/add_center_dimension.cpp @@ -0,0 +1,29 @@ + +/* Do not modify this file, it was automatically generated by the + * PNG2cpp CMake script, using a *.png file as input. + */ + +#include + +static const unsigned char png[] = { + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1a, 0x08, 0x06, 0x00, 0x00, 0x00, 0xa9, 0x4a, 0x4c, + 0xce, 0x00, 0x00, 0x00, 0xbd, 0x49, 0x44, 0x41, 0x54, 0x48, 0xc7, 0x63, 0x60, 0x18, 0xac, 0x40, + 0x53, 0x53, 0x53, 0x12, 0x84, 0x69, 0x6e, 0x91, 0x86, 0x86, 0xc6, 0x0e, 0x10, 0xa6, 0x87, 0x45, + 0x07, 0x41, 0x78, 0xd4, 0xa2, 0x51, 0x8b, 0x86, 0x91, 0x45, 0xb9, 0xb9, 0xb9, 0xec, 0x29, 0xd9, + 0xa9, 0x93, 0x12, 0xd3, 0x93, 0x7e, 0x83, 0x70, 0x72, 0x4e, 0xea, 0x04, 0x90, 0x18, 0x2e, 0x75, + 0x29, 0x59, 0x29, 0x1f, 0x40, 0x18, 0x97, 0x3a, 0x9c, 0x00, 0xa4, 0x39, 0xac, 0x2e, 0xea, 0x9b, + 0xe1, 0x0e, 0xc7, 0xff, 0x06, 0x3b, 0x1c, 0xfe, 0x87, 0xd5, 0xc5, 0x7c, 0x05, 0x19, 0x42, 0xb2, + 0x3a, 0x75, 0x75, 0xf5, 0x7c, 0x60, 0x90, 0xec, 0xc6, 0x85, 0x41, 0xbe, 0x00, 0x69, 0xd4, 0x3a, + 0x64, 0x03, 0xc6, 0x20, 0x83, 0x12, 0x33, 0x92, 0x7e, 0x13, 0xa3, 0x2e, 0x25, 0x3b, 0xe5, 0x3d, + 0xfd, 0x2d, 0x22, 0x04, 0x40, 0xde, 0x0f, 0xaf, 0x8d, 0xfe, 0x06, 0x32, 0x04, 0xa4, 0x39, 0xac, + 0x16, 0x18, 0x24, 0x59, 0xa9, 0x7d, 0xe4, 0xaa, 0xc3, 0x9b, 0x18, 0x40, 0x86, 0x24, 0x01, 0x7d, + 0x01, 0xc2, 0x20, 0xcd, 0xa1, 0xa1, 0xa1, 0x6c, 0xb8, 0xd4, 0x81, 0x7c, 0x01, 0xc2, 0xb8, 0xd4, + 0x8d, 0x66, 0xd8, 0x51, 0x8b, 0x46, 0xb8, 0x45, 0xf4, 0x69, 0x9c, 0xd0, 0xad, 0xb9, 0x45, 0x2e, + 0x00, 0x00, 0x24, 0x51, 0xd2, 0xad, 0xa0, 0x23, 0x80, 0x52, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, + 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, +}; + +const BITMAP_OPAQUE add_center_dimension_xpm[1] = {{ png, sizeof( png ), "add_center_dimension_xpm" }}; + +//EOF diff --git a/bitmaps_png/include/bitmaps_png/bitmaps_list.h b/bitmaps_png/include/bitmaps_png/bitmaps_list.h index fb9e37d6b2..9487bb1cae 100644 --- a/bitmaps_png/include/bitmaps_png/bitmaps_list.h +++ b/bitmaps_png/include/bitmaps_png/bitmaps_list.h @@ -34,6 +34,7 @@ EXTERN_BITMAP( add_arc_xpm ) EXTERN_BITMAP( add_board_xpm ) EXTERN_BITMAP( add_bus2bus_xpm ) EXTERN_BITMAP( add_bus_xpm ) +EXTERN_BITMAP( add_center_dimension_xpm ) EXTERN_BITMAP( add_circle_xpm ) EXTERN_BITMAP( add_component_xpm ) EXTERN_BITMAP( add_corner_xpm ) diff --git a/bitmaps_png/sources/add_center_dimension.svg b/bitmaps_png/sources/add_center_dimension.svg new file mode 100644 index 0000000000..84e59ba575 --- /dev/null +++ b/bitmaps_png/sources/add_center_dimension.svg @@ -0,0 +1,266 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/core/typeinfo.h b/include/core/typeinfo.h index 9bbcab3a29..2b9ba1900c 100644 --- a/include/core/typeinfo.h +++ b/include/core/typeinfo.h @@ -100,6 +100,8 @@ enum KICAD_T PCB_DIMENSION_T, ///< class DIMENSION: abstract dimension meta-type PCB_DIM_ALIGNED_T, ///< class ALIGNED_DIMENSION, a linear dimension (graphic item) PCB_DIM_LEADER_T, ///< class LEADER, a leader dimension (graphic item) + PCB_DIM_CENTER_T, ///< class CENTER_DIMENSION, a center point marking (graphic item) + PCB_DIM_ORTHOGONAL_T, ///< class ORTHOGONAL_DIMENSION, a linear dimension constrained to x/y PCB_TARGET_T, ///< class PCB_TARGET, a target (graphic item) PCB_ZONE_AREA_T, ///< class ZONE_CONTAINER, a zone area PCB_ITEM_LIST_T, ///< class BOARD_ITEM_LIST, a list of board items @@ -256,6 +258,8 @@ constexpr KICAD_T BaseType( const KICAD_T aType ) return PCB_LOCATE_HOLE_T; case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_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 a2aef5ed64..9e97337fed 100644 --- a/pcbnew/array_creator.cpp +++ b/pcbnew/array_creator.cpp @@ -114,6 +114,8 @@ void ARRAY_CREATOR::Invoke() case PCB_ZONE_AREA_T: case PCB_TARGET_T: case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: new_item = item->Duplicate(); break; diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index 6f7d8c96b1..cf778afb7d 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -218,6 +218,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a case PCB_ARC_T: // an arced track segment (segment on a copper layer) 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_ORTHOGONAL_T: case PCB_DIM_LEADER_T: // a leader dimension case PCB_TARGET_T: // a target (graphic item) case PCB_MARKER_T: // a marker used to show something diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 4aae500a3a..7eec8b4f80 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -581,6 +581,8 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode ) break; case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: case PCB_LINE_T: case PCB_TEXT_T: @@ -669,6 +671,8 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem ) break; case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: case PCB_LINE_T: case PCB_TEXT_T: @@ -1007,6 +1011,8 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T s case PCB_LINE_T: case PCB_TEXT_T: case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: case PCB_TARGET_T: result = IterateForward( m_drawings, inspector, testData, p ); @@ -1019,6 +1025,8 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR inspector, void* testData, const KICAD_T s case PCB_LINE_T: case PCB_TEXT_T: case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: case PCB_TARGET_T: continue; diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 0cdd21eb8e..2e9e2d4b86 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -336,6 +336,7 @@ bool DIMENSION::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) arect.Inflate( aAccuracy ); EDA_RECT rect = GetBoundingBox(); + if( aAccuracy ) rect.Inflate( aAccuracy ); @@ -360,6 +361,8 @@ const EDA_RECT DIMENSION::GetBoundingBox() const for( const std::shared_ptr& shape : GetShapes() ) { BOX2I shapeBox = shape->BBox(); + shapeBox.Inflate( m_lineThickness / 2 ); + xmin = std::min( xmin, shapeBox.GetOrigin().x ); xmax = std::max( xmax, shapeBox.GetEnd().x ); ymin = std::min( ymin, shapeBox.GetOrigin().y ); @@ -716,3 +719,70 @@ void LEADER::updateGeometry() if( endpoint ) m_shapes.emplace_back( new SHAPE_SEGMENT( m_end, *endpoint ) ); } + + +CENTER_DIMENSION::CENTER_DIMENSION( BOARD_ITEM* aParent ) : + DIMENSION( aParent, PCB_DIM_CENTER_T ) +{ + m_unitsFormat = DIM_UNITS_FORMAT::NO_SUFFIX; + m_overrideTextEnabled = true; +} + + +EDA_ITEM* CENTER_DIMENSION::Clone() const +{ + return new CENTER_DIMENSION( *this ); +} + + +void CENTER_DIMENSION::SwapData( BOARD_ITEM* aImage ) +{ + assert( aImage->Type() == PCB_DIM_CENTER_T ); + + std::swap( *static_cast( this ), *static_cast( aImage ) ); +} + + +BITMAP_DEF CENTER_DIMENSION::GetMenuImage() const +{ + return add_center_dimension_xpm; +} + + +const EDA_RECT CENTER_DIMENSION::GetBoundingBox() const +{ + int halfWidth = VECTOR2I( m_end - m_start ).x + ( m_lineThickness / 2.0 ); + + EDA_RECT bBox; + + bBox.SetX( m_start.x - halfWidth ); + bBox.SetY( m_start.y - halfWidth ); + bBox.SetWidth( halfWidth * 2 ); + bBox.SetHeight( halfWidth * 2 ); + + bBox.Normalize(); + + return bBox; +} + + +const BOX2I CENTER_DIMENSION::ViewBBox() const +{ + return BOX2I( VECTOR2I( GetBoundingBox().GetPosition() ), + VECTOR2I( GetBoundingBox().GetSize() ) ); +} + + +void CENTER_DIMENSION::updateGeometry() +{ + m_shapes.clear(); + + VECTOR2I center( m_start ); + VECTOR2I arm( m_end - m_start ); + + m_shapes.emplace_back( new SHAPE_SEGMENT( center - arm, center + arm ) ); + + arm = arm.Rotate( DEG2RAD( 90 ) ); + + m_shapes.emplace_back( new SHAPE_SEGMENT( center - arm, center + arm ) ); +} diff --git a/pcbnew/class_dimension.h b/pcbnew/class_dimension.h index 699897afbb..aa94649086 100644 --- a/pcbnew/class_dimension.h +++ b/pcbnew/class_dimension.h @@ -249,7 +249,7 @@ public: wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; - virtual const BOX2I ViewBBox() const override; + const BOX2I ViewBBox() const override; #if defined(DEBUG) virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } @@ -455,4 +455,41 @@ protected: void updateGeometry() override; }; + +/** + * Marks the center of a circle or arc with a cross shape + * The size and orientation of the cross is adjustable. + * m_start always marks the center being measured; m_end marks the end of one leg of the cross. + */ +class CENTER_DIMENSION : public DIMENSION +{ + +public: + CENTER_DIMENSION( BOARD_ITEM* aParent ); + + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && PCB_DIM_CENTER_T == aItem->Type(); + } + + EDA_ITEM* Clone() const override; + + virtual void SwapData( BOARD_ITEM* aImage ) override; + + BITMAP_DEF GetMenuImage() const override; + + wxString GetClass() const override + { + return wxT( "CENTER_DIMENSION" ); + } + + const EDA_RECT GetBoundingBox() const override; + + const BOX2I ViewBBox() const override; + +protected: + + void updateGeometry() override; +}; + #endif // DIMENSION_H_ diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index c1cc429818..dd5de65f60 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -50,6 +50,8 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = { PCB_TEXT_T, // in m_drawings PCB_LINE_T, // in m_drawings PCB_DIM_ALIGNED_T, // in m_drawings + PCB_DIM_CENTER_T, // in m_drawings + PCB_DIM_ORTHOGONAL_T, // in m_drawings PCB_DIM_LEADER_T, // in m_drawings PCB_TARGET_T, // in m_drawings PCB_VIA_T, // in m_tracks @@ -311,6 +313,8 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData ) break; case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: break; diff --git a/pcbnew/dialogs/dialog_dimension_properties.cpp b/pcbnew/dialogs/dialog_dimension_properties.cpp index 96e4d2d165..0da4f115d5 100644 --- a/pcbnew/dialogs/dialog_dimension_properties.cpp +++ b/pcbnew/dialogs/dialog_dimension_properties.cpp @@ -57,6 +57,7 @@ DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES( PCB_BASE_EDIT_FRAME* a case PCB_DIM_LEADER_T: // Hide the main format controls and keep the leader controls shown m_sizerFormat->GetStaticBox()->Hide(); + m_sizerCenter->GetStaticBox()->Hide(); m_cbLayerActual = m_cbLeaderLayer; m_txtValueActual = m_txtLeaderValue; @@ -66,8 +67,25 @@ DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES( PCB_BASE_EDIT_FRAME* a m_cbTextPositionMode->Hide(); break; + case PCB_DIM_CENTER_T: + m_sizerLeader->GetStaticBox()->Hide(); + m_sizerFormat->GetStaticBox()->Hide(); + m_sizerText->GetStaticBox()->Hide(); + + m_lblArrowLength->Hide(); + m_txtArrowLength->Hide(); + m_lblArrowLengthUnits->Hide(); + + m_lblExtensionOffset->Hide(); + m_txtExtensionOffset->Hide(); + m_lblExtensionOffsetUnits->Hide(); + + m_cbLayerActual = m_cbCenterLayer; + break; + default: m_sizerLeader->GetStaticBox()->Hide(); + m_sizerCenter->GetStaticBox()->Hide(); break; } diff --git a/pcbnew/dialogs/dialog_dimension_properties_base.cpp b/pcbnew/dialogs/dialog_dimension_properties_base.cpp index 0961313fd1..32d6313d71 100644 --- a/pcbnew/dialogs/dialog_dimension_properties_base.cpp +++ b/pcbnew/dialogs/dialog_dimension_properties_base.cpp @@ -61,6 +61,26 @@ DIALOG_DIMENSION_PROPERTIES_BASE::DIALOG_DIMENSION_PROPERTIES_BASE( wxWindow* pa m_mainSizer->Add( m_sizerLeader, 0, wxALL|wxEXPAND, 5 ); + m_sizerCenter = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Dimension Format") ), wxVERTICAL ); + + wxGridBagSizer* gbSizerCenter; + gbSizerCenter = new wxGridBagSizer( 0, 0 ); + gbSizerCenter->SetFlexibleDirection( wxBOTH ); + gbSizerCenter->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_lblCenterLayer = new wxStaticText( m_sizerCenter->GetStaticBox(), wxID_ANY, _("Layer:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblCenterLayer->Wrap( -1 ); + gbSizerCenter->Add( m_lblCenterLayer, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + m_cbCenterLayer = new PCB_LAYER_BOX_SELECTOR( m_sizerCenter->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); + gbSizerCenter->Add( m_cbCenterLayer, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); + + + m_sizerCenter->Add( gbSizerCenter, 1, wxBOTTOM|wxEXPAND, 5 ); + + + m_mainSizer->Add( m_sizerCenter, 1, wxALL|wxEXPAND, 5 ); + m_sizerFormat = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Dimension Format") ), wxVERTICAL ); wxGridBagSizer* gbSizerFormat; @@ -184,125 +204,124 @@ DIALOG_DIMENSION_PROPERTIES_BASE::DIALOG_DIMENSION_PROPERTIES_BASE( wxWindow* pa m_mainSizer->Add( m_sizerFormat, 1, wxALL|wxEXPAND, 5 ); - wxStaticBoxSizer* sbSizerText; - sbSizerText = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Dimension Text") ), wxVERTICAL ); + m_sizerText = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Dimension Text") ), wxVERTICAL ); wxGridBagSizer* gbSizerText; gbSizerText = new wxGridBagSizer( 0, 0 ); gbSizerText->SetFlexibleDirection( wxHORIZONTAL ); gbSizerText->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_lblTextWidth = new wxStaticText( sbSizerText->GetStaticBox(), wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblTextWidth = new wxStaticText( m_sizerText->GetStaticBox(), wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblTextWidth->Wrap( -1 ); m_lblTextWidth->SetToolTip( _("Text width") ); gbSizerText->Add( m_lblTextWidth, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_txtTextWidth = new wxTextCtrl( sbSizerText->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); + m_txtTextWidth = new wxTextCtrl( m_sizerText->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); gbSizerText->Add( m_txtTextWidth, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - m_lblTextWidthUnits = new wxStaticText( sbSizerText->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblTextWidthUnits = new wxStaticText( m_sizerText->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblTextWidthUnits->Wrap( -1 ); gbSizerText->Add( m_lblTextWidthUnits, wxGBPosition( 0, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); gbSizerText->Add( 20, 0, wxGBPosition( 0, 3 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); - m_lblTextPosX = new wxStaticText( sbSizerText->GetStaticBox(), wxID_ANY, _("Position X:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblTextPosX = new wxStaticText( m_sizerText->GetStaticBox(), wxID_ANY, _("Position X:"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblTextPosX->Wrap( -1 ); m_lblTextPosX->SetToolTip( _("Text pos X") ); gbSizerText->Add( m_lblTextPosX, wxGBPosition( 0, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_txtTextPosX = new wxTextCtrl( sbSizerText->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); + m_txtTextPosX = new wxTextCtrl( m_sizerText->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); gbSizerText->Add( m_txtTextPosX, wxGBPosition( 0, 5 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - m_lblTextPosXUnits = new wxStaticText( sbSizerText->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblTextPosXUnits = new wxStaticText( m_sizerText->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblTextPosXUnits->Wrap( -1 ); gbSizerText->Add( m_lblTextPosXUnits, wxGBPosition( 0, 6 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5 ); - m_lblTextHeight = new wxStaticText( sbSizerText->GetStaticBox(), wxID_ANY, _("Height:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblTextHeight = new wxStaticText( m_sizerText->GetStaticBox(), wxID_ANY, _("Height:"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblTextHeight->Wrap( -1 ); m_lblTextHeight->SetToolTip( _("Text height") ); gbSizerText->Add( m_lblTextHeight, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_txtTextHeight = new wxTextCtrl( sbSizerText->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); + m_txtTextHeight = new wxTextCtrl( m_sizerText->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); gbSizerText->Add( m_txtTextHeight, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - m_lblTextHeightUnits = new wxStaticText( sbSizerText->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblTextHeightUnits = new wxStaticText( m_sizerText->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblTextHeightUnits->Wrap( -1 ); gbSizerText->Add( m_lblTextHeightUnits, wxGBPosition( 1, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_lblTextPosY = new wxStaticText( sbSizerText->GetStaticBox(), wxID_ANY, _("Position Y:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblTextPosY = new wxStaticText( m_sizerText->GetStaticBox(), wxID_ANY, _("Position Y:"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblTextPosY->Wrap( -1 ); m_lblTextPosY->SetToolTip( _("Text pos Y") ); gbSizerText->Add( m_lblTextPosY, wxGBPosition( 1, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_txtTextPosY = new wxTextCtrl( sbSizerText->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); + m_txtTextPosY = new wxTextCtrl( m_sizerText->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); gbSizerText->Add( m_txtTextPosY, wxGBPosition( 1, 5 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - m_lblTextPosYUnits = new wxStaticText( sbSizerText->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblTextPosYUnits = new wxStaticText( m_sizerText->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblTextPosYUnits->Wrap( -1 ); gbSizerText->Add( m_lblTextPosYUnits, wxGBPosition( 1, 6 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5 ); - m_lblTextThickness = new wxStaticText( sbSizerText->GetStaticBox(), wxID_ANY, _("Thickness:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblTextThickness = new wxStaticText( m_sizerText->GetStaticBox(), wxID_ANY, _("Thickness:"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblTextThickness->Wrap( -1 ); m_lblTextThickness->SetToolTip( _("Text thickness") ); gbSizerText->Add( m_lblTextThickness, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_txtTextThickness = new wxTextCtrl( sbSizerText->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); + m_txtTextThickness = new wxTextCtrl( m_sizerText->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); gbSizerText->Add( m_txtTextThickness, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - m_lblTextThicknessUnits = new wxStaticText( sbSizerText->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblTextThicknessUnits = new wxStaticText( m_sizerText->GetStaticBox(), wxID_ANY, _("unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblTextThicknessUnits->Wrap( -1 ); gbSizerText->Add( m_lblTextThicknessUnits, wxGBPosition( 2, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_lblTextOrientation = new wxStaticText( sbSizerText->GetStaticBox(), wxID_ANY, _("Orientation:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblTextOrientation = new wxStaticText( m_sizerText->GetStaticBox(), wxID_ANY, _("Orientation:"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblTextOrientation->Wrap( -1 ); m_lblTextOrientation->SetToolTip( _("Text orientation") ); gbSizerText->Add( m_lblTextOrientation, wxGBPosition( 3, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_cbTextOrientation = new wxComboBox( sbSizerText->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); + m_cbTextOrientation = new wxComboBox( m_sizerText->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); m_cbTextOrientation->Append( _("0.0") ); m_cbTextOrientation->Append( _("90.0") ); m_cbTextOrientation->Append( _("-90.0") ); m_cbTextOrientation->Append( _("180.0") ); gbSizerText->Add( m_cbTextOrientation, wxGBPosition( 3, 5 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - m_cbItalic = new wxCheckBox( sbSizerText->GetStaticBox(), wxID_ANY, _("Italic"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbItalic = new wxCheckBox( m_sizerText->GetStaticBox(), wxID_ANY, _("Italic"), wxDefaultPosition, wxDefaultSize, 0 ); gbSizerText->Add( m_cbItalic, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_cbKeepAligned = new wxCheckBox( sbSizerText->GetStaticBox(), wxID_ANY, _("Keep aligned with dimension"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbKeepAligned = new wxCheckBox( m_sizerText->GetStaticBox(), wxID_ANY, _("Keep aligned with dimension"), wxDefaultPosition, wxDefaultSize, 0 ); m_cbKeepAligned->SetToolTip( _("Automatically set the text orientation to match the dimension lines") ); gbSizerText->Add( m_cbKeepAligned, wxGBPosition( 4, 4 ), wxGBSpan( 1, 3 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_cbMirrored = new wxCheckBox( sbSizerText->GetStaticBox(), wxID_ANY, _("Mirrored"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbMirrored = new wxCheckBox( m_sizerText->GetStaticBox(), wxID_ANY, _("Mirrored"), wxDefaultPosition, wxDefaultSize, 0 ); m_cbMirrored->SetToolTip( _("Mirror text") ); gbSizerText->Add( m_cbMirrored, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - m_lblJustification = new wxStaticText( sbSizerText->GetStaticBox(), wxID_ANY, _("Justification:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblJustification = new wxStaticText( m_sizerText->GetStaticBox(), wxID_ANY, _("Justification:"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblJustification->Wrap( -1 ); gbSizerText->Add( m_lblJustification, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); wxString m_cbJustificationChoices[] = { _("Left"), _("Center"), _("Right") }; int m_cbJustificationNChoices = sizeof( m_cbJustificationChoices ) / sizeof( wxString ); - m_cbJustification = new wxChoice( sbSizerText->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_cbJustificationNChoices, m_cbJustificationChoices, 0 ); + m_cbJustification = new wxChoice( m_sizerText->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_cbJustificationNChoices, m_cbJustificationChoices, 0 ); m_cbJustification->SetSelection( 0 ); gbSizerText->Add( m_cbJustification, wxGBPosition( 5, 1 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - m_lblTextPositionMode = new wxStaticText( sbSizerText->GetStaticBox(), wxID_ANY, _("Position mode:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_lblTextPositionMode = new wxStaticText( m_sizerText->GetStaticBox(), wxID_ANY, _("Position mode:"), wxDefaultPosition, wxDefaultSize, 0 ); m_lblTextPositionMode->Wrap( -1 ); gbSizerText->Add( m_lblTextPositionMode, wxGBPosition( 2, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALL, 5 ); wxString m_cbTextPositionModeChoices[] = { _("Outside"), _("Inline"), _("Manual") }; int m_cbTextPositionModeNChoices = sizeof( m_cbTextPositionModeChoices ) / sizeof( wxString ); - m_cbTextPositionMode = new wxChoice( sbSizerText->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_cbTextPositionModeNChoices, m_cbTextPositionModeChoices, 0 ); + m_cbTextPositionMode = new wxChoice( m_sizerText->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_cbTextPositionModeNChoices, m_cbTextPositionModeChoices, 0 ); m_cbTextPositionMode->SetSelection( 0 ); m_cbTextPositionMode->SetToolTip( _("Choose how to position the text relative to the dimension line") ); @@ -313,10 +332,10 @@ DIALOG_DIMENSION_PROPERTIES_BASE::DIALOG_DIMENSION_PROPERTIES_BASE( wxWindow* pa gbSizerText->AddGrowableCol( 3 ); gbSizerText->AddGrowableCol( 5 ); - sbSizerText->Add( gbSizerText, 0, wxBOTTOM|wxEXPAND, 5 ); + m_sizerText->Add( gbSizerText, 0, wxBOTTOM|wxEXPAND, 5 ); - m_mainSizer->Add( sbSizerText, 0, wxALL|wxEXPAND, 5 ); + m_mainSizer->Add( m_sizerText, 0, wxALL|wxEXPAND, 5 ); wxStaticBoxSizer* sbSizerLine; sbSizerLine = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Dimension Line") ), wxVERTICAL ); diff --git a/pcbnew/dialogs/dialog_dimension_properties_base.fbp b/pcbnew/dialogs/dialog_dimension_properties_base.fbp index 5426e8d7c8..cde8d1b5c8 100644 --- a/pcbnew/dialogs/dialog_dimension_properties_base.fbp +++ b/pcbnew/dialogs/dialog_dimension_properties_base.fbp @@ -45,7 +45,7 @@ -1,-1 DIALOG_DIMENSION_PROPERTIES_BASE - 654,600 + 654,500 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSYSTEM_MENU DIALOG_SHIM; dialog_shim.h Dimension Properties @@ -497,6 +497,169 @@ + + 5 + wxALL|wxEXPAND + 1 + + wxID_ANY + Dimension Format + + m_sizerCenter + wxVERTICAL + 1 + protected + + 5 + wxBOTTOM|wxEXPAND + 1 + + + wxBOTH + + + 0 + + gbSizerCenter + wxFLEX_GROWMODE_SPECIFIED + none + 0 + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Layer: + 0 + + 0 + + + 0 + + 1 + m_lblCenterLayer + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxALL|wxEXPAND + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_cbCenterLayer + 1 + + + protected + 1 + + Resizable + -1 + 1 + + + PCB_LAYER_BOX_SELECTOR; pcb_layer_box_selector.h + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + 5 wxALL|wxEXPAND @@ -1730,10 +1893,10 @@ wxID_ANY Dimension Text - sbSizerText + m_sizerText wxVERTICAL 1 - none + protected 5 wxBOTTOM|wxEXPAND diff --git a/pcbnew/dialogs/dialog_dimension_properties_base.h b/pcbnew/dialogs/dialog_dimension_properties_base.h index 1a88d2dc67..dc96128005 100644 --- a/pcbnew/dialogs/dialog_dimension_properties_base.h +++ b/pcbnew/dialogs/dialog_dimension_properties_base.h @@ -50,6 +50,9 @@ class DIALOG_DIMENSION_PROPERTIES_BASE : public DIALOG_SHIM wxChoice* m_cbTextFrame; wxStaticText* m_lblLeaderLayer; PCB_LAYER_BOX_SELECTOR* m_cbLeaderLayer; + wxStaticBoxSizer* m_sizerCenter; + wxStaticText* m_lblCenterLayer; + PCB_LAYER_BOX_SELECTOR* m_cbCenterLayer; wxStaticBoxSizer* m_sizerFormat; wxStaticText* m_lblValue; wxTextCtrl* m_txtValue; @@ -69,6 +72,7 @@ class DIALOG_DIMENSION_PROPERTIES_BASE : public DIALOG_SHIM PCB_LAYER_BOX_SELECTOR* m_cbLayer; wxStaticText* m_lblPreview; wxStaticText* m_staticTextPreview; + wxStaticBoxSizer* m_sizerText; wxStaticText* m_lblTextWidth; wxTextCtrl* m_txtTextWidth; wxStaticText* m_lblTextWidthUnits; @@ -115,7 +119,7 @@ class DIALOG_DIMENSION_PROPERTIES_BASE : public DIALOG_SHIM public: - DIALOG_DIMENSION_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Dimension Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 654,600 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSYSTEM_MENU ); + DIALOG_DIMENSION_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Dimension Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 654,500 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSYSTEM_MENU ); ~DIALOG_DIMENSION_PROPERTIES_BASE(); }; diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index c913a9c72d..cb43d447a8 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -143,6 +143,8 @@ void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem ) break; case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: ShowDimensionPropertyDialog( static_cast( aItem ) ); break; diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index 55ef154467..58cd4a6163 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -203,6 +203,8 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ break; case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: case PCB_TARGET_T: case PCB_MARKER_T: // do not draw diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index b6ae0412bf..87b05f3bf7 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -399,6 +399,8 @@ void PCB_IO::Format( BOARD_ITEM* aItem, int aNestLevel ) const break; case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: format( static_cast( aItem ), aNestLevel ); break; @@ -663,6 +665,7 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const void PCB_IO::format( DIMENSION* aDimension, int aNestLevel ) const { ALIGNED_DIMENSION* aligned = dynamic_cast( aDimension ); + CENTER_DIMENSION* center = dynamic_cast( aDimension ); LEADER* leader = dynamic_cast( aDimension ); m_out->Print( aNestLevel, "(dimension" ); @@ -671,6 +674,8 @@ void PCB_IO::format( DIMENSION* aDimension, int aNestLevel ) const m_out->Print( 0, " (type aligned)" ); else if( aDimension->Type() == PCB_DIM_LEADER_T ) m_out->Print( 0, " (type leader)" ); + else if( aDimension->Type() == PCB_DIM_CENTER_T ) + m_out->Print( 0, " (type center)" ); else wxFAIL_MSG( wxT( "Cannot format unknown dimension type!" ) ); @@ -690,27 +695,30 @@ void PCB_IO::format( DIMENSION* aDimension, int aNestLevel ) const m_out->Print( aNestLevel+1, "(height %s)\n", FormatInternalUnits( aligned->GetHeight() ).c_str() ); - Format( &aDimension->Text(), aNestLevel+1 ); + if( !center ) + { + Format( &aDimension->Text(), aNestLevel + 1 ); - m_out->Print( aNestLevel+1, "(format" ); + m_out->Print( aNestLevel + 1, "(format" ); - if( !aDimension->GetPrefix().IsEmpty() ) - m_out->Print( 0, " (prefix \"%s\")", TO_UTF8( aDimension->GetPrefix() ) ); + if( !aDimension->GetPrefix().IsEmpty() ) + m_out->Print( 0, " (prefix \"%s\")", TO_UTF8( aDimension->GetPrefix() ) ); - if( !aDimension->GetSuffix().IsEmpty() ) - m_out->Print( 0, " (suffix \"%s\")", TO_UTF8( aDimension->GetSuffix() ) ); + if( !aDimension->GetSuffix().IsEmpty() ) + m_out->Print( 0, " (suffix \"%s\")", TO_UTF8( aDimension->GetSuffix() ) ); - m_out->Print( 0, " (units %d) (units_format %d) (precision %d)", - static_cast( aDimension->GetUnitsMode() ), - static_cast( aDimension->GetUnitsFormat() ), aDimension->GetPrecision() ); + m_out->Print( 0, " (units %d) (units_format %d) (precision %d)", + static_cast( aDimension->GetUnitsMode() ), + static_cast( aDimension->GetUnitsFormat() ), aDimension->GetPrecision() ); - if( aDimension->GetOverrideTextEnabled() ) - m_out->Print( 0, " (override_value \"%s\")", TO_UTF8( aDimension->GetOverrideText() ) ); + if( aDimension->GetOverrideTextEnabled() ) + m_out->Print( 0, " (override_value \"%s\")", TO_UTF8( aDimension->GetOverrideText() ) ); - if( aDimension->GetSuppressZeroes() ) - m_out->Print( 0, " suppress_zeroes" ); + if( aDimension->GetSuppressZeroes() ) + m_out->Print( 0, " suppress_zeroes" ); - m_out->Print( 0, ")\n" ); + m_out->Print( 0, ")\n" ); + } m_out->Print( aNestLevel+1, "(style (thickness %s) (arrow_length %s) (text_position_mode %d)", FormatInternalUnits( aDimension->GetLineThickness() ).c_str(), diff --git a/pcbnew/kicad_plugin.h b/pcbnew/kicad_plugin.h index e61583cb17..609f2ea20d 100644 --- a/pcbnew/kicad_plugin.h +++ b/pcbnew/kicad_plugin.h @@ -84,7 +84,8 @@ class TEXTE_PCB; //#define SEXPR_BOARD_FILE_VERSION 20200828 // Add new fabrication attributes //#define SEXPR_BOARD_FILE_VERSION 20200829 // Remove library name from exported footprints //#define SEXPR_BOARD_FILE_VERSION 20200909 // Change DIMENSION format -#define SEXPR_BOARD_FILE_VERSION 20200913 // Add leader dimension +//#define SEXPR_BOARD_FILE_VERSION 20200913 // Add leader dimension +#define SEXPR_BOARD_FILE_VERSION 20200916 // Add center dimension #define BOARD_FILE_HOST_VERSION 20200825 ///< Earlier files than this include the host tag diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index b74e506771..b5681f560f 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -321,6 +321,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() placeMenu->AppendSeparator(); placeMenu->Add( PCB_ACTIONS::drawAlignedDimension ); + placeMenu->Add( PCB_ACTIONS::drawCenterDimension ); placeMenu->Add( PCB_ACTIONS::drawLeader ); placeMenu->AppendSeparator(); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index b4c5594fa5..97fb97210c 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -723,6 +723,7 @@ void PCB_EDIT_FRAME::setupUIConditions() CURRENT_TOOL( PCB_ACTIONS::drawPolygon ); CURRENT_TOOL( PCB_ACTIONS::placeText ); CURRENT_TOOL( PCB_ACTIONS::drawAlignedDimension ); + CURRENT_TOOL( PCB_ACTIONS::drawCenterDimension ); CURRENT_TOOL( PCB_ACTIONS::drawLeader ); CURRENT_TOOL( PCB_ACTIONS::placeTarget ); CURRENT_TOOL( PCB_ACTIONS::drillOrigin ); diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index c8b34bf684..59fd80382e 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -444,6 +444,8 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer ) break; case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: draw( static_cast( item ), aLayer ); break; diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index e0cb198685..4f41d580d5 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -2387,6 +2387,10 @@ DIMENSION* PCB_PARSER::parseDIMENSION() dimension = std::make_unique( nullptr ); break; + case T_center: + dimension = std::make_unique( nullptr ); + break; + default: wxFAIL_MSG( wxT( "Cannot parse unknown dimension type %s" ) + GetTokenString( CurTok() ) ); diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 593c503ee5..04a8c98d6e 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -315,6 +315,8 @@ void BRDITEMS_PLOTTER::PlotBoardGraphicItems() case PCB_TEXT_T: PlotTextePcb( (TEXTE_PCB*) item ); break; case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: PlotDimension( (DIMENSION*) item ); break; diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 3046a226cc..3508a7021e 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -380,6 +380,7 @@ void PCB_EDIT_FRAME::ReCreateVToolbar() m_drawToolBar->Add( PCB_ACTIONS::placeText, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::drawAlignedDimension, ACTION_TOOLBAR::TOGGLE ); // TODO: re-insert when we have a multi-select tool button + // m_drawToolBar->Add( PCB_ACTIONS::drawCenterDimension, ACTION_TOOLBAR::TOGGLE ); // m_drawToolBar->Add( PCB_ACTIONS::drawLeader, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::placeTarget, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE ); diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 0c6e4eefea..0c3f8093af 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -746,6 +746,10 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) if( boardSettings.m_DimensionUnitsMode == DIM_UNITS_MODE::AUTOMATIC ) dimension->SetUnits( m_frame->GetUserUnits(), false ); } + else if( originalEvent.IsAction( &PCB_ACTIONS::drawCenterDimension ) ) + { + dimension = new CENTER_DIMENSION( m_board ); + } else if( originalEvent.IsAction( &PCB_ACTIONS::drawLeader ) ) { dimension = new LEADER( m_board ); @@ -774,9 +778,10 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) break; case SET_END: + { dimension->SetEnd( (wxPoint) cursorPos ); - if( !!evt->Modifier( MD_CTRL ) ) + if( !!evt->Modifier( MD_CTRL ) || dimension->Type() == PCB_DIM_CENTER_T ) constrainDimension( dimension ); // Dimensions that have origin and end in the same spot are not valid @@ -785,7 +790,15 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) else if( dimension->Type() == PCB_DIM_LEADER_T ) dimension->SetText( wxT( "?" ) ); - break; + if( dimension->Type() == PCB_DIM_CENTER_T ) + { + // No separate height/text step + ++step; + KI_FALLTHROUGH; + } + else + break; + } case SET_HEIGHT: { @@ -814,8 +827,9 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, dimension ); } + + break; } - break; } if( ++step == FINISHED ) @@ -832,7 +846,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) case SET_END: dimension->SetEnd( (wxPoint) cursorPos ); - if( !!evt->Modifier( MD_CTRL ) ) + if( !!evt->Modifier( MD_CTRL ) || dimension->Type() == PCB_DIM_CENTER_T ) constrainDimension( dimension ); break; @@ -850,7 +864,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) double height = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) ); aligned->SetHeight( height ); } - else + else if( dimension->Type() != PCB_DIM_CENTER_T ) { wxASSERT( dimension->Type() == PCB_DIM_LEADER_T ); @@ -2127,6 +2141,7 @@ void DRAWING_TOOL::setTransitions() Go( &DRAWING_TOOL::DrawCircle, PCB_ACTIONS::drawCircle.MakeEvent() ); Go( &DRAWING_TOOL::DrawArc, PCB_ACTIONS::drawArc.MakeEvent() ); Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawAlignedDimension.MakeEvent() ); + Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawCenterDimension.MakeEvent() ); Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawLeader.MakeEvent() ); Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawZone.MakeEvent() ); Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawZoneKeepout.MakeEvent() ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 0429bd7906..3ac2c5d5af 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -1421,6 +1421,8 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) case PCB_ZONE_AREA_T: case PCB_TARGET_T: case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: dupe_item = orig_item->Duplicate(); break; diff --git a/pcbnew/tools/grid_helper.cpp b/pcbnew/tools/grid_helper.cpp index 5c3f6bcde0..f5c47caf45 100644 --- a/pcbnew/tools/grid_helper.cpp +++ b/pcbnew/tools/grid_helper.cpp @@ -556,6 +556,24 @@ void GRID_HELPER::computeAnchors( BOARD_ITEM* aItem, const VECTOR2I& aRefPos, bo break; } + case PCB_DIM_CENTER_T: + { + const CENTER_DIMENSION* dim = static_cast( aItem ); + addAnchor( dim->GetStart(), CORNER | SNAPPABLE, aItem ); + addAnchor( dim->GetEnd(), CORNER | SNAPPABLE, aItem ); + + VECTOR2I start( dim->GetStart() ); + VECTOR2I radial( dim->GetEnd() - dim->GetStart() ); + + for( int i = 0; i < 2; i++ ) + { + radial = radial.Rotate( DEG2RAD( 90 ) ); + addAnchor( start + radial, CORNER | SNAPPABLE, aItem ); + } + + break; + } + case PCB_DIM_LEADER_T: { const LEADER* leader = static_cast( aItem ); diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index b0d33b03b5..c2b2efac33 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -122,6 +122,11 @@ TOOL_ACTION PCB_ACTIONS::drawAlignedDimension( "pcbnew.InteractiveDrawing.aligne _( "Add Aligned Dimension" ), _( "Add an aligned linear dimension" ), add_aligned_dimension_xpm, AF_ACTIVATE ); +TOOL_ACTION PCB_ACTIONS::drawCenterDimension( "pcbnew.InteractiveDrawing.centerDimension", + AS_GLOBAL, 0, "", + _( "Add Center Dimension" ), _( "Add a center dimension" ), + add_center_dimension_xpm, AF_ACTIVATE ); + TOOL_ACTION PCB_ACTIONS::drawLeader( "pcbnew.InteractiveDrawing.leader", AS_GLOBAL, 0, "", _( "Add Leader" ), _( "Add a leader dimension" ), diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index d0eeaeeb86..36f0a27b0a 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -143,6 +143,7 @@ public: static TOOL_ACTION drawArc; static TOOL_ACTION placeText; static TOOL_ACTION drawAlignedDimension; + static TOOL_ACTION drawCenterDimension; static TOOL_ACTION drawLeader; static TOOL_ACTION drawZone; static TOOL_ACTION drawVia; diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index afc34a0dc5..ea8c561d48 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -259,8 +259,22 @@ public: points->Point( DIM_START ) ) ); points->Point( DIM_CROSSBAREND ).SetConstraint( new EC_LINE( points->Point( DIM_CROSSBAREND ), points->Point( DIM_END ) ) ); - } + break; + } + + case PCB_DIM_CENTER_T: + { + const CENTER_DIMENSION* dimension = static_cast( aItem ); + + points->AddPoint( dimension->GetStart() ); + points->AddPoint( dimension->GetEnd() ); + + points->Point( DIM_END ).SetConstraint( new EC_45DEGREE( points->Point( DIM_END ), + points->Point( DIM_START ) ) ); + + break; + } case PCB_DIM_LEADER_T: { @@ -1321,6 +1335,26 @@ void POINT_EDITOR::updateItem() const break; } + case PCB_DIM_CENTER_T: + { + CENTER_DIMENSION* dimension = static_cast( item ); + + if( isModified( m_editPoints->Point( DIM_START ) ) ) + { + dimension->SetStart( wxPoint( m_editedPoint->GetPosition().x, + m_editedPoint->GetPosition().y ) ); + } + else if( isModified( m_editPoints->Point( DIM_END ) ) ) + { + dimension->SetEnd( wxPoint( m_editedPoint->GetPosition().x, + m_editedPoint->GetPosition().y ) ); + } + + dimension->Update(); + + break; + } + case PCB_DIM_LEADER_T: { LEADER* dimension = static_cast( item ); @@ -1577,6 +1611,15 @@ void POINT_EDITOR::updatePoints() break; } + case PCB_DIM_CENTER_T: + { + const CENTER_DIMENSION* dimension = static_cast( item ); + + m_editPoints->Point( DIM_START ).SetPosition( dimension->GetStart() ); + m_editPoints->Point( DIM_END ).SetPosition( dimension->GetEnd() ); + break; + } + case PCB_DIM_LEADER_T: { const LEADER* dimension = static_cast( item ); @@ -1696,6 +1739,14 @@ EDIT_POINT POINT_EDITOR::get45DegConstrainer() const break; } + case PCB_DIM_CENTER_T: + { + if( isModified( m_editPoints->Point( DIM_END ) ) ) + return m_editPoints->Point( DIM_START ); + + break; + } + default: break; } diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index de939ff15c..2406889b72 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -1382,6 +1382,8 @@ static bool itemIsIncludedByFilter( const BOARD_ITEM& aItem, const BOARD& aBoard case PCB_LINE_T: case PCB_TARGET_T: case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: { if( layer == Edge_Cuts ) @@ -1518,6 +1520,8 @@ bool SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem ) break; case PCB_DIM_ALIGNED_T: + case PCB_DIM_CENTER_T: + case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: if( !m_filter.dimensions ) return false;