KiCad PCB EDA Suite
point_editor.cpp File Reference
#include <functional>
#include <memory>
#include <advanced_config.h>
#include <tool/tool_manager.h>
#include <view/view_controls.h>
#include <gal/graphics_abstraction_layer.h>
#include <geometry/seg.h>
#include <confirm.h>
#include "pcb_actions.h"
#include "selection_tool.h"
#include "point_editor.h"
#include "grid_helper.h"
#include <board_commit.h>
#include <bitmaps.h>
#include <status_popup.h>
#include <pcb_edit_frame.h>
#include <class_edge_mod.h>
#include <class_dimension.h>
#include <class_zone.h>
#include <connectivity/connectivity_data.h>
#include <widgets/progress_reporter.h>

Go to the source code of this file.

Classes

class  EDIT_POINTS_FACTORY
 

Enumerations

enum  SEG_POINTS { SEG_START, SEG_END }
 
enum  RECT_POINTS { RECT_TOP_LEFT, RECT_TOP_RIGHT, RECT_BOT_RIGHT, RECT_BOT_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 59 of file point_editor.cpp.

◆ BEZIER_CURVE_POINTS

Enumerator
BEZIER_CURVE_START 
BEZIER_CURVE_CONTROL_POINT1 
BEZIER_CURVE_CONTROL_POINT2 
BEZIER_CURVE_END 

Definition at line 69 of file point_editor.cpp.

◆ CIRCLE_POINTS

Enumerator
CIRC_CENTER 
CIRC_END 
CIRC_CENTER 
CIRC_END 

Definition at line 64 of file point_editor.cpp.

◆ DIMENSION_POINTS

Enumerator
DIM_START 
DIM_END 
DIM_TEXT 
DIM_CROSSBARSTART 
DIM_CROSSBAREND 

Definition at line 77 of file point_editor.cpp.

◆ RECT_POINTS

Enumerator
RECT_TOP_LEFT 
RECT_TOP_RIGHT 
RECT_BOT_RIGHT 
RECT_BOT_LEFT 

Definition at line 54 of file point_editor.cpp.

◆ SEG_POINTS

enum SEG_POINTS
Enumerator
SEG_START 
SEG_END 

Definition at line 49 of file point_editor.cpp.

50 {
52 };

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 1867 of file point_editor.cpp.

1868 {
1869  for( auto it = aPolySet.IterateWithHoles(); it; ++it )
1870  {
1871  auto vertexIdx = it.GetIndex();
1872 
1873  if( aPolySet.CVertex( vertexIdx ) == aPoint.GetPosition() )
1874  return std::make_pair( true, vertexIdx );
1875  }
1876 
1877  return std::make_pair( false, SHAPE_POLY_SET::VERTEX_INDEX() );
1878 }
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
Struct VERTEX_INDEX.
virtual VECTOR2I GetPosition() const
Function GetPosition()
Definition: edit_points.h:70
ITERATOR IterateWithHoles(int aOutline)
Function IterateWithHoles.

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

Referenced by POINT_EDITOR::removeCorner(), and POINT_EDITOR::removeCornerCondition().

◆ 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 722 of file point_editor.cpp.

725 {
726  switch( aEditedPointIndex )
727  {
728  case RECT_TOP_LEFT:
729  if( aHoleSize.x )
730  {
731  // pin edited point to the top/left of the hole
732  aTopLeft.x = std::min( aTopLeft.x, aHole.x - aHoleSize.x / 2 - aMinWidth );
733  aTopLeft.y = std::min( aTopLeft.y, aHole.y - aHoleSize.y / 2 - aMinHeight );
734  }
735  else
736  {
737  // pin edited point within opposite corner
738  aTopLeft.x = std::min( aTopLeft.x, aBotRight.x - aMinWidth );
739  aTopLeft.y = std::min( aTopLeft.y, aBotRight.y - aMinHeight );
740  }
741 
742  // push edited point edges to adjacent corners
743  aTopRight.y = aTopLeft.y;
744  aBotLeft.x = aTopLeft.x;
745 
746  break;
747 
748  case RECT_TOP_RIGHT:
749  if( aHoleSize.x )
750  {
751  // pin edited point to the top/right of the hole
752  aTopRight.x = std::max( aTopRight.x, aHole.x + aHoleSize.x / 2 + aMinWidth );
753  aTopRight.y = std::min( aTopRight.y, aHole.y - aHoleSize.y / 2 - aMinHeight );
754  }
755  else
756  {
757  // pin edited point within opposite corner
758  aTopRight.x = std::max( aTopRight.x, aBotLeft.x + aMinWidth );
759  aTopRight.y = std::min( aTopRight.y, aBotLeft.y - aMinHeight );
760  }
761 
762  // push edited point edges to adjacent corners
763  aTopLeft.y = aTopRight.y;
764  aBotRight.x = aTopRight.x;
765 
766  break;
767 
768  case RECT_BOT_LEFT:
769  if( aHoleSize.x )
770  {
771  // pin edited point to the bottom/left of the hole
772  aBotLeft.x = std::min( aBotLeft.x, aHole.x - aHoleSize.x / 2 - aMinWidth );
773  aBotLeft.y = std::max( aBotLeft.y, aHole.y + aHoleSize.y / 2 + aMinHeight );
774  }
775  else
776  {
777  // pin edited point within opposite corner
778  aBotLeft.x = std::min( aBotLeft.x, aTopRight.x - aMinWidth );
779  aBotLeft.y = std::max( aBotLeft.y, aTopRight.y + aMinHeight );
780  }
781 
782  // push edited point edges to adjacent corners
783  aBotRight.y = aBotLeft.y;
784  aTopLeft.x = aBotLeft.x;
785 
786  break;
787 
788  case RECT_BOT_RIGHT:
789  if( aHoleSize.x )
790  {
791  // pin edited point to the bottom/right of the hole
792  aBotRight.x = std::max( aBotRight.x, aHole.x + aHoleSize.x / 2 + aMinWidth );
793  aBotRight.y = std::max( aBotRight.y, aHole.y + aHoleSize.y / 2 + aMinHeight );
794  }
795  else
796  {
797  // pin edited point within opposite corner
798  aBotRight.x = std::max( aBotRight.x, aTopLeft.x + aMinWidth );
799  aBotRight.y = std::max( aBotRight.y, aTopLeft.y + aMinHeight );
800  }
801 
802  // push edited point edges to adjacent corners
803  aBotLeft.y = aBotRight.y;
804  aTopRight.x = aBotRight.x;
805 
806  break;
807  }
808 }

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

Referenced by POINT_EDITOR::updateItem().