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 1883 of file pcb_point_editor.cpp.

1884 {
1885  for( auto it = aPolySet.IterateWithHoles(); it; ++it )
1886  {
1887  auto vertexIdx = it.GetIndex();
1888 
1889  if( aPolySet.CVertex( vertexIdx ) == aPoint.GetPosition() )
1890  return std::make_pair( true, vertexIdx );
1891  }
1892 
1893  return std::make_pair( false, SHAPE_POLY_SET::VERTEX_INDEX() );
1894 }
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 763 of file pcb_point_editor.cpp.

766 {
767  switch( aEditedPointIndex )
768  {
769  case RECT_TOP_LEFT:
770  if( aHoleSize.x )
771  {
772  // pin edited point to the top/left of the hole
773  aTopLeft.x = std::min( aTopLeft.x, aHole.x - aHoleSize.x / 2 - aMinWidth );
774  aTopLeft.y = std::min( aTopLeft.y, aHole.y - aHoleSize.y / 2 - aMinHeight );
775  }
776  else
777  {
778  // pin edited point within opposite corner
779  aTopLeft.x = std::min( aTopLeft.x, aBotRight.x - aMinWidth );
780  aTopLeft.y = std::min( aTopLeft.y, aBotRight.y - aMinHeight );
781  }
782 
783  // push edited point edges to adjacent corners
784  aTopRight.y = aTopLeft.y;
785  aBotLeft.x = aTopLeft.x;
786 
787  break;
788 
789  case RECT_TOP_RIGHT:
790  if( aHoleSize.x )
791  {
792  // pin edited point to the top/right of the hole
793  aTopRight.x = std::max( aTopRight.x, aHole.x + aHoleSize.x / 2 + aMinWidth );
794  aTopRight.y = std::min( aTopRight.y, aHole.y - aHoleSize.y / 2 - aMinHeight );
795  }
796  else
797  {
798  // pin edited point within opposite corner
799  aTopRight.x = std::max( aTopRight.x, aBotLeft.x + aMinWidth );
800  aTopRight.y = std::min( aTopRight.y, aBotLeft.y - aMinHeight );
801  }
802 
803  // push edited point edges to adjacent corners
804  aTopLeft.y = aTopRight.y;
805  aBotRight.x = aTopRight.x;
806 
807  break;
808 
809  case RECT_BOT_LEFT:
810  if( aHoleSize.x )
811  {
812  // pin edited point to the bottom/left of the hole
813  aBotLeft.x = std::min( aBotLeft.x, aHole.x - aHoleSize.x / 2 - aMinWidth );
814  aBotLeft.y = std::max( aBotLeft.y, aHole.y + aHoleSize.y / 2 + aMinHeight );
815  }
816  else
817  {
818  // pin edited point within opposite corner
819  aBotLeft.x = std::min( aBotLeft.x, aTopRight.x - aMinWidth );
820  aBotLeft.y = std::max( aBotLeft.y, aTopRight.y + aMinHeight );
821  }
822 
823  // push edited point edges to adjacent corners
824  aBotRight.y = aBotLeft.y;
825  aTopLeft.x = aBotLeft.x;
826 
827  break;
828 
829  case RECT_BOT_RIGHT:
830  if( aHoleSize.x )
831  {
832  // pin edited point to the bottom/right of the hole
833  aBotRight.x = std::max( aBotRight.x, aHole.x + aHoleSize.x / 2 + aMinWidth );
834  aBotRight.y = std::max( aBotRight.y, aHole.y + aHoleSize.y / 2 + aMinHeight );
835  }
836  else
837  {
838  // pin edited point within opposite corner
839  aBotRight.x = std::max( aBotRight.x, aTopLeft.x + aMinWidth );
840  aBotRight.y = std::max( aBotRight.y, aTopLeft.y + aMinHeight );
841  }
842 
843  // push edited point edges to adjacent corners
844  aBotLeft.y = aBotRight.y;
845  aTopRight.x = aBotRight.x;
846 
847  break;
848  }
849 }

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().