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)
 

Private Member Functions

 EDIT_POINTS_FACTORY ()
 
 EDIT_POINTS_FACTORY ()
 

Detailed Description

Definition at line 68 of file ee_point_editor.cpp.

Constructor & Destructor Documentation

◆ EDIT_POINTS_FACTORY() [1/2]

EDIT_POINTS_FACTORY::EDIT_POINTS_FACTORY ( )
inlineprivate

Definition at line 199 of file ee_point_editor.cpp.

199 {};

◆ EDIT_POINTS_FACTORY() [2/2]

EDIT_POINTS_FACTORY::EDIT_POINTS_FACTORY ( )
inlineprivate

Definition at line 100 of file pl_point_editor.cpp.

100 {};

Member Function Documentation

◆ Make() [1/2]

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

Definition at line 62 of file pl_point_editor.cpp.

63  {
64  std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
65 
66  if( !aItem )
67  return points;
68 
69  // Generate list of edit points based on the item type
70  switch( aItem->Type() )
71  {
72  case WSG_LINE_T:
73  {
74  DS_DRAW_ITEM_LINE* line = static_cast<DS_DRAW_ITEM_LINE*>( aItem );
75  points->AddPoint( line->GetStart() );
76  points->AddPoint( line->GetEnd() );
77  break;
78  }
79  case WSG_RECT_T:
80  {
81  DS_DRAW_ITEM_RECT* rect = static_cast<DS_DRAW_ITEM_RECT*>( aItem );
82  wxPoint topLeft = rect->GetStart();
83  wxPoint botRight = rect->GetEnd();
84 
85  points->AddPoint( (VECTOR2I) topLeft );
86  points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) );
87  points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) );
88  points->AddPoint( (VECTOR2I) botRight );
89  break;
90  }
91  default:
92  points.reset();
93  break;
94  }
95 
96  return points;
97  }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
const wxPoint & GetStart() const
Definition: ds_draw_item.h:133
const wxPoint & GetStart() const
Definition: ds_draw_item.h:219
Non filled rectangle with thick segment.
Definition: ds_draw_item.h:205
const wxPoint & GetEnd() const
Definition: ds_draw_item.h:221
const wxPoint & GetEnd() const
Definition: ds_draw_item.h:135
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:163

References DS_DRAW_ITEM_LINE::GetEnd(), DS_DRAW_ITEM_RECT::GetEnd(), DS_DRAW_ITEM_LINE::GetStart(), DS_DRAW_ITEM_RECT::GetStart(), EDA_ITEM::Type(), WSG_LINE_T, WSG_RECT_T, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Make() [2/2]

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

Definition at line 71 of file ee_point_editor.cpp.

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

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(), EDA_ITEM::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, STARTPOINT, EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), and EE_POINT_EDITOR::updatePoints().


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