7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-19 14:01:41 +00:00

ADDED: PCB tables.

This commit is contained in:
Jeff Young 2024-01-15 17:29:55 +00:00
parent 48f983826d
commit e445249720
74 changed files with 11148 additions and 4194 deletions
3d-viewer/3d_canvas
common
eeschema
include
pcbnew

View File

@ -42,6 +42,8 @@
#include <pcb_track.h>
#include <pcb_base_frame.h>
#include <pcb_text.h>
#include <pcb_textbox.h>
#include <pcb_table.h>
#include <pcb_shape.h>
#include <pcb_dimension.h>
#include <zone.h>
@ -376,6 +378,9 @@ private:
void addShape( const PCB_TEXTBOX* aTextBox, CONTAINER_2D_BASE* aContainer,
const BOARD_ITEM* aOwner );
void addTable( const PCB_TABLE* aTable, CONTAINER_2D_BASE* aContainer,
const BOARD_ITEM* aOwner );
void addSolidAreasShapes( const ZONE* aZone, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId );

View File

@ -38,6 +38,7 @@
#include <pad.h>
#include <pcb_text.h>
#include <pcb_textbox.h>
#include <pcb_table.h>
#include <board_design_settings.h>
#include <pcb_painter.h> // for PCB_RENDER_SETTINGS
#include <zone.h>
@ -225,12 +226,17 @@ void BOARD_ADAPTER::addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2
PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( item );
if( textbox->GetLayer() == aLayerId )
{
if( textbox->IsBorderEnabled() )
addShape( textbox, aContainer, aFootprint );
addShape( textbox, aContainer, aFootprint );
addText( textbox, aContainer, aFootprint );
}
break;
}
case PCB_TABLE_T:
{
PCB_TABLE* table = static_cast<PCB_TABLE*>( item );
if( table->GetLayer() == aLayerId )
addTable( table, aContainer, aFootprint );
break;
}
@ -726,7 +732,9 @@ void BOARD_ADAPTER::addShape( const PCB_TEXTBOX* aTextBox, CONTAINER_2D_BASE* aC
// So for polygon, we use PCB_SHAPE::TransformShapeToPolygon
if( aTextBox->GetShape() == SHAPE_T::RECTANGLE )
{
addShape( static_cast<const PCB_SHAPE*>( aTextBox ), aContainer, aOwner );
}
else
{
SHAPE_POLY_SET polyList;
@ -739,6 +747,17 @@ void BOARD_ADAPTER::addShape( const PCB_TEXTBOX* aTextBox, CONTAINER_2D_BASE* aC
}
void BOARD_ADAPTER::addTable( const PCB_TABLE* aTable, CONTAINER_2D_BASE* aContainer,
const BOARD_ITEM* aOwner )
{
// JEY TODO: tables
// add borders
for( PCB_TABLECELL* cell : aTable->GetCells() )
addText( cell, aContainer, aOwner );
}
void BOARD_ADAPTER::addSolidAreasShapes( const ZONE* aZone, CONTAINER_2D_BASE* aContainer,
PCB_LAYER_ID aLayerId )
{

View File

@ -40,6 +40,7 @@
#include <pad.h>
#include <pcb_text.h>
#include <pcb_textbox.h>
#include <pcb_table.h>
#include <pcb_shape.h>
#include <zone.h>
#include <convert_basic_shapes_to_polygon.h>
@ -622,6 +623,10 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
addShape( static_cast<PCB_TEXTBOX*>( item ), layerContainer, item );
break;
case PCB_TABLE_T:
addTable( static_cast<PCB_TABLE*>( item ), layerContainer, item );
break;
case PCB_DIM_ALIGNED_T:
case PCB_DIM_CENTER_T:
case PCB_DIM_RADIAL_T:
@ -686,6 +691,10 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
break;
}
case PCB_TABLE_T:
// JEY TODO: tables
break;
default:
wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
item->Type() );
@ -847,6 +856,10 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
addShape( static_cast<PCB_TEXTBOX*>( item ), layerContainer, item );
break;
case PCB_TABLE_T:
// JEY TODO: tables
break;
case PCB_DIM_ALIGNED_T:
case PCB_DIM_CENTER_T:
case PCB_DIM_RADIAL_T:
@ -942,6 +955,10 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
break;
}
case PCB_TABLE_T:
// JEY TODO: tables
break;
default:
break;
}

View File

@ -680,6 +680,8 @@ set( PCB_COMMON_SRCS
${CMAKE_SOURCE_DIR}/pcbnew/pcb_target.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_reference_image.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_field.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_table.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_tablecell.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_text.cpp
${CMAKE_SOURCE_DIR}/pcbnew/pcb_textbox.cpp
${CMAKE_SOURCE_DIR}/pcbnew/project_pcb.cpp

View File

@ -349,6 +349,8 @@ static struct EDA_ITEM_DESC
.Map( PCB_FIELD_T, _HKI( "Text" ) )
.Map( PCB_TEXT_T, _HKI( "Text" ) )
.Map( PCB_TEXTBOX_T, _HKI( "Text Box" ) )
.Map( PCB_TABLE_T, _HKI( "Table" ) )
.Map( PCB_TABLECELL_T, _HKI( "Table Cell" ) )
.Map( PCB_TRACE_T, _HKI( "Track" ) )
.Map( PCB_ARC_T, _HKI( "Track" ) )
.Map( PCB_VIA_T, _HKI( "Via" ) )

View File

@ -2015,8 +2015,8 @@ static struct EDA_SHAPE_DESC
&EDA_SHAPE::SetWidth, &EDA_SHAPE::GetWidth, PROPERTY_DISPLAY::PT_SIZE ) );
void ( EDA_SHAPE::*lineStyleSetter )( LINE_STYLE ) = &EDA_SHAPE::SetLineStyle;
propMgr.AddProperty( new PROPERTY_ENUM<EDA_SHAPE, LINE_STYLE>(
_HKI( "Line Style" ), lineStyleSetter, &EDA_SHAPE::GetLineStyle ) );
propMgr.AddProperty( new PROPERTY_ENUM<EDA_SHAPE, LINE_STYLE>( _HKI( "Line Style" ),
lineStyleSetter, &EDA_SHAPE::GetLineStyle ) );
propMgr.AddProperty( new PROPERTY<EDA_SHAPE, COLOR4D>( _HKI( "Line Color" ),
&EDA_SHAPE::SetLineColor, &EDA_SHAPE::GetLineColor ) )

View File

@ -296,6 +296,10 @@ size_t hash_fp_item( const EDA_ITEM* aItem, int aFlags )
}
break;
case PCB_TABLE_T:
// JEY TODO: tables
break;
default:
wxASSERT_MSG( false, "Unhandled type in function hash_fp_item() (exporter_gencad.cpp)" );
}

View File

@ -59,6 +59,7 @@ bottom
bottom_left
bottom_right
castellated_pads
cells
center
chamfer
chamfer_ratio
@ -66,6 +67,9 @@ circle
clearance
clearance_min
color
cols
column_count
column_widths
comment
company
connect
@ -108,6 +112,7 @@ exclude_from_pos_files
exclude_from_bom
extension_height
extension_offset
external
fab_layers_line_width
fab_layers_text_dims
face
@ -158,6 +163,7 @@ hatch_smoothing_level
hatch_smoothing_value
hatch_border_algorithm
hatch_min_hole_area
header
height
hide
hole_to_hole_min
@ -269,9 +275,12 @@ right
rotate
roundrect
roundrect_rratio
rows
row_heights
scale
segment
segment_width
separators
setup
sheetfile
sheetname
@ -286,6 +295,7 @@ solder_paste_margin
solder_paste_margin_ratio
solder_paste_ratio
solid
span
stackup
start
status
@ -293,6 +303,8 @@ stroke
style
suffix
suppress_zeroes
table
table_cell
tags
target
title

View File

@ -298,6 +298,83 @@ TOOL_ACTION ACTIONS::rightJustify( TOOL_ACTION_ARGS()
.Tooltip( _( "Right-justify fields and text items" ) )
.Icon( BITMAPS::text_align_right ) );
TOOL_ACTION ACTIONS::selectColumns( TOOL_ACTION_ARGS()
.Name( "common.InteractiveSelection.SelectColumns" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Select Column(s)" ) )
.Tooltip( _( "Select complete column(s) containing the current selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION ACTIONS::selectRows( TOOL_ACTION_ARGS()
.Name( "common.InteractiveSelection.Rows" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Select Row(s)" ) )
.Tooltip( _( "Select complete row(s) containing the current selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION ACTIONS::selectTable( TOOL_ACTION_ARGS()
.Name( "common.InteractiveSelection.SelectTable" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Select Table" ) )
.Tooltip( _( "Select parent table of selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION ACTIONS::addRowAbove( TOOL_ACTION_ARGS()
.Name( "common.TableEditor.addRowAbove" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Add Row Above" ) )
.Tooltip( _( "Insert a new table row above the selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION ACTIONS::addRowBelow( TOOL_ACTION_ARGS()
.Name( "common.TableEditor.addRowBelow" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Add Row Below" ) )
.Tooltip( _( "Insert a new table row below the selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION ACTIONS::addColBefore( TOOL_ACTION_ARGS()
.Name( "common.TableEditor.addColBefore" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Add Column Before" ) )
.Tooltip( _( "Insert a new table column before the selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION ACTIONS::addColAfter( TOOL_ACTION_ARGS()
.Name( "common.TableEditor.addColAfter" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Add Column After" ) )
.Tooltip( _( "Insert a new table column after the selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION ACTIONS::deleteRows( TOOL_ACTION_ARGS()
.Name( "common.TableEditor.deleteRows" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Delete Row(s)" ) )
.Tooltip( _( "Delete rows containing the currently selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION ACTIONS::deleteColumns( TOOL_ACTION_ARGS()
.Name( "common.TableEditor.deleteColumns" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Delete Column(s)" ) )
.Tooltip( _( "Delete columns containing the currently selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION ACTIONS::mergeCells( TOOL_ACTION_ARGS()
.Name( "common.TableEditor.mergeCells" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Merge Cells" ) )
.Tooltip( _( "Turn selected table cells into a single cell" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION ACTIONS::unmergeCells( TOOL_ACTION_ARGS()
.Name( "common.TableEditor.unmergeCell" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Unmerge Cells" ) )
.Tooltip( _( "Turn merged table cells back into separate cells." ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION ACTIONS::activatePointEditor( TOOL_ACTION_ARGS()
.Name( "common.Control.activatePointEditor" )
.Scope( AS_GLOBAL ) );
@ -765,7 +842,7 @@ TOOL_ACTION ACTIONS::updatePreferences( TOOL_ACTION_ARGS()
.Name( "common.Control.updatePreferences" )
.Scope( AS_GLOBAL ) );
TOOL_ACTION ACTIONS::selectColumns( TOOL_ACTION_ARGS()
TOOL_ACTION ACTIONS::selectLibTreeColumns( TOOL_ACTION_ARGS()
.Name( "common.Control.selectColumns" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Select Columns..." ) ) );

View File

@ -931,7 +931,7 @@ void LIB_TREE::onHeaderContextMenu( wxDataViewEvent& aEvent )
ACTION_MENU menu( true, nullptr );
menu.Add( ACTIONS::selectColumns );
menu.Add( ACTIONS::selectLibTreeColumns );
if( GetPopupMenuSelectionFromUser( menu ) != wxID_NONE )
{

View File

@ -393,7 +393,19 @@ bool DIALOG_TABLECELL_PROPERTIES::TransferDataFromWindow()
m_table->SetSeparatorsStroke( stroke );
}
m_cell->SetText( m_textCtrl->GetValue() );
wxString txt = m_textCtrl->GetValue();
#ifdef __WXMAC__
// On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting.
// Replace it now.
txt.Replace( "\r", "\n" );
#elif defined( __WINDOWS__ )
// On Windows, a new line is coded as \r\n. We use only \n in kicad files and in
// drawing routines so strip the \r char.
txt.Replace( "\r", "" );
#endif
m_cell->SetText( txt );
if( m_fontCtrl->HaveFontSelection() )
{

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -76,7 +76,7 @@ DIALOG_TABLECELL_PROPERTIES_BASE::DIALOG_TABLECELL_PROPERTIES_BASE( wxWindow* pa
wxBoxSizer* bSizer16;
bSizer16 = new wxBoxSizer( wxVERTICAL );
m_textEntrySizer = new wxGridBagSizer( 4, 3 );
m_textEntrySizer = new wxGridBagSizer( 3, 3 );
m_textEntrySizer->SetFlexibleDirection( wxBOTH );
m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_textEntrySizer->SetEmptyCellSize( wxSize( 0,2 ) );

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!

View File

@ -4226,6 +4226,10 @@ void SCH_IO_KICAD_SEXPR_PARSER::parseSchTextBoxContent( SCH_TEXTBOX* aTextBox )
cell->SetColSpan( parseInt( "column span" ) );
cell->SetRowSpan( parseInt( "row span" ) );
}
else
{
Expecting( "at, size, stroke, fill, effects or uuid" );
}
NeedRIGHT();
break;
@ -4252,7 +4256,10 @@ void SCH_IO_KICAD_SEXPR_PARSER::parseSchTextBoxContent( SCH_TEXTBOX* aTextBox )
break;
default:
Expecting( "at, size, stroke, fill, effects or uuid" );
if( SCH_TABLECELL* cell = dynamic_cast<SCH_TABLECELL*>( aTextBox ) )
Expecting( "at, size, stroke, fill, effects, span or uuid" );
else
Expecting( "at, size, stroke, fill, effects or uuid" );
}
}

View File

@ -301,7 +301,7 @@ public:
* This is a pure virtual function. Derived classes must implement this.
*/
virtual double Similarity( const SCH_ITEM& aItem ) const = 0;
virtual bool operator==( const SCH_ITEM& aItem ) const = 0;
virtual bool operator==( const SCH_ITEM& aOtherItem ) const = 0;
/**
* Print a schematic item.

View File

@ -2418,11 +2418,8 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer )
void SCH_PAINTER::draw( const SCH_TABLE* aTable, int aLayer )
{
const_cast<SCH_TABLE*>( aTable )->RunOnChildren(
[&]( SCH_ITEM* aChild )
{
draw( static_cast<SCH_TEXTBOX*>( aChild ), aLayer );
} );
for( SCH_TABLECELL* cell : aTable->GetCells() )
draw( static_cast<SCH_TEXTBOX*>( cell ), aLayer );
if( aLayer == LAYER_SELECTION_SHADOWS )
return;

View File

@ -66,10 +66,7 @@ SCH_TABLE::SCH_TABLE( const SCH_TABLE& aTable ) :
m_rowHeights = aTable.m_rowHeights;
for( SCH_TABLECELL* src : aTable.m_cells )
m_cells.push_back( new SCH_TABLECELL( *src ) );
for( SCH_TABLECELL* dest : m_cells )
dest->SetParent( this );
AddCell( new SCH_TABLECELL( *src ) );
}
@ -139,6 +136,8 @@ VECTOR2I SCH_TABLE::GetEnd() const
void SCH_TABLE::Normalize()
{
// JEY TODO: pukes on rotated tables...
int y = GetPosition().y;
for( int row = 0; row < GetRowCount(); ++row )
@ -151,20 +150,29 @@ void SCH_TABLE::Normalize()
int colWidth = m_colWidths[ col ];
SCH_TABLECELL* cell = GetCell( row, col );
cell->SetPosition( VECTOR2I( x, y ) );
cell->SetEnd( cell->GetStart() + VECTOR2I( colWidth, rowHeight ) );
VECTOR2I pos( x, y );
if( cell->GetPosition() != pos )
{
cell->SetPosition( pos );
cell->ClearRenderCache();
}
VECTOR2I end = cell->GetStart() + VECTOR2I( colWidth, rowHeight );
if( cell->GetColSpan() > 1 || cell->GetRowSpan() > 1 )
{
VECTOR2I extraSize;
for( int ii = col + 1; ii < col + cell->GetColSpan(); ++ii )
extraSize.x += m_colWidths[ii];
end.x += m_colWidths[ii];
for( int ii = row + 1; ii < row + cell->GetRowSpan(); ++ii )
extraSize.y += m_rowHeights[ii];
end.y += m_rowHeights[ii];
}
cell->SetEnd( cell->GetEnd() + extraSize );
if( cell->GetEnd() != end )
{
cell->SetEnd( end );
cell->ClearRenderCache();
}
x += colWidth;
@ -198,6 +206,8 @@ void SCH_TABLE::Rotate( const VECTOR2I& aCenter )
{
for( SCH_TABLECELL* cell : m_cells )
cell->Rotate( aCenter );
Normalize();
}
@ -599,36 +609,48 @@ static struct SCH_TABLE_DESC
&EDA_SHAPE::SetStartY, &EDA_SHAPE::GetStartY, PROPERTY_DISPLAY::PT_COORD,
ORIGIN_TRANSFORMS::ABS_Y_COORD ) );
const wxString tableProps = _( "Table Properties" );
propMgr.AddProperty( new PROPERTY<SCH_TABLE, bool>( _HKI( "External Border" ),
&SCH_TABLE::SetStrokeExternal, &SCH_TABLE::StrokeExternal ) );
&SCH_TABLE::SetStrokeExternal, &SCH_TABLE::StrokeExternal ),
tableProps );
propMgr.AddProperty( new PROPERTY<SCH_TABLE, bool>( _HKI( "Header Border" ),
&SCH_TABLE::SetStrokeHeader, &SCH_TABLE::StrokeHeader ) );
&SCH_TABLE::SetStrokeHeader, &SCH_TABLE::StrokeHeader ),
tableProps );
propMgr.AddProperty( new PROPERTY<SCH_TABLE, int>( _HKI( "Border Width" ),
&SCH_TABLE::SetBorderWidth, &SCH_TABLE::GetBorderWidth,
PROPERTY_DISPLAY::PT_SIZE ) );
PROPERTY_DISPLAY::PT_SIZE ),
tableProps );
propMgr.AddProperty( new PROPERTY_ENUM<SCH_TABLE, LINE_STYLE>( _HKI( "Border Style" ),
&SCH_TABLE::SetBorderStyle, &SCH_TABLE::GetBorderStyle ) );
&SCH_TABLE::SetBorderStyle, &SCH_TABLE::GetBorderStyle ),
tableProps );
propMgr.AddProperty( new PROPERTY<SCH_TABLE, COLOR4D>( _HKI( "Border Color" ),
&SCH_TABLE::SetBorderColor, &SCH_TABLE::GetBorderColor ) );
&SCH_TABLE::SetBorderColor, &SCH_TABLE::GetBorderColor ),
tableProps );
propMgr.AddProperty( new PROPERTY<SCH_TABLE, bool>( _HKI( "Row Separators" ),
&SCH_TABLE::SetStrokeRows, &SCH_TABLE::StrokeRows ) );
&SCH_TABLE::SetStrokeRows, &SCH_TABLE::StrokeRows ),
tableProps );
propMgr.AddProperty( new PROPERTY<SCH_TABLE, bool>( _HKI( "Cell Separators" ),
&SCH_TABLE::SetStrokeColumns, &SCH_TABLE::StrokeColumns ) );
&SCH_TABLE::SetStrokeColumns, &SCH_TABLE::StrokeColumns ),
tableProps );
propMgr.AddProperty( new PROPERTY<SCH_TABLE, int>( _HKI( "Separators Width" ),
&SCH_TABLE::SetSeparatorsWidth, &SCH_TABLE::GetSeparatorsWidth,
PROPERTY_DISPLAY::PT_SIZE ) );
PROPERTY_DISPLAY::PT_SIZE ),
tableProps );
propMgr.AddProperty( new PROPERTY_ENUM<SCH_TABLE, LINE_STYLE>( _HKI( "Separators Style" ),
&SCH_TABLE::SetSeparatorsStyle, &SCH_TABLE::GetSeparatorsStyle ) );
&SCH_TABLE::SetSeparatorsStyle, &SCH_TABLE::GetSeparatorsStyle ),
tableProps );
propMgr.AddProperty( new PROPERTY<SCH_TABLE, COLOR4D>( _HKI( "Separators Color" ),
&SCH_TABLE::SetSeparatorsColor, &SCH_TABLE::GetSeparatorsColor ) );
&SCH_TABLE::SetSeparatorsColor, &SCH_TABLE::GetSeparatorsColor ),
tableProps );
}
} _SCH_TABLE_DESC;

View File

@ -135,6 +135,41 @@ void SCH_TABLECELL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PAN
}
double SCH_TABLECELL::Similarity( const SCH_ITEM& aOtherItem ) const
{
if( aOtherItem.Type() != Type() )
return 0.0;
const SCH_TABLECELL& other = static_cast<const SCH_TABLECELL&>( aOtherItem );
double similarity = 1.0;
if( m_colSpan != other.m_colSpan )
similarity *= 0.9;
if( m_rowSpan != other.m_rowSpan )
similarity *= 0.9;
similarity *= SCH_TEXTBOX::Similarity( other );
return similarity;
}
bool SCH_TABLECELL::operator==( const SCH_ITEM& aOtherItem ) const
{
if( aOtherItem.Type() != Type() )
return false;
const SCH_TABLECELL& other = static_cast<const SCH_TABLECELL&>( aOtherItem );
return m_colSpan == other.m_colSpan
&& m_rowSpan == other.m_rowSpan
&& SCH_TEXTBOX::operator==( other );
}
static struct SCH_TABLECELL_DESC
{
SCH_TABLECELL_DESC()

View File

@ -71,6 +71,10 @@ public:
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
double Similarity( const SCH_ITEM& aOther ) const override;
bool operator==( const SCH_ITEM& aOther ) const override;
protected:
int m_colSpan;
int m_rowSpan;

View File

@ -145,83 +145,6 @@ TOOL_ACTION EE_ACTIONS::syncSelection( TOOL_ACTION_ARGS()
.Name( "eeschema.InteractiveSelection.SyncSelection" )
.Scope( AS_GLOBAL ) );
TOOL_ACTION EE_ACTIONS::selectColumns( TOOL_ACTION_ARGS()
.Name( "eeschema.InteractiveSelection.SelectColumns" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Select Column(s)" ) )
.Tooltip( _( "Select complete column(s) containing the current selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION EE_ACTIONS::selectRows( TOOL_ACTION_ARGS()
.Name( "eeschema.InteractiveSelection.Rows" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Select Row(s)" ) )
.Tooltip( _( "Select complete row(s) containing the current selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION EE_ACTIONS::selectTable( TOOL_ACTION_ARGS()
.Name( "eeschema.InteractiveSelection.SelectTable" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Select Table" ) )
.Tooltip( _( "Select parent table of selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION EE_ACTIONS::addRowAbove( TOOL_ACTION_ARGS()
.Name( "eeschema.TableEditor.addRowAbove" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Add Row Above" ) )
.Tooltip( _( "Insert a new table row above the selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION EE_ACTIONS::addRowBelow( TOOL_ACTION_ARGS()
.Name( "eeschema.TableEditor.addRowBelow" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Add Row Below" ) )
.Tooltip( _( "Insert a new table row below the selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION EE_ACTIONS::addColumnBefore( TOOL_ACTION_ARGS()
.Name( "eeschema.TableEditor.addColumnBefore" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Add Column Before" ) )
.Tooltip( _( "Insert a new table column before the selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION EE_ACTIONS::addColumnAfter( TOOL_ACTION_ARGS()
.Name( "eeschema.TableEditor.addColumnAfter" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Add Column After" ) )
.Tooltip( _( "Insert a new table column after the selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION EE_ACTIONS::deleteRows( TOOL_ACTION_ARGS()
.Name( "eeschema.TableEditor.deleteRows" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Delete Row(s)" ) )
.Tooltip( _( "Delete rows containing the currently selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION EE_ACTIONS::deleteColumns( TOOL_ACTION_ARGS()
.Name( "eeschema.TableEditor.deleteColumns" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Delete Column(s)" ) )
.Tooltip( _( "Delete columns containing the currently selected cell(s)" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION EE_ACTIONS::mergeCells( TOOL_ACTION_ARGS()
.Name( "eeschema.TableEditor.mergeCells" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Merge Cells" ) )
.Tooltip( _( "Turn selected table cells into a single cell" ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
TOOL_ACTION EE_ACTIONS::unmergeCells( TOOL_ACTION_ARGS()
.Name( "eeschema.TableEditor.unmergeCell" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Unmerge Cells" ) )
.Tooltip( _( "Turn merged table cells back into separate cells." ) )
.Icon( BITMAPS::spreadsheet ) ); // JEY TODO: need icon
// SYMBOL_EDITOR_CONTROL
//
TOOL_ACTION EE_ACTIONS::saveLibraryAs( TOOL_ACTION_ARGS()

View File

@ -69,19 +69,6 @@ public:
/// Selection synchronization (PCB -> SCH)
static TOOL_ACTION syncSelection;
// Tables
static TOOL_ACTION selectRows;
static TOOL_ACTION selectColumns;
static TOOL_ACTION selectTable;
static TOOL_ACTION addRowAbove;
static TOOL_ACTION addRowBelow;
static TOOL_ACTION addColumnBefore;
static TOOL_ACTION addColumnAfter;
static TOOL_ACTION deleteRows;
static TOOL_ACTION deleteColumns;
static TOOL_ACTION mergeCells;
static TOOL_ACTION unmergeCells;
// Locking
static TOOL_ACTION toggleLock;
static TOOL_ACTION lock;

View File

@ -280,9 +280,9 @@ bool EE_SELECTION_TOOL::Init()
menu.AddItem( EE_ACTIONS::clearHighlight, haveHighlight && EE_CONDITIONS::Idle, 1 );
menu.AddSeparator( haveHighlight && EE_CONDITIONS::Idle, 1 );
menu.AddItem( EE_ACTIONS::selectColumns, tableCellSelection && EE_CONDITIONS::Idle, 2 );
menu.AddItem( EE_ACTIONS::selectRows, tableCellSelection && EE_CONDITIONS::Idle, 2 );
menu.AddItem( EE_ACTIONS::selectTable, tableCellSelection && EE_CONDITIONS::Idle, 2 );
menu.AddItem( ACTIONS::selectColumns, tableCellSelection && EE_CONDITIONS::Idle, 2 );
menu.AddItem( ACTIONS::selectRows, tableCellSelection && EE_CONDITIONS::Idle, 2 );
menu.AddItem( ACTIONS::selectTable, tableCellSelection && EE_CONDITIONS::Idle, 2 );
menu.AddSeparator( 100 );
menu.AddItem( EE_ACTIONS::drawWire, schEditCondition && EE_CONDITIONS::Empty, 100 );
@ -2545,9 +2545,9 @@ void EE_SELECTION_TOOL::setTransitions()
Go( &EE_SELECTION_TOOL::Main, EE_ACTIONS::selectionActivate.MakeEvent() );
Go( &EE_SELECTION_TOOL::SelectNode, EE_ACTIONS::selectNode.MakeEvent() );
Go( &EE_SELECTION_TOOL::SelectConnection, EE_ACTIONS::selectConnection.MakeEvent() );
Go( &EE_SELECTION_TOOL::SelectColumns, EE_ACTIONS::selectColumns.MakeEvent() );
Go( &EE_SELECTION_TOOL::SelectRows, EE_ACTIONS::selectRows.MakeEvent() );
Go( &EE_SELECTION_TOOL::SelectTable, EE_ACTIONS::selectTable.MakeEvent() );
Go( &EE_SELECTION_TOOL::SelectColumns, ACTIONS::selectColumns.MakeEvent() );
Go( &EE_SELECTION_TOOL::SelectRows, ACTIONS::selectRows.MakeEvent() );
Go( &EE_SELECTION_TOOL::SelectTable, ACTIONS::selectTable.MakeEvent() );
Go( &EE_SELECTION_TOOL::ClearSelection, EE_ACTIONS::clearSelection.MakeEvent() );

View File

@ -2165,13 +2165,14 @@ int SCH_DRAWING_TOOLS::DrawTable( const TOOL_EVENT& aEvent )
else if( table && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{
VECTOR2I gridSize = grid.GetGridSize( grid.GetItemGrid( table ) );
int fontSize = schematic->Settings().m_DefaultTextSize;
VECTOR2I origin( table->GetPosition() );
VECTOR2I requestedSize( cursorPos - origin );
int colCount = std::max( 1, requestedSize.x / ( gridSize.x * 24 ) );
int rowCount = std::max( 1, requestedSize.y / ( gridSize.y * 8 ) );
int colCount = std::max( 1, requestedSize.x / ( fontSize * 15 ) );
int rowCount = std::max( 1, requestedSize.y / ( fontSize * 2 ) );
VECTOR2I cellSize( std::max( gridSize.x * 4, requestedSize.x / colCount ),
VECTOR2I cellSize( std::max( gridSize.x * 5, requestedSize.x / colCount ),
std::max( gridSize.y * 2, requestedSize.y / rowCount ) );
cellSize.x = KiROUND( (double) cellSize.x / gridSize.x ) * gridSize.x;

View File

@ -21,16 +21,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <kiway.h>
#include <tools/sch_edit_tool.h>
#include <tools/ee_selection_tool.h>
#include <ee_actions.h>
#include <string_utils.h>
#include <sch_table.h>
#include <sch_tablecell.h>
#include <sch_commit.h>
#include <pgm_base.h>
#include <core/kicad_algo.h>
#include <tools/sch_edit_table_tool.h>
@ -44,78 +35,13 @@ bool SCH_EDIT_TABLE_TOOL::Init()
{
EE_TOOL_BASE::Init();
auto tableCellSelection = EE_CONDITIONS::MoreThan( 0 )
&& EE_CONDITIONS::OnlyTypes( { SCH_TABLECELL_T } );
auto tableCellBlockSelection =
[&]( const SELECTION& sel )
{
if( sel.CountType( SCH_TABLECELL_T ) < 2 )
return false;
int colMin = std::numeric_limits<int>::max();
int colMax = 0;
int rowMin = std::numeric_limits<int>::max();
int rowMax = 0;
int selectedArea = 0;
for( EDA_ITEM* item : sel )
{
wxCHECK2( item->Type() == SCH_TABLECELL_T, continue );
SCH_TABLECELL* cell = static_cast<SCH_TABLECELL*>( item );
colMin = std::min( colMin, cell->GetColumn() );
colMax = std::max( colMax, cell->GetColumn() + cell->GetColSpan() );
rowMin = std::min( rowMin, cell->GetRow() );
rowMax = std::max( rowMax, cell->GetRow() + cell->GetRowSpan() );
selectedArea += cell->GetColSpan() * cell->GetRowSpan();
}
return selectedArea == ( colMax - colMin ) * ( rowMax - rowMin );
};
auto mergedCellsSelection =
[&]( const SELECTION& sel )
{
for( EDA_ITEM* item : sel )
{
if( SCH_TABLECELL* cell = dynamic_cast<SCH_TABLECELL*>( item ) )
{
if( cell->GetColSpan() > 1 || cell->GetRowSpan() > 1 )
return true;
}
}
return false;
};
//
// Add editing actions to the selection tool menu
//
CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu();
selToolMenu.AddSeparator( 100 );
selToolMenu.AddItem( EE_ACTIONS::addRowAbove, tableCellSelection && EE_CONDITIONS::Idle, 100 );
selToolMenu.AddItem( EE_ACTIONS::addRowBelow, tableCellSelection && EE_CONDITIONS::Idle, 100 );
selToolMenu.AddItem( EE_ACTIONS::addColumnBefore, tableCellSelection && EE_CONDITIONS::Idle, 100 );
selToolMenu.AddItem( EE_ACTIONS::addColumnAfter, tableCellSelection && EE_CONDITIONS::Idle, 100 );
selToolMenu.AddSeparator( 100 );
selToolMenu.AddItem( EE_ACTIONS::deleteRows, tableCellSelection && EE_CONDITIONS::Idle, 100 );
selToolMenu.AddItem( EE_ACTIONS::deleteColumns, tableCellSelection && EE_CONDITIONS::Idle, 100 );
selToolMenu.AddSeparator( 100 );
selToolMenu.AddItem( EE_ACTIONS::mergeCells, tableCellSelection && tableCellBlockSelection, 100 );
selToolMenu.AddItem( EE_ACTIONS::unmergeCells, tableCellSelection && mergedCellsSelection, 100 );
selToolMenu.AddSeparator( 100 );
addMenus( m_selectionTool->GetToolMenu().GetMenu() );
return true;
}
SCH_TABLECELL* copyCell( SCH_TABLECELL* aSource )
SCH_TABLECELL* SCH_EDIT_TABLE_TOOL::copyCell( SCH_TABLECELL* aSource )
{
SCH_TABLECELL* cell = new SCH_TABLECELL();
@ -127,415 +53,23 @@ SCH_TABLECELL* copyCell( SCH_TABLECELL* aSource )
}
int SCH_EDIT_TABLE_TOOL::AddRowAbove( const TOOL_EVENT& aEvent )
const SELECTION& SCH_EDIT_TABLE_TOOL::getTableCellSelection()
{
EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_TABLECELL_T } );
SCH_TABLECELL* topmost = nullptr;
for( EDA_ITEM* item : selection )
{
SCH_TABLECELL* cell = static_cast<SCH_TABLECELL*>( item );
if( !topmost || cell->GetRow() < topmost->GetRow() )
topmost = cell;
}
if( !topmost )
return 0;
int row = topmost->GetRow();
SCH_TABLE* table = static_cast<SCH_TABLE*>( topmost->GetParent() );
SCH_COMMIT commit( m_toolMgr );
// Make a copy of the source row before things start moving around
std::vector<SCH_TABLECELL*> sources;
sources.reserve( table->GetColCount() );
for( int col = 0; col < table->GetColCount(); ++col )
sources.push_back( table->GetCell( row, col ) );
commit.Modify( table, m_frame->GetScreen() );
for( int col = 0; col < table->GetColCount(); ++col )
{
SCH_TABLECELL* cell = copyCell( sources[col] );
table->InsertCell( row * table->GetColCount(), cell );
}
table->Normalize();
commit.Push( _( "Add Row Above" ) );
return 0;
}
int SCH_EDIT_TABLE_TOOL::AddRowBelow( const TOOL_EVENT& aEvent )
{
EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_TABLECELL_T } );
SCH_TABLECELL* bottommost = nullptr;
if( selection.Empty() )
return 0;
for( EDA_ITEM* item : selection )
{
SCH_TABLECELL* cell = static_cast<SCH_TABLECELL*>( item );
if( !bottommost || cell->GetRow() > bottommost->GetRow() )
bottommost = cell;
}
if( !bottommost )
return 0;
int row = bottommost->GetRow();
SCH_TABLE* table = static_cast<SCH_TABLE*>( bottommost->GetParent() );
SCH_COMMIT commit( m_toolMgr );
// Make a copy of the source row before things start moving around
std::vector<SCH_TABLECELL*> sources;
sources.reserve( table->GetColCount() );
for( int col = 0; col < table->GetColCount(); ++col )
sources.push_back( table->GetCell( row, col ) );
commit.Modify( table, m_frame->GetScreen() );
for( int col = 0; col < table->GetColCount(); ++col )
{
SCH_TABLECELL* cell = copyCell( sources[col] );
table->InsertCell( ( row + 1 ) * table->GetColCount(), cell );
}
table->Normalize();
commit.Push( _( "Add Row Below" ) );
return 0;
}
int SCH_EDIT_TABLE_TOOL::AddColumnBefore( const TOOL_EVENT& aEvent )
{
EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_TABLECELL_T } );
SCH_TABLECELL* leftmost = nullptr;
for( EDA_ITEM* item : selection )
{
SCH_TABLECELL* cell = static_cast<SCH_TABLECELL*>( item );
if( !leftmost || cell->GetColumn() < leftmost->GetColumn() )
leftmost = cell;
}
if( !leftmost )
return 0;
int col = leftmost->GetColumn();
SCH_TABLE* table = static_cast<SCH_TABLE*>( leftmost->GetParent() );
int rowCount = table->GetRowCount();
SCH_COMMIT commit( m_toolMgr );
// Make a copy of the source column before things start moving around
std::vector<SCH_TABLECELL*> sources;
sources.reserve( rowCount );
for( int row = 0; row < rowCount; ++row )
sources.push_back( table->GetCell( row, col ) );
commit.Modify( table, m_frame->GetScreen() );
table->SetColCount( table->GetColCount() + 1 );
for( int row = 0; row < rowCount; ++row )
{
SCH_TABLECELL* cell = copyCell( sources[row] );
table->InsertCell( row * table->GetColCount() + col, cell );
}
table->Normalize();
commit.Push( _( "Add Column Before" ) );
return 0;
}
int SCH_EDIT_TABLE_TOOL::AddColumnAfter( const TOOL_EVENT& aEvent )
{
EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_TABLECELL_T } );
SCH_TABLECELL* rightmost = nullptr;
for( EDA_ITEM* item : selection )
{
SCH_TABLECELL* cell = static_cast<SCH_TABLECELL*>( item );
if( !rightmost || cell->GetColumn() > rightmost->GetColumn() )
rightmost = cell;
}
if( !rightmost )
return 0;
int col = rightmost->GetColumn();
SCH_TABLE* table = static_cast<SCH_TABLE*>( rightmost->GetParent() );
int rowCount = table->GetRowCount();
SCH_COMMIT commit( m_toolMgr );
// Make a copy of the source column before things start moving around
std::vector<SCH_TABLECELL*> sources;
sources.reserve( rowCount );
for( int row = 0; row < rowCount; ++row )
sources.push_back( table->GetCell( row, col ) );
commit.Modify( table, m_frame->GetScreen() );
table->SetColCount( table->GetColCount() + 1 );
for( int row = 0; row < rowCount; ++row )
{
SCH_TABLECELL* cell = copyCell( sources[row] );
table->InsertCell( row * table->GetColCount() + col + 1, cell );
}
table->Normalize();
commit.Push( _( "Add Column After" ) );
return 0;
}
int SCH_EDIT_TABLE_TOOL::DeleteColumns( const TOOL_EVENT& aEvent )
{
EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_TABLECELL_T } );
if( selection.Empty() )
return 0;
SCH_TABLE* table = static_cast<SCH_TABLE*>( selection[0]->GetParent() );
int deleted = 0;
for( int col = 0; col < table->GetColCount(); ++col )
{
bool deleteColumn = false;
for( int row = 0; row < table->GetRowCount(); ++row )
{
if( table->GetCell( row, col )->IsSelected() )
{
deleteColumn = true;
break;
}
}
if( deleteColumn )
{
for( int row = 0; row < table->GetRowCount(); ++row )
table->GetCell( row, col )->SetFlags( STRUCT_DELETED );
deleted++;
}
}
SCH_COMMIT commit( m_toolMgr );
if( deleted == table->GetColCount() )
{
commit.Remove( table, m_frame->GetScreen() );
}
else
{
commit.Modify( table, m_frame->GetScreen() );
table->DeleteMarkedCells();
table->SetColCount( table->GetColCount() - deleted );
table->Normalize();
}
if( deleted > 1 )
commit.Push( _( "Delete Columns" ) );
else
commit.Push( _( "Delete Column" ) );
return 0;
}
int SCH_EDIT_TABLE_TOOL::DeleteRows( const TOOL_EVENT& aEvent )
{
EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_TABLECELL_T } );
if( selection.Empty() )
return 0;
SCH_TABLE* table = static_cast<SCH_TABLE*>( selection[0]->GetParent() );
int deleted = 0;
for( int row = 0; row < table->GetRowCount(); ++row )
{
bool deleteRow = false;
for( int col = 0; col < table->GetColCount(); ++col )
{
if( table->GetCell( row, col )->IsSelected() )
{
deleteRow = true;
break;
}
}
if( deleteRow )
{
for( int col = 0; col < table->GetColCount(); ++col )
table->GetCell( row, col )->SetFlags( STRUCT_DELETED );
deleted++;
}
}
SCH_COMMIT commit( m_toolMgr );
if( deleted == table->GetRowCount() )
{
commit.Remove( table, m_frame->GetScreen() );
}
else
{
commit.Modify( table, m_frame->GetScreen() );
table->DeleteMarkedCells();
table->Normalize();
}
if( deleted > 1 )
commit.Push( _( "Delete Rows" ) );
else
commit.Push( _( "Delete Row" ) );
return 0;
}
int SCH_EDIT_TABLE_TOOL::MergeCells( const TOOL_EVENT& aEvent )
{
EE_SELECTION& sel = m_selectionTool->RequestSelection( { SCH_TABLECELL_T } );
if( sel.Empty() )
return 0;
int colMin = std::numeric_limits<int>::max();
int colMax = 0;
int rowMin = std::numeric_limits<int>::max();
int rowMax = 0;
SCH_COMMIT commit( m_toolMgr );
SCH_TABLE* table = static_cast<SCH_TABLE*>( sel[0]->GetParent() );
for( EDA_ITEM* item : sel )
{
wxCHECK2( item->Type() == SCH_TABLECELL_T, continue );
SCH_TABLECELL* cell = static_cast<SCH_TABLECELL*>( item );
colMin = std::min( colMin, cell->GetColumn() );
colMax = std::max( colMax, cell->GetColumn() + cell->GetColSpan() );
rowMin = std::min( rowMin, cell->GetRow() );
rowMax = std::max( rowMax, cell->GetRow() + cell->GetRowSpan() );
}
wxString content;
VECTOR2I extents;
for( int row = rowMin; row < rowMax; ++row )
{
extents.y += table->GetRowHeight( row );
extents.x = 0;
for( int col = colMin; col < colMax; ++col )
{
extents.x += table->GetColWidth( col );
SCH_TABLECELL* cell = table->GetCell( row, col );
if( !cell->GetText().IsEmpty() )
{
if( !content.IsEmpty() )
content += "\n";
content += cell->GetText();
}
commit.Modify( cell, m_frame->GetScreen() );
cell->SetColSpan( 0 );
cell->SetRowSpan( 0 );
cell->SetText( wxEmptyString );
}
}
SCH_TABLECELL* topLeft = table->GetCell( rowMin, colMin );
topLeft->SetColSpan( colMax - colMin );
topLeft->SetRowSpan( rowMax - rowMin );
topLeft->SetText( content );
topLeft->SetEnd( topLeft->GetStart() + extents );
table->Normalize();
commit.Push( _( "Merge Cells" ) );
return 0;
}
int SCH_EDIT_TABLE_TOOL::UnmergeCells( const TOOL_EVENT& aEvent )
{
EE_SELECTION& sel = m_selectionTool->RequestSelection( { SCH_TABLECELL_T } );
if( sel.Empty() )
return 0;
SCH_COMMIT commit( m_toolMgr );
SCH_TABLE* table = static_cast<SCH_TABLE*>( sel[0]->GetParent() );
for( EDA_ITEM* item : sel )
{
wxCHECK2( item->Type() == SCH_TABLECELL_T, continue );
SCH_TABLECELL* cell = static_cast<SCH_TABLECELL*>( item );
int rowSpan = cell->GetRowSpan();
int colSpan = cell->GetColSpan();
for( int row = cell->GetRow(); row < cell->GetRow() + rowSpan; ++row )
{
for( int col = cell->GetColumn(); col < cell->GetColumn() + colSpan; ++col )
{
SCH_TABLECELL* target = table->GetCell( row, col );
commit.Modify( target, m_frame->GetScreen() );
target->SetColSpan( 1 );
target->SetRowSpan( 1 );
VECTOR2I extents( table->GetColWidth( col ), table->GetRowHeight( row ) );
target->SetEnd( target->GetStart() + extents );
}
}
}
table->Normalize();
commit.Push( _( "Unmerge Cells" ) );
return 0;
return m_selectionTool->RequestSelection( { SCH_TABLECELL_T } );
}
void SCH_EDIT_TABLE_TOOL::setTransitions()
{
Go( &SCH_EDIT_TABLE_TOOL::AddRowAbove, EE_ACTIONS::addRowAbove.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::AddRowBelow, EE_ACTIONS::addRowBelow.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::AddRowAbove, ACTIONS::addRowAbove.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::AddRowBelow, ACTIONS::addRowBelow.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::AddColumnBefore, EE_ACTIONS::addColumnBefore.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::AddColumnAfter, EE_ACTIONS::addColumnAfter.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::AddColumnBefore, ACTIONS::addColBefore.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::AddColumnAfter, ACTIONS::addColAfter.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::DeleteRows, EE_ACTIONS::deleteRows.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::DeleteColumns, EE_ACTIONS::deleteColumns.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::DeleteRows, ACTIONS::deleteRows.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::DeleteColumns, ACTIONS::deleteColumns.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::MergeCells, EE_ACTIONS::mergeCells.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::UnmergeCells, EE_ACTIONS::unmergeCells.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::MergeCells, ACTIONS::mergeCells.MakeEvent() );
Go( &SCH_EDIT_TABLE_TOOL::UnmergeCells, ACTIONS::unmergeCells.MakeEvent() );
}

Some files were not shown because too many files have changed in this diff Show More