KiCad PCB EDA Suite
dialog_export_step.cpp File Reference
#include <wx/choicdlg.h>
#include <wx/stdpaths.h>
#include "pcb_edit_frame.h"
#include "kiface_i.h"
#include "confirm.h"
#include "reporter.h"
#include "pcbnew.h"
#include "class_board.h"
#include "dialog_export_step_base.h"
#include <widgets/text_ctrl_eval.h>
#include <wx_html_report_panel.h>

Go to the source code of this file.

Classes

class  DIALOG_EXPORT_STEP
 

Macros

#define OPTKEY_STEP_ORIGIN_OPT   "STEP_Origin_Opt"
 
#define OPTKEY_STEP_UORG_UNITS   "STEP_UserOriginUnits"
 
#define OPTKEY_STEP_UORG_X   "STEP_UserOriginX"
 
#define OPTKEY_STEP_UORG_Y   "STEP_UserOriginY"
 
#define OPTKEY_STEP_NOVIRT   "STEP_NoVirtual"
 

Functions

bool BuildBoardPolygonOutlines (BOARD *aBoard, SHAPE_POLY_SET &aOutlines, wxString *aErrorText, unsigned int aTolerance, wxPoint *aErrorLocation=nullptr)
 

Macro Definition Documentation

◆ OPTKEY_STEP_NOVIRT

#define OPTKEY_STEP_NOVIRT   "STEP_NoVirtual"

Definition at line 47 of file dialog_export_step.cpp.

◆ OPTKEY_STEP_ORIGIN_OPT

#define OPTKEY_STEP_ORIGIN_OPT   "STEP_Origin_Opt"

Definition at line 43 of file dialog_export_step.cpp.

◆ OPTKEY_STEP_UORG_UNITS

#define OPTKEY_STEP_UORG_UNITS   "STEP_UserOriginUnits"

Definition at line 44 of file dialog_export_step.cpp.

◆ OPTKEY_STEP_UORG_X

#define OPTKEY_STEP_UORG_X   "STEP_UserOriginX"

Definition at line 45 of file dialog_export_step.cpp.

◆ OPTKEY_STEP_UORG_Y

#define OPTKEY_STEP_UORG_Y   "STEP_UserOriginY"

Definition at line 46 of file dialog_export_step.cpp.

Function Documentation

◆ BuildBoardPolygonOutlines()

bool BuildBoardPolygonOutlines ( BOARD aBoard,
SHAPE_POLY_SET aOutlines,
wxString *  aErrorText,
unsigned int  aTolerance,
wxPoint *  aErrorLocation = nullptr 
)

Definition at line 750 of file convert_drawsegment_list_to_polygon.cpp.

752 {
753  PCB_TYPE_COLLECTOR items;
754 
755  // Get all the DRAWSEGMENTS and module graphics into 'items',
756  // then keep only those on layer == Edge_Cuts.
757  static const KICAD_T scan_graphics[] = { PCB_LINE_T, PCB_MODULE_EDGE_T, EOT };
758  items.Collect( aBoard, scan_graphics );
759 
760  // Make a working copy of aSegList, because the list is modified during calculations
761  std::vector< DRAWSEGMENT* > segList;
762 
763  for( int ii = 0; ii < items.GetCount(); ii++ )
764  {
765  if( items[ii]->GetLayer() == Edge_Cuts )
766  segList.push_back( static_cast< DRAWSEGMENT* >( items[ii] ) );
767  }
768 
769  bool success = ConvertOutlineToPolygon( segList, aOutlines, aErrorText, aTolerance, aErrorLocation );
770 
771  if( !success || !aOutlines.OutlineCount() )
772  {
773  // Creates a valid polygon outline is not possible.
774  // So uses the board edge cuts bounding box to create a
775  // rectangular outline
776  // When no edge cuts items, build a contour
777  // from global bounding box
778 
779  EDA_RECT bbbox = aBoard->GetBoardEdgesBoundingBox();
780 
781  // If null area, uses the global bounding box.
782  if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )
783  bbbox = aBoard->ComputeBoundingBox();
784 
785  // Ensure non null area. If happen, gives a minimal size.
786  if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )
787  bbbox.Inflate( Millimeter2iu( 1.0 ) );
788 
789  aOutlines.RemoveAllContours();
790  aOutlines.NewOutline();
791 
792  wxPoint corner;
793  aOutlines.Append( bbbox.GetOrigin() );
794 
795  corner.x = bbbox.GetOrigin().x;
796  corner.y = bbbox.GetEnd().y;
797  aOutlines.Append( corner );
798 
799  aOutlines.Append( bbbox.GetEnd() );
800 
801  corner.x = bbbox.GetEnd().x;
802  corner.y = bbbox.GetOrigin().y;
803  aOutlines.Append( corner );
804  }
805 
806  return success;
807 }
int OutlineCount() const
Returns the number of outlines in the set
const EDA_RECT GetBoardEdgesBoundingBox() const
Function GetBoardEdgesBoundingBox Returns the board bounding box calculated using exclusively the boa...
Definition: class_board.h:810
int GetWidth() const
Definition: eda_rect.h:117
bool ConvertOutlineToPolygon(std::vector< DRAWSEGMENT * > &aSegList, SHAPE_POLY_SET &aPolygons, wxString *aErrorText, unsigned int aTolerance, wxPoint *aErrorLocation)
Function ConvertOutlineToPolygon build a polygon (with holes) from a DRAWSEGMENT list,...
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:114
const wxPoint GetEnd() const
Definition: eda_rect.h:114
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
int NewOutline()
Creates a new empty polygon in the set and returns its index
void Collect(BOARD_ITEM *aBoard, const KICAD_T aScanList[])
Collect BOARD_ITEM objects using this class's Inspector method, which does the collection.
Definition: collectors.cpp:522
int GetHeight() const
Definition: eda_rect.h:118
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
static bool GetLayer(MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Function ComputeBoundingBox calculates the bounding box containing all board items (or board edge seg...
Collect all BOARD_ITEM objects of a given set of KICAD_T type(s).
Definition: collectors.h:627
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

References SHAPE_POLY_SET::Append(), PCB_TYPE_COLLECTOR::Collect(), BOARD::ComputeBoundingBox(), ConvertOutlineToPolygon(), Edge_Cuts, EOT, BOARD::GetBoardEdgesBoundingBox(), COLLECTOR::GetCount(), EDA_RECT::GetEnd(), EDA_RECT::GetHeight(), GetLayer(), EDA_RECT::GetOrigin(), EDA_RECT::GetWidth(), EDA_RECT::Inflate(), SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::OutlineCount(), PCB_LINE_T, PCB_MODULE_EDGE_T, and SHAPE_POLY_SET::RemoveAllContours().

Referenced by DIALOG_EXPORT_STEP::onExportButton().