diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 4713759519..bab7a71945 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -1239,36 +1239,38 @@ LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int unit, int convert, * Otherwise NULL. */ LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int unit, int convert, - KICAD_T type, const wxPoint& pt, const int aTransMat[2][2] ) + KICAD_T type, const wxPoint& pt, + const int aTransMat[2][2] ) { - /* we use LocateDrawItem( int unit, int convert, KICAD_T type, const wxPoint& pt ) - * to search items. + /* we use LocateDrawItem( int unit, int convert, KICAD_T type, const + * wxPoint& pt ) to search items. * because this function uses DefaultTransformMatrix as orient/mirror matrix * we temporary copy aTransMat in DefaultTransformMatrix - */ + */ LIB_DRAW_ITEM * item; int matrix[2][2]; - for ( int ii =0; ii<2;ii++ ) + for ( int ii = 0; ii < 2; ii++ ) { - for ( int jj =0; jj<2;jj++ ) + for ( int jj = 0; jj < 2; jj++ ) { matrix[ii][jj] = aTransMat[ii][jj]; - EXCHG(matrix[ii][jj], DefaultTransformMatrix[ii][jj]); + EXCHG( matrix[ii][jj], DefaultTransformMatrix[ii][jj] ); } } item = LocateDrawItem( unit, convert, type, pt ); //Restore matrix - for ( int ii =0; ii<2;ii++ ) + for ( int ii = 0; ii < 2; ii++ ) { - for ( int jj =0; jj<2;jj++ ) + for ( int jj = 0; jj < 2; jj++ ) { - EXCHG(matrix[ii][jj], DefaultTransformMatrix[ii][jj]); + EXCHG( matrix[ii][jj], DefaultTransformMatrix[ii][jj] ); } } return item; } + void LIB_COMPONENT::SetPartCount( int count ) { LIB_DRAW_ITEM_LIST::iterator i; @@ -1335,7 +1337,8 @@ void LIB_COMPONENT::SetConversion( bool asConvert ) } else { - // Delete converted shape items becuase the converted shape does not exist + // Delete converted shape items becuase the converted shape does + // not exist LIB_DRAW_ITEM_LIST::iterator i = m_Drawings.begin(); while( i != m_Drawings.end() ) diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index 3675003976..20cb633c89 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -194,8 +194,9 @@ public: * @param transformMatrix - Cooridinate adjustment settings. * @param showPinText - Show pin text if true. * @param drawFields - Draw field text if true otherwise just draw - * body items (useful to draw a body in schematic, - * because fields of schematic components replace the lib component fields). + * body items (useful to draw a body in schematic, + * because fields of schematic components replace + * the lib component fields). * @param onlySelected - Draws only the body items that are selected. * Used for block move redraws. */ @@ -401,7 +402,8 @@ public: * Otherwise NULL. */ LIB_DRAW_ITEM* LocateDrawItem( int unit, int convert, KICAD_T type, - const wxPoint& pt, const int aTransMat[2][2] ); + const wxPoint& pt, + const int aTransMat[2][2] ); /** * Return a reference to the draw item list. @@ -444,10 +446,6 @@ public: * * Component aliases are not really components. They are references * to an actual component object. - * - * @todo Alias objects should really be defined as children of a component - * object not as children of a library object. This would greatly - * simplify searching for components in libraries. */ class LIB_ALIAS : public CMP_LIB_ENTRY { diff --git a/eeschema/class_libentry_fields.h b/eeschema/class_libentry_fields.h index 29be4e27ec..cbe601a36d 100644 --- a/eeschema/class_libentry_fields.h +++ b/eeschema/class_libentry_fields.h @@ -154,6 +154,7 @@ protected: virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const int transform[2][2] ); virtual int DoGetWidth( void ) { return m_Width; } + virtual void DoSetWidth( int width ) { m_Width = width; } }; #endif // CLASS_LIBENTRY_FIELDS_H diff --git a/eeschema/classes_body_items.h b/eeschema/classes_body_items.h index d638dfc791..864435cbd2 100644 --- a/eeschema/classes_body_items.h +++ b/eeschema/classes_body_items.h @@ -301,7 +301,7 @@ public: * @return int - Width of draw object. */ int GetWidth( void ) { return DoGetWidth(); } - + void SetWidth( int width ) { DoSetWidth( width ); } protected: virtual LIB_DRAW_ITEM* DoGenCopy() = 0; @@ -326,6 +326,7 @@ protected: virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const int transform[2][2] ) = 0; virtual int DoGetWidth( void ) = 0; + virtual void DoSetWidth( int width ) = 0; }; @@ -474,6 +475,7 @@ protected: virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const int transform[2][2] ); virtual int DoGetWidth( void ) { return m_Width; } + virtual void DoSetWidth( int width ) { m_Width = width; } }; @@ -563,6 +565,7 @@ protected: virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const int transform[2][2] ); virtual int DoGetWidth( void ) { return m_Width; } + virtual void DoSetWidth( int width ) { m_Width = width; } }; @@ -648,6 +651,7 @@ protected: virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const int transform[2][2] ); virtual int DoGetWidth( void ) { return m_Width; } + virtual void DoSetWidth( int width ) { m_Width = width; } }; @@ -744,6 +748,7 @@ protected: virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const int transform[2][2] ); virtual int DoGetWidth( void ) { return m_Width; } + virtual void DoSetWidth( int width ) { m_Width = width; } }; @@ -829,6 +834,7 @@ protected: virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const int transform[2][2] ); virtual int DoGetWidth( void ) { return m_Width; } + virtual void DoSetWidth( int width ) { m_Width = width; } }; /**********************************/ @@ -913,6 +919,7 @@ protected: virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const int transform[2][2] ); virtual int DoGetWidth( void ) { return m_Width; } + virtual void DoSetWidth( int width ) { m_Width = width; } }; @@ -1006,6 +1013,7 @@ protected: virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const int transform[2][2] ); virtual int DoGetWidth( void ) { return m_Width; } + virtual void DoSetWidth( int width ) { m_Width = width; } }; /**********************************************************/ @@ -1099,6 +1107,7 @@ protected: virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const int transform[2][2] ); virtual int DoGetWidth( void ) { return m_Width; } + virtual void DoSetWidth( int width ) { m_Width = width; } }; #endif // CLASSES_BODY_ITEMS_H diff --git a/eeschema/dialog_cmp_graphic_properties.cpp b/eeschema/dialog_cmp_graphic_properties.cpp index d4dc643acd..dfad995ab7 100644 --- a/eeschema/dialog_cmp_graphic_properties.cpp +++ b/eeschema/dialog_cmp_graphic_properties.cpp @@ -62,7 +62,7 @@ WinEDA_bodygraphics_PropertiesFrame::WinEDA_bodygraphics_PropertiesFrame( WinEDA if ( CurrentItem->m_Unit == 0 ) m_CommonUnit->SetValue( TRUE ); } - else if ( ! g_FlDrawSpecificUnit ) + else if ( ! m_Parent->m_drawSpecificUnit ) { m_CommonUnit->SetValue( TRUE ); } @@ -72,7 +72,7 @@ WinEDA_bodygraphics_PropertiesFrame::WinEDA_bodygraphics_PropertiesFrame( WinEDA if ( CurrentItem->m_Convert == 0 ) m_CommonConvert->SetValue( TRUE ); } - else if ( !g_FlDrawSpecificConvert ) + else if ( !m_Parent->m_drawSpecificConvert ) { m_CommonConvert->SetValue( TRUE ); } diff --git a/eeschema/edit_graphic_bodyitem_text.cpp b/eeschema/edit_graphic_bodyitem_text.cpp index 2bb075b924..43c8662b72 100644 --- a/eeschema/edit_graphic_bodyitem_text.cpp +++ b/eeschema/edit_graphic_bodyitem_text.cpp @@ -112,15 +112,15 @@ void Dialog_BodyGraphicText_Properties::InitDialog( ) } else { - msg = ReturnStringFromValue( g_UnitMetric, g_LastTextSize, + msg = ReturnStringFromValue( g_UnitMetric, m_Parent->m_textSize, m_Parent->m_InternalUnits ); m_TextSize->SetValue( msg ); - if ( ! g_FlDrawSpecificUnit ) + if ( ! m_Parent->m_drawSpecificUnit ) m_CommonUnit->SetValue( TRUE ); - if ( ! g_FlDrawSpecificConvert ) + if ( ! m_Parent->m_drawSpecificConvert ) m_CommonConvert->SetValue( TRUE ); - if ( g_LastTextOrient == TEXT_ORIENT_VERT ) + if ( m_Parent->m_textOrientation == TEXT_ORIENT_VERT ) m_Orient->SetValue( TRUE ); } @@ -149,12 +149,13 @@ void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event ) wxString Line; Line = m_TextValue->GetValue(); - g_LastTextOrient = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; + m_Parent->m_textOrientation = + m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ; wxString msg = m_TextSize->GetValue(); - g_LastTextSize = ReturnValueFromString(g_UnitMetric, msg, - m_Parent->m_InternalUnits); - g_FlDrawSpecificConvert = m_CommonConvert->GetValue() ? FALSE : TRUE; - g_FlDrawSpecificUnit = m_CommonUnit->GetValue() ? FALSE : TRUE; + m_Parent->m_textSize = ReturnValueFromString( g_UnitMetric, msg, + m_Parent->m_InternalUnits ); + m_Parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true; + m_Parent->m_drawSpecificUnit = m_CommonUnit->GetValue() ? false : true; if ( m_GraphicText ) { @@ -163,15 +164,15 @@ void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event ) else m_GraphicText->m_Text = wxT("[null]"); - m_GraphicText->m_Size.x = m_GraphicText->m_Size.y = g_LastTextSize; - m_GraphicText->m_Orient = g_LastTextOrient; + m_GraphicText->m_Size.x = m_GraphicText->m_Size.y = m_Parent->m_textSize; + m_GraphicText->m_Orient = m_Parent->m_textOrientation; - if( g_FlDrawSpecificUnit ) + if( m_Parent->m_drawSpecificUnit ) m_GraphicText->m_Unit = m_Parent->GetUnit(); else m_GraphicText->m_Unit = 0; - if( g_FlDrawSpecificConvert ) + if( m_Parent->m_drawSpecificConvert ) m_GraphicText->m_Convert = m_Parent->GetConvert(); else m_GraphicText->m_Convert = 0; diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index 8a1fcf024c..e944e0df1b 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -47,13 +47,6 @@ struct EESchemaVariables g_EESchemaVar; /* Variables globales pour Schematic Edit */ int g_DefaultTextLabelSize = DEFAULT_SIZE_TEXT; -/* Variables globales pour LibEdit */ -int g_LastTextSize = DEFAULT_SIZE_TEXT; -int g_LastTextOrient = TEXT_ORIENT_HORIZ; - -bool g_FlDrawSpecificUnit = FALSE; -bool g_FlDrawSpecificConvert = TRUE; - HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr; //SCH_SCREEN * ScreenSch; diff --git a/eeschema/general.h b/eeschema/general.h index e66d62ec9b..6b4bd0c05a 100644 --- a/eeschema/general.h +++ b/eeschema/general.h @@ -129,12 +129,6 @@ extern struct EESchemaVariables g_EESchemaVar; /* Variables globales pour Schematic Edit */ extern int g_DefaultTextLabelSize; -/* Variables globales pour LibEdit */ -extern int g_LastTextSize; -extern int g_LastTextOrient; - -extern bool g_FlDrawSpecificUnit; -extern bool g_FlDrawSpecificConvert; /********************************************************/ /* Description des structures des parametres principaux */ diff --git a/eeschema/libeditfrm.h b/eeschema/libeditfrm.h index eb28024f43..e4f41c5823 100644 --- a/eeschema/libeditfrm.h +++ b/eeschema/libeditfrm.h @@ -13,6 +13,9 @@ class CMP_LIBRARY; class LIB_COMPONENT; class LIB_ALIAS; class LIB_DRAW_ITEM; +class WinEDA_bodygraphics_PropertiesFrame; +class Dialog_BodyGraphicText_Properties; + /** * The component library editor main window. @@ -187,21 +190,44 @@ protected: wxString m_LastLibImportPath; wxString m_LastLibExportPath; - static LIB_COMPONENT* m_component; // The current edited component (NULL if no component) - static CMP_LIBRARY* m_library; // The current active libary (NULL if none) + /// Convert of the item currently being drawn. + bool m_drawSpecificConvert; + bool m_drawSpecificUnit; + + // The current edited component (NULL if no component) + static LIB_COMPONENT* m_component; + + // The current active libary (NULL if none) + static CMP_LIBRARY* m_library; static LIB_DRAW_ITEM* m_lastDrawItem; static LIB_DRAW_ITEM* m_drawItem; static wxString m_aliasName; - static int m_unit; // The unit number to edit and show - static int m_convert; // Show the normal shape ( m_convert <= 1 ) - // or the converted shape ( m_convert > 1 ) - static bool m_showDeMorgan; // true to force DeMorgan/normal tools selection enabled - // They are enabled when the loaded component has - // Graphic items for converted shape - // But under some circumstances (New component created) - // these tools must left enable + + // The unit number to edit and show + static int m_unit; + + // Show the normal shape ( m_convert <= 1 ) or the converted shape + // ( m_convert > 1 ) + static int m_convert; + + // true to force DeMorgan/normal tools selection enabled. + // They are enabled when the loaded component has + // Graphic items for converted shape + // But under some circumstances (New component created) + // these tools must left enable + static bool m_showDeMorgan; + + /// The current text size setting. + static int m_textSize; + + /// Current text orientation setting. + static int m_textOrientation; + static wxSize m_clientSize; + friend class WinEDA_bodygraphics_PropertiesFrame; + friend class Dialog_BodyGraphicText_Properties; + DECLARE_EVENT_TABLE() }; diff --git a/eeschema/libframe.cpp b/eeschema/libframe.cpp index 0e7a901be7..f95640fd76 100644 --- a/eeschema/libframe.cpp +++ b/eeschema/libframe.cpp @@ -48,6 +48,8 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::m_lastDrawItem = NULL; LIB_DRAW_ITEM* WinEDA_LibeditFrame::m_drawItem = NULL; bool WinEDA_LibeditFrame::m_showDeMorgan = false; wxSize WinEDA_LibeditFrame::m_clientSize = wxSize( -1, -1 ); +int WinEDA_LibeditFrame::m_textSize = DEFAULT_SIZE_TEXT; +int WinEDA_LibeditFrame::m_textOrientation = TEXT_ORIENT_HORIZ; /*****************************/ @@ -155,6 +157,8 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father, m_Draw_Grid = true; // true pour avoir la axes dessinee m_ConfigPath = wxT( "LibraryEditor" ); SetShowDeMorgan( false ); + m_drawSpecificConvert = true; + m_drawSpecificUnit = false; // Give an icon SetIcon( wxIcon( libedit_xpm ) ); diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index 6a20f9fba7..07b6d3953b 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -51,8 +51,8 @@ void WinEDA_bodygraphics_PropertiesFrame::bodygraphics_PropertiesAccept( wxComma if( item == NULL ) return; - g_FlDrawSpecificConvert = m_CommonConvert->GetValue() ? FALSE : TRUE; - g_FlDrawSpecificUnit = m_CommonUnit->GetValue() ? FALSE : TRUE; + m_Parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true; + m_Parent->m_drawSpecificUnit = m_CommonUnit->GetValue() ? false : true; if( m_Filled ) FlSymbol_Fill = (FILL_T) m_Filled->GetSelection(); @@ -68,49 +68,20 @@ void WinEDA_bodygraphics_PropertiesFrame::bodygraphics_PropertiesAccept( wxComma item->Draw( m_Parent->DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL, DefaultTransformMatrix ); - if( g_FlDrawSpecificUnit ) + if( m_Parent->m_drawSpecificUnit ) item->m_Unit = m_Parent->GetUnit(); else item->m_Unit = 0; - if( g_FlDrawSpecificConvert ) + if( m_Parent->m_drawSpecificConvert ) item->m_Convert = m_Parent->GetConvert(); else item->m_Convert = 0; - if( m_Filled ) + if( m_Filled ) { - switch( item->Type() ) - { - case COMPONENT_ARC_DRAW_TYPE: - ( (LIB_ARC*) item )->m_Fill = FlSymbol_Fill; - ( (LIB_ARC*) item )->m_Width = - m_GraphicShapeWidthCtrl->GetValue(); - break; - - case COMPONENT_CIRCLE_DRAW_TYPE: - ( (LIB_CIRCLE*) item )->m_Fill = FlSymbol_Fill; - ( (LIB_CIRCLE*) item )->m_Width = - m_GraphicShapeWidthCtrl->GetValue(); - break; - - case COMPONENT_RECT_DRAW_TYPE: - ( (LIB_RECTANGLE*) item )->m_Fill = FlSymbol_Fill; - ( (LIB_RECTANGLE*) item )->m_Width = - m_GraphicShapeWidthCtrl->GetValue(); - break; - - case COMPONENT_POLYLINE_DRAW_TYPE: - ( (LIB_POLYLINE*) item )->m_Fill = - FlSymbol_Fill; - ( (LIB_POLYLINE*) item )->m_Width = - m_GraphicShapeWidthCtrl->GetValue(); - break; - - default: - break; - } - + item->m_Fill = FlSymbol_Fill; + item->SetWidth( m_GraphicShapeWidthCtrl->GetValue() ); item->GetParent()->GetDrawItemList().sort(); m_Parent->GetScreen()->SetModify(); @@ -254,8 +225,8 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry, LIB_TEXT* Text = new LIB_TEXT( LibEntry ); m_drawItem = Text; - Text->m_Size.x = Text->m_Size.y = g_LastTextSize; - Text->m_Orient = g_LastTextOrient; + Text->m_Size.x = Text->m_Size.y = m_textSize; + Text->m_Orient = m_textOrientation; Text->m_Pos = GetScreen()->m_Curseur; NEGATE( Text->m_Pos.y ); EditSymbolText( NULL, Text ); @@ -284,9 +255,9 @@ error" ) ); if( m_drawItem ) { m_drawItem->m_Flags |= IS_NEW; - if( g_FlDrawSpecificUnit ) + if( m_drawSpecificUnit ) m_drawItem->m_Unit = m_unit; - if( g_FlDrawSpecificConvert ) + if( m_drawSpecificConvert ) m_drawItem->m_Convert = m_convert; }