Commit 5bab73d6 authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: fix issues in drag command (mainly hotkey command and forgotten wire...

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.
parent 597f6775
...@@ -4,6 +4,14 @@ KiCad ChangeLog 2010 ...@@ -4,6 +4,14 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. 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> 2010-Dec-19 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
++new: ++new:
......
...@@ -315,7 +315,7 @@ bool EDA_TextStruct::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const ...@@ -315,7 +315,7 @@ bool EDA_TextStruct::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
rect.Inflate( aAccuracy ); rect.Inflate( aAccuracy );
RotatePoint( &location, m_Pos, -m_Orient ); 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 ...@@ -326,7 +326,7 @@ bool EDA_TextStruct::TextHitTest( const EDA_Rect& aRect, bool aContains, int aAc
rect.Inflate( aAccuracy ); rect.Inflate( aAccuracy );
if( aContains ) if( aContains )
return rect.Inside( GetTextBox( -1 ) ); return rect.Contains( GetTextBox( -1 ) );
return rect.Intersects( GetTextBox( -1 ) ); return rect.Intersects( GetTextBox( -1 ) );
} }
...@@ -515,48 +515,59 @@ void EDA_Rect::Move( const wxPoint& aMoveVector ) ...@@ -515,48 +515,59 @@ void EDA_Rect::Move( const wxPoint& aMoveVector )
/* Return TRUE if point is in Rect /* Return TRUE if point is in Rect
* Accept rect size < 0 * 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; wxPoint rel_pos = aPoint - m_Pos;
int rel_posy = point.y - m_Pos.y;
wxSize size = m_Size; wxSize size = m_Size;
if( size.x < 0 ) if( size.x < 0 )
{ {
size.x = -size.x; size.x = -size.x;
rel_posx += size.x; rel_pos.x += size.x;
} }
if( size.y < 0 ) if( size.y < 0 )
{ {
size.y = -size.y; 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; return Contains(aRect.GetOrigin() ) && Contains(aRect.GetEnd() );
wxRect me = wxRect();
return me.Contains( rect );
} }
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: // this logic taken from wxWidgets' geometry.cpp file:
bool rc; bool rc;
EDA_Rect me(*this);
int left = MAX( m_Pos.x, aRect.m_Pos.x ); EDA_Rect rect(aRect);
int right = MIN( m_Pos.x + m_Size.x, aRect.m_Pos.x + aRect.m_Size.x ); me.Normalize(); // ensure size is >= 0
int top = MAX( m_Pos.y, aRect.m_Pos.y ); rect.Normalize(); // ensure size is >= 0
int bottom = MIN( m_Pos.y + m_Size.y, aRect.m_Pos.y + aRect.m_Size.y );
// calculate the left common area coordinate:
if( left < right && top < bottom ) 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 a common area exists, it must have a positive (null accepted) size
if( left <= right && top <= bottom )
rc = true; rc = true;
else else
rc = false; rc = false;
......
...@@ -118,7 +118,7 @@ bool MARKER_BASE::HitTestMarker( const wxPoint& refPos ) const ...@@ -118,7 +118,7 @@ bool MARKER_BASE::HitTestMarker( const wxPoint& refPos ) const
rel_pos.x /= m_ScalingFactor; rel_pos.x /= m_ScalingFactor;
rel_pos.y /= m_ScalingFactor; rel_pos.y /= m_ScalingFactor;
return m_ShapeBoundingBox.Inside( rel_pos ); return m_ShapeBoundingBox.Contains( rel_pos );
} }
......
...@@ -251,7 +251,7 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos ) ...@@ -251,7 +251,7 @@ bool WinEDA_DrawPanel::IsPointOnDisplay( wxPoint ref_pos )
GetScreen()->Unscale( display_rect.m_Size ); GetScreen()->Unscale( display_rect.m_Size );
#endif #endif
return display_rect.Inside( ref_pos ); return display_rect.Contains( ref_pos );
} }
......
...@@ -188,7 +188,7 @@ int GRMapY( int y ) ...@@ -188,7 +188,7 @@ int GRMapY( int y )
*/ */
static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 ) 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; return false;
wxRect rect = *aClipBox; wxRect rect = *aClipBox;
...@@ -206,7 +206,7 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 ) ...@@ -206,7 +206,7 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 )
tmpY2 = y2; tmpY2 = y2;
#endif #endif
if( aClipBox->Inside( x1, y1 ) ) if( aClipBox->Contains( x1, y1 ) )
{ {
if( x1 == x2 ) /* Vertical line, clip Y. */ 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 ) ...@@ -263,7 +263,7 @@ static bool clipLine( EDA_Rect* aClipBox, int& x1, int& y1, int& x2, int& y2 )
#endif #endif
return false; return false;
} }
else if( aClipBox->Inside( x2, y2 ) ) else if( aClipBox->Contains( x2, y2 ) )
{ {
if( x1 == x2 ) /* Vertical line, clip Y. */ if( x1 == x2 ) /* Vertical line, clip Y. */
{ {
...@@ -704,7 +704,7 @@ void GRPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int Color ) ...@@ -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 ) 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; return;
GRSetColorPen( DC, Color ); GRSetColorPen( DC, Color );
......
...@@ -170,15 +170,14 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound ) ...@@ -170,15 +170,14 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound )
} }
/** /* AddHotkeyName
* Function AddHotkeyName
* Add the key name from the Command id value ( m_Idcommand member value) * Add the key name from the Command id value ( m_Idcommand member value)
* @param aText = a wxString. returns aText + key name * aText = a wxString. returns aText + key name
* @param aList = pointer to a Ki_HotkeyInfo list of commands * aList = pointer to a Ki_HotkeyInfo list of commands
* @param aCommandId = Command Id value * aCommandId = Command Id value
* @param aIsShortCut = true to add <tab><keyname> (active shortcuts in menus) * aIsShortCut = true to add <tab><keyname> (active shortcuts in menus)
* = false to add <spaces><(keyname)> * = 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, wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList,
int aCommandId, bool aIsShortCut ) int aCommandId, bool aIsShortCut )
...@@ -200,15 +199,14 @@ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList, ...@@ -200,15 +199,14 @@ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList,
} }
/** /* AddHotkeyName
* Function AddHotkeyName
* Add the key name from the Command id value ( m_Idcommand member value) * Add the key name from the Command id value ( m_Idcommand member value)
* @param aText = a wxString. returns aText + key name * aText = a wxString. returns aText + key name
* @param aList = pointer to a Ki_HotkeyInfoSectionDescriptor DescrList of commands * aList = pointer to a Ki_HotkeyInfoSectionDescriptor DescrList of commands
* @param aCommandId = Command Id value * aCommandId = Command Id value
* @param aIsShortCut = true to add <tab><keyname> (active shortcuts in menus) * aIsShortCut = true to add <tab><keyname> (active shortcuts in menus)
* = false to add <spaces><(keyname)> * = 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, wxString AddHotkeyName( const wxString& aText,
struct Ki_HotkeyInfoSectionDescriptor* aDescList, struct Ki_HotkeyInfoSectionDescriptor* aDescList,
...@@ -325,13 +323,9 @@ int ReturnKeyCodeFromKeyName( const wxString& keyname ) ...@@ -325,13 +323,9 @@ int ReturnKeyCodeFromKeyName( const wxString& keyname )
} }
/** /* DisplayHotkeyList
* Function DisplayHotkeyList
* Displays the current hotkey list * Displays the current hotkey list
* @param aFrame = current active frame * aList = a Ki_HotkeyInfoSectionDescriptor list(Null terminated)
* @param aList = pointer to a Ki_HotkeyInfoSectionDescriptor list
*(Null terminated)
* @return none
*/ */
void DisplayHotkeyList( WinEDA_DrawFrame* aFrame, void DisplayHotkeyList( WinEDA_DrawFrame* aFrame,
struct Ki_HotkeyInfoSectionDescriptor* aDescList ) struct Ki_HotkeyInfoSectionDescriptor* aDescList )
...@@ -478,7 +472,6 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile( ...@@ -478,7 +472,6 @@ int WinEDA_BasicFrame::ReadHotkeyConfigFile(
return 1; return 1;
} }
void ReadHotkeyConfig( const wxString& Appname, void ReadHotkeyConfig( const wxString& Appname,
struct Ki_HotkeyInfoSectionDescriptor* aDescList ) struct Ki_HotkeyInfoSectionDescriptor* aDescList )
{ {
...@@ -496,11 +489,9 @@ void ReadHotkeyConfig( const wxString& Appname, ...@@ -496,11 +489,9 @@ void ReadHotkeyConfig( const wxString& Appname,
ParseHotkeyConfig( data, aDescList ); ParseHotkeyConfig( data, aDescList );
} }
/* Function ReadHotkeyConfig
/**
* Function ReadHotkeyConfig
* Read configuration data and fill the current hotkey list with hotkeys * 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 ) int WinEDA_BasicFrame::ReadHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* aDescList )
{ {
...@@ -509,16 +500,14 @@ int WinEDA_BasicFrame::ReadHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor* ...@@ -509,16 +500,14 @@ int WinEDA_BasicFrame::ReadHotkeyConfig( struct Ki_HotkeyInfoSectionDescriptor*
} }
/** /* Function ParseHotkeyConfig
* Function ParseHotkeyConfig
* the input format is: shortcut "key" "function" * the input format is: shortcut "key" "function"
* lines starting by # are ignored (comments) * lines starting by # are ignored (comments)
* lines like [xxx] are tags (example: [common] or [libedit] which identify * lines like [xxx] are tags (example: [common] or [libedit] which identify sections
* sections
*/ */
void ParseHotkeyConfig( void ParseHotkeyConfig(
const wxString& data, const wxString& data,
struct Ki_HotkeyInfoSectionDescriptor* DescList ) struct Ki_HotkeyInfoSectionDescriptor* aDescList )
{ {
/* Read the config */ /* Read the config */
wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK ); wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK );
...@@ -536,7 +525,7 @@ void ParseHotkeyConfig( ...@@ -536,7 +525,7 @@ void ParseHotkeyConfig(
if( line_type[0] == '[' ) // A tag is found. search infos in list if( line_type[0] == '[' ) // A tag is found. search infos in list
{ {
CurrentHotkeyList = 0; CurrentHotkeyList = 0;
Ki_HotkeyInfoSectionDescriptor* DList = DescList; Ki_HotkeyInfoSectionDescriptor* DList = aDescList;
for( ; DList->m_HK_InfoList; DList++ ) for( ; DList->m_HK_InfoList; DList++ )
{ {
if( *DList->m_SectionTag == line_type ) if( *DList->m_SectionTag == line_type )
...@@ -639,8 +628,7 @@ void WinEDA_BasicFrame::ExportHotkeyConfigToFile( ...@@ -639,8 +628,7 @@ void WinEDA_BasicFrame::ExportHotkeyConfigToFile(
} }
/** add hotkey config options submenu to a menu /* add hotkey config options submenu to aMenu
* @param menu : root menu
*/ */
void AddHotkeyConfigMenu( wxMenu* aMenu ) void AddHotkeyConfigMenu( wxMenu* aMenu )
{ {
......
...@@ -37,9 +37,9 @@ void DuplicateItemsInList( SCH_SCREEN* screen, ...@@ -37,9 +37,9 @@ void DuplicateItemsInList( SCH_SCREEN* screen,
static void CollectStructsToDrag( SCH_SCREEN* screen ); static void CollectStructsToDrag( SCH_SCREEN* screen );
static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition ); static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition );
static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aComponent,
wxPoint& aPosition, wxPoint& aPosition,
bool aSearchFirst ); LIB_PIN* aPin );
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList ); static void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList );
...@@ -226,6 +226,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) ...@@ -226,6 +226,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
} }
if( DrawPanel->ManageCurseur != NULL ) if( DrawPanel->ManageCurseur != NULL )
{
switch( block->m_Command ) switch( block->m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
...@@ -234,14 +235,14 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) ...@@ -234,14 +235,14 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */ case BLOCK_DRAG: /* Drag */
BreakSegmentOnJunction( GetScreen() ); BreakSegmentOnJunction( GetScreen() );
// fall through
case BLOCK_ROTATE: case BLOCK_ROTATE:
case BLOCK_MIRROR_X: case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: case BLOCK_MIRROR_Y:
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() ); PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
// fall through
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
if( block->GetCount() ) if( block->GetCount() )
{ {
...@@ -301,6 +302,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) ...@@ -301,6 +302,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
case BLOCK_ABORT: /* not executed here */ case BLOCK_ABORT: /* not executed here */
break; break;
} }
}
if( block->m_Command == BLOCK_ABORT ) if( block->m_Command == BLOCK_ABORT )
{ {
...@@ -595,7 +597,8 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC ) ...@@ -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 * 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 ) * connected to a selected item (connected wires to a component or an entry )
*/ */
...@@ -624,14 +627,14 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -624,14 +627,14 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
/* Remove the displacement of segment and undo the selection. */ /* Remove the displacement of segment and undo the selection. */
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ ) 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 ) if( Struct->Type() == SCH_LINE_T )
{ {
SegmStruct = (SCH_LINE*) Struct; SegmStruct = (SCH_LINE*) Struct;
if( !screen->m_BlockLocate.Inside( SegmStruct->m_Start ) ) if( !screen->m_BlockLocate.Contains( SegmStruct->m_Start ) )
SegmStruct->m_Flags |= STARTPOINT; SegmStruct->m_Flags |= STARTPOINT;
if( !screen->m_BlockLocate.Inside( SegmStruct->m_End ) ) if( !screen->m_BlockLocate.Contains( SegmStruct->m_End ) )
SegmStruct->m_Flags |= ENDPOINT; SegmStruct->m_Flags |= ENDPOINT;
// Save m_Flags for Undo/redo drag operations: // Save m_Flags for Undo/redo drag operations:
...@@ -642,17 +645,16 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -642,17 +645,16 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
/* Search for other items to drag. They are end wires connected to selected /* Search for other items to drag. They are end wires connected to selected
* items * items
*/ */
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ ) 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 ) if( ( Struct->Type() == SCH_LABEL_T )
|| ( Struct->Type() == SCH_GLOBAL_LABEL_T ) || ( Struct->Type() == SCH_GLOBAL_LABEL_T )
|| ( Struct->Type() == SCH_HIERARCHICAL_LABEL_T ) ) || ( Struct->Type() == SCH_HIERARCHICAL_LABEL_T ) )
{ {
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_TEXT*) 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 ); AddPickedItem( screen, STRUCT->m_Pos );
} }
...@@ -661,20 +663,20 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -661,20 +663,20 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
if( Struct->Type() == SCH_COMPONENT_T ) if( Struct->Type() == SCH_COMPONENT_T )
{ {
// Add all pins of the selected component to list // Add all pins of the selected component to list
LIB_PIN* pin;
wxPoint pos; wxPoint pos;
pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, true ); LIB_PIN* pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, NULL );
while( pin ) while( pin )
{ {
if( !screen->m_BlockLocate.Inside( pos ) ) if( !screen->m_BlockLocate.Contains( pos ) )
{ {
// This pin is outside area, // 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 // we must also select connected items to this pin
// and mainly wires
AddPickedItem( screen, pos ); 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 ) ...@@ -774,7 +776,6 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
{ {
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
Struct->m_Flags &= ~STARTPOINT; Struct->m_Flags &= ~STARTPOINT;
// Save m_Flags for Undo/redo drag operations: // Save m_Flags for Undo/redo drag operations:
picker.m_PickerFlags = Struct->m_Flags; picker.m_PickerFlags = Struct->m_Flags;
pickedlist->PushItem( picker ); pickedlist->PushItem( picker );
...@@ -783,7 +784,6 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -783,7 +784,6 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
{ {
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
Struct->m_Flags &= ~ENDPOINT; Struct->m_Flags &= ~ENDPOINT;
// Save m_Flags for Undo/redo drag operations: // Save m_Flags for Undo/redo drag operations:
picker.m_PickerFlags = Struct->m_Flags; picker.m_PickerFlags = Struct->m_Flags;
pickedlist->PushItem( picker ); pickedlist->PushItem( picker );
...@@ -856,53 +856,45 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -856,53 +856,45 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
/** GetNextPinPosition() /** GetNextPinPosition()
* calculate position of the "next" pin of the aDrawLibItem component * 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 * @param aPosition = the calculated pin position, according to the component
* orientation and position * orientation and position
* @param aSearchFirst = if true, search for the first pin * @param aSearchFirst = if true, search for the first pin
* @return a pointer to the pin * @return a pointer to the pin
*/ */
static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aComponent,
wxPoint& aPosition, wxPoint& aPosition,
bool aSearchFirst ) LIB_PIN* aPin )
{ {
static LIB_COMPONENT* Entry; 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 ) if( Entry == NULL )
return 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 */ /* Skip items not used for this part */
if( Multi && Pin->GetUnit() && ( Pin->GetUnit() != Multi ) ) if( multi && aPin->GetUnit() && ( aPin->GetUnit() != multi ) )
continue; continue;
if( convert && Pin->GetConvert() && ( Pin->GetConvert() != convert ) ) if( convert && aPin->GetConvert() && ( aPin->GetConvert() != convert ) )
continue; continue;
/* Calculate the pin position (according to the component orientation) /* Calculate the pin position (according to the component orientation)
*/ */
aPosition = DefaultTransform.TransformCoordinate( Pin->GetPosition() ) + CmpPosition; aPosition = aComponent->GetPinPhysicalPosition( aPin );
return Pin; return aPin;
} }
return NULL; return NULL;
......
...@@ -748,7 +748,12 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct ) ...@@ -748,7 +748,12 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
case SCH_LINE_T: case SCH_LINE_T:
if( ( (SCH_ITEM*) DrawStruct )->GetLayer() == LAYER_WIRE ) if( ( (SCH_ITEM*) DrawStruct )->GetLayer() == LAYER_WIRE )
{
if( HK_Descr->m_Idcommand == HK_DRAG )
wxPostEvent( this, eventDragWire ); wxPostEvent( this, eventDragWire );
else
wxPostEvent( this, eventMoveItem );
}
break; break;
default: default:
......
...@@ -263,8 +263,8 @@ void LIB_ARC::DoOffset( const wxPoint& aOffset ) ...@@ -263,8 +263,8 @@ void LIB_ARC::DoOffset( const wxPoint& aOffset )
bool LIB_ARC::DoTestInside( EDA_Rect& aRect ) const bool LIB_ARC::DoTestInside( EDA_Rect& aRect ) const
{ {
return aRect.Inside( m_ArcStart.x, -m_ArcStart.y ) return aRect.Contains( m_ArcStart.x, -m_ArcStart.y )
|| aRect.Inside( m_ArcEnd.x, -m_ArcEnd.y ); || aRect.Contains( m_ArcEnd.x, -m_ArcEnd.y );
} }
......
...@@ -164,7 +164,7 @@ bool LIB_BEZIER::DoTestInside( EDA_Rect& aRect ) const ...@@ -164,7 +164,7 @@ bool LIB_BEZIER::DoTestInside( EDA_Rect& aRect ) const
{ {
for( size_t i = 0; i < m_PolyPoints.size(); i++ ) 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; return true;
} }
......
...@@ -152,7 +152,7 @@ bool LIB_CIRCLE::DoTestInside( EDA_Rect& aRect ) const ...@@ -152,7 +152,7 @@ bool LIB_CIRCLE::DoTestInside( EDA_Rect& aRect ) const
* FIXME: This fails to take into account the radius around the center * FIXME: This fails to take into account the radius around the center
* point. * point.
*/ */
return aRect.Inside( m_Pos.x, -m_Pos.y ); return aRect.Contains( m_Pos.x, -m_Pos.y );
} }
......
...@@ -466,7 +466,7 @@ bool LIB_FIELD::DoTestInside( EDA_Rect& rect ) const ...@@ -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 * FIXME: This fails to take into acount the size and/or orientation of
* the text. * the text.
*/ */
return rect.Inside( m_Pos.x, -m_Pos.y ); return rect.Contains( m_Pos.x, -m_Pos.y );
} }
......
...@@ -1653,7 +1653,7 @@ bool LIB_PIN::DoTestInside( EDA_Rect& rect ) const ...@@ -1653,7 +1653,7 @@ bool LIB_PIN::DoTestInside( EDA_Rect& rect ) const
{ {
wxPoint end = ReturnPinEndPoint(); 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 );
} }
......
...@@ -162,7 +162,7 @@ bool LIB_POLYLINE::DoTestInside( EDA_Rect& aRect ) const ...@@ -162,7 +162,7 @@ bool LIB_POLYLINE::DoTestInside( EDA_Rect& aRect ) const
{ {
for( size_t i = 0; i < m_PolyPoints.size(); i++ ) 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; return true;
} }
......
...@@ -119,7 +119,7 @@ void LIB_RECTANGLE::DoOffset( const wxPoint& aOffset ) ...@@ -119,7 +119,7 @@ void LIB_RECTANGLE::DoOffset( const wxPoint& aOffset )
bool LIB_RECTANGLE::DoTestInside( EDA_Rect& aRect ) const 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 );
} }
......
...@@ -223,7 +223,7 @@ bool LIB_TEXT::DoTestInside( EDA_Rect& rect ) const ...@@ -223,7 +223,7 @@ bool LIB_TEXT::DoTestInside( EDA_Rect& rect ) const
* FIXME: This should calculate the text size and justification and * FIXME: This should calculate the text size and justification and
* use rectangle instect. * use rectangle instect.
*/ */
return rect.Inside( m_Pos.x, -m_Pos.y ); return rect.Contains( m_Pos.x, -m_Pos.y );
} }
......
...@@ -139,6 +139,7 @@ int PickItemsInBlock( BLOCK_SELECTOR& aBlock, SCH_SCREEN* aScreen ) ...@@ -139,6 +139,7 @@ int PickItemsInBlock( BLOCK_SELECTOR& aBlock, SCH_SCREEN* aScreen )
for( ; item != NULL; item = item->Next() ) for( ; item != NULL; item = item->Next() )
{ {
// an item is picked if its bounding box intersects the reference area
if( item->HitTest( area ) ) if( item->HitTest( area ) )
{ {
/* Put this structure in the picked list: */ /* Put this structure in the picked list: */
...@@ -310,7 +311,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList ) ...@@ -310,7 +311,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList )
EDA_Rect BoundaryBox = field->GetBoundingBox(); EDA_Rect BoundaryBox = field->GetBoundingBox();
if( BoundaryBox.Inside( aPosRef ) ) if( BoundaryBox.Contains( aPosRef ) )
{ {
LastSnappedStruct = field; LastSnappedStruct = field;
return true; return true;
...@@ -323,7 +324,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList ) ...@@ -323,7 +324,7 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, SCH_ITEM* DrawList )
#define STRUCT ( (SCH_COMPONENT*) DrawList ) #define STRUCT ( (SCH_COMPONENT*) DrawList )
EDA_Rect BoundaryBox = STRUCT->GetBoundingBox(); EDA_Rect BoundaryBox = STRUCT->GetBoundingBox();
if( BoundaryBox.Inside( aPosRef ) ) if( BoundaryBox.Contains( aPosRef ) )
{ {
LastSnappedStruct = DrawList; LastSnappedStruct = DrawList;
return true; return true;
......
...@@ -1664,7 +1664,7 @@ bool SCH_COMPONENT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_ ...@@ -1664,7 +1664,7 @@ bool SCH_COMPONENT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_
bBox = GetField( ii )->GetBoundingBox(); bBox = GetField( ii )->GetBoundingBox();
bBox.Inflate( aAccuracy ); bBox.Inflate( aAccuracy );
if( bBox.Inside( aPoint ) ) if( bBox.Contains( aPoint ) )
return true; return true;
} }
} }
...@@ -1674,7 +1674,7 @@ bool SCH_COMPONENT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_ ...@@ -1674,7 +1674,7 @@ bool SCH_COMPONENT::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_
bBox = GetBodyBoundingBox(); bBox = GetBodyBoundingBox();
bBox.Inflate( aAccuracy ); bBox.Inflate( aAccuracy );
if( bBox.Inside( aPoint ) ) if( bBox.Contains( aPoint ) )
return true; return true;
} }
...@@ -1689,7 +1689,7 @@ bool SCH_COMPONENT::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccu ...@@ -1689,7 +1689,7 @@ bool SCH_COMPONENT::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccu
rect.Inflate( aAccuracy ); rect.Inflate( aAccuracy );
if( aContained ) if( aContained )
return rect.Inside( GetBoundingBox() ); return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() );
} }
......
...@@ -469,7 +469,7 @@ bool SCH_FIELD::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const ...@@ -469,7 +469,7 @@ bool SCH_FIELD::DoHitTest( const wxPoint& aPoint, int aAccuracy ) const
rect.Inflate( aAccuracy ); 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 ...@@ -484,7 +484,7 @@ bool SCH_FIELD::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy
rect.Inflate( aAccuracy ); rect.Inflate( aAccuracy );
if( aContained ) if( aContained )
return rect.Inside( GetBoundingBox() ); return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() );
} }
...@@ -262,7 +262,7 @@ bool SCH_BUS_ENTRY::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccu ...@@ -262,7 +262,7 @@ bool SCH_BUS_ENTRY::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccu
rect.Inflate( aAccuracy ); rect.Inflate( aAccuracy );
if( aContained ) if( aContained )
return rect.Inside( GetBoundingBox() ); return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() );
} }
...@@ -433,7 +433,7 @@ bool SCH_JUNCTION::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T ...@@ -433,7 +433,7 @@ bool SCH_JUNCTION::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T
rect.Inflate( aAccuracy ); 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 ...@@ -444,7 +444,7 @@ bool SCH_JUNCTION::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccur
rect.Inflate( aAccuracy ); rect.Inflate( aAccuracy );
if( aContained ) if( aContained )
return rect.Inside( GetBoundingBox() ); return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() );
} }
...@@ -628,7 +628,7 @@ bool SCH_NO_CONNECT::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAcc ...@@ -628,7 +628,7 @@ bool SCH_NO_CONNECT::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAcc
rect.Inflate( aAccuracy ); rect.Inflate( aAccuracy );
if( aContained ) if( aContained )
return rect.Inside( GetBoundingBox() ); return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() );
} }
...@@ -1048,7 +1048,7 @@ bool SCH_LINE::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ...@@ -1048,7 +1048,7 @@ bool SCH_LINE::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy
rect.Inflate( aAccuracy ); rect.Inflate( aAccuracy );
if( aContained ) if( aContained )
return rect.Inside( GetBoundingBox() ); return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() );
} }
...@@ -1278,7 +1278,7 @@ bool SCH_POLYLINE::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccur ...@@ -1278,7 +1278,7 @@ bool SCH_POLYLINE::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccur
rect.Inflate( aAccuracy ); rect.Inflate( aAccuracy );
if( aContained ) if( aContained )
return rect.Inside( GetBoundingBox() ); return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() );
} }
...@@ -1145,7 +1145,7 @@ bool SCH_SHEET::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aF ...@@ -1145,7 +1145,7 @@ bool SCH_SHEET::DoHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aF
rect.Inflate( aAccuracy ); 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 ...@@ -1156,7 +1156,7 @@ bool SCH_SHEET::DoHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy
rect.Inflate( aAccuracy ); rect.Inflate( aAccuracy );
if( aContained ) if( aContained )
return rect.Inside( GetBoundingBox() ); return rect.Contains( GetBoundingBox() );
return rect.Intersects( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() );
} }
......
...@@ -454,7 +454,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -454,7 +454,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DRAG_WIRE_REQUEST: case ID_POPUP_SCH_DRAG_WIRE_REQUEST:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
// The easiest way to handle a drag component is to simulate a // The easiest way to handle a drag component is to simulate a
// block drag command // block drag command
if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK ) if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
...@@ -472,13 +471,12 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -472,13 +471,12 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// TODO: a better way to drag only wires // TODO: a better way to drag only wires
SCH_LINE* segm = (SCH_LINE*) screen->GetCurItem(); SCH_LINE* segm = (SCH_LINE*) screen->GetCurItem();
if( !screen->m_BlockLocate.Inside( segm->m_Start ) if( !screen->m_BlockLocate.Contains( segm->m_Start )
&& !screen->m_BlockLocate.Inside( segm->m_End ) ) && !screen->m_BlockLocate.Contains( segm->m_End ) )
{ {
screen->m_BlockLocate.SetOrigin( segm->m_Start ); screen->m_BlockLocate.SetOrigin( segm->m_Start );
screen->m_BlockLocate.SetEnd( segm->m_End ); screen->m_BlockLocate.SetEnd( segm->m_End );
} }
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
} }
break; break;
......
...@@ -668,10 +668,10 @@ bool GERBER_DRAW_ITEM::HitTest( EDA_Rect& aRefArea ) ...@@ -668,10 +668,10 @@ bool GERBER_DRAW_ITEM::HitTest( EDA_Rect& aRefArea )
{ {
wxPoint pos = GetABPosition( m_Start ); wxPoint pos = GetABPosition( m_Start );
if( aRefArea.Inside( pos ) ) if( aRefArea.Contains( pos ) )
return true; return true;
pos = GetABPosition( m_End ); pos = GetABPosition( m_End );
if( aRefArea.Inside( pos ) ) if( aRefArea.Contains( pos ) )
return true; return true;
return false; return false;
} }
......
...@@ -146,7 +146,9 @@ public: ...@@ -146,7 +146,9 @@ public:
* Class EDA_Rect * Class EDA_Rect
* handles the component boundary box. * handles the component boundary box.
* This class is similar to wxRect, but some wxRect functions are very curious, * 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 class EDA_Rect
{ {
...@@ -173,11 +175,33 @@ public: ...@@ -173,11 +175,33 @@ public:
*/ */
void Move( const wxPoint& aMoveVector ); 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; } wxSize GetSize() const { return m_Size; }
int GetX() const { return m_Pos.x; } int GetX() const { return m_Pos.x; }
int GetY() const { return m_Pos.y; } int GetY() const { return m_Pos.y; }
...@@ -209,8 +233,9 @@ public: ...@@ -209,8 +233,9 @@ public:
/** /**
* Function Intersects * Function Intersects
* @return bool - true if the argument rectangle intersects this rectangle. * @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;
/** /**
......
...@@ -137,17 +137,18 @@ void DisplayHotkeyList( WinEDA_DrawFrame* aFrame ...@@ -137,17 +137,18 @@ void DisplayHotkeyList( WinEDA_DrawFrame* aFrame
*/ */
Ki_HotkeyInfo* GetDescriptorFromHotkey( int aKey, Ki_HotkeyInfo** aList ); 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 * Function ReadHotkeyConfig
* Read hotkey configuration for a given app,
@param Appname = the value of the app's m_FrameName * possibly before the frame for that app has been created
@param DescList = the hotkey data * @param Appname = the value of the app's m_FrameName
* @param aDescList = the hotkey data
*/ */
void ReadHotkeyConfig( const wxString& Appname, void ReadHotkeyConfig( const wxString& Appname,
struct Ki_HotkeyInfoSectionDescriptor* DescList ); struct Ki_HotkeyInfoSectionDescriptor* aDescList );
void ParseHotkeyConfig( const wxString& data, void ParseHotkeyConfig( const wxString& data,
struct Ki_HotkeyInfoSectionDescriptor* DescList ); struct Ki_HotkeyInfoSectionDescriptor* aDescList );
// common hotkeys event id // common hotkeys event id
......
...@@ -271,11 +271,11 @@ public: ...@@ -271,11 +271,11 @@ public:
/** /**
* Function HitTest(). * 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 aRect - Rectangle to test.
* @param aContained - Set to true to test for containment instead of an intersection. * @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. * @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 bool HitTest( const EDA_Rect& aRect, bool aContained = false, int aAccuracy = 0 ) const
......
...@@ -224,7 +224,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) ...@@ -224,7 +224,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
Module = moduleList[ii]; Module = moduleList[ii];
if( PlaceModulesHorsPcb && edgesExists ) if( PlaceModulesHorsPcb && edgesExists )
{ {
if( GetBoard()->m_BoundaryBox.Inside( Module->m_Pos ) ) if( GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) )
continue; continue;
} }
surface += Module->m_Surface; surface += Module->m_Surface;
...@@ -243,7 +243,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) ...@@ -243,7 +243,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
if( PlaceModulesHorsPcb && edgesExists ) if( PlaceModulesHorsPcb && edgesExists )
{ {
if( GetBoard()->m_BoundaryBox.Inside( Module->m_Pos ) ) if( GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) )
continue; continue;
} }
......
...@@ -150,7 +150,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, ...@@ -150,7 +150,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module,
Module->m_ModuleStatus &= ~MODULE_is_PLACED; Module->m_ModuleStatus &= ~MODULE_is_PLACED;
if( Module->m_ModuleStatus & MODULE_is_LOCKED ) if( Module->m_ModuleStatus & MODULE_is_LOCKED )
break; break;
if( !GetBoard()->m_BoundaryBox.Inside( Module->m_Pos ) ) if( !GetBoard()->m_BoundaryBox.Contains( Module->m_Pos ) )
Module->m_ModuleStatus |= MODULE_to_PLACE; Module->m_ModuleStatus |= MODULE_to_PLACE;
break; break;
......
...@@ -657,7 +657,7 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect ) ...@@ -657,7 +657,7 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect )
{ {
pad->m_Selected = 0; pad->m_Selected = 0;
pos = pad->GetPosition(); pos = pad->GetPosition();
if( Rect.Inside( pos ) ) if( Rect.Contains( pos ) )
{ {
pad->m_Selected = IS_SELECTED; pad->m_Selected = IS_SELECTED;
ItemsCount++; ItemsCount++;
...@@ -673,13 +673,13 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect ) ...@@ -673,13 +673,13 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect )
{ {
case TYPE_EDGE_MODULE: case TYPE_EDGE_MODULE:
pos = ( (EDGE_MODULE*) item )->m_Start; pos = ( (EDGE_MODULE*) item )->m_Start;
if( Rect.Inside( pos ) ) if( Rect.Contains( pos ) )
{ {
item->m_Selected = IS_SELECTED; item->m_Selected = IS_SELECTED;
ItemsCount++; ItemsCount++;
} }
pos = ( (EDGE_MODULE*) item )->m_End; pos = ( (EDGE_MODULE*) item )->m_End;
if( Rect.Inside( pos ) ) if( Rect.Contains( pos ) )
{ {
item->m_Selected = IS_SELECTED; item->m_Selected = IS_SELECTED;
ItemsCount++; ItemsCount++;
...@@ -688,7 +688,7 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect ) ...@@ -688,7 +688,7 @@ int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect )
case TYPE_TEXTE_MODULE: case TYPE_TEXTE_MODULE:
pos = ( (TEXTE_MODULE*) item )->GetPosition(); pos = ( (TEXTE_MODULE*) item )->GetPosition();
if( Rect.Inside( pos ) ) if( Rect.Contains( pos ) )
{ {
item->m_Selected = IS_SELECTED; item->m_Selected = IS_SELECTED;
ItemsCount++; ItemsCount++;
......
...@@ -738,7 +738,7 @@ bool DIMENSION::HitTest( const wxPoint& ref_pos ) ...@@ -738,7 +738,7 @@ bool DIMENSION::HitTest( const wxPoint& ref_pos )
*/ */
bool DIMENSION::HitTest( EDA_Rect& refArea ) bool DIMENSION::HitTest( EDA_Rect& refArea )
{ {
if( refArea.Inside( m_Pos ) ) if( refArea.Contains( m_Pos ) )
return true; return true;
return false; return false;
} }
...@@ -487,9 +487,9 @@ bool DRAWSEGMENT::HitTest( const wxPoint& ref_pos ) ...@@ -487,9 +487,9 @@ bool DRAWSEGMENT::HitTest( const wxPoint& ref_pos )
*/ */
bool DRAWSEGMENT::HitTest( EDA_Rect& refArea ) bool DRAWSEGMENT::HitTest( EDA_Rect& refArea )
{ {
if( refArea.Inside( m_Start ) ) if( refArea.Contains( m_Start ) )
return true; return true;
if( refArea.Inside( m_End ) ) if( refArea.Contains( m_End ) )
return true; return true;
return false; return false;
} }
......
...@@ -200,7 +200,7 @@ bool MIREPCB::HitTest( const wxPoint& refPos ) ...@@ -200,7 +200,7 @@ bool MIREPCB::HitTest( const wxPoint& refPos )
*/ */
bool MIREPCB::HitTest( EDA_Rect& refArea ) bool MIREPCB::HitTest( EDA_Rect& refArea )
{ {
if( refArea.Inside( m_Pos ) ) if( refArea.Contains( m_Pos ) )
return true; return true;
return false; return false;
} }
......
...@@ -875,13 +875,12 @@ void MODULE::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -875,13 +875,12 @@ void MODULE::DisplayInfo( WinEDA_DrawFrame* frame )
bool MODULE::HitTest( const wxPoint& refPos ) bool MODULE::HitTest( const wxPoint& refPos )
{ {
/* Calculation of the cursor coordinate relative to module */ /* Calculation of the cursor coordinate relative to module */
int spot_cX = refPos.x - m_Pos.x; wxPoint pos = refPos - m_Pos;
int spot_cY = refPos.y - m_Pos.y;
RotatePoint( &spot_cX, &spot_cY, -m_Orient ); RotatePoint( &pos, -m_Orient );
/* Check if cursor is in the rectangle. */ /* Check if cursor is in the rectangle. */
if( m_BoundaryBox.Inside( spot_cX, spot_cY ) ) if( m_BoundaryBox.Contains( pos ) )
return true; return true;
return false; return false;
......
...@@ -291,7 +291,7 @@ bool TEXTE_MODULE::HitTest( const wxPoint& refPos ) ...@@ -291,7 +291,7 @@ bool TEXTE_MODULE::HitTest( const wxPoint& refPos )
rel_pos = refPos; rel_pos = refPos;
RotatePoint( &rel_pos, m_Pos, -GetDrawRotation() ); RotatePoint( &rel_pos, m_Pos, -GetDrawRotation() );
if( area.Inside( rel_pos ) ) if( area.Contains( rel_pos ) )
return true; return true;
return false; return false;
......
...@@ -1175,9 +1175,9 @@ bool TRACK::HitTest( const wxPoint& ref_pos ) ...@@ -1175,9 +1175,9 @@ bool TRACK::HitTest( const wxPoint& ref_pos )
*/ */
bool TRACK::HitTest( EDA_Rect& refArea ) bool TRACK::HitTest( EDA_Rect& refArea )
{ {
if( refArea.Inside( m_Start ) ) if( refArea.Contains( m_Start ) )
return true; return true;
if( refArea.Inside( m_End ) ) if( refArea.Contains( m_End ) )
return true; return true;
return false; return false;
} }
......
...@@ -90,7 +90,7 @@ void ZONE_CONTAINER::Test_For_Copper_Island_And_Remove_Insulated_Islands( BOARD ...@@ -90,7 +90,7 @@ void ZONE_CONTAINER::Test_For_Copper_Island_And_Remove_Insulated_Islands( BOARD
ic++ ) ic++ )
{ // test if this area is connected to a board item: { // test if this area is connected to a board item:
wxPoint pos = ListPointsCandidates[ic]; wxPoint pos = ListPointsCandidates[ic];
if( !bbox.Inside( pos ) ) if( !bbox.Contains( pos ) )
continue; continue;
if( TestPointInsidePolygon( if( TestPointInsidePolygon(
m_FilledPolysList, indexstart, m_FilledPolysList, indexstart,
......
...@@ -130,7 +130,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) ...@@ -130,7 +130,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
else else
continue; continue;
bool connected = false; bool connected = false;
if( bbox.Inside( pos1 ) ) if( bbox.Contains( pos1 ) )
{ {
if( TestPointInsidePolygon( curr_zone->m_FilledPolysList, indexstart, if( TestPointInsidePolygon( curr_zone->m_FilledPolysList, indexstart,
indexend, pos1.x, pos1.y ) ) indexend, pos1.x, pos1.y ) )
...@@ -138,7 +138,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) ...@@ -138,7 +138,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
} }
if( !connected && (pos1 != pos2 ) ) if( !connected && (pos1 != pos2 ) )
{ {
if( bbox.Inside( pos2 ) ) if( bbox.Contains( pos2 ) )
if( TestPointInsidePolygon( curr_zone->m_FilledPolysList, indexstart, if( TestPointInsidePolygon( curr_zone->m_FilledPolysList, indexstart,
indexend, pos2.x, pos2.y ) ) indexend, pos2.x, pos2.y ) )
connected = true; connected = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment