Commit 74154480 authored by unknown's avatar unknown Committed by jean-pierre charras
Browse files

Eeschema enhancements: Option to annotate keeping multi-unit parts grouped and...

Eeschema enhancements: Option to annotate keeping multi-unit parts grouped and friendlier warning for modifying power values.
parent 9c43d6f2
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#include <sch_component.h>
#include <lib_pin.h>

#include <boost/foreach.hpp>

void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly )
{
@@ -62,7 +63,8 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
                                         ANNOTATE_ORDER_T  aSortOption,
                                         ANNOTATE_OPTION_T aAlgoOption,
                                         bool              aResetAnnotation,
                                         bool              aRepairTimestamps )
                                         bool              aRepairTimestamps,
                                         bool              aLockUnits )
{
    SCH_REFERENCE_LIST references;

@@ -73,6 +75,9 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
    // Build the sheet list.
    SCH_SHEET_LIST sheets;

    // Map of locked components
    SCH_MULTI_UNIT_REFERENCE_MAP lockedComponents;

    // 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.
@@ -88,6 +93,19 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
        }
    }

    // If units must be locked, collect all the sets that must be annotated together.
    if( aLockUnits )
    {
        if( aAnnotateSchematic )
        {
            sheets.GetMultiUnitComponents( Prj().SchLibs(), lockedComponents );
        }
        else
        {
            m_CurrentSheet->GetMultiUnitComponents( Prj().SchLibs(), lockedComponents );
        }
    }

    // If it is an annotation for all the components, reset previous annotation.
    if( aResetAnnotation )
        DeleteAnnotation( !aAnnotateSchematic );
@@ -141,7 +159,7 @@ void SCH_EDIT_FRAME::AnnotateComponents( bool aAnnotateSchematic,
    }

    // Recalculate and update reference numbers in schematic
    references.Annotate( useSheetNum, idStep );
    references.Annotate( useSheetNum, idStep, lockedComponents );
    references.UpdateAnnotation();

    wxArrayString errors;
+86 −32
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@
#include <sch_reference_list.h>
#include <sch_component.h>

#include <boost/foreach.hpp>


//#define USE_OLD_ALGO

@@ -283,7 +285,8 @@ int SCH_REFERENCE_LIST::CreateFirstFreeRefId( std::vector<int>& aIdList, int aFi
}


void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId  )
void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
      SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap )
{
    if ( componentFlatList.size() == 0 )
        return;
@@ -327,6 +330,24 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
        if( componentFlatList[ii].m_Flag )
            continue;

        // Check whether this component is in aLockedUnitMap.
        SCH_REFERENCE_LIST* lockedList = NULL;
        BOOST_FOREACH( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair, aLockedUnitMap )
        {
            unsigned n_refs = pair.second.GetCount();
            for( unsigned thisRefI = 0; thisRefI < n_refs; ++thisRefI )
            {
                SCH_REFERENCE &thisRef = pair.second[thisRefI];

                if( thisRef.IsSameInstance( componentFlatList[ii] ) )
                {
                    lockedList = &pair.second;
                    break;
                }
            }
            if( lockedList != NULL ) break;
        }

        if(  ( componentFlatList[first].CompareRef( componentFlatList[ii] ) != 0 )
          || ( aUseSheetNum && ( componentFlatList[first].m_SheetNum != componentFlatList[ii].m_SheetNum ) )  )
        {
@@ -388,6 +409,38 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
            componentFlatList[ii].m_Flag = 1;
        }

        // If this component is in aLockedUnitMap, copy the annotation to all
        // components that are not it
        if( lockedList != NULL )
        {
            unsigned n_refs = lockedList->GetCount();
            for( unsigned thisRefI = 0; thisRefI < n_refs; ++thisRefI )
            {
                SCH_REFERENCE &thisRef = (*lockedList)[thisRefI];
                if( thisRef.IsSameInstance( componentFlatList[ii] ) )
                {
                    // This is the component we're currently annotating. Hold the unit!
                    componentFlatList[ii].m_Unit = thisRef.m_Unit;
                }

                if( thisRef.CompareValue( componentFlatList[ii] ) != 0 ) continue;
                if( thisRef.CompareLibName( componentFlatList[ii] ) != 0 ) continue;

                // Find the matching component
                for( unsigned jj = ii + 1; jj < componentFlatList.size(); jj++ )
                {
                    if( ! thisRef.IsSameInstance( componentFlatList[jj] ) ) continue;
                    componentFlatList[jj].m_NumRef = componentFlatList[ii].m_NumRef;
                    componentFlatList[jj].m_Unit = thisRef.m_Unit;
                    componentFlatList[jj].m_IsNew = false;
                    componentFlatList[jj].m_Flag = 1;
                    break;
                }
            }
        }

        else
        {
            /* search for others units of this component.
            * we search for others parts that have the same value and the same
            * reference prefix (ref without ref number)
@@ -434,6 +487,7 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId )
            }
        }
    }
}


int SCH_REFERENCE_LIST::CheckAnnotation( wxArrayString* aMessageList )
+7 −2
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ private:
    // User functions:
    bool GetLevel();
    bool GetResetItems();
    bool GetLockUnits();

    /**
     * Function GetSortOrder
@@ -212,7 +213,7 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event )

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

    m_btnClear->Enable();
@@ -273,9 +274,13 @@ bool DIALOG_ANNOTATE::GetLevel()

bool DIALOG_ANNOTATE::GetResetItems()
{
    return m_rbResetAnnotation->GetValue();
    return m_rbResetAnnotation->GetValue() || m_rbResetButLock->GetValue();
}

bool DIALOG_ANNOTATE::GetLockUnits()
{
    return m_rbResetButLock->GetValue();
}

int DIALOG_ANNOTATE::GetSortOrder()
{
+4 −1
Original line number Diff line number Diff line
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun  6 2014)
// C++ code generated with wxFormBuilder (version Mar 13 2015)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@@ -43,6 +43,9 @@ DIALOG_ANNOTATE_BASE::DIALOG_ANNOTATE_BASE( wxWindow* parent, wxWindowID id, con
	m_rbResetAnnotation = new wxRadioButton( this, ID_RESET_ANNOTATION, _("&Reset existing annotation"), wxDefaultPosition, wxDefaultSize, 0 );
	bscopeOptSizer->Add( m_rbResetAnnotation, 0, wxALL, 3 );
	
	m_rbResetButLock = new wxRadioButton( this, ID_RESET_BUT_LOCK, _("R&eset, but do not swap any annotated multi-unit parts"), wxDefaultPosition, wxDefaultSize, 0 );
	bscopeOptSizer->Add( m_rbResetButLock, 0, wxALL, 3 );
	
	
	bupperSizer->Add( bscopeOptSizer, 0, wxEXPAND|wxLEFT|wxALIGN_RIGHT, 25 );
	
+88 −0
Original line number Diff line number Diff line
@@ -627,6 +627,94 @@
                                        <event name="OnUpdateUI"></event>
                                    </object>
                                </object>
                                <object class="sizeritem" expanded="1">
                                    <property name="border">3</property>
                                    <property name="flag">wxALL</property>
                                    <property name="proportion">0</property>
                                    <object class="wxRadioButton" expanded="1">
                                        <property name="BottomDockable">1</property>
                                        <property name="LeftDockable">1</property>
                                        <property name="RightDockable">1</property>
                                        <property name="TopDockable">1</property>
                                        <property name="aui_layer"></property>
                                        <property name="aui_name"></property>
                                        <property name="aui_position"></property>
                                        <property name="aui_row"></property>
                                        <property name="best_size"></property>
                                        <property name="bg"></property>
                                        <property name="caption"></property>
                                        <property name="caption_visible">1</property>
                                        <property name="center_pane">0</property>
                                        <property name="close_button">1</property>
                                        <property name="context_help"></property>
                                        <property name="context_menu">1</property>
                                        <property name="default_pane">0</property>
                                        <property name="dock">Dock</property>
                                        <property name="dock_fixed">0</property>
                                        <property name="docking">Left</property>
                                        <property name="enabled">1</property>
                                        <property name="fg"></property>
                                        <property name="floatable">1</property>
                                        <property name="font"></property>
                                        <property name="gripper">0</property>
                                        <property name="hidden">0</property>
                                        <property name="id">ID_RESET_BUT_LOCK</property>
                                        <property name="label">R&amp;eset, but do not swap any annotated multi-unit parts</property>
                                        <property name="max_size"></property>
                                        <property name="maximize_button">0</property>
                                        <property name="maximum_size"></property>
                                        <property name="min_size"></property>
                                        <property name="minimize_button">0</property>
                                        <property name="minimum_size"></property>
                                        <property name="moveable">1</property>
                                        <property name="name">m_rbResetButLock</property>
                                        <property name="pane_border">1</property>
                                        <property name="pane_position"></property>
                                        <property name="pane_size"></property>
                                        <property name="permission">protected</property>
                                        <property name="pin_button">1</property>
                                        <property name="pos"></property>
                                        <property name="resize">Resizable</property>
                                        <property name="show">1</property>
                                        <property name="size"></property>
                                        <property name="style"></property>
                                        <property name="subclass"></property>
                                        <property name="toolbar_pane">0</property>
                                        <property name="tooltip"></property>
                                        <property name="validator_data_type"></property>
                                        <property name="validator_style">wxFILTER_NONE</property>
                                        <property name="validator_type">wxDefaultValidator</property>
                                        <property name="validator_variable"></property>
                                        <property name="value">0</property>
                                        <property name="window_extra_style"></property>
                                        <property name="window_name"></property>
                                        <property name="window_style"></property>
                                        <event name="OnChar"></event>
                                        <event name="OnEnterWindow"></event>
                                        <event name="OnEraseBackground"></event>
                                        <event name="OnKeyDown"></event>
                                        <event name="OnKeyUp"></event>
                                        <event name="OnKillFocus"></event>
                                        <event name="OnLeaveWindow"></event>
                                        <event name="OnLeftDClick"></event>
                                        <event name="OnLeftDown"></event>
                                        <event name="OnLeftUp"></event>
                                        <event name="OnMiddleDClick"></event>
                                        <event name="OnMiddleDown"></event>
                                        <event name="OnMiddleUp"></event>
                                        <event name="OnMotion"></event>
                                        <event name="OnMouseEvents"></event>
                                        <event name="OnMouseWheel"></event>
                                        <event name="OnPaint"></event>
                                        <event name="OnRadioButton"></event>
                                        <event name="OnRightDClick"></event>
                                        <event name="OnRightDown"></event>
                                        <event name="OnRightUp"></event>
                                        <event name="OnSetFocus"></event>
                                        <event name="OnSize"></event>
                                        <event name="OnUpdateUI"></event>
                                    </object>
                                </object>
                            </object>
                        </object>
                        <object class="sizeritem" expanded="1">
Loading