Commit 175fab48 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

EESchema multiple item hit testing and other minor improvements.

* Add item clarification context menu to EESchema when multiple unresolved
  items are found at the current cross hair position.
* Add collector class SCH_COLLECTOR for supporting multiple item hit testing.
* Removed bit wise masked filtering from schematic item hit testing.
* Removed all old hit testing functions and methods scattered about the
  EESchema source code.
* Move terminal point test function into SCH_SCREEN object.
* Fixed bug in terminal point test when terminating a bus to a label.
* Define the < operator for sorting schematic items.
* Add area calculation method to EDA_Rect item.
* Add method for returning an item's bitmap for menu display purposes.
* Add method for returning an item's menu text for menu display purposes.
* Changed EDA_ITEMS container from boost::ptr_vector to std::vector.
* Factor coordinate string conversion code from EDA_DRAW_FRAME to function
  CoordinateToString().
parents 5f6cd454 628f874c
Loading
Loading
Loading
Loading
+16 −0
Original line number Original line Diff line number Diff line
@@ -125,6 +125,16 @@ SEARCH_RESULT EDA_ITEM::Visit( INSPECTOR* inspector, const void* testData,
    return SEARCH_CONTINUE;
    return SEARCH_CONTINUE;
}
}



wxString EDA_ITEM::GetSelectMenuText() const
{
    wxFAIL_MSG( wxT( "GetSelectMenuText() was not overridden for schematic item type " ) +
                GetClass() );

    return wxString( wxT( "Undefined menu text for " ) + GetClass() );
}


#if defined(DEBUG)
#if defined(DEBUG)




@@ -637,3 +647,9 @@ void EDA_Rect::Merge( const wxPoint& aPoint )
    end.y   = MAX( end.y, aPoint.y );
    end.y   = MAX( end.y, aPoint.y );
    SetEnd( end );
    SetEnd( end );
}
}


double EDA_Rect::GetArea() const
{
    return (double) GetWidth() * (double) GetHeight();
}
+41 −0
Original line number Original line Diff line number Diff line
@@ -708,6 +708,47 @@ const wxString& valeur_param( int valeur, wxString& buf_texte )
}
}






wxString CoordinateToString( int aValue, int aInternalUnits, bool aConvertToMils )
{
    wxCHECK_MSG( (aInternalUnits == EESCHEMA_INTERNAL_UNIT)
                 || (aInternalUnits == PCB_INTERNAL_UNIT),
                 wxString( _( "*** Bad Internal Units ***" ) ),
                 wxT( "Invalid interanl units value." ) );

    wxString      text;
    const wxChar* format;
    double        value = To_User_Unit( g_UserUnit, aValue, aInternalUnits );

    if( g_UserUnit == INCHES )
    {
        if( aConvertToMils )
        {
            format = ( aInternalUnits == EESCHEMA_INTERNAL_UNIT ) ? wxT( "%.0f" ) : wxT( "%.1f" );
            value *= 1000;
        }
        else
        {
            format = ( aInternalUnits == EESCHEMA_INTERNAL_UNIT ) ? wxT( "%.3f" ) : wxT( "%.4f" );
        }
    }
    else
    {
        format = ( aInternalUnits == EESCHEMA_INTERNAL_UNIT ) ? wxT( "%.2f" ) : wxT( "%.3f" );
    }

    text.Printf( format, value );

    if( g_UserUnit == INCHES )
        text += ( aConvertToMils ) ? _( " mils" ) : _( " in" );
    else
        text += _( " mm" );

    return text;
}


/*
/*
 *
 *
 */
 */
+1 −1
Original line number Original line Diff line number Diff line
@@ -41,7 +41,7 @@ dialog_about::dialog_about(wxWindow *parent, AboutAppInfo& appInfo)
    CreateNotebooks();
    CreateNotebooks();
    GetSizer()->SetSizeHints(this);
    GetSizer()->SetSizeHints(this);
    m_auiNotebook->Update();
    m_auiNotebook->Update();

    SetFocus();
    Centre();
    Centre();
}
}


+1 −29
Original line number Original line Diff line number Diff line
@@ -808,33 +808,5 @@ void EDA_DRAW_FRAME::ClearMsgPanel( void )


wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool aConvertToMils )
wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool aConvertToMils )
{
{
    wxString      text;
    return ::CoordinateToString( aValue, m_InternalUnits, aConvertToMils );
    const wxChar* format;
    double        value = To_User_Unit( g_UserUnit, aValue, m_InternalUnits );

    if( g_UserUnit == INCHES )
    {
        if( aConvertToMils )
        {
            format = ( m_InternalUnits == EESCHEMA_INTERNAL_UNIT ) ? wxT( "%.0f" ) : wxT( "%.1f" );
            value *= 1000;
        }
        else
        {
            format = ( m_InternalUnits == EESCHEMA_INTERNAL_UNIT ) ? wxT( "%.3f" ) : wxT( "%.4f" );
        }
    }
    else
    {
        format = ( m_InternalUnits == EESCHEMA_INTERNAL_UNIT ) ? wxT( "%.2f" ) : wxT( "%.3f" );
    }

    text.Printf( format, value );

    if( g_UserUnit == INCHES )
        text += ( aConvertToMils ) ? _( " mils" ) : _( " in" );
    else
        text += _( " mm" );

    return text;
}
}
+16 −3
Original line number Original line Diff line number Diff line
@@ -17,6 +17,12 @@
#include "../eeschema/dialogs/dialog_schematic_find.h"
#include "../eeschema/dialogs/dialog_schematic_find.h"




bool sort_schematic_items( const SCH_ITEM* aItem1, const SCH_ITEM* aItem2 )
{
    return *aItem1 < *aItem2;
}


/* Constructor and destructor for SCH_ITEM */
/* Constructor and destructor for SCH_ITEM */
/* They are not inline because this creates problems with gcc at linking time
/* They are not inline because this creates problems with gcc at linking time
 * in debug mode
 * in debug mode
@@ -38,18 +44,18 @@ SCH_ITEM::SCH_ITEM( const SCH_ITEM& aItem ) :


SCH_ITEM::~SCH_ITEM()
SCH_ITEM::~SCH_ITEM()
{
{
    // Do not let the connections container go out of scope with any ojbects or they
    // Do not let the connections container go out of scope with any objects or they
    // will be deleted by the container will cause the EESchema to crash.  These objects
    // will be deleted by the container will cause the EESchema to crash.  These objects
    // are owned by the sheet object container.
    // are owned by the sheet object container.
    if( !m_connections.empty() )
    if( !m_connections.empty() )
        m_connections.release();
        m_connections.clear();
}
}




/**
/**
 * place the struct in m_drawList.
 * place the struct in m_drawList.
 * if it is a new item, it it also put in undo list
 * if it is a new item, it it also put in undo list
 * for an "old" item, saving it in undo list must be done before editiing,
 * for an "old" item, saving it in undo list must be done before editing,
 * and not here!
 * and not here!
 */
 */
void SCH_ITEM::Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC )
void SCH_ITEM::Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC )
@@ -108,3 +114,10 @@ bool SCH_ITEM::IsConnected( const wxPoint& aPosition ) const


    return doIsConnected( aPosition );
    return doIsConnected( aPosition );
}
}


bool SCH_ITEM::operator < ( const SCH_ITEM& aItem ) const
{
    wxCHECK_MSG( false, this->Type() < aItem.Type(),
                 wxT( "Less than operator not defined for " ) + GetClass() );
}
Loading