← Back to team overview

kicad-developers team mailing list archive

Re: Improving SCM behaviour of kicad_pcb

 

Sorry for not getting back to you earlier.

I did the changes back when BZR was being used and used the bzr/git gateway
thing, but now my git-fu is not advanced enough to apply the changes easily
to the copy I have checked out of git (the commit hashes are different).
The attached patches are based on quite an old version.

Anyways, here is the output of git-format-patch but based on that old
version.
If there is interest I could try to rebase the changes to the current
master.

"0001-Removed-separate..." is the one that removes the separate annotation
system used by the netlist and ERC commands.
Usually the "annotation required" dialog pops up if there are components
with missing references, but not if it's only power symbols.
With this change, it will pop up also if there are unannotated power
symbols.
I found this behavior much less intrusive than changing all power symbols
of all sheets when executing what I thought would be a read-only operation
on the schematic.

"0001-Eeschema-removed-clearing-..." removes another source of spurious
changes: when running the normal annotation command, power symbol
references were cleared and reannotated from scratch. However, the
annotation code knows how to handle power symbols just like normal
components, only annotating unannotated ones. With this change the clearing
step is removed and only new power symbols are annotated by the normal
annotation code.

If I'm not mistaken, this fixes LP bug
https://bugs.launchpad.net/kicad/+bug/1327986

Regards,
Joakim


On Thu, Jul 13, 2017 at 5:00 PM, Wayne Stambaugh <stambaughw@xxxxxxxxx>
wrote:

> Joakim,
>
> I was not aware that there were two different code paths for annotating
> power symbols.  I'm not sure why that is but your solution seems sound.
> Would you please make your source tree available or provide a patch of
> the changes so we can review it to see if makes sense to merge the
> changes into the master branch.  I'm sure a lot of users would like to
> see this change make it into KiCad.
>
> Cheers,
>
> Wayne
>
> On 7/12/2017 5:43 PM, Joakim Asplund wrote:
> > I found previously that there are two different pieces of code that
> > annotates the power symbols. One is the normal annotation code. The
> > other uses a completely different numbering scheme and runs silently
> > before DRC and netlist generation and renumbers all power symbols on all
> > open sheets. This caused lots of problems for us because even sheets we
> > hadn't touched changed and we were working on different sheets in
> > parallel using Git.
> >
> > Our workaround for a while was to run the normal annotation command
> > after generating the netlist, but now I instead use a modified branch of
> > Kicad where I have ripped out the alternative power symbols annotation
> > code (AnnotatePowerSymbols). I also removed the code which cleans out
> > all the power symbol references before the normal annotate
> > (ResetHiddenReferences). I couldn't see why it was needed because the
> > annotation code already knows how to assign only new references and
> > leave already-assigned references as they were.
> >
> > Regards
> > Joakim
> >
> > On Tue, Jul 11, 2017 at 8:14 AM, jp charras <jp.charras@xxxxxxxxxx
> > <mailto:jp.charras@xxxxxxxxxx>> wrote:
> >
> >     Le 10/07/2017 à 20:51, Wayne Stambaugh a écrit :
> >     > I'm not sure why power symbols would be re-annotated.  Maybe JP
> could
> >     > shed some light on this.  It does seem odd that power symbols are
> >     > annotated differently than non-power symbols.
> >
> >     There are 2 reasons:
> >     * silently annotating power symbols (that are frequently modified)
> >     avoids too frequently popup the
> >     annotate dialog (the early versions of Eeschema did not annotate
> >     silently power symbols, and this
> >     annotate dialog, only to annotate power symbols, was annoying and
> >     even strange).
> >     * reset the reference (not meaningful for users) of power symbols
> >     and rebuild it is just the easier
> >     way to update these reference, from the point of view of C++ code.
> >     Of course, this is not optimal from the point of view of SCM, but
> >     when this code was written, SCM
> >     was not used to manage schematic project files.
> >
> >     >
> >     > On 7/10/2017 2:06 PM, José Ignacio wrote:
> >     >> I've noticed another annoying churn in eeschema, when annotating
> the
> >     >> schematics power flags get re-annotated even if they already had
> refs
> >     >> assigned from before and the annotate command is not set to
> overwrite. I
> >     >> don't know if it does it all the time but it does it fairly often
> in my
> >     >> experience.
> >     >>
> >
> >
> >
> >     --
> >     Jean-Pierre CHARRAS
> >
> >     _______________________________________________
> >     Mailing list: https://launchpad.net/~kicad-developers
> >     <https://launchpad.net/~kicad-developers>
> >     Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> >     <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
> >     Unsubscribe : https://launchpad.net/~kicad-developers
> >     <https://launchpad.net/~kicad-developers>
> >     More help   : https://help.launchpad.net/ListHelp
> >     <https://help.launchpad.net/ListHelp>
> >
> >
> >
> >
> > _______________________________________________
> > Mailing list: https://launchpad.net/~kicad-developers
> > Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> > Unsubscribe : https://launchpad.net/~kicad-developers
> > More help   : https://help.launchpad.net/ListHelp
> >
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
>
From fabcda70b2b41f4a37f9ec9233f7500abbdcfc27 Mon Sep 17 00:00:00 2001
From: Joakim Asplund <joakimas@xxxxxx>
Date: Thu, 24 Sep 2015 03:29:21 +0200
Subject: [PATCH] Eeschema: removed clearing of hidden references on Annotate.
 (fixes lp:1327986)

This was one more source of spurious .sch file changes which made version control of Kicad projects
hard.
---
 eeschema/component_references_lister.cpp | 16 ----------------
 eeschema/sch_reference_list.h            |  7 -------
 2 files changed, 23 deletions(-)

diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp
index 6796ef3..11c1dd2 100644
--- a/eeschema/component_references_lister.cpp
+++ b/eeschema/component_references_lister.cpp
@@ -195,19 +195,6 @@ void SCH_REFERENCE_LIST::RemoveSubComponentsFromList()
 }
 
 
-void SCH_REFERENCE_LIST::ResetHiddenReferences()
-{
-    for( unsigned ii = 0; ii < componentFlatList.size(); ii++ )
-    {
-        if( componentFlatList[ii].GetRefStr()[0] == '#' )
-        {
-            componentFlatList[ii].m_IsNew  = true;
-            componentFlatList[ii].m_NumRef = 0;
-        }
-    }
-}
-
-
 void SCH_REFERENCE_LIST::GetRefsInUse( int aIndex, std::vector< int >& aIdList, int aMinRefId )
 {
     aIdList.clear();
@@ -294,9 +281,6 @@ void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId,
     int LastReferenceNumber = 0;
     int NumberOfUnits, Unit;
 
-    // Components with an invisible reference (power...) always are re-annotated.
-    ResetHiddenReferences();
-
     /* calculate index of the first component with the same reference prefix
      * than the current component.  All components having the same reference
      * prefix will receive a reference number with consecutive values:
diff --git a/eeschema/sch_reference_list.h b/eeschema/sch_reference_list.h
index d5048cb..c83adf4 100644
--- a/eeschema/sch_reference_list.h
+++ b/eeschema/sch_reference_list.h
@@ -411,13 +411,6 @@ public:
     int FindUnit( size_t aIndex, int aUnit );
 
     /**
-     * Function ResetHiddenReferences
-     * clears the annotation for all references that have an invisible reference designator.
-     * Invisible reference designators always have # as the first letter.
-     */
-    void ResetHiddenReferences();
-
-    /**
      * Function GetRefsInUse
      * adds all the reference designator numbers greater than \a aMinRefId to \a aIdList
      * skipping the reference at \a aIndex.
-- 
1.9.1

From f77469073bff7cc581c367ec48d02f0f49acee7a Mon Sep 17 00:00:00 2001
From: Joakim Asplund <joakimas@xxxxxx>
Date: Thu, 24 Sep 2015 03:11:23 +0200
Subject: [PATCH] Removed separate annotation system for power symbols that
 made version control of Kicad schematic files difficult. All schematic files
 in a project would change almost everywhere dependent on which of the Netlist
 (ran the removed annotation system) and Annotate (performs a regular
 annotation) commands was run last before saving.

---
 eeschema/dialogs/dialog_erc.cpp |  4 ----
 eeschema/netlist.cpp            |  4 ----
 eeschema/sch_sheet_path.cpp     | 46 -----------------------------------------
 eeschema/sch_sheet_path.h       | 18 ----------------
 4 files changed, 72 deletions(-)

diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp
index c6792ea..3389cc8 100644
--- a/eeschema/dialogs/dialog_erc.cpp
+++ b/eeschema/dialogs/dialog_erc.cpp
@@ -440,10 +440,6 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
 
     m_writeErcFile = m_WriteResultOpt->GetValue();
 
-    // Build the whole sheet list in hierarchy (sheet, not screen)
-    SCH_SHEET_LIST sheets;
-    sheets.AnnotatePowerSymbols( Prj().SchLibs() );
-
     if( m_parent->CheckAnnotate( aMessagesList, false ) )
     {
         if( aMessagesList )
diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp
index 3a4c61f..f382b75 100644
--- a/eeschema/netlist.cpp
+++ b/eeschema/netlist.cpp
@@ -56,10 +56,6 @@ int TestDuplicateSheetNames( bool aCreateMarker );
 
 bool SCH_EDIT_FRAME::prepareForNetlist()
 {
-    SCH_SHEET_LIST sheets;
-
-    sheets.AnnotatePowerSymbols( Prj().SchLibs() );
-
     // Performs some controls:
     if( CheckAnnotate( NULL, 0 ) )
     {
diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp
index 52027e3..ee81083 100644
--- a/eeschema/sch_sheet_path.cpp
+++ b/eeschema/sch_sheet_path.cpp
@@ -245,43 +245,6 @@ void SCH_SHEET_PATH::UpdateAllScreenReferences()
 }
 
 
-void SCH_SHEET_PATH::AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference )
-{
-    int ref = 1;
-
-    if( aReference )
-        ref = *aReference;
-
-    for( EDA_ITEM* item = LastDrawList();  item;  item = item->Next() )
-    {
-        if( item->Type() != SCH_COMPONENT_T )
-                continue;
-
-        SCH_COMPONENT*  component = (SCH_COMPONENT*) item;
-        LIB_PART*       part = aLibs->FindLibPart( component->GetPartName() );
-
-        if( !part || !part->IsPower() )
-            continue;
-
-        wxString refstr = component->GetPrefix();
-
-        //str will be "C?" or so after the ClearAnnotation call.
-        while( refstr.Last() == '?' )
-            refstr.RemoveLast();
-
-        if( !refstr.StartsWith( wxT( "#" ) ) )
-            refstr = wxT( "#" ) + refstr;
-
-        refstr << wxT( "0" ) << ref;
-        component->SetRef( this, refstr );
-        ref++;
-    }
-
-    if( aReference )
-        *aReference = ref;
-}
-
-
 void SCH_SHEET_PATH::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols )
 {
     // Search to sheet path number:
@@ -718,15 +681,6 @@ void SCH_SHEET_LIST::ClearModifyStatus()
 }
 
 
-void SCH_SHEET_LIST::AnnotatePowerSymbols( PART_LIBS* aLibs )
-{
-    int ref = 1;
-
-    for( SCH_SHEET_PATH* path = GetFirst();  path;  path = GetNext() )
-        path->AnnotatePowerSymbols( aLibs, &ref );
-}
-
-
 void SCH_SHEET_LIST::GetComponents( PART_LIBS* aLibs, SCH_REFERENCE_LIST& aReferences,
         bool aIncludePowerSymbols )
 {
diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h
index 939d899..b322d59 100644
--- a/eeschema/sch_sheet_path.h
+++ b/eeschema/sch_sheet_path.h
@@ -227,17 +227,6 @@ public:
     void UpdateAllScreenReferences();
 
     /**
-     * Function AnnotatePowerSymbols
-     * annotates the power symbols only starting at \a aReference in the sheet path.
-     * @param aLibs the library list to use
-     * @param aReference A pointer to the number for the reference designator of the
-     *                   first power symbol to be annotated.  If the pointer is NULL
-     *                   the annotation starts at 1.  The number is incremented for
-     *                   each power symbol annotated.
-     */
-    void AnnotatePowerSymbols( PART_LIBS* aLibs, int* aReference );
-
-    /**
      * Function GetComponents
      * adds a SCH_REFERENCE() object to \a aReferences for each component in the sheet.
      * @param aLibs the library list to use
@@ -453,13 +442,6 @@ public:
     void ClearModifyStatus();
 
     /**
-     * Function AnnotatePowerSymbols
-     * clear and annotates the entire hierarchy of the sheet path list.
-     * @param aLib the library list to use
-     */
-    void AnnotatePowerSymbols( PART_LIBS* aLib );
-
-    /**
      * Function GetComponents
      * adds a SCH_REFERENCE() object to \a aReferences for each component in the list
      * of sheets.
-- 
1.9.1


Follow ups

References