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

View File

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

View File

@ -1021,10 +1021,10 @@ private:
* Function EditSheetPin
* displays the dialog for editing the parameters of \a aSheetPin.
* @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.
*/
int EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC );
int EditSheetPin( SCH_SHEET_PIN* aSheetPin, bool aRedraw );
/**
* Function ImportSheetPin

View File

@ -58,7 +58,7 @@ const wxSize &SCH_EDIT_FRAME::GetLastSheetPinTextSize()
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 )
return wxID_CANCEL;
@ -84,9 +84,6 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC )
if( dlg.ShowModal() == wxID_CANCEL )
return wxID_CANCEL;
if( aDC )
aSheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
if( !aSheetPin->IsNew() )
{
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() ) ) );
aSheetPin->SetShape( dlg.GetConnectionType() );
if( aDC )
aSheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
OnModify();
if( aRedraw )
m_canvas->Refresh();
return wxID_OK;
}
@ -115,7 +114,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
sheetPin->SetSize( GetLastSheetPinTextSize() );
sheetPin->SetShape( m_lastSheetPinType );
int response = EditSheetPin( sheetPin, NULL );
int response = EditSheetPin( sheetPin, false );
if( sheetPin->GetText().IsEmpty() || (response == wxID_CANCEL) )
{

View File

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