class EDA_RECT: is no more derived from EDA_ITEM, just from EDA_RECT (reason: does not use anything in EDA_ITEM)

issue in cast to wxRect fixed (EDA_RECT accepts negative size, but not wxRect, so the wxRectcast  is normalized now).
This fixes some bugs.
A minor other bug fix in Pcbnew.
This commit is contained in:
jean-pierre charras 2012-03-24 15:25:30 +01:00
parent b01bcda079
commit cf9864766b
8 changed files with 15 additions and 21 deletions

View File

@ -40,9 +40,7 @@
#include <block_commande.h> #include <block_commande.h>
BLOCK_SELECTOR::BLOCK_SELECTOR() : BLOCK_SELECTOR::BLOCK_SELECTOR() : EDA_RECT()
EDA_ITEM( BLOCK_LOCATE_STRUCT_TYPE ),
EDA_RECT()
{ {
m_State = STATE_NO_BLOCK; /* State (enum BlockState) of block. */ m_State = STATE_NO_BLOCK; /* State (enum BlockState) of block. */
m_Command = BLOCK_IDLE; /* Type (enum CmdBlockType) of operation. */ m_Command = BLOCK_IDLE; /* Type (enum CmdBlockType) of operation. */
@ -188,7 +186,6 @@ void BLOCK_SELECTOR::Clear()
{ {
if( m_Command != BLOCK_IDLE ) if( m_Command != BLOCK_IDLE )
{ {
m_Flags = 0;
m_Command = BLOCK_IDLE; m_Command = BLOCK_IDLE;
m_State = STATE_NO_BLOCK; m_State = STATE_NO_BLOCK;
ClearItemsList(); ClearItemsList();
@ -206,7 +203,6 @@ bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* DC, int key, const wxPoint& startpo
if( ( Block->m_Command != BLOCK_IDLE ) || ( Block->m_State != STATE_NO_BLOCK ) ) if( ( Block->m_Command != BLOCK_IDLE ) || ( Block->m_State != STATE_NO_BLOCK ) )
return false; return false;
Block->ClearFlags();
Block->m_Command = (CmdBlockType) ReturnBlockCommand( key ); Block->m_Command = (CmdBlockType) ReturnBlockCommand( key );
if( Block->m_Command == 0 ) if( Block->m_Command == 0 )
@ -323,7 +319,6 @@ void AbortBlockCurrentCommand( EDA_DRAW_PANEL* Panel, wxDC* DC )
screen->m_BlockLocate.ClearItemsList(); screen->m_BlockLocate.ClearItemsList();
} }
screen->m_BlockLocate.ClearFlags();
screen->m_BlockLocate.m_State = STATE_NO_BLOCK; screen->m_BlockLocate.m_State = STATE_NO_BLOCK;
screen->m_BlockLocate.m_Command = BLOCK_ABORT; screen->m_BlockLocate.m_Command = BLOCK_ABORT;
Panel->GetParent()->HandleBlockEnd( DC ); Panel->GetParent()->HandleBlockEnd( DC );

View File

@ -178,7 +178,7 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
OnModify(); OnModify();
// clear struct.m_Flags. // clear dome flags and pointers
GetScreen()->ClearDrawingState(); GetScreen()->ClearDrawingState();
GetScreen()->ClearBlockCommand(); GetScreen()->ClearBlockCommand();
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
@ -308,7 +308,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
if( ! nextcmd ) if( ! nextcmd )
{ {
block->ClearFlags();
block->m_State = STATE_NO_BLOCK; block->m_State = STATE_NO_BLOCK;
block->m_Command = BLOCK_IDLE; block->m_Command = BLOCK_IDLE;
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );

View File

@ -201,7 +201,6 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY && m_component ) if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY && m_component )
m_component->ClearSelectedItems(); m_component->ClearSelectedItems();
GetScreen()->m_BlockLocate.ClearFlags();
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
@ -298,7 +297,6 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
OnModify(); OnModify();
GetScreen()->m_BlockLocate.ClearFlags();
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );

View File

@ -279,8 +279,15 @@ public:
/** /**
* Function operator(wxRect) * Function operator(wxRect)
* overloads the cast operator to return a wxRect * overloads the cast operator to return a wxRect
* wxRect does not accept negative values for size, so ensure the
* wxRect size is always >= 0
*/ */
operator wxRect() const { return wxRect( m_Pos, m_Size ); } operator wxRect() const
{
EDA_RECT rect( m_Pos, m_Size );
rect.Normalize();
return wxRect( rect.m_Pos, rect.m_Size );
}
/** /**
* Function Inflate * Function Inflate

View File

@ -53,7 +53,7 @@ typedef enum {
} CmdBlockType; } CmdBlockType;
class BLOCK_SELECTOR : public EDA_ITEM, public EDA_RECT class BLOCK_SELECTOR : public EDA_RECT
{ {
public: public:
BlockState m_State; /* State (enum BlockState) BlockState m_State; /* State (enum BlockState)
@ -143,10 +143,6 @@ public:
* and clears the selected item list. * and clears the selected item list.
*/ */
void Clear(); void Clear();
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const {} // override
#endif
}; };

View File

@ -288,7 +288,6 @@ void FOOTPRINT_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
OnModify(); OnModify();
GetScreen()->m_BlockLocate.ClearFlags();
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
SetCurItem( NULL ); SetCurItem( NULL );

View File

@ -690,8 +690,8 @@ if you do not want this pad plotted in gerber files");
max_size.y = ABS( m_dummyPad->GetOffset().y ); max_size.y = ABS( m_dummyPad->GetOffset().y );
max_size.x += m_dummyPad->GetDrillSize().x / 2; max_size.x += m_dummyPad->GetDrillSize().x / 2;
max_size.y += m_dummyPad->GetDrillSize().y / 2; max_size.y += m_dummyPad->GetDrillSize().y / 2;
if( ( m_dummyPad->GetSize().x / 2 <= max_size.x ) || if( ( m_dummyPad->GetSize().x / 2 < max_size.x ) ||
( m_dummyPad->GetSize().y / 2 <= max_size.y ) ) ( m_dummyPad->GetSize().y / 2 < max_size.y ) )
{ {
error_msgs.Add( _( "Incorrect value for pad offset" ) ); error_msgs.Add( _( "Incorrect value for pad offset" ) );
} }

View File

@ -747,8 +747,8 @@ void PCB_BASE_FRAME::Plot_Layer( PLOTTER* plotter, int Layer, EDA_DRAW_MODE_T tr
} }
/* Plot a copper layer or mask in HPGL format. /* Plot a copper layer or mask.
* HPGL unit = 0.98 mils (1 mil = 1.02041 unit HPGL). * Silk screen layers are not plotted here.
*/ */
void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
int aLayerMask, int aLayerMask,