Commit 1e2e1442 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Schematic reference object refactoring and minor dialog fix.

* Schematic reference object now completely encapsulated.
* Schematic reference list object refactoring complete.
* Make OK default button in PCBNew block operation dialog.
parent c42af938
This diff is collapsed.
This diff is collapsed.
...@@ -649,7 +649,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f, ...@@ -649,7 +649,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f,
isMulti = entry->IsMulti(); isMulti = entry->IsMulti();
if( isMulti && aIncludeSubComponents ) if( isMulti && aIncludeSubComponents )
subRef = LIB_COMPONENT::ReturnSubReference( aList[ii].m_Unit ); subRef = LIB_COMPONENT::ReturnSubReference( aList[ii].GetUnit() );
else else
subRef.Empty(); subRef.Empty();
...@@ -786,8 +786,8 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* f, SCH_REFERENCE_LIST& aL ...@@ -786,8 +786,8 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* f, SCH_REFERENCE_LIST& aL
multi = 0; multi = 0;
} }
if ( multi && aList[ii].m_Unit > 0 ) if ( multi && aList[ii].GetUnit() > 0 )
unitId.Printf( wxT("%c"), 'A' -1 + aList[ii].m_Unit ); unitId.Printf( wxT("%c"), 'A' -1 + aList[ii].GetUnit() );
else else
unitId.Empty(); unitId.Empty();
...@@ -901,7 +901,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f, ...@@ -901,7 +901,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f,
wxString subRef; wxString subRef;
if( isMulti && aIncludeSubComponents ) if( isMulti && aIncludeSubComponents )
subRef = LIB_COMPONENT::ReturnSubReference( aList[ii].m_Unit ); subRef = LIB_COMPONENT::ReturnSubReference( aList[ii].GetUnit() );
else else
subRef.Empty(); subRef.Empty();
......
...@@ -66,24 +66,19 @@ private: ...@@ -66,24 +66,19 @@ private:
LIB_COMPONENT* m_Entry; ///< The source component from a library. LIB_COMPONENT* m_Entry; ///< The source component from a library.
wxPoint m_CmpPos; ///< The physical position of the component in schematic wxPoint m_CmpPos; ///< The physical position of the component in schematic
///< used to annotate by X or Y position ///< used to annotate by X or Y position
int m_Unit; ///< The unit number for components with multiple parts
///< per package.
SCH_SHEET_PATH m_SheetPath; ///< The sheet path for this reference. SCH_SHEET_PATH m_SheetPath; ///< The sheet path for this reference.
bool m_IsNew; ///< True if not yet annotated.
int m_SheetNum; ///< The sheet number for the reference.
unsigned long m_TimeStamp; ///< The time stamp for the reference.
wxString* m_Value; ///< The component value of the refernce. It is the
///< same for all instances.
int m_NumRef; ///< The numeric part of the reference designator.
int m_Flag;
friend class SCH_REFERENCE_LIST; friend class SCH_REFERENCE_LIST;
public:
int m_Unit; /* Selected part (For multi parts per
* package) depending on sheet path */
int m_SheetNum; // the sheet num for this component
unsigned long m_TimeStamp; /* unique identification number
* depending on sheet path */
bool m_IsNew; /* true for not yet annotated
* components */
wxString* m_Value; /* Component value (same for all
* instances) */
int m_NumRef; /* Reference number (for IC1, this is
* 1) ) depending on sheet path*/
int m_Flag; /* flag for computations */
public: public:
SCH_REFERENCE() SCH_REFERENCE()
...@@ -108,6 +103,10 @@ public: ...@@ -108,6 +103,10 @@ public:
SCH_SHEET_PATH GetSheetPath() const { return m_SheetPath; } SCH_SHEET_PATH GetSheetPath() const { return m_SheetPath; }
int GetUnit() const { return m_Unit; }
void SetSheetNumber( int aSheetNumber ) { m_SheetNum = aSheetNumber; }
/** /**
* Function Annotate * Function Annotate
* updates the annotation of the component according the the current object state. * updates the annotation of the component according the the current object state.
...@@ -165,9 +164,9 @@ public: ...@@ -165,9 +164,9 @@ public:
/** /**
* Class SCH_REFERENCE_LIST * Class SCH_REFERENCE_LIST
* is used create a flattened list of components because in a complex hierarchy, a component * is used create a flattened list of components because in a complex hierarchy, a component
* can used more than once and its reference designator is dependent on the sheet path for the * can be used more than once and its reference designator is dependent on the sheet path for
* same component. This flattened list is used for netlist generation, BOM generation, and * the same component. This flattened list is used for netlist generation, BOM generation,
* schematic annotation. * and schematic annotation.
*/ */
class SCH_REFERENCE_LIST class SCH_REFERENCE_LIST
{ {
...@@ -262,6 +261,38 @@ public: ...@@ -262,6 +261,38 @@ public:
} }
} }
/**
* Function Annotate
* set the reference designators in the list that have not been annotated.
* @param aUseSheetNum Set to true to start annotation for each sheet at the sheet number
* times \a aSheetIntervalId. Otherwise annotate incrementally.
* @param aSheetIntervalId The per sheet reference designator multiplier.
* <p>
* If a the sheet number is 2 and \a aSheetIntervalId is 100, then the first reference
* designator would be 201 and the last reference designator would be 299 when no overlap
* occurs with sheet number 3. If there are 150 items in sheet number 2, then items are
* referenced U201 to U351, and items in sheet 3 start from U352
* </p>
*/
void Annotate( bool aUseSheetNum, int aSheetIntervalId );
/**
* Function CheckAnnotation
* check for annotations errors.
* <p>
* The following annotation error conditions are tested:
* <ul>
* <li>Components not annotated.</li>
* <li>Components having the same reference designator (duplicates).</li>
* <li>Components with multiple parts per package having different reference designators.</li>
* <li>Components with multiple parts per package with invalid part count.</li>
* </ul>
* </p>
* @param aMessageList A wxArrayString to store error messages.
* @return The number of errors found.
*/
int CheckAnnotation( wxArrayString* aMessageList );
/** /**
* Function sortByXCoordinate * Function sortByXCoordinate
* sorts the list of references by X position. * sorts the list of references by X position.
...@@ -305,7 +336,7 @@ public: ...@@ -305,7 +336,7 @@ public:
* sort the flat list by Time Stamp. * sort the flat list by Time Stamp.
* Useful to detect duplicate Time Stamps * Useful to detect duplicate Time Stamps
*/ */
void SortComponentsByTimeStamp() void SortByTimeStamp()
{ {
sort( componentFlatList.begin(), componentFlatList.end(), sortByTimeStamp ); sort( componentFlatList.begin(), componentFlatList.end(), sortByTimeStamp );
} }
...@@ -417,6 +448,19 @@ private: ...@@ -417,6 +448,19 @@ private:
static bool sortByValueOnly( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 ); static bool sortByValueOnly( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 );
static bool sortByReferenceOnly( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 ); static bool sortByReferenceOnly( const SCH_REFERENCE& item1, const SCH_REFERENCE& item2 );
/**
* Function CreateFirstFreeRefId
* searches for the first free reference number in \a aListId of reference numbers in use.
* This function just searches for a hole in a list of incremented numbers, this list must
* be sorted by increasing values and each value can be stored only once. The new value
* is added to the list.
* @see BuildRefIdInUseList to prepare this list
* @param aIdList The buffer that contains the reference numbers in use.
* @param aFirstValue The first expected free value
* @return The first free (not yet used) value.
*/
int CreateFirstFreeRefId( std::vector<int>& aIdList, int aFirstValue );
}; };
......
...@@ -341,7 +341,7 @@ void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, ...@@ -341,7 +341,7 @@ void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences,
continue; continue;
SCH_REFERENCE reference = SCH_REFERENCE( component, entry, *this ); SCH_REFERENCE reference = SCH_REFERENCE( component, entry, *this );
reference.m_SheetNum = sheetnumber; reference.SetSheetNumber( sheetnumber );
aReferences.AddItem( reference ); aReferences.AddItem( reference );
} }
} }
......
...@@ -118,6 +118,7 @@ DIALOG_BLOCK_OPTIONS::DIALOG_BLOCK_OPTIONS( WinEDA_BasePcbFrame* aParent, ...@@ -118,6 +118,7 @@ DIALOG_BLOCK_OPTIONS::DIALOG_BLOCK_OPTIONS( WinEDA_BasePcbFrame* aParent,
m_Include_Edges_Items->SetValue( blockIncludeBoardOutlineLayer ); m_Include_Edges_Items->SetValue( blockIncludeBoardOutlineLayer );
m_Include_PcbTextes->SetValue( blockIncludePcbTexts ); m_Include_PcbTextes->SetValue( blockIncludePcbTexts );
m_DrawBlockItems->SetValue( blockDrawItems ); m_DrawBlockItems->SetValue( blockDrawItems );
m_sdbSizer1OK->SetDefault();
SetFocus(); SetFocus();
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
Centre(); Centre();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment