Pin edit: fix some minor issues.
This commit is contained in:
parent
883929f969
commit
d60caed493
|
@ -15,10 +15,13 @@ wxSize DIALOG_LIB_EDIT_PIN::s_LastSize;
|
|||
DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN( wxWindow* parent, LIB_PIN* aPin ) :
|
||||
DIALOG_LIB_EDIT_PIN_BASE( parent )
|
||||
{
|
||||
// Creates a dummy pin to show on a panel, insside this dialog:
|
||||
m_dummyPin = new LIB_PIN( *aPin );
|
||||
|
||||
// m_dummyPin changes do not proparagte to a parent, so set parent to null
|
||||
// m_dummyPin changes do not proparagte to other pins of the current lib component,
|
||||
// so set parent to null and clear flags
|
||||
m_dummyPin->SetParent( NULL );
|
||||
m_dummyPin->ClearFlags();
|
||||
|
||||
m_panelShowPin->SetBackgroundColour( MakeColour( g_DrawBgColor ) );
|
||||
|
||||
|
@ -60,7 +63,7 @@ void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event )
|
|||
|
||||
// Give a parent to m_dummyPin only from draw purpose.
|
||||
// In fact m_dummyPin should not have a parent, but draw functions need a parent
|
||||
// to know some options
|
||||
// to know some options, about pin texts
|
||||
LIB_EDIT_FRAME* libframe = (LIB_EDIT_FRAME*) GetParent();
|
||||
m_dummyPin->SetParent( libframe->GetComponent() );
|
||||
|
||||
|
@ -79,7 +82,6 @@ void DIALOG_LIB_EDIT_PIN::OnPaintShowPanel( wxPaintEvent& event )
|
|||
NEGATE( offset.y );
|
||||
|
||||
GRResetPenAndBrush( &dc );
|
||||
m_dummyPin->SetVisible( true ); // TODO find a better way to show invisible pin here
|
||||
m_dummyPin->Draw( NULL, &dc, offset, -1, wxCOPY,
|
||||
NULL, DefaultTransform );
|
||||
|
||||
|
@ -115,6 +117,8 @@ void DIALOG_LIB_EDIT_PIN::OnOKButtonClick( wxCommandEvent& event )
|
|||
// Called when a pin properties changes
|
||||
void DIALOG_LIB_EDIT_PIN::OnPropertiesChange( wxCommandEvent& event )
|
||||
{
|
||||
if( ! IsShown() ) // do nothing at init time
|
||||
return;
|
||||
int units = ((LIB_EDIT_FRAME*)GetParent())->m_InternalUnits;
|
||||
int pinNameSize = ReturnValueFromString( g_UserUnit, GetNameTextSize(), units );
|
||||
int pinNumSize = ReturnValueFromString( g_UserUnit, GetPadNameTextSize(), units);
|
||||
|
|
|
@ -470,9 +470,9 @@ void LIB_PIN::SetVisible( bool visible )
|
|||
return;
|
||||
|
||||
if( visible )
|
||||
m_attributes &= ~PINNOTDRAW;
|
||||
m_attributes &= ~PIN_INVISIBLE;
|
||||
else
|
||||
m_attributes |= PINNOTDRAW;
|
||||
m_attributes |= PIN_INVISIBLE;
|
||||
|
||||
SetModified();
|
||||
|
||||
|
@ -488,9 +488,9 @@ void LIB_PIN::SetVisible( bool visible )
|
|||
continue;
|
||||
|
||||
if( visible )
|
||||
pinList[i]->m_attributes &= ~PINNOTDRAW;
|
||||
pinList[i]->m_attributes &= ~PIN_INVISIBLE;
|
||||
else
|
||||
pinList[i]->m_attributes |= PINNOTDRAW;
|
||||
pinList[i]->m_attributes |= PIN_INVISIBLE;
|
||||
|
||||
SetModified();
|
||||
}
|
||||
|
@ -619,13 +619,12 @@ bool LIB_PIN::Save( FILE* ExportFile )
|
|||
m_Unit, m_Convert, Etype ) < 0 )
|
||||
return false;
|
||||
|
||||
if( ( m_shape ) || ( m_attributes & PINNOTDRAW ) )
|
||||
if( m_shape || !IsVisible() )
|
||||
{
|
||||
if( fprintf( ExportFile, " " ) < 0 )
|
||||
return false;
|
||||
}
|
||||
if( m_attributes & PINNOTDRAW
|
||||
&& fprintf( ExportFile, "N" ) < 0 )
|
||||
if( !IsVisible() && fprintf( ExportFile, "N" ) < 0 )
|
||||
return false;
|
||||
if( m_shape & INVERT
|
||||
&& fprintf( ExportFile, "I" ) < 0 )
|
||||
|
@ -741,7 +740,7 @@ bool LIB_PIN::Load( char* line, wxString& errorMsg )
|
|||
break;
|
||||
|
||||
case 'N':
|
||||
m_attributes |= PINNOTDRAW;
|
||||
m_attributes |= PIN_INVISIBLE;
|
||||
break;
|
||||
|
||||
case 'I':
|
||||
|
@ -797,16 +796,21 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel,
|
|||
void* aData,
|
||||
const TRANSFORM& aTransform )
|
||||
{
|
||||
// Invisible pins are only drawn on request. In libedit they are drawn
|
||||
// in g_InvisibleItemColor because we must see them.
|
||||
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) wxGetApp().GetTopWindow();
|
||||
|
||||
if( m_attributes & PINNOTDRAW )
|
||||
// Invisible pins are only drawn on request.
|
||||
// They are drawn in g_InvisibleItemColor.
|
||||
// in schematic, they are drawn only if m_ShowAllPins is true.
|
||||
// In other windows, they are always drawn because we must see them.
|
||||
if( ! IsVisible() )
|
||||
{
|
||||
if( frame->m_LibeditFrame && frame->m_LibeditFrame->IsActive() )
|
||||
aColor = g_InvisibleItemColor;
|
||||
else if( !frame->m_ShowAllPins )
|
||||
EDA_DRAW_FRAME* frame = NULL;
|
||||
if( aPanel && aPanel->GetParent() )
|
||||
frame = (EDA_DRAW_FRAME*)aPanel->GetParent();
|
||||
|
||||
if( frame && frame->m_Ident == SCHEMATIC_FRAME &&
|
||||
! ((SCH_EDIT_FRAME*)frame)->m_ShowAllPins )
|
||||
return;
|
||||
|
||||
aColor = g_InvisibleItemColor;
|
||||
}
|
||||
|
||||
LIB_COMPONENT* Entry = GetParent();
|
||||
|
@ -1673,7 +1677,7 @@ void LIB_PIN::DoMirrorHorizontal( const wxPoint& center )
|
|||
void LIB_PIN::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill,
|
||||
const TRANSFORM& aTransform )
|
||||
{
|
||||
if( m_attributes & PINNOTDRAW )
|
||||
if( ! IsVisible() )
|
||||
return;
|
||||
|
||||
int orient = ReturnPinDrawOrient( aTransform );
|
||||
|
|
|
@ -52,7 +52,7 @@ enum ElectricPinType {
|
|||
extern const wxChar* MsgPinElectricType[];
|
||||
|
||||
/* Pin visibility flag bit. */
|
||||
#define PINNOTDRAW 1 /* Set makes pin invisible */
|
||||
#define PIN_INVISIBLE 1 /* Set makes pin invisible */
|
||||
|
||||
|
||||
/**
|
||||
|
@ -350,7 +350,7 @@ public:
|
|||
*
|
||||
* @return True if draw object is visible otherwise false.
|
||||
*/
|
||||
bool IsVisible() { return ( m_attributes & PINNOTDRAW ) == 0; }
|
||||
bool IsVisible() { return ( m_attributes & PIN_INVISIBLE ) == 0; }
|
||||
|
||||
/**
|
||||
* @return the size of the "pen" that be used to draw or plot this item.
|
||||
|
|
Loading…
Reference in New Issue