2018-04-28 15:22:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2022-01-11 15:34:24 +00:00
|
|
|
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-04-28 15:22:25 +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 2
|
|
|
|
* 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, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2018-04-28 15:22:25 +00:00
|
|
|
#include <board_commit.h>
|
|
|
|
#include <pcb_edit_frame.h>
|
2021-11-20 22:05:57 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2018-04-28 15:22:25 +00:00
|
|
|
#include <pcb_layer_box_selector.h>
|
2021-06-06 12:24:49 +00:00
|
|
|
#include <pcbnew.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2021-09-04 17:05:57 +00:00
|
|
|
#include <pcb_group.h>
|
2021-06-11 16:59:28 +00:00
|
|
|
#include <pcb_dimension.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <fp_shape.h>
|
|
|
|
#include <pcb_text.h>
|
2018-04-28 15:22:25 +00:00
|
|
|
#include <widgets/unit_binder.h>
|
2022-01-11 15:34:24 +00:00
|
|
|
#include <widgets/font_choice.h>
|
2021-02-16 03:14:28 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2019-06-03 20:06:58 +00:00
|
|
|
#include <tools/global_edit_tool.h>
|
2021-11-20 22:05:57 +00:00
|
|
|
#include <tools/footprint_editor_control.h>
|
2018-04-28 15:22:25 +00:00
|
|
|
#include <dialog_global_edit_text_and_graphics_base.h>
|
2022-04-26 11:51:39 +00:00
|
|
|
#include "font/kicad_font_name.h"
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
// Columns of layer classes grid
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
COL_CLASS_NAME = 0,
|
|
|
|
COL_LINE_THICKNESS,
|
|
|
|
COL_TEXT_WIDTH,
|
|
|
|
COL_TEXT_HEIGHT,
|
|
|
|
COL_TEXT_THICKNESS,
|
|
|
|
COL_TEXT_ITALIC,
|
|
|
|
COL_TEXT_UPRIGHT
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ROW_HEADER = 0,
|
|
|
|
ROW_SILK,
|
|
|
|
ROW_COPPER,
|
|
|
|
ROW_EDGES,
|
2018-08-24 20:08:30 +00:00
|
|
|
ROW_COURTYARD,
|
2020-05-01 16:24:01 +00:00
|
|
|
ROW_FAB,
|
2018-04-28 15:22:25 +00:00
|
|
|
ROW_OTHERS
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-02-21 22:09:54 +00:00
|
|
|
static bool g_modifyReferences;
|
|
|
|
static bool g_modifyValues;
|
|
|
|
static bool g_modifyOtherFields;
|
|
|
|
static bool g_modifyFootprintGraphics;
|
|
|
|
static bool g_modifyBoardText;
|
|
|
|
static bool g_modifyBoardGraphics;
|
|
|
|
static bool g_filterByLayer;
|
2021-07-21 23:14:56 +00:00
|
|
|
static int g_layerFilter;
|
2019-02-21 22:09:54 +00:00
|
|
|
static bool g_filterByReference;
|
|
|
|
static wxString g_referenceFilter;
|
|
|
|
static bool g_filterByFootprint;
|
|
|
|
static wxString g_footprintFilter;
|
2021-02-16 03:14:28 +00:00
|
|
|
static bool g_filterSelected = false;
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS : public DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE
|
|
|
|
{
|
2021-11-20 22:05:57 +00:00
|
|
|
PCB_BASE_EDIT_FRAME* m_parent;
|
2018-04-28 15:22:25 +00:00
|
|
|
BOARD_DESIGN_SETTINGS* m_brdSettings;
|
2021-02-16 03:14:28 +00:00
|
|
|
PCB_SELECTION m_selection;
|
2021-11-20 22:05:57 +00:00
|
|
|
bool m_isBoardEditor;
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
UNIT_BINDER m_lineWidth;
|
|
|
|
UNIT_BINDER m_textWidth;
|
|
|
|
UNIT_BINDER m_textHeight;
|
|
|
|
UNIT_BINDER m_thickness;
|
|
|
|
|
|
|
|
public:
|
2021-11-20 22:05:57 +00:00
|
|
|
DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( PCB_BASE_EDIT_FRAME* parent );
|
2018-04-28 15:22:25 +00:00
|
|
|
~DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS() override;
|
|
|
|
|
|
|
|
protected:
|
2021-04-07 16:38:07 +00:00
|
|
|
void onActionButtonChange( wxCommandEvent& event ) override;
|
|
|
|
void onSpecifiedValueUpdateUI( wxUpdateUIEvent& event ) override;
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
void OnLayerFilterSelect( wxCommandEvent& event ) override
|
|
|
|
{
|
|
|
|
m_layerFilterOpt->SetValue( true );
|
|
|
|
}
|
2018-11-11 12:24:34 +00:00
|
|
|
void OnReferenceFilterText( wxCommandEvent& event ) override
|
|
|
|
{
|
|
|
|
m_referenceFilterOpt->SetValue( true );
|
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
void OnFootprintFilterText( wxCommandEvent& event ) override
|
|
|
|
{
|
|
|
|
m_footprintFilterOpt->SetValue( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
bool TransferDataFromWindow() override;
|
|
|
|
|
2021-09-04 17:05:57 +00:00
|
|
|
void visitItem( BOARD_COMMIT& aCommit, BOARD_ITEM* aItem );
|
2018-04-28 15:22:25 +00:00
|
|
|
void processItem( BOARD_COMMIT& aCommit, BOARD_ITEM* aItem );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-11-20 22:05:57 +00:00
|
|
|
DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( PCB_BASE_EDIT_FRAME* parent ) :
|
2018-04-28 15:22:25 +00:00
|
|
|
DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE( parent ),
|
2021-03-12 15:12:49 +00:00
|
|
|
m_lineWidth( parent, m_lineWidthLabel, m_LineWidthCtrl, m_lineWidthUnits ),
|
|
|
|
m_textWidth( parent, m_SizeXlabel, m_SizeXCtrl, m_SizeXunit ),
|
|
|
|
m_textHeight( parent, m_SizeYlabel, m_SizeYCtrl, m_SizeYunit ),
|
|
|
|
m_thickness( parent, m_ThicknessLabel, m_ThicknessCtrl, m_ThicknessUnit )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
|
|
|
m_parent = parent;
|
|
|
|
m_brdSettings = &m_parent->GetDesignSettings();
|
2021-11-20 22:05:57 +00:00
|
|
|
m_isBoardEditor = dynamic_cast<PCB_EDIT_FRAME*>( m_parent ) != nullptr;
|
|
|
|
|
|
|
|
if( !m_isBoardEditor )
|
|
|
|
{
|
|
|
|
m_otherFields->SetLabel( _( "Other text items" ) );
|
|
|
|
m_footprintGraphics->SetLabel( _( "Graphic items" ) );
|
|
|
|
|
|
|
|
m_boardText->Show( false );
|
|
|
|
m_boardGraphics->Show( false );
|
|
|
|
|
|
|
|
m_referenceFilterOpt->Show( false );
|
|
|
|
m_referenceFilter->Show( false );
|
|
|
|
m_footprintFilterOpt->Show( false );
|
|
|
|
m_footprintFilter->Show( false );
|
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
m_layerFilter->SetBoardFrame( m_parent );
|
|
|
|
m_layerFilter->SetLayersHotkeys( false );
|
|
|
|
m_layerFilter->Resync();
|
|
|
|
|
|
|
|
m_LayerCtrl->SetBoardFrame( m_parent );
|
|
|
|
m_LayerCtrl->SetLayersHotkeys( false );
|
2020-05-05 15:40:18 +00:00
|
|
|
m_LayerCtrl->SetUndefinedLayerName( INDETERMINATE_ACTION );
|
2018-04-28 15:22:25 +00:00
|
|
|
m_LayerCtrl->Resync();
|
|
|
|
|
|
|
|
m_grid->SetCellHighlightPenWidth( 0 );
|
2021-09-11 19:07:33 +00:00
|
|
|
m_grid->SetDefaultCellFont( KIUI::GetInfoFont( this ) );
|
2018-07-18 16:59:05 +00:00
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons();
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::~DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS()
|
|
|
|
{
|
2019-02-21 22:09:54 +00:00
|
|
|
g_modifyReferences = m_references->GetValue();
|
|
|
|
g_modifyValues = m_values->GetValue();
|
|
|
|
g_modifyOtherFields = m_otherFields->GetValue();
|
|
|
|
g_modifyFootprintGraphics = m_footprintGraphics->GetValue();
|
2021-11-20 22:05:57 +00:00
|
|
|
|
|
|
|
if( m_isBoardEditor )
|
|
|
|
{
|
|
|
|
g_modifyBoardText = m_boardText->GetValue();
|
|
|
|
g_modifyBoardGraphics = m_boardGraphics->GetValue();
|
|
|
|
}
|
2019-02-21 22:09:54 +00:00
|
|
|
|
|
|
|
g_filterByLayer = m_layerFilterOpt->GetValue();
|
|
|
|
g_layerFilter = m_layerFilter->GetLayerSelection();
|
2021-11-20 22:05:57 +00:00
|
|
|
|
|
|
|
if( m_isBoardEditor )
|
|
|
|
{
|
|
|
|
g_filterByReference = m_referenceFilterOpt->GetValue();
|
|
|
|
g_referenceFilter = m_referenceFilter->GetValue();
|
|
|
|
g_filterByFootprint = m_footprintFilterOpt->GetValue();
|
|
|
|
g_footprintFilter = m_footprintFilter->GetValue();
|
|
|
|
}
|
|
|
|
|
2021-02-16 03:14:28 +00:00
|
|
|
g_filterSelected = m_selectedItemsFilter->GetValue();
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow()
|
|
|
|
{
|
2021-02-16 03:14:28 +00:00
|
|
|
PCB_SELECTION_TOOL* selTool = m_parent->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
|
|
|
|
m_selection = selTool->GetSelection();
|
|
|
|
|
2019-02-21 22:09:54 +00:00
|
|
|
m_references->SetValue( g_modifyReferences );
|
|
|
|
m_values->SetValue( g_modifyValues );
|
|
|
|
m_otherFields->SetValue( g_modifyOtherFields );
|
|
|
|
m_footprintGraphics->SetValue( g_modifyFootprintGraphics );
|
2021-11-20 22:05:57 +00:00
|
|
|
|
|
|
|
if( m_isBoardEditor )
|
|
|
|
{
|
|
|
|
m_boardText->SetValue( g_modifyBoardText );
|
|
|
|
m_boardGraphics->SetValue( g_modifyBoardGraphics );
|
|
|
|
}
|
2019-02-21 22:09:54 +00:00
|
|
|
|
|
|
|
if( m_layerFilter->SetLayerSelection( g_layerFilter ) != wxNOT_FOUND )
|
|
|
|
m_layerFilterOpt->SetValue( g_filterByLayer );
|
|
|
|
|
2021-11-20 22:05:57 +00:00
|
|
|
if( m_isBoardEditor )
|
|
|
|
{
|
|
|
|
// SetValue() generates events, ChangeValue() does not
|
|
|
|
m_referenceFilter->ChangeValue( g_referenceFilter );
|
|
|
|
m_referenceFilterOpt->SetValue( g_filterByReference );
|
|
|
|
m_footprintFilter->ChangeValue( g_footprintFilter );
|
|
|
|
m_footprintFilterOpt->SetValue( g_filterByFootprint );
|
|
|
|
}
|
|
|
|
|
2021-02-16 03:14:28 +00:00
|
|
|
m_selectedItemsFilter->SetValue( g_filterSelected );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2020-05-05 15:40:18 +00:00
|
|
|
m_lineWidth.SetValue( INDETERMINATE_ACTION );
|
2022-01-11 15:34:24 +00:00
|
|
|
|
|
|
|
m_fontCtrl->Append( INDETERMINATE_ACTION );
|
|
|
|
m_fontCtrl->SetStringSelection( INDETERMINATE_ACTION );
|
|
|
|
|
2020-05-05 15:40:18 +00:00
|
|
|
m_textWidth.SetValue( INDETERMINATE_ACTION );
|
|
|
|
m_textHeight.SetValue( INDETERMINATE_ACTION );
|
|
|
|
m_thickness.SetValue( INDETERMINATE_ACTION );
|
2022-01-11 15:34:24 +00:00
|
|
|
m_bold->Set3StateValue( wxCHK_UNDETERMINED );
|
|
|
|
m_italic->Set3StateValue( wxCHK_UNDETERMINED );
|
2018-04-28 15:22:25 +00:00
|
|
|
m_keepUpright->Set3StateValue( wxCHK_UNDETERMINED );
|
2022-01-11 15:34:24 +00:00
|
|
|
m_visible->Set3StateValue( wxCHK_UNDETERMINED );
|
2018-04-28 15:22:25 +00:00
|
|
|
m_LayerCtrl->SetLayerSelection( UNDEFINED_LAYER );
|
|
|
|
|
2018-08-24 20:08:30 +00:00
|
|
|
#define SET_INT_VALUE( aRow, aCol, aValue ) \
|
2022-09-16 04:38:10 +00:00
|
|
|
m_grid->SetCellValue( aRow, aCol, EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, GetUserUnits(), aValue, true ) )
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
#define SET_BOOL_VALUE( aRow, aCol, aValue ) \
|
|
|
|
attr = new wxGridCellAttr; \
|
|
|
|
attr->SetRenderer( new wxGridCellBoolRenderer() ); \
|
2020-10-04 08:34:31 +00:00
|
|
|
attr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); \
|
2018-04-28 15:22:25 +00:00
|
|
|
attr->SetReadOnly(); \
|
|
|
|
m_grid->SetAttr( aRow, aCol, attr ); \
|
2022-02-04 22:44:59 +00:00
|
|
|
m_grid->SetCellValue( aRow, aCol, ( aValue ) ? wxT( "1" ) : wxT( "" ) )
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
const BOARD_DESIGN_SETTINGS& bds = m_parent->GetBoard()->GetDesignSettings();
|
|
|
|
wxGridCellAttr* attr;
|
|
|
|
|
2018-08-24 20:08:30 +00:00
|
|
|
m_grid->SetCellValue( ROW_SILK, COL_CLASS_NAME, _( "Silk Layers" ) );
|
|
|
|
m_grid->SetCellValue( ROW_COPPER, COL_CLASS_NAME, _( "Copper Layers" ) );
|
|
|
|
m_grid->SetCellValue( ROW_EDGES, COL_CLASS_NAME, _( "Edge Cuts" ) );
|
|
|
|
m_grid->SetCellValue( ROW_COURTYARD, COL_CLASS_NAME, _( "Courtyards" ) );
|
2020-05-01 16:24:01 +00:00
|
|
|
m_grid->SetCellValue( ROW_FAB, COL_CLASS_NAME, _( "Fab Layers" ) );
|
2018-08-24 20:08:30 +00:00
|
|
|
m_grid->SetCellValue( ROW_OTHERS, COL_CLASS_NAME, _( "Other Layers" ) );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
m_grid->SetCellValue( ROW_HEADER, COL_LINE_THICKNESS, _( "Line Thickness" ) );
|
2018-08-24 20:08:30 +00:00
|
|
|
SET_INT_VALUE( ROW_SILK, COL_LINE_THICKNESS, bds.m_LineThickness[ LAYER_CLASS_SILK ] );
|
|
|
|
SET_INT_VALUE( ROW_COPPER, COL_LINE_THICKNESS, bds.m_LineThickness[ LAYER_CLASS_COPPER ] );
|
|
|
|
SET_INT_VALUE( ROW_EDGES, COL_LINE_THICKNESS, bds.m_LineThickness[ LAYER_CLASS_EDGES ] );
|
|
|
|
SET_INT_VALUE( ROW_COURTYARD, COL_LINE_THICKNESS, bds.m_LineThickness[ LAYER_CLASS_COURTYARD ] );
|
2020-05-01 16:24:01 +00:00
|
|
|
SET_INT_VALUE( ROW_FAB, COL_LINE_THICKNESS, bds.m_LineThickness[ LAYER_CLASS_FAB ] );
|
2018-08-24 20:08:30 +00:00
|
|
|
SET_INT_VALUE( ROW_OTHERS, COL_LINE_THICKNESS, bds.m_LineThickness[ LAYER_CLASS_OTHERS ] );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
m_grid->SetCellValue( ROW_HEADER, COL_TEXT_WIDTH, _( "Text Width" ) );
|
2018-08-24 20:08:30 +00:00
|
|
|
SET_INT_VALUE( ROW_SILK, COL_TEXT_WIDTH, bds.m_TextSize[ LAYER_CLASS_SILK ].x );
|
|
|
|
SET_INT_VALUE( ROW_COPPER, COL_TEXT_WIDTH, bds.m_TextSize[ LAYER_CLASS_COPPER ].x );
|
2020-05-01 16:24:01 +00:00
|
|
|
SET_INT_VALUE( ROW_FAB, COL_TEXT_WIDTH, bds.m_TextSize[ LAYER_CLASS_FAB ].x );
|
2018-08-24 20:08:30 +00:00
|
|
|
SET_INT_VALUE( ROW_OTHERS, COL_TEXT_WIDTH, bds.m_TextSize[ LAYER_CLASS_OTHERS ].x );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
m_grid->SetCellValue( ROW_HEADER, COL_TEXT_HEIGHT, _( "Text Height" ) );
|
2018-08-24 20:08:30 +00:00
|
|
|
SET_INT_VALUE( ROW_SILK, COL_TEXT_HEIGHT, bds.m_TextSize[ LAYER_CLASS_SILK ].y );
|
|
|
|
SET_INT_VALUE( ROW_COPPER, COL_TEXT_HEIGHT, bds.m_TextSize[ LAYER_CLASS_COPPER ].y );
|
2020-05-01 16:24:01 +00:00
|
|
|
SET_INT_VALUE( ROW_FAB, COL_TEXT_HEIGHT, bds.m_TextSize[ LAYER_CLASS_FAB ].y );
|
2018-08-24 20:08:30 +00:00
|
|
|
SET_INT_VALUE( ROW_OTHERS, COL_TEXT_HEIGHT, bds.m_TextSize[ LAYER_CLASS_OTHERS ].y );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
m_grid->SetCellValue( ROW_HEADER, COL_TEXT_THICKNESS, _( "Text Thickness" ) );
|
2018-08-24 20:08:30 +00:00
|
|
|
SET_INT_VALUE( ROW_SILK, COL_TEXT_THICKNESS, bds.m_TextThickness[ LAYER_CLASS_SILK ] );
|
|
|
|
SET_INT_VALUE( ROW_COPPER, COL_TEXT_THICKNESS, bds.m_TextThickness[ LAYER_CLASS_COPPER ] );
|
2020-05-01 16:24:01 +00:00
|
|
|
SET_INT_VALUE( ROW_FAB, COL_TEXT_THICKNESS, bds.m_TextThickness[ LAYER_CLASS_FAB ] );
|
2018-08-24 20:08:30 +00:00
|
|
|
SET_INT_VALUE( ROW_OTHERS, COL_TEXT_THICKNESS, bds.m_TextThickness[ LAYER_CLASS_OTHERS ] );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
m_grid->SetCellValue( ROW_HEADER, COL_TEXT_ITALIC, _( "Italic" ) );
|
|
|
|
SET_BOOL_VALUE( ROW_SILK, COL_TEXT_ITALIC, bds.m_TextItalic[ LAYER_CLASS_SILK ] );
|
|
|
|
SET_BOOL_VALUE( ROW_COPPER, COL_TEXT_ITALIC, bds.m_TextItalic[ LAYER_CLASS_COPPER ] );
|
2020-05-01 16:24:01 +00:00
|
|
|
SET_BOOL_VALUE( ROW_FAB, COL_TEXT_ITALIC, bds.m_TextItalic[ LAYER_CLASS_FAB ] );
|
2018-04-28 15:22:25 +00:00
|
|
|
SET_BOOL_VALUE( ROW_OTHERS, COL_TEXT_ITALIC, bds.m_TextItalic[ LAYER_CLASS_OTHERS ] );
|
|
|
|
|
|
|
|
m_grid->SetCellValue( ROW_HEADER, COL_TEXT_UPRIGHT, _( "Upright" ) );
|
|
|
|
SET_BOOL_VALUE( ROW_SILK, COL_TEXT_UPRIGHT, bds.m_TextUpright[ LAYER_CLASS_SILK ] );
|
|
|
|
SET_BOOL_VALUE( ROW_COPPER, COL_TEXT_UPRIGHT, bds.m_TextUpright[ LAYER_CLASS_COPPER ] );
|
2020-05-01 16:24:01 +00:00
|
|
|
SET_BOOL_VALUE( ROW_FAB, COL_TEXT_UPRIGHT, bds.m_TextUpright[ LAYER_CLASS_FAB ] );
|
2018-04-28 15:22:25 +00:00
|
|
|
SET_BOOL_VALUE( ROW_OTHERS, COL_TEXT_UPRIGHT, bds.m_TextUpright[ LAYER_CLASS_OTHERS ] );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
2018-08-24 20:08:30 +00:00
|
|
|
#undef SET_INT_VALUE
|
2018-04-28 15:22:25 +00:00
|
|
|
#undef SET_BOOL_VALUE
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-07 16:38:07 +00:00
|
|
|
void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::onActionButtonChange( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Update the UNIT_BINDER controls if the action to take is changed
|
|
|
|
bool enable = m_setToSpecifiedValues->GetValue();
|
|
|
|
|
|
|
|
m_lineWidth.Enable( enable );
|
|
|
|
m_textWidth.Enable( enable );
|
|
|
|
m_textHeight.Enable( enable );
|
|
|
|
m_thickness.Enable( enable );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::onSpecifiedValueUpdateUI( wxUpdateUIEvent& event )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2021-04-07 16:38:07 +00:00
|
|
|
// Update the UI for the elements inside the use specified values sizer
|
|
|
|
event.Enable( m_setToSpecifiedValues->GetValue() );
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( BOARD_COMMIT& aCommit, BOARD_ITEM* aItem )
|
|
|
|
{
|
|
|
|
aCommit.Modify( aItem );
|
|
|
|
|
2022-04-26 11:51:39 +00:00
|
|
|
EDA_TEXT* edaText = dynamic_cast<EDA_TEXT*>( aItem );
|
|
|
|
FP_TEXT* fpText = dynamic_cast<FP_TEXT*>( aItem );
|
|
|
|
PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( aItem );
|
2021-06-11 16:59:28 +00:00
|
|
|
PCB_DIMENSION_BASE* dimension = dynamic_cast<PCB_DIMENSION_BASE*>( aItem );
|
2020-11-09 20:32:08 +00:00
|
|
|
|
|
|
|
if( dimension )
|
2022-04-26 11:51:39 +00:00
|
|
|
edaText = &dimension->Text();
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
if( m_setToSpecifiedValues->GetValue() )
|
|
|
|
{
|
|
|
|
if( m_LayerCtrl->GetLayerSelection() != UNDEFINED_LAYER )
|
|
|
|
aItem->SetLayer( ToLAYER_ID( m_LayerCtrl->GetLayerSelection() ) );
|
|
|
|
|
2022-04-26 11:51:39 +00:00
|
|
|
if( edaText )
|
|
|
|
{
|
|
|
|
if( !m_textWidth.IsIndeterminate() )
|
|
|
|
edaText->SetTextSize( wxSize( m_textWidth.GetValue(), edaText->GetTextSize().y ) );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2022-04-26 11:51:39 +00:00
|
|
|
if( !m_textHeight.IsIndeterminate() )
|
|
|
|
edaText->SetTextSize( wxSize( edaText->GetTextSize().x, m_textHeight.GetValue() ) );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2022-04-26 11:51:39 +00:00
|
|
|
if( !m_thickness.IsIndeterminate() )
|
|
|
|
edaText->SetTextThickness( m_thickness.GetValue() );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2022-04-26 11:51:39 +00:00
|
|
|
if( m_bold->Get3StateValue() != wxCHK_UNDETERMINED )
|
|
|
|
edaText->SetBold( m_bold->GetValue() );
|
2022-01-11 15:34:24 +00:00
|
|
|
|
2022-04-26 11:51:39 +00:00
|
|
|
if( m_italic->Get3StateValue() != wxCHK_UNDETERMINED )
|
|
|
|
edaText->SetItalic( m_italic->GetValue() );
|
2022-01-11 15:34:24 +00:00
|
|
|
|
2022-04-26 11:51:39 +00:00
|
|
|
// Must come after setting bold & italic
|
|
|
|
if( m_fontCtrl->GetStringSelection() != INDETERMINATE_ACTION )
|
|
|
|
{
|
|
|
|
edaText->SetFont( m_fontCtrl->GetFontSelection( edaText->IsBold(),
|
|
|
|
edaText->IsItalic() ) );
|
|
|
|
}
|
|
|
|
else if(( m_italic->Get3StateValue() != wxCHK_UNDETERMINED
|
|
|
|
|| m_bold->Get3StateValue() != wxCHK_UNDETERMINED ) )
|
|
|
|
{
|
|
|
|
wxString fontName = edaText->GetFontName();
|
|
|
|
|
|
|
|
if( !edaText->GetFontName().IsEmpty() )
|
|
|
|
{
|
|
|
|
edaText->SetFont( KIFONT::FONT::GetFont( edaText->GetFontName(),
|
|
|
|
edaText->IsBold(),
|
|
|
|
edaText->IsItalic() ) );
|
|
|
|
}
|
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2022-04-26 11:51:39 +00:00
|
|
|
if( m_visible->Get3StateValue() != wxCHK_UNDETERMINED )
|
|
|
|
edaText->SetVisible( m_visible->GetValue() );
|
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2022-04-26 11:51:39 +00:00
|
|
|
if( fpText )
|
|
|
|
{
|
|
|
|
if( m_keepUpright->Get3StateValue() != wxCHK_UNDETERMINED )
|
|
|
|
fpText->SetKeepUpright( m_keepUpright->GetValue() );
|
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2020-11-09 20:32:08 +00:00
|
|
|
if( !m_lineWidth.IsIndeterminate() )
|
|
|
|
{
|
2022-04-26 11:51:39 +00:00
|
|
|
if( shape )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2022-04-26 11:51:39 +00:00
|
|
|
STROKE_PARAMS stroke = shape->GetStroke();
|
2021-07-17 19:56:18 +00:00
|
|
|
stroke.SetWidth( m_lineWidth.GetValue() );
|
2022-04-26 11:51:39 +00:00
|
|
|
shape->SetStroke( stroke );
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
2020-11-09 20:32:08 +00:00
|
|
|
|
|
|
|
if( dimension )
|
|
|
|
dimension->SetLineThickness( m_lineWidth.GetValue() );
|
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PCB_LAYER_ID layer = aItem->GetLayer();
|
|
|
|
|
2022-04-26 11:51:39 +00:00
|
|
|
if( edaText )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2022-04-26 11:51:39 +00:00
|
|
|
edaText->SetTextSize( m_brdSettings->GetTextSize( layer ) );
|
|
|
|
edaText->SetTextThickness( m_brdSettings->GetTextThickness( layer ) );
|
|
|
|
edaText->SetItalic( m_brdSettings->GetTextItalic( layer ) );
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
|
2022-04-26 11:51:39 +00:00
|
|
|
if( fpText )
|
|
|
|
fpText->SetKeepUpright( m_brdSettings->GetTextUpright( layer ) );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2022-04-26 11:51:39 +00:00
|
|
|
if( shape )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
2022-04-26 11:51:39 +00:00
|
|
|
STROKE_PARAMS stroke = shape->GetStroke();
|
2021-07-17 19:56:18 +00:00
|
|
|
stroke.SetWidth( m_brdSettings->GetLineThickness( layer ) );
|
2022-04-26 11:51:39 +00:00
|
|
|
shape->SetStroke( stroke );
|
2021-07-17 19:56:18 +00:00
|
|
|
}
|
2020-11-09 20:32:08 +00:00
|
|
|
|
|
|
|
if( dimension )
|
|
|
|
dimension->SetLineThickness( m_brdSettings->GetLineThickness( layer ) );
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-04 17:05:57 +00:00
|
|
|
void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( BOARD_COMMIT& aCommit, BOARD_ITEM* aItem )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2021-09-04 17:05:57 +00:00
|
|
|
if( m_selectedItemsFilter->GetValue() )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* candidate = aItem;
|
|
|
|
|
|
|
|
if( !candidate->IsSelected() )
|
|
|
|
{
|
|
|
|
if( candidate->GetParent() && candidate->GetParent()->Type() == PCB_FOOTPRINT_T )
|
|
|
|
candidate = candidate->GetParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !candidate->IsSelected() )
|
|
|
|
{
|
|
|
|
candidate = candidate->GetParentGroup();
|
|
|
|
|
|
|
|
while( candidate && !candidate->IsSelected() )
|
|
|
|
candidate = candidate->GetParentGroup();
|
|
|
|
|
|
|
|
if( !candidate )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-02-16 03:14:28 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
if( m_layerFilterOpt->GetValue() && m_layerFilter->GetLayerSelection() != UNDEFINED_LAYER )
|
|
|
|
{
|
|
|
|
if( aItem->GetLayer() != m_layerFilter->GetLayerSelection() )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-11-20 22:05:57 +00:00
|
|
|
if( m_isBoardEditor )
|
2018-11-11 12:24:34 +00:00
|
|
|
{
|
2021-11-20 22:05:57 +00:00
|
|
|
if( m_referenceFilterOpt->GetValue() && !m_referenceFilter->GetValue().IsEmpty() )
|
2018-11-11 12:24:34 +00:00
|
|
|
{
|
2021-11-20 22:05:57 +00:00
|
|
|
FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( aItem->GetParent() );
|
2018-11-11 12:24:34 +00:00
|
|
|
|
2021-11-20 22:05:57 +00:00
|
|
|
if( fp )
|
|
|
|
{
|
|
|
|
if( !WildCompareString( m_referenceFilter->GetValue(), fp->GetReference(), false ) )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2021-11-20 22:05:57 +00:00
|
|
|
if( m_footprintFilterOpt->GetValue() && !m_footprintFilter->GetValue().IsEmpty() )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2021-11-20 22:05:57 +00:00
|
|
|
FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( aItem->GetParent() );
|
|
|
|
|
|
|
|
if( fp )
|
|
|
|
{
|
|
|
|
if( !WildCompareString( m_footprintFilter->GetValue(), fp->GetFPID().Format(), false ) )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
processItem( aCommit, aItem );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow()
|
|
|
|
{
|
2018-11-29 18:59:38 +00:00
|
|
|
if( !m_textWidth.Validate( TEXTS_MIN_SIZE, TEXTS_MAX_SIZE )
|
|
|
|
|| !m_textHeight.Validate( TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) )
|
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
return false;
|
2018-11-29 18:59:38 +00:00
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
BOARD_COMMIT commit( m_parent );
|
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
// Go through the footprints
|
2020-11-13 15:15:52 +00:00
|
|
|
for( FOOTPRINT* fp : m_parent->GetBoard()->Footprints() )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
|
|
|
if( m_references->GetValue() )
|
2021-09-04 17:05:57 +00:00
|
|
|
visitItem( commit, &fp->Reference() );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
if( m_values->GetValue() )
|
2021-09-04 17:05:57 +00:00
|
|
|
visitItem( commit, &fp->Value() );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2020-10-14 23:37:26 +00:00
|
|
|
// Go through all other footprint items
|
|
|
|
for( BOARD_ITEM* boardItem : fp->GraphicalItems() )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2021-12-04 23:52:00 +00:00
|
|
|
KICAD_T itemType = boardItem->Type();
|
|
|
|
|
2022-04-30 22:00:58 +00:00
|
|
|
if( itemType == PCB_FP_TEXT_T || itemType == PCB_FP_TEXTBOX_T )
|
2022-01-30 10:52:52 +00:00
|
|
|
{
|
|
|
|
if( m_otherFields->GetValue() )
|
|
|
|
visitItem( commit, boardItem );
|
|
|
|
}
|
2021-12-04 23:52:00 +00:00
|
|
|
else if( itemType == PCB_FP_SHAPE_T || BaseType( itemType ) == PCB_DIMENSION_T )
|
2018-10-16 16:46:01 +00:00
|
|
|
{
|
|
|
|
if( m_footprintGraphics->GetValue() )
|
2021-09-04 17:05:57 +00:00
|
|
|
visitItem( commit, boardItem );
|
2018-10-16 16:46:01 +00:00
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-20 22:05:57 +00:00
|
|
|
if( m_isBoardEditor )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2021-11-20 22:05:57 +00:00
|
|
|
// Go through the PCB text & graphic items
|
|
|
|
for( BOARD_ITEM* boardItem : m_parent->GetBoard()->Drawings() )
|
2018-10-16 16:46:01 +00:00
|
|
|
{
|
2021-11-20 22:05:57 +00:00
|
|
|
KICAD_T itemType = boardItem->Type();
|
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
if( itemType == PCB_TEXT_T || itemType == PCB_TEXTBOX_T )
|
2021-11-20 22:05:57 +00:00
|
|
|
{
|
|
|
|
if( m_boardText->GetValue() )
|
|
|
|
visitItem( commit, boardItem );
|
|
|
|
}
|
|
|
|
else if( itemType == PCB_SHAPE_T || BaseType( itemType ) == PCB_DIMENSION_T )
|
|
|
|
{
|
|
|
|
if( m_boardGraphics->GetValue() )
|
|
|
|
visitItem( commit, boardItem );
|
|
|
|
}
|
2018-10-16 16:46:01 +00:00
|
|
|
}
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
commit.Push( wxT( "Edit text and graphics properties" ) );
|
2019-06-13 17:28:55 +00:00
|
|
|
m_parent->GetCanvas()->Refresh();
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-03 20:06:58 +00:00
|
|
|
int GLOBAL_EDIT_TOOL::EditTextAndGraphics( const TOOL_EVENT& aEvent )
|
2018-04-28 15:22:25 +00:00
|
|
|
{
|
2019-06-09 23:21:50 +00:00
|
|
|
PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
|
|
|
|
DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS dlg( editFrame );
|
2020-01-12 19:45:37 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
dlg.ShowModal();
|
2019-06-03 20:06:58 +00:00
|
|
|
return 0;
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-20 22:05:57 +00:00
|
|
|
int FOOTPRINT_EDITOR_CONTROL::EditTextAndGraphics( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
FOOTPRINT_EDIT_FRAME* editFrame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
|
|
|
|
DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS dlg( editFrame );
|
|
|
|
|
|
|
|
dlg.ShowModal();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|