Introduce PCB_GENERATOR.
This commit is contained in:
parent
0fcb36bc2e
commit
be72e07e61
|
@ -656,6 +656,7 @@ set( PCB_COMMON_SRCS
|
|||
${CMAKE_SOURCE_DIR}/pcbnew/project_pcb.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/board_stackup_manager/board_stackup.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/pcb_track.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/pcb_generator.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/zone.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/collectors.cpp
|
||||
${CMAKE_SOURCE_DIR}/pcbnew/connectivity/connectivity_algo.cpp
|
||||
|
|
|
@ -345,6 +345,7 @@ static struct EDA_ITEM_DESC
|
|||
.Map( PCB_PAD_T, _HKI( "Pad" ) )
|
||||
.Map( PCB_SHAPE_T, _HKI( "Graphic" ) )
|
||||
.Map( PCB_BITMAP_T, _HKI( "Bitmap" ) )
|
||||
.Map( PCB_GENERATOR_T, _HKI( "Generator" ) )
|
||||
.Map( PCB_FIELD_T, _HKI( "Field" ) )
|
||||
.Map( PCB_TEXT_T, _HKI( "Text" ) )
|
||||
.Map( PCB_TEXTBOX_T, _HKI( "Text Box" ) )
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 CERN
|
||||
* Copyright (C) 2004-2022 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2004-2023 KiCad Developers, see change_log.txt for contributors.
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -88,6 +88,7 @@ enum KICAD_T
|
|||
PCB_SHAPE_T, ///< class PCB_SHAPE, a segment not on copper layers
|
||||
PCB_BITMAP_T, ///< class PCB_BITMAP, bitmap on a layer
|
||||
PCB_FIELD_T, ///< class PCB_FIELD, text associated with a footprint property
|
||||
PCB_GENERATOR_T, ///< class PCB_GENERATOR, generator on a layer
|
||||
PCB_TEXT_T, ///< class PCB_TEXT, text on a layer
|
||||
PCB_TEXTBOX_T, ///< class PCB_TEXTBOX, wrapped text on a layer
|
||||
PCB_TRACE_T, ///< class PCB_TRACK, a track segment (segment on a copper layer)
|
||||
|
@ -452,6 +453,7 @@ constexpr bool IsPcbnewType( const KICAD_T aType )
|
|||
case PCB_ITEM_LIST_T:
|
||||
case PCB_NETINFO_T:
|
||||
case PCB_GROUP_T:
|
||||
case PCB_GENERATOR_T:
|
||||
|
||||
case PCB_FIELD_LOCATE_REFERENCE_T:
|
||||
case PCB_FIELD_LOCATE_VALUE_T:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 Joshua Redstone redstone at gmail.com
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -80,14 +80,14 @@ public:
|
|||
*
|
||||
* @return true if item was added (false if item belongs to a different group).
|
||||
*/
|
||||
bool AddItem( BOARD_ITEM* aItem );
|
||||
virtual bool AddItem( BOARD_ITEM* aItem );
|
||||
|
||||
/**
|
||||
* Remove item from group.
|
||||
*
|
||||
* @return true if item was removed (false if item was not in the group).
|
||||
*/
|
||||
bool RemoveItem( BOARD_ITEM* aItem );
|
||||
virtual bool RemoveItem( BOARD_ITEM* aItem );
|
||||
|
||||
void RemoveAll();
|
||||
|
||||
|
@ -236,10 +236,11 @@ public:
|
|||
static bool IsGroupableType( KICAD_T aType );
|
||||
|
||||
protected:
|
||||
PCB_GROUP( BOARD_ITEM* aParent, KICAD_T idtype, PCB_LAYER_ID aLayer = F_Cu );
|
||||
|
||||
/// @copydoc BOARD_ITEM::swapData
|
||||
void swapData( BOARD_ITEM* aImage ) override;
|
||||
|
||||
private:
|
||||
std::unordered_set<BOARD_ITEM*> m_items; // Members of the group
|
||||
wxString m_name; // Optional group name
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
|
||||
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* 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
|
||||
|
@ -51,6 +51,7 @@ struct SELECTION_FILTER_OPTIONS
|
|||
bool zones; ///< Copper zones
|
||||
bool keepouts; ///< Keepout zones
|
||||
bool dimensions; ///< Dimension items
|
||||
bool generators; ///< Generator items
|
||||
bool otherItems; ///< Anything not fitting one of the above categories
|
||||
|
||||
SELECTION_FILTER_OPTIONS()
|
||||
|
@ -65,6 +66,7 @@ struct SELECTION_FILTER_OPTIONS
|
|||
zones = true;
|
||||
keepouts = true;
|
||||
dimensions = true;
|
||||
generators = true;
|
||||
otherItems = true;
|
||||
}
|
||||
|
||||
|
@ -74,7 +76,7 @@ struct SELECTION_FILTER_OPTIONS
|
|||
bool Any()
|
||||
{
|
||||
return ( footprints || text || tracks || vias || pads || graphics || zones
|
||||
|| keepouts || dimensions || otherItems );
|
||||
|| keepouts || dimensions || generators || otherItems );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,7 +85,7 @@ struct SELECTION_FILTER_OPTIONS
|
|||
bool All()
|
||||
{
|
||||
return ( footprints && text && tracks && vias && pads && graphics && zones
|
||||
&& keepouts && dimensions && otherItems );
|
||||
&& keepouts && dimensions && generators && otherItems );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Created on: 11 Mar 2016, author John Beard
|
||||
* Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -119,6 +119,7 @@ void ARRAY_CREATOR::Invoke()
|
|||
case PCB_FOOTPRINT_T:
|
||||
case PCB_SHAPE_T:
|
||||
case PCB_BITMAP_T:
|
||||
case PCB_GENERATOR_T:
|
||||
case PCB_TEXT_T:
|
||||
case PCB_TEXTBOX_T:
|
||||
case PCB_TRACE_T:
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <pcb_track.h>
|
||||
#include <pcb_marker.h>
|
||||
#include <pcb_group.h>
|
||||
#include <pcb_generator.h>
|
||||
#include <pcb_target.h>
|
||||
#include <pcb_shape.h>
|
||||
#include <pcb_bitmap.h>
|
||||
|
@ -133,6 +134,12 @@ BOARD::~BOARD()
|
|||
item->SetParentGroup( nullptr );
|
||||
}
|
||||
|
||||
for( PCB_GENERATOR* generator : m_generators )
|
||||
{
|
||||
for( BOARD_ITEM* item : generator->GetItems() )
|
||||
item->SetParentGroup( nullptr );
|
||||
}
|
||||
|
||||
// Clean up the owned elements
|
||||
DeleteMARKERs();
|
||||
|
||||
|
@ -162,6 +169,11 @@ BOARD::~BOARD()
|
|||
delete g;
|
||||
|
||||
m_groups.clear();
|
||||
|
||||
for( PCB_GENERATOR* g : m_generators )
|
||||
delete g;
|
||||
|
||||
m_generators.clear();
|
||||
}
|
||||
|
||||
|
||||
|
@ -841,6 +853,11 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectivity
|
|||
m_groups.push_back( (PCB_GROUP*) aBoardItem );
|
||||
break;
|
||||
|
||||
// this one uses a vector
|
||||
case PCB_GENERATOR_T:
|
||||
m_generators.push_back( (PCB_GENERATOR*) aBoardItem );
|
||||
break;
|
||||
|
||||
// this one uses a vector
|
||||
case PCB_ZONE_T:
|
||||
m_zones.push_back( (ZONE*) aBoardItem );
|
||||
|
@ -976,6 +993,10 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aRemoveMode )
|
|||
alg::delete_matching( m_zones, aBoardItem );
|
||||
break;
|
||||
|
||||
case PCB_GENERATOR_T:
|
||||
alg::delete_matching( m_generators, aBoardItem );
|
||||
break;
|
||||
|
||||
case PCB_FOOTPRINT_T:
|
||||
alg::delete_matching( m_footprints, aBoardItem );
|
||||
break;
|
||||
|
@ -1163,6 +1184,13 @@ BOARD_ITEM* BOARD::GetItem( const KIID& aID ) const
|
|||
return group;
|
||||
}
|
||||
|
||||
for( PCB_GENERATOR* generator : m_generators )
|
||||
{
|
||||
if( generator->m_Uuid == aID )
|
||||
return generator;
|
||||
}
|
||||
|
||||
|
||||
for( NETINFO_ITEM* netInfo : m_NetInfo )
|
||||
{
|
||||
if( netInfo->m_Uuid == aID )
|
||||
|
@ -1210,6 +1238,9 @@ void BOARD::FillItemMap( std::map<KIID, EDA_ITEM*>& aMap )
|
|||
|
||||
for( PCB_GROUP* group : m_groups )
|
||||
aMap[ group->m_Uuid ] = group;
|
||||
|
||||
for( PCB_GENERATOR* generator : m_generators )
|
||||
aMap[ generator->m_Uuid ] = generator;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1547,6 +1578,26 @@ INSPECT_RESULT BOARD::Visit( INSPECTOR inspector, void* testData,
|
|||
|
||||
break;
|
||||
|
||||
case PCB_GENERATOR_T:
|
||||
if( !footprintsScanned )
|
||||
{
|
||||
if( IterateForward<FOOTPRINT*>( m_footprints, inspector, testData, scanTypes )
|
||||
== INSPECT_RESULT::QUIT )
|
||||
{
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
footprintsScanned = true;
|
||||
}
|
||||
|
||||
if( IterateForward<PCB_GENERATOR*>( m_generators, inspector, testData, { scanType } )
|
||||
== INSPECT_RESULT::QUIT )
|
||||
{
|
||||
return INSPECT_RESULT::QUIT;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case PCB_GROUP_T:
|
||||
if( IterateForward<PCB_GROUP*>( m_groups, inspector, testData, { scanType } )
|
||||
== INSPECT_RESULT::QUIT )
|
||||
|
@ -2241,9 +2292,12 @@ wxString BOARD::GroupsSanityCheckInternal( bool repair )
|
|||
// Groups we haven't checked yet.
|
||||
std::unordered_set<PCB_GROUP*> toCheckGroups;
|
||||
|
||||
// Initialize set of groups to check that could participate in a cycle.
|
||||
// Initialize set of groups and generators to check that could participate in a cycle.
|
||||
for( PCB_GROUP* group : Groups() )
|
||||
toCheckGroups.insert( group);
|
||||
toCheckGroups.insert( group );
|
||||
|
||||
for( PCB_GENERATOR* gen : Generators() )
|
||||
toCheckGroups.insert( gen );
|
||||
|
||||
while( !toCheckGroups.empty() )
|
||||
{
|
||||
|
|
|
@ -51,6 +51,7 @@ class ZONE;
|
|||
class PCB_TRACK;
|
||||
class PAD;
|
||||
class PCB_GROUP;
|
||||
class PCB_GENERATOR;
|
||||
class PCB_MARKER;
|
||||
class MSG_PANEL_ITEM;
|
||||
class NETLIST;
|
||||
|
@ -319,6 +320,9 @@ public:
|
|||
ZONES& Zones() { return m_zones; }
|
||||
const ZONES& Zones() const { return m_zones; }
|
||||
|
||||
GENERATORS& Generators() { return m_generators; }
|
||||
const GENERATORS& Generators() const { return m_generators; }
|
||||
|
||||
MARKERS& Markers() { return m_markers; }
|
||||
const MARKERS& Markers() const { return m_markers; }
|
||||
|
||||
|
@ -1238,6 +1242,7 @@ private:
|
|||
TRACKS m_tracks;
|
||||
GROUPS m_groups;
|
||||
ZONES m_zones;
|
||||
GENERATORS m_generators;
|
||||
|
||||
LAYER m_layers[PCB_LAYER_ID_COUNT];
|
||||
|
||||
|
|
|
@ -318,6 +318,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
|
|||
case PCB_PAD_T:
|
||||
case PCB_SHAPE_T: // a shape (normally not on copper layers)
|
||||
case PCB_BITMAP_T: // a bitmap on a user layer
|
||||
case PCB_GENERATOR_T: // a generator on a layer
|
||||
case PCB_TEXTBOX_T: // a wrapped text on a layer
|
||||
case PCB_TRACE_T: // a track segment (segment on a copper layer)
|
||||
case PCB_ARC_T: // an arced track segment (segment on a copper layer)
|
||||
|
@ -627,7 +628,7 @@ void BOARD_COMMIT::Revert()
|
|||
wxASSERT( boardItemCopy );
|
||||
boardItem->SwapItemData( boardItemCopy );
|
||||
|
||||
if( boardItem->Type() == PCB_GROUP_T )
|
||||
if( boardItem->Type() == PCB_GROUP_T || boardItem->Type() == PCB_GENERATOR_T)
|
||||
{
|
||||
PCB_GROUP* group = static_cast<PCB_GROUP*>( boardItem );
|
||||
|
||||
|
|
|
@ -56,7 +56,8 @@ const std::vector<KICAD_T> GENERAL_COLLECTOR::AllBoardItems = {
|
|||
PCB_FIELD_T, // in footprints
|
||||
PCB_FOOTPRINT_T, // in m_footprints
|
||||
PCB_GROUP_T, // in m_groups
|
||||
PCB_ZONE_T // in m_zones
|
||||
PCB_ZONE_T, // in m_zones
|
||||
PCB_GENERATOR_T // in m_generators
|
||||
};
|
||||
|
||||
|
||||
|
@ -77,7 +78,8 @@ const std::vector<KICAD_T> GENERAL_COLLECTOR::BoardLevelItems = {
|
|||
PCB_TRACE_T,
|
||||
PCB_FOOTPRINT_T,
|
||||
PCB_GROUP_T,
|
||||
PCB_ZONE_T
|
||||
PCB_ZONE_T,
|
||||
PCB_GENERATOR_T
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <pad.h>
|
||||
#include <zone.h>
|
||||
#include <pcb_group.h>
|
||||
#include <pcb_generator.h>
|
||||
#include <pcb_target.h>
|
||||
#include <pcb_dimension.h>
|
||||
#include <pcb_textbox.h>
|
||||
|
@ -171,6 +172,11 @@ void PCB_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem )
|
|||
static_cast<PCB_GROUP*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_GENERATOR_T:
|
||||
m_toolManager->RunAction<PCB_GENERATOR*>( PCB_ACTIONS::generatorProperties,
|
||||
static_cast<PCB_GENERATOR*>( aItem ) );
|
||||
break;
|
||||
|
||||
case PCB_MARKER_T:
|
||||
m_toolManager->GetTool<DRC_TOOL>()->CrossProbe( static_cast<PCB_MARKER*>( aItem ) );
|
||||
break;
|
||||
|
|
|
@ -2274,7 +2274,7 @@ double FOOTPRINT::GetCoverageArea( const BOARD_ITEM* aItem, const GENERAL_COLLEC
|
|||
marker->ShapeToPolygon( markerShape );
|
||||
return markerShape.Area();
|
||||
}
|
||||
else if( aItem->Type() == PCB_GROUP_T )
|
||||
else if( aItem->Type() == PCB_GROUP_T || aItem->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
double combinedArea = 0.0;
|
||||
|
||||
|
|
|
@ -298,7 +298,7 @@ void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID
|
|||
child->ClearBrightened();
|
||||
} );
|
||||
}
|
||||
else if( lastItem->Type() == PCB_GROUP_T )
|
||||
else if( lastItem->Type() == PCB_GROUP_T || lastItem->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
static_cast<PCB_GROUP*>( lastItem )->RunOnChildren(
|
||||
[&]( BOARD_ITEM* child )
|
||||
|
@ -356,7 +356,7 @@ void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID
|
|||
child->SetBrightened();
|
||||
});
|
||||
}
|
||||
else if( item->Type() == PCB_GROUP_T )
|
||||
else if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
static_cast<PCB_GROUP*>( item )->RunOnChildren(
|
||||
[&]( BOARD_ITEM* child )
|
||||
|
|
|
@ -722,7 +722,8 @@ void PCB_EDIT_FRAME::setupUIConditions()
|
|||
mgr->SetConditions( ACTIONS::duplicate, ENABLE( cond.HasItems() ) );
|
||||
|
||||
mgr->SetConditions( PCB_ACTIONS::group, ENABLE( SELECTION_CONDITIONS::MoreThan( 1 ) ) );
|
||||
mgr->SetConditions( PCB_ACTIONS::ungroup, ENABLE( SELECTION_CONDITIONS::HasType( PCB_GROUP_T ) ) );
|
||||
mgr->SetConditions( PCB_ACTIONS::ungroup, ENABLE( SELECTION_CONDITIONS::HasTypes(
|
||||
{ PCB_GROUP_T, PCB_GENERATOR_T } ) ) );
|
||||
mgr->SetConditions( PCB_ACTIONS::lock, ENABLE( PCB_SELECTION_CONDITIONS::HasUnlockedItems ) );
|
||||
mgr->SetConditions( PCB_ACTIONS::unlock, ENABLE( PCB_SELECTION_CONDITIONS::HasLockedItems ) );
|
||||
|
||||
|
|
|
@ -0,0 +1,225 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2023 Alex Shvartzkop <dudesuchamazing@gmail.com>
|
||||
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* 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 <pcb_generator.h>
|
||||
#include <i18n_utility.h>
|
||||
|
||||
|
||||
PCB_GENERATOR::PCB_GENERATOR( BOARD_ITEM* aParent, PCB_LAYER_ID aLayer ) :
|
||||
PCB_GROUP( aParent, PCB_GENERATOR_T, aLayer )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PCB_GENERATOR::~PCB_GENERATOR()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void PCB_GENERATOR::EditStart( GENERATOR_TOOL* aTool, BOARD* aBoard, PCB_BASE_EDIT_FRAME* aFrame,
|
||||
BOARD_COMMIT* aCommit )
|
||||
{
|
||||
aCommit->Modify( this );
|
||||
|
||||
RunOnDescendants(
|
||||
[&]( BOARD_ITEM* aItem )
|
||||
{
|
||||
aCommit->Modify( aItem );
|
||||
} );
|
||||
|
||||
aCommit->Push( "Generator edit start" );
|
||||
}
|
||||
|
||||
|
||||
void PCB_GENERATOR::EditPush( GENERATOR_TOOL* aTool, BOARD* aBoard, PCB_BASE_EDIT_FRAME* aFrame,
|
||||
BOARD_COMMIT* aCommit )
|
||||
{
|
||||
aCommit->Push( "Generator edit end", APPEND_UNDO );
|
||||
}
|
||||
|
||||
|
||||
void PCB_GENERATOR::EditRevert( GENERATOR_TOOL* aTool, BOARD* aBoard, PCB_BASE_EDIT_FRAME* aFrame,
|
||||
BOARD_COMMIT* aCommit )
|
||||
{
|
||||
aCommit->Revert();
|
||||
}
|
||||
|
||||
|
||||
void PCB_GENERATOR::Remove( GENERATOR_TOOL* aTool, BOARD* aBoard, PCB_BASE_EDIT_FRAME* aFrame,
|
||||
BOARD_COMMIT* aCommit )
|
||||
{
|
||||
RunOnDescendants(
|
||||
[&]( BOARD_ITEM* aItem )
|
||||
{
|
||||
aCommit->Stage( aItem, CHT_MODIFY );
|
||||
} );
|
||||
|
||||
RemoveAll();
|
||||
|
||||
aCommit->Remove( this );
|
||||
}
|
||||
|
||||
|
||||
bool PCB_GENERATOR::Update( GENERATOR_TOOL* aTool, BOARD* aBoard, PCB_BASE_EDIT_FRAME* aFrame,
|
||||
BOARD_COMMIT* aCommit )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool PCB_GENERATOR::NeedsUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool PCB_GENERATOR::MakeEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints ) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool PCB_GENERATOR::UpdateFromEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints,
|
||||
BOARD_COMMIT* aCommit )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool PCB_GENERATOR::UpdateEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const BOX2I PCB_GENERATOR::GetBoundingBox() const
|
||||
{
|
||||
BOX2I bbox;
|
||||
return bbox;
|
||||
}
|
||||
|
||||
|
||||
VECTOR2I PCB_GENERATOR::GetPosition() const
|
||||
{
|
||||
return m_origin;
|
||||
}
|
||||
|
||||
|
||||
void PCB_GENERATOR::Move( const VECTOR2I& aMoveVector )
|
||||
{
|
||||
m_origin += aMoveVector;
|
||||
|
||||
PCB_GROUP::Move( aMoveVector );
|
||||
}
|
||||
|
||||
|
||||
bool PCB_GENERATOR::AddItem( BOARD_ITEM* aItem )
|
||||
{
|
||||
// Items can only be in one group at a time
|
||||
if( aItem->GetParentGroup() )
|
||||
aItem->GetParentGroup()->RemoveItem( aItem );
|
||||
|
||||
m_items.insert( aItem );
|
||||
aItem->SetParentGroup( this );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
LSET PCB_GENERATOR::GetLayerSet() const
|
||||
{
|
||||
return PCB_GROUP::GetLayerSet() | LSET( GetLayer() );
|
||||
}
|
||||
|
||||
|
||||
void PCB_GENERATOR::SetLayer( PCB_LAYER_ID aLayer )
|
||||
{
|
||||
m_layer = aLayer;
|
||||
}
|
||||
|
||||
|
||||
wxString PCB_GENERATOR::GetGeneratorType() const
|
||||
{
|
||||
return m_generatorType;
|
||||
}
|
||||
|
||||
|
||||
const STRING_ANY_MAP PCB_GENERATOR::GetProperties() const
|
||||
{
|
||||
STRING_ANY_MAP props( pcbIUScale.IU_PER_MM );
|
||||
|
||||
props.set( "update_order", m_updateOrder );
|
||||
props.set( "origin", m_origin );
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
|
||||
void PCB_GENERATOR::SetProperties( const STRING_ANY_MAP& aProps )
|
||||
{
|
||||
aProps.get_to( "update_order", m_updateOrder );
|
||||
aProps.get_to( "origin", m_origin );
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::pair<wxString, wxVariant>> PCB_GENERATOR::GetRowData()
|
||||
{
|
||||
return { { _HKI( "Update order" ), wxString::FromCDouble( GetUpdateOrder() ) } };
|
||||
}
|
||||
|
||||
|
||||
wxString PCB_GENERATOR::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
|
||||
{
|
||||
return wxString( _( "Generator" ) );
|
||||
}
|
||||
|
||||
|
||||
wxString PCB_GENERATOR::GetClass() const
|
||||
{
|
||||
return wxS( "PCB_GENERATOR" );
|
||||
}
|
||||
|
||||
|
||||
bool PCB_GENERATOR::ClassOf( const EDA_ITEM* aItem )
|
||||
{
|
||||
return aItem && PCB_GENERATOR_T == aItem->Type();
|
||||
}
|
||||
|
||||
|
||||
static struct PCB_GENERATOR_DESC
|
||||
{
|
||||
PCB_GENERATOR_DESC()
|
||||
{
|
||||
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
|
||||
REGISTER_TYPE( PCB_GENERATOR );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<PCB_GENERATOR, BOARD_ITEM> );
|
||||
propMgr.InheritsAfter( TYPE_HASH( PCB_GENERATOR ), TYPE_HASH( BOARD_ITEM ) );
|
||||
|
||||
const wxString groupTab = _HKI( "Generator Properties" );
|
||||
|
||||
propMgr.AddProperty( new PROPERTY<PCB_GENERATOR, int>( _HKI( "Update order" ),
|
||||
&PCB_GENERATOR::SetUpdateOrder,
|
||||
&PCB_GENERATOR::GetUpdateOrder ),
|
||||
groupTab );
|
||||
}
|
||||
} _PCB_GENERATOR_DESC;
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2023 Alex Shvartzkop <dudesuchamazing@gmail.com>
|
||||
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef GENERATOR_H_
|
||||
#define GENERATOR_H_
|
||||
|
||||
|
||||
#include <unordered_set>
|
||||
#include <string_any_map.h>
|
||||
|
||||
#include <pcb_group.h>
|
||||
|
||||
class EDIT_POINTS;
|
||||
class BOARD;
|
||||
class BOARD_ITEM;
|
||||
class PCB_BASE_EDIT_FRAME;
|
||||
class GENERATOR_TOOL;
|
||||
|
||||
|
||||
class PCB_GENERATOR : public PCB_GROUP
|
||||
{
|
||||
public:
|
||||
|
||||
PCB_GENERATOR( BOARD_ITEM* aParent, PCB_LAYER_ID aLayer );
|
||||
|
||||
virtual ~PCB_GENERATOR();
|
||||
|
||||
virtual void EditStart( GENERATOR_TOOL* aTool, BOARD* aBoard, PCB_BASE_EDIT_FRAME* aFrame,
|
||||
BOARD_COMMIT* aCommit );
|
||||
|
||||
virtual void EditPush( GENERATOR_TOOL* aTool, BOARD* aBoard, PCB_BASE_EDIT_FRAME* aFrame,
|
||||
BOARD_COMMIT* aCommit );
|
||||
|
||||
virtual void EditRevert( GENERATOR_TOOL* aTool, BOARD* aBoard, PCB_BASE_EDIT_FRAME* aFrame,
|
||||
BOARD_COMMIT* aCommit );
|
||||
|
||||
virtual void Remove( GENERATOR_TOOL* aTool, BOARD* aBoard, PCB_BASE_EDIT_FRAME* aFrame,
|
||||
BOARD_COMMIT* aCommit );
|
||||
|
||||
virtual bool Update( GENERATOR_TOOL* aTool, BOARD* aBoard, PCB_BASE_EDIT_FRAME* aFrame,
|
||||
BOARD_COMMIT* aCommit );
|
||||
|
||||
virtual bool NeedsUpdate();
|
||||
|
||||
virtual bool MakeEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints ) const;
|
||||
|
||||
virtual bool UpdateFromEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints,
|
||||
BOARD_COMMIT* aCommit );
|
||||
|
||||
virtual bool UpdateEditPoints( std::shared_ptr<EDIT_POINTS> aEditPoints );
|
||||
|
||||
const BOX2I GetBoundingBox() const override;
|
||||
|
||||
VECTOR2I GetPosition() const override;
|
||||
|
||||
void Move( const VECTOR2I& aMoveVector ) override;
|
||||
|
||||
bool AddItem( BOARD_ITEM* aItem ) override;
|
||||
|
||||
LSET GetLayerSet() const override;
|
||||
|
||||
virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
|
||||
|
||||
virtual wxString GetGeneratorType() const;
|
||||
|
||||
virtual const STRING_ANY_MAP GetProperties() const;
|
||||
|
||||
virtual void SetProperties( const STRING_ANY_MAP& aProps );
|
||||
|
||||
virtual std::vector<std::pair<wxString, wxVariant>> GetRowData();
|
||||
|
||||
virtual void ShowPropertiesDialog( PCB_BASE_EDIT_FRAME* aEditFrame ){};
|
||||
|
||||
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
|
||||
|
||||
#if defined(DEBUG)
|
||||
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
|
||||
#endif
|
||||
|
||||
wxString GetClass() const override;
|
||||
|
||||
static inline bool ClassOf( const EDA_ITEM* aItem );
|
||||
|
||||
int GetUpdateOrder() const { return m_updateOrder; }
|
||||
void SetUpdateOrder( int aValue ) { m_updateOrder = aValue; }
|
||||
|
||||
protected:
|
||||
wxString m_generatorType;
|
||||
|
||||
VECTOR2I m_origin;
|
||||
int m_updateOrder = 0;
|
||||
|
||||
friend class GENERATORS_MGR;
|
||||
void setGeneratorType( const wxString& aGenType ) { m_generatorType = aGenType; }
|
||||
|
||||
};
|
||||
|
||||
#endif /* GENERATOR_H_ */
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 Joshua Redstone redstone at gmail.com
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -40,6 +40,12 @@ PCB_GROUP::PCB_GROUP( BOARD_ITEM* aParent ) :
|
|||
}
|
||||
|
||||
|
||||
PCB_GROUP::PCB_GROUP( BOARD_ITEM* aParent, KICAD_T idtype, PCB_LAYER_ID aLayer ) :
|
||||
BOARD_ITEM( aParent, idtype, aLayer )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool PCB_GROUP::IsGroupableType( KICAD_T aType )
|
||||
{
|
||||
switch ( aType )
|
||||
|
@ -52,6 +58,7 @@ bool PCB_GROUP::IsGroupableType( KICAD_T aType )
|
|||
case PCB_TEXT_T:
|
||||
case PCB_TEXTBOX_T:
|
||||
case PCB_GROUP_T:
|
||||
case PCB_GENERATOR_T:
|
||||
case PCB_TRACE_T:
|
||||
case PCB_VIA_T:
|
||||
case PCB_ARC_T:
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
class FOOTPRINT;
|
||||
class PCB_TRACK;
|
||||
class PCB_GROUP;
|
||||
class PCB_GENERATOR;
|
||||
class PCB_MARKER;
|
||||
class ZONE;
|
||||
|
||||
|
@ -39,6 +40,7 @@ DECL_DEQ_FOR_SWIG( TRACKS, PCB_TRACK* )
|
|||
DECL_DEQ_FOR_SWIG( FOOTPRINTS, FOOTPRINT* )
|
||||
// Dequeue rather than Vector just so we can use moveUnflaggedItems in pcbnew_control.cpp
|
||||
DECL_DEQ_FOR_SWIG( GROUPS, PCB_GROUP* )
|
||||
DECL_DEQ_FOR_SWIG( GENERATORS, PCB_GENERATOR* )
|
||||
|
||||
|
||||
// Shared with board and footprint
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013-2017 CERN
|
||||
* Copyright (C) 2013-2023 CERN
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
|
@ -103,7 +103,8 @@ void PCB_VIEW::Update( const KIGFX::VIEW_ITEM* aItem, int aUpdateFlags ) const
|
|||
VIEW::Update( child, aUpdateFlags );
|
||||
} );
|
||||
}
|
||||
else if( boardItem && boardItem->Type() == PCB_GROUP_T )
|
||||
else if( boardItem
|
||||
&& ( boardItem->Type() == PCB_GROUP_T || boardItem->Type() == PCB_GENERATOR_T ) )
|
||||
{
|
||||
const PCB_GROUP* group = static_cast<const PCB_GROUP*>( boardItem );
|
||||
group->RunOnChildren(
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <pcb_target.h>
|
||||
#include <pcb_text.h>
|
||||
#include <pcb_textbox.h>
|
||||
#include <pcb_generator.h>
|
||||
#include <collectors.h>
|
||||
#include <pcb_edit_frame.h>
|
||||
#include <drawing_sheet/ds_proxy_view_item.h>
|
||||
|
@ -2144,6 +2145,16 @@ void EDIT_TOOL::DeleteItems( const PCB_SELECTION& aItems, bool aIsCut )
|
|||
break;
|
||||
}
|
||||
|
||||
case PCB_GENERATOR_T:
|
||||
{
|
||||
PCB_GENERATOR* generator = static_cast<PCB_GENERATOR*>( board_item );
|
||||
|
||||
m_toolMgr->RunSynchronousAction<PCB_GENERATOR*>( PCB_ACTIONS::genRemove, &commit,
|
||||
generator );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
wxASSERT_MSG( parentFP == nullptr, wxT( "Try to delete an item living in a footrprint" ) );
|
||||
commit.Remove( board_item );
|
||||
|
@ -2407,6 +2418,7 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
|
|||
case PCB_TEXT_T:
|
||||
case PCB_TEXTBOX_T:
|
||||
case PCB_BITMAP_T:
|
||||
case PCB_GENERATOR_T:
|
||||
case PCB_SHAPE_T:
|
||||
case PCB_TRACE_T:
|
||||
case PCB_ARC_T:
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <pad.h>
|
||||
#include <pcb_group.h>
|
||||
#include <pcb_generator.h>
|
||||
#include <pcb_edit_frame.h>
|
||||
#include <spread_footprints.h>
|
||||
#include <tools/pcb_actions.h>
|
||||
|
@ -94,7 +95,7 @@ int EDIT_TOOL::Swap( const TOOL_EVENT& aEvent )
|
|||
commit->Modify( item );
|
||||
|
||||
// If swapping a group, record position of all the descendants for undo
|
||||
if( item->Type() == PCB_GROUP_T )
|
||||
if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
|
||||
group->RunOnDescendants( [&]( BOARD_ITEM* descendant )
|
||||
|
@ -555,6 +556,17 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit
|
|||
if( redraw3D && allowRedraw3D )
|
||||
editFrame->Update3DView( false, true );
|
||||
|
||||
for( BOARD_ITEM* item : sel_items )
|
||||
{
|
||||
if( item->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
PCB_GENERATOR* generator = static_cast<PCB_GENERATOR*>( item );
|
||||
|
||||
m_toolMgr->RunSynchronousAction<PCB_GENERATOR*>( PCB_ACTIONS::genUpdateEdit,
|
||||
aCommit, generator );
|
||||
}
|
||||
}
|
||||
|
||||
if( showCourtyardConflicts && drc_on_move->m_FpInMove.size() )
|
||||
{
|
||||
drc_on_move->Run();
|
||||
|
@ -576,6 +588,15 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit
|
|||
continue;
|
||||
|
||||
if( !item->IsNew() && !item->IsMoving() )
|
||||
{
|
||||
if( item->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
PCB_GENERATOR* generator = static_cast<PCB_GENERATOR*>( item );
|
||||
|
||||
m_toolMgr->RunSynchronousAction<PCB_GENERATOR*>(
|
||||
PCB_ACTIONS::genStartEdit, aCommit, generator );
|
||||
}
|
||||
else
|
||||
{
|
||||
aCommit->Modify( item );
|
||||
item->SetFlags( IS_MOVING );
|
||||
|
@ -584,11 +605,13 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit
|
|||
if( item->Type() == PCB_GROUP_T )
|
||||
{
|
||||
PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
|
||||
group->RunOnDescendants( [&]( BOARD_ITEM* bItem )
|
||||
group->RunOnDescendants(
|
||||
[&]( BOARD_ITEM* bItem )
|
||||
{
|
||||
aCommit->Modify( bItem );
|
||||
item->SetFlags( IS_MOVING );
|
||||
});
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -784,6 +807,30 @@ bool EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit
|
|||
{
|
||||
EDA_ITEMS oItems( orig_items.begin(), orig_items.end() );
|
||||
m_toolMgr->RunAction<EDA_ITEMS*>( PCB_ACTIONS::selectItems, &oItems );
|
||||
|
||||
for( BOARD_ITEM* item : sel_items )
|
||||
{
|
||||
if( item->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
PCB_GENERATOR* generator = static_cast<PCB_GENERATOR*>( item );
|
||||
|
||||
m_toolMgr->RunSynchronousAction<PCB_GENERATOR*>( PCB_ACTIONS::genPushEdit, aCommit,
|
||||
generator );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( BOARD_ITEM* item : sel_items )
|
||||
{
|
||||
if( item->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
PCB_GENERATOR* generator = static_cast<PCB_GENERATOR*>( item );
|
||||
|
||||
m_toolMgr->RunSynchronousAction<PCB_GENERATOR*>( PCB_ACTIONS::genRevertEdit,
|
||||
aCommit, generator );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the dynamic ratsnest from the screen
|
||||
|
|
|
@ -45,6 +45,7 @@ class PCB_BITMAP;
|
|||
#undef _
|
||||
#define _(s) s
|
||||
|
||||
// clang-format off
|
||||
|
||||
// CONVERT_TOOL
|
||||
//
|
||||
|
@ -2354,6 +2355,61 @@ TOOL_ACTION PCB_ACTIONS::dragFreeAngle( TOOL_ACTION_ARGS()
|
|||
.Icon( BITMAPS::drag ) );
|
||||
|
||||
|
||||
// GENERATOR_TOOL
|
||||
//
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::generatorProperties( TOOL_ACTION_ARGS()
|
||||
.Name( "pcbnew.Generator.generatorProperties" )
|
||||
.Scope( AS_GLOBAL ) );
|
||||
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::regenerateOutdated( TOOL_ACTION_ARGS()
|
||||
.Name( "pcbnew.Generator.regenerateOutdated" )
|
||||
.Scope( AS_GLOBAL )
|
||||
.MenuText( _( "Rebuild Outdated Generators" ) )
|
||||
.Tooltip( _( "Rebuilds geometry of outdated generators" ) )
|
||||
.Icon( BITMAPS::refresh ) );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::regenerateAll( TOOL_ACTION_ARGS()
|
||||
.Name( "pcbnew.Generator.regenerateAll" )
|
||||
.Scope( AS_GLOBAL )
|
||||
.MenuText( _( "Rebuild All Generators" ) )
|
||||
.Tooltip( _( "Rebuilds geometry of all generators" ) )
|
||||
.Icon( BITMAPS::refresh ) );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::regenerateSelected( TOOL_ACTION_ARGS()
|
||||
.Name( "pcbnew.Generator.regenerateSelected" )
|
||||
.Scope( AS_GLOBAL )
|
||||
.MenuText( _( "Rebuild Selected Generators" ) )
|
||||
.Tooltip( _( "Rebuilds geometry of selected generator(s)" ) )
|
||||
.Icon( BITMAPS::refresh ) );
|
||||
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::regenerateItem( TOOL_ACTION_ARGS()
|
||||
.Name( "pcbnew.Generator.regenerateItem" )
|
||||
.Scope( AS_CONTEXT ) );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::genStartEdit( TOOL_ACTION_ARGS()
|
||||
.Name( "pcbnew.Generator.genStartEdit" )
|
||||
.Scope( AS_CONTEXT ) );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::genUpdateEdit( TOOL_ACTION_ARGS()
|
||||
.Name( "pcbnew.Generator.genUpdateEdit" )
|
||||
.Scope( AS_CONTEXT ) );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::genPushEdit( TOOL_ACTION_ARGS()
|
||||
.Name( "pcbnew.Generator.genPushEdit" )
|
||||
.Scope( AS_CONTEXT ) );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::genRevertEdit( TOOL_ACTION_ARGS()
|
||||
.Name( "pcbnew.Generator.genRevertEdit" )
|
||||
.Scope( AS_CONTEXT ) );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::genRemove( TOOL_ACTION_ARGS()
|
||||
.Name( "pcbnew.Generator.genRemove" )
|
||||
.Scope( AS_CONTEXT ) );
|
||||
|
||||
|
||||
// LENGTH_TUNER_TOOL
|
||||
//
|
||||
TOOL_ACTION PCB_ACTIONS::ddAppendBoard( TOOL_ACTION_ARGS()
|
||||
|
|
|
@ -268,6 +268,18 @@ public:
|
|||
/// Activation of the Push and Shove router (inline dragging mode)
|
||||
static TOOL_ACTION routerInlineDrag;
|
||||
|
||||
/// Generator tool
|
||||
static TOOL_ACTION generatorProperties;
|
||||
static TOOL_ACTION regenerateOutdated;
|
||||
static TOOL_ACTION regenerateAll;
|
||||
static TOOL_ACTION regenerateSelected;
|
||||
static TOOL_ACTION regenerateItem;
|
||||
static TOOL_ACTION genStartEdit;
|
||||
static TOOL_ACTION genUpdateEdit;
|
||||
static TOOL_ACTION genPushEdit;
|
||||
static TOOL_ACTION genRevertEdit;
|
||||
static TOOL_ACTION genRemove;
|
||||
|
||||
// Point Editor
|
||||
static TOOL_ACTION pointEditorAddCorner;
|
||||
static TOOL_ACTION pointEditorRemoveCorner;
|
||||
|
|
|
@ -810,7 +810,7 @@ void PCB_CONTROL::pruneItemLayers( std::vector<BOARD_ITEM*>& aItems )
|
|||
if( fp->GraphicalItems().size() || fp->Pads().size() || fp->Zones().size() )
|
||||
returnItems.push_back( fp );
|
||||
}
|
||||
else if( item->Type() == PCB_GROUP_T )
|
||||
else if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
returnItems.push_back( item );
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ using namespace std::placeholders;
|
|||
#include <board_commit.h>
|
||||
#include <pcb_edit_frame.h>
|
||||
#include <pcb_bitmap.h>
|
||||
#include <pcb_generator.h>
|
||||
#include <pcb_dimension.h>
|
||||
#include <pcb_textbox.h>
|
||||
#include <pad.h>
|
||||
|
@ -316,6 +317,13 @@ std::shared_ptr<EDIT_POINTS> PCB_POINT_EDITOR::makePoints( EDA_ITEM* aItem )
|
|||
break;
|
||||
}
|
||||
|
||||
case PCB_GENERATOR_T:
|
||||
{
|
||||
const PCB_GENERATOR* generator = static_cast<const PCB_GENERATOR*>( aItem );
|
||||
generator->MakeEditPoints( points );
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_DIM_ALIGNED_T:
|
||||
case PCB_DIM_ORTHOGONAL_T:
|
||||
{
|
||||
|
@ -528,7 +536,16 @@ int PCB_POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
frame()->UndoRedoBlock( true );
|
||||
|
||||
if( item->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
m_toolMgr->RunSynchronousAction<PCB_GENERATOR*>(
|
||||
PCB_ACTIONS::genStartEdit, &commit,
|
||||
static_cast<PCB_GENERATOR*>( item ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
commit.StageItems( selection, CHT_MODIFY );
|
||||
}
|
||||
|
||||
getViewControls()->ForceCursorPosition( false );
|
||||
m_original = *m_editedPoint; // Save the original position
|
||||
|
@ -601,7 +618,7 @@ int PCB_POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
|||
grid.GetItemGrid( item ), { item } ) );
|
||||
}
|
||||
|
||||
updateItem();
|
||||
updateItem( &commit );
|
||||
getViewControls()->ForceCursorPosition( true, m_editedPoint->GetPosition() );
|
||||
updatePoints();
|
||||
}
|
||||
|
@ -630,17 +647,33 @@ int PCB_POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
|||
getViewControls()->SetAutoPan( false );
|
||||
setAltConstraint( false );
|
||||
|
||||
if( item->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
m_toolMgr->RunSynchronousAction<PCB_GENERATOR*>(
|
||||
PCB_ACTIONS::genPushEdit, &commit, static_cast<PCB_GENERATOR*>( item ) );
|
||||
}
|
||||
|
||||
commit.Push( _( "Drag Corner" ) );
|
||||
|
||||
inDrag = false;
|
||||
frame()->UndoRedoBlock( false );
|
||||
|
||||
m_toolMgr->PostAction<EDA_ITEM*>( PCB_ACTIONS::reselectItem,
|
||||
item ); // FIXME: Needed for generators
|
||||
m_refill = true;
|
||||
}
|
||||
else if( evt->IsCancelInteractive() || evt->IsActivate() )
|
||||
{
|
||||
if( inDrag ) // Restore the last change
|
||||
{
|
||||
if( item->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
m_toolMgr->RunSynchronousAction<PCB_GENERATOR*>(
|
||||
PCB_ACTIONS::genRevertEdit, &commit,
|
||||
static_cast<PCB_GENERATOR*>( item ) );
|
||||
}
|
||||
commit.Revert();
|
||||
|
||||
inDrag = false;
|
||||
frame()->UndoRedoBlock( false );
|
||||
}
|
||||
|
@ -700,7 +733,7 @@ int PCB_POINT_EDITOR::movePoint( const TOOL_EVENT& aEvent )
|
|||
if( dlg.ShowModal() == wxID_OK )
|
||||
{
|
||||
m_editedPoint->SetPosition( dlg.GetValue() );
|
||||
updateItem();
|
||||
updateItem( &commit );
|
||||
commit.Push( msg );
|
||||
}
|
||||
|
||||
|
@ -1119,7 +1152,7 @@ void PCB_POINT_EDITOR::editArcMidKeepEndpoints( PCB_SHAPE* aArc, const VECTOR2I&
|
|||
}
|
||||
|
||||
|
||||
void PCB_POINT_EDITOR::updateItem() const
|
||||
void PCB_POINT_EDITOR::updateItem( BOARD_COMMIT* aCommit )
|
||||
{
|
||||
EDA_ITEM* item = m_editPoints->GetParent();
|
||||
|
||||
|
@ -1458,6 +1491,16 @@ void PCB_POINT_EDITOR::updateItem() const
|
|||
break;
|
||||
}
|
||||
|
||||
case PCB_GENERATOR_T:
|
||||
{
|
||||
PCB_GENERATOR* generator = static_cast<PCB_GENERATOR*>( item );
|
||||
generator->UpdateFromEditPoints( m_editPoints, aCommit );
|
||||
|
||||
m_toolMgr->RunSynchronousAction<PCB_GENERATOR*>( PCB_ACTIONS::genUpdateEdit, aCommit,
|
||||
generator );
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_DIM_ALIGNED_T:
|
||||
{
|
||||
PCB_DIM_ALIGNED* dimension = static_cast<PCB_DIM_ALIGNED*>( item );
|
||||
|
@ -1922,6 +1965,13 @@ void PCB_POINT_EDITOR::updatePoints()
|
|||
break;
|
||||
}
|
||||
|
||||
case PCB_GENERATOR_T:
|
||||
{
|
||||
PCB_GENERATOR* generator = static_cast<PCB_GENERATOR*>( item );
|
||||
generator->UpdateEditPoints( m_editPoints );
|
||||
break;
|
||||
}
|
||||
|
||||
case PCB_DIM_ALIGNED_T:
|
||||
case PCB_DIM_ORTHOGONAL_T:
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013-2017 CERN
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
|
@ -75,7 +75,7 @@ private:
|
|||
std::shared_ptr<EDIT_POINTS> makePoints( EDA_ITEM* aItem );
|
||||
|
||||
///< Update item's points with edit points.
|
||||
void updateItem() const;
|
||||
void updateItem( BOARD_COMMIT* aCommit );
|
||||
|
||||
/**
|
||||
* Validate a polygon and displays a popup warning if invalid.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (C) 2013-2017 CERN
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.TXT for contributors.
|
||||
* Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -99,7 +99,7 @@ const std::vector<KIGFX::VIEW_ITEM*> PCB_SELECTION::updateDrawList() const
|
|||
addItem( bitem );
|
||||
} );
|
||||
}
|
||||
else if( item->Type() == PCB_GROUP_T )
|
||||
else if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
|
||||
group->RunOnChildren( [&]( BOARD_ITEM* bitem )
|
||||
|
|
|
@ -2374,6 +2374,12 @@ bool PCB_SELECTION_TOOL::itemPassesFilter( BOARD_ITEM* aItem, bool aMultiSelect
|
|||
|
||||
break;
|
||||
|
||||
case PCB_GENERATOR_T:
|
||||
if( !m_filter.generators )
|
||||
return false;
|
||||
|
||||
break;
|
||||
|
||||
case PCB_ZONE_T:
|
||||
{
|
||||
ZONE* zone = static_cast<ZONE*>( aItem );
|
||||
|
@ -2851,7 +2857,7 @@ void PCB_SELECTION_TOOL::highlightInternal( EDA_ITEM* aItem, int aMode, bool aUs
|
|||
highlightInternal( aChild, aMode, aUsingOverlay );
|
||||
} );
|
||||
}
|
||||
else if( aItem->Type() == PCB_GROUP_T )
|
||||
else if( aItem->Type() == PCB_GROUP_T || aItem->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
static_cast<PCB_GROUP*>( aItem )->RunOnChildren(
|
||||
[&]( BOARD_ITEM* aChild )
|
||||
|
@ -2894,7 +2900,7 @@ void PCB_SELECTION_TOOL::unhighlightInternal( EDA_ITEM* aItem, int aMode, bool a
|
|||
unhighlightInternal( aChild, aMode, aUsingOverlay );
|
||||
} );
|
||||
}
|
||||
else if( aItem->Type() == PCB_GROUP_T )
|
||||
else if( aItem->Type() == PCB_GROUP_T || aItem->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
static_cast<PCB_GROUP*>( aItem )->RunOnChildren(
|
||||
[&]( BOARD_ITEM* aChild )
|
||||
|
@ -2929,14 +2935,14 @@ bool PCB_SELECTION_TOOL::selectionContains( const VECTOR2I& aPoint ) const
|
|||
aGroup->RunOnChildren(
|
||||
[&]( BOARD_ITEM* aItem )
|
||||
{
|
||||
if( aItem->Type() == PCB_GROUP_T )
|
||||
if( aItem->Type() == PCB_GROUP_T || aItem->Type() == PCB_GENERATOR_T )
|
||||
checkGroup( static_cast<PCB_GROUP*>( aItem ) );
|
||||
else if( aItem->HitTest( aPoint, margin ) )
|
||||
found = true;
|
||||
} );
|
||||
};
|
||||
|
||||
if( item->Type() == PCB_GROUP_T )
|
||||
if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T )
|
||||
checkGroup( static_cast<PCB_GROUP*>( item ) );
|
||||
|
||||
if( found )
|
||||
|
@ -3031,6 +3037,7 @@ int PCB_SELECTION_TOOL::hitTestDistance( const VECTOR2I& aWhere, BOARD_ITEM* aIt
|
|||
}
|
||||
|
||||
case PCB_GROUP_T:
|
||||
case PCB_GENERATOR_T:
|
||||
{
|
||||
PCB_GROUP* group = static_cast<PCB_GROUP*>( aItem );
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2016 CERN
|
||||
* Copyright (C) 2012-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2012-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -31,6 +31,7 @@ using namespace std::placeholders;
|
|||
#include <pcb_edit_frame.h>
|
||||
#include <pcb_track.h>
|
||||
#include <pcb_group.h>
|
||||
#include <pcb_generator.h>
|
||||
#include <pcb_target.h>
|
||||
#include <footprint.h>
|
||||
#include <pad.h>
|
||||
|
@ -380,7 +381,7 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
|
|||
|
||||
item->SwapItemData( image );
|
||||
|
||||
if( item->Type() == PCB_GROUP_T )
|
||||
if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
group = static_cast<PCB_GROUP*>( item );
|
||||
|
||||
|
@ -413,7 +414,7 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
|
|||
if( eda_item->Type() != PCB_NETINFO_T )
|
||||
view->Add( eda_item );
|
||||
|
||||
if( eda_item->Type() == PCB_GROUP_T )
|
||||
if( eda_item->Type() == PCB_GROUP_T || eda_item->Type() == PCB_GENERATOR_T )
|
||||
group = static_cast<PCB_GROUP*>( eda_item );
|
||||
|
||||
break;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 CERN
|
||||
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <pcb_base_edit_frame.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/pcb_actions.h>
|
||||
#include <tools/pcb_selection_tool.h>
|
||||
#include <properties/property_mgr.h>
|
||||
#include <properties/pg_editors.h>
|
||||
|
@ -32,6 +33,7 @@
|
|||
#include <pcb_shape.h>
|
||||
#include <pcb_text.h>
|
||||
#include <pcb_track.h>
|
||||
#include <pcb_generator.h>
|
||||
#include <pad.h>
|
||||
#include <settings/color_settings.h>
|
||||
#include <string_utils.h>
|
||||
|
@ -211,6 +213,16 @@ void PCB_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
|
|||
}
|
||||
|
||||
changes.Push( _( "Change property" ) );
|
||||
|
||||
for( EDA_ITEM* edaItem : selection )
|
||||
{
|
||||
if( edaItem->Type() == PCB_GENERATOR_T )
|
||||
{
|
||||
m_frame->GetToolManager()->RunAction<PCB_GENERATOR*>(
|
||||
PCB_ACTIONS::regenerateItem, static_cast<PCB_GENERATOR*>( edaItem ) );
|
||||
}
|
||||
}
|
||||
|
||||
m_frame->Refresh();
|
||||
|
||||
// Perform grid updates as necessary based on value change
|
||||
|
|
Loading…
Reference in New Issue