KiCad PCB EDA Suite
board_editor_control.cpp File Reference
#include <functional>
#include <memory>
#include <advanced_config.h>
#include "board_editor_control.h"
#include <bitmaps.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 <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 <pcbnew_settings.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_tool.h>
#include <tools/edit_tool.h>
#include <tools/tool_event_utils.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>

Go to the source code of this file.

Classes

class  ZONE_CONTEXT_MENU
 
class  LOCK_CONTEXT_MENU
 
class  NETLIST_OPTIONS_HELPER
 Helper widget to add controls to a wxFileDialog to set netlist configuration options. More...
 

Functions

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

Function Documentation

◆ mergeZones()

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

Definition at line 1318 of file board_editor_control.cpp.

1320 {
1321  aCommit.Modify( aOriginZones[0] );
1322 
1323  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1324  {
1325  aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
1327  }
1328 
1329  aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
1330 
1331  // We should have one polygon with hole
1332  // We can have 2 polygons with hole, if the 2 initial polygons have only one common corner
1333  // and therefore cannot be merged (they are detected as intersecting)
1334  // but we should never have more than 2 polys
1335  if( aOriginZones[0]->Outline()->OutlineCount() > 1 )
1336  {
1337  wxLogMessage( "BOARD::mergeZones error: more than 2 polys after merging" );
1338  return false;
1339  }
1340 
1341  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1342  aCommit.Remove( aOriginZones[i] );
1343 
1344  aMergedZones.push_back( aOriginZones[0] );
1345 
1346  aOriginZones[0]->SetLocalFlags( 1 );
1347  aOriginZones[0]->HatchBorder();
1348  aOriginZones[0]->CacheTriangulation();
1349 
1350  return true;
1351 }
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

References COMMIT::Modify(), SHAPE_POLY_SET::PM_FAST, and COMMIT::Remove().

Referenced by BOARD_EDITOR_CONTROL::ZoneMerge().