KiCad PCB EDA Suite
BLOCK_SELECTOR Class Reference

#include <block_commande.h>

Inheritance diagram for BLOCK_SELECTOR:
EDA_RECT

Public Member Functions

 BLOCK_SELECTOR ()
 
 ~BLOCK_SELECTOR ()
 
void SetState (BLOCK_STATE_T aState)
 
BLOCK_STATE_T GetState () const
 
void SetCommand (BLOCK_COMMAND_T aCommand)
 
BLOCK_COMMAND_T GetCommand () const
 
void SetColor (COLOR4D aColor)
 
COLOR4D GetColor () const
 
void SetLastCursorPosition (const wxPoint &aPosition)
 Function SetLastCursorPosition sets the last cursor position to aPosition. More...
 
wxPoint GetLastCursorPosition () const
 
void SetMoveVector (const wxPoint &aMoveVector)
 
wxPoint GetMoveVector () const
 
void InitData (EDA_DRAW_PANEL *Panel, const wxPoint &startpos)
 Function InitData sets the initial values of a BLOCK_SELECTOR, before starting a block command. More...
 
void SetMessageBlock (EDA_DRAW_FRAME *frame)
 Function SetMessageBlock Displays the type of block command in the status bar of the window. More...
 
void Draw (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor)
 
void PushItem (ITEM_PICKER &aItem)
 Function PushItem adds aItem to the list of items. More...
 
void ClearListAndDeleteItems ()
 Function ClearListAndDeleteItems deletes only the list of EDA_ITEM * pointers, AND the data printed by m_Item. More...
 
void ClearItemsList ()
 Function ClearItemsList clear only the list of EDA_ITEM pointers, it does NOT delete the EDA_ITEM object itself. More...
 
unsigned GetCount () const
 
PICKED_ITEMS_LISTGetItems ()
 
EDA_ITEMGetItem (unsigned aIndex)
 
bool IsDragging () const
 Function IsDragging returns true if the current block command is a drag operation. More...
 
bool IsIdle () const
 Function IsIdle returns true if there is currently no block operation in progress. More...
 
void Clear ()
 Function Clear clears the block selector by setting the command to idle, the state to no block, and clears the selected item list. More...
 
wxPoint Centre () const
 
void Move (const wxPoint &aMoveVector)
 Function Move moves the rectangle by the aMoveVector. More...
 
void Normalize ()
 Function Normalize ensures that the height ant width are positive. More...
 
bool Contains (const wxPoint &aPoint) const
 Function Contains. More...
 
bool Contains (int x, int y) const
 Function Contains. More...
 
bool Contains (const EDA_RECT &aRect) const
 Function Contains. More...
 
const wxSize & GetSize () const
 
int GetSizeMax () const
 GetSizeMax. More...
 
int GetX () const
 
int GetY () const
 
const wxPointGetOrigin () const
 
const wxPointGetPosition () const
 
const wxPoint GetEnd () const
 
int GetWidth () const
 
int GetHeight () const
 
int GetRight () const
 
int GetLeft () const
 
int GetTop () const
 
int GetBottom () const
 
void SetOrigin (const wxPoint &pos)
 
void SetOrigin (int x, int y)
 
void SetSize (const wxSize &size)
 
void SetSize (int w, int h)
 
void Offset (int dx, int dy)
 
void Offset (const wxPoint &offset)
 
void SetX (int val)
 
void SetY (int val)
 
void SetWidth (int val)
 
void SetHeight (int val)
 
void SetEnd (int x, int y)
 
void SetEnd (const wxPoint &pos)
 
void RevertYAxis ()
 Function RevertYAxis Mirror the rectangle from the X axis (negate Y pos and size) More...
 
bool Intersects (const EDA_RECT &aRect) const
 Function Intersects tests for a common area between rectangles. More...
 
bool Intersects (const wxPoint &aPoint1, const wxPoint &aPoint2) const
 Function Intersects tests for a common area between a segment and this rectangle. More...
 
 operator wxRect () const
 Function operator(wxRect) overloads the cast operator to return a wxRect wxRect does not accept negative values for size, so ensure the wxRect size is always >= 0. More...
 
 operator BOX2I () const
 Function operator(BOX2I) overloads the cast operator to return a BOX2I. More...
 
EDA_RECTInflate (wxCoord dx, wxCoord dy)
 Function Inflate inflates the rectangle horizontally by dx and vertically by dy. More...
 
EDA_RECTInflate (int aDelta)
 Function Inflate inflates the rectangle horizontally and vertically by aDelta. More...
 
void Merge (const EDA_RECT &aRect)
 Function Merge modifies the position and size of the rectangle in order to contain aRect. More...
 
void Merge (const wxPoint &aPoint)
 Function Merge modifies the position and size of the rectangle in order to contain the given point. More...
 
double GetArea () const
 Function GetArea returns the area of the rectangle. More...
 
EDA_RECT Common (const EDA_RECT &aRect) const
 Function Common returns the area that is common with another rectangle. More...
 
const EDA_RECT GetBoundingBoxRotated (wxPoint aRotCenter, double aAngle)
 Function GetBoundingBoxRotated. More...
 

Private Attributes

BLOCK_STATE_T m_state
 
BLOCK_COMMAND_T m_command
 
PICKED_ITEMS_LIST m_items
 
COLOR4D m_color
 
wxPoint m_moveVector
 
wxPoint m_lastCursorPosition
 

Detailed Description

Definition at line 74 of file block_commande.h.

Constructor & Destructor Documentation

BLOCK_SELECTOR::BLOCK_SELECTOR ( )

Definition at line 42 of file block_commande.cpp.

References BLOCK_IDLE, BROWN, m_color, m_command, m_state, and STATE_NO_BLOCK.

42  :
43  EDA_RECT()
44 {
45  m_state = STATE_NO_BLOCK; // State (enum BLOCK_STATE_T) of block.
46  m_command = BLOCK_IDLE; // Type (enum BLOCK_COMMAND_T) of operation.
47  m_color = BROWN;
48 }
BLOCK_COMMAND_T m_command
BLOCK_STATE_T m_state
Definition: colors.h:62
BLOCK_SELECTOR::~BLOCK_SELECTOR ( )

Definition at line 51 of file block_commande.cpp.

52 {
53 }

Member Function Documentation

wxPoint EDA_RECT::Centre ( ) const
inlineinherited

Definition at line 57 of file class_eda_rect.h.

References wxPoint::x, and wxPoint::y.

Referenced by PCB_EDIT_FRAME::AppendBoardFile(), LIB_VIEW_FRAME::BestZoom(), PCB_BASE_FRAME::BestZoom(), GERBVIEW_FRAME::BestZoom(), PCB_EDIT_FRAME::Block_Flip(), PCB_EDIT_FRAME::Block_Rotate(), compareX(), compareY(), SCH_FIELD::Draw(), LIB_TEXT::drawGraphic(), BOARD_PRINTOUT_CONTROLLER::DrawPage(), BOARD_NETLIST_UPDATER::estimateComponentInsertionPosition(), AUTOPLACER::field_box_placement(), AUTOPLACER::field_horiz_placement(), EXCELLON_WRITER::GenDrillMapFile(), SELECTION::GetCenter(), DRAWSEGMENT::GetCenter(), FOOTPRINT_EDIT_FRAME::HandleBlockEnd(), LIB_EDIT_FRAME::HandleBlockEnd(), SCH_EDIT_FRAME::HandleBlockEnd(), LIB_EDIT_FRAME::HandleBlockPlace(), initializePlotter(), CINFO3D_VISU::InitSettings(), SCH_FIELD::IsHorizJustifyFlipped(), LIB_PIN::Matches(), SCH_TEXT::Matches(), SCH_FIELD::Matches(), SCH_SHEET_PIN::Matches(), SCH_EDIT_FRAME::MirrorSheet(), PCB_EDIT_FRAME::OnExportIDF3(), DIALOG_LIB_EDIT_PIN::OnPaintShowPanel(), LIB_TEXT::Plot(), SCH_FIELD::Plot(), LIB_FIELD::Plot(), DIALOG_RESCUE_EACH::renderPreview(), DIALOG_CHOOSE_COMPONENT::RenderPreview(), BOARD::ReplaceNetlist(), SCH_EDIT_FRAME::RotateHierarchicalSheet(), and EDA_DRAW_FRAME::Window_Zoom().

58  {
59  return wxPoint( m_Pos.x + ( m_Size.x >> 1 ),
60  m_Pos.y + ( m_Size.y >> 1 ) );
61  }
wxSize m_Size
wxPoint m_Pos
void BLOCK_SELECTOR::Clear ( )

Function Clear clears the block selector by setting the command to idle, the state to no block, and clears the selected item list.

Definition at line 172 of file block_commande.cpp.

References BLOCK_IDLE, ClearItemsList(), m_command, m_state, and STATE_NO_BLOCK.

Referenced by BASE_SCREEN::ClearBlockCommand().

173 {
174  if( m_command != BLOCK_IDLE )
175  {
178  ClearItemsList();
179  }
180 }
BLOCK_COMMAND_T m_command
void ClearItemsList()
Function ClearItemsList clear only the list of EDA_ITEM pointers, it does NOT delete the EDA_ITEM obj...
BLOCK_STATE_T m_state
void BLOCK_SELECTOR::ClearListAndDeleteItems ( )

Function ClearListAndDeleteItems deletes only the list of EDA_ITEM * pointers, AND the data printed by m_Item.

Definition at line 160 of file block_commande.cpp.

References PICKED_ITEMS_LIST::ClearListAndDeleteItems(), and m_items.

Referenced by SCH_EDIT_FRAME::copyBlockItems().

161 {
163 }
PICKED_ITEMS_LIST m_items
void ClearListAndDeleteItems()
Function ClearListAndDeleteItems deletes the list of pickers, AND the data pointed by m_PickedItem or...
EDA_RECT EDA_RECT::Common ( const EDA_RECT aRect) const
inherited

Function Common returns the area that is common with another rectangle.

Parameters
aRectis the rectangle to find the common area with.
Returns
The common area rect or 0-sized rectangle if there is no intersection.

Definition at line 559 of file base_struct.cpp.

References EDA_RECT::GetEnd(), EDA_RECT::GetOrigin(), EDA_RECT::Intersects(), max, min, EDA_RECT::SetEnd(), EDA_RECT::SetOrigin(), point_s::x, wxPoint::x, point_s::y, and wxPoint::y.

Referenced by calcCommonArea().

560 {
561  EDA_RECT r;
562 
563  if( Intersects( aRect ) )
564  {
565  wxPoint originA( std::min( GetOrigin().x, GetEnd().x ),
566  std::min( GetOrigin().y, GetEnd().y ) );
567  wxPoint originB( std::min( aRect.GetOrigin().x, aRect.GetEnd().x ),
568  std::min( aRect.GetOrigin().y, aRect.GetEnd().y ) );
569  wxPoint endA( std::max( GetOrigin().x, GetEnd().x ),
570  std::max( GetOrigin().y, GetEnd().y ) );
571  wxPoint endB( std::max( aRect.GetOrigin().x, aRect.GetEnd().x ),
572  std::max( aRect.GetOrigin().y, aRect.GetEnd().y ) );
573 
574  r.SetOrigin( wxPoint( std::max( originA.x, originB.x ), std::max( originA.y, originB.y ) ) );
575  r.SetEnd ( wxPoint( std::min( endA.x, endB.x ), std::min( endA.y, endB.y ) ) );
576  }
577 
578  return r;
579 }
void SetOrigin(const wxPoint &pos)
const wxPoint & GetOrigin() const
void SetEnd(int x, int y)
const wxPoint GetEnd() const
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
#define max(a, b)
Definition: auxiliary.h:86
Class EDA_RECT handles the component boundary box.
#define min(a, b)
Definition: auxiliary.h:85
bool EDA_RECT::Contains ( const wxPoint aPoint) const
inherited

Function Contains.

Parameters
aPoint= the wxPoint to test
Returns
true if aPoint is inside the boundary box. A point on a edge is seen as inside

Definition at line 355 of file base_struct.cpp.

References EDA_RECT::m_Pos, EDA_RECT::m_Size, wxPoint::x, and wxPoint::y.

Referenced by PCB_EDIT_FRAME::AutoPlaceModule(), compute_Ratsnest_PlaceModule(), EDA_RECT::Contains(), GRPutPixel(), SCH_JUNCTION::HitTest(), PCB_TARGET::HitTest(), SCH_NO_CONNECT::HitTest(), LIB_PIN::HitTest(), SCH_BUS_ENTRY_BASE::HitTest(), SCH_BITMAP::HitTest(), SCH_LINE::HitTest(), TEXTE_MODULE::HitTest(), DRAWSEGMENT::HitTest(), SCH_FIELD::HitTest(), SCH_SHEET_PIN::HitTest(), SCH_TEXT::HitTest(), DIMENSION::HitTest(), TRACK::HitTest(), GERBER_DRAW_ITEM::HitTest(), WS_DRAW_ITEM_BITMAP::HitTest(), MODULE::HitTest(), VIA::HitTest(), SCH_COMPONENT::HitTest(), SCH_SHEET::HitTest(), MARKER_BASE::HitTestMarker(), LIB_BEZIER::Inside(), LIB_CIRCLE::Inside(), LIB_RECTANGLE::Inside(), LIB_POLYLINE::Inside(), LIB_TEXT::Inside(), LIB_ARC::Inside(), LIB_FIELD::Inside(), LIB_PIN::Inside(), EDA_RECT::Intersects(), EDA_DRAW_PANEL::IsPointOnDisplay(), MarkItemsInBloc(), PCB_EDIT_FRAME::SpreadFootprints(), and EDA_TEXT::TextHitTest().

356 {
357  wxPoint rel_pos = aPoint - m_Pos;
358  wxSize size = m_Size;
359 
360  if( size.x < 0 )
361  {
362  size.x = -size.x;
363  rel_pos.x += size.x;
364  }
365 
366  if( size.y < 0 )
367  {
368  size.y = -size.y;
369  rel_pos.y += size.y;
370  }
371 
372  return (rel_pos.x >= 0) && (rel_pos.y >= 0) && ( rel_pos.y <= size.y) && ( rel_pos.x <= size.x);
373 }
wxSize m_Size
wxPoint m_Pos
bool EDA_RECT::Contains ( int  x,
int  y 
) const
inlineinherited

Function Contains.

Parameters
x= the x coordinate of the point to test
y= the x coordinate of the point to test
Returns
true if point is inside the boundary box. A point on a edge is seen as inside

Definition at line 89 of file class_eda_rect.h.

References EDA_RECT::Contains().

Referenced by EDA_RECT::Contains().

89 { return Contains( wxPoint( x, y ) ); }
bool Contains(const wxPoint &aPoint) const
Function Contains.
bool EDA_RECT::Contains ( const EDA_RECT aRect) const
inherited

Function Contains.

Parameters
aRect= the EDA_RECT to test
Returns
true if aRect is Contained. A common edge is seen as contained

Definition at line 379 of file base_struct.cpp.

References EDA_RECT::Contains(), EDA_RECT::GetEnd(), and EDA_RECT::GetOrigin().

380 {
381  return Contains( aRect.GetOrigin() ) && Contains( aRect.GetEnd() );
382 }
bool Contains(const wxPoint &aPoint) const
Function Contains.
const wxPoint & GetOrigin() const
const wxPoint GetEnd() const
void BLOCK_SELECTOR::Draw ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aOffset,
GR_DRAWMODE  aDrawMode,
COLOR4D  aColor 
)

Definition at line 124 of file block_commande.cpp.

References EDA_RECT::GetBottom(), EDA_DRAW_PANEL::GetClipBox(), EDA_RECT::GetHeight(), EDA_RECT::GetRight(), EDA_RECT::GetWidth(), EDA_RECT::GetX(), EDA_RECT::GetY(), GRLine(), GRRect(), GRSetDrawMode(), wxPoint::x, and wxPoint::y.

Referenced by DrawAndSizingBlockOutlines(), drawMovingBlock(), and DrawMovingBlockOutlines().

126 {
127  if( !aDC )
128  return;
129 
130  int w = GetWidth();
131  int h = GetHeight();
132 
133  GRSetDrawMode( aDC, aDrawMode );
134 
135  if( w == 0 || h == 0 )
136  GRLine( aPanel->GetClipBox(), aDC, GetX() + aOffset.x, GetY() + aOffset.y,
137  GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor );
138  else
139  GRRect( aPanel->GetClipBox(), aDC, GetX() + aOffset.x, GetY() + aOffset.y,
140  GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor );
141 }
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:352
int GetHeight() const
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1077
EDA_RECT * GetClipBox()
int GetBottom() const
int GetRight() const
int GetX() const
int GetWidth() const
int GetY() const
double EDA_RECT::GetArea ( ) const
inherited

Function GetArea returns the area of the rectangle.

Returns
The area of the rectangle.

Definition at line 553 of file base_struct.cpp.

References EDA_RECT::GetHeight(), and EDA_RECT::GetWidth().

Referenced by calcArea(), calcCommonArea(), SCH_COMPONENT::operator<(), and MODULE::PadCoverageRatio().

554 {
555  return (double) GetWidth() * (double) GetHeight();
556 }
int GetHeight() const
int GetWidth() const
const EDA_RECT EDA_RECT::GetBoundingBoxRotated ( wxPoint  aRotCenter,
double  aAngle 
)
inherited

Function GetBoundingBoxRotated.

Returns
the bounding box of this, after rotation
Parameters
aAngle= the rotation angle in 0.1 deg.
aRotCenter= the rotation point. useful to calculate bounding box of rotated items, when rotation if not k*90 degrees

Definition at line 584 of file base_struct.cpp.

References EDA_RECT::GetEnd(), EDA_RECT::GetOrigin(), max, min, RotatePoint(), EDA_RECT::SetEnd(), EDA_RECT::SetOrigin(), wxPoint::x, and wxPoint::y.

Referenced by TEXTE_PCB::GetBoundingBox(), TEXTE_MODULE::GetBoundingBox(), and TEXTE_MODULE::ViewBBox().

585 {
586  wxPoint corners[4];
587 
588  // Build the corners list
589  corners[0] = GetOrigin();
590  corners[2] = GetEnd();
591  corners[1].x = corners[0].x;
592  corners[1].y = corners[2].y;
593  corners[3].x = corners[2].x;
594  corners[3].y = corners[0].y;
595 
596  // Rotate all corners, to find the bounding box
597  for( int ii = 0; ii < 4; ii ++ )
598  RotatePoint( &corners[ii], aRotCenter, aAngle );
599 
600  // Find the corners bounding box
601  wxPoint start = corners[0];
602  wxPoint end = corners[0];
603 
604  for( int ii = 1; ii < 4; ii ++ )
605  {
606  start.x = std::min( start.x, corners[ii].x);
607  start.y = std::min( start.y, corners[ii].y);
608  end.x = std::max( end.x, corners[ii].x);
609  end.y = std::max( end.y, corners[ii].y);
610  }
611 
612  EDA_RECT bbox;
613  bbox.SetOrigin( start );
614  bbox.SetEnd( end );
615 
616  return bbox;
617 }
void SetOrigin(const wxPoint &pos)
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
const wxPoint & GetOrigin() const
void SetEnd(int x, int y)
const wxPoint GetEnd() const
#define max(a, b)
Definition: auxiliary.h:86
Class EDA_RECT handles the component boundary box.
#define min(a, b)
Definition: auxiliary.h:85
COLOR4D BLOCK_SELECTOR::GetColor ( ) const
inline

Definition at line 99 of file block_commande.h.

References m_color.

Referenced by DrawAndSizingBlockOutlines(), and DrawMovingBlockOutlines().

99 { return m_color; }
unsigned BLOCK_SELECTOR::GetCount ( ) const
inline
EDA_ITEM* BLOCK_SELECTOR::GetItem ( unsigned  aIndex)
inline

Definition at line 162 of file block_commande.h.

References PICKED_ITEMS_LIST::GetCount(), and PICKED_ITEMS_LIST::GetPickedItem().

Referenced by DrawMovingBlockOutlines(), SCH_EDIT_FRAME::PasteListOfItems(), and SCH_SCREEN::UpdatePickList().

163  {
164  if( aIndex < m_items.GetCount() )
165  return m_items.GetPickedItem( aIndex );
166 
167  return NULL;
168  }
unsigned GetCount() const
Function GetCount.
PICKED_ITEMS_LIST m_items
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
wxPoint BLOCK_SELECTOR::GetLastCursorPosition ( ) const
inline

Definition at line 109 of file block_commande.h.

References m_lastCursorPosition.

Referenced by drawMovingBlock(), DrawMovingBlockOutlines(), and SCH_EDIT_FRAME::HandleBlockEnd().

109 { return m_lastCursorPosition; }
wxPoint m_lastCursorPosition
int EDA_RECT::GetLeft ( ) const
inlineinherited

Definition at line 116 of file class_eda_rect.h.

References wxPoint::x.

Referenced by AUTOPLACER::field_horiz_placement().

116 { return m_Pos.x; }
wxPoint m_Pos
const wxPoint& EDA_RECT::GetPosition ( ) const
inlineinherited
int EDA_RECT::GetSizeMax ( ) const
inlineinherited

GetSizeMax.

Returns
the max size dimension

Definition at line 104 of file class_eda_rect.h.

Referenced by CINFO3D_VISU::AddShapeWithClearanceToContainer(), and CINFO3D_VISU::transformGraphicModuleEdgeToPolygonSet().

104 { return ( m_Size.x > m_Size.y )?m_Size.x:m_Size.y; }
wxSize m_Size
int EDA_RECT::GetTop ( ) const
inlineinherited

Definition at line 117 of file class_eda_rect.h.

References wxPoint::y.

Referenced by AUTOPLACER::DoAutoplace(), and AUTOPLACER::fit_fields_between_wires().

117 { return m_Pos.y; }
wxPoint m_Pos
int EDA_RECT::GetWidth ( void  ) const
inlineinherited
EDA_RECT & EDA_RECT::Inflate ( wxCoord  dx,
wxCoord  dy 
)
inherited

Function Inflate inflates the rectangle horizontally by dx and vertically by dy.

If dx and/or dy is negative the rectangle is deflated.

Definition at line 454 of file base_struct.cpp.

References EDA_RECT::m_Pos, EDA_RECT::m_Size, wxPoint::x, and wxPoint::y.

Referenced by BuildBoardPolygonOutlines(), ZONE_CONTAINER::buildFeatureHoleList(), BuildUnconnectedThermalStubsPolygonList(), FillNegativeKnockout(), genModuleOnRoutingMatrix(), SCH_JUNCTION::GetBoundingBox(), SCH_NO_CONNECT::GetBoundingBox(), LIB_CIRCLE::GetBoundingBox(), LIB_RECTANGLE::GetBoundingBox(), LIB_BEZIER::GetBoundingBox(), LIB_POLYLINE::GetBoundingBox(), SCH_BUS_ENTRY_BASE::GetBoundingBox(), LIB_ARC::GetBoundingBox(), MODULE::GetBoundingBox(), LIB_PIN::GetBoundingBox(), BITMAP_BASE::GetBoundingBox(), DRAWSEGMENT::GetBoundingBox(), GERBER_DRAW_ITEM::GetBoundingBox(), SCH_SHEET::GetBoundingBox(), D_PAD::GetBoundingBox(), MODULE::GetFootprintRect(), GRCSegm(), GRLineArray(), GRSFilledRect(), SCH_JUNCTION::HitTest(), PCB_TARGET::HitTest(), SCH_NO_CONNECT::HitTest(), SCH_BUS_ENTRY_BASE::HitTest(), LIB_PIN::HitTest(), SCH_BITMAP::HitTest(), SCH_LINE::HitTest(), DRAWSEGMENT::HitTest(), SCH_FIELD::HitTest(), SCH_SHEET_PIN::HitTest(), SCH_TEXT::HitTest(), DIMENSION::HitTest(), TRACK::HitTest(), MODULE::HitTest(), VIA::HitTest(), SCH_COMPONENT::HitTest(), SCH_SHEET::HitTest(), EDA_RECT::Inflate(), CINFO3D_VISU::InitSettings(), EDA_DRAW_PANEL::IsPointOnDisplay(), moveBitmap(), SCH_EDIT_FRAME::OnDragItem(), SCH_SCREEN::SelectBlockItems(), PCB_EDIT_FRAME::SpreadFootprints(), EDA_TEXT::TextHitTest(), TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(), TstModuleOnBoard(), TstRectangle(), and WinClipAndDrawLine().

455 {
456  if( m_Size.x >= 0 )
457  {
458  if( m_Size.x < -2 * dx )
459  {
460  // Don't allow deflate to eat more width than we have,
461  m_Pos.x += m_Size.x / 2;
462  m_Size.x = 0;
463  }
464  else
465  {
466  // The inflate is valid.
467  m_Pos.x -= dx;
468  m_Size.x += 2 * dx;
469  }
470  }
471  else // size.x < 0:
472  {
473  if( m_Size.x > -2 * dx )
474  {
475  // Don't allow deflate to eat more width than we have,
476  m_Pos.x -= m_Size.x / 2;
477  m_Size.x = 0;
478  }
479  else
480  {
481  // The inflate is valid.
482  m_Pos.x += dx;
483  m_Size.x -= 2 * dx; // m_Size.x <0: inflate when dx > 0
484  }
485  }
486 
487  if( m_Size.y >= 0 )
488  {
489  if( m_Size.y < -2 * dy )
490  {
491  // Don't allow deflate to eat more height than we have,
492  m_Pos.y += m_Size.y / 2;
493  m_Size.y = 0;
494  }
495  else
496  {
497  // The inflate is valid.
498  m_Pos.y -= dy;
499  m_Size.y += 2 * dy;
500  }
501  }
502  else // size.y < 0:
503  {
504  if( m_Size.y > 2 * dy )
505  {
506  // Don't allow deflate to eat more height than we have,
507  m_Pos.y -= m_Size.y / 2;
508  m_Size.y = 0;
509  }
510  else
511  {
512  // The inflate is valid.
513  m_Pos.y += dy;
514  m_Size.y -= 2 * dy; // m_Size.y <0: inflate when dy > 0
515  }
516  }
517 
518  return *this;
519 }
wxSize m_Size
wxPoint m_Pos
EDA_RECT & EDA_RECT::Inflate ( int  aDelta)
inherited

Function Inflate inflates the rectangle horizontally and vertically by aDelta.

If aDelta is negative the rectangle is deflated.

Definition at line 447 of file base_struct.cpp.

References EDA_RECT::Inflate().

448 {
449  Inflate( aDelta, aDelta );
450  return *this;
451 }
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
void BLOCK_SELECTOR::InitData ( EDA_DRAW_PANEL Panel,
const wxPoint startpos 
)

Function InitData sets the initial values of a BLOCK_SELECTOR, before starting a block command.

Definition at line 144 of file block_commande.cpp.

References AbortBlockCurrentCommand(), PICKED_ITEMS_LIST::ClearItemsList(), DrawAndSizingBlockOutlines(), m_items, m_state, EDA_DRAW_PANEL::SetMouseCapture(), EDA_RECT::SetOrigin(), EDA_RECT::SetSize(), and STATE_BLOCK_INIT.

Referenced by EDA_DRAW_FRAME::HandleBlockBegin().

145 {
147  SetOrigin( startpos );
148  SetSize( wxSize( 0, 0 ) );
150  aPanel->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand );
151 }
void SetOrigin(const wxPoint &pos)
void DrawAndSizingBlockOutlines(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function DrawAndSizingBlockOutlines redraws the outlines of the block which shows the search area for...
void AbortBlockCurrentCommand(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
Function AbortBlockCurrentCommand cancels the current block operation.
PICKED_ITEMS_LIST m_items
void SetSize(const wxSize &size)
BLOCK_STATE_T m_state
void ClearItemsList()
Function ClearItemsList deletes only the list of pickers, NOT the picked data itself.
bool EDA_RECT::Intersects ( const EDA_RECT aRect) const
inherited

Function Intersects tests for a common area between rectangles.

Parameters
aRectA rectangle to test intersection with.
Returns
bool - true if the argument rectangle intersects this rectangle. (i.e. if the 2 rectangles have at least a common point)

Definition at line 419 of file base_struct.cpp.

References EDA_RECT::m_Pos, EDA_RECT::m_Size, max, min, EDA_RECT::Normalize(), wxPoint::x, and wxPoint::y.

Referenced by ZONE_CONTAINER::buildFeatureHoleList(), BuildUnconnectedThermalStubsPolygonList(), EDA_RECT::Common(), AUTOPLACER::filtered_colliders(), PCB_TARGET::HitTest(), SCH_JUNCTION::HitTest(), SCH_NO_CONNECT::HitTest(), SCH_BUS_ENTRY_BASE::HitTest(), SCH_BITMAP::HitTest(), SCH_LINE::HitTest(), WS_DRAW_ITEM_LINE::HitTest(), DRAWSEGMENT::HitTest(), SCH_FIELD::HitTest(), SCH_TEXT::HitTest(), DIMENSION::HitTest(), TRACK::HitTest(), WS_DRAW_ITEM_POLYGON::HitTest(), WS_DRAW_ITEM_RECT::HitTest(), WS_DRAW_ITEM_BITMAP::HitTest(), MODULE::HitTest(), VIA::HitTest(), SCH_COMPONENT::HitTest(), SCH_SHEET::HitTest(), and EDA_TEXT::TextHitTest().

420 {
421  // this logic taken from wxWidgets' geometry.cpp file:
422  bool rc;
423  EDA_RECT me(*this);
424  EDA_RECT rect(aRect);
425  me.Normalize(); // ensure size is >= 0
426  rect.Normalize(); // ensure size is >= 0
427 
428  // calculate the left common area coordinate:
429  int left = std::max( me.m_Pos.x, rect.m_Pos.x );
430  // calculate the right common area coordinate:
431  int right = std::min( me.m_Pos.x + me.m_Size.x, rect.m_Pos.x + rect.m_Size.x );
432  // calculate the upper common area coordinate:
433  int top = std::max( me.m_Pos.y, aRect.m_Pos.y );
434  // calculate the lower common area coordinate:
435  int bottom = std::min( me.m_Pos.y + me.m_Size.y, rect.m_Pos.y + rect.m_Size.y );
436 
437  // if a common area exists, it must have a positive (null accepted) size
438  if( left <= right && top <= bottom )
439  rc = true;
440  else
441  rc = false;
442 
443  return rc;
444 }
#define max(a, b)
Definition: auxiliary.h:86
Class EDA_RECT handles the component boundary box.
wxPoint m_Pos
#define min(a, b)
Definition: auxiliary.h:85
bool EDA_RECT::Intersects ( const wxPoint aPoint1,
const wxPoint aPoint2 
) const
inherited

Function Intersects tests for a common area between a segment and this rectangle.

Parameters
aPoint1First point of the segment to test intersection with.
aPoint2Second point of the segment to test intersection with.
Returns
bool - true if the argument segment intersects this rectangle. (i.e. if the segment and rectangle have at least a common point)

Definition at line 389 of file base_struct.cpp.

References EDA_RECT::Contains(), EDA_RECT::GetEnd(), EDA_RECT::GetOrigin(), SegmentIntersectsSegment(), wxPoint::x, and wxPoint::y.

390 {
391  wxPoint point2, point4;
392 
393  if( Contains( aPoint1 ) || Contains( aPoint2 ) )
394  return true;
395 
396  point2.x = GetEnd().x;
397  point2.y = GetOrigin().y;
398  point4.x = GetOrigin().x;
399  point4.y = GetEnd().y;
400 
401  //Only need to test 3 sides since a straight line cant enter and exit on same side
402  if( SegmentIntersectsSegment( aPoint1, aPoint2, GetOrigin() , point2 ) )
403  return true;
404 
405  if( SegmentIntersectsSegment( aPoint1, aPoint2, point2 , GetEnd() ) )
406  return true;
407 
408  if( SegmentIntersectsSegment( aPoint1, aPoint2, GetEnd() , point4 ) )
409  return true;
410 
411  return false;
412 }
bool Contains(const wxPoint &aPoint) const
Function Contains.
const wxPoint & GetOrigin() const
bool SegmentIntersectsSegment(const wxPoint &a_p1_l1, const wxPoint &a_p2_l1, const wxPoint &a_p1_l2, const wxPoint &a_p2_l2)
Function SegmentIntersectsSegment.
Definition: trigo.cpp:58
const wxPoint GetEnd() const
bool BLOCK_SELECTOR::IsDragging ( ) const
inline

Function IsDragging returns true if the current block command is a drag operation.

Definition at line 174 of file block_commande.h.

References BLOCK_DRAG, and BLOCK_DRAG_ITEM.

Referenced by SCH_SCREEN::SelectBlockItems().

175  {
177  }
BLOCK_COMMAND_T m_command
bool BLOCK_SELECTOR::IsIdle ( ) const
inline

Function IsIdle returns true if there is currently no block operation in progress.

Definition at line 183 of file block_commande.h.

References BLOCK_IDLE.

Referenced by BASE_SCREEN::IsBlockActive(), FOOTPRINT_EDIT_FRAME::OnRightClick(), GERBVIEW_FRAME::OnRightClick(), and PCB_EDIT_FRAME::OnRightClick().

183 { return m_command == BLOCK_IDLE; }
BLOCK_COMMAND_T m_command
void EDA_RECT::Merge ( const EDA_RECT aRect)
inherited

Function Merge modifies the position and size of the rectangle in order to contain aRect.

It is mainly used to calculate bounding boxes.

Parameters
aRectThe rectangle to merge with this rectangle.

Definition at line 522 of file base_struct.cpp.

References EDA_RECT::GetEnd(), EDA_RECT::m_Pos, max, min, EDA_RECT::Normalize(), EDA_RECT::SetEnd(), wxPoint::x, and wxPoint::y.

Referenced by PCB_EDIT_FRAME::AppendBoardFile(), DRAWSEGMENT::computeArcBBox(), GBR_LAYOUT::ComputeBoundingBox(), BOARD::ComputeBoundingBox(), LIB_PART::GetBodyBoundingBox(), MODULE::GetBoundingBox(), SCH_COMPONENT::GetBoundingBox(), SELECTION::GetCenter(), MODULE::GetFootprintRect(), LIB_PART::GetUnitBoundingBox(), and SELECTION::ViewBBox().

523 {
524  Normalize(); // ensure width and height >= 0
525  EDA_RECT rect = aRect;
526  rect.Normalize(); // ensure width and height >= 0
527  wxPoint end = GetEnd();
528  wxPoint rect_end = rect.GetEnd();
529 
530  // Change origin and size in order to contain the given rect
531  m_Pos.x = std::min( m_Pos.x, rect.m_Pos.x );
532  m_Pos.y = std::min( m_Pos.y, rect.m_Pos.y );
533  end.x = std::max( end.x, rect_end.x );
534  end.y = std::max( end.y, rect_end.y );
535  SetEnd( end );
536 }
void SetEnd(int x, int y)
const wxPoint GetEnd() const
void Normalize()
Function Normalize ensures that the height ant width are positive.
#define max(a, b)
Definition: auxiliary.h:86
Class EDA_RECT handles the component boundary box.
wxPoint m_Pos
#define min(a, b)
Definition: auxiliary.h:85
void EDA_RECT::Merge ( const wxPoint aPoint)
inherited

Function Merge modifies the position and size of the rectangle in order to contain the given point.

Parameters
aPointThe point to merge with the rectangle.

Definition at line 539 of file base_struct.cpp.

References EDA_RECT::GetEnd(), EDA_RECT::m_Pos, max, min, EDA_RECT::Normalize(), EDA_RECT::SetEnd(), wxPoint::x, and wxPoint::y.

540 {
541  Normalize(); // ensure width and height >= 0
542 
543  wxPoint end = GetEnd();
544  // Change origin and size in order to contain the given rect
545  m_Pos.x = std::min( m_Pos.x, aPoint.x );
546  m_Pos.y = std::min( m_Pos.y, aPoint.y );
547  end.x = std::max( end.x, aPoint.x );
548  end.y = std::max( end.y, aPoint.y );
549  SetEnd( end );
550 }
void SetEnd(int x, int y)
const wxPoint GetEnd() const
void Normalize()
Function Normalize ensures that the height ant width are positive.
#define max(a, b)
Definition: auxiliary.h:86
wxPoint m_Pos
#define min(a, b)
Definition: auxiliary.h:85
void EDA_RECT::Move ( const wxPoint aMoveVector)
inherited
void EDA_RECT::Offset ( int  dx,
int  dy 
)
inlineinherited

Definition at line 124 of file class_eda_rect.h.

References wxPoint::x, and wxPoint::y.

Referenced by SCH_COMPONENT::GetBodyBoundingBox().

124 { m_Pos.x += dx; m_Pos.y += dy; }
wxPoint m_Pos
void EDA_RECT::Offset ( const wxPoint offset)
inlineinherited

Definition at line 125 of file class_eda_rect.h.

References wxPoint::x, and wxPoint::y.

125  { m_Pos.x += offset.x; m_Pos.y +=
126  offset.y; }
wxPoint m_Pos
EDA_RECT::operator BOX2I ( ) const
inlineinherited

Function operator(BOX2I) overloads the cast operator to return a BOX2I.

Returns
BOX2I - this box shaped as a BOX2I object.

Definition at line 187 of file class_eda_rect.h.

References EDA_RECT::GetEnd(), EDA_RECT::GetPosition(), and EDA_RECT::Normalize().

188  {
189  EDA_RECT rect( m_Pos, m_Size );
190  rect.Normalize();
191  return BOX2I( rect.GetPosition(), rect.GetEnd() );
192  }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:468
wxSize m_Size
Class EDA_RECT handles the component boundary box.
wxPoint m_Pos
EDA_RECT::operator wxRect ( ) const
inlineinherited

Function operator(wxRect) overloads the cast operator to return a wxRect wxRect does not accept negative values for size, so ensure the wxRect size is always >= 0.

Definition at line 175 of file class_eda_rect.h.

References EDA_RECT::m_Pos, EDA_RECT::m_Size, and EDA_RECT::Normalize().

176  {
177  EDA_RECT rect( m_Pos, m_Size );
178  rect.Normalize();
179  return wxRect( rect.m_Pos, rect.m_Size );
180  }
wxSize m_Size
Class EDA_RECT handles the component boundary box.
wxPoint m_Pos
void BLOCK_SELECTOR::PushItem ( ITEM_PICKER aItem)

Function PushItem adds aItem to the list of items.

Parameters
aItem= an ITEM_PICKER to add to the list

Definition at line 166 of file block_commande.cpp.

References m_items, and PICKED_ITEMS_LIST::PushItem().

Referenced by SCH_EDIT_FRAME::copyBlockItems(), SCH_EDIT_FRAME::HandleBlockEnd(), and SCH_SCREEN::UpdatePickList().

167 {
168  m_items.PushItem( aItem );
169 }
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
PICKED_ITEMS_LIST m_items
void EDA_RECT::RevertYAxis ( )
inlineinherited
void BLOCK_SELECTOR::SetColor ( COLOR4D  aColor)
inline

Definition at line 97 of file block_commande.h.

97 { m_color = aColor; }
void EDA_RECT::SetEnd ( const wxPoint pos)
inlineinherited

Definition at line 132 of file class_eda_rect.h.

References wxPoint::x, and wxPoint::y.

133  {
134  m_Size.x = pos.x - m_Pos.x; m_Size.y = pos.y - m_Pos.y;
135  }
wxSize m_Size
wxPoint m_Pos
void EDA_RECT::SetHeight ( int  val)
inlineinherited
void BLOCK_SELECTOR::SetLastCursorPosition ( const wxPoint aPosition)
inline

Function SetLastCursorPosition sets the last cursor position to aPosition.

Parameters
aPositionThe current cursor position.

Definition at line 107 of file block_commande.h.

Referenced by PCB_EDIT_FRAME::AppendBoardFile(), DrawAndSizingBlockOutlines(), PCB_BASE_EDIT_FRAME::duplicateItem(), and EDA_DRAW_FRAME::HandleBlockBegin().

107 { m_lastCursorPosition = aPosition; }
wxPoint m_lastCursorPosition
void BLOCK_SELECTOR::SetMessageBlock ( EDA_DRAW_FRAME frame)

Function SetMessageBlock Displays the type of block command in the status bar of the window.

Definition at line 56 of file block_commande.cpp.

References BLOCK_ABORT, BLOCK_COPY, BLOCK_DELETE, BLOCK_DRAG, BLOCK_DRAG_ITEM, BLOCK_FLIP, BLOCK_IDLE, BLOCK_MIRROR_X, BLOCK_MIRROR_Y, BLOCK_MOVE, BLOCK_MOVE_EXACT, BLOCK_PASTE, BLOCK_PRESELECT_MOVE, BLOCK_ROTATE, BLOCK_SAVE, BLOCK_ZOOM, EDA_DRAW_FRAME::DisplayToolMsg(), and m_command.

Referenced by EDA_DRAW_FRAME::HandleBlockBegin(), LIB_EDIT_FRAME::OnOrient(), SCH_EDIT_FRAME::OnOrient(), SCH_EDIT_FRAME::Process_Special_Functions(), and PCB_EDIT_FRAME::Process_Special_Functions().

57 {
58  wxString msg;
59 
60  switch( m_command )
61  {
62  case BLOCK_IDLE:
63  break;
64 
65  case BLOCK_MOVE: // Move
66  case BLOCK_PRESELECT_MOVE: // Move with preselection list
67  case BLOCK_MOVE_EXACT:
68  msg = _( "Block Move" );
69  break;
70 
71  case BLOCK_DRAG: // Drag
72  msg = _( "Block Drag" );
73  break;
74 
75  case BLOCK_DRAG_ITEM: // Drag
76  msg = _( "Drag item" );
77  break;
78 
79  case BLOCK_COPY: // Copy
80  msg = _( "Block Copy" );
81  break;
82 
83  case BLOCK_DELETE: // Delete
84  msg = _( "Block Delete" );
85  break;
86 
87  case BLOCK_SAVE: // Save
88  msg = _( "Block Save" );
89  break;
90 
91  case BLOCK_PASTE:
92  msg = _( "Block Paste" );
93  break;
94 
95  case BLOCK_ZOOM: // Window Zoom
96  msg = _( "Win Zoom" );
97  break;
98 
99  case BLOCK_ROTATE: // Rotate 90 deg
100  msg = _( "Block Rotate" );
101  break;
102 
103  case BLOCK_FLIP: // Flip
104  msg = _( "Block Flip" );
105  break;
106 
107  case BLOCK_MIRROR_X:
108  case BLOCK_MIRROR_Y: // mirror
109  msg = _( "Block Mirror" );
110  break;
111 
112  case BLOCK_ABORT:
113  break;
114 
115  default:
116  msg = wxT( "???" );
117  break;
118  }
119 
120  frame->DisplayToolMsg( msg );
121 }
BLOCK_COMMAND_T m_command
void DisplayToolMsg(const wxString &msg)
Definition: draw_frame.cpp:497
void BLOCK_SELECTOR::SetMoveVector ( const wxPoint aMoveVector)
inline

Definition at line 111 of file block_commande.h.

Referenced by DrawAndSizingBlockOutlines(), drawMovingBlock(), and DrawMovingBlockOutlines().

111 { m_moveVector = aMoveVector; }
wxPoint m_moveVector
void EDA_RECT::SetOrigin ( int  x,
int  y 
)
inlineinherited

Definition at line 121 of file class_eda_rect.h.

References wxPoint::x, and wxPoint::y.

121 { m_Pos.x = x; m_Pos.y = y; }
wxPoint m_Pos
void EDA_RECT::SetSize ( int  w,
int  h 
)
inlineinherited

Definition at line 123 of file class_eda_rect.h.

123 { m_Size.x = w; m_Size.y = h; }
wxSize m_Size
void EDA_RECT::SetWidth ( int  val)
inlineinherited

Member Data Documentation

COLOR4D BLOCK_SELECTOR::m_color
private

Definition at line 79 of file block_commande.h.

Referenced by BLOCK_SELECTOR(), and GetColor().

BLOCK_COMMAND_T BLOCK_SELECTOR::m_command
private

Definition at line 77 of file block_commande.h.

Referenced by BLOCK_SELECTOR(), Clear(), GetCommand(), and SetMessageBlock().

PICKED_ITEMS_LIST BLOCK_SELECTOR::m_items
private
wxPoint BLOCK_SELECTOR::m_lastCursorPosition
private

Definition at line 81 of file block_commande.h.

Referenced by GetLastCursorPosition().

wxPoint BLOCK_SELECTOR::m_moveVector
private

Definition at line 80 of file block_commande.h.

Referenced by GetMoveVector().

BLOCK_STATE_T BLOCK_SELECTOR::m_state
private

Definition at line 76 of file block_commande.h.

Referenced by BLOCK_SELECTOR(), Clear(), GetState(), and InitData().


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