2018-03-28 17:14:04 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2022-09-19 09:25:20 +00:00
|
|
|
* Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-03-28 17:14:04 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <kiway_player.h>
|
2023-06-13 16:56:24 +00:00
|
|
|
#include <project.h>
|
2021-02-02 23:16:37 +00:00
|
|
|
#include <fp_text_grid_table.h>
|
2018-03-28 17:14:04 +00:00
|
|
|
#include <widgets/grid_icon_text_helpers.h>
|
|
|
|
#include <widgets/grid_combobox.h>
|
2020-10-14 03:37:48 +00:00
|
|
|
#include <trigo.h>
|
2021-12-22 21:43:41 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2023-03-30 11:49:23 +00:00
|
|
|
#include <footprint.h>
|
2018-03-28 17:14:04 +00:00
|
|
|
#include "grid_layer_box_helpers.h"
|
2023-06-13 16:56:24 +00:00
|
|
|
#include "widgets/grid_text_button_helpers.h"
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MYID_SELECT_FOOTPRINT = 991, // must be within GRID_TRICKS' enum range
|
|
|
|
MYID_SHOW_DATASHEET
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
wxArrayString g_menuOrientations;
|
|
|
|
|
|
|
|
|
2023-06-13 16:56:24 +00:00
|
|
|
FP_TEXT_GRID_TABLE::FP_TEXT_GRID_TABLE( PCB_BASE_FRAME* aFrame, DIALOG_SHIM* aDialog ) :
|
|
|
|
m_frame( aFrame ),
|
|
|
|
m_dialog( aDialog ),
|
|
|
|
m_fieldNameValidator( FIELD_NAME ),
|
|
|
|
m_referenceValidator( REFERENCE_FIELD ),
|
|
|
|
m_valueValidator( VALUE_FIELD ),
|
|
|
|
m_urlValidator( FIELD_VALUE ),
|
|
|
|
m_nonUrlValidator( FIELD_VALUE )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
|
|
|
// Build the column attributes.
|
|
|
|
|
|
|
|
m_readOnlyAttr = new wxGridCellAttr;
|
|
|
|
m_readOnlyAttr->SetReadOnly( true );
|
|
|
|
|
|
|
|
m_boolColAttr = new wxGridCellAttr;
|
|
|
|
m_boolColAttr->SetRenderer( new wxGridCellBoolRenderer() );
|
|
|
|
m_boolColAttr->SetEditor( new wxGridCellBoolEditor() );
|
2020-09-04 13:41:36 +00:00
|
|
|
m_boolColAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_CENTER );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
if( g_menuOrientations.IsEmpty() )
|
|
|
|
{
|
2022-09-19 09:25:20 +00:00
|
|
|
g_menuOrientations.push_back( "0" + EDA_UNIT_UTILS::GetText( EDA_UNITS::DEGREES ) );
|
|
|
|
g_menuOrientations.push_back( "90" + EDA_UNIT_UTILS::GetText( EDA_UNITS::DEGREES ) );
|
|
|
|
g_menuOrientations.push_back( "-90" + EDA_UNIT_UTILS::GetText( EDA_UNITS::DEGREES ) );
|
|
|
|
g_menuOrientations.push_back( "180" + EDA_UNIT_UTILS::GetText( EDA_UNITS::DEGREES ) );
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_orientationColAttr = new wxGridCellAttr;
|
|
|
|
m_orientationColAttr->SetEditor( new GRID_CELL_COMBOBOX( g_menuOrientations ) );
|
|
|
|
|
|
|
|
m_layerColAttr = new wxGridCellAttr;
|
|
|
|
m_layerColAttr->SetRenderer( new GRID_CELL_LAYER_RENDERER( m_frame ) );
|
2020-10-13 17:46:48 +00:00
|
|
|
m_layerColAttr->SetEditor( new GRID_CELL_LAYER_SELECTOR( m_frame, {} ) );
|
2021-12-22 21:43:41 +00:00
|
|
|
|
2023-06-13 16:56:24 +00:00
|
|
|
m_referenceAttr = new wxGridCellAttr;
|
|
|
|
GRID_CELL_TEXT_EDITOR* referenceEditor = new GRID_CELL_TEXT_EDITOR();
|
|
|
|
referenceEditor->SetValidator( m_referenceValidator );
|
|
|
|
m_referenceAttr->SetEditor( referenceEditor );
|
|
|
|
|
|
|
|
m_valueAttr = new wxGridCellAttr;
|
|
|
|
GRID_CELL_TEXT_EDITOR* valueEditor = new GRID_CELL_TEXT_EDITOR();
|
|
|
|
valueEditor->SetValidator( m_valueValidator );
|
|
|
|
m_valueAttr->SetEditor( valueEditor );
|
|
|
|
|
|
|
|
m_footprintAttr = new wxGridCellAttr;
|
2023-10-23 10:53:25 +00:00
|
|
|
|
|
|
|
if( !m_frame->IsType( FRAME_FOOTPRINT_EDITOR ) )
|
|
|
|
m_footprintAttr->SetReadOnly( true );
|
|
|
|
|
2023-06-13 16:56:24 +00:00
|
|
|
GRID_CELL_FPID_EDITOR* fpIdEditor = new GRID_CELL_FPID_EDITOR( m_dialog, "" );
|
|
|
|
fpIdEditor->SetValidator( m_nonUrlValidator );
|
|
|
|
m_footprintAttr->SetEditor( fpIdEditor );
|
|
|
|
|
|
|
|
m_urlAttr = new wxGridCellAttr;
|
|
|
|
GRID_CELL_URL_EDITOR* urlEditor = new GRID_CELL_URL_EDITOR( m_dialog );
|
|
|
|
urlEditor->SetValidator( m_urlValidator );
|
|
|
|
m_urlAttr->SetEditor( urlEditor );
|
|
|
|
|
2022-10-11 17:01:47 +00:00
|
|
|
m_eval = std::make_unique<NUMERIC_EVALUATOR>( m_frame->GetUserUnits() );
|
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
m_frame->Bind( EDA_EVT_UNITS_CHANGED, &FP_TEXT_GRID_TABLE::onUnitsChanged, this );
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
FP_TEXT_GRID_TABLE::~FP_TEXT_GRID_TABLE()
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
|
|
|
m_readOnlyAttr->DecRef();
|
|
|
|
m_boolColAttr->DecRef();
|
|
|
|
m_orientationColAttr->DecRef();
|
|
|
|
m_layerColAttr->DecRef();
|
2023-06-13 16:56:24 +00:00
|
|
|
m_referenceAttr->DecRef();
|
|
|
|
m_valueAttr->DecRef();
|
|
|
|
m_footprintAttr->DecRef();
|
|
|
|
m_urlAttr->DecRef();
|
2021-12-22 21:43:41 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
m_frame->Unbind( EDA_EVT_UNITS_CHANGED, &FP_TEXT_GRID_TABLE::onUnitsChanged, this );
|
2021-12-22 21:43:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FP_TEXT_GRID_TABLE::onUnitsChanged( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( GetView() )
|
|
|
|
GetView()->ForceRefresh();
|
|
|
|
|
|
|
|
aEvent.Skip();
|
2018-03-28 17:14:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
wxString FP_TEXT_GRID_TABLE::GetColLabelValue( int aCol )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
|
|
|
switch( aCol )
|
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
case FPT_NAME: return _( "Name" );
|
|
|
|
case FPT_VALUE: return _( "Value" );
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_SHOWN: return _( "Show" );
|
|
|
|
case FPT_WIDTH: return _( "Width" );
|
|
|
|
case FPT_HEIGHT: return _( "Height" );
|
|
|
|
case FPT_THICKNESS: return _( "Thickness" );
|
|
|
|
case FPT_ITALIC: return _( "Italic" );
|
|
|
|
case FPT_LAYER: return _( "Layer" );
|
|
|
|
case FPT_ORIENTATION: return _( "Orientation" );
|
|
|
|
case FPT_UPRIGHT: return _( "Keep Upright" );
|
|
|
|
case FPT_XOFFSET: return _( "X Offset" );
|
|
|
|
case FPT_YOFFSET: return _( "Y Offset" );
|
2023-05-03 16:41:26 +00:00
|
|
|
case FPT_KNOCKOUT: return _( "Knockout" );
|
2018-03-28 17:14:04 +00:00
|
|
|
default: wxFAIL; return wxEmptyString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
bool FP_TEXT_GRID_TABLE::CanGetValueAs( int aRow, int aCol, const wxString& aTypeName )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
|
|
|
switch( aCol )
|
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
case FPT_NAME:
|
|
|
|
case FPT_VALUE:
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_WIDTH:
|
|
|
|
case FPT_HEIGHT:
|
|
|
|
case FPT_THICKNESS:
|
|
|
|
case FPT_ORIENTATION:
|
|
|
|
case FPT_XOFFSET:
|
|
|
|
case FPT_YOFFSET:
|
2018-03-28 17:14:04 +00:00
|
|
|
return aTypeName == wxGRID_VALUE_STRING;
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_SHOWN:
|
|
|
|
case FPT_ITALIC:
|
|
|
|
case FPT_UPRIGHT:
|
2023-05-03 16:41:26 +00:00
|
|
|
case FPT_KNOCKOUT:
|
2018-03-28 17:14:04 +00:00
|
|
|
return aTypeName == wxGRID_VALUE_BOOL;
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_LAYER:
|
2018-03-28 17:14:04 +00:00
|
|
|
return aTypeName == wxGRID_VALUE_NUMBER;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxFAIL;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
bool FP_TEXT_GRID_TABLE::CanSetValueAs( int aRow, int aCol, const wxString& aTypeName )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
|
|
|
return CanGetValueAs( aRow, aCol, aTypeName );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
wxGridCellAttr* FP_TEXT_GRID_TABLE::GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
|
|
|
switch( aCol )
|
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
case FPT_NAME:
|
2023-06-13 13:47:36 +00:00
|
|
|
if( aRow < MANDATORY_FIELDS )
|
2023-05-24 12:39:25 +00:00
|
|
|
{
|
|
|
|
m_readOnlyAttr->IncRef();
|
|
|
|
return m_readOnlyAttr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
case FPT_VALUE:
|
2023-06-13 16:56:24 +00:00
|
|
|
if( aRow == REFERENCE_FIELD )
|
|
|
|
{
|
|
|
|
m_referenceAttr->IncRef();
|
|
|
|
return m_referenceAttr;
|
|
|
|
}
|
|
|
|
else if( aRow == VALUE_FIELD )
|
|
|
|
{
|
|
|
|
m_valueAttr->IncRef();
|
|
|
|
return m_valueAttr;
|
|
|
|
}
|
|
|
|
else if( aRow == FOOTPRINT_FIELD )
|
|
|
|
{
|
|
|
|
m_footprintAttr->IncRef();
|
|
|
|
return m_footprintAttr;
|
|
|
|
}
|
|
|
|
else if( aRow == DATASHEET_FIELD )
|
|
|
|
{
|
|
|
|
m_urlAttr->IncRef();
|
|
|
|
return m_urlAttr;
|
|
|
|
}
|
|
|
|
|
2023-06-20 23:23:10 +00:00
|
|
|
return nullptr;
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_WIDTH:
|
|
|
|
case FPT_HEIGHT:
|
|
|
|
case FPT_THICKNESS:
|
|
|
|
case FPT_XOFFSET:
|
|
|
|
case FPT_YOFFSET:
|
2018-03-28 17:14:04 +00:00
|
|
|
return nullptr;
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_SHOWN:
|
|
|
|
case FPT_ITALIC:
|
|
|
|
case FPT_UPRIGHT:
|
2023-05-03 16:41:26 +00:00
|
|
|
case FPT_KNOCKOUT:
|
2018-03-28 17:14:04 +00:00
|
|
|
m_boolColAttr->IncRef();
|
|
|
|
return m_boolColAttr;
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_LAYER:
|
2018-03-28 17:14:04 +00:00
|
|
|
m_layerColAttr->IncRef();
|
|
|
|
return m_layerColAttr;
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_ORIENTATION:
|
2018-03-28 17:14:04 +00:00
|
|
|
m_orientationColAttr->IncRef();
|
|
|
|
return m_orientationColAttr;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxFAIL;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
wxString FP_TEXT_GRID_TABLE::GetValue( int aRow, int aCol )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
wxGrid* grid = GetView();
|
2023-05-24 12:39:25 +00:00
|
|
|
const PCB_FIELD* field = this->at( (size_t) aRow );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2022-10-11 17:01:47 +00:00
|
|
|
if( grid->GetGridCursorRow() == aRow && grid->GetGridCursorCol() == aCol
|
|
|
|
&& grid->IsCellEditControlShown() )
|
|
|
|
{
|
|
|
|
auto it = m_evalOriginal.find( { aRow, aCol } );
|
|
|
|
|
|
|
|
if( it != m_evalOriginal.end() )
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
switch( aCol )
|
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
case FPT_NAME:
|
|
|
|
return field->GetName();
|
|
|
|
|
|
|
|
case FPT_VALUE:
|
|
|
|
return field->GetText();
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_WIDTH:
|
2023-05-24 12:39:25 +00:00
|
|
|
return m_frame->StringFromValue( field->GetTextWidth(), true );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_HEIGHT:
|
2023-05-24 12:39:25 +00:00
|
|
|
return m_frame->StringFromValue( field->GetTextHeight(), true );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_THICKNESS:
|
2023-05-24 12:39:25 +00:00
|
|
|
return m_frame->StringFromValue( field->GetTextThickness(), true );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_LAYER:
|
2023-05-24 12:39:25 +00:00
|
|
|
return field->GetLayerName();
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_ORIENTATION:
|
2023-03-30 11:49:23 +00:00
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
EDA_ANGLE angle = field->GetTextAngle() - field->GetParentFootprint()->GetOrientation();
|
2023-03-30 11:49:23 +00:00
|
|
|
return m_frame->StringFromValue( angle, true );
|
|
|
|
}
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_XOFFSET:
|
2023-05-24 12:39:25 +00:00
|
|
|
return m_frame->StringFromValue( field->GetFPRelativePosition().x, true );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_YOFFSET:
|
2023-05-24 12:39:25 +00:00
|
|
|
return m_frame->StringFromValue( field->GetFPRelativePosition().y, true );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
// we can't assert here because wxWidgets sometimes calls this without checking
|
|
|
|
// the column type when trying to see if there's an overflow
|
|
|
|
return wxT( "bad wxWidgets!" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
bool FP_TEXT_GRID_TABLE::GetValueAsBool( int aRow, int aCol )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
PCB_FIELD* field = this->at( (size_t) aRow );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
switch( aCol )
|
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
case FPT_SHOWN: return field->IsVisible();
|
|
|
|
case FPT_ITALIC: return field->IsItalic();
|
|
|
|
case FPT_UPRIGHT: return field->IsKeepUpright();
|
|
|
|
case FPT_KNOCKOUT: return field->IsKnockout();
|
2021-12-05 21:56:55 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
default:
|
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
long FP_TEXT_GRID_TABLE::GetValueAsLong( int aRow, int aCol )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
PCB_FIELD* field = this->at( (size_t) aRow );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
switch( aCol )
|
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
case FPT_LAYER: return field->GetLayer();
|
2021-12-05 21:56:55 +00:00
|
|
|
|
2018-03-28 17:14:04 +00:00
|
|
|
default:
|
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a long value" ), aCol ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
void FP_TEXT_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
PCB_FIELD* field = this->at( (size_t) aRow );
|
2023-03-30 11:49:23 +00:00
|
|
|
VECTOR2I pos;
|
|
|
|
wxString value = aValue;
|
2022-10-11 17:01:47 +00:00
|
|
|
|
|
|
|
switch( aCol )
|
|
|
|
{
|
|
|
|
case FPT_WIDTH:
|
|
|
|
case FPT_HEIGHT:
|
|
|
|
case FPT_THICKNESS:
|
|
|
|
case FPT_XOFFSET:
|
|
|
|
case FPT_YOFFSET:
|
|
|
|
m_eval->SetDefaultUnits( m_frame->GetUserUnits() );
|
|
|
|
|
|
|
|
if( m_eval->Process( value ) )
|
|
|
|
{
|
|
|
|
m_evalOriginal[ { aRow, aCol } ] = value;
|
|
|
|
value = m_eval->Result();
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
switch( aCol )
|
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
case FPT_NAME:
|
|
|
|
field->SetName( value );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FPT_VALUE:
|
|
|
|
field->SetText( value );
|
2018-03-28 17:14:04 +00:00
|
|
|
break;
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_WIDTH:
|
2023-05-24 12:39:25 +00:00
|
|
|
field->SetTextWidth( m_frame->ValueFromString( value ) );
|
2018-03-28 17:14:04 +00:00
|
|
|
break;
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_HEIGHT:
|
2023-05-24 12:39:25 +00:00
|
|
|
field->SetTextHeight( m_frame->ValueFromString( value ) );
|
2018-03-28 17:14:04 +00:00
|
|
|
break;
|
|
|
|
|
2022-10-05 16:42:03 +00:00
|
|
|
case FPT_THICKNESS:
|
2023-05-24 12:39:25 +00:00
|
|
|
field->SetTextThickness( m_frame->ValueFromString( value ) );
|
2018-03-28 17:14:04 +00:00
|
|
|
break;
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_ORIENTATION:
|
2023-05-24 12:39:25 +00:00
|
|
|
field->SetTextAngle( m_frame->AngleValueFromString( value )
|
|
|
|
+ field->GetParentFootprint()->GetOrientation() );
|
2018-03-28 17:14:04 +00:00
|
|
|
break;
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_XOFFSET:
|
|
|
|
case FPT_YOFFSET:
|
2023-05-24 12:39:25 +00:00
|
|
|
pos = field->GetFPRelativePosition();
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
if( aCol == FPT_XOFFSET )
|
2022-10-11 17:01:47 +00:00
|
|
|
pos.x = m_frame->ValueFromString( value );
|
2018-03-28 17:14:04 +00:00
|
|
|
else
|
2022-10-11 17:01:47 +00:00
|
|
|
pos.y = m_frame->ValueFromString( value );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
2023-05-24 12:39:25 +00:00
|
|
|
field->SetFPRelativePosition( pos );
|
2018-03-28 17:14:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetView()->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
void FP_TEXT_GRID_TABLE::SetValueAsBool( int aRow, int aCol, bool aValue )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
PCB_FIELD* field = this->at( (size_t) aRow );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
switch( aCol )
|
|
|
|
{
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_SHOWN:
|
2023-05-24 12:39:25 +00:00
|
|
|
field->SetVisible( aValue );
|
2018-03-28 17:14:04 +00:00
|
|
|
break;
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_ITALIC:
|
2023-05-24 12:39:25 +00:00
|
|
|
field->SetItalic( aValue );
|
2018-03-28 17:14:04 +00:00
|
|
|
break;
|
|
|
|
|
2023-05-03 16:41:26 +00:00
|
|
|
case FPT_UPRIGHT:
|
2023-05-24 12:39:25 +00:00
|
|
|
field->SetKeepUpright( aValue );
|
2023-05-03 16:41:26 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FPT_KNOCKOUT:
|
2023-05-24 12:39:25 +00:00
|
|
|
field->SetIsKnockout( aValue );
|
2018-03-28 17:14:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-02 23:16:37 +00:00
|
|
|
void FP_TEXT_GRID_TABLE::SetValueAsLong( int aRow, int aCol, long aValue )
|
2018-03-28 17:14:04 +00:00
|
|
|
{
|
2023-05-24 12:39:25 +00:00
|
|
|
PCB_FIELD* field = this->at( (size_t) aRow );
|
2018-03-28 17:14:04 +00:00
|
|
|
|
|
|
|
switch( aCol )
|
|
|
|
{
|
2021-02-02 23:16:37 +00:00
|
|
|
case FPT_LAYER:
|
2023-05-24 12:39:25 +00:00
|
|
|
field->SetLayer( ToLAYER_ID( (int) aValue ) );
|
|
|
|
field->SetMirrored( IsBackLayer( field->GetLayer() ) );
|
2018-03-28 17:14:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a long value" ), aCol ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|