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,
isMulti = entry->IsMulti();
if( isMulti && aIncludeSubComponents )
subRef = LIB_COMPONENT::ReturnSubReference( aList[ii].m_Unit );
subRef = LIB_COMPONENT::ReturnSubReference( aList[ii].GetUnit() );
else
subRef.Empty();
......@@ -786,8 +786,8 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( FILE* f, SCH_REFERENCE_LIST& aL
multi = 0;
}
if ( multi && aList[ii].m_Unit > 0 )
unitId.Printf( wxT("%c"), 'A' -1 + aList[ii].m_Unit );
if ( multi && aList[ii].GetUnit() > 0 )
unitId.Printf( wxT("%c"), 'A' -1 + aList[ii].GetUnit() );
else
unitId.Empty();
......@@ -901,7 +901,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f,
wxString subRef;
if( isMulti && aIncludeSubComponents )
subRef = LIB_COMPONENT::ReturnSubReference( aList[ii].m_Unit );
subRef = LIB_COMPONENT::ReturnSubReference( aList[ii].GetUnit() );
else
subRef.Empty();
......
......@@ -66,24 +66,19 @@ private:
LIB_COMPONENT* m_Entry; ///< The source component from a library.
wxPoint m_CmpPos; ///< The physical position of the component in schematic
///< 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.
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;
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:
SCH_REFERENCE()
......@@ -108,6 +103,10 @@ public:
SCH_SHEET_PATH GetSheetPath() const { return m_SheetPath; }
int GetUnit() const { return m_Unit; }
void SetSheetNumber( int aSheetNumber ) { m_SheetNum = aSheetNumber; }
/**
* Function Annotate
* updates the annotation of the component according the the current object state.
......@@ -165,9 +164,9 @@ public:
/**
* Class SCH_REFERENCE_LIST
* 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
* same component. This flattened list is used for netlist generation, BOM generation, and
* schematic annotation.
* can be used more than once and its reference designator is dependent on the sheet path for
* the same component. This flattened list is used for netlist generation, BOM generation,
* and schematic annotation.
*/
class SCH_REFERENCE_LIST
{
......@@ -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
* sorts the list of references by X position.
......@@ -305,7 +336,7 @@ public:
* sort the flat list by Time Stamp.
* Useful to detect duplicate Time Stamps
*/
void SortComponentsByTimeStamp()
void SortByTimeStamp()
{
sort( componentFlatList.begin(), componentFlatList.end(), sortByTimeStamp );
}
......@@ -417,6 +448,19 @@ private:
static bool sortByValueOnly( 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,
continue;
SCH_REFERENCE reference = SCH_REFERENCE( component, entry, *this );
reference.m_SheetNum = sheetnumber;
reference.SetSheetNumber( sheetnumber );
aReferences.AddItem( reference );
}
}
......
......@@ -118,6 +118,7 @@ DIALOG_BLOCK_OPTIONS::DIALOG_BLOCK_OPTIONS( WinEDA_BasePcbFrame* aParent,
m_Include_Edges_Items->SetValue( blockIncludeBoardOutlineLayer );
m_Include_PcbTextes->SetValue( blockIncludePcbTexts );
m_DrawBlockItems->SetValue( blockDrawItems );
m_sdbSizer1OK->SetDefault();
SetFocus();
GetSizer()->SetSizeHints( this );
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