From a03dc577f87a294447a9ea34c11c29f67918a394 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 28 Aug 2018 18:45:30 +0100 Subject: [PATCH] Add support for units. --- eeschema/class_libentry.cpp | 8 ++++++-- eeschema/class_libentry.h | 15 +++++++++++++++ eeschema/sch_painter.cpp | 4 +--- eeschema/sch_preview_panel.cpp | 2 +- eeschema/widgets/symbol_preview_widget.cpp | 9 ++++++++- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 74f3d99aa8..d3d6935945 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -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; diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index a5fe127edb..e894afdfd9 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -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. */ diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 3fc200dadc..5eda6b0f76 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -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 ); diff --git a/eeschema/sch_preview_panel.cpp b/eeschema/sch_preview_panel.cpp index d826ad63e5..5570f4926b 100644 --- a/eeschema/sch_preview_panel.cpp +++ b/eeschema/sch_preview_panel.cpp @@ -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 ); diff --git a/eeschema/widgets/symbol_preview_widget.cpp b/eeschema/widgets/symbol_preview_widget.cpp index a0e9345d4a..a070a66a24 100644 --- a/eeschema/widgets/symbol_preview_widget.cpp +++ b/eeschema/widgets/symbol_preview_widget.cpp @@ -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