Commit 502f3160 authored by stambaughw's avatar stambaughw

Global variable reduction and minor code cleaning.

* Remove global variables used by the library editor.
* Add SetWidth() method to library draw objects.
parent 64249102
......@@ -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() )
......
......@@ -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
{
......
......@@ -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
......@@ -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
......@@ -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 );
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 */
......
......@@ -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()
};
......
......@@ -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 ) );
......
......@@ -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;
}
......
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