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 <dimension.h>
#include <zone.h>
#include <connectivity/connectivity_data.h>
#include <widgets/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 64 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 74 of file pcb_point_editor.cpp.

◆ CIRCLE_POINTS

Enumerator
CIRC_CENTER 
CIRC_END 
CIRC_CENTER 
CIRC_END 

Definition at line 69 of file pcb_point_editor.cpp.

◆ DIMENSION_POINTS

Enumerator
DIM_START 
DIM_END 
DIM_TEXT 
DIM_CROSSBARSTART 
DIM_CROSSBAREND 

Definition at line 82 of file pcb_point_editor.cpp.

◆ RECT_LINES

enum RECT_LINES
Enumerator
RECT_TOP 
RECT_RIGHT 
RECT_BOT 
RECT_LEFT 

Definition at line 59 of file pcb_point_editor.cpp.

◆ RECT_POINTS

Enumerator
RECT_TOP_LEFT 
RECT_TOP_RIGHT 
RECT_BOT_RIGHT 
RECT_BOT_LEFT 

Definition at line 54 of file pcb_point_editor.cpp.

◆ SEG_POINTS

enum SEG_POINTS
Enumerator
SEG_START 
SEG_END 

Definition at line 49 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 1920 of file pcb_point_editor.cpp.

1921 {
1922  for( auto it = aPolySet.IterateWithHoles(); it; ++it )
1923  {
1924  auto vertexIdx = it.GetIndex();
1925 
1926  if( aPolySet.CVertex( vertexIdx ) == aPoint.GetPosition() )
1927  return std::make_pair( true, vertexIdx );
1928  }
1929 
1930  return std::make_pair( false, SHAPE_POLY_SET::VERTEX_INDEX() );
1931 }
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(), PNS::LINE::Walkaround(), and walkaround2().

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

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

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