Eeschema: fix issues in drag command (mainly hotkey command and forgotten wire ends connected to components to drag).

Rename EDA_Rect::Inside to EDA_Rect::Contains ( EDA_Rect::Inside( const EDA_Rect& aRect ) was very ambiguous )
 Fix some Doxygen warnings and erroneous comments; Add comments.
This commit is contained in:
jean-pierre charras 2010-12-20 18:44:25 +01:00
parent 597f67755b
commit 5bab73d638
37 changed files with 196 additions and 168 deletions

View File

@ -4,6 +4,14 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
email address.
2010-dec-20, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
common:
Rename EDA_Rect::Inside to EDA_Rect::Contains
( EDA_Rect::Inside( const EDA_Rect& aRect ) was very ambiguous )
Fix some Doxygen warnings and erroneous comments
2010-Dec-19 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++new:

View File

@ -315,7 +315,7 @@ bool EDA_TextStruct::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
rect.Inflate( aAccuracy );
RotatePoint( &location, m_Pos, -m_Orient );
return rect.Inside( location );
return rect.Contains( location );
}
@ -326,7 +326,7 @@ bool EDA_TextStruct::TextHitTest( const EDA_Rect& aRect, bool aContains, int aAc
rect.Inflate( aAccuracy );
if( aContains )
return rect.Inside( GetTextBox( -1 ) );
return rect.Contains( GetTextBox( -1 ) );
return rect.Intersects( GetTextBox( -1 ) );
}
@ -515,48 +515,59 @@ void EDA_Rect::Move( const wxPoint& aMoveVector )
/* Return TRUE if point is in Rect
* Accept rect size < 0
*/
bool EDA_Rect::Inside( const wxPoint& point ) const
bool EDA_Rect::Contains( const wxPoint& aPoint ) const
{
int rel_posx = point.x - m_Pos.x;
int rel_posy = point.y - m_Pos.y;
wxPoint rel_pos = aPoint - m_Pos;
wxSize size = m_Size;
if( size.x < 0 )
{
size.x = -size.x;
rel_posx += size.x;
rel_pos.x += size.x;
}
if( size.y < 0 )
{
size.y = -size.y;
rel_posy += size.y;
rel_pos.y += size.y;
}
return (rel_posx >= 0) && (rel_posy >= 0) && ( rel_posy <= size.y) && ( rel_posx <= size.x);
return (rel_pos.x >= 0) && (rel_pos.y >= 0) && ( rel_pos.y <= size.y) && ( rel_pos.x <= size.x);
}
bool EDA_Rect::Inside( const EDA_Rect& aRect ) const
/*
* return true if aRect is inside me (or on boundaries)
*/
bool EDA_Rect::Contains( const EDA_Rect& aRect ) const
{
wxRect rect = aRect;
wxRect me = wxRect();
return me.Contains( rect );
return Contains(aRect.GetOrigin() ) && Contains(aRect.GetEnd() );
}
bool EDA_Rect::Intersects( const EDA_Rect aRect ) const
/* Intersects
* test for a common area between 2 rect.
* return true if at least a common point is found
*/
bool EDA_Rect::Intersects( const EDA_Rect& aRect ) const
{
// this logic taken from wxWidgets' geometry.cpp file:
bool rc;
EDA_Rect me(*this);
EDA_Rect rect(aRect);
me.Normalize(); // ensure size is >= 0
rect.Normalize(); // ensure size is >= 0
int left = MAX( m_Pos.x, aRect.m_Pos.x );
int right = MIN( m_Pos.x + m_Size.x, aRect.m_Pos.x + aRect.m_Size.x );
int top = MAX( m_Pos.y, aRect.m_Pos.y );
int bottom = MIN( m_Pos.y + m_Size.y, aRect.m_Pos.y + aRect.m_Size.y );
// calculate the left common area coordinate:
int left = MAX( me.m_Pos.x, rect.m_Pos.x );
// calculate the right common area coordinate:
int right = MIN( me.m_Pos.x + m_Size.x, rect.m_Pos.x + rect.m_Size.x );
// calculate the upper common area coordinate:
int top = MAX( me.m_Pos.y, aRect.m_Pos.y );
// calculate the lower common area coordinate:
int bottom = MIN( me.m_Pos.y + m_Size.y, rect.m_Pos.y + rect.m_Size.y );
if( left < right && top < bottom )
// if a common area exists, it must have a positive (null accepted) size
if( left <= right && top <= bottom )
rc = true;
else
rc = false;

View File

@ -118,7 +118,7 @@ bool MARKER_BASE::HitTestMarker( const wxPoint& refPos ) const
rel_pos.x /= m_ScalingFactor;
rel_pos.y /= m_ScalingFactor;
return m_ShapeBoundingBox.Inside( rel_pos );
return m_ShapeBoundingBox.Contains( rel_pos );
}

View File

@ -251,7 +251,7 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
GetScreen()->Unscale( display_rect.m_Size );
#endif
return display_rect.Inside( ref_pos );
return display_rect.Contains( ref_pos );
}

View File

@ -188,7 +188,7 @@ int GRMapY( int y )
*/
static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 )
{
if( aClipBox->Inside( x1, y1 ) && aClipBox->Inside( x2, y2 ) )
if( aClipBox->Contains( x1, y1 ) && aClipBox->Contains( x2, y2 ) )
return false;
wxRect rect = *aClipBox;
@ -206,7 +206,7 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 )
tmpY2 = y2;
#endif
if( aClipBox->Inside( x1, y1 ) )
if( aClipBox->Contains( x1, y1 ) )
{
if( x1 == x2 ) /* Vertical line, clip Y. */
{
@ -263,7 +263,7 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 )
#endif
return false;
}
else if( aClipBox->Inside( x2, y2 ) )
else if( aClipBox->Contains( x2, y2 ) )
{
if( x1 == x2 ) /* Vertical line, clip Y. */
{
@ -704,7 +704,7 @@ void GRPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int Color )
void GRSPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int Color )
{
if( ClipBox && !ClipBox->Inside( x, y ) )
if( ClipBox && !ClipBox->Contains( x, y ) )
return;
GRSetColorPen( DC, Color );

View File

@ -170,15 +170,14 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound )
}
/**
* Function AddHotkeyName
/* AddHotkeyName
* Add the key name from the Command id value ( m_Idcommand member value)
* @param aText = a wxString. returns aText + key name
* @param aList = pointer to a Ki_HotkeyInfo list of commands
* @param aCommandId = Command Id value
* @param aIsShortCut = true to add <tab><keyname> (active shortcuts in menus)
* aText = a wxString. returns aText + key name
* aList = pointer to a Ki_HotkeyInfo list of commands
* aCommandId = Command Id value
* aIsShortCut = true to add <tab><keyname> (active shortcuts in menus)
* = false to add <spaces><(keyname)>
* @return a wxString (aTest + key name) if key found or aText without modification
* Return a wxString (aTest + key name) if key found or aText without modification
*/
wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList,
int aCommandId, bool aIsShortCut )
@ -200,15 +199,14 @@ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList,
}
/**
* Function AddHotkeyName
/* AddHotkeyName
* Add the key name from the Command id value ( m_Idcommand member value)
* @param aText = a wxString. returns aText + key name
* @param aList = pointer to a Ki_HotkeyInfoSectionDescriptor DescrList of commands
* @param aCommandId = Command Id value
* @param aIsShortCut = true to add <tab><keyname> (active shortcuts in menus)
* aText = a wxString. returns aText + key name
* aList = pointer to a Ki_HotkeyInfoSectionDescriptor DescrList of commands
* aCommandId = Command Id value
* aIsShortCut = true to add <tab><keyname> (active shortcuts in menus)
* = false to add <spaces><(keyname)>
* @return a wxString (aTest + key name) if key found or aText without modification
* Return a wxString (aText + key name) if key found or aText without modification
*/
wxString AddHotkeyName( const wxString& aText,
struct Ki_HotkeyInfoSectionDescriptor* aDescList,
@ -325,13 +323,9 @@ int ReturnKeyCodeFromKeyName( const wxString& keyname )
}
/**
* Function DisplayHotkeyList
/* DisplayHotkeyList
* Displays the current hotkey list
* @param aFrame = current active frame
* @param aList = pointer to a Ki_HotkeyInfoSectionDescriptor list
*(Null terminated)
* @return none
* aList = a Ki_HotkeyInfoSectionDescriptor list(Null terminated)
*/
void DisplayHotkeyList( WinEDA_DrawFrame* aFrame,
struct Ki_HotkeyInfoSectionDescriptor* aDescList )
@ -478,7 +472,6 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile(
return 1;
}
void ReadHotkeyConfig( const wxString& Appname,
struct Ki_HotkeyInfoSectionDescriptor* aDescList )
{
@ -496,11 +489,9 @@ void ReadHotkeyConfig( const wxString& Appname,
ParseHotkeyConfig( data, aDescList );
}
/**
* Function ReadHotkeyConfig
/* Function ReadHotkeyConfig
* Read configuration data and fill the current hotkey list with hotkeys
* @param aDescList = current hotkey list descr. to initialise.
* aDescList is the current hotkey list descr. to initialise.
*/
int WinEDA_BasicFrame::ReadHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aDescList )
{
@ -509,16 +500,14 @@ int WinEDA_BasicFrame::ReadHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor*
}
/**
* Function ParseHotkeyConfig
/* Function ParseHotkeyConfig
* the input format is: shortcut "key" "function"
* lines starting by # are ignored (comments)
* lines like [xxx] are tags (example: [common] or [libedit] which identify
* sections
* lines like [xxx] are tags (example: [common] or [libedit] which identify sections
*/
void ParseHotkeyConfig(
const wxString& data,
struct Ki_HotkeyInfoSectionDescriptor* DescList )
struct Ki_HotkeyInfoSectionDescriptor* aDescList )
{
/* Read the config */
wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK );
@ -536,7 +525,7 @@ void ParseHotkeyConfig(
if( line_type[0] == '[' ) // A tag is found. search infos in list
{
CurrentHotkeyList = 0;
Ki_HotkeyInfoSectionDescriptor* DList = DescList;
Ki_HotkeyInfoSectionDescriptor* DList = aDescList;
for( ; DList->m_HK_InfoList; DList++ )
{
if( *DList->m_SectionTag == line_type )
@ -639,8 +628,7 @@ void WinEDA_BasicFrame::ExportHotkeyConfigToFile(
}
/** add hotkey config options submenu to a menu
* @param menu : root menu
/* add hotkey config options submenu to aMenu
*/
void AddHotkeyConfigMenu( wxMenu* aMenu )
{

View File

@ -37,9 +37,9 @@ void DuplicateItemsInList( SCH_SCREEN* screen,
static void CollectStructsToDrag( SCH_SCREEN* screen );
static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition );
static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aComponent,
wxPoint& aPosition,
bool aSearchFirst );
LIB_PIN* aPin );
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList );
@ -226,6 +226,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
}
if( DrawPanel->ManageCurseur != NULL )
{
switch( block->m_Command )
{
case BLOCK_IDLE:
@ -234,14 +235,14 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */
BreakSegmentOnJunction( GetScreen() );
// fall through
case BLOCK_ROTATE:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
// fall through
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
if( block->GetCount() )
{
@ -301,6 +302,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
case BLOCK_ABORT: /* not executed here */
break;
}
}
if( block->m_Command == BLOCK_ABORT )
{
@ -595,7 +597,8 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
}
/* creates the list of items found when a drag block is initiated.
/* Set in m_BlockLocate.m_ItemsSelection items members .m_Flags to SELECTED
* Creates the list of items found when a drag block is initiated.
* items are those selected in window block an some items outside this area but
* connected to a selected item (connected wires to a component or an entry )
*/
@ -624,14 +627,14 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
/* Remove the displacement of segment and undo the selection. */
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
{
Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetPickedItem( ii );
Struct = (SCH_ITEM*)pickedlist->GetPickedItem( ii );
if( Struct->Type() == SCH_LINE_T )
{
SegmStruct = (SCH_LINE*) Struct;
if( !screen->m_BlockLocate.Inside( SegmStruct->m_Start ) )
if( !screen->m_BlockLocate.Contains( SegmStruct->m_Start ) )
SegmStruct->m_Flags |= STARTPOINT;
if( !screen->m_BlockLocate.Inside( SegmStruct->m_End ) )
if( !screen->m_BlockLocate.Contains( SegmStruct->m_End ) )
SegmStruct->m_Flags |= ENDPOINT;
// Save m_Flags for Undo/redo drag operations:
@ -642,17 +645,16 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
/* Search for other items to drag. They are end wires connected to selected
* items
*/
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
{
Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetPickedItem( ii );
Struct = (SCH_ITEM*)pickedlist->GetPickedItem( ii );
if( ( Struct->Type() == SCH_LABEL_T )
|| ( Struct->Type() == SCH_GLOBAL_LABEL_T )
|| ( Struct->Type() == SCH_HIERARCHICAL_LABEL_T ) )
{
#undef STRUCT
#define STRUCT ( (SCH_TEXT*) Struct )
if( !screen->m_BlockLocate.Inside( STRUCT->m_Pos ) )
if( !screen->m_BlockLocate.Contains( STRUCT->m_Pos ) )
{
AddPickedItem( screen, STRUCT->m_Pos );
}
@ -661,20 +663,20 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
if( Struct->Type() == SCH_COMPONENT_T )
{
// Add all pins of the selected component to list
LIB_PIN* pin;
wxPoint pos;
pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, true );
LIB_PIN* pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, NULL );
while( pin )
{
if( !screen->m_BlockLocate.Inside( pos ) )
if( !screen->m_BlockLocate.Contains( pos ) )
{
// This pin is outside area,
// but because it it the pin of a selected component
// but because it is a pin of a selected component
// we must also select connected items to this pin
// and mainly wires
AddPickedItem( screen, pos );
}
pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, false );
pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, pin );
}
}
@ -774,7 +776,6 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
{
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
Struct->m_Flags &= ~STARTPOINT;
// Save m_Flags for Undo/redo drag operations:
picker.m_PickerFlags = Struct->m_Flags;
pickedlist->PushItem( picker );
@ -783,7 +784,6 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
{
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
Struct->m_Flags &= ~ENDPOINT;
// Save m_Flags for Undo/redo drag operations:
picker.m_PickerFlags = Struct->m_Flags;
pickedlist->PushItem( picker );
@ -856,53 +856,45 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
/** GetNextPinPosition()
* calculate position of the "next" pin of the aDrawLibItem component
* @param aDrawLibItem = component to test.
* @param aComponent = component to test.
* @param aPosition = the calculated pin position, according to the component
* orientation and position
* @param aSearchFirst = if true, search for the first pin
* @return a pointer to the pin
*/
static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aComponent,
wxPoint& aPosition,
bool aSearchFirst )
LIB_PIN* aPin )
{
static LIB_COMPONENT* Entry;
static int Multi, convert;
TRANSFORM transform;
static wxPoint CmpPosition;
static LIB_PIN* Pin;
if( aSearchFirst )
if( aPin == NULL )
{
Entry = CMP_LIBRARY::FindLibraryComponent( aDrawLibItem->GetLibName() );
Entry = CMP_LIBRARY::FindLibraryComponent( aComponent->GetLibName() );
if( Entry == NULL )
return NULL;
Pin = Entry->GetNextPin();
Multi = aDrawLibItem->GetUnit();
convert = aDrawLibItem->GetConvert();
CmpPosition = aDrawLibItem->m_Pos;
transform = aDrawLibItem->GetTransform();
}
else
Pin = Entry->GetNextPin( Pin );
for( ; Pin != NULL; Pin = Entry->GetNextPin( Pin ) )
aPin = Entry->GetNextPin( aPin );
int multi = aComponent->GetUnit();
int convert = aComponent->GetConvert();
for( ; aPin != NULL; aPin = Entry->GetNextPin( aPin ) )
{
wxASSERT( Pin->Type() == LIB_PIN_T );
wxASSERT( aPin->Type() == LIB_PIN_T );
/* Skip items not used for this part */
if( Multi && Pin->GetUnit() && ( Pin->GetUnit() != Multi ) )
if( multi && aPin->GetUnit() && ( aPin->GetUnit() != multi ) )
continue;
if( convert && Pin->GetConvert() && ( Pin->GetConvert() != convert ) )
if( convert && aPin->GetConvert() && ( aPin->GetConvert() != convert ) )
continue;
/* Calculate the pin position (according to the component orientation)
*/
aPosition = DefaultTransform.TransformCoordinate( Pin->GetPosition() ) + CmpPosition;
return Pin;
aPosition = aComponent->GetPinPhysicalPosition( aPin );
return aPin;
}
return NULL;

View File

@ -748,7 +748,12 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
case SCH_LINE_T:
if( ( (SCH_ITEM*) DrawStruct )->GetLayer() == LAYER_WIRE )
{
if( HK_Descr->m_Idcommand == HK_DRAG )
wxPostEvent( this, eventDragWire );
else
wxPostEvent( this, eventMoveItem );
}
break;
default:

View File

@ -263,8 +263,8 @@ void LIB_ARC::DoOffset( const wxPoint& aOffset )
bool LIB_ARC::DoTestInside( EDA_Rect& aRect ) const
{
return aRect.Inside( m_ArcStart.x, -m_ArcStart.y )
|| aRect.Inside( m_ArcEnd.x, -m_ArcEnd.y );
return aRect.Contains( m_ArcStart.x, -m_ArcStart.y )
|| aRect.Contains( m_ArcEnd.x, -m_ArcEnd.y );
}

View File

@ -164,7 +164,7 @@ bool LIB_BEZIER::DoTestInside( EDA_Rect& aRect ) const
{
for( size_t i = 0; i < m_PolyPoints.size(); i++ )
{
if( aRect.Inside( m_PolyPoints[i].x, -m_PolyPoints[i].y ) )
if( aRect.Contains( m_PolyPoints[i].x, -m_PolyPoints[i].y ) )
return true;
}

View File

@ -152,7 +152,7 @@ bool LIB_CIRCLE::DoTestInside( EDA_Rect& aRect ) const
* FIXME: This fails to take into account the radius around the center
* point.
*/
return aRect.Inside( m_Pos.x, -m_Pos.y );
return aRect.Contains( m_Pos.x, -m_Pos.y );
}

View File

@ -466,7 +466,7 @@ bool LIB_FIELD::DoTestInside( EDA_Rect& rect ) const
* FIXME: This fails to take into acount the size and/or orientation of
* the text.
*/
return rect.Inside( m_Pos.x, -m_Pos.y );
return rect.Contains( m_Pos.x, -m_Pos.y );
}

View File

@ -1653,7 +1653,7 @@ bool LIB_PIN::DoTestInside( EDA_Rect& rect ) const
{
wxPoint end = ReturnPinEndPoint();
return rect.Inside( m_position.x, -m_position.y ) || rect.Inside( end.x, -end.y );
return rect.Contains( m_position.x, -m_position.y ) || rect.Contains( end.x, -end.y );
}

View File

@ -162,7 +162,7 @@ bool LIB_POLYLINE::DoTestInside( EDA_Rect& aRect ) const
{
for( size_t i = 0; i < m_PolyPoints.size(); i++ )
{
if( aRect.Inside( m_PolyPoints[i].x, -m_PolyPoints[i].y ) )
if( aRect.Contains( m_PolyPoints[i].x, -m_PolyPoints[i].y ) )
return true;
}

View File

@ -119,7 +119,7 @@ void LIB_RECTANGLE::DoOffset( const wxPoint& aOffset )
bool LIB_RECTANGLE::DoTestInside( EDA_Rect& aRect ) const
{
return aRect.Inside( m_Pos.x, -m_Pos.y ) || aRect.Inside( m_End.x, -m_End.y );
return aRect.Contains( m_Pos.x, -m_Pos.y ) || aRect.Contains( m_End.x, -m_End.y );
}

View File

@ -223,7 +223,7 @@ bool LIB_TEXT::DoTestInside( EDA_Rect& rect ) const
* FIXME: This should calculate the text size and justification and
* use rectangle instect.
*/
return rect.Inside( m_Pos.x, -m_Pos.y );
return rect.Contains( m_Pos.x, -m_Pos.y );
}

View File

@ -139,6 +139,7 @@ int PickItemsInBlock( BLOCK_SELECTOR& aBlock, SCH_SCREEN* aScreen )
for( ; item != NULL; item = item->Next() )
{
// an item is picked if its bounding box intersects the reference area
if( item->HitTest( area ) )
{
/* Put this structure in the picked list: */
@ -310,7 +311,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList )
EDA_Rect BoundaryBox = field->GetBoundingBox();
if( BoundaryBox.Inside( aPosRef ) )
if( BoundaryBox.Contains( aPosRef ) )
{
LastSnappedStruct = field;
return true;
@ -323,7 +324,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList )
#define STRUCT ( (SCH_COMPONENT*) DrawList )
EDA_Rect BoundaryBox = STRUCT->GetBoundingBox();
if( BoundaryBox.Inside( aPosRef ) )
if( BoundaryBox.Contains( aPosRef ) )
{
LastSnappedStruct = DrawList;
return true;

View File

@ -1664,7 +1664,7 @@ bool SCH_COMPONENT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_
bBox = GetField( ii )->GetBoundingBox();
bBox.Inflate( aAccuracy );
if( bBox.Inside( aPoint ) )
if( bBox.Contains( aPoint ) )
return true;
}
}
@ -1674,7 +1674,7 @@ bool SCH_COMPONENT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_
bBox = GetBodyBoundingBox();
bBox.Inflate( aAccuracy );
if( bBox.Inside( aPoint ) )
if( bBox.Contains( aPoint ) )
return true;
}
@ -1689,7 +1689,7 @@ bool SCH_COMPONENT::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccu
rect.Inflate( aAccuracy );
if( aContained )
return rect.Inside( GetBoundingBox() );
return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}

View File

@ -469,7 +469,7 @@ bool SCH_FIELD::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const
rect.Inflate( aAccuracy );
return rect.Inside( aPoint );
return rect.Contains( aPoint );
}
@ -484,7 +484,7 @@ bool SCH_FIELD::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy
rect.Inflate( aAccuracy );
if( aContained )
return rect.Inside( GetBoundingBox() );
return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}

View File

@ -262,7 +262,7 @@ bool SCH_BUS_ENTRY::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccu
rect.Inflate( aAccuracy );
if( aContained )
return rect.Inside( GetBoundingBox() );
return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}
@ -433,7 +433,7 @@ bool SCH_JUNCTION::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T
rect.Inflate( aAccuracy );
return rect.Inside( aPoint );
return rect.Contains( aPoint );
}
@ -444,7 +444,7 @@ bool SCH_JUNCTION::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccur
rect.Inflate( aAccuracy );
if( aContained )
return rect.Inside( GetBoundingBox() );
return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}
@ -628,7 +628,7 @@ bool SCH_NO_CONNECT::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAcc
rect.Inflate( aAccuracy );
if( aContained )
return rect.Inside( GetBoundingBox() );
return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}
@ -1048,7 +1048,7 @@ bool SCH_LINE::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy
rect.Inflate( aAccuracy );
if( aContained )
return rect.Inside( GetBoundingBox() );
return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}
@ -1278,7 +1278,7 @@ bool SCH_POLYLINE::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccur
rect.Inflate( aAccuracy );
if( aContained )
return rect.Inside( GetBoundingBox() );
return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}

View File

@ -1145,7 +1145,7 @@ bool SCH_SHEET::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aF
rect.Inflate( aAccuracy );
return rect.Inside( aPoint );
return rect.Contains( aPoint );
}
@ -1156,7 +1156,7 @@ bool SCH_SHEET::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy
rect.Inflate( aAccuracy );
if( aContained )
return rect.Inside( GetBoundingBox() );
return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() );
}

View File

@ -454,7 +454,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DRAG_WIRE_REQUEST:
DrawPanel->MouseToCursorSchema();
// The easiest way to handle a drag component is to simulate a
// block drag command
if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
@ -472,13 +471,12 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// TODO: a better way to drag only wires
SCH_LINE* segm = (SCH_LINE*) screen->GetCurItem();
if( !screen->m_BlockLocate.Inside( segm->m_Start )
&& !screen->m_BlockLocate.Inside( segm->m_End ) )
if( !screen->m_BlockLocate.Contains( segm->m_Start )
&& !screen->m_BlockLocate.Contains( segm->m_End ) )
{
screen->m_BlockLocate.SetOrigin( segm->m_Start );
screen->m_BlockLocate.SetEnd( segm->m_End );
}
HandleBlockEnd( &dc );
}
break;

View File

@ -668,10 +668,10 @@ bool GERBER_DRAW_ITEM::HitTest( EDA_Rect& aRefArea )
{
wxPoint pos = GetABPosition( m_Start );
if( aRefArea.Inside( pos ) )
if( aRefArea.Contains( pos ) )
return true;
pos = GetABPosition( m_End );
if( aRefArea.Inside( pos ) )
if( aRefArea.Contains( pos ) )
return true;
return false;
}

View File

@ -146,7 +146,9 @@ public:
* Class EDA_Rect
* handles the component boundary box.
* This class is similar to wxRect, but some wxRect functions are very curious,
* so I prefer this suitable class
* and are working only if dimensions are >= 0 (not always the case in kicad)
* and also kicad needs some specific method.
* so I prefer this more suitable class
*/
class EDA_Rect
{
@ -173,11 +175,33 @@ public:
*/
void Move( const wxPoint& aMoveVector );
void Normalize(); // Ensure the height and width are >= 0
bool Inside( const wxPoint& point ) const; // Return TRUE if point is in Rect
/**
* Function Normalize
* Ensure the height and width are >= 0
*/
void Normalize();
/**
* Function Contains
* @param aPoint = the wxPoint to test
* @return true if aPoint is inside the boundary box. A point on a edge is seen as inside
*/
bool Contains( const wxPoint& aPoint ) const;
/**
* Function Contains
* @param x = the x coordinate of the point to test
* @param y = the x coordinate of the point to test
* @return true if point is inside the boundary box. A point on a edge is seen as inside
*/
bool Contains( int x, int y ) const { return Contains( wxPoint( x, y ) ); }
/**
* Function Contains
* @param aRect = the EDA_Rect to test
* @return true if aRect is Contained. A common edge is seen as contained
*/
bool Contains( const EDA_Rect& aRect ) const;
bool Inside( int x, int y ) const { return Inside( wxPoint( x, y ) ); }
bool Inside( const EDA_Rect& aRect ) const;
wxSize GetSize() const { return m_Size; }
int GetX() const { return m_Pos.x; }
int GetY() const { return m_Pos.y; }
@ -209,8 +233,9 @@ public:
/**
* Function Intersects
* @return bool - true if the argument rectangle intersects this rectangle.
* (i.e. if the 2 rectangles have at least a common point)
*/
bool Intersects( const EDA_Rect aRect ) const;
bool Intersects( const EDA_Rect& aRect ) const;
/**

View File

@ -137,17 +137,18 @@ void DisplayHotkeyList( WinEDA_DrawFrame* aFrame
*/
Ki_HotkeyInfo* GetDescriptorFromHotkey( int aKey, Ki_HotkeyInfo** aList );
/** function ReadHotkeyConfig * Read hotkey configuration for a given
app, possibly before the frame for that app has been created
@param Appname = the value of the app's m_FrameName
@param DescList = the hotkey data
/**
* Function ReadHotkeyConfig
* Read hotkey configuration for a given app,
* possibly before the frame for that app has been created
* @param Appname = the value of the app's m_FrameName
* @param aDescList = the hotkey data
*/
void ReadHotkeyConfig( const wxString& Appname,
struct Ki_HotkeyInfoSectionDescriptor* DescList );
struct Ki_HotkeyInfoSectionDescriptor* aDescList );
void ParseHotkeyConfig( const wxString& data,
struct Ki_HotkeyInfoSectionDescriptor* DescList );
struct Ki_HotkeyInfoSectionDescriptor* aDescList );
// common hotkeys event id

View File

@ -271,11 +271,11 @@ public:
/**
* Function HitTest().
* Test if \a aRect intersects or is contained within the bounding box of an item.
* Test if \a aRect intersects or contains the bounding box of me.
*
* @param aRect - Rectangle to test.
* @param aContained - Set to true to test for containment instead of an intersection.
* @param aAccuracy - Increase the item bounding box by this amount.
* @param aAccuracy - Increase aRect by this amount.
* @return True if \a aRect contains or intersects the item bounding box.
*/
bool HitTest( const EDA_Rect& aRect, bool aContained = false, int aAccuracy = 0 ) const

View File

@ -224,7 +224,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
Module = moduleList[ii];
if( PlaceModulesHorsPcb && edgesExists )
{
if( GetBoard()->m_BoundaryBox.Inside( Module->m_Pos ) )
if( GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) )
continue;
}
surface += Module->m_Surface;
@ -243,7 +243,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
if( PlaceModulesHorsPcb && edgesExists )
{
if( GetBoard()->m_BoundaryBox.Inside( Module->m_Pos ) )
if( GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) )
continue;
}

View File

@ -150,7 +150,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module,
Module->m_ModuleStatus &= ~MODULE_is_PLACED;
if( Module->m_ModuleStatus & MODULE_is_LOCKED )
break;
if( !GetBoard()->m_BoundaryBox.Inside( Module->m_Pos ) )
if( !GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) )
Module->m_ModuleStatus |= MODULE_to_PLACE;
break;

View File

@ -657,7 +657,7 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect )
{
pad->m_Selected = 0;
pos = pad->GetPosition();
if( Rect.Inside( pos ) )
if( Rect.Contains( pos ) )
{
pad->m_Selected = IS_SELECTED;
ItemsCount++;
@ -673,13 +673,13 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect )
{
case TYPE_EDGE_MODULE:
pos = ( (EDGE_MODULE*) item )->m_Start;
if( Rect.Inside( pos ) )
if( Rect.Contains( pos ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;
}
pos = ( (EDGE_MODULE*) item )->m_End;
if( Rect.Inside( pos ) )
if( Rect.Contains( pos ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;
@ -688,7 +688,7 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect )
case TYPE_TEXTE_MODULE:
pos = ( (TEXTE_MODULE*) item )->GetPosition();
if( Rect.Inside( pos ) )
if( Rect.Contains( pos ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;

View File

@ -738,7 +738,7 @@ bool DIMENSION::HitTest( const wxPoint& ref_pos )
*/
bool DIMENSION::HitTest( EDA_Rect& refArea )
{
if( refArea.Inside( m_Pos ) )
if( refArea.Contains( m_Pos ) )
return true;
return false;
}

View File

@ -487,9 +487,9 @@ bool DRAWSEGMENT::HitTest( const wxPoint& ref_pos )
*/
bool DRAWSEGMENT::HitTest( EDA_Rect& refArea )
{
if( refArea.Inside( m_Start ) )
if( refArea.Contains( m_Start ) )
return true;
if( refArea.Inside( m_End ) )
if( refArea.Contains( m_End ) )
return true;
return false;
}

View File

@ -200,7 +200,7 @@ bool MIREPCB::HitTest( const wxPoint& refPos )
*/
bool MIREPCB::HitTest( EDA_Rect& refArea )
{
if( refArea.Inside( m_Pos ) )
if( refArea.Contains( m_Pos ) )
return true;
return false;
}

View File

@ -875,13 +875,12 @@ void MODULE::DisplayInfo( WinEDA_DrawFrame* frame )
bool MODULE::HitTest( const wxPoint& refPos )
{
/* Calculation of the cursor coordinate relative to module */
int spot_cX = refPos.x - m_Pos.x;
int spot_cY = refPos.y - m_Pos.y;
wxPoint pos = refPos - m_Pos;
RotatePoint( &spot_cX, &spot_cY, -m_Orient );
RotatePoint( &pos, -m_Orient );
/* Check if cursor is in the rectangle. */
if( m_BoundaryBox.Inside( spot_cX, spot_cY ) )
if( m_BoundaryBox.Contains( pos ) )
return true;
return false;

View File

@ -291,7 +291,7 @@ bool TEXTE_MODULE::HitTest( const wxPoint& refPos )
rel_pos = refPos;
RotatePoint( &rel_pos, m_Pos, -GetDrawRotation() );
if( area.Inside( rel_pos ) )
if( area.Contains( rel_pos ) )
return true;
return false;

View File

@ -1175,9 +1175,9 @@ bool TRACK::HitTest( const wxPoint& ref_pos )
*/
bool TRACK::HitTest( EDA_Rect& refArea )
{
if( refArea.Inside( m_Start ) )
if( refArea.Contains( m_Start ) )
return true;
if( refArea.Inside( m_End ) )
if( refArea.Contains( m_End ) )
return true;
return false;
}

View File

@ -90,7 +90,7 @@ void ZONE_CONTAINER::Test_For_Copper_Island_And_Remove_Insulated_Islands( BOARD
ic++ )
{ // test if this area is connected to a board item:
wxPoint pos = ListPointsCandidates[ic];
if( !bbox.Inside( pos ) )
if( !bbox.Contains( pos ) )
continue;
if( TestPointInsidePolygon(
m_FilledPolysList, indexstart,

View File

@ -130,7 +130,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
else
continue;
bool connected = false;
if( bbox.Inside( pos1 ) )
if( bbox.Contains( pos1 ) )
{
if( TestPointInsidePolygon( curr_zone->m_FilledPolysList, indexstart,
indexend, pos1.x, pos1.y ) )
@ -138,7 +138,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
}
if( !connected && (pos1 != pos2 ) )
{
if( bbox.Inside( pos2 ) )
if( bbox.Contains( pos2 ) )
if( TestPointInsidePolygon( curr_zone->m_FilledPolysList, indexstart,
indexend, pos2.x, pos2.y ) )
connected = true;