KiCad PCB EDA Suite
EDIT_POINTS_FACTORY Class Reference

Static Public Member Functions

static std::shared_ptr< EDIT_POINTSMake (EDA_ITEM *aItem, SCH_BASE_FRAME *frame)
 
static std::shared_ptr< EDIT_POINTSMake (EDA_ITEM *aItem, KIGFX::GAL *aGal)
 

Private Member Functions

 EDIT_POINTS_FACTORY ()
 
 EDIT_POINTS_FACTORY ()
 

Static Private Member Functions

static void buildForPolyOutline (std::shared_ptr< EDIT_POINTS > points, const SHAPE_POLY_SET *aOutline, KIGFX::GAL *aGal)
 

Detailed Description

Definition at line 67 of file ee_point_editor.cpp.

Constructor & Destructor Documentation

◆ EDIT_POINTS_FACTORY() [1/2]

EDIT_POINTS_FACTORY::EDIT_POINTS_FACTORY ( )
inlineprivate

Definition at line 203 of file ee_point_editor.cpp.

203 {};

◆ EDIT_POINTS_FACTORY() [2/2]

EDIT_POINTS_FACTORY::EDIT_POINTS_FACTORY ( )
inlineprivate

Definition at line 222 of file point_editor.cpp.

222 {};

Member Function Documentation

◆ buildForPolyOutline()

static void EDIT_POINTS_FACTORY::buildForPolyOutline ( std::shared_ptr< EDIT_POINTS points,
const SHAPE_POLY_SET aOutline,
KIGFX::GAL aGal 
)
inlinestaticprivate

Definition at line 83 of file point_editor.cpp.

85  {
86 
87  int cornersCount = aOutline->TotalVertices();
88 
89  for( auto iterator = aOutline->CIterateWithHoles(); iterator; iterator++ )
90  {
91  points->AddPoint( *iterator );
92 
93  if( iterator.IsEndContour() )
94  points->AddBreak();
95  }
96 
97  // Lines have to be added after creating edit points,
98  // as they use EDIT_POINT references
99  for( int i = 0; i < cornersCount - 1; ++i )
100  {
101  if( points->IsContourEnd( i ) )
102  {
103  points->AddLine( points->Point( i ),
104  points->Point( points->GetContourStartIdx( i ) ) );
105  }
106  else
107  {
108  points->AddLine( points->Point( i ), points->Point( i + 1 ) );
109  }
110 
111  points->Line( i ).SetConstraint( new EC_SNAPLINE( points->Line( i ),
112  std::bind( &KIGFX::GAL::GetGridPoint, aGal, _1 ) ) );
113  }
114 
115  // The last missing line, connecting the last and the first polygon point
116  points->AddLine( points->Point( cornersCount - 1 ),
117  points->Point( points->GetContourStartIdx( cornersCount - 1 ) ) );
118 
119  points->Line( points->LinesSize() - 1 ).SetConstraint(
120  new EC_SNAPLINE( points->Line( points->LinesSize() - 1 ),
121  std::bind( &KIGFX::GAL::GetGridPoint, aGal, _1 ) ) );
122  }
int TotalVertices() const
Returns total number of vertices stored in the set.
CONST_ITERATOR CIterateWithHoles(int aOutline) const
VECTOR2D GetGridPoint(const VECTOR2D &aPoint) const
Function GetGridPoint() For a given point it returns the nearest point belonging to the grid in world...
EC_SNAPLINE.

References SHAPE_POLY_SET::CIterateWithHoles(), KIGFX::GAL::GetGridPoint(), and SHAPE_POLY_SET::TotalVertices().

◆ Make() [1/2]

static std::shared_ptr<EDIT_POINTS> EDIT_POINTS_FACTORY::Make ( EDA_ITEM aItem,
SCH_BASE_FRAME frame 
)
inlinestatic

Definition at line 70 of file ee_point_editor.cpp.

71  {
72  std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
73 
74  if( !aItem )
75  return points;
76 
77  // Generate list of edit points based on the item type
78  switch( aItem->Type() )
79  {
80  case LIB_ARC_T:
81  {
82  LIB_ARC* arc = (LIB_ARC*) aItem;
83 
84  points->AddPoint( mapCoords( arc->GetPosition() ) );
85  points->AddPoint( mapCoords( arc->GetStart() ) );
86  points->AddPoint( mapCoords( arc->GetEnd() ) );
87  break;
88  }
89  case LIB_CIRCLE_T:
90  {
91  LIB_CIRCLE* circle = (LIB_CIRCLE*) aItem;
92 
93  points->AddPoint( mapCoords( circle->GetPosition() ) );
94  points->AddPoint( mapCoords( circle->GetEnd() ) );
95  break;
96  }
97  case LIB_POLYLINE_T:
98  {
99  LIB_POLYLINE* lines = (LIB_POLYLINE*) aItem;
100  const std::vector<wxPoint>& pts = lines->GetPolyPoints();
101 
102  for( wxPoint pt : pts )
103  points->AddPoint( mapCoords( pt ) );
104 
105  break;
106  }
107  case LIB_RECTANGLE_T:
108  {
109  LIB_RECTANGLE* rect = (LIB_RECTANGLE*) aItem;
110  // point editor works only with rectangles having width and height > 0
111  // Some symbols can have rectangles with width or height < 0
112  // So normalize the size:
113  BOX2I dummy;
114  dummy.SetOrigin( mapCoords( rect->GetPosition() ) );
115  dummy.SetEnd( mapCoords( rect->GetEnd() ) );
116  dummy.Normalize();
117  VECTOR2I topLeft = dummy.GetPosition();
118  VECTOR2I botRight = dummy.GetEnd();
119 
120  points->AddPoint( topLeft );
121  points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) );
122  points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) );
123  points->AddPoint( botRight );
124  break;
125  }
126  case SCH_SHEET_T:
127  {
128  SCH_SHEET* sheet = (SCH_SHEET*) aItem;
129  wxPoint topLeft = sheet->GetPosition();
130  wxPoint botRight = sheet->GetPosition() + sheet->GetSize();
131 
132  points->AddPoint( (wxPoint) topLeft );
133  points->AddPoint( wxPoint( botRight.x, topLeft.y ) );
134  points->AddPoint( wxPoint( topLeft.x, botRight.y ) );
135  points->AddPoint( (wxPoint) botRight );
136  break;
137  }
138  case SCH_BITMAP_T:
139  {
140  SCH_BITMAP* bitmap = (SCH_BITMAP*) aItem;
141  wxPoint topLeft = bitmap->GetPosition() - bitmap->GetSize() / 2;
142  wxPoint botRight = bitmap->GetPosition() + bitmap->GetSize() / 2;
143 
144  points->AddPoint( (wxPoint) topLeft );
145  points->AddPoint( wxPoint( botRight.x, topLeft.y ) );
146  points->AddPoint( wxPoint( topLeft.x, botRight.y ) );
147  points->AddPoint( (wxPoint) botRight );
148  break;
149  }
150  case SCH_LINE_T:
151  {
152  SCH_LINE* line = (SCH_LINE*) aItem;
153  SCH_LINE* connectedStart = nullptr;
154  SCH_LINE* connectedEnd = nullptr;
155 
156  for( auto test : frame->GetScreen()->Items().OfType( SCH_LINE_T ) )
157  {
158  if( test->GetLayer() != LAYER_NOTES )
159  continue;
160 
161  if( test == aItem )
162  continue;
163 
164  auto testLine = static_cast<SCH_LINE*>( test );
165  testLine->ClearFlags( STARTPOINT | ENDPOINT );
166 
167  if( testLine->GetStartPoint() == line->GetStartPoint() )
168  {
169  connectedStart = testLine;
170  testLine->SetFlags( STARTPOINT );
171  }
172  else if( testLine->GetEndPoint() == line->GetStartPoint() )
173  {
174  connectedStart = testLine;
175  testLine->SetFlags( ENDPOINT );
176  }
177  else if( testLine->GetStartPoint() == line->GetEndPoint() )
178  {
179  connectedEnd = testLine;
180  testLine->SetFlags( STARTPOINT );
181  }
182  else if( testLine->GetEndPoint() == line->GetEndPoint() )
183  {
184  connectedEnd = testLine;
185  testLine->SetFlags( ENDPOINT );
186  }
187  }
188 
189 
190  points->AddPoint( line->GetStartPoint(), connectedStart );
191  points->AddPoint( line->GetEndPoint(), connectedEnd );
192  break;
193  }
194  default:
195  points.reset();
196  break;
197  }
198 
199  return points;
200  }
wxPoint GetStartPoint() const
Definition: sch_line.h:97
wxPoint GetEnd() const
Definition: lib_rectangle.h:89
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
wxPoint GetPosition() const override
Definition: lib_circle.h:76
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_bitmap.h:140
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
const std::vector< wxPoint > & GetPolyPoints() const
Definition: lib_polyline.h:60
wxPoint GetEnd() const
Definition: lib_circle.h:79
wxSize GetSize() const
Definition: sch_bitmap.cpp:123
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:255
wxPoint GetStart() const
Definition: lib_arc.h:113
static VECTOR2D mapCoords(const wxPoint &aCoord)
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:538
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:206
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:38
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
EE_RTREE & Items()
Definition: sch_screen.h:127
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:126
wxPoint GetEnd() const
Definition: lib_arc.h:116
wxSize GetSize()
Definition: sch_sheet.h:280
wxPoint GetPosition() const override
Definition: lib_rectangle.h:76
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207
wxPoint GetPosition() const override
Definition: lib_arc.h:92
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:125
wxPoint GetEndPoint() const
Definition: sch_line.h:100

References dummy(), ENDPOINT, LIB_CIRCLE::GetEnd(), LIB_RECTANGLE::GetEnd(), LIB_ARC::GetEnd(), SCH_LINE::GetEndPoint(), LIB_POLYLINE::GetPolyPoints(), LIB_CIRCLE::GetPosition(), LIB_RECTANGLE::GetPosition(), LIB_ARC::GetPosition(), SCH_BITMAP::GetPosition(), SCH_SHEET::GetPosition(), SCH_BASE_FRAME::GetScreen(), SCH_BITMAP::GetSize(), SCH_SHEET::GetSize(), LIB_ARC::GetStart(), SCH_LINE::GetStartPoint(), SCH_SCREEN::Items(), LAYER_NOTES, LIB_ARC_T, LIB_CIRCLE_T, LIB_POLYLINE_T, LIB_RECTANGLE_T, KIGFX::mapCoords(), EE_RTREE::OfType(), SCH_BITMAP_T, SCH_LINE_T, SCH_SHEET_T, EDA_ITEM::SetFlags(), STARTPOINT, EDA_ITEM::Type(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by EE_POINT_EDITOR::Main(), POINT_EDITOR::OnSelectionChange(), EE_POINT_EDITOR::updatePoints(), and POINT_EDITOR::updatePoints().

◆ Make() [2/2]

static std::shared_ptr<EDIT_POINTS> EDIT_POINTS_FACTORY::Make ( EDA_ITEM aItem,
KIGFX::GAL aGal 
)
inlinestatic

Definition at line 125 of file point_editor.cpp.

126  {
127  std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
128 
129  if( !aItem )
130  return points;
131 
132  // Generate list of edit points basing on the item type
133  switch( aItem->Type() )
134  {
135  case PCB_LINE_T:
136  case PCB_MODULE_EDGE_T:
137  {
138  const DRAWSEGMENT* segment = static_cast<const DRAWSEGMENT*>( aItem );
139 
140  switch( segment->GetShape() )
141  {
142  case S_SEGMENT:
143  points->AddPoint( segment->GetStart() );
144  points->AddPoint( segment->GetEnd() );
145  break;
146 
147  case S_ARC:
148  points->AddPoint( segment->GetCenter() );
149  points->AddPoint( segment->GetArcStart() );
150  points->AddPoint( segment->GetArcMid() );
151  points->AddPoint( segment->GetArcEnd() );
152 
153  // Set constraints
154  // Arc end has to stay at the same radius as the start
155  points->Point( ARC_END ).SetConstraint( new EC_CIRCLE( points->Point( ARC_END ),
156  points->Point( ARC_CENTER ),
157  points->Point( ARC_START ) ) );
158 
159  points->Point( ARC_MID ).SetConstraint( new EC_LINE( points->Point( ARC_MID ),
160  points->Point( ARC_CENTER ) ) );
161  break;
162 
163  case S_CIRCLE:
164  points->AddPoint( segment->GetCenter() );
165  points->AddPoint( segment->GetEnd() );
166 
167  break;
168 
169  case S_POLYGON:
170  buildForPolyOutline( points, &segment->GetPolyShape(), aGal );
171  break;
172 
173  case S_CURVE:
174  points->AddPoint( segment->GetStart() );
175  points->AddPoint( segment->GetBezControl1() );
176  points->AddPoint( segment->GetBezControl2() );
177  points->AddPoint( segment->GetEnd() );
178  break;
179 
180  default: // suppress warnings
181  break;
182  }
183 
184  break;
185  }
186 
188  case PCB_ZONE_AREA_T:
189  {
190  auto zone = static_cast<const ZONE_CONTAINER*>( aItem );
191  buildForPolyOutline( points, zone->Outline(), aGal );
192  break;
193  }
194 
195  case PCB_DIMENSION_T:
196  {
197  const DIMENSION* dimension = static_cast<const DIMENSION*>( aItem );
198 
199  points->AddPoint( dimension->m_crossBarO );
200  points->AddPoint( dimension->m_crossBarF );
201  points->AddPoint( dimension->m_featureLineGO );
202  points->AddPoint( dimension->m_featureLineDO );
203 
204  // Dimension height setting - edit points should move only along the feature lines
205  points->Point( DIM_CROSSBARO ).SetConstraint( new EC_LINE( points->Point( DIM_CROSSBARO ),
206  points->Point( DIM_FEATUREGO ) ) );
207  points->Point( DIM_CROSSBARF ).SetConstraint( new EC_LINE( points->Point( DIM_CROSSBARF ),
208  points->Point( DIM_FEATUREDO ) ) );
209 
210  break;
211  }
212 
213  default:
214  points.reset();
215  break;
216  }
217 
218  return points;
219  }
const wxPoint GetArcMid() const
wxPoint m_crossBarF
const wxPoint GetCenter() const override
Function GetCenter()
STROKE_T GetShape() const
const wxPoint GetArcEnd() const
polygon (not yet used for tracks, but could be in microwave apps)
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:101
usual segment : line with rounded ends
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
EC_LINE.
EC_CIRCLE.
wxPoint m_featureLineGO
Arcs (with rounded ends)
const wxPoint & GetArcStart() const
SHAPE_POLY_SET & GetPolyShape()
Bezier Curve.
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:99
const wxPoint & GetBezControl2() const
wxPoint m_crossBarO
const wxPoint & GetBezControl1() const
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
class ZONE_CONTAINER, managed by a footprint
Definition: typeinfo.h:95
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
wxPoint m_featureLineDO
static void buildForPolyOutline(std::shared_ptr< EDIT_POINTS > points, const SHAPE_POLY_SET *aOutline, KIGFX::GAL *aGal)
DIMENSION.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207

References ARC_CENTER, ARC_END, ARC_MID, ARC_START, DIM_CROSSBARF, DIM_CROSSBARO, DIM_FEATUREDO, DIM_FEATUREGO, DRAWSEGMENT::GetArcEnd(), DRAWSEGMENT::GetArcMid(), DRAWSEGMENT::GetArcStart(), DRAWSEGMENT::GetBezControl1(), DRAWSEGMENT::GetBezControl2(), DRAWSEGMENT::GetCenter(), DRAWSEGMENT::GetEnd(), DRAWSEGMENT::GetPolyShape(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), DIMENSION::m_crossBarF, DIMENSION::m_crossBarO, DIMENSION::m_featureLineDO, DIMENSION::m_featureLineGO, PCB_DIMENSION_T, PCB_LINE_T, PCB_MODULE_EDGE_T, PCB_MODULE_ZONE_AREA_T, PCB_ZONE_AREA_T, S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_SEGMENT, and EDA_ITEM::Type().


The documentation for this class was generated from the following files: