Fix minor issues (included Bug #1469358 hierarchical sheet pin not redrawn after edition)

This commit is contained in:
jean-pierre charras 2015-06-27 11:12:32 +02:00
parent ada5274b28
commit 7be1d32a10
7 changed files with 95 additions and 69 deletions

View File

@ -367,7 +367,8 @@ public:
m_cache_candidate( aCacheCandidate ), m_cache_candidate( aCacheCandidate ),
m_lib_candidate( aLibCandidate ) { } m_lib_candidate( aLibCandidate ) { }
RESCUE_CACHE_CANDIDATE() {} RESCUE_CACHE_CANDIDATE()
: m_cache_candidate( NULL ), m_lib_candidate( NULL ) {}
virtual wxString GetRequestedName() const { return m_requested_name; } virtual wxString GetRequestedName() const { return m_requested_name; }
virtual wxString GetNewName() const { return m_new_name; } virtual wxString GetNewName() const { return m_new_name; }

View File

@ -70,14 +70,22 @@ private:
/** /**
* Defines the edge of the sheet that the sheet pin is positioned * Defines the edge of the sheet that the sheet pin is positioned
* 0: pin on left side * SHEET_LEFT_SIDE = 0: pin on left side
* 1: pin on right side * SHEET_RIGHT_SIDE = 1: pin on right side
* 2: pin on top side * SHEET_TOP_SIDE = 2: pin on top side
* 3: pin on bottom side * SHEET_BOTTOM_SIDE =3: pin on bottom side
* *
* For compatibility reasons, this does not follow same values as text orientation. * For compatibility reasons, this does not follow same values as text orientation.
*/ */
int m_edge; enum SHEET_SIDE
{
SHEET_LEFT_SIDE = 0,
SHEET_RIGHT_SIDE,
SHEET_TOP_SIDE,
SHEET_BOTTOM_SIDE,
SHEET_UNDEFINED_SIDE
};
SHEET_SIDE m_edge;
public: public:
SCH_SHEET_PIN( SCH_SHEET* parent, SCH_SHEET_PIN( SCH_SHEET* parent,
@ -132,9 +140,9 @@ public:
*/ */
void SetNumber( int aNumber ); void SetNumber( int aNumber );
void SetEdge( int aEdge ); void SetEdge( SHEET_SIDE aEdge );
int GetEdge() const; SHEET_SIDE GetEdge() const;
/** /**
* Function ConstrainOnEdge * Function ConstrainOnEdge

View File

@ -50,9 +50,9 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxStr
m_Pos = pos; m_Pos = pos;
if( parent->IsVerticalOrientation() ) if( parent->IsVerticalOrientation() )
SetEdge( 2 ); SetEdge( SHEET_TOP_SIDE );
else else
SetEdge( 0 ); SetEdge( SHEET_LEFT_SIDE );
m_shape = NET_INPUT; m_shape = NET_INPUT;
m_isDangling = true; m_isDangling = true;
@ -86,13 +86,12 @@ void SCH_SHEET_PIN::SwapData( SCH_ITEM* aItem )
SCH_SHEET_PIN* pin = ( SCH_SHEET_PIN* ) aItem; SCH_SHEET_PIN* pin = ( SCH_SHEET_PIN* ) aItem;
SCH_TEXT::SwapData( (SCH_TEXT*) pin ); SCH_TEXT::SwapData( (SCH_TEXT*) pin );
int tmp; int tmp = pin->GetNumber();
tmp = pin->GetNumber();
pin->SetNumber( GetNumber() ); pin->SetNumber( GetNumber() );
SetNumber( tmp ); SetNumber( tmp );
tmp = pin->GetEdge(); SHEET_SIDE stmp = pin->GetEdge();
pin->SetEdge( GetEdge() ); pin->SetEdge( GetEdge() );
SetEdge( tmp ); SetEdge( stmp );
} }
@ -116,40 +115,45 @@ void SCH_SHEET_PIN::SetNumber( int aNumber )
} }
void SCH_SHEET_PIN::SetEdge( int aEdge ) void SCH_SHEET_PIN::SetEdge( SCH_SHEET_PIN::SHEET_SIDE aEdge )
{ {
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent(); SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
/* use -1 to adjust text orientation without changing edge*/ // use SHEET_UNDEFINED_SIDE to adjust text orientation without changing edge
if( aEdge > -1 )
m_edge = aEdge;
switch( m_edge ) switch( aEdge )
{ {
case 0: /* pin on left side*/ case SHEET_LEFT_SIDE:
m_edge = aEdge;
m_Pos.x = Sheet->m_pos.x; m_Pos.x = Sheet->m_pos.x;
SetOrientation( 2 ); /* Orientation horiz inverse */ SetOrientation( 2 ); /* Orientation horiz inverse */
break; break;
case 1: /* pin on right side*/ case SHEET_RIGHT_SIDE:
m_edge = aEdge;
m_Pos.x = Sheet->m_pos.x + Sheet->m_size.x; m_Pos.x = Sheet->m_pos.x + Sheet->m_size.x;
SetOrientation( 0 ); /* Orientation horiz normal */ SetOrientation( 0 ); /* Orientation horiz normal */
break; break;
case 2: /* pin on top side*/ case SHEET_TOP_SIDE:
m_edge = aEdge;
m_Pos.y = Sheet->m_pos.y; m_Pos.y = Sheet->m_pos.y;
SetOrientation( 3 ); /* Orientation vert BOTTOM */ SetOrientation( 3 ); /* Orientation vert BOTTOM */
break; break;
case 3: /* pin on bottom side*/ case SHEET_BOTTOM_SIDE:
m_edge = aEdge;
m_Pos.y = Sheet->m_pos.y + Sheet->m_size.y; m_Pos.y = Sheet->m_pos.y + Sheet->m_size.y;
SetOrientation( 1 ); /* Orientation vert UP */ SetOrientation( 1 ); /* Orientation vert UP */
break; break;
default:
break;
} }
} }
int SCH_SHEET_PIN::GetEdge() const enum SCH_SHEET_PIN::SHEET_SIDE SCH_SHEET_PIN::GetEdge() const
{ {
return m_edge; return m_edge;
} }
@ -162,15 +166,15 @@ void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos )
if( Sheet == NULL ) if( Sheet == NULL )
return; return;
if( m_edge<2 ) /*horizontal sheetpin*/ if( m_edge == SHEET_LEFT_SIDE || m_edge == SHEET_RIGHT_SIDE )
{ {
if( Pos.x > ( Sheet->m_pos.x + ( Sheet->m_size.x / 2 ) ) ) if( Pos.x > ( Sheet->m_pos.x + ( Sheet->m_size.x / 2 ) ) )
{ {
SetEdge( 1 ); SetEdge( SHEET_RIGHT_SIDE );
} }
else else
{ {
SetEdge( 0 ); SetEdge( SHEET_LEFT_SIDE );
} }
m_Pos.y = Pos.y; m_Pos.y = Pos.y;
@ -185,11 +189,11 @@ void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos )
{ {
if( Pos.y > ( Sheet->m_pos.y + ( Sheet->m_size.y / 2 ) ) ) if( Pos.y > ( Sheet->m_pos.y + ( Sheet->m_size.y / 2 ) ) )
{ {
SetEdge( 3 ); //bottom SetEdge( SHEET_BOTTOM_SIDE ); //bottom
} }
else else
{ {
SetEdge( 2 ); //top SetEdge( SHEET_TOP_SIDE ); //top
} }
m_Pos.x = Pos.x; m_Pos.x = Pos.x;
@ -212,19 +216,20 @@ bool SCH_SHEET_PIN::Save( FILE* aFile ) const
switch( m_edge ) switch( m_edge )
{ {
case 0: //pin on left side default:
case SHEET_LEFT_SIDE: //pin on left side
side = 'L'; side = 'L';
break; break;
case 1: //pin on right side case SHEET_RIGHT_SIDE: //pin on right side
side = 'R'; side = 'R';
break; break;
case 2: //pin on top side case SHEET_TOP_SIDE: //pin on top side
side = 'T'; side = 'T';
break; break;
case 3: //pin on bottom side case SHEET_BOTTOM_SIDE: //pin on bottom side
side = 'B'; side = 'B';
break; break;
} }
@ -336,20 +341,20 @@ bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg )
switch( sheetSide[0] ) switch( sheetSide[0] )
{ {
case 'R' : /* pin on right side */ case 'R' : /* pin on right side */
SetEdge( 1 ); SetEdge( SHEET_RIGHT_SIDE );
break; break;
case 'T' : /* pin on top side */ case 'T' : /* pin on top side */
SetEdge( 2 ); SetEdge( SHEET_TOP_SIDE );
break; break;
case 'B' : /* pin on bottom side */ case 'B' : /* pin on bottom side */
SetEdge( 3 ); SetEdge( SHEET_BOTTOM_SIDE );
break; break;
case 'L' : /* pin on left side */ case 'L' : /* pin on left side */
default : default :
SetEdge( 0 ); SetEdge( SHEET_LEFT_SIDE );
break; break;
} }
@ -385,12 +390,15 @@ void SCH_SHEET_PIN::MirrorX( int aXaxis_position )
switch( m_edge ) switch( m_edge )
{ {
case 2: case SHEET_TOP_SIDE:
SetEdge( 3 ); SetEdge( SHEET_BOTTOM_SIDE );
break; break;
case 3: case SHEET_BOTTOM_SIDE:
SetEdge( 2 ); SetEdge( SHEET_TOP_SIDE );
break;
default:
break; break;
} }
} }
@ -404,12 +412,15 @@ void SCH_SHEET_PIN::MirrorY( int aYaxis_position )
switch( m_edge ) switch( m_edge )
{ {
case 0: case SHEET_LEFT_SIDE:
SetEdge( 1 ); SetEdge( SHEET_RIGHT_SIDE );
break; break;
case 1: case SHEET_RIGHT_SIDE:
SetEdge( 0 ); SetEdge( SHEET_LEFT_SIDE );
break;
default:
break; break;
} }
} }
@ -421,20 +432,23 @@ void SCH_SHEET_PIN::Rotate( wxPoint aPosition )
switch( m_edge ) switch( m_edge )
{ {
case 0: //pin on left side case SHEET_LEFT_SIDE: //pin on left side
SetEdge( 3 ); SetEdge( SHEET_BOTTOM_SIDE );
break; break;
case 1: //pin on right side case SHEET_RIGHT_SIDE: //pin on right side
SetEdge( 2 ); SetEdge( SHEET_TOP_SIDE );
break; break;
case 2: //pin on top side case SHEET_TOP_SIDE: //pin on top side
SetEdge( 0 ); SetEdge( SHEET_LEFT_SIDE );
break; break;
case 3: //pin on bottom side case SHEET_BOTTOM_SIDE: //pin on bottom side
SetEdge( 1 ); SetEdge( SHEET_RIGHT_SIDE );
break;
default:
break; break;
} }
} }

View File

@ -959,7 +959,7 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
break; break;
case SCH_SHEET_PIN_T: case SCH_SHEET_PIN_T:
EditSheetPin( (SCH_SHEET_PIN*) item, &dc ); EditSheetPin( (SCH_SHEET_PIN*) item, true );
break; break;
case SCH_TEXT_T: case SCH_TEXT_T:

View File

@ -1021,10 +1021,10 @@ private:
* Function EditSheetPin * Function EditSheetPin
* displays the dialog for editing the parameters of \a aSheetPin. * displays the dialog for editing the parameters of \a aSheetPin.
* @param aSheetPin The sheet pin item to edit. * @param aSheetPin The sheet pin item to edit.
* @param aDC The device context to draw on. * @param aRedraw = true to refresh the screen
* @return The user response from the edit dialog. * @return The user response from the edit dialog.
*/ */
int EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC ); int EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw );
/** /**
* Function ImportSheetPin * Function ImportSheetPin

View File

@ -58,7 +58,7 @@ const wxSize &SCH_EDIT_FRAME::GetLastSheetPinTextSize()
return m_lastSheetPinTextSize; return m_lastSheetPinTextSize;
} }
int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC ) int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw )
{ {
if( aSheetPin == NULL ) if( aSheetPin == NULL )
return wxID_CANCEL; return wxID_CANCEL;
@ -84,9 +84,6 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC )
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return wxID_CANCEL; return wxID_CANCEL;
if( aDC )
aSheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
if( !aSheetPin->IsNew() ) if( !aSheetPin->IsNew() )
{ {
SaveCopyInUndoList( (SCH_ITEM*) aSheetPin->GetParent(), UR_CHANGED ); SaveCopyInUndoList( (SCH_ITEM*) aSheetPin->GetParent(), UR_CHANGED );
@ -98,8 +95,10 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC )
ValueFromString( g_UserUnit, dlg.GetTextHeight() ) ) ); ValueFromString( g_UserUnit, dlg.GetTextHeight() ) ) );
aSheetPin->SetShape( dlg.GetConnectionType() ); aSheetPin->SetShape( dlg.GetConnectionType() );
if( aDC ) OnModify();
aSheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
if( aRedraw )
m_canvas->Refresh();
return wxID_OK; return wxID_OK;
} }
@ -115,7 +114,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
sheetPin->SetSize( GetLastSheetPinTextSize() ); sheetPin->SetSize( GetLastSheetPinTextSize() );
sheetPin->SetShape( m_lastSheetPinType ); sheetPin->SetShape( m_lastSheetPinType );
int response = EditSheetPin( sheetPin, NULL ); int response = EditSheetPin( sheetPin, false );
if( sheetPin->GetText().IsEmpty() || (response == wxID_CANCEL) ) if( sheetPin->GetText().IsEmpty() || (response == wxID_CANCEL) )
{ {

View File

@ -97,16 +97,20 @@ END_EVENT_TABLE()
FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway,
wxWindow* aParent, FRAME_T aFrameType ) : wxWindow* aParent, FRAME_T aFrameType ) :
PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ), PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ),
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT, #ifdef __WINDOWS__
FOOTPRINT_WIZARD_FRAME_NAME ) KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
#else
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT,
#endif
FOOTPRINT_WIZARD_FRAME_NAME )
{ {
wxASSERT( aFrameType==FRAME_PCB_FOOTPRINT_WIZARD_MODAL ); wxASSERT( aFrameType==FRAME_PCB_FOOTPRINT_WIZARD_MODAL );
if( aFrameType == FRAME_PCB_FOOTPRINT_WIZARD_MODAL ) // This frame is always show modal:
SetModal( true ); SetModal( true );
m_configPath = wxT( "FootprintWizard" ); m_configPath = FOOTPRINT_WIZARD_FRAME_NAME;
m_showAxis = true; // true to draw axis. m_showAxis = true; // true to draw axis.
// Give an icon // Give an icon