2021-03-14 15:12:51 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014-2017 CERN
|
2023-03-30 11:49:23 +00:00
|
|
|
* Copyright (C) 2018-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2021-03-14 15:12:51 +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 "drawing_tool.h"
|
|
|
|
#include "pcb_actions.h"
|
|
|
|
#include <pcb_edit_frame.h>
|
|
|
|
#include <view/view.h>
|
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <board_commit.h>
|
|
|
|
#include <scoped_set_reset.h>
|
2023-09-07 00:23:19 +00:00
|
|
|
#include <gal/painter.h>
|
2022-11-14 23:39:08 +00:00
|
|
|
#include <tools/zone_filler_tool.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2021-06-03 18:05:43 +00:00
|
|
|
#include <footprint.h>
|
2023-03-30 11:49:23 +00:00
|
|
|
#include <pcb_shape.h>
|
2021-06-03 17:03:25 +00:00
|
|
|
#include <pcb_group.h>
|
2021-03-14 15:12:51 +00:00
|
|
|
#include <pcb_text.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2021-03-14 17:44:31 +00:00
|
|
|
#include <wx/utils.h>
|
|
|
|
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
using SCOPED_DRAW_MODE = SCOPED_SET_RESET<DRAWING_TOOL::MODE>;
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-03-14 15:12:51 +00:00
|
|
|
static std::vector<BOARD_ITEM*> initTextTable( std::vector<std::vector<PCB_TEXT*>> aContent,
|
2022-07-29 21:02:35 +00:00
|
|
|
VECTOR2I origin, PCB_LAYER_ID aLayer,
|
|
|
|
VECTOR2I* aTableSize, bool aDrawFrame = true )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
int nbCols = aContent.size();
|
|
|
|
int nbRows = 0;
|
|
|
|
|
2022-07-29 21:02:35 +00:00
|
|
|
for( const std::vector<PCB_TEXT*>& col : aContent )
|
2021-03-14 15:12:51 +00:00
|
|
|
nbRows = std::max( nbRows, static_cast<int>( col.size() ) );
|
|
|
|
|
|
|
|
// Limit the number of cells
|
|
|
|
nbCols = std::min( nbCols, 99 );
|
|
|
|
nbRows = std::min( nbRows, 99 );
|
|
|
|
|
|
|
|
int rowHeight[99];
|
|
|
|
int colWidth[99];
|
|
|
|
|
|
|
|
std::vector<BOARD_ITEM*> table;
|
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
// xmargin and ymargin are margins between the text and the table lines.
|
2021-03-14 15:12:51 +00:00
|
|
|
//
|
|
|
|
// +--------------------------------+
|
|
|
|
// | ^ |
|
|
|
|
// | | ymargin |
|
|
|
|
// | v |
|
|
|
|
// |<------->TEXT_TEXT_TEXT<------->|
|
|
|
|
// | xmargin ^ xmargin |
|
|
|
|
// | | ymargin |
|
|
|
|
// | v |
|
|
|
|
// +--------------------------------+
|
|
|
|
//
|
|
|
|
|
2022-09-16 11:33:56 +00:00
|
|
|
int xmargin = pcbIUScale.mmToIU( 0.75 );
|
|
|
|
int ymargin = pcbIUScale.mmToIU( 0.75 );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
// Init table
|
|
|
|
for( i = 0; i < nbRows; i++ )
|
|
|
|
rowHeight[i] = 0;
|
|
|
|
|
|
|
|
for( i = 0; i < nbCols; i++ )
|
|
|
|
colWidth[i] = 0;
|
|
|
|
|
|
|
|
// First, we determine what the height/Width should be for every cell
|
|
|
|
i = 0;
|
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
for( const std::vector<PCB_TEXT*>& col : aContent )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
|
|
|
j = 0;
|
|
|
|
|
|
|
|
if( i >= nbCols )
|
|
|
|
break;
|
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
for( const PCB_TEXT* cell : col )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
|
|
|
if( j >= nbRows )
|
|
|
|
break;
|
|
|
|
|
|
|
|
int height = cell->GetBoundingBox().GetHeight() + 2 * ymargin;
|
|
|
|
int width = cell->GetBoundingBox().GetWidth() + 2 * xmargin;
|
|
|
|
rowHeight[j] = rowHeight[j] > height ? rowHeight[j] : height;
|
|
|
|
colWidth[i] = colWidth[i] > width ? colWidth[i] : width;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get table size
|
|
|
|
int height = std::accumulate( rowHeight, rowHeight + nbRows, 0 );
|
|
|
|
int width = std::accumulate( colWidth, colWidth + nbCols, 0 );
|
|
|
|
|
|
|
|
aTableSize->x = width;
|
|
|
|
aTableSize->y = height;
|
|
|
|
// Draw the frame
|
|
|
|
|
|
|
|
if( aDrawFrame )
|
|
|
|
{
|
|
|
|
int y = origin.y;
|
|
|
|
PCB_SHAPE* line;
|
|
|
|
|
|
|
|
for( i = 0; i < nbRows; i++ )
|
|
|
|
{
|
|
|
|
line = new PCB_SHAPE;
|
|
|
|
line->SetLayer( aLayer );
|
2022-08-20 09:27:35 +00:00
|
|
|
line->SetStart( VECTOR2I( origin.x, y ) );
|
|
|
|
line->SetEnd( VECTOR2I( origin.x + width, y ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
y += rowHeight[i];
|
|
|
|
table.push_back( line );
|
|
|
|
}
|
|
|
|
|
|
|
|
line = new PCB_SHAPE;
|
|
|
|
line->SetLayer( aLayer );
|
2022-08-20 09:27:35 +00:00
|
|
|
line->SetStart( VECTOR2I( origin.x, y ) );
|
|
|
|
line->SetEnd( VECTOR2I( origin.x + width, y ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
table.push_back( line );
|
|
|
|
int x = origin.x;
|
|
|
|
|
|
|
|
for( i = 0; i < nbCols; i++ )
|
|
|
|
{
|
|
|
|
line = new PCB_SHAPE;
|
|
|
|
line->SetLayer( aLayer );
|
2022-08-20 09:27:35 +00:00
|
|
|
line->SetStart( VECTOR2I( x, origin.y ) );
|
|
|
|
line->SetEnd( VECTOR2I( x, origin.y + height ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
x += colWidth[i];
|
|
|
|
table.push_back( line );
|
|
|
|
}
|
|
|
|
|
|
|
|
line = new PCB_SHAPE;
|
|
|
|
line->SetLayer( aLayer );
|
2022-08-20 09:27:35 +00:00
|
|
|
line->SetStart( VECTOR2I( x, origin.y ) );
|
|
|
|
line->SetEnd( VECTOR2I( x, origin.y + height ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
table.push_back( line );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-03-14 15:12:51 +00:00
|
|
|
//Now add the text
|
2022-07-29 21:02:35 +00:00
|
|
|
i = 0;
|
|
|
|
VECTOR2I pos( origin.x + xmargin, origin.y + ymargin );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
for( std::vector<PCB_TEXT*>& col : aContent )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
|
|
|
j = 0;
|
|
|
|
|
|
|
|
if( i >= nbCols )
|
|
|
|
break;
|
|
|
|
|
|
|
|
pos.y = origin.y + ymargin;
|
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
for( PCB_TEXT* cell : col )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
|
|
|
if( j >= nbRows )
|
|
|
|
break;
|
|
|
|
|
|
|
|
cell->SetTextPos( pos );
|
|
|
|
cell->SetLayer( aLayer );
|
|
|
|
pos.y = pos.y + rowHeight[j];
|
|
|
|
table.push_back( cell );
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos.x = pos.x + colWidth[i];
|
|
|
|
i++;
|
|
|
|
}
|
2022-08-20 09:27:35 +00:00
|
|
|
|
2021-03-14 15:12:51 +00:00
|
|
|
return table;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-29 21:02:35 +00:00
|
|
|
std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup( const VECTOR2I& aOrigin,
|
2021-09-13 16:18:58 +00:00
|
|
|
PCB_LAYER_ID aLayer,
|
|
|
|
bool aDrawNow,
|
2022-07-29 21:02:35 +00:00
|
|
|
VECTOR2I* tableSize )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
2021-09-13 16:18:58 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
2022-07-29 21:02:35 +00:00
|
|
|
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( m_frame->GetModel() );
|
|
|
|
|
2021-03-14 15:12:51 +00:00
|
|
|
std::vector<std::vector<PCB_TEXT*>> texts;
|
|
|
|
|
|
|
|
// Style : Header
|
2022-07-29 21:02:35 +00:00
|
|
|
std::unique_ptr<PCB_TEXT> headStyle = std::make_unique<PCB_TEXT>( footprint );
|
2021-03-14 15:12:51 +00:00
|
|
|
headStyle->SetLayer( Eco1_User );
|
2023-02-19 03:40:07 +00:00
|
|
|
headStyle->SetTextSize( VECTOR2I( pcbIUScale.mmToIU( 1.5 ), pcbIUScale.mmToIU( 1.5 ) ) );
|
2022-09-16 11:33:56 +00:00
|
|
|
headStyle->SetTextThickness( pcbIUScale.mmToIU( 0.3 ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
headStyle->SetItalic( false );
|
2023-02-19 03:40:07 +00:00
|
|
|
headStyle->SetTextPos( VECTOR2I( 0, 0 ) );
|
2022-02-05 13:25:43 +00:00
|
|
|
headStyle->SetText( _( "Layer" ) );
|
2021-12-28 22:13:54 +00:00
|
|
|
headStyle->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
|
|
|
headStyle->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
// Style : data
|
2022-07-29 21:02:35 +00:00
|
|
|
std::unique_ptr<PCB_TEXT> dataStyle = std::make_unique<PCB_TEXT>( footprint );
|
2021-03-14 15:12:51 +00:00
|
|
|
dataStyle->SetLayer( Eco1_User );
|
2023-02-19 03:40:07 +00:00
|
|
|
dataStyle->SetTextSize( VECTOR2I( pcbIUScale.mmToIU( 1.5 ), pcbIUScale.mmToIU( 1.5 ) ) );
|
2022-09-16 11:33:56 +00:00
|
|
|
dataStyle->SetTextThickness( pcbIUScale.mmToIU( 0.1 ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
dataStyle->SetItalic( false );
|
2023-02-19 03:40:07 +00:00
|
|
|
dataStyle->SetTextPos( VECTOR2I( 0, 0 ) );
|
2022-02-05 13:25:43 +00:00
|
|
|
dataStyle->SetText( _( "Layer" ) );
|
2021-12-28 22:13:54 +00:00
|
|
|
dataStyle->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
|
|
|
dataStyle->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
//Get Layer names
|
2021-09-13 16:18:58 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
|
|
|
|
BOARD_STACKUP& stackup = dsnSettings.GetStackupDescriptor();
|
2021-06-24 08:52:51 +00:00
|
|
|
stackup.SynchronizeWithBoard( &dsnSettings );
|
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
std::vector<BOARD_STACKUP_ITEM*> layers = stackup.GetList();
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
std::vector<PCB_TEXT*> colLayer;
|
|
|
|
std::vector<PCB_TEXT*> colType;
|
|
|
|
std::vector<PCB_TEXT*> colMaterial;
|
|
|
|
std::vector<PCB_TEXT*> colThickness;
|
|
|
|
std::vector<PCB_TEXT*> colColor;
|
|
|
|
std::vector<PCB_TEXT*> colEpsilon;
|
|
|
|
std::vector<PCB_TEXT*> colTanD;
|
|
|
|
PCB_TEXT* t;
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( headStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Layer Name" ) );
|
|
|
|
colLayer.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( headStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Type" ) );
|
|
|
|
colType.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( headStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Material" ) );
|
|
|
|
colMaterial.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( headStyle->Duplicate() );
|
|
|
|
|
2021-10-08 20:37:39 +00:00
|
|
|
switch( m_frame->GetUserUnits() )
|
|
|
|
{
|
|
|
|
case EDA_UNITS::MILLIMETRES: t->SetText( _( "Thickness (mm)" ) ); break;
|
|
|
|
case EDA_UNITS::INCHES: t->SetText( _( "Thickness (inches)" ) ); break;
|
|
|
|
case EDA_UNITS::MILS: t->SetText( _( "Thickness (mils)" ) ); break;
|
2022-02-05 13:25:43 +00:00
|
|
|
default: wxFAIL_MSG( wxT( "Unhandled unit type" ) );
|
2021-10-08 20:37:39 +00:00
|
|
|
}
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
colThickness.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( headStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Color" ) );
|
|
|
|
colColor.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( headStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Epsilon R" ) );
|
|
|
|
colEpsilon.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( headStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Loss Tangent" ) );
|
|
|
|
colTanD.push_back( t );
|
|
|
|
|
2021-09-26 08:01:59 +00:00
|
|
|
for( int i = 0; i < stackup.GetCount(); i++ )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
2021-09-26 08:01:59 +00:00
|
|
|
BOARD_STACKUP_ITEM* stackup_item = layers.at( i );
|
2021-09-22 19:37:17 +00:00
|
|
|
|
2022-12-02 09:41:03 +00:00
|
|
|
for( int sublayer_id = 0; sublayer_id < stackup_item->GetSublayersCount(); sublayer_id++ )
|
2021-06-24 08:52:51 +00:00
|
|
|
{
|
2021-09-26 08:01:59 +00:00
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
|
Fix source comment/doc typos (follow-up)
Found via `codespell -q 3 -S *.po,./thirdparty -L aactual,acount,aline,alocation,alog,anormal,anumber,aother,apoints,aparent,aray,dout,einstance,modul,ot,overide,serie,te,,tesselate,tesselator,tht`
2021-07-03 22:37:31 +00:00
|
|
|
// Layer names are empty until we close at least once the board setup dialog.
|
2021-06-24 08:52:51 +00:00
|
|
|
// If the user did not open the dialog, then get the names from the board.
|
|
|
|
// But dielectric layer names will be missing.
|
2021-09-26 08:01:59 +00:00
|
|
|
// In this case, for dielectric, a dummy name will be used
|
|
|
|
if( stackup_item->GetLayerName().IsEmpty() )
|
|
|
|
{
|
2021-09-26 08:54:50 +00:00
|
|
|
wxString ly_name;
|
|
|
|
|
|
|
|
if( IsValidLayer( stackup_item->GetBrdLayerId() ) )
|
|
|
|
ly_name = m_frame->GetBoard()->GetLayerName( stackup_item->GetBrdLayerId() );
|
2021-09-26 08:01:59 +00:00
|
|
|
|
|
|
|
if( ly_name.IsEmpty() && stackup_item->GetType() == BS_ITEM_TYPE_DIELECTRIC )
|
2022-08-20 09:27:35 +00:00
|
|
|
ly_name = _( "Dielectric" );
|
2021-07-26 19:35:12 +00:00
|
|
|
|
2021-09-26 08:01:59 +00:00
|
|
|
t->SetText( ly_name );
|
|
|
|
}
|
2021-06-24 08:52:51 +00:00
|
|
|
else
|
2022-07-29 21:02:35 +00:00
|
|
|
{
|
2021-09-26 08:01:59 +00:00
|
|
|
t->SetText( stackup_item->GetLayerName() );
|
2022-07-29 21:02:35 +00:00
|
|
|
}
|
2021-07-26 19:35:12 +00:00
|
|
|
|
2021-06-24 08:52:51 +00:00
|
|
|
colLayer.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
2021-09-26 08:01:59 +00:00
|
|
|
t->SetText( stackup_item->GetTypeName() );
|
2021-06-24 08:52:51 +00:00
|
|
|
colType.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
2022-12-02 09:41:03 +00:00
|
|
|
t->SetText( stackup_item->GetMaterial( sublayer_id ) );
|
2021-06-24 08:52:51 +00:00
|
|
|
colMaterial.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
2022-12-02 09:41:03 +00:00
|
|
|
t->SetText( m_frame->StringFromValue( stackup_item->GetThickness( sublayer_id ), true ) );
|
2021-06-24 08:52:51 +00:00
|
|
|
colThickness.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
2022-12-02 09:41:03 +00:00
|
|
|
t->SetText( stackup_item->GetColor( sublayer_id ) );
|
2021-06-24 08:52:51 +00:00
|
|
|
colColor.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
2022-09-19 09:25:20 +00:00
|
|
|
t->SetText( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, EDA_UNITS::UNSCALED,
|
2022-12-02 09:41:03 +00:00
|
|
|
stackup_item->GetEpsilonR( sublayer_id ), false ) );
|
2021-06-24 08:52:51 +00:00
|
|
|
colEpsilon.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
2022-09-19 09:25:20 +00:00
|
|
|
t->SetText( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, EDA_UNITS::UNSCALED,
|
2022-12-02 09:41:03 +00:00
|
|
|
stackup_item->GetLossTangent( sublayer_id ), false ) );
|
2021-06-24 08:52:51 +00:00
|
|
|
colTanD.push_back( t );
|
|
|
|
}
|
2021-03-14 15:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
texts.push_back( colLayer );
|
|
|
|
texts.push_back( colType );
|
|
|
|
texts.push_back( colMaterial );
|
|
|
|
texts.push_back( colThickness );
|
|
|
|
texts.push_back( colColor );
|
|
|
|
texts.push_back( colEpsilon );
|
|
|
|
texts.push_back( colTanD );
|
2021-07-26 19:35:12 +00:00
|
|
|
std::vector<BOARD_ITEM*> table = initTextTable( texts, aOrigin, aLayer, tableSize, true );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
if( aDrawNow )
|
|
|
|
{
|
2021-09-13 16:18:58 +00:00
|
|
|
for( BOARD_ITEM* item : table )
|
2021-03-14 15:12:51 +00:00
|
|
|
commit.Add( item );
|
|
|
|
|
|
|
|
commit.Push( _( "Insert board stackup table" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2022-07-29 21:02:35 +00:00
|
|
|
std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawBoardCharacteristics( const VECTOR2I& aOrigin,
|
2021-09-13 16:18:58 +00:00
|
|
|
PCB_LAYER_ID aLayer,
|
|
|
|
bool aDrawNow,
|
2022-07-29 21:02:35 +00:00
|
|
|
VECTOR2I* tableSize )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
2021-09-13 16:18:58 +00:00
|
|
|
BOARD_COMMIT commit( m_frame );
|
2021-03-14 15:12:51 +00:00
|
|
|
std::vector<BOARD_ITEM*> objects;
|
|
|
|
BOARD_DESIGN_SETTINGS& settings = m_frame->GetBoard()->GetDesignSettings();
|
|
|
|
BOARD_STACKUP& stackup = settings.GetStackupDescriptor();
|
|
|
|
|
2022-07-29 21:02:35 +00:00
|
|
|
VECTOR2I cursorPos = aOrigin;
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
// Style : Section header
|
2022-02-05 16:15:10 +00:00
|
|
|
std::unique_ptr<PCB_TEXT> headStyle =
|
|
|
|
std::make_unique<PCB_TEXT>( static_cast<FOOTPRINT*>( m_frame->GetModel() ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
headStyle->SetLayer( Eco1_User );
|
2023-02-19 03:40:07 +00:00
|
|
|
headStyle->SetTextSize( VECTOR2I( pcbIUScale.mmToIU( 2.0 ), pcbIUScale.mmToIU( 2.0 ) ) );
|
2022-09-16 11:33:56 +00:00
|
|
|
headStyle->SetTextThickness( pcbIUScale.mmToIU( 0.4 ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
headStyle->SetItalic( false );
|
2023-02-19 03:40:07 +00:00
|
|
|
headStyle->SetTextPos( VECTOR2I( 0, 0 ) );
|
2021-12-28 22:13:54 +00:00
|
|
|
headStyle->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
|
|
|
headStyle->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
// Style : Data
|
2022-02-05 16:15:10 +00:00
|
|
|
std::unique_ptr<PCB_TEXT> dataStyle =
|
|
|
|
std::make_unique<PCB_TEXT>( static_cast<FOOTPRINT*>( m_frame->GetModel() ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
dataStyle->SetLayer( Eco1_User );
|
2023-02-19 03:40:07 +00:00
|
|
|
dataStyle->SetTextSize( VECTOR2I( pcbIUScale.mmToIU( 1.5 ), pcbIUScale.mmToIU( 1.5 ) ) );
|
2022-09-16 11:33:56 +00:00
|
|
|
dataStyle->SetTextThickness( pcbIUScale.mmToIU( 0.2 ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
dataStyle->SetItalic( false );
|
2023-02-19 03:40:07 +00:00
|
|
|
dataStyle->SetTextPos( VECTOR2I( 0, 0 ) );
|
2021-12-28 22:13:54 +00:00
|
|
|
dataStyle->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
|
|
|
dataStyle->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
PCB_TEXT* t;
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( headStyle->Duplicate() );
|
|
|
|
t->SetText( _( "BOARD CHARACTERISTICS" ) );
|
|
|
|
t->SetPosition( cursorPos );
|
|
|
|
objects.push_back( t );
|
|
|
|
|
|
|
|
cursorPos.y = cursorPos.y + t->GetBoundingBox().GetHeight()
|
2022-09-16 04:38:10 +00:00
|
|
|
+ EDA_UNIT_UTILS::UI::FromUserUnit( pcbIUScale, EDA_UNITS::MILLIMETRES, 1.0 );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
std::vector<std::vector<PCB_TEXT*>> texts;
|
|
|
|
std::vector<PCB_TEXT*> colLabel1;
|
|
|
|
std::vector<PCB_TEXT*> colData1;
|
|
|
|
std::vector<PCB_TEXT*> colbreak;
|
|
|
|
std::vector<PCB_TEXT*> colLabel2;
|
|
|
|
std::vector<PCB_TEXT*> colData2;
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Copper Layer Count: " ) );
|
|
|
|
colLabel1.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
2022-09-19 09:25:20 +00:00
|
|
|
t->SetText( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, EDA_UNITS::UNSCALED,
|
|
|
|
settings.GetCopperLayerCount(), false ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
colData1.push_back( t );
|
|
|
|
|
2022-02-25 19:11:36 +00:00
|
|
|
SHAPE_POLY_SET outline;
|
|
|
|
m_frame->GetBoard()->GetBoardPolygonOutlines( outline );
|
|
|
|
BOX2I size = outline.BBox();
|
2021-03-14 15:12:51 +00:00
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Board overall dimensions: " ) );
|
|
|
|
colLabel1.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
2022-02-05 13:25:43 +00:00
|
|
|
t->SetText( wxString::Format( wxT( "%s x %s" ),
|
2022-09-19 09:25:20 +00:00
|
|
|
m_frame->MessageTextFromValue( size.GetWidth(), true ),
|
|
|
|
m_frame->MessageTextFromValue( size.GetHeight(), true ) ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
colData1.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Min track/spacing: " ) );
|
|
|
|
colLabel1.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
2022-02-05 13:25:43 +00:00
|
|
|
t->SetText( wxString::Format( wxT( "%s / %s" ),
|
2022-09-19 09:25:20 +00:00
|
|
|
m_frame->MessageTextFromValue( settings.m_TrackMinWidth, true ),
|
|
|
|
m_frame->MessageTextFromValue( settings.m_MinClearance, true ) ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
colData1.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Copper Finish: " ) );
|
|
|
|
colLabel1.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
t->SetText( stackup.m_FinishType );
|
|
|
|
colData1.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Castellated pads: " ) );
|
|
|
|
colLabel1.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
t->SetText( stackup.m_CastellatedPads ? _( "Yes" ) : _( "No" ) );
|
|
|
|
colData1.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Board Thickness: " ) );
|
|
|
|
colLabel2.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
2022-09-19 09:25:20 +00:00
|
|
|
t->SetText( m_frame->MessageTextFromValue( settings.GetBoardThickness(), true ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
colData2.push_back( t );
|
|
|
|
|
|
|
|
// some empty cells
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
colLabel2.push_back( t );
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
colData2.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Min hole diameter: " ) );
|
|
|
|
colLabel2.push_back( t );
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
|
|
|
|
double holeSize = std::min( settings.m_MinThroughDrill, settings.m_ViasMinSize );
|
2022-09-19 09:25:20 +00:00
|
|
|
t->SetText( m_frame->MessageTextFromValue( holeSize, true ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
colData2.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Impedance Control: " ) );
|
|
|
|
colLabel2.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
2021-09-26 08:01:59 +00:00
|
|
|
t->SetText( stackup.m_HasDielectricConstrains ? _( "Yes" ) : _( "No" ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
colData2.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Plated Board Edge: " ) );
|
|
|
|
colLabel2.push_back( t );
|
2021-09-26 08:01:59 +00:00
|
|
|
|
2021-03-14 15:12:51 +00:00
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
2021-09-26 08:01:59 +00:00
|
|
|
t->SetText( stackup.m_EdgePlating ? _( "Yes" ) : _( "No" ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
colData2.push_back( t );
|
|
|
|
|
2021-09-26 08:01:59 +00:00
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
t->SetText( _( "Edge card connectors: " ) );
|
|
|
|
colLabel1.push_back( t );
|
|
|
|
|
|
|
|
t = static_cast<PCB_TEXT*>( dataStyle->Duplicate() );
|
|
|
|
switch( stackup.m_EdgeConnectorConstraints )
|
|
|
|
{
|
|
|
|
case BS_EDGE_CONNECTOR_NONE: t->SetText( _( "No" ) ); break;
|
|
|
|
case BS_EDGE_CONNECTOR_IN_USE: t->SetText( _( "Yes" ) ); break;
|
|
|
|
case BS_EDGE_CONNECTOR_BEVELLED: t->SetText( _( "Yes, Bevelled" ) ); break;
|
|
|
|
}
|
|
|
|
colData1.push_back( t );
|
|
|
|
|
2021-03-14 15:12:51 +00:00
|
|
|
texts.push_back( colLabel1 );
|
|
|
|
texts.push_back( colData1 );
|
|
|
|
texts.push_back( colbreak );
|
|
|
|
texts.push_back( colLabel2 );
|
|
|
|
texts.push_back( colData2 );
|
2022-07-29 21:02:35 +00:00
|
|
|
VECTOR2I tableSize2;
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
std::vector<BOARD_ITEM*> table = initTextTable( texts, cursorPos, Eco1_User, &tableSize2,
|
|
|
|
false );
|
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
for( BOARD_ITEM* item : table )
|
2021-03-14 15:12:51 +00:00
|
|
|
objects.push_back( item );
|
|
|
|
|
|
|
|
if( aDrawNow )
|
|
|
|
{
|
2022-08-20 09:27:35 +00:00
|
|
|
for( BOARD_ITEM* item : objects )
|
2021-03-14 15:12:51 +00:00
|
|
|
commit.Add( item );
|
|
|
|
|
2022-02-05 13:25:43 +00:00
|
|
|
commit.Push( wxT( "Board Characteristics" ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tableSize->x = tableSize2.x;
|
2022-09-16 04:38:10 +00:00
|
|
|
tableSize->y = cursorPos.y + tableSize2.y
|
|
|
|
+ EDA_UNIT_UTILS::UI::FromUserUnit( pcbIUScale, EDA_UNITS::MILLIMETRES, 2.0 );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
return objects;
|
|
|
|
}
|
|
|
|
|
2021-03-14 16:44:01 +00:00
|
|
|
|
2021-03-14 19:12:25 +00:00
|
|
|
int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
|
|
|
|
std::vector<BOARD_ITEM*>& aItems,
|
|
|
|
std::vector<BOARD_ITEM*>& aPreview,
|
|
|
|
LSET* aLayers )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
|
|
|
if( m_isFootprintEditor && !m_frame->GetModel() )
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
bool cancelled = false;
|
|
|
|
|
|
|
|
BOARD_COMMIT commit( m_frame );
|
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
// do not capture or auto-pan until we start placing the table
|
2021-03-14 15:12:51 +00:00
|
|
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
|
|
|
|
|
2022-09-14 17:31:56 +00:00
|
|
|
m_frame->PushTool( aEvent );
|
2021-09-13 12:23:10 +00:00
|
|
|
|
2021-03-14 15:12:51 +00:00
|
|
|
Activate();
|
2021-09-13 12:23:10 +00:00
|
|
|
// Must be done after Activate() so that it gets set into the correct context
|
|
|
|
m_controls->ShowCursor( true );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
if( aEvent.HasPosition() )
|
2022-05-16 09:22:55 +00:00
|
|
|
m_toolMgr->PrimeTool( aEvent.Position() );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
// Main loop: keep receiving events
|
2022-11-14 23:39:08 +00:00
|
|
|
VECTOR2I cursorPosition;
|
|
|
|
VECTOR2I previousCursorPosition;
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
view()->ClearPreview();
|
|
|
|
view()->InitPreview();
|
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
for( BOARD_ITEM* item : aPreview )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
2022-11-14 23:39:08 +00:00
|
|
|
item->Move( cursorPosition - previousCursorPosition );
|
2021-03-14 15:12:51 +00:00
|
|
|
view()->AddToPreview( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
while( TOOL_EVENT* evt = Wait() )
|
|
|
|
{
|
|
|
|
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
|
2022-11-14 23:39:08 +00:00
|
|
|
cursorPosition = m_controls->GetCursorPosition();
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
if( evt->IsCancelInteractive() )
|
|
|
|
{
|
2022-09-14 17:31:56 +00:00
|
|
|
m_frame->PopTool( aEvent );
|
2021-03-14 15:12:51 +00:00
|
|
|
cancelled = true;
|
|
|
|
break;
|
|
|
|
}
|
2022-11-14 23:39:08 +00:00
|
|
|
else if( evt->IsMotion() )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
|
|
|
view()->ShowPreview( false );
|
|
|
|
|
2022-11-14 23:39:08 +00:00
|
|
|
for( BOARD_ITEM* item : aPreview )
|
|
|
|
item->Move( cursorPosition - previousCursorPosition );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
view()->ShowPreview( true );
|
|
|
|
|
2022-11-14 23:39:08 +00:00
|
|
|
previousCursorPosition = cursorPosition;
|
2021-03-14 15:12:51 +00:00
|
|
|
}
|
|
|
|
else if( evt->IsActivate() )
|
|
|
|
{
|
|
|
|
if( evt->IsMoveTool() )
|
|
|
|
{
|
|
|
|
// leave ourselves on the stack so we come back after the move
|
|
|
|
cancelled = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-14 17:31:56 +00:00
|
|
|
m_frame->PopTool( aEvent );
|
2021-03-14 15:12:51 +00:00
|
|
|
cancelled = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( evt->IsClick( BUT_RIGHT ) )
|
|
|
|
{
|
|
|
|
m_menu.ShowContextMenu( selection() );
|
|
|
|
}
|
|
|
|
else if( evt->IsClick( BUT_LEFT ) )
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
if( aLayers != nullptr )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
2021-09-13 16:18:58 +00:00
|
|
|
PCB_LAYER_ID destLayer = frame()->SelectOneLayer( PCB_LAYER_ID::PCB_LAYER_ID_COUNT,
|
|
|
|
*aLayers, wxGetMousePosition() );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
view()->ClearPreview();
|
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
if( destLayer == PCB_LAYER_ID::UNDEFINED_LAYER )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
2021-03-14 16:44:01 +00:00
|
|
|
// The user did not pick any layer.
|
2022-09-14 17:31:56 +00:00
|
|
|
m_frame->PopTool( aEvent );
|
2021-03-14 15:12:51 +00:00
|
|
|
cancelled = true;
|
2021-03-14 16:44:01 +00:00
|
|
|
break;
|
2021-03-14 15:12:51 +00:00
|
|
|
}
|
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
for( BOARD_ITEM* item : aItems )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
|
|
|
if( item->Type() == PCB_GROUP_T )
|
2021-09-13 16:18:58 +00:00
|
|
|
static_cast<PCB_GROUP*>( item )->SetLayerRecursive( destLayer, 200 );
|
2021-03-14 15:12:51 +00:00
|
|
|
else
|
2021-09-13 16:18:58 +00:00
|
|
|
item->SetLayer( destLayer );
|
2021-03-14 15:12:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
for( BOARD_ITEM* item : aItems )
|
2021-03-14 15:12:51 +00:00
|
|
|
{
|
2022-11-14 23:39:08 +00:00
|
|
|
item->Move( cursorPosition );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
if( item->Type() == PCB_GROUP_T )
|
|
|
|
static_cast<PCB_GROUP*>( item )->AddChildrenToCommit( commit );
|
|
|
|
|
|
|
|
commit.Add( item );
|
|
|
|
}
|
|
|
|
|
2022-02-05 13:25:43 +00:00
|
|
|
commit.Push( wxT( "Placing items" ) );
|
2022-09-14 17:31:56 +00:00
|
|
|
m_frame->PopTool( aEvent );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2022-11-14 23:39:08 +00:00
|
|
|
// TODO: It'd be nice to be able to say "don't allow any non-trivial editing actions",
|
|
|
|
// but we don't at present have that, so we just knock out some of the egregious ones.
|
|
|
|
else if( ZONE_FILLER_TOOL::IsZoneFillAction( evt ) )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
}
|
2021-03-14 15:12:51 +00:00
|
|
|
else
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2021-03-14 15:12:51 +00:00
|
|
|
evt->SetPassEvent();
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2021-03-14 15:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
view()->ClearPreview();
|
|
|
|
frame()->SetMsgPanel( board() );
|
|
|
|
|
|
|
|
if( cancelled )
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-07-26 19:35:12 +00:00
|
|
|
|
2021-03-14 15:12:51 +00:00
|
|
|
int DRAWING_TOOL::PlaceCharacteristics( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2022-07-29 21:02:35 +00:00
|
|
|
VECTOR2I tableSize;
|
2021-03-14 15:12:51 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
LSET layerSet = ( layerSet.AllCuMask() | layerSet.AllTechMask() );
|
|
|
|
layerSet = layerSet.set( Edge_Cuts ).set( Margin );
|
|
|
|
layerSet = layerSet.reset( F_Fab ).reset( B_Fab );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
2022-07-29 21:02:35 +00:00
|
|
|
PCB_LAYER_ID layer = m_frame->GetActiveLayer();
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
if( ( layerSet & LSET( layer ) ).count() ) // if layer is a forbidden layer
|
|
|
|
m_frame->SetActiveLayer( Cmts_User );
|
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
std::vector<BOARD_ITEM*> table = DrawBoardCharacteristics( { 0, 0 }, m_frame->GetActiveLayer(),
|
|
|
|
false, &tableSize );
|
2021-03-14 19:12:25 +00:00
|
|
|
std::vector<BOARD_ITEM*> preview;
|
|
|
|
std::vector<BOARD_ITEM*> items;
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
PCB_SHAPE* line1 = new PCB_SHAPE;
|
|
|
|
PCB_SHAPE* line2 = new PCB_SHAPE;
|
|
|
|
PCB_SHAPE* line3 = new PCB_SHAPE;
|
|
|
|
PCB_SHAPE* line4 = new PCB_SHAPE;
|
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
line1->SetStart( VECTOR2I( 0, 0 ) );
|
|
|
|
line1->SetEnd( VECTOR2I( tableSize.x, 0 ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
line2->SetStart( VECTOR2I( 0, 0 ) );
|
|
|
|
line2->SetEnd( VECTOR2I( 0, tableSize.y ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
line3->SetStart( VECTOR2I( tableSize.x, 0 ) );
|
|
|
|
line3->SetEnd( tableSize );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
line4->SetStart( VECTOR2I( 0, tableSize.y ) );
|
|
|
|
line4->SetEnd( tableSize );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
line1->SetLayer( m_frame->GetActiveLayer() );
|
|
|
|
line2->SetLayer( m_frame->GetActiveLayer() );
|
|
|
|
line3->SetLayer( m_frame->GetActiveLayer() );
|
|
|
|
line4->SetLayer( m_frame->GetActiveLayer() );
|
|
|
|
|
2021-03-14 19:12:25 +00:00
|
|
|
preview.push_back( line1 );
|
|
|
|
preview.push_back( line2 );
|
|
|
|
preview.push_back( line3 );
|
|
|
|
preview.push_back( line4 );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
PCB_GROUP* group = new PCB_GROUP( m_board );
|
|
|
|
group->SetName("group-boardCharacteristics");
|
|
|
|
|
|
|
|
for( auto item : table )
|
|
|
|
group->AddItem( static_cast<BOARD_ITEM*>( item ) );
|
|
|
|
|
2021-03-14 19:12:25 +00:00
|
|
|
items.push_back( static_cast<BOARD_ITEM*>( group ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
2021-03-14 19:12:25 +00:00
|
|
|
if( InteractivePlaceWithPreview( aEvent, items, preview, &layerSet ) == -1 )
|
2022-07-29 21:02:35 +00:00
|
|
|
m_frame->SetActiveLayer( layer );
|
2021-03-14 15:12:51 +00:00
|
|
|
else
|
|
|
|
m_frame->SetActiveLayer( table.front()->GetLayer() );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-07-26 19:35:12 +00:00
|
|
|
|
2021-03-14 15:12:51 +00:00
|
|
|
int DRAWING_TOOL::PlaceStackup( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2022-07-29 21:02:35 +00:00
|
|
|
VECTOR2I tableSize;
|
2021-03-14 15:12:51 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
LSET layerSet = ( layerSet.AllCuMask() | layerSet.AllTechMask() );
|
|
|
|
layerSet = layerSet.set( Edge_Cuts ).set( Margin );
|
|
|
|
layerSet = layerSet.reset( F_Fab ).reset( B_Fab );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
PCB_LAYER_ID layer = m_frame->GetActiveLayer();
|
|
|
|
PCB_LAYER_ID savedLayer = layer;
|
|
|
|
|
|
|
|
if( ( layerSet & LSET( layer ) ).count() ) // if layer is a forbidden layer
|
|
|
|
{
|
|
|
|
m_frame->SetActiveLayer( Cmts_User );
|
|
|
|
layer = Cmts_User;
|
|
|
|
}
|
|
|
|
|
2022-07-29 21:02:35 +00:00
|
|
|
std::vector<BOARD_ITEM*> table = DrawSpecificationStackup( VECTOR2I( 0, 0 ),
|
|
|
|
m_frame->GetActiveLayer(), false,
|
|
|
|
&tableSize );
|
2021-03-14 19:12:25 +00:00
|
|
|
std::vector<BOARD_ITEM*> preview;
|
|
|
|
std::vector<BOARD_ITEM*> items;
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
PCB_SHAPE* line1 = new PCB_SHAPE;
|
|
|
|
PCB_SHAPE* line2 = new PCB_SHAPE;
|
|
|
|
PCB_SHAPE* line3 = new PCB_SHAPE;
|
|
|
|
PCB_SHAPE* line4 = new PCB_SHAPE;
|
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
line1->SetStart( VECTOR2I( 0, 0 ) );
|
|
|
|
line1->SetEnd( VECTOR2I( tableSize.x, 0 ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
line2->SetStart( VECTOR2I( 0, 0 ) );
|
|
|
|
line2->SetEnd( VECTOR2I( 0, tableSize.y ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
line3->SetStart( VECTOR2I( tableSize.x, 0 ) );
|
|
|
|
line3->SetEnd( tableSize );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
line4->SetStart( VECTOR2I( 0, tableSize.y ) );
|
|
|
|
line4->SetEnd( tableSize );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
line1->SetLayer( m_frame->GetActiveLayer() );
|
|
|
|
line2->SetLayer( m_frame->GetActiveLayer() );
|
|
|
|
line3->SetLayer( m_frame->GetActiveLayer() );
|
|
|
|
line4->SetLayer( m_frame->GetActiveLayer() );
|
|
|
|
|
2021-03-14 19:12:25 +00:00
|
|
|
preview.push_back( line1 );
|
|
|
|
preview.push_back( line2 );
|
|
|
|
preview.push_back( line3 );
|
|
|
|
preview.push_back( line4 );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
|
|
|
PCB_GROUP* group = new PCB_GROUP( m_board );
|
2022-08-20 09:27:35 +00:00
|
|
|
group->SetName( "group-boardStackUp" );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
2021-09-13 16:18:58 +00:00
|
|
|
for( BOARD_ITEM* item : table )
|
2021-03-14 15:12:51 +00:00
|
|
|
group->AddItem( item );
|
|
|
|
|
2021-03-14 19:12:25 +00:00
|
|
|
items.push_back( static_cast<BOARD_ITEM*>( group ) );
|
2021-03-14 15:12:51 +00:00
|
|
|
|
2021-03-14 19:12:25 +00:00
|
|
|
if( InteractivePlaceWithPreview( aEvent, items, preview, &layerSet ) == -1 )
|
2021-03-14 15:12:51 +00:00
|
|
|
m_frame->SetActiveLayer( savedLayer );
|
|
|
|
else
|
|
|
|
m_frame->SetActiveLayer( table.front()->GetLayer() );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|