2020-09-08 02:42:26 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
|
2023-03-04 23:15:43 +00:00
|
|
|
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-09-08 02:42:26 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2022-01-03 01:20:25 +00:00
|
|
|
#include <widgets/bitmap_button.h>
|
|
|
|
#include <widgets/font_choice.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2021-06-03 17:03:25 +00:00
|
|
|
#include <board_commit.h>
|
2021-06-11 16:59:28 +00:00
|
|
|
#include <pcb_dimension.h>
|
2020-09-08 02:42:26 +00:00
|
|
|
#include <pcb_base_edit_frame.h>
|
|
|
|
#include <pcb_layer_box_selector.h>
|
|
|
|
#include <widgets/unit_binder.h>
|
2021-06-06 12:41:16 +00:00
|
|
|
#include <wx/msgdlg.h>
|
2020-09-08 02:42:26 +00:00
|
|
|
|
|
|
|
#include "dialog_dimension_properties.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent,
|
|
|
|
BOARD_ITEM* aItem ) :
|
|
|
|
DIALOG_DIMENSION_PROPERTIES_BASE( aParent ),
|
|
|
|
m_frame( aParent ),
|
2020-09-12 20:09:40 +00:00
|
|
|
m_cbLayerActual( m_cbLayer ),
|
|
|
|
m_txtValueActual( m_txtValue ),
|
2021-03-12 15:12:49 +00:00
|
|
|
m_textWidth( aParent, m_lblTextWidth, m_txtTextWidth, m_lblTextWidthUnits ),
|
|
|
|
m_textHeight( aParent, m_lblTextHeight, m_txtTextHeight, m_lblTextHeightUnits ),
|
|
|
|
m_textThickness( aParent, m_lblTextThickness, m_txtTextThickness, m_lblTextThicknessUnits ),
|
2020-09-08 02:42:26 +00:00
|
|
|
m_textPosX( aParent, m_lblTextPosX, m_txtTextPosX, m_lblTextPosXUnits ),
|
|
|
|
m_textPosY( aParent, m_lblTextPosY, m_txtTextPosY, m_lblTextPosYUnits ),
|
2022-01-03 01:20:25 +00:00
|
|
|
m_orientation( aParent, m_lblTextOrientation, m_cbTextOrientation, nullptr ),
|
2021-03-12 15:12:49 +00:00
|
|
|
m_lineThickness( aParent, m_lblLineThickness, m_txtLineThickness, m_lblLineThicknessUnits ),
|
|
|
|
m_arrowLength( aParent, m_lblArrowLength, m_txtArrowLength, m_lblArrowLengthUnits ),
|
2023-04-30 21:45:00 +00:00
|
|
|
m_extensionOffset( aParent, m_lblExtensionOffset, m_txtExtensionOffset, m_lblExtensionOffsetUnits ),
|
|
|
|
m_extensionOvershoot( aParent, m_lblExtensionOvershoot, m_txtExtensionOvershoot, m_lblExtensionOvershootUnits )
|
2020-09-08 02:42:26 +00:00
|
|
|
{
|
2020-09-12 20:09:40 +00:00
|
|
|
wxASSERT( BaseType( aItem->Type() ) == PCB_DIMENSION_T );
|
2021-06-11 16:59:28 +00:00
|
|
|
m_dimension = static_cast<PCB_DIMENSION_BASE*>( aItem );
|
|
|
|
m_previewDimension = static_cast<PCB_DIMENSION_BASE*>( m_dimension->Clone() );
|
2020-09-12 14:23:07 +00:00
|
|
|
m_previewDimension->SetParent( m_frame->GetBoard() );
|
2020-09-08 02:42:26 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
switch( m_dimension->Type() )
|
|
|
|
{
|
|
|
|
case PCB_DIM_LEADER_T:
|
|
|
|
// Hide the main format controls and keep the leader controls shown
|
|
|
|
m_sizerFormat->GetStaticBox()->Hide();
|
2020-09-17 00:54:58 +00:00
|
|
|
m_sizerCenter->GetStaticBox()->Hide();
|
2020-09-12 20:09:40 +00:00
|
|
|
|
|
|
|
m_cbLayerActual = m_cbLeaderLayer;
|
|
|
|
m_txtValueActual = m_txtLeaderValue;
|
|
|
|
|
|
|
|
// Remove a fewings from text format
|
|
|
|
m_lblTextPositionMode->Hide();
|
|
|
|
m_cbTextPositionMode->Hide();
|
|
|
|
break;
|
|
|
|
|
2022-05-06 17:13:10 +00:00
|
|
|
case PCB_DIM_CENTER_T:
|
2020-09-17 00:54:58 +00:00
|
|
|
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;
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
default:
|
|
|
|
m_sizerLeader->GetStaticBox()->Hide();
|
2020-09-17 00:54:58 +00:00
|
|
|
m_sizerCenter->GetStaticBox()->Hide();
|
2020-09-12 20:09:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-01-03 01:20:25 +00:00
|
|
|
m_separator0->SetIsSeparator();
|
|
|
|
|
|
|
|
m_bold->SetIsCheckButton();
|
|
|
|
m_bold->SetBitmap( KiBitmap( BITMAPS::text_bold ) );
|
|
|
|
m_italic->SetIsCheckButton();
|
|
|
|
m_italic->SetBitmap( KiBitmap( BITMAPS::text_italic ) );
|
|
|
|
|
|
|
|
m_separator1->SetIsSeparator();
|
|
|
|
|
2022-06-12 19:09:21 +00:00
|
|
|
m_alignLeft->SetIsRadioButton();
|
2022-01-03 01:20:25 +00:00
|
|
|
m_alignLeft->SetBitmap( KiBitmap( BITMAPS::text_align_left ) );
|
2022-06-12 19:09:21 +00:00
|
|
|
m_alignCenter->SetIsRadioButton();
|
2022-01-03 01:20:25 +00:00
|
|
|
m_alignCenter->SetBitmap( KiBitmap( BITMAPS::text_align_center ) );
|
2022-06-12 19:09:21 +00:00
|
|
|
m_alignRight->SetIsRadioButton();
|
2022-01-03 01:20:25 +00:00
|
|
|
m_alignRight->SetBitmap( KiBitmap( BITMAPS::text_align_right ) );
|
|
|
|
|
|
|
|
m_separator2->SetIsSeparator();
|
|
|
|
|
|
|
|
m_mirrored->SetIsCheckButton();
|
|
|
|
m_mirrored->SetBitmap( KiBitmap( BITMAPS::text_mirrored ) );
|
|
|
|
|
|
|
|
m_separator3->SetIsSeparator();
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
// Fix the size after hiding/showing some of the properties
|
|
|
|
Layout();
|
|
|
|
|
2020-09-08 02:42:26 +00:00
|
|
|
// Configure display origin transforms
|
|
|
|
m_textPosX.SetCoordType( ORIGIN_TRANSFORMS::ABS_X_COORD );
|
|
|
|
m_textPosY.SetCoordType( ORIGIN_TRANSFORMS::ABS_Y_COORD );
|
|
|
|
|
|
|
|
// Configure the layers list selector. Note that footprints are built outside the current
|
|
|
|
// board and so we may need to show all layers if the text is on an unactivated layer.
|
|
|
|
if( !m_frame->GetBoard()->IsLayerEnabled( m_dimension->GetLayer() ) )
|
2020-09-12 20:09:40 +00:00
|
|
|
m_cbLayerActual->ShowNonActivatedLayers( true );
|
2020-09-08 02:42:26 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
m_cbLayerActual->SetLayersHotkeys( false );
|
|
|
|
m_cbLayerActual->SetBoardFrame( aParent );
|
|
|
|
m_cbLayerActual->Resync();
|
2020-09-08 02:42:26 +00:00
|
|
|
|
2022-01-03 01:20:25 +00:00
|
|
|
m_orientation.SetUnits( EDA_UNITS::DEGREES );
|
|
|
|
m_orientation.SetPrecision( 3 );
|
2020-09-08 02:42:26 +00:00
|
|
|
|
2022-01-03 01:20:25 +00:00
|
|
|
// Set predefined rotations in combo dropdown, according to the locale floating point
|
|
|
|
// separator notation
|
|
|
|
double rot_list[] = { 0.0, 90.0, -90.0, 180.0 };
|
|
|
|
|
|
|
|
for( size_t ii = 0; ii < m_cbTextOrientation->GetCount() && ii < 4; ++ii )
|
|
|
|
m_cbTextOrientation->SetString( ii, wxString::Format( "%.1f", rot_list[ii] ) );
|
2020-09-08 02:42:26 +00:00
|
|
|
|
2020-09-11 02:38:30 +00:00
|
|
|
m_cbOverrideValue->Bind( wxEVT_CHECKBOX,
|
|
|
|
[&]( wxCommandEvent& evt )
|
|
|
|
{
|
|
|
|
m_txtValue->Enable( m_cbOverrideValue->GetValue() );
|
|
|
|
|
|
|
|
if( !m_cbOverrideValue->GetValue() )
|
2020-09-11 23:52:45 +00:00
|
|
|
m_txtValue->SetValue( m_dimension->GetValueText() );
|
2020-09-11 02:38:30 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
auto updateEventHandler =
|
|
|
|
[&]( wxCommandEvent& evt )
|
|
|
|
{
|
|
|
|
if( !m_cbOverrideValue->GetValue() )
|
2020-09-11 23:52:45 +00:00
|
|
|
m_txtValue->ChangeValue( m_dimension->GetValueText() );
|
2020-09-11 02:38:30 +00:00
|
|
|
|
|
|
|
updatePreviewText();
|
|
|
|
};
|
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
// No need to use m_txtValueActual here since we don't have previewing for leaders
|
2020-09-11 02:38:30 +00:00
|
|
|
m_txtValue->Bind( wxEVT_TEXT, updateEventHandler );
|
|
|
|
m_txtPrefix->Bind( wxEVT_TEXT, updateEventHandler );
|
|
|
|
m_txtSuffix->Bind( wxEVT_TEXT, updateEventHandler );
|
|
|
|
|
|
|
|
m_cbUnits->Bind( wxEVT_CHOICE, updateEventHandler );
|
|
|
|
m_cbUnitsFormat->Bind( wxEVT_CHOICE, updateEventHandler );
|
|
|
|
m_cbPrecision->Bind( wxEVT_CHOICE, updateEventHandler );
|
|
|
|
m_cbSuppressZeroes->Bind( wxEVT_CHECKBOX, updateEventHandler );
|
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
m_cbTextPositionMode->Bind( wxEVT_CHOICE,
|
|
|
|
[&]( wxCommandEvent& aEvt )
|
|
|
|
{
|
|
|
|
// manual mode
|
|
|
|
bool allowPositioning = ( m_cbTextPositionMode->GetSelection() == 2 );
|
|
|
|
|
|
|
|
m_txtTextPosX->Enable( allowPositioning );
|
|
|
|
m_txtTextPosY->Enable( allowPositioning );
|
|
|
|
} );
|
|
|
|
|
|
|
|
m_cbKeepAligned->Bind( wxEVT_CHECKBOX,
|
|
|
|
[&]( wxCommandEvent& aEvt )
|
|
|
|
{
|
|
|
|
m_cbTextOrientation->Enable( !m_cbKeepAligned->GetValue() );
|
|
|
|
} );
|
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons();
|
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2020-09-08 02:42:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_DIMENSION_PROPERTIES::~DIALOG_DIMENSION_PROPERTIES()
|
|
|
|
{
|
2020-09-11 23:52:45 +00:00
|
|
|
delete m_previewDimension;
|
2020-09-08 02:42:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow()
|
|
|
|
{
|
2020-09-23 17:01:19 +00:00
|
|
|
BOARD* board = m_frame->GetBoard();
|
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
m_txtValue->Enable( m_dimension->GetOverrideTextEnabled() );
|
|
|
|
m_cbOverrideValue->SetValue( m_dimension->GetOverrideTextEnabled() );
|
2020-09-08 02:42:26 +00:00
|
|
|
|
2020-11-04 00:36:27 +00:00
|
|
|
switch( m_dimension->GetUnitsMode() )
|
|
|
|
{
|
|
|
|
case DIM_UNITS_MODE::INCHES: m_cbUnits->SetSelection( 0 ); break;
|
|
|
|
case DIM_UNITS_MODE::MILS: m_cbUnits->SetSelection( 1 ); break;
|
|
|
|
case DIM_UNITS_MODE::MILLIMETRES: m_cbUnits->SetSelection( 2 ); break;
|
|
|
|
case DIM_UNITS_MODE::AUTOMATIC: m_cbUnits->SetSelection( 3 ); break;
|
|
|
|
}
|
2020-09-08 02:42:26 +00:00
|
|
|
|
2020-09-11 02:38:30 +00:00
|
|
|
m_cbUnitsFormat->SetSelection( static_cast<int>( m_dimension->GetUnitsFormat() ) );
|
|
|
|
m_cbPrecision->SetSelection( static_cast<int>( m_dimension->GetPrecision() ) );
|
2020-09-08 02:42:26 +00:00
|
|
|
|
2020-09-23 17:01:19 +00:00
|
|
|
m_txtPrefix->SetValue( board->ConvertKIIDsToCrossReferences( m_dimension->GetPrefix() ) );
|
|
|
|
m_txtSuffix->SetValue( board->ConvertKIIDsToCrossReferences( m_dimension->GetSuffix() ) );
|
2020-09-08 02:42:26 +00:00
|
|
|
|
2020-09-12 20:09:40 +00:00
|
|
|
if( m_cbLayerActual->SetLayerSelection( m_dimension->GetLayer() ) < 0 )
|
2020-09-08 02:42:26 +00:00
|
|
|
{
|
2021-07-13 18:46:33 +00:00
|
|
|
wxMessageBox( _( "This item was on a non-existing layer.\n"
|
|
|
|
"It has been moved to the first defined layer." ) );
|
2020-09-12 20:09:40 +00:00
|
|
|
m_cbLayerActual->SetSelection( 0 );
|
2020-09-08 02:42:26 +00:00
|
|
|
}
|
|
|
|
|
2020-09-11 02:38:30 +00:00
|
|
|
m_cbSuppressZeroes->SetValue( m_dimension->GetSuppressZeroes() );
|
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
m_fontCtrl->SetFontSelection( m_dimension->GetFont() );
|
2020-09-08 02:42:26 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
m_textWidth.SetValue( m_dimension->GetTextSize().x );
|
|
|
|
m_textHeight.SetValue( m_dimension->GetTextSize().y );
|
|
|
|
m_textThickness.SetValue( m_dimension->GetTextThickness() );
|
2022-01-03 01:20:25 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
m_textPosX.SetValue( m_dimension->GetTextPos().x );
|
|
|
|
m_textPosY.SetValue( m_dimension->GetTextPos().y );
|
2020-09-11 23:52:45 +00:00
|
|
|
m_cbTextPositionMode->SetSelection( static_cast<int>( m_dimension->GetTextPositionMode() ) );
|
|
|
|
|
|
|
|
if( m_dimension->GetTextPositionMode() != DIM_TEXT_POSITION::MANUAL )
|
|
|
|
{
|
|
|
|
m_txtTextPosX->Disable();
|
|
|
|
m_txtTextPosY->Disable();
|
|
|
|
}
|
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
EDA_ANGLE orientation = m_dimension->GetTextAngle();
|
2022-04-10 21:43:09 +00:00
|
|
|
m_orientation.SetAngleValue( orientation.Normalize180() );
|
2022-05-28 18:41:39 +00:00
|
|
|
m_cbTextOrientation->Enable( !m_dimension->GetKeepTextAligned() );
|
2022-02-19 09:24:44 +00:00
|
|
|
m_cbKeepAligned->SetValue( m_dimension->GetKeepTextAligned() );
|
2022-01-03 01:20:25 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
m_bold->Check( m_dimension->IsBold() );
|
|
|
|
m_italic->Check( m_dimension->IsItalic() );
|
2020-09-08 02:42:26 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
switch ( m_dimension->GetHorizJustify() )
|
2022-01-03 01:20:25 +00:00
|
|
|
{
|
|
|
|
case GR_TEXT_H_ALIGN_LEFT: m_alignLeft->Check( true ); break;
|
|
|
|
case GR_TEXT_H_ALIGN_CENTER: m_alignCenter->Check( true ); break;
|
|
|
|
case GR_TEXT_H_ALIGN_RIGHT: m_alignRight->Check( true ); break;
|
|
|
|
}
|
2021-07-13 18:46:33 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
m_mirrored->Check( m_dimension->IsMirrored() );
|
2020-09-08 02:42:26 +00:00
|
|
|
|
2020-09-09 03:17:08 +00:00
|
|
|
m_lineThickness.SetValue( m_dimension->GetLineThickness() );
|
2020-09-11 02:38:30 +00:00
|
|
|
m_arrowLength.SetValue( m_dimension->GetArrowLength() );
|
2020-09-12 15:46:33 +00:00
|
|
|
m_extensionOffset.SetValue( m_dimension->GetExtensionOffset() );
|
2020-09-11 02:38:30 +00:00
|
|
|
|
2023-04-30 21:45:00 +00:00
|
|
|
if( PCB_DIM_ALIGNED* aligned = dynamic_cast<PCB_DIM_ALIGNED*>( m_dimension ) )
|
|
|
|
m_extensionOvershoot.SetValue( aligned->GetExtensionHeight() );
|
|
|
|
else
|
|
|
|
m_extensionOvershoot.Show( false );
|
|
|
|
|
2020-09-11 02:38:30 +00:00
|
|
|
// Do this last; it depends on the other settings
|
2020-09-11 23:52:45 +00:00
|
|
|
if( m_dimension->GetOverrideTextEnabled() )
|
2020-09-19 19:41:54 +00:00
|
|
|
{
|
|
|
|
wxString txt = board->ConvertKIIDsToCrossReferences( m_dimension->GetOverrideText() );
|
|
|
|
m_txtValueActual->SetValue( txt );
|
|
|
|
}
|
2020-09-11 23:52:45 +00:00
|
|
|
else
|
2020-09-19 19:41:54 +00:00
|
|
|
{
|
2020-09-12 20:09:40 +00:00
|
|
|
m_txtValueActual->SetValue( m_dimension->GetValueText() );
|
2020-09-19 19:41:54 +00:00
|
|
|
}
|
2020-09-11 23:52:45 +00:00
|
|
|
|
2023-04-30 21:45:00 +00:00
|
|
|
if( PCB_DIM_LEADER* leader = static_cast<PCB_DIM_LEADER*>( m_dimension ) )
|
2021-07-13 18:46:33 +00:00
|
|
|
m_cbTextFrame->SetSelection( static_cast<int>( leader->GetTextBorder() ) );
|
2020-09-12 20:09:40 +00:00
|
|
|
|
2020-09-08 02:42:26 +00:00
|
|
|
return DIALOG_DIMENSION_PROPERTIES_BASE::TransferDataToWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow()
|
|
|
|
{
|
2020-09-11 23:52:45 +00:00
|
|
|
if( !DIALOG_DIMENSION_PROPERTIES_BASE::TransferDataFromWindow() )
|
|
|
|
return false;
|
2020-09-11 02:38:30 +00:00
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
commit.Modify( m_dimension );
|
2020-09-11 02:38:30 +00:00
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
// If no other command in progress, prepare undo command
|
|
|
|
// (for a command in progress, will be made later, at the completion of command)
|
|
|
|
bool pushCommit = ( m_dimension->GetEditFlags() == 0 );
|
2020-09-11 02:38:30 +00:00
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
/* set flag in edit to force undo/redo/abort proper operation,
|
|
|
|
* and avoid new calls to SaveCopyInUndoList for the same dimension
|
|
|
|
* this can occurs when a dimension is moved, and then rotated, edited ..
|
|
|
|
*/
|
|
|
|
if( !pushCommit )
|
|
|
|
m_dimension->SetFlags( IN_EDIT );
|
2020-09-11 02:38:30 +00:00
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
updateDimensionFromDialog( m_dimension );
|
2020-09-11 02:38:30 +00:00
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
if( pushCommit )
|
|
|
|
commit.Push( _( "Change dimension properties" ) );
|
2020-09-11 02:38:30 +00:00
|
|
|
|
2020-09-08 02:42:26 +00:00
|
|
|
return true;
|
|
|
|
}
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2020-09-11 02:38:30 +00:00
|
|
|
|
2022-01-03 01:20:25 +00:00
|
|
|
void DIALOG_DIMENSION_PROPERTIES::onFontSelected( wxCommandEvent & aEvent )
|
|
|
|
{
|
|
|
|
if( KIFONT::FONT::IsStroke( aEvent.GetString() ) )
|
|
|
|
{
|
|
|
|
m_textThickness.Show( true );
|
|
|
|
|
|
|
|
int textSize = std::min( m_textWidth.GetValue(), m_textHeight.GetValue() );
|
|
|
|
int thickness = m_textThickness.GetValue();
|
|
|
|
|
|
|
|
m_bold->Check( abs( thickness - GetPenSizeForBold( textSize ) )
|
|
|
|
< abs( thickness - GetPenSizeForNormal( textSize ) ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_textThickness.Show( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_DIMENSION_PROPERTIES::onBoldToggle( wxCommandEvent & aEvent )
|
|
|
|
{
|
|
|
|
int textSize = std::min( m_textWidth.GetValue(), m_textHeight.GetValue() );
|
|
|
|
|
|
|
|
if( aEvent.IsChecked() )
|
|
|
|
m_textThickness.ChangeValue( GetPenSizeForBold( textSize ) );
|
|
|
|
else
|
|
|
|
m_textThickness.ChangeValue( GetPenSizeForNormal( textSize ) );
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_DIMENSION_PROPERTIES::onAlignButton( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
for( BITMAP_BUTTON* btn : { m_alignLeft, m_alignCenter, m_alignRight } )
|
|
|
|
{
|
|
|
|
if( btn->IsChecked() && btn != aEvent.GetEventObject() )
|
|
|
|
btn->Check( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_DIMENSION_PROPERTIES::onThickness( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int textSize = std::min( m_textWidth.GetValue(), m_textHeight.GetValue() );
|
|
|
|
int thickness = m_textThickness.GetValue();
|
|
|
|
|
|
|
|
m_bold->Check( abs( thickness - GetPenSizeForBold( textSize ) )
|
|
|
|
< abs( thickness - GetPenSizeForNormal( textSize ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-11 16:59:28 +00:00
|
|
|
void DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog( PCB_DIMENSION_BASE* aTarget )
|
2020-09-09 03:17:08 +00:00
|
|
|
{
|
2020-09-23 17:01:19 +00:00
|
|
|
BOARD* board = m_frame->GetBoard();
|
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
aTarget->SetOverrideTextEnabled( m_cbOverrideValue->GetValue() );
|
2020-09-11 02:38:30 +00:00
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
if( m_cbOverrideValue->GetValue() )
|
2020-09-19 19:41:54 +00:00
|
|
|
{
|
|
|
|
wxString txt = board->ConvertCrossReferencesToKIIDs( m_txtValueActual->GetValue() );
|
|
|
|
aTarget->SetOverrideText( txt );
|
|
|
|
}
|
2020-09-11 02:38:30 +00:00
|
|
|
|
2020-09-23 17:01:19 +00:00
|
|
|
aTarget->SetPrefix( board->ConvertCrossReferencesToKIIDs( m_txtPrefix->GetValue() ) );
|
|
|
|
aTarget->SetSuffix( board->ConvertCrossReferencesToKIIDs( m_txtSuffix->GetValue() ) );
|
2020-09-12 20:09:40 +00:00
|
|
|
aTarget->SetLayer( static_cast<PCB_LAYER_ID>( m_cbLayerActual->GetLayerSelection() ) );
|
2020-09-11 02:38:30 +00:00
|
|
|
|
2020-11-04 00:36:27 +00:00
|
|
|
switch( m_cbUnits->GetSelection() )
|
|
|
|
{
|
2023-03-05 13:27:22 +00:00
|
|
|
case 0: aTarget->SetUnitsMode( DIM_UNITS_MODE::INCHES ); break;
|
|
|
|
case 1: aTarget->SetUnitsMode( DIM_UNITS_MODE::MILS ); break;
|
|
|
|
case 2: aTarget->SetUnitsMode( DIM_UNITS_MODE::MILLIMETRES ); break;
|
|
|
|
case 3: aTarget->SetUnitsMode( DIM_UNITS_MODE::AUTOMATIC ); break;
|
2020-11-04 00:36:27 +00:00
|
|
|
}
|
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
aTarget->SetUnitsFormat( static_cast<DIM_UNITS_FORMAT>( m_cbUnitsFormat->GetSelection() ) );
|
2023-03-05 13:27:22 +00:00
|
|
|
aTarget->SetPrecision( static_cast<DIM_PRECISION>( m_cbPrecision->GetSelection() ) );
|
2020-09-11 23:52:45 +00:00
|
|
|
aTarget->SetSuppressZeroes( m_cbSuppressZeroes->GetValue() );
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
DIM_TEXT_POSITION tpm = static_cast<DIM_TEXT_POSITION>( m_cbTextPositionMode->GetSelection() );
|
|
|
|
aTarget->SetTextPositionMode( tpm );
|
2020-09-11 02:38:30 +00:00
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
if( tpm == DIM_TEXT_POSITION::MANUAL )
|
|
|
|
{
|
2023-02-19 03:40:07 +00:00
|
|
|
VECTOR2I pos( m_textPosX.GetValue(), m_textPosY.GetValue() );
|
2023-03-04 23:15:43 +00:00
|
|
|
aTarget->SetTextPos( pos );
|
2020-09-11 23:52:45 +00:00
|
|
|
}
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
aTarget->SetKeepTextAligned( m_cbKeepAligned->GetValue() );
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
aTarget->SetTextAngle( m_orientation.GetAngleValue().Normalize() );
|
|
|
|
aTarget->SetTextWidth( m_textWidth.GetValue() );
|
|
|
|
aTarget->SetTextHeight( m_textHeight.GetValue() );
|
|
|
|
aTarget->SetTextThickness( m_textThickness.GetValue() );
|
2022-05-06 17:13:10 +00:00
|
|
|
|
|
|
|
if( m_fontCtrl->HaveFontSelection() )
|
2023-03-04 23:15:43 +00:00
|
|
|
aTarget->SetFont( m_fontCtrl->GetFontSelection( m_bold->IsChecked(), m_italic->IsChecked() ) );
|
2022-01-03 01:20:25 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
aTarget->SetBold( m_bold->IsChecked() );
|
|
|
|
aTarget->SetItalic( m_italic->IsChecked() );
|
2022-01-03 01:20:25 +00:00
|
|
|
|
|
|
|
if( m_alignLeft->IsChecked() )
|
2023-03-04 23:15:43 +00:00
|
|
|
aTarget->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
2022-01-03 01:20:25 +00:00
|
|
|
else if( m_alignCenter->IsChecked() )
|
2023-03-04 23:15:43 +00:00
|
|
|
aTarget->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
|
2022-01-03 01:20:25 +00:00
|
|
|
else
|
2023-03-04 23:15:43 +00:00
|
|
|
aTarget->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
|
2022-01-03 01:20:25 +00:00
|
|
|
|
2023-03-04 23:15:43 +00:00
|
|
|
aTarget->SetMirrored( m_mirrored->IsChecked() );
|
2020-09-09 03:17:08 +00:00
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
aTarget->SetLineThickness( m_lineThickness.GetValue() );
|
|
|
|
aTarget->SetArrowLength( m_arrowLength.GetValue() );
|
2020-09-12 15:46:33 +00:00
|
|
|
aTarget->SetExtensionOffset( m_extensionOffset.GetValue() );
|
2020-09-11 02:38:30 +00:00
|
|
|
|
2023-04-30 21:45:00 +00:00
|
|
|
if( PCB_DIM_ALIGNED* aligned = dynamic_cast<PCB_DIM_ALIGNED*>( aTarget ) )
|
|
|
|
aligned->SetExtensionHeight( m_extensionOvershoot.GetValue() );
|
|
|
|
|
|
|
|
if( PCB_DIM_LEADER* leader = dynamic_cast<PCB_DIM_LEADER*>( aTarget ) )
|
2021-07-13 18:46:33 +00:00
|
|
|
leader->SetTextBorder( static_cast<DIM_TEXT_BORDER>( m_cbTextFrame->GetSelection()));
|
2020-09-12 20:09:40 +00:00
|
|
|
|
2020-09-11 23:52:45 +00:00
|
|
|
aTarget->Update();
|
2020-09-11 02:38:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_DIMENSION_PROPERTIES::updatePreviewText()
|
|
|
|
{
|
2020-09-11 23:52:45 +00:00
|
|
|
updateDimensionFromDialog( m_previewDimension );
|
2023-05-05 13:21:56 +00:00
|
|
|
m_staticTextPreview->SetLabel( m_previewDimension->GetShownText( true ) );
|
2020-09-09 03:17:08 +00:00
|
|
|
}
|