Re: [Kicad-developers] [PATCH] Option in eeschema to annotate keeping multi-unit parts grouped

2015-03-22 Thread jp charras
Le 22/03/2015 03:18, Chris Pavlina a écrit :
 Here is a fixed version of the patch. It handled perfectly any complex
 hierarchies I could throw at it. Got anything worse to torture it with?
 
 Chris

Better, but not yet perfect...

There is an issue for units of a package which are on different sheets
(both simple and complex hierarchies).
The normal annotation use only one package:
For instance unit A of package U1 is in a sheet, unit B of the same
package U1 is on an other sheet.
The do not swap units uses one package per sheet (U1A for a sheet, but
U2B for the other sheet).

-- 
Jean-Pierre CHARRAS

___
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp


Re: [Kicad-developers] [PATCH] Option in eeschema to annotate keeping multi-unit parts grouped

2015-03-22 Thread Chris Pavlina
Got it - fixed. Looks like I was a bit overzealous in correcting the 
first patch and introduced this.


I also found another issue - it didn't treat unannotated parts 
differently, so if you had a schematic full of R?A it would try to make 
them all R1A. Also fixed.


I can't think of anything else to test. I tried it on every combination 
of hierarchical nastiness I could and it worked fine. Here's the latest 
version, and final if you also can't think of anything else.


Thanks,
Chris

On Sun, Mar 22, 2015 at 04:06:57PM +0100, jp charras wrote:

Le 22/03/2015 03:18, Chris Pavlina a écrit :

Here is a fixed version of the patch. It handled perfectly any complex
hierarchies I could throw at it. Got anything worse to torture it with?

Chris


Better, but not yet perfect...

There is an issue for units of a package which are on different sheets
(both simple and complex hierarchies).
The normal annotation use only one package:
For instance unit A of package U1 is in a sheet, unit B of the same
package U1 is on an other sheet.
The do not swap units uses one package per sheet (U1A for a sheet, but
U2B for the other sheet).

--
Jean-Pierre CHARRAS

___
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp
diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp
index 3fccb8e..f041fe3 100644
--- a/eeschema/annotate.cpp
+++ b/eeschema/annotate.cpp
@@ -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;
diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp
index 15eb9e6..6796ef3 100644
--- a/eeschema/component_references_lister.cpp
+++ b/eeschema/component_references_lister.cpp
@@ -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::vectorint 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  

Re: [Kicad-developers] [PATCH] Option in eeschema to annotate keeping multi-unit parts grouped

2015-03-21 Thread Chris Pavlina
Ah, thank you for having a look. Yes, I clearly missed this use case. 
D'oh...


I'll submit a new patch in a couple days that handles this. Any interest 
in including it if I get it working properly?


Chris


On Sat, Mar 21, 2015 at 04:44:43PM +0100, jp charras wrote:

Thank for your contribution.
This is a very interesting feature.

I tested it on different schematic projects.

It works fine only for simple hierarchies.
Unfortunately, it does not work on complex hierarchies.
These hierarchies uses more than once a given sheet: there is one file,
one schematic, and several instances.
the sheet which is used more than once stores only one drawing, but n
different references when it is used n times.

For instance demos/complex_hierarchy project.

Be *extremely careful with complex hierarchies.
Complex hierarchies are always a very tricky case, and are never easy to
handle.


--
Jean-Pierre CHARRAS

___
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp


___
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp


Re: [Kicad-developers] [PATCH] Option in eeschema to annotate keeping multi-unit parts grouped

2015-03-21 Thread Chris Pavlina
Here is a fixed version of the patch. It handled perfectly any complex 
hierarchies I could throw at it. Got anything worse to torture it with?


Chris

On Sat, Mar 21, 2015 at 04:44:43PM +0100, jp charras wrote:

Le 14/03/2015 00:11, Chris Pavlina a écrit :

Hello,

Here is a patch for eeschema that adds Reset existing annotation, but
do not swap any units to eeschema. This first compiles a list of
multi-unit parts and all of the components that comprise them, and then
on annotation, annotates all of them as a group. For example, if
components were originally R3B and R3C, they can be annotated to R5B and
R5C, but never R5B and R6C, or R5A and R5D.

I wanted this feature so that I could re-annotate a project to tidy up
the references, while not losing symbol-footprint mappings that already
exist in a routed PCB.

Perhaps, I'll follow up in a few days with a patch to follow through the
annotations to the other files in the project. (Currently I'm using a
hacked-together Python script for this...)


Chris


Thank for your contribution.
This is a very interesting feature.

I tested it on different schematic projects.

It works fine only for simple hierarchies.
Unfortunately, it does not work on complex hierarchies.
These hierarchies uses more than once a given sheet: there is one file,
one schematic, and several instances.
the sheet which is used more than once stores only one drawing, but n
different references when it is used n times.

For instance demos/complex_hierarchy project.

Be *extremely careful with complex hierarchies.
Complex hierarchies are always a very tricky case, and are never easy to
handle.


--
Jean-Pierre CHARRAS

___
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp
diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp
index 3fccb8e..f041fe3 100644
--- a/eeschema/annotate.cpp
+++ b/eeschema/annotate.cpp
@@ -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;
diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp
index 15eb9e6..6796ef3 100644
--- a/eeschema/component_references_lister.cpp
+++ b/eeschema/component_references_lister.cpp
@@ -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::vectorint 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 )

Re: [Kicad-developers] [PATCH] Option in eeschema to annotate keeping multi-unit parts grouped

2015-03-13 Thread Andy Peters

 On Mar 13, 2015, at 4:11 PM, Chris Pavlina pavlina.ch...@gmail.com wrote:
 
 Hello,
 
 Here is a patch for eeschema that adds Reset existing annotation, but do not 
 swap any units to eeschema. This first compiles a list of multi-unit parts 
 and all of the components that comprise them, and then on annotation, 
 annotates all of them as a group. For example, if components were originally 
 R3B and R3C, they can be annotated to R5B and R5C, but never R5B and R6C, or 
 R5A and R5D.
 
 I wanted this feature so that I could re-annotate a project to tidy up the 
 references, while not losing symbol-footprint mappings that already exist in 
 a routed PCB.

Brilliant. I will try this.

-a
___
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp