KiCad PCB EDA Suite
pcb_point_editor.cpp File Reference
#include <functional>
#include <memory>
#include <advanced_config.h>
#include <tool/tool_manager.h>
#include <view/view_controls.h>
#include <geometry/seg.h>
#include <confirm.h>
#include "pcb_actions.h"
#include "pcb_selection_tool.h"
#include "pcb_point_editor.h"
#include "pcb_grid_helper.h"
#include <board_commit.h>
#include <bitmaps.h>
#include <status_popup.h>
#include <pcb_edit_frame.h>
#include <fp_shape.h>
#include <pcb_dimension.h>
#include <pad.h>
#include <zone.h>
#include <connectivity/connectivity_data.h>
#include <progress_reporter.h>

Go to the source code of this file.

Enumerations

enum  SEG_POINTS { SEG_START, SEG_END }
 
enum  RECT_POINTS { RECT_TOP_LEFT, RECT_TOP_RIGHT, RECT_BOT_RIGHT, RECT_BOT_LEFT }
 
enum  RECT_LINES { RECT_TOP, RECT_RIGHT, RECT_BOT, RECT_LEFT }
 
enum  ARC_POINTS {
  ARC_CENTER, ARC_START, ARC_END, ARC_CENTER,
  ARC_START, ARC_MID, ARC_END
}
 
enum  CIRCLE_POINTS { CIRC_CENTER, CIRC_END, CIRC_CENTER, CIRC_END }
 
enum  BEZIER_CURVE_POINTS { BEZIER_CURVE_START, BEZIER_CURVE_CONTROL_POINT1, BEZIER_CURVE_CONTROL_POINT2, BEZIER_CURVE_END }
 
enum  DIMENSION_POINTS {
  DIM_START, DIM_END, DIM_TEXT, DIM_CROSSBARSTART,
  DIM_CROSSBAREND
}
 

Functions

static void pinEditedCorner (int aEditedPointIndex, int aMinWidth, int aMinHeight, VECTOR2I &aTopLeft, VECTOR2I &aTopRight, VECTOR2I &aBotLeft, VECTOR2I &aBotRight, VECTOR2I &aHole, VECTOR2I &aHoleSize)
 Update the coordinates of 4 corners of a rectangle, according to pad constraints and the moved corner. More...
 
static std::pair< bool, SHAPE_POLY_SET::VERTEX_INDEXfindVertex (SHAPE_POLY_SET &aPolySet, const EDIT_POINT &aPoint)
 

Enumeration Type Documentation

◆ ARC_POINTS

enum ARC_POINTS
Enumerator
ARC_CENTER 
ARC_START 
ARC_END 
ARC_CENTER 
ARC_START 
ARC_MID 
ARC_END 

Definition at line 70 of file pcb_point_editor.cpp.

◆ BEZIER_CURVE_POINTS

Enumerator
BEZIER_CURVE_START 
BEZIER_CURVE_CONTROL_POINT1 
BEZIER_CURVE_CONTROL_POINT2 
BEZIER_CURVE_END 

Definition at line 82 of file pcb_point_editor.cpp.

◆ CIRCLE_POINTS

Enumerator
CIRC_CENTER 
CIRC_END 
CIRC_CENTER 
CIRC_END 

Definition at line 76 of file pcb_point_editor.cpp.

◆ DIMENSION_POINTS

Enumerator
DIM_START 
DIM_END 
DIM_TEXT 
DIM_CROSSBARSTART 
DIM_CROSSBAREND 

Definition at line 91 of file pcb_point_editor.cpp.

◆ RECT_LINES

enum RECT_LINES
Enumerator
RECT_TOP 
RECT_RIGHT 
RECT_BOT 
RECT_LEFT 

Definition at line 64 of file pcb_point_editor.cpp.

◆ RECT_POINTS

Enumerator
RECT_TOP_LEFT 
RECT_TOP_RIGHT 
RECT_BOT_RIGHT 
RECT_BOT_LEFT 

Definition at line 58 of file pcb_point_editor.cpp.

◆ SEG_POINTS

enum SEG_POINTS
Enumerator
SEG_START 
SEG_END 

Definition at line 52 of file pcb_point_editor.cpp.

Function Documentation

◆ findVertex()

static std::pair<bool, SHAPE_POLY_SET::VERTEX_INDEX> findVertex ( SHAPE_POLY_SET aPolySet,
const EDIT_POINT aPoint 
)
static

Definition at line 1905 of file pcb_point_editor.cpp.

1906 {
1907  for( auto it = aPolySet.IterateWithHoles(); it; ++it )
1908  {
1909  auto vertexIdx = it.GetIndex();
1910 
1911  if( aPolySet.CVertex( vertexIdx ) == aPoint.GetPosition() )
1912  return std::make_pair( true, vertexIdx );
1913  }
1914 
1915  return std::make_pair( false, SHAPE_POLY_SET::VERTEX_INDEX() );
1916 }
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the aGlobalIndex-th vertex in the poly set.
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: th...
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
Definition: edit_points.h:70
ITERATOR IterateWithHoles(int aOutline)

References SHAPE_POLY_SET::CVertex(), EDIT_POINT::GetPosition(), and SHAPE_POLY_SET::IterateWithHoles().

Referenced by PCB_POINT_EDITOR::removeCorner(), PCB_POINT_EDITOR::removeCornerCondition(), and PNS::LINE::Walkaround().

◆ pinEditedCorner()

static void pinEditedCorner ( int  aEditedPointIndex,
int  aMinWidth,
int  aMinHeight,
VECTOR2I aTopLeft,
VECTOR2I aTopRight,
VECTOR2I aBotLeft,
VECTOR2I aBotRight,
VECTOR2I aHole,
VECTOR2I aHoleSize 
)
static

Update the coordinates of 4 corners of a rectangle, according to pad constraints and the moved corner.

Parameters
aEditedPointIndexis the corner id
aMinWidthis the minimal width constraint
aMinHeightis the minimal height constraint
aTopLeft[in/out] is the RECT_TOPLEFT to constraint
aTopRight[in/out] is the RECT_TOPRIGHT to constraint
aBotLeft[in/out] is the RECT_BOTLEFT to constraint
aBotRight[in/out] is the RECT_BOTRIGHT to constraint
aHolethe location of the pad's hole
aHoleSizethe pad's hole size (or {0,0} if it has no hole)

Definition at line 786 of file pcb_point_editor.cpp.

789 {
790  switch( aEditedPointIndex )
791  {
792  case RECT_TOP_LEFT:
793  if( aHoleSize.x )
794  {
795  // pin edited point to the top/left of the hole
796  aTopLeft.x = std::min( aTopLeft.x, aHole.x - aHoleSize.x / 2 - aMinWidth );
797  aTopLeft.y = std::min( aTopLeft.y, aHole.y - aHoleSize.y / 2 - aMinHeight );
798  }
799  else
800  {
801  // pin edited point within opposite corner
802  aTopLeft.x = std::min( aTopLeft.x, aBotRight.x - aMinWidth );
803  aTopLeft.y = std::min( aTopLeft.y, aBotRight.y - aMinHeight );
804  }
805 
806  // push edited point edges to adjacent corners
807  aTopRight.y = aTopLeft.y;
808  aBotLeft.x = aTopLeft.x;
809 
810  break;
811 
812  case RECT_TOP_RIGHT:
813  if( aHoleSize.x )
814  {
815  // pin edited point to the top/right of the hole
816  aTopRight.x = std::max( aTopRight.x, aHole.x + aHoleSize.x / 2 + aMinWidth );
817  aTopRight.y = std::min( aTopRight.y, aHole.y - aHoleSize.y / 2 - aMinHeight );
818  }
819  else
820  {
821  // pin edited point within opposite corner
822  aTopRight.x = std::max( aTopRight.x, aBotLeft.x + aMinWidth );
823  aTopRight.y = std::min( aTopRight.y, aBotLeft.y - aMinHeight );
824  }
825 
826  // push edited point edges to adjacent corners
827  aTopLeft.y = aTopRight.y;
828  aBotRight.x = aTopRight.x;
829 
830  break;
831 
832  case RECT_BOT_LEFT:
833  if( aHoleSize.x )
834  {
835  // pin edited point to the bottom/left of the hole
836  aBotLeft.x = std::min( aBotLeft.x, aHole.x - aHoleSize.x / 2 - aMinWidth );
837  aBotLeft.y = std::max( aBotLeft.y, aHole.y + aHoleSize.y / 2 + aMinHeight );
838  }
839  else
840  {
841  // pin edited point within opposite corner
842  aBotLeft.x = std::min( aBotLeft.x, aTopRight.x - aMinWidth );
843  aBotLeft.y = std::max( aBotLeft.y, aTopRight.y + aMinHeight );
844  }
845 
846  // push edited point edges to adjacent corners
847  aBotRight.y = aBotLeft.y;
848  aTopLeft.x = aBotLeft.x;
849 
850  break;
851 
852  case RECT_BOT_RIGHT:
853  if( aHoleSize.x )
854  {
855  // pin edited point to the bottom/right of the hole
856  aBotRight.x = std::max( aBotRight.x, aHole.x + aHoleSize.x / 2 + aMinWidth );
857  aBotRight.y = std::max( aBotRight.y, aHole.y + aHoleSize.y / 2 + aMinHeight );
858  }
859  else
860  {
861  // pin edited point within opposite corner
862  aBotRight.x = std::max( aBotRight.x, aTopLeft.x + aMinWidth );
863  aBotRight.y = std::max( aBotRight.y, aTopLeft.y + aMinHeight );
864  }
865 
866  // push edited point edges to adjacent corners
867  aBotLeft.y = aBotRight.y;
868  aTopRight.x = aBotRight.x;
869 
870  break;
871  }
872 }

References RECT_BOT_LEFT, RECT_BOT_RIGHT, RECT_TOP_LEFT, RECT_TOP_RIGHT, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PCB_POINT_EDITOR::updateItem().