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)
 
void SetFlags (const STATUS_FLAGS aFlag)
 Function SetFlags sets a status flag on each item in a block selector. More...
 
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 wxPoint GetOrigin () const
 
const wxPoint GetPosition () const
 
const wxPoint GetEnd () const
 
const wxPoint GetCenter () 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 EDA_RECT &aRect, double aRot) const
 Tests for a common area between this rectangle, and a rectangle with arbitrary rotation. More...
 
bool Intersects (const wxPoint &aPoint1, const wxPoint &aPoint2) const
 Function Intersects tests for a common area between a segment and this rectangle. More...
 
const wxPoint ClosestPointTo (const wxPoint &aPoint) const
 Return the point in this rect that is closest to the provided point. More...
 
const wxPoint FarthestPointTo (const wxPoint &aPoint) const
 Return the point in this rect that is farthest from the provided point. More...
 
bool IntersectsCircle (const wxPoint &aCenter, const int aRadius) const
 Function IntersectsCircle tests for a common area between a circle and this rectangle. More...
 
bool IntersectsCircleEdge (const wxPoint &aCenter, const int aRadius, const int aWidth) const
 IntersectsCircleEdge Tests for intersection between this rect and the edge (radius) of a circle. 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 75 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
EDA_RECT()
Definition: eda_rect.h:51
Definition: colors.h:62
BLOCK_SELECTOR::~BLOCK_SELECTOR ( )

Definition at line 51 of file block_commande.cpp.

References ClearListAndDeleteItems().

52 {
54 }
void ClearListAndDeleteItems()
Function ClearListAndDeleteItems deletes only the list of EDA_ITEM * pointers, AND the data printed b...

Member Function Documentation

wxPoint EDA_RECT::Centre ( ) const
inlineinherited

Definition at line 60 of file eda_rect.h.

References EDA_RECT::Contains(), EDA_RECT::Move(), EDA_RECT::Normalize(), wxPoint::x, and wxPoint::y.

Referenced by PCB_EDIT_FRAME::AppendBoardFile(), FOOTPRINT_EDIT_FRAME::BestZoom(), LIB_VIEW_FRAME::BestZoom(), PCB_BASE_FRAME::BestZoom(), GERBVIEW_FRAME::BestZoom(), LIB_EDIT_FRAME::BestZoom(), PCB_EDIT_FRAME::Block_Flip(), PCB_EDIT_FRAME::Block_Rotate(), SCH_FIELD::Draw(), LIB_TEXT::drawGraphic(), BOARD_PRINTOUT_CONTROLLER::DrawPage(), BOARD_NETLIST_UPDATER::estimateComponentInsertionPosition(), AUTOPLACER::field_box_placement(), AUTOPLACER::field_horiz_placement(), GENDRILL_WRITER_BASE::genDrillMapFile(), DRAWSEGMENT::GetCenter(), FOOTPRINT_EDIT_FRAME::HandleBlockEnd(), LIB_EDIT_FRAME::HandleBlockEnd(), SCH_EDIT_FRAME::HandleBlockEnd(), LIB_EDIT_FRAME::HandleBlockPlace(), initializePlotter(), CINFO3D_VISU::InitSettings(), EDA_RECT::Intersects(), SCH_FIELD::IsHorizJustifyFlipped(), SCH_EAGLE_PLUGIN::loadSheet(), LIB_PIN::Matches(), SCH_TEXT::Matches(), SCH_FIELD::Matches(), SCH_SHEET_PIN::Matches(), GERBVIEW_SELECTION_TOOL::MeasureTool(), 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().

61  {
62  return wxPoint( m_Pos.x + ( m_Size.x >> 1 ),
63  m_Pos.y + ( m_Size.y >> 1 ) );
64  }
wxSize m_Size
Definition: eda_rect.h:48
wxPoint m_Pos
Definition: eda_rect.h:47
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 173 of file block_commande.cpp.

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

Referenced by BASE_SCREEN::ClearBlockCommand(), and IsIdle().

174 {
175  if( m_command != BLOCK_IDLE )
176  {
179  ClearItemsList();
180  }
181 }
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 161 of file block_commande.cpp.

References PICKED_ITEMS_LIST::ClearListAndDeleteItems(), and m_items.

Referenced by SCH_EDIT_FRAME::copyBlockItems(), LIB_EDIT_FRAME::copySelectedItems(), GetMoveVector(), and ~BLOCK_SELECTOR().

162 {
164 }
PICKED_ITEMS_LIST m_items
void ClearListAndDeleteItems()
Function ClearListAndDeleteItems deletes the list of pickers, AND the data pointed by m_PickedItem or...
const wxPoint EDA_RECT::ClosestPointTo ( const wxPoint aPoint) const
inherited

Return the point in this rect that is closest to the provided point.

Definition at line 540 of file base_struct.cpp.

References EDA_RECT::GetBottom(), EDA_RECT::GetLeft(), EDA_RECT::GetRight(), EDA_RECT::GetTop(), max, min, EDA_RECT::Normalize(), wxPoint::x, and wxPoint::y.

Referenced by EDA_RECT::RevertYAxis().

541 {
542  EDA_RECT me( *this );
543 
544  me.Normalize(); // ensure size is >= 0
545 
546  // Determine closest point to the circle centre within this rect
547  int nx = std::max( me.GetLeft(), std::min( aPoint.x, me.GetRight() ) );
548  int ny = std::max( me.GetTop(), std::min( aPoint.y, me.GetBottom() ) );
549 
550  return wxPoint( nx, ny );
551 }
#define max(a, b)
Definition: auxiliary.h:86
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
#define min(a, b)
Definition: auxiliary.h:85
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 714 of file base_struct.cpp.

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

Referenced by calcCommonArea(), DRAWSEGMENT::HitTest(), and EDA_RECT::operator BOX2I().

715 {
716  EDA_RECT r;
717 
718  if( Intersects( aRect ) )
719  {
720  wxPoint originA( std::min( GetOrigin().x, GetEnd().x ),
721  std::min( GetOrigin().y, GetEnd().y ) );
722  wxPoint originB( std::min( aRect.GetOrigin().x, aRect.GetEnd().x ),
723  std::min( aRect.GetOrigin().y, aRect.GetEnd().y ) );
724  wxPoint endA( std::max( GetOrigin().x, GetEnd().x ),
725  std::max( GetOrigin().y, GetEnd().y ) );
726  wxPoint endB( std::max( aRect.GetOrigin().x, aRect.GetEnd().x ),
727  std::max( aRect.GetOrigin().y, aRect.GetEnd().y ) );
728 
729  r.SetOrigin( wxPoint( std::max( originA.x, originB.x ), std::max( originA.y, originB.y ) ) );
730  r.SetEnd ( wxPoint( std::min( endA.x, endB.x ), std::min( endA.y, endB.y ) ) );
731  }
732 
733  return r;
734 }
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
void SetEnd(int x, int y)
Definition: eda_rect.h:134
const wxPoint GetEnd() const
Definition: eda_rect.h:114
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.
Definition: eda_rect.h:44
#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 354 of file base_struct.cpp.

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

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

355 {
356  wxPoint rel_pos = aPoint - m_Pos;
357  wxSize size = m_Size;
358 
359  if( size.x < 0 )
360  {
361  size.x = -size.x;
362  rel_pos.x += size.x;
363  }
364 
365  if( size.y < 0 )
366  {
367  size.y = -size.y;
368  rel_pos.y += size.y;
369  }
370 
371  return (rel_pos.x >= 0) && (rel_pos.y >= 0) && ( rel_pos.y <= size.y) && ( rel_pos.x <= size.x);
372 }
wxSize m_Size
Definition: eda_rect.h:48
wxPoint m_Pos
Definition: eda_rect.h:47
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 92 of file eda_rect.h.

References EDA_RECT::Contains().

Referenced by EDA_RECT::Contains().

92 { 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 375 of file base_struct.cpp.

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

376 {
377  return Contains( aRect.GetOrigin() ) && Contains( aRect.GetEnd() );
378 }
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
bool Contains(const wxPoint &aPoint) const
Function Contains.
const wxPoint GetEnd() const
Definition: eda_rect.h:114
void BLOCK_SELECTOR::Draw ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aOffset,
GR_DRAWMODE  aDrawMode,
COLOR4D  aColor 
)

Definition at line 125 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(), DrawMovingBlockOutlines(), and GetMoveVector().

127 {
128  if( !aDC )
129  return;
130 
131  int w = GetWidth();
132  int h = GetHeight();
133 
134  GRSetDrawMode( aDC, aDrawMode );
135 
136  if( w == 0 || h == 0 )
137  GRLine( aPanel->GetClipBox(), aDC, GetX() + aOffset.x, GetY() + aOffset.y,
138  GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor );
139  else
140  GRRect( aPanel->GetClipBox(), aDC, GetX() + aOffset.x, GetY() + aOffset.y,
141  GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor );
142 }
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:318
int GetHeight() const
Definition: eda_rect.h:118
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1098
EDA_RECT * GetClipBox()
int GetBottom() const
Definition: eda_rect.h:122
int GetRight() const
Definition: eda_rect.h:119
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:380
int GetX() const
Definition: eda_rect.h:109
int GetWidth() const
Definition: eda_rect.h:117
int GetY() const
Definition: eda_rect.h:110
const wxPoint EDA_RECT::FarthestPointTo ( const wxPoint aPoint) const
inherited

Return the point in this rect that is farthest from the provided point.

Definition at line 554 of file base_struct.cpp.

References abs, EDA_RECT::GetBottom(), EDA_RECT::GetLeft(), EDA_RECT::GetRight(), EDA_RECT::GetTop(), max, EDA_RECT::Normalize(), wxPoint::x, and wxPoint::y.

Referenced by EDA_RECT::RevertYAxis().

555 {
556  EDA_RECT me( *this );
557 
558  me.Normalize(); // ensure size is >= 0
559 
560  int fx = std::max( std::abs( aPoint.x - me.GetLeft() ), std::abs( aPoint.x - me.GetRight() ) );
561  int fy = std::max( std::abs( aPoint.y - me.GetTop() ), std::abs( aPoint.y - me.GetBottom() ) );
562 
563  return wxPoint( fx, fy );
564 }
#define abs(a)
Definition: auxiliary.h:84
#define max(a, b)
Definition: auxiliary.h:86
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
double EDA_RECT::GetArea ( ) const
inherited

Function GetArea returns the area of the rectangle.

Returns
The area of the rectangle.

Definition at line 708 of file base_struct.cpp.

Referenced by calcArea(), calcCommonArea(), MODULE::CoverageRatio(), EDA_RECT::operator BOX2I(), SCH_COMPONENT::operator<(), and SELECTION_TOOL::selectable().

709 {
710  return (double) GetWidth() * (double) GetHeight();
711 }
int GetHeight() const
Definition: eda_rect.h:118
int GetWidth() const
Definition: eda_rect.h:117
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 737 of file base_struct.cpp.

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

Referenced by TEXTE_PCB::GetBoundingBox(), TEXTE_MODULE::GetBoundingBox(), D_PAD::GetBoundingBox(), EDA_RECT::operator BOX2I(), and TEXTE_MODULE::ViewBBox().

738 {
739  wxPoint corners[4];
740 
741  // Build the corners list
742  corners[0] = GetOrigin();
743  corners[2] = GetEnd();
744  corners[1].x = corners[0].x;
745  corners[1].y = corners[2].y;
746  corners[3].x = corners[2].x;
747  corners[3].y = corners[0].y;
748 
749  // Rotate all corners, to find the bounding box
750  for( int ii = 0; ii < 4; ii ++ )
751  RotatePoint( &corners[ii], aRotCenter, aAngle );
752 
753  // Find the corners bounding box
754  wxPoint start = corners[0];
755  wxPoint end = corners[0];
756 
757  for( int ii = 1; ii < 4; ii ++ )
758  {
759  start.x = std::min( start.x, corners[ii].x);
760  start.y = std::min( start.y, corners[ii].y);
761  end.x = std::max( end.x, corners[ii].x);
762  end.y = std::max( end.y, corners[ii].y);
763  }
764 
765  EDA_RECT bbox;
766  bbox.SetOrigin( start );
767  bbox.SetEnd( end );
768 
769  return bbox;
770 }
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
void SetEnd(int x, int y)
Definition: eda_rect.h:134
const wxPoint GetEnd() const
Definition: eda_rect.h:114
#define max(a, b)
Definition: auxiliary.h:86
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
#define min(a, b)
Definition: auxiliary.h:85
const wxPoint EDA_RECT::GetCenter ( ) const
inlineinherited

Definition at line 115 of file eda_rect.h.

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

Referenced by DIALOG_EXPORT_STEP::onExportButton().

115 { return wxPoint( m_Pos.x + ( m_Size.x / 2 ), m_Pos.y + ( m_Size.y / 2 ) ); }
wxSize m_Size
Definition: eda_rect.h:48
wxPoint m_Pos
Definition: eda_rect.h:47
COLOR4D BLOCK_SELECTOR::GetColor ( ) const
inline

Definition at line 100 of file block_commande.h.

References m_color.

Referenced by DrawAndSizingBlockOutlines(), and DrawMovingBlockOutlines().

100 { return m_color; }
int EDA_RECT::GetHeight ( ) const
inlineinherited

Definition at line 118 of file eda_rect.h.

Referenced by GERBER_JOBFILE_WRITER::addJSONGeneralSpecs(), AllAreModulesAndReturnSmallestIfSo(), FOOTPRINT_EDIT_FRAME::BestZoom(), LIB_VIEW_FRAME::BestZoom(), PCB_BASE_FRAME::BestZoom(), GERBVIEW_FRAME::BestZoom(), LIB_EDIT_FRAME::BestZoom(), BuildBoardPolygonOutlines(), MODULE::CalculateBoundingBox(), EAGLE_PLUGIN::centerBoard(), ClipAndDrawPoly(), MATRIX_ROUTING_HEAD::ComputeMatrixSize(), DIALOG_EXPORT_SVG::CreateSVGFile(), CreateThermalReliefPadPolygon(), Draw(), DrawAndSizingBlockOutlines(), BOARD_PRINTOUT_CONTROLLER::DrawPage(), DrawPageOnClipboard(), BOARD_NETLIST_UPDATER::estimateComponentInsertionPosition(), AUTOPLACER::field_box_placement(), AUTOPLACER::field_vert_placement(), fillRectList(), GENDRILL_WRITER_BASE::genDrillMapFile(), genPlacementRoutingMatrix(), AUTOPLACER::get_preferred_sides(), PCB_BASE_FRAME::GetBoardBoundingBox(), BOARD::GetFootprint(), SCH_SHEET::GetMinHeight(), D_PAD::HitTest(), CINFO3D_VISU::InitSettings(), EDA_RECT::Intersects(), SCH_EAGLE_PLUGIN::loadSchematic(), DSN::SPECCTRA_DB::makePADSTACK(), moveFootprintsInArea(), EDA_DRAW_PANEL::OnMouseEvent(), DIALOG_LIB_EDIT_PIN::OnPaintShowPanel(), SELECTION_TOOL::pickSmallestComponent(), PlaceCells(), EDA_DRAW_PANEL::RefreshDrawingRect(), DIALOG_RESCUE_EACH::renderPreview(), DIALOG_CHOOSE_COMPONENT::RenderPreview(), BOARD::ReplaceNetlist(), EDA_DRAW_PANEL::SetClipBox(), WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize(), and PCB_EDIT_FRAME::SpreadFootprints().

118 { return m_Size.y; }
wxSize m_Size
Definition: eda_rect.h:48
EDA_ITEM* BLOCK_SELECTOR::GetItem ( unsigned  aIndex)
inline

Definition at line 163 of file block_commande.h.

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

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

164  {
165  if( aIndex < m_items.GetCount() )
166  return m_items.GetPickedItem( aIndex );
167 
168  return NULL;
169  }
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
int EDA_RECT::GetLeft ( ) const
inlineinherited
const wxPoint EDA_RECT::GetPosition ( ) const
inlineinherited
int EDA_RECT::GetSizeMax ( ) const
inlineinherited

GetSizeMax.

Returns
the max size dimension

Definition at line 107 of file eda_rect.h.

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

107 { return ( m_Size.x > m_Size.y )?m_Size.x:m_Size.y; }
wxSize m_Size
Definition: eda_rect.h:48
int EDA_RECT::GetTop ( ) const
inlineinherited
int EDA_RECT::GetWidth ( ) const
inlineinherited

Definition at line 117 of file eda_rect.h.

Referenced by GERBER_JOBFILE_WRITER::addJSONGeneralSpecs(), AllAreModulesAndReturnSmallestIfSo(), FOOTPRINT_EDIT_FRAME::BestZoom(), LIB_VIEW_FRAME::BestZoom(), PCB_BASE_FRAME::BestZoom(), GERBVIEW_FRAME::BestZoom(), LIB_EDIT_FRAME::BestZoom(), PCB_EDIT_FRAME::Block_SelectItems(), BuildBoardPolygonOutlines(), MODULE::CalculateBoundingBox(), EAGLE_PLUGIN::centerBoard(), ClipAndDrawPoly(), MATRIX_ROUTING_HEAD::ComputeMatrixSize(), DIALOG_EXPORT_SVG::CreateSVGFile(), CreateThermalReliefPadPolygon(), Draw(), DrawAndSizingBlockOutlines(), BOARD_PRINTOUT_CONTROLLER::DrawPage(), DrawPageOnClipboard(), BOARD_NETLIST_UPDATER::estimateComponentInsertionPosition(), AUTOPLACER::field_box_placement(), fillRectList(), GENDRILL_WRITER_BASE::genDrillMapFile(), genPlacementRoutingMatrix(), AUTOPLACER::get_preferred_sides(), PCB_BASE_FRAME::GetBoardBoundingBox(), BOARD::GetFootprint(), SCH_SHEET::GetMinWidth(), EDA_TEXT::GetTextBox(), D_PAD::HitTest(), CINFO3D_VISU::InitSettings(), EDA_RECT::Intersects(), SCH_EAGLE_PLUGIN::loadSchematic(), DSN::SPECCTRA_DB::makePADSTACK(), moveFootprintsInArea(), EDA_DRAW_PANEL::OnMouseEvent(), DIALOG_LIB_EDIT_PIN::OnPaintShowPanel(), SELECTION_TOOL::pickSmallestComponent(), PlaceCells(), EDA_DRAW_PANEL::RefreshDrawingRect(), DIALOG_RESCUE_EACH::renderPreview(), DIALOG_CHOOSE_COMPONENT::RenderPreview(), BOARD::ReplaceNetlist(), EDA_DRAW_PANEL::SetClipBox(), WORKSHEET_DATAITEM_TEXT::SetConstrainedTextSize(), PCB_EDIT_FRAME::SpreadFootprints(), and GERBER_DRAW_ITEM::ViewGetLOD().

117 { return m_Size.x; }
wxSize m_Size
Definition: eda_rect.h:48
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 609 of file base_struct.cpp.

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

610 {
611  if( m_Size.x >= 0 )
612  {
613  if( m_Size.x < -2 * dx )
614  {
615  // Don't allow deflate to eat more width than we have,
616  m_Pos.x += m_Size.x / 2;
617  m_Size.x = 0;
618  }
619  else
620  {
621  // The inflate is valid.
622  m_Pos.x -= dx;
623  m_Size.x += 2 * dx;
624  }
625  }
626  else // size.x < 0:
627  {
628  if( m_Size.x > -2 * dx )
629  {
630  // Don't allow deflate to eat more width than we have,
631  m_Pos.x -= m_Size.x / 2;
632  m_Size.x = 0;
633  }
634  else
635  {
636  // The inflate is valid.
637  m_Pos.x += dx;
638  m_Size.x -= 2 * dx; // m_Size.x <0: inflate when dx > 0
639  }
640  }
641 
642  if( m_Size.y >= 0 )
643  {
644  if( m_Size.y < -2 * dy )
645  {
646  // Don't allow deflate to eat more height than we have,
647  m_Pos.y += m_Size.y / 2;
648  m_Size.y = 0;
649  }
650  else
651  {
652  // The inflate is valid.
653  m_Pos.y -= dy;
654  m_Size.y += 2 * dy;
655  }
656  }
657  else // size.y < 0:
658  {
659  if( m_Size.y > 2 * dy )
660  {
661  // Don't allow deflate to eat more height than we have,
662  m_Pos.y -= m_Size.y / 2;
663  m_Size.y = 0;
664  }
665  else
666  {
667  // The inflate is valid.
668  m_Pos.y += dy;
669  m_Size.y -= 2 * dy; // m_Size.y <0: inflate when dy > 0
670  }
671  }
672 
673  return *this;
674 }
wxSize m_Size
Definition: eda_rect.h:48
wxPoint m_Pos
Definition: eda_rect.h:47
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 602 of file base_struct.cpp.

603 {
604  Inflate( aDelta, aDelta );
605  return *this;
606 }
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 145 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 GetMoveVector(), and EDA_DRAW_FRAME::HandleBlockBegin().

146 {
148  SetOrigin( startpos );
149  SetSize( wxSize( 0, 0 ) );
151  aPanel->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand );
152 }
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
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)
Definition: eda_rect.h:126
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 407 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_FILLER::buildZoneFeatureHoleList(), AUTOPLACER::filtered_colliders(), PCB_TARGET::HitTest(), SCH_JUNCTION::HitTest(), SCH_NO_CONNECT::HitTest(), SCH_BUS_ENTRY_BASE::HitTest(), SCH_BITMAP::HitTest(), WS_DRAW_ITEM_LINE::HitTest(), SCH_LINE::HitTest(), SCH_FIELD::HitTest(), SCH_TEXT::HitTest(), DRAWSEGMENT::HitTest(), DIMENSION::HitTest(), TRACK::HitTest(), WS_DRAW_ITEM_POLYGON::HitTest(), WS_DRAW_ITEM_RECT::HitTest(), ZONE_CONTAINER::HitTest(), WS_DRAW_ITEM_BITMAP::HitTest(), MODULE::HitTest(), SCH_SHEET::HitTest(), SCH_COMPONENT::HitTest(), D_PAD::HitTest(), LIB_TEXT::Inside(), LIB_FIELD::Inside(), EDA_RECT::RevertYAxis(), TEXTE_MODULE::TextHitTest(), and EDA_TEXT::TextHitTest().

408 {
409  // this logic taken from wxWidgets' geometry.cpp file:
410  bool rc;
411  EDA_RECT me(*this);
412  EDA_RECT rect(aRect);
413  me.Normalize(); // ensure size is >= 0
414  rect.Normalize(); // ensure size is >= 0
415 
416  // calculate the left common area coordinate:
417  int left = std::max( me.m_Pos.x, rect.m_Pos.x );
418  // calculate the right common area coordinate:
419  int right = std::min( me.m_Pos.x + me.m_Size.x, rect.m_Pos.x + rect.m_Size.x );
420  // calculate the upper common area coordinate:
421  int top = std::max( me.m_Pos.y, aRect.m_Pos.y );
422  // calculate the lower common area coordinate:
423  int bottom = std::min( me.m_Pos.y + me.m_Size.y, rect.m_Pos.y + rect.m_Size.y );
424 
425  // if a common area exists, it must have a positive (null accepted) size
426  if( left <= right && top <= bottom )
427  rc = true;
428  else
429  rc = false;
430 
431  return rc;
432 }
#define max(a, b)
Definition: auxiliary.h:86
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
wxPoint m_Pos
Definition: eda_rect.h:47
#define min(a, b)
Definition: auxiliary.h:85
bool EDA_RECT::Intersects ( const EDA_RECT aRect,
double  aRot 
) const
inherited

Tests for a common area between this rectangle, and a rectangle with arbitrary rotation.

Parameters
aRecta rectangle to test intersection with
aRotrectangle rotation (in 1/10 degrees)

Definition at line 435 of file base_struct.cpp.

References EDA_RECT::Centre(), EDA_RECT::Contains(), delta, EDA_RECT::GetHeight(), EDA_RECT::GetWidth(), i, EDA_RECT::Inflate(), RotatePoint(), and EDA_RECT::SetOrigin().

436 {
437  /* Most rectangles will be axis aligned.
438  * It is quicker to check for this case and pass the rect
439  * to the simpler intersection test
440  */
441 
442  // Prevent floating point comparison errors
443  static const double ROT_EPS = 0.000000001;
444 
445  static const double ROT_PARALLEL[] = { -3600, -1800, 0, 1800, 3600 };
446  static const double ROT_PERPENDICULAR[] = { -2700, -900, 0, 900, 2700 };
447 
448  NORMALIZE_ANGLE_POS<double>( aRot );
449 
450  // Test for non-rotated rectangle
451  for( int ii = 0; ii < 5; ii++ )
452  {
453  if( std::fabs( aRot - ROT_PARALLEL[ii] ) < ROT_EPS )
454  {
455  return Intersects( aRect );
456  }
457  }
458 
459  // Test for rectangle rotated by multiple of 90 degrees
460  for( int jj = 0; jj < 4; jj++ )
461  {
462  if( std::fabs( aRot - ROT_PERPENDICULAR[jj] ) < ROT_EPS )
463  {
464  EDA_RECT rotRect;
465 
466  // Rotate the supplied rect by 90 degrees
467  rotRect.SetOrigin( aRect.Centre() );
468  rotRect.Inflate( aRect.GetHeight(), aRect.GetWidth() );
469  return Intersects( rotRect );
470  }
471  }
472 
473  /* There is some non-orthogonal rotation.
474  * There are three cases to test:
475  * A) One point of this rect is inside the rotated rect
476  * B) One point of the rotated rect is inside this rect
477  * C) One of the sides of the rotated rect intersect this
478  */
479 
480  wxPoint corners[4];
481 
482  /* Test A : Any corners exist in rotated rect? */
483 
484  corners[0] = m_Pos;
485  corners[1] = m_Pos + wxPoint( m_Size.x, 0 );
486  corners[2] = m_Pos + wxPoint( m_Size.x, m_Size.y );
487  corners[3] = m_Pos + wxPoint( 0, m_Size.y );
488 
489  wxPoint rCentre = aRect.Centre();
490 
491  for( int i = 0; i < 4; i++ )
492  {
493  wxPoint delta = corners[i] - rCentre;
494  RotatePoint( &delta, -aRot );
495  delta += rCentre;
496 
497  if( aRect.Contains( delta ) )
498  {
499  return true;
500  }
501  }
502 
503  /* Test B : Any corners of rotated rect exist in this one? */
504  int w = aRect.GetWidth() / 2;
505  int h = aRect.GetHeight() / 2;
506 
507  // Construct corners around center of shape
508  corners[0] = wxPoint( -w, -h );
509  corners[1] = wxPoint( w, -h );
510  corners[2] = wxPoint( w, h );
511  corners[3] = wxPoint( -w, h );
512 
513  // Rotate and test each corner
514  for( int j=0; j<4; j++ )
515  {
516  RotatePoint( &corners[j], aRot );
517  corners[j] += rCentre;
518 
519  if( Contains( corners[j] ) )
520  {
521  return true;
522  }
523  }
524 
525  /* Test C : Any sides of rotated rect intersect this */
526 
527  if( Intersects( corners[0], corners[1] ) ||
528  Intersects( corners[1], corners[2] ) ||
529  Intersects( corners[2], corners[3] ) ||
530  Intersects( corners[3], corners[0] ) )
531  {
532  return true;
533  }
534 
535 
536  return false;
537 }
bool Contains(const wxPoint &aPoint) const
Function Contains.
int GetHeight() const
Definition: eda_rect.h:118
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
static const int delta[8][2]
Definition: solve.cpp:112
wxSize m_Size
Definition: eda_rect.h:48
wxPoint Centre() const
Definition: eda_rect.h:60
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
size_t i
Definition: json11.cpp:597
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
wxPoint m_Pos
Definition: eda_rect.h:47
int GetWidth() const
Definition: eda_rect.h:117
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
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 381 of file base_struct.cpp.

References SegmentIntersectsSegment(), wxPoint::x, and wxPoint::y.

382 {
383  wxPoint point2, point4;
384 
385  if( Contains( aPoint1 ) || Contains( aPoint2 ) )
386  return true;
387 
388  point2.x = GetEnd().x;
389  point2.y = GetOrigin().y;
390  point4.x = GetOrigin().x;
391  point4.y = GetEnd().y;
392 
393  //Only need to test 3 sides since a straight line cant enter and exit on same side
394  if( SegmentIntersectsSegment( aPoint1, aPoint2, GetOrigin() , point2 ) )
395  return true;
396 
397  if( SegmentIntersectsSegment( aPoint1, aPoint2, point2 , GetEnd() ) )
398  return true;
399 
400  if( SegmentIntersectsSegment( aPoint1, aPoint2, GetEnd() , point4 ) )
401  return true;
402 
403  return false;
404 }
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
bool Contains(const wxPoint &aPoint) const
Function Contains.
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
Definition: eda_rect.h:114
bool EDA_RECT::IntersectsCircle ( const wxPoint aCenter,
const int  aRadius 
) const
inherited

Function IntersectsCircle tests for a common area between a circle and this rectangle.

Parameters
aCentercenter of the circle
aRadiusradius of the circle

Definition at line 567 of file base_struct.cpp.

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

Referenced by VIA::HitTest(), D_PAD::HitTest(), LIB_CIRCLE::Inside(), and EDA_RECT::RevertYAxis().

568 {
569  wxPoint closest = ClosestPointTo( aCenter );
570 
571  double dx = aCenter.x - closest.x;
572  double dy = aCenter.y - closest.y;
573 
574  double r = (double) aRadius;
575 
576  return ( dx * dx + dy * dy ) <= ( r * r );
577 }
const wxPoint ClosestPointTo(const wxPoint &aPoint) const
Return the point in this rect that is closest to the provided point.
bool EDA_RECT::IntersectsCircleEdge ( const wxPoint aCenter,
const int  aRadius,
const int  aWidth 
) const
inherited

IntersectsCircleEdge Tests for intersection between this rect and the edge (radius) of a circle.

Parameters
aCentercenter of the circle
aRadiusradius of the circle
aWidthwidth of the circle edge

Definition at line 580 of file base_struct.cpp.

References EDA_RECT::Normalize(), wxPoint::x, and wxPoint::y.

Referenced by DRAWSEGMENT::HitTest(), and EDA_RECT::RevertYAxis().

581 {
582  EDA_RECT me( *this );
583  me.Normalize(); // ensure size is >= 0
584 
585  // Test if the circle intersects at all
586  if( !IntersectsCircle( aCenter, aRadius + aWidth / 2 ) )
587  {
588  return false;
589  }
590 
591  wxPoint farpt = FarthestPointTo( aCenter );
592  // Farthest point must be further than the inside of the line
593  double fx = (double) farpt.x;
594  double fy = (double) farpt.y;
595 
596  double r = (double) aRadius - (double) aWidth / 2;
597 
598  return ( fx * fx + fy * fy ) > ( r * r );
599 }
bool IntersectsCircle(const wxPoint &aCenter, const int aRadius) const
Function IntersectsCircle tests for a common area between a circle and this rectangle.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const wxPoint FarthestPointTo(const wxPoint &aPoint) const
Return the point in this rect that is farthest from the provided point.
bool BLOCK_SELECTOR::IsDragging ( ) const
inline

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

Definition at line 185 of file block_commande.h.

References BLOCK_DRAG, and BLOCK_DRAG_ITEM.

Referenced by SCH_SCREEN::SelectBlockItems().

186  {
188  }
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 194 of file block_commande.h.

References AbortBlockCurrentCommand(), BLOCK_IDLE, Clear(), and DrawAndSizingBlockOutlines().

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

194 { 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 677 of file base_struct.cpp.

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

Referenced by PCB_EDIT_FRAME::AppendBoardFile(), DRAWSEGMENT::computeArcBBox(), GBR_LAYOUT::ComputeBoundingBox(), BOARD::ComputeBoundingBox(), LIB_PART::GetBodyBoundingBox(), SELECTION::GetBoundingBox(), SCH_COMPONENT::GetBoundingBox(), D_PAD::GetBoundingBox(), MODULE::GetFootprintRect(), getSheetBbox(), LIB_PART::GetUnitBoundingBox(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDA_RECT::operator BOX2I(), and MODULE::ViewBBox().

678 {
679  Normalize(); // ensure width and height >= 0
680  EDA_RECT rect = aRect;
681  rect.Normalize(); // ensure width and height >= 0
682  wxPoint end = GetEnd();
683  wxPoint rect_end = rect.GetEnd();
684 
685  // Change origin and size in order to contain the given rect
686  m_Pos.x = std::min( m_Pos.x, rect.m_Pos.x );
687  m_Pos.y = std::min( m_Pos.y, rect.m_Pos.y );
688  end.x = std::max( end.x, rect_end.x );
689  end.y = std::max( end.y, rect_end.y );
690  SetEnd( end );
691 }
void SetEnd(int x, int y)
Definition: eda_rect.h:134
const wxPoint GetEnd() const
Definition: eda_rect.h:114
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.
Definition: eda_rect.h:44
wxPoint m_Pos
Definition: eda_rect.h:47
#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 694 of file base_struct.cpp.

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

695 {
696  Normalize(); // ensure width and height >= 0
697 
698  wxPoint end = GetEnd();
699  // Change origin and size in order to contain the given rect
700  m_Pos.x = std::min( m_Pos.x, aPoint.x );
701  m_Pos.y = std::min( m_Pos.y, aPoint.y );
702  end.x = std::max( end.x, aPoint.x );
703  end.y = std::max( end.y, aPoint.y );
704  SetEnd( end );
705 }
void SetEnd(int x, int y)
Definition: eda_rect.h:134
const wxPoint GetEnd() const
Definition: eda_rect.h:114
void Normalize()
Function Normalize ensures that the height ant width are positive.
#define max(a, b)
Definition: auxiliary.h:86
wxPoint m_Pos
Definition: eda_rect.h:47
#define min(a, b)
Definition: auxiliary.h:85
void EDA_RECT::Normalize ( )
inherited

Function Normalize ensures that the height ant width are positive.

Definition at line 332 of file base_struct.cpp.

Referenced by PL_EDITOR_FRAME::Block_Move(), GERBVIEW_FRAME::Block_Move(), PCB_EDIT_FRAME::Block_SelectItems(), EDA_RECT::Centre(), EDA_RECT::ClosestPointTo(), GBR_LAYOUT::ComputeBoundingBox(), EDA_RECT::FarthestPointTo(), SCH_BUS_ENTRY_BASE::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), LIB_PIN::GetBoundingBox(), DRAWSEGMENT::GetBoundingBox(), DIMENSION::GetBoundingBox(), GERBER_DRAW_ITEM::GetBoundingBox(), SCH_LABEL::GetBoundingBox(), SCH_GLOBALLABEL::GetBoundingBox(), SCH_HIERLABEL::GetBoundingBox(), EDA_TEXT::GetTextBox(), DRAWSEGMENT::HitTest(), ZONE_CONTAINER::HitTest(), D_PAD::HitTest(), EDA_RECT::Intersects(), EDA_RECT::IntersectsCircleEdge(), EDA_RECT::Merge(), EDA_RECT::operator BOX2I(), EDA_RECT::operator wxRect(), SVG_PLOTTER::Rect(), EDA_RECT::RevertYAxis(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SCH_SCREEN::UpdatePickList(), and EDA_DRAW_FRAME::Window_Zoom().

333 {
334  if( m_Size.y < 0 )
335  {
336  m_Size.y = -m_Size.y;
337  m_Pos.y -= m_Size.y;
338  }
339 
340  if( m_Size.x < 0 )
341  {
342  m_Size.x = -m_Size.x;
343  m_Pos.x -= m_Size.x;
344  }
345 }
wxSize m_Size
Definition: eda_rect.h:48
wxPoint m_Pos
Definition: eda_rect.h:47
void EDA_RECT::Offset ( int  dx,
int  dy 
)
inlineinherited

Definition at line 128 of file eda_rect.h.

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

Referenced by SCH_COMPONENT::GetBodyBoundingBox().

128 { m_Pos.x += dx; m_Pos.y += dy; }
wxPoint m_Pos
Definition: eda_rect.h:47
void EDA_RECT::Offset ( const wxPoint offset)
inlineinherited

Definition at line 129 of file eda_rect.h.

129 { m_Pos += offset; }
wxPoint m_Pos
Definition: eda_rect.h:47
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 228 of file eda_rect.h.

References EDA_RECT::Common(), EDA_RECT::GetArea(), EDA_RECT::GetBoundingBoxRotated(), EDA_RECT::GetOrigin(), EDA_RECT::GetSize(), EDA_RECT::Inflate(), EDA_RECT::Merge(), and EDA_RECT::Normalize().

229  {
230  EDA_RECT rect( m_Pos, m_Size );
231  rect.Normalize();
232  return BOX2I( rect.GetOrigin(), rect.GetSize() );
233  }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:502
wxSize m_Size
Definition: eda_rect.h:48
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
wxPoint m_Pos
Definition: eda_rect.h:47
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 216 of file eda_rect.h.

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

217  {
218  EDA_RECT rect( m_Pos, m_Size );
219  rect.Normalize();
220  return wxRect( rect.m_Pos, rect.m_Size );
221  }
wxSize m_Size
Definition: eda_rect.h:48
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
wxPoint m_Pos
Definition: eda_rect.h:47
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 167 of file block_commande.cpp.

References m_items, and PICKED_ITEMS_LIST::PushItem().

Referenced by SCH_EDIT_FRAME::copyBlockItems(), LIB_EDIT_FRAME::copySelectedItems(), GetMoveVector(), SCH_EDIT_FRAME::HandleBlockEnd(), LIB_EDIT_FRAME::OnOrient(), and SCH_SCREEN::UpdatePickList().

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

Definition at line 98 of file block_commande.h.

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

Definition at line 135 of file eda_rect.h.

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

136  {
137  m_Size.x = pos.x - m_Pos.x; m_Size.y = pos.y - m_Pos.y;
138  }
wxSize m_Size
Definition: eda_rect.h:48
wxPoint m_Pos
Definition: eda_rect.h:47
void BLOCK_SELECTOR::SetFlags ( const STATUS_FLAGS  aFlag)
inline

Function SetFlags sets a status flag on each item in a block selector.

Definition at line 175 of file block_commande.h.

References PICKED_ITEMS_LIST::GetCount(), PICKED_ITEMS_LIST::GetPickedItem(), i, and EDA_ITEM::SetFlags().

Referenced by SCH_EDIT_FRAME::HandleBlockEnd().

176  {
177  for( unsigned i = 0; i < m_items.GetCount(); i++ )
178  m_items.GetPickedItem( i )->SetFlags( aFlag );
179  }
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
unsigned GetCount() const
Function GetCount.
PICKED_ITEMS_LIST m_items
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
size_t i
Definition: json11.cpp:597
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 108 of file block_commande.h.

Referenced by PCB_EDIT_FRAME::AppendBoardFile(), LIB_EDIT_FRAME::copySelectedItems(), DrawAndSizingBlockOutlines(), PCB_BASE_EDIT_FRAME::duplicateItem(), EDA_DRAW_FRAME::HandleBlockBegin(), LIB_EDIT_FRAME::InitBlockPasteInfos(), and LIB_EDIT_FRAME::OnOrient().

108 { 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 57 of file block_commande.cpp.

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

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

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

Definition at line 112 of file block_commande.h.

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

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

Definition at line 125 of file eda_rect.h.

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

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

Definition at line 127 of file eda_rect.h.

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

Member Data Documentation

COLOR4D BLOCK_SELECTOR::m_color
private

Definition at line 80 of file block_commande.h.

Referenced by BLOCK_SELECTOR(), and GetColor().

BLOCK_COMMAND_T BLOCK_SELECTOR::m_command
private

Definition at line 78 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 82 of file block_commande.h.

Referenced by GetLastCursorPosition().

wxPoint BLOCK_SELECTOR::m_moveVector
private

Definition at line 81 of file block_commande.h.

Referenced by GetMoveVector().

BLOCK_STATE_T BLOCK_SELECTOR::m_state
private

Definition at line 77 of file block_commande.h.

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


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