← Back to team overview

kicad-developers team mailing list archive

Re: Ponderings about the reference field

 

On 3/25/2013 9:50 AM, Wayne Stambaugh wrote:
> On 3/25/2013 6:55 AM, Lorenzo Marcantonio wrote:
>> It's a real mess IMHO...
>>
>> I think most of the issues comes from the reference m_Text needing to
>> contain the 'full' reference, instead of only the reference field. Why
>> is that?
>>
>> Because it's also an EDA_TEXT which draws m_Text without passing from
>> GetText(), simply (there may be other reasons). The fact that complex
>> hierarchies exist only aggravate the issue :(((
>>
>> From a pure modelling standpoint the SCH_FIELD(REFERENCE) should only
>> contain the base reference. But then it wouldn't be shown properly. Even
>> if we make EDA_TEXT go through GetText and override (as it is now)
>> GetText to get the 'full' reference, we would lose the
>>
>> ref->SetText(ref->GetText()) 
>>
>> invariant, which is actually what give the problem.
>>
>> As a quick hack I'd would suggest a GetBaseText (as proposed) which
>> would *strip* the subpart ID from the reference; I feel that would be
>> extremely wrong and source of further problems...
>>
>> OTOH why the GetRef function would need the SCH_SHEET_PATH to work?
>> hasn't the SCH_COMPONENT already have the needed infos?
>>
>> I think a more 'elegant' solution would be:
>>
>> - The field itself (its m_Text) *always* contains the reference without
>>   subpart ID. That would rid of many (all?) of the current
>>   SetText(GetText) calls.
>> - The EDA_TEXT would follow a MVC route and use a virtual override
>>   (something like GetPresentationText) to allow runtime generation of
>>   the text (the default would be a no-op).
>> - SCH_FIELD having access to the component via the m_Parent link would
>>   override the GetPresentationText to correctly show the subid (this
>>   would also handle the GOST variant)
>> - SCH_COMPONENT would get the GetRef() and GetFullRef() members to
>>   obtain the reference (with or without subpart id). This would also
>>   clean some of the usage of GetField(REFERENCE)->GetText()
>> - Need to inspect all the GetField(REFERENCE) to ensure it's getting the
>>   correct stuff
>>
>> Not easy but I can't devise a more simple/elegant solution.
>>
>> How do you feel about that?
>>
> 
> The short term solution is to figure out which SCH_FIELD::GetText()
> calls require the base reference designator string instead of the fully
> formed string and call EDA_TEXT::GetText() directly.  I'm already
> working on it.  The long term solution is to fix the way hierarchical
> sheets are handled.  This would eliminate the reference designator
> string being manipulated in  SCH_FIELD::GetText() which is the real problem.
> 

I forgot to add that this is a text book example of why you should not
make class members public.  When EDA_TEXT::m_Text was public,
SCH_FIELD::GetText() was not being called because EDA_TEXT::m_Text was
being accessed directly which bypassed the reference designator string
manipulation.  I now remember why I never got around to encapsulating
EDA_TEXT.



Follow ups

References