2019-06-30 22:06:34 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2024-03-09 13:50:26 +00:00
|
|
|
* Copyright (C) 2019-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-06-30 22:06:34 +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
|
|
|
|
*/
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <dialog_global_edit_text_and_graphics_base.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2021-02-24 13:48:02 +00:00
|
|
|
#include <sch_symbol.h>
|
2019-06-30 22:06:34 +00:00
|
|
|
#include <sch_connection.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2021-07-17 19:56:18 +00:00
|
|
|
#include <sch_shape.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <sch_line.h>
|
2020-11-03 13:39:31 +00:00
|
|
|
#include <sch_junction.h>
|
2019-06-30 22:06:34 +00:00
|
|
|
#include <sch_sheet.h>
|
2022-03-31 21:09:35 +00:00
|
|
|
#include <sch_sheet_pin.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
2023-06-09 21:41:33 +00:00
|
|
|
#include <sch_commit.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/ee_selection_tool.h>
|
|
|
|
#include <tools/sch_edit_tool.h>
|
|
|
|
#include <widgets/unit_binder.h>
|
2022-01-11 15:34:24 +00:00
|
|
|
#include <widgets/font_choice.h>
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
static bool g_modifyReferences;
|
|
|
|
static bool g_modifyValues;
|
|
|
|
static bool g_modifyOtherFields;
|
|
|
|
static bool g_modifyWires;
|
2020-04-02 13:58:35 +00:00
|
|
|
static bool g_modifyBuses;
|
2019-06-30 22:06:34 +00:00
|
|
|
static bool g_modifyGlobalLabels;
|
|
|
|
static bool g_modifyHierLabels;
|
2023-01-23 19:58:53 +00:00
|
|
|
static bool g_modifyLabelFields;
|
2019-06-30 22:06:34 +00:00
|
|
|
static bool g_modifySheetTitles;
|
2020-04-02 12:57:07 +00:00
|
|
|
static bool g_modifyOtherSheetFields;
|
2019-06-30 22:06:34 +00:00
|
|
|
static bool g_modifySheetPins;
|
2020-04-02 12:57:07 +00:00
|
|
|
static bool g_modifySheetBorders;
|
2019-06-30 22:06:34 +00:00
|
|
|
static bool g_modifySchTextAndGraphics;
|
|
|
|
|
|
|
|
static bool g_filterByFieldname;
|
|
|
|
static wxString g_fieldnameFilter;
|
|
|
|
static bool g_filterByReference;
|
|
|
|
static wxString g_referenceFilter;
|
|
|
|
static bool g_filterBySymbol;
|
|
|
|
static wxString g_symbolFilter;
|
2020-05-06 21:56:18 +00:00
|
|
|
static bool g_filterByType;
|
|
|
|
static bool g_typeFilterIsPower;
|
2019-06-30 22:06:34 +00:00
|
|
|
static bool g_filterByNet;
|
|
|
|
static wxString g_netFilter;
|
2021-02-14 23:38:52 +00:00
|
|
|
static bool g_filterSelected;
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
|
2020-09-18 22:04:10 +00:00
|
|
|
#define DEFAULT_STYLE _( "Default" )
|
|
|
|
|
2019-06-30 22:06:34 +00:00
|
|
|
class DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS : public DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE
|
|
|
|
{
|
|
|
|
SCH_EDIT_FRAME* m_parent;
|
2021-02-14 23:38:52 +00:00
|
|
|
EE_SELECTION m_selection;
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
UNIT_BINDER m_textSize;
|
|
|
|
UNIT_BINDER m_lineWidth;
|
2021-08-31 10:48:45 +00:00
|
|
|
UNIT_BINDER m_junctionSize;
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( SCH_EDIT_FRAME* parent );
|
|
|
|
~DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void OnReferenceFilterText( wxCommandEvent& event ) override
|
|
|
|
{
|
|
|
|
m_referenceFilterOpt->SetValue( true );
|
|
|
|
}
|
|
|
|
void OnSymbolFilterText( wxCommandEvent& event ) override
|
|
|
|
{
|
|
|
|
m_symbolFilterOpt->SetValue( true );
|
|
|
|
}
|
2022-02-25 00:30:29 +00:00
|
|
|
void OnFieldNameFilterText( wxCommandEvent& event ) override
|
|
|
|
{
|
|
|
|
m_fieldnameFilterOpt->SetValue( true );
|
|
|
|
}
|
|
|
|
void OnNetFilterText( wxCommandEvent& event ) override
|
|
|
|
{
|
|
|
|
m_netFilterOpt->SetValue( true );
|
|
|
|
}
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
bool TransferDataFromWindow() override;
|
|
|
|
|
2023-06-09 21:41:33 +00:00
|
|
|
void visitItem( SCH_COMMIT* aCommit, const SCH_SHEET_PATH& aSheetPath, SCH_ITEM* aItem );
|
|
|
|
void processItem( SCH_COMMIT* aCommit, const SCH_SHEET_PATH& aSheetPath, SCH_ITEM* aItem );
|
2019-06-30 22:06:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( SCH_EDIT_FRAME* parent ) :
|
|
|
|
DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE( parent ),
|
|
|
|
m_textSize( parent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ),
|
2021-08-31 10:48:45 +00:00
|
|
|
m_lineWidth( parent, m_lineWidthLabel, m_LineWidthCtrl, m_lineWidthUnits, true ),
|
|
|
|
m_junctionSize( parent, m_dotSizeLabel, m_dotSizeCtrl, m_dotSizeUnits, true )
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
|
|
|
m_parent = parent;
|
|
|
|
|
2020-09-18 22:04:10 +00:00
|
|
|
m_lineStyle->Append( DEFAULT_STYLE );
|
2020-07-07 18:55:35 +00:00
|
|
|
m_lineStyle->Append( INDETERMINATE_ACTION );
|
|
|
|
|
2022-05-03 21:55:35 +00:00
|
|
|
m_textColorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
|
|
|
|
m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
|
2020-11-03 13:39:31 +00:00
|
|
|
m_colorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
|
|
|
|
m_colorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
|
2021-07-17 19:56:18 +00:00
|
|
|
m_fillColorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
|
|
|
|
m_fillColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
|
2021-08-31 10:48:45 +00:00
|
|
|
m_dotColorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
|
|
|
|
m_dotColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
|
2020-11-03 13:39:31 +00:00
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons();
|
2019-06-30 22:06:34 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2019-06-30 22:06:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::~DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS()
|
|
|
|
{
|
|
|
|
g_modifyReferences = m_references->GetValue();
|
|
|
|
g_modifyValues = m_values->GetValue();
|
|
|
|
g_modifyOtherFields = m_otherFields->GetValue();
|
|
|
|
g_modifyWires = m_wires->GetValue();
|
2020-04-02 13:58:35 +00:00
|
|
|
g_modifyBuses = m_buses->GetValue();
|
2019-06-30 22:06:34 +00:00
|
|
|
g_modifyGlobalLabels = m_globalLabels->GetValue();
|
|
|
|
g_modifyHierLabels = m_hierLabels->GetValue();
|
2023-01-23 19:58:53 +00:00
|
|
|
g_modifyLabelFields = m_labelFields->GetValue();
|
2019-06-30 22:06:34 +00:00
|
|
|
g_modifySheetTitles = m_sheetTitles->GetValue();
|
2020-04-02 12:57:07 +00:00
|
|
|
g_modifyOtherSheetFields = m_sheetFields->GetValue();
|
2019-06-30 22:06:34 +00:00
|
|
|
g_modifySheetPins = m_sheetPins->GetValue();
|
2020-04-02 12:57:07 +00:00
|
|
|
g_modifySheetBorders = m_sheetBorders->GetValue();
|
2019-06-30 22:06:34 +00:00
|
|
|
g_modifySchTextAndGraphics = m_schTextAndGraphics->GetValue();
|
|
|
|
|
|
|
|
g_filterByFieldname = m_fieldnameFilterOpt->GetValue();
|
|
|
|
g_fieldnameFilter = m_fieldnameFilter->GetValue();
|
|
|
|
g_filterByReference = m_referenceFilterOpt->GetValue();
|
|
|
|
g_referenceFilter = m_referenceFilter->GetValue();
|
|
|
|
g_filterBySymbol = m_symbolFilterOpt->GetValue();
|
|
|
|
g_symbolFilter = m_symbolFilter->GetValue();
|
2020-05-06 21:56:18 +00:00
|
|
|
g_filterByType = m_typeFilterOpt->GetValue();
|
|
|
|
g_typeFilterIsPower = m_typeFilter->GetSelection() == 1;
|
2019-06-30 22:06:34 +00:00
|
|
|
g_filterByNet = m_netFilterOpt->GetValue();
|
|
|
|
g_netFilter = m_netFilter->GetValue();
|
2021-02-14 23:38:52 +00:00
|
|
|
g_filterSelected = m_selectedFilterOpt->GetValue();
|
2019-06-30 22:06:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow()
|
|
|
|
{
|
|
|
|
EE_SELECTION_TOOL* selectionTool = m_parent->GetToolManager()->GetTool<EE_SELECTION_TOOL>();
|
2021-02-14 23:38:52 +00:00
|
|
|
m_selection = selectionTool->GetSelection();
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
m_references->SetValue( g_modifyReferences );
|
|
|
|
m_values->SetValue( g_modifyValues );
|
|
|
|
m_otherFields->SetValue( g_modifyOtherFields );
|
|
|
|
m_wires->SetValue( g_modifyWires );
|
2020-04-02 13:58:35 +00:00
|
|
|
m_buses->SetValue( g_modifyBuses );
|
2019-06-30 22:06:34 +00:00
|
|
|
m_globalLabels->SetValue( g_modifyGlobalLabels );
|
|
|
|
m_hierLabels->SetValue( g_modifyHierLabels );
|
2023-01-23 19:58:53 +00:00
|
|
|
m_labelFields->SetValue( g_modifyLabelFields );
|
2019-06-30 22:06:34 +00:00
|
|
|
m_sheetTitles->SetValue( g_modifySheetTitles );
|
2020-04-02 12:57:07 +00:00
|
|
|
m_sheetFields->SetValue( g_modifyOtherSheetFields );
|
2019-06-30 22:06:34 +00:00
|
|
|
m_sheetPins->SetValue( g_modifySheetPins );
|
2020-04-02 12:57:07 +00:00
|
|
|
m_sheetBorders->SetValue( g_modifySheetBorders );
|
2019-06-30 22:06:34 +00:00
|
|
|
m_schTextAndGraphics->SetValue( g_modifySchTextAndGraphics );
|
|
|
|
|
|
|
|
// SetValue() generates events, ChangeValue() does not
|
|
|
|
m_fieldnameFilter->ChangeValue( g_fieldnameFilter );
|
|
|
|
m_fieldnameFilterOpt->SetValue( g_filterByFieldname );
|
|
|
|
m_referenceFilter->ChangeValue( g_referenceFilter );
|
|
|
|
m_referenceFilterOpt->SetValue( g_filterByReference );
|
|
|
|
m_symbolFilter->ChangeValue( g_symbolFilter );
|
|
|
|
m_symbolFilterOpt->SetValue( g_filterBySymbol );
|
2020-05-06 21:56:18 +00:00
|
|
|
m_typeFilter->SetSelection( g_typeFilterIsPower ? 1 : 0 );
|
|
|
|
m_typeFilterOpt->SetValue( g_filterByType );
|
2021-02-14 23:38:52 +00:00
|
|
|
m_selectedFilterOpt->SetValue( g_filterSelected );
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
if( g_filterByNet && !g_netFilter.IsEmpty() )
|
|
|
|
{
|
|
|
|
m_netFilter->SetValue( g_netFilter );
|
|
|
|
m_netFilterOpt->SetValue( true );
|
|
|
|
}
|
2023-05-17 00:06:21 +00:00
|
|
|
else if( !m_parent->GetHighlightedConnection().IsEmpty() )
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
2023-05-17 00:06:21 +00:00
|
|
|
m_netFilter->SetValue( m_parent->GetHighlightedConnection() );
|
2019-06-30 22:06:34 +00:00
|
|
|
}
|
2021-02-14 23:38:52 +00:00
|
|
|
else if( m_selection.GetSize() )
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
2021-02-14 23:38:52 +00:00
|
|
|
SCH_ITEM* sch_item = (SCH_ITEM*) m_selection.Front();
|
2020-10-07 14:40:12 +00:00
|
|
|
SCH_CONNECTION* connection = sch_item->Connection();
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
if( connection )
|
|
|
|
m_netFilter->SetValue( connection->Name() );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_netFilterOpt->SetValue( g_filterByNet );
|
|
|
|
|
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_textSize.SetValue( INDETERMINATE_ACTION );
|
|
|
|
m_orientation->SetStringSelection( INDETERMINATE_ACTION );
|
|
|
|
m_hAlign->SetStringSelection( INDETERMINATE_ACTION );
|
|
|
|
m_vAlign->SetStringSelection( INDETERMINATE_ACTION );
|
2022-01-11 15:34:24 +00:00
|
|
|
m_italic->Set3StateValue( wxCHK_UNDETERMINED );
|
|
|
|
m_bold->Set3StateValue( wxCHK_UNDETERMINED );
|
|
|
|
m_visible->Set3StateValue( wxCHK_UNDETERMINED );
|
2022-10-14 22:03:32 +00:00
|
|
|
m_showFieldNames->Set3StateValue( wxCHK_UNDETERMINED );
|
2020-05-05 15:40:18 +00:00
|
|
|
m_lineWidth.SetValue( INDETERMINATE_ACTION );
|
|
|
|
m_lineStyle->SetStringSelection( INDETERMINATE_ACTION );
|
2021-08-31 10:48:45 +00:00
|
|
|
m_junctionSize.SetValue( INDETERMINATE_ACTION );
|
2019-07-02 13:51:48 +00:00
|
|
|
m_setColor->SetValue( false );
|
2021-07-17 19:56:18 +00:00
|
|
|
m_setFillColor->SetValue( false );
|
2021-08-31 10:48:45 +00:00
|
|
|
m_setDotColor->SetValue( false );
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-09 21:41:33 +00:00
|
|
|
void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem( SCH_COMMIT* aCommit,
|
2023-06-07 22:45:06 +00:00
|
|
|
const SCH_SHEET_PATH& aSheetPath,
|
2021-09-04 17:05:57 +00:00
|
|
|
SCH_ITEM* aItem )
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
2021-09-04 17:05:57 +00:00
|
|
|
if( m_selectedFilterOpt->GetValue() )
|
2021-04-09 09:17:36 +00:00
|
|
|
{
|
2021-09-04 17:05:57 +00:00
|
|
|
if( !aItem->IsSelected() && ( !aItem->GetParent() || !aItem->GetParent()->IsSelected() ) )
|
|
|
|
return;
|
2021-04-09 09:17:36 +00:00
|
|
|
}
|
|
|
|
|
2023-06-07 22:45:06 +00:00
|
|
|
aCommit->Modify( aItem, aSheetPath.LastScreen() );
|
2020-05-30 23:01:24 +00:00
|
|
|
|
2022-10-14 22:03:32 +00:00
|
|
|
if( EDA_TEXT* eda_text = dynamic_cast<EDA_TEXT*>( aItem ) )
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
|
|
|
if( !m_textSize.IsIndeterminate() )
|
2023-02-19 03:40:07 +00:00
|
|
|
eda_text->SetTextSize( VECTOR2I( m_textSize.GetValue(), m_textSize.GetValue() ) );
|
2019-06-30 22:06:34 +00:00
|
|
|
|
2022-05-03 21:55:35 +00:00
|
|
|
if( m_setTextColor->GetValue() )
|
|
|
|
eda_text->SetTextColor( m_textColorSwatch->GetSwatchColor() );
|
|
|
|
|
2020-05-05 15:40:18 +00:00
|
|
|
if( m_hAlign->GetStringSelection() != INDETERMINATE_ACTION )
|
2022-05-23 23:05:06 +00:00
|
|
|
{
|
|
|
|
GR_TEXT_H_ALIGN_T hAlign = EDA_TEXT::MapHorizJustify( m_hAlign->GetSelection() - 1 );
|
2022-10-14 22:03:32 +00:00
|
|
|
SCH_SYMBOL* parentSymbol = dynamic_cast<SCH_SYMBOL*>( aItem->GetParent() );
|
2022-05-23 23:05:06 +00:00
|
|
|
|
2022-10-14 22:03:32 +00:00
|
|
|
if( parentSymbol && parentSymbol->GetTransform().x1 < 0 )
|
2022-05-23 23:05:06 +00:00
|
|
|
{
|
|
|
|
if( hAlign == GR_TEXT_H_ALIGN_LEFT )
|
|
|
|
hAlign = GR_TEXT_H_ALIGN_RIGHT;
|
|
|
|
else if( hAlign == GR_TEXT_H_ALIGN_RIGHT )
|
|
|
|
hAlign = GR_TEXT_H_ALIGN_LEFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
eda_text->SetHorizJustify( hAlign );
|
|
|
|
}
|
2019-06-30 22:06:34 +00:00
|
|
|
|
2021-02-25 11:52:04 +00:00
|
|
|
if( m_vAlign->GetStringSelection() != INDETERMINATE_ACTION )
|
2022-05-23 23:05:06 +00:00
|
|
|
{
|
|
|
|
GR_TEXT_V_ALIGN_T vAlign = EDA_TEXT::MapVertJustify( m_vAlign->GetSelection() - 1 );
|
2022-10-14 22:03:32 +00:00
|
|
|
SCH_SYMBOL* parentSymbol = dynamic_cast<SCH_SYMBOL*>( aItem->GetParent() );
|
2022-05-23 23:05:06 +00:00
|
|
|
|
2022-10-14 22:03:32 +00:00
|
|
|
if( parentSymbol && parentSymbol->GetTransform().y1 < 0 )
|
2022-05-23 23:05:06 +00:00
|
|
|
{
|
|
|
|
if( vAlign == GR_TEXT_V_ALIGN_TOP )
|
|
|
|
vAlign = GR_TEXT_V_ALIGN_BOTTOM;
|
|
|
|
else if( vAlign == GR_TEXT_V_ALIGN_BOTTOM )
|
|
|
|
vAlign = GR_TEXT_V_ALIGN_TOP;
|
|
|
|
}
|
|
|
|
|
|
|
|
eda_text->SetVertJustify( vAlign );
|
|
|
|
}
|
2019-06-30 22:06:34 +00:00
|
|
|
|
2022-01-11 15:34:24 +00:00
|
|
|
if( m_visible->Get3StateValue() != wxCHK_UNDETERMINED )
|
|
|
|
eda_text->SetVisible( m_visible->GetValue() );
|
2019-06-30 22:06:34 +00:00
|
|
|
|
2022-01-11 15:34:24 +00:00
|
|
|
if( m_italic->Get3StateValue() != wxCHK_UNDETERMINED )
|
|
|
|
eda_text->SetItalic( m_italic->GetValue() );
|
2019-06-30 22:06:34 +00:00
|
|
|
|
2024-02-25 17:28:05 +00:00
|
|
|
// Must come after SetTextSize()
|
2022-01-11 15:34:24 +00:00
|
|
|
if( m_bold->Get3StateValue() != wxCHK_UNDETERMINED )
|
|
|
|
eda_text->SetBold( m_bold->GetValue() );
|
|
|
|
|
2024-02-25 17:28:05 +00:00
|
|
|
// Must come after SetBold() & SetItalic()
|
2022-01-11 15:34:24 +00:00
|
|
|
if( m_fontCtrl->GetStringSelection() != INDETERMINATE_ACTION )
|
|
|
|
{
|
|
|
|
eda_text->SetFont( m_fontCtrl->GetFontSelection( eda_text->IsBold(),
|
|
|
|
eda_text->IsItalic() ) );
|
|
|
|
}
|
2022-04-26 11:51:39 +00:00
|
|
|
else if( m_italic->Get3StateValue() != wxCHK_UNDETERMINED
|
|
|
|
|| m_bold->Get3StateValue() != wxCHK_UNDETERMINED )
|
|
|
|
{
|
|
|
|
if( !eda_text->GetFontName().IsEmpty() )
|
|
|
|
{
|
|
|
|
eda_text->SetFont( KIFONT::FONT::GetFont( eda_text->GetFontName(),
|
|
|
|
eda_text->IsBold(),
|
|
|
|
eda_text->IsItalic() ) );
|
|
|
|
}
|
|
|
|
}
|
2019-06-30 22:06:34 +00:00
|
|
|
}
|
|
|
|
|
2023-09-07 16:09:53 +00:00
|
|
|
if( SCH_LABEL_BASE* sch_label = dynamic_cast<SCH_LABEL_BASE*>( aItem ) )
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
2020-05-05 15:40:18 +00:00
|
|
|
if( m_orientation->GetStringSelection() != INDETERMINATE_ACTION )
|
2023-09-07 16:09:53 +00:00
|
|
|
sch_label->SetSpinStyle( (SPIN_STYLE::SPIN) m_orientation->GetSelection() );
|
2019-06-30 22:06:34 +00:00
|
|
|
}
|
|
|
|
|
2022-10-14 22:03:32 +00:00
|
|
|
if( SCH_FIELD* sch_field = dynamic_cast<SCH_FIELD*>( aItem ) )
|
|
|
|
{
|
|
|
|
if( m_showFieldNames->Get3StateValue() != wxCHK_UNDETERMINED )
|
|
|
|
sch_field->SetNameShown( m_showFieldNames->GetValue() );
|
|
|
|
}
|
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
if( aItem->HasLineStroke() )
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
2021-07-17 19:56:18 +00:00
|
|
|
STROKE_PARAMS stroke = aItem->GetStroke();
|
|
|
|
|
2019-06-30 22:06:34 +00:00
|
|
|
if( !m_lineWidth.IsIndeterminate() )
|
2021-07-17 19:56:18 +00:00
|
|
|
stroke.SetWidth( m_lineWidth.GetValue() );
|
2019-07-02 13:51:48 +00:00
|
|
|
|
2020-05-30 22:49:12 +00:00
|
|
|
if( m_lineStyle->GetStringSelection() != INDETERMINATE_ACTION )
|
2019-07-02 13:51:48 +00:00
|
|
|
{
|
2020-09-18 22:04:10 +00:00
|
|
|
if( m_lineStyle->GetStringSelection() == DEFAULT_STYLE )
|
2023-11-25 13:05:45 +00:00
|
|
|
stroke.SetLineStyle( LINE_STYLE::DEFAULT );
|
2020-09-18 22:04:10 +00:00
|
|
|
else
|
2023-11-25 13:05:45 +00:00
|
|
|
stroke.SetLineStyle( (LINE_STYLE) m_lineStyle->GetSelection() );
|
2020-05-30 22:49:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_setColor->GetValue() )
|
2021-07-17 19:56:18 +00:00
|
|
|
stroke.SetColor( m_colorSwatch->GetSwatchColor() );
|
|
|
|
|
|
|
|
aItem->SetStroke( stroke );
|
|
|
|
}
|
|
|
|
|
2022-10-14 22:03:32 +00:00
|
|
|
if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( aItem ) )
|
2021-07-17 19:56:18 +00:00
|
|
|
{
|
|
|
|
if( m_setFillColor->GetValue() )
|
|
|
|
{
|
|
|
|
shape->SetFillColor( m_fillColorSwatch->GetSwatchColor() );
|
|
|
|
|
|
|
|
if( m_fillColorSwatch->GetSwatchColor() == COLOR4D::UNSPECIFIED )
|
|
|
|
shape->SetFillMode( FILL_T::NO_FILL );
|
|
|
|
else
|
|
|
|
shape->SetFillMode( FILL_T::FILLED_WITH_COLOR );
|
|
|
|
}
|
2019-06-30 22:06:34 +00:00
|
|
|
}
|
2021-08-31 10:48:45 +00:00
|
|
|
|
2022-10-14 22:03:32 +00:00
|
|
|
if( SCH_JUNCTION* junction = dynamic_cast<SCH_JUNCTION*>( aItem ) )
|
2021-08-31 10:48:45 +00:00
|
|
|
{
|
|
|
|
if( !m_junctionSize.IsIndeterminate() )
|
|
|
|
junction->SetDiameter( m_junctionSize.GetValue() );
|
|
|
|
|
|
|
|
if( m_setDotColor->GetValue() )
|
|
|
|
junction->SetColor( m_dotColorSwatch->GetSwatchColor() );
|
|
|
|
}
|
2019-06-30 22:06:34 +00:00
|
|
|
}
|
|
|
|
|
2023-06-09 21:41:33 +00:00
|
|
|
void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( SCH_COMMIT* aCommit,
|
2023-06-07 22:45:06 +00:00
|
|
|
const SCH_SHEET_PATH& aSheetPath,
|
2019-06-30 22:06:34 +00:00
|
|
|
SCH_ITEM* aItem )
|
|
|
|
{
|
|
|
|
if( m_netFilterOpt->GetValue() && !m_netFilter->GetValue().IsEmpty() )
|
|
|
|
{
|
2020-10-07 14:40:12 +00:00
|
|
|
SCH_CONNECTION* connection = aItem->Connection( &aSheetPath );
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
if( !connection )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( !WildCompareString( m_netFilter->GetValue(), connection->Name(), false ) )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_referenceFilterOpt->GetValue() && !m_referenceFilter->GetValue().IsEmpty() )
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
if( aItem->Type() == SCH_SYMBOL_T )
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
wxString ref = static_cast<SCH_SYMBOL*>( aItem )->GetRef( &aSheetPath );
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
if( !WildCompareString( m_referenceFilter->GetValue(), ref, false ) )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_symbolFilterOpt->GetValue() && !m_symbolFilter->GetValue().IsEmpty() )
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
if( aItem->Type() == SCH_SYMBOL_T )
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
2021-07-28 15:39:40 +00:00
|
|
|
wxString id = UnescapeString( static_cast<SCH_SYMBOL*>( aItem )->GetLibId().Format() );
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
if( !WildCompareString( m_symbolFilter->GetValue(), id, false ) )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-06 21:56:18 +00:00
|
|
|
if( m_typeFilterOpt->GetValue() )
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
if( aItem->Type() == SCH_SYMBOL_T )
|
2020-05-06 21:56:18 +00:00
|
|
|
{
|
2024-06-12 17:27:17 +00:00
|
|
|
bool isPower = static_cast<SCH_SYMBOL*>( aItem )->GetLibSymbolRef()->IsPower();
|
2020-05-06 21:56:18 +00:00
|
|
|
|
|
|
|
if( isPower != ( m_typeFilter->GetSelection() == 1 ) )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-16 13:11:10 +00:00
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
|
|
|
case SCH_SYMBOL_T:
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = (SCH_SYMBOL*) aItem;
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
if( m_references->GetValue() )
|
2023-06-07 22:45:06 +00:00
|
|
|
processItem( aCommit, aSheetPath, symbol->GetField( REFERENCE_FIELD ) );
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
if( m_values->GetValue() )
|
2023-06-07 22:45:06 +00:00
|
|
|
processItem( aCommit, aSheetPath, symbol->GetField( VALUE_FIELD ) );
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
if( m_otherFields->GetValue() )
|
|
|
|
{
|
2021-05-05 21:41:51 +00:00
|
|
|
for( int i = 2; i < symbol->GetFieldCount(); ++i )
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
2021-05-05 21:41:51 +00:00
|
|
|
SCH_FIELD& field = symbol->GetFields()[i];
|
2021-02-28 13:28:23 +00:00
|
|
|
const wxString& fieldName = field.GetName();
|
2019-06-30 22:06:34 +00:00
|
|
|
|
|
|
|
if( !m_fieldnameFilterOpt->GetValue() || m_fieldnameFilter->GetValue().IsEmpty()
|
|
|
|
|| WildCompareString( m_fieldnameFilter->GetValue(), fieldName, false ) )
|
|
|
|
{
|
2023-06-07 22:45:06 +00:00
|
|
|
processItem( aCommit, aSheetPath, &field );
|
2019-06-30 22:06:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-16 13:11:10 +00:00
|
|
|
|
|
|
|
break;
|
2019-06-30 22:06:34 +00:00
|
|
|
}
|
2023-07-16 13:11:10 +00:00
|
|
|
|
|
|
|
case SCH_SHEET_T:
|
2020-04-02 12:57:07 +00:00
|
|
|
{
|
|
|
|
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
|
|
|
|
|
|
|
|
if( m_sheetTitles->GetValue() )
|
2023-06-07 22:45:06 +00:00
|
|
|
processItem( aCommit, aSheetPath, &sheet->GetFields()[SHEETNAME] );
|
2020-04-02 12:57:07 +00:00
|
|
|
|
|
|
|
if( m_sheetFields->GetValue() )
|
|
|
|
{
|
|
|
|
for( SCH_FIELD& field : sheet->GetFields() )
|
|
|
|
{
|
|
|
|
if( field.GetId() == SHEETNAME )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const wxString& fieldName = field.GetName();
|
|
|
|
|
|
|
|
if( !m_fieldnameFilterOpt->GetValue() || m_fieldnameFilter->GetValue().IsEmpty()
|
|
|
|
|| WildCompareString( m_fieldnameFilter->GetValue(), fieldName, false ) )
|
|
|
|
{
|
2023-06-07 22:45:06 +00:00
|
|
|
processItem( aCommit, aSheetPath, &field );
|
2020-04-02 12:57:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_sheetBorders->GetValue() )
|
|
|
|
{
|
|
|
|
if( !m_lineWidth.IsIndeterminate() )
|
|
|
|
sheet->SetBorderWidth( m_lineWidth.GetValue() );
|
|
|
|
|
|
|
|
if( m_setColor->GetValue() )
|
|
|
|
sheet->SetBorderColor( m_colorSwatch->GetSwatchColor() );
|
|
|
|
|
2021-07-17 19:56:18 +00:00
|
|
|
if( m_setFillColor->GetValue() )
|
|
|
|
sheet->SetBackgroundColor( m_fillColorSwatch->GetSwatchColor() );
|
2020-04-02 12:57:07 +00:00
|
|
|
}
|
2022-03-31 21:09:35 +00:00
|
|
|
|
|
|
|
if( m_sheetPins->GetValue() )
|
|
|
|
{
|
|
|
|
for( SCH_SHEET_PIN* pin : sheet->GetPins() )
|
2023-06-07 22:45:06 +00:00
|
|
|
processItem( aCommit, aSheetPath, pin );
|
2022-03-31 21:09:35 +00:00
|
|
|
}
|
2023-07-16 13:11:10 +00:00
|
|
|
|
|
|
|
break;
|
2020-04-02 12:57:07 +00:00
|
|
|
}
|
2023-07-16 13:11:10 +00:00
|
|
|
|
|
|
|
case SCH_LINE_T:
|
2023-07-16 19:19:09 +00:00
|
|
|
if( m_schTextAndGraphics->GetValue() && aItem->GetLayer() == LAYER_NOTES )
|
2023-07-16 13:11:10 +00:00
|
|
|
processItem( aCommit, aSheetPath, aItem );
|
2023-07-16 19:19:09 +00:00
|
|
|
else if( m_wires->GetValue() && aItem->GetLayer() == LAYER_WIRE )
|
2023-07-16 13:11:10 +00:00
|
|
|
processItem( aCommit, aSheetPath, aItem );
|
2023-07-16 19:19:09 +00:00
|
|
|
else if( m_buses->GetValue() && aItem->GetLayer() == LAYER_BUS )
|
2023-07-16 13:11:10 +00:00
|
|
|
processItem( aCommit, aSheetPath, aItem );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIER_LABEL_T:
|
|
|
|
case SCH_DIRECTIVE_LABEL_T:
|
2023-07-16 19:19:09 +00:00
|
|
|
if( m_wires->GetValue() && aItem->IsType( { SCH_LABEL_LOCATE_WIRE_T } ) )
|
|
|
|
processItem( aCommit, aSheetPath, aItem );
|
|
|
|
|
|
|
|
if( m_buses->GetValue() && aItem->IsType( { SCH_LABEL_LOCATE_BUS_T } ) )
|
|
|
|
processItem( aCommit, aSheetPath, aItem );
|
|
|
|
|
2023-01-23 19:58:53 +00:00
|
|
|
if( m_globalLabels->GetValue() && aItem->Type() == SCH_GLOBAL_LABEL_T )
|
2023-06-07 22:45:06 +00:00
|
|
|
processItem( aCommit, aSheetPath, aItem );
|
2023-01-23 19:58:53 +00:00
|
|
|
|
|
|
|
if( m_hierLabels->GetValue() && aItem->Type() == SCH_HIER_LABEL_T )
|
2023-06-07 22:45:06 +00:00
|
|
|
processItem( aCommit, aSheetPath, aItem );
|
2023-01-23 19:58:53 +00:00
|
|
|
|
|
|
|
if( m_labelFields->GetValue() )
|
|
|
|
{
|
|
|
|
for( SCH_FIELD& field : static_cast<SCH_LABEL_BASE*>( aItem )->GetFields() )
|
|
|
|
{
|
|
|
|
const wxString& fieldName = field.GetName();
|
|
|
|
|
|
|
|
if( !m_fieldnameFilterOpt->GetValue() || m_fieldnameFilter->GetValue().IsEmpty()
|
|
|
|
|| WildCompareString( m_fieldnameFilter->GetValue(), fieldName, false ) )
|
|
|
|
{
|
2023-06-07 22:45:06 +00:00
|
|
|
processItem( aCommit, aSheetPath, &field );
|
2023-01-23 19:58:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-16 13:11:10 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCH_JUNCTION_T:
|
2020-11-03 13:39:31 +00:00
|
|
|
{
|
|
|
|
SCH_JUNCTION* junction = static_cast<SCH_JUNCTION*>( aItem );
|
|
|
|
|
|
|
|
for( SCH_ITEM* item : junction->ConnectedItems( aSheetPath ) )
|
|
|
|
{
|
2021-08-31 10:48:45 +00:00
|
|
|
if( item->GetLayer() == LAYER_BUS && m_buses->GetValue() )
|
2020-11-03 13:39:31 +00:00
|
|
|
{
|
2023-06-07 22:45:06 +00:00
|
|
|
processItem( aCommit, aSheetPath, aItem );
|
2020-11-03 13:39:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-08-31 10:48:45 +00:00
|
|
|
else if( item->GetLayer() == LAYER_WIRE && m_wires->GetValue() )
|
2020-11-03 13:39:31 +00:00
|
|
|
{
|
2023-06-07 22:45:06 +00:00
|
|
|
processItem( aCommit, aSheetPath, aItem );
|
2020-11-03 13:39:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-07-16 13:11:10 +00:00
|
|
|
|
|
|
|
break;
|
2020-11-03 13:39:31 +00:00
|
|
|
}
|
2023-07-16 13:11:10 +00:00
|
|
|
|
|
|
|
case SCH_TEXT_T:
|
|
|
|
case SCH_TEXTBOX_T:
|
|
|
|
case SCH_SHAPE_T:
|
|
|
|
if( m_schTextAndGraphics->GetValue() )
|
|
|
|
processItem( aCommit, aSheetPath, aItem );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2022-08-20 09:27:35 +00:00
|
|
|
}
|
2019-06-30 22:06:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow()
|
|
|
|
{
|
2020-10-02 22:04:16 +00:00
|
|
|
if( !m_textSize.Validate( 1.0, 10000.0, EDA_UNITS::MILS ) ) // 1 mil .. 10 inches
|
2019-06-30 22:06:34 +00:00
|
|
|
return false;
|
|
|
|
|
2023-06-09 21:41:33 +00:00
|
|
|
SCH_SHEET_PATH currentSheet = m_parent->GetCurrentSheet();
|
|
|
|
SCH_COMMIT commit( m_parent );
|
2020-05-30 23:01:24 +00:00
|
|
|
|
2019-06-30 22:06:34 +00:00
|
|
|
// Go through sheets
|
2024-06-06 16:58:48 +00:00
|
|
|
for( const SCH_SHEET_PATH& sheetPath : m_parent->Schematic().BuildUnorderedSheetList() )
|
2019-06-30 22:06:34 +00:00
|
|
|
{
|
|
|
|
SCH_SCREEN* screen = sheetPath.LastScreen();
|
|
|
|
|
|
|
|
if( screen )
|
|
|
|
{
|
2020-05-30 23:01:24 +00:00
|
|
|
m_parent->SetCurrentSheet( sheetPath );
|
2020-02-04 13:01:06 +00:00
|
|
|
|
2021-04-16 16:32:59 +00:00
|
|
|
for( SCH_ITEM* item : screen->Items() )
|
2023-06-07 22:45:06 +00:00
|
|
|
visitItem( &commit, sheetPath, item );
|
2019-06-30 22:06:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-07 22:45:06 +00:00
|
|
|
if( !commit.Empty() )
|
2021-06-30 17:44:39 +00:00
|
|
|
{
|
2024-03-09 13:50:26 +00:00
|
|
|
commit.Push( _( "Edit Text and Graphics" ) );
|
2021-06-30 17:44:39 +00:00
|
|
|
m_parent->HardRedraw();
|
|
|
|
}
|
|
|
|
|
2020-05-30 23:01:24 +00:00
|
|
|
// Reset the view to where we left the user
|
|
|
|
m_parent->SetCurrentSheet( currentSheet );
|
2023-07-16 13:11:10 +00:00
|
|
|
m_parent->Refresh();
|
2020-05-30 23:01:24 +00:00
|
|
|
|
2019-06-30 22:06:34 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_EDIT_TOOL::GlobalEdit( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS dlg( m_frame );
|
|
|
|
dlg.ShowModal();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|