Commit 6b7ab761 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Add drag context menu entry for junctions in EESchema, fixes lp:783173.

* Add drag context menu entry for junctions that actually form a junction
  with wires to EESchema.
* Add function to test for junctions to SCH_COLLECTOR class.
* Create annotate type and sort order enums to eliminate magic numbers
  used in annotate code.
* Remove duplicate Doxygen comments from annotate.cpp and improve the
  actual Doxygen comments in wxEeschemaStruct.h.
parent f81c237d
Loading
Loading
Loading
Loading
+13 −57
Original line number Diff line number Diff line
@@ -20,12 +20,6 @@
#include "lib_pin.h"


/**
 * Function DeleteAnnotation
 * Remove current component annotations
 * @param aCurrentSheetOnly : if false: remove all annotations, else remove
 *                             annotation relative to the current sheet only
 */
void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly )
{
    if( aCurrentSheetOnly )
@@ -45,36 +39,11 @@ void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly )
}


/**
 * Function AnnotateComponents:
 *
 *  Compute the annotation of the components for the whole project, or the
 *  current sheet only.  All the components or the new ones only will be
 *  annotated.
 * @param aAnnotateSchematic : true = entire schematic annotation,
 *                            false = current sheet only
 * @param aSortOption : 0 = annotate by sorting X position,
 *                      1 = annotate by sorting Y position,
 *                      2 = annotate by sorting value
 * @param aAlgoOption : 0 = annotate schematic using first free Id number
 *                      1 = annotate using first free Id number, starting to sheet number * 100
 *                      2 = annotate  using first free Id number, starting to sheet number * 1000
 * @param aResetAnnotation : true = remove previous annotation
 *                          false = annotate new components only
 * @param aRepairsTimestamps : true = test for duplicate times stamps and
 *                                   replace duplicated
 *        Note: this option could change previous annotation, because time
 *              stamps are used to handle annotation mainly in complex
 *              hierarchies.
 * When the sheet number is used in annotation,
 *      for each sheet annotation starts from sheet number * 100
 *      ( the first sheet uses 100 to 199, the second 200 to 299 ... )
 */
void SCH_EDIT_FRAME::AnnotateComponents( bool              aAnnotateSchematic,
                                         int  aSortOption,
                                         int  aAlgoOption,
                                         ANNOTATE_ORDER_T  aSortOption,
                                         ANNOTATE_OPTION_T aAlgoOption,
                                         bool              aResetAnnotation,
                                         bool aRepairsTimestamps )
                                         bool              aRepairTimestamps )
{
    SCH_REFERENCE_LIST references;

@@ -82,13 +51,13 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,

    SCH_SCREENS screens;

    /* Build the sheet list */
    // Build the sheet list.
    SCH_SHEET_LIST sheets;

    // Test for and replace duplicate time stamps in components and sheets.  Duplicate
    // time stamps can happen with old schematics, schematic conversions, or manual
    // editing of files.
    if( aRepairsTimestamps )
    if( aRepairTimestamps )
    {
        int count = screens.ReplaceDuplicateTimeStamps();

@@ -127,11 +96,11 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
    switch( aSortOption )
    {
    default:
    case 0:
    case SORT_BY_X_POSITION:
        references.SortByXCoordinate();
        break;

    case 1:
    case SORT_BY_Y_POSITION:
        references.SortByYCoordinate();
        break;
    }
@@ -142,14 +111,14 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
    switch( aAlgoOption )
    {
    default:
    case 0:
    case INCREMENTAL_BY_REF:
        break;

    case 1:
    case SHEET_NUMBER_X_100:
        useSheetNum = true;
        break;

    case 2:
    case SHEET_NUMBER_X_1000:
        useSheetNum = true;
        idStep = 1000;
        break;
@@ -161,7 +130,7 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,

    wxArrayString errors;

    /* Final control (just in case ... )*/
    // Final control (just in case ... ).
    if( CheckAnnotate( &errors, !aAnnotateSchematic ) )
    {
        wxString msg;
@@ -185,19 +154,6 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
}


/**
 * Function CheckAnnotate
 *  Check errors relatives to annotation:
 *      components not annotated
 *      components having the same reference (duplicates)
 *      for multiple parts per package components :
 *          part number > number of parts
 *          different values between parts
 * @param aMessageList = a wxArrayString to store messages.
 * @param aOneSheetOnly : true = search is made only in the current sheet
 *                        false = search in whole hierarchy (usual search).
 * @return errors count
 */
int SCH_EDIT_FRAME::CheckAnnotate( wxArrayString* aMessageList, bool aOneSheetOnly )
{
    /* build the screen list */
+2 −1
Original line number Diff line number Diff line
@@ -118,7 +118,8 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, const KICAD_T aF
            switch( aHotKeyCommandId )
            {
            case HK_DRAG:
                if( m_collectedItems.IsCorner() || m_collectedItems.IsNode( false ) )
                if( m_collectedItems.IsCorner() || m_collectedItems.IsNode( false )
                    || m_collectedItems.IsDraggableJunction() )
                {
                    item = m_collectedItems[0];
                    GetScreen()->SetCurItem( item );
+2 −1
Original line number Diff line number Diff line
@@ -135,7 +135,8 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event )
    if (response == wxCANCEL)
        return;

    m_Parent->AnnotateComponents( GetLevel(), GetSortOrder(), GetAnnotateAlgo(),
    m_Parent->AnnotateComponents( GetLevel(), (ANNOTATE_ORDER_T) GetSortOrder(),
                                  (ANNOTATE_OPTION_T) GetAnnotateAlgo(),
                                  GetResetItems() , true );
    m_Parent->DrawPanel->Refresh();

+1 −1
Original line number Diff line number Diff line
@@ -696,6 +696,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,

            case SCH_BUS_ENTRY_T:
            case SCH_LINE_T:
            case SCH_JUNCTION_T:
                if( ((SCH_ITEM*) aItem )->GetLayer() != LAYER_BUS )
                {
                    cmd.SetId( ID_POPUP_SCH_DRAG_WIRE_REQUEST );
@@ -711,7 +712,6 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,

        break;


    case HK_MOVE_COMPONENT_OR_ITEM:         // Start move component or other schematic item
        if( itemInEdit )
            break;
+15 −14
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ static void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel );
static void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* GLabel );
static void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component );
static void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field );
static void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, SCH_EDIT_FRAME* frame );
static void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_FRAME* aFrame );


@@ -118,7 +117,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
        break;

    case SCH_JUNCTION_T:
        AddMenusForJunction( PopMenu, (SCH_JUNCTION*) item, this );
        addJunctionMenuEntries( PopMenu, (SCH_JUNCTION*) item );
        break;

    case SCH_BUS_ENTRY_T:
@@ -465,25 +464,27 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
}


void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, SCH_EDIT_FRAME* frame )
void SCH_EDIT_FRAME::addJunctionMenuEntries( wxMenu* aMenu, SCH_JUNCTION* aJunction )
{
    bool     is_new = Junction->IsNew();
    SCH_SCREEN* screen = frame->GetScreen();
    wxString msg;
    SCH_SCREEN* screen = GetScreen();

    msg = AddHotkeyName( _( "Delete Junction" ), s_Schematic_Hokeys_Descr, HK_DELETE );
    ADD_MENUITEM( aMenu, ID_POPUP_SCH_DELETE, msg, delete_xpm );

    if( !is_new )
    if( !aJunction->IsNew() )
    {
        if( screen->GetWire( screen->GetCrossHairPosition(), EXCLUDE_END_POINTS_T ) )
            ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm );
    }
        if( m_collectedItems.IsDraggableJunction() )
            ADD_MENUITEM( aMenu, ID_POPUP_SCH_DRAG_WIRE_REQUEST, _( "Drag Junction" ), move_xpm );

    msg = AddHotkeyName( _( "Delete Junction" ), s_Schematic_Hokeys_Descr, HK_DELETE );
    ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg, delete_xpm );
        if( screen->GetWire( aJunction->m_Pos, EXCLUDE_END_POINTS_T ) )
            ADD_MENUITEM( aMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm );
    }

    if( screen->GetWireOrBus( screen->GetCrossHairPosition() ) )
    if( screen->GetWireOrBus( aJunction->m_Pos ) )
    {
        ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ), delete_node_xpm );
        ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
        ADD_MENUITEM( aMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ), delete_node_xpm );
        ADD_MENUITEM( aMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
                      delete_connection_xpm );
    }
}
Loading