Add support for units.

This commit is contained in:
Jeff Young 2018-08-28 18:45:30 +01:00
parent 7cbfa08ddd
commit a03dc577f8
5 changed files with 31 additions and 7 deletions

View File

@ -64,7 +64,9 @@ int LIB_PART::m_subpartFirstId = 'A';
LIB_ALIAS::LIB_ALIAS( const wxString& aName, LIB_PART* aRootPart ) :
EDA_ITEM( LIB_ALIAS_T ),
shared( aRootPart )
shared( aRootPart ),
tmpUnit( 0 ),
tmpConversion( 0 )
{
SetName( aName );
}
@ -72,7 +74,9 @@ LIB_ALIAS::LIB_ALIAS( const wxString& aName, LIB_PART* aRootPart ) :
LIB_ALIAS::LIB_ALIAS( const LIB_ALIAS& aAlias, LIB_PART* aRootPart ) :
EDA_ITEM( aAlias ),
shared( aRootPart )
shared( aRootPart ),
tmpUnit( 0 ),
tmpConversion( 0 )
{
name = aAlias.name;

View File

@ -87,6 +87,9 @@ protected:
wxString keyWords; ///< keyword list (used for search for parts by keyword)
wxString docFileName; ///< Associate doc file name
int tmpUnit; ///< Temporary unit designator (used for rendering)
int tmpConversion; ///< Temporary conversion designator (used for rendering)
public:
LIB_ALIAS( const wxString& aName, LIB_PART* aRootComponent );
LIB_ALIAS( const LIB_ALIAS& aAlias, LIB_PART* aRootComponent = NULL );
@ -156,6 +159,18 @@ public:
*/
wxString GetUnitReference( int aUnit ) override;
/**
* A temporary unit designation for rendering, preview, etc.
*/
void SetTmpUnit( int aUnit ) { tmpUnit = aUnit; }
int GetTmpUnit() { return tmpUnit; }
/**
* A temporary conversion (deMorgan) designation for rendering, preview, etc.
*/
void SetTmpConversion( int aConversion ) { tmpConversion = aConversion; }
int GetTmpConversion() { return tmpConversion; }
/**
* KEEPCASE sensitive comparison of the part entry name.
*/

View File

@ -193,10 +193,8 @@ void SCH_PAINTER::draw( LIB_PART *aComp, int aLayer, bool aDrawFields, int aUnit
void SCH_PAINTER::draw( LIB_ALIAS *aAlias, int aLayer )
{
LIB_PART* comp = aAlias->GetPart();
int unit = 0;
int convert = 0;
draw( comp, aLayer, false, unit, convert );
draw( comp, aLayer, false, aAlias->GetTmpUnit(), aAlias->GetTmpConversion() );
LIB_FIELDS fields;
comp->GetFields( fields );

View File

@ -44,7 +44,7 @@ using namespace std::placeholders;
SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
const wxPoint& aPosition, const wxSize& aSize,
KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) :
EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, GAL_TYPE_OPENGL ),
EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalType ),
m_parent( aParentWindow )
{
m_view = new KIGFX::SCH_VIEW( true );

View File

@ -89,7 +89,14 @@ void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit )
if( alias )
{
// JEY TODO: how to communicate unit to drawing code?
LIB_PART* part = alias->GetPart();
// If unit isn't specified for a multi-unit part, pick the first. (Otherwise we'll
// draw all of them.)
if( part->IsMulti() && aUnit == 0 )
aUnit = 1;
alias->SetTmpUnit( aUnit );
view->Add( alias );
// Zoom to fit