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 (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 1374 of file board_editor_control.cpp.

1376 {
1377  aCommit.Modify( aOriginZones[0] );
1378 
1379  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1380  {
1381  aOriginZones[0]->Outline()->BooleanAdd( *aOriginZones[i]->Outline(),
1383  }
1384 
1385  aOriginZones[0]->Outline()->Simplify( SHAPE_POLY_SET::PM_FAST );
1386 
1387  // We should have one polygon, possibly with holes. If we end up with two polygons (either
1388  // because the intersection was a single point or because the intersection was within one of
1389  // the zone's holes) then we can't merge.
1390  if( aOriginZones[0]->Outline()->IsSelfIntersecting()
1391  || aOriginZones[0]->Outline()->OutlineCount() > 1 )
1392  {
1393  DisplayErrorMessage( aFrame, _( "Zones have insufficient overlap for merging." ) );
1394  aCommit.Revert();
1395  return false;
1396  }
1397 
1398  for( unsigned int i = 1; i < aOriginZones.size(); i++ )
1399  aCommit.Remove( aOriginZones[i] );
1400 
1401  aMergedZones.push_back( aOriginZones[0] );
1402 
1403  aOriginZones[0]->SetLocalFlags( 1 );
1404  aOriginZones[0]->HatchBorder();
1405  aOriginZones[0]->CacheTriangulation();
1406 
1407  return true;
1408 }
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
Definition: commit.h:103
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:292
virtual void Revert() override
#define _(s)
COMMIT & Remove(EDA_ITEM *aItem)
Notify observers that aItem has been removed.
Definition: commit.h:90

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

Referenced by BOARD_EDITOR_CONTROL::ZoneMerge().