KiCad PCB EDA Suite
board_editor_control.cpp File Reference
#include <functional>
#include <memory>
#include <pgm_base.h>
#include <advanced_config.h>
#include "board_editor_control.h"
#include <bitmaps.h>
#include <pcb_painter.h>
#include <board.h>
#include <board_commit.h>
#include <board_design_settings.h>
#include <pcb_group.h>
#include <footprint.h>
#include <pad.h>
#include <pcb_target.h>
#include <pcb_track.h>
#include <zone.h>
#include <pcb_marker.h>
#include <confirm.h>
#include <dialogs/dialog_page_settings.h>
#include <dialogs/dialog_update_pcb.h>
#include <dialogs/dialog_assign_netclass.h>
#include <kiface_base.h>
#include <kiway.h>
#include <netlist_reader/pcb_netlist.h>
#include <origin_viewitem.h>
#include <pcb_edit_frame.h>
#include <pcbnew_id.h>
#include <project.h>
#include <project/project_file.h>
#include <tool/tool_manager.h>
#include <tool/tool_event.h>
#include <tools/drawing_tool.h>
#include <tools/pcb_actions.h>
#include <tools/pcb_picker_tool.h>
#include <tools/pcb_selection_conditions.h>
#include <tools/pcb_selection_tool.h>
#include <tools/edit_tool.h>
#include <tools/tool_event_utils.h>
#include <tools/zone_filler_tool.h>
#include <router/router_tool.h>
#include <view/view_controls.h>
#include <view/view_group.h>
#include <wildcards_and_files_ext.h>
#include <drawing_sheet/ds_proxy_undo_item.h>
#include <footprint_edit_frame.h>
#include <wx/filedlg.h>
#include <wx/log.h>
#include <widgets/legacyfiledlg_netlist_options.h>

Go to the source code of this file.

Classes

class  ZONE_CONTEXT_MENU
 
class  LOCK_CONTEXT_MENU
 

Functions

static bool mergeZones (EDA_DRAW_FRAME *aFrame, BOARD_COMMIT &aCommit, std::vector< ZONE * > &aOriginZones, std::vector< ZONE * > &aMergedZones)
 

Function Documentation

◆ mergeZones()

static bool mergeZones ( EDA_DRAW_FRAME aFrame,
BOARD_COMMIT aCommit,
std::vector< ZONE * > &  aOriginZones,
std::vector< ZONE * > &  aMergedZones 
)
static

Definition at line 1254 of file board_editor_control.cpp.

1256{
1257 aCommit.Modify( aOriginZones[0] );
1258
1259 for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1260 {
1261 aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
1263 }
1264
1265 aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
1266
1267 // We should have one polygon, possibly with holes. If we end up with two polygons (either
1268 // because the intersection was a single point or because the intersection was within one of
1269 // the zone's holes) then we can't merge.
1270 if( aOriginZones[0]->Outline()->IsSelfIntersecting()
1271 || aOriginZones[0]->Outline()->OutlineCount() > 1 )
1272 {
1273 DisplayErrorMessage( aFrame, _( "Zones have insufficient overlap for merging." ) );
1274 aCommit.Revert();
1275 return false;
1276 }
1277
1278 for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1279 aCommit.Remove( aOriginZones[i] );
1280
1281 aMergedZones.push_back( aOriginZones[0] );
1282
1283 aOriginZones[0]->SetLocalFlags( 1 );
1284 aOriginZones[0]->HatchBorder();
1285 aOriginZones[0]->CacheTriangulation();
1286
1287 return true;
1288}
virtual void Revert() override
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
Definition: commit.h:103
COMMIT & Remove(EDA_ITEM *aItem)
Notify observers that aItem has been removed.
Definition: commit.h:90
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:325
#define _(s)

References _, DisplayErrorMessage(), COMMIT::Modify(), SHAPE_POLY_SET::PM_FAST, COMMIT::Remove(), and BOARD_COMMIT::Revert().

Referenced by BOARD_EDITOR_CONTROL::ZoneMerge().