KiCad PCB EDA Suite
pl_point_editor.cpp File Reference
#include <functional>
#include <tool/tool_manager.h>
#include <tool/actions.h>
#include <view/view_controls.h>
#include <gal/graphics_abstraction_layer.h>
#include <confirm.h>
#include <bitmaps.h>
#include <status_popup.h>
#include <drawing_sheet/ds_draw_item.h>
#include <drawing_sheet/ds_data_item.h>
#include "pl_editor_frame.h"
#include "pl_point_editor.h"
#include "properties_frame.h"
#include "tools/pl_selection_tool.h"

Go to the source code of this file.

Classes

class  EDIT_POINTS_FACTORY
 

Enumerations

enum  RECTANGLE_POINTS {
  RECT_TOPLEFT, RECT_TOPRIGHT, RECT_BOTLEFT, RECT_BOTRIGHT,
  RECT_TOPLEFT, RECT_TOPRIGHT, RECT_BOTLEFT, RECT_BOTRIGHT
}
 
enum  LINE_POINTS { LINE_START, LINE_END, LINE_START, LINE_END }
 

Functions

void pinEditedCorner (int editedPointIndex, int minWidth, int minHeight, VECTOR2I &topLeft, VECTOR2I &topRight, VECTOR2I &botLeft, VECTOR2I &botRight)
 

Enumeration Type Documentation

◆ LINE_POINTS

Enumerator
LINE_START 
LINE_END 
LINE_START 
LINE_END 

Definition at line 48 of file pl_point_editor.cpp.

◆ RECTANGLE_POINTS

Enumerator
RECT_TOPLEFT 
RECT_TOPRIGHT 
RECT_BOTLEFT 
RECT_BOTRIGHT 
RECT_TOPLEFT 
RECT_TOPRIGHT 
RECT_BOTLEFT 
RECT_BOTRIGHT 

Definition at line 43 of file pl_point_editor.cpp.

Function Documentation

◆ pinEditedCorner()

void pinEditedCorner ( int  editedPointIndex,
int  minWidth,
int  minHeight,
VECTOR2I topLeft,
VECTOR2I topRight,
VECTOR2I botLeft,
VECTOR2I botRight 
)

Definition at line 251 of file pl_point_editor.cpp.

253 {
254  switch( editedPointIndex )
255  {
256  case RECT_TOPLEFT:
257  // pin edited point within opposite corner
258  topLeft.x = std::min( topLeft.x, botRight.x - minWidth );
259  topLeft.y = std::min( topLeft.y, botRight.y - minHeight );
260 
261  // push edited point edges to adjacent corners
262  topRight.y = topLeft.y;
263  botLeft.x = topLeft.x;
264 
265  break;
266 
267  case RECT_TOPRIGHT:
268  // pin edited point within opposite corner
269  topRight.x = std::max( topRight.x, botLeft.x + minWidth );
270  topRight.y = std::min( topRight.y, botLeft.y - minHeight );
271 
272  // push edited point edges to adjacent corners
273  topLeft.y = topRight.y;
274  botRight.x = topRight.x;
275 
276  break;
277 
278  case RECT_BOTLEFT:
279  // pin edited point within opposite corner
280  botLeft.x = std::min( botLeft.x, topRight.x - minWidth );
281  botLeft.y = std::max( botLeft.y, topRight.y + minHeight );
282 
283  // push edited point edges to adjacent corners
284  botRight.y = botLeft.y;
285  topLeft.x = botLeft.x;
286 
287  break;
288 
289  case RECT_BOTRIGHT:
290  // pin edited point within opposite corner
291  botRight.x = std::max( botRight.x, topLeft.x + minWidth );
292  botRight.y = std::max( botRight.y, topLeft.y + minHeight );
293 
294  // push edited point edges to adjacent corners
295  botLeft.y = botRight.y;
296  topRight.x = botRight.x;
297 
298  break;
299  }
300 }

References RECT_BOTLEFT, RECT_BOTRIGHT, RECT_TOPLEFT, RECT_TOPRIGHT, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PL_POINT_EDITOR::updateItem().