Dirty rect used in footprint start move, rotation, flip and delete.
This commit is contained in:
parent
8e5665c22a
commit
fb54ab8649
|
@ -5,6 +5,12 @@ Started 2007-June-11
|
||||||
Please add newer entries at the top, list the date and your name with
|
Please add newer entries at the top, list the date and your name with
|
||||||
email address.
|
email address.
|
||||||
|
|
||||||
|
2008-Mar-13 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
|
||||||
|
================================================================================
|
||||||
|
+pcbnew
|
||||||
|
Dirty rect used in footprint rotation, flip and delete.
|
||||||
|
Better calculation of the footprint dirty rect.
|
||||||
|
|
||||||
|
|
||||||
2008-Mar-13 UPDATE Dick Hollenbeck <dick@softplc.com>
|
2008-Mar-13 UPDATE Dick Hollenbeck <dick@softplc.com>
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
|
@ -167,7 +167,7 @@ public:
|
||||||
#define STRUCT_DELETED (1 << 13) ///< Bit flag de Status pour structures effacee
|
#define STRUCT_DELETED (1 << 13) ///< Bit flag de Status pour structures effacee
|
||||||
#define CANDIDATE (1 << 14) ///< flag indiquant que la structure est connectee
|
#define CANDIDATE (1 << 14) ///< flag indiquant que la structure est connectee
|
||||||
#define SKIP_STRUCT (1 << 15) ///< flag indiquant que la structure ne doit pas etre traitee
|
#define SKIP_STRUCT (1 << 15) ///< flag indiquant que la structure ne doit pas etre traitee
|
||||||
|
#define DO_NOT_DRAW (1 << 16) ///< Used to disable draw function
|
||||||
|
|
||||||
unsigned long m_TimeStamp; // Time stamp used for logical links
|
unsigned long m_TimeStamp; // Time stamp used for logical links
|
||||||
int m_Selected; /* Used by block commands, and selective editing */
|
int m_Selected; /* Used by block commands, and selective editing */
|
||||||
|
|
|
@ -267,20 +267,22 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
||||||
const wxPoint& offset, int draw_mode )
|
const wxPoint& offset, int draw_mode )
|
||||||
/**********************************************************/
|
/**********************************************************/
|
||||||
|
|
||||||
/* Dessin d'une empreinte sur l'ecran actif:
|
/** Function Draw
|
||||||
* Entree :
|
* Draws the footprint to the current Device Context
|
||||||
* Module: pointeur sur le module
|
* @param panel = The active Draw Panel (used to know the clip box)
|
||||||
* ox, oy = offset de trace
|
* @param DC = current Device Context
|
||||||
* draw_mode = mode de trace ( GR_OR, GR_XOR, GR_AND)
|
* @param offset = draw offset (usually wxPoint(0,0)
|
||||||
* Utilise par ailleur:
|
* @param draw_mode = GR_OR, GR_XOR, GR_AND
|
||||||
* Description des parametres de l'empreinte calcules par caract() ;
|
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
D_PAD* pt_pad;
|
D_PAD* pt_pad;
|
||||||
EDA_BaseStruct* PtStruct;
|
EDA_BaseStruct* PtStruct;
|
||||||
TEXTE_MODULE* PtTexte;
|
TEXTE_MODULE* PtTexte;
|
||||||
|
|
||||||
|
if ( (m_Flags & DO_NOT_DRAW) )
|
||||||
|
return;
|
||||||
|
|
||||||
/* trace des pastilles */
|
/* Draw pads */
|
||||||
pt_pad = m_Pads;
|
pt_pad = m_Pads;
|
||||||
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
|
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
|
||||||
{
|
{
|
||||||
|
@ -289,10 +291,10 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
||||||
pt_pad->Draw( panel, DC, offset, draw_mode );
|
pt_pad->Draw( panel, DC, offset, draw_mode );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Impression de l'ancre du module */
|
/* Draws foootprint anchor */
|
||||||
DrawAncre( panel, DC, offset, DIM_ANCRE_MODULE, draw_mode );
|
DrawAncre( panel, DC, offset, DIM_ANCRE_MODULE, draw_mode );
|
||||||
|
|
||||||
/* impression des graphismes */
|
/* Draw graphic items */
|
||||||
if( !(m_Reference->m_Flags & IS_MOVED) )
|
if( !(m_Reference->m_Flags & IS_MOVED) )
|
||||||
m_Reference->Draw( panel, DC, offset, draw_mode );
|
m_Reference->Draw( panel, DC, offset, draw_mode );
|
||||||
if( !(m_Value->m_Flags & IS_MOVED) )
|
if( !(m_Value->m_Flags & IS_MOVED) )
|
||||||
|
@ -326,10 +328,17 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
|
||||||
void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
|
void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
|
||||||
const wxPoint& offset, int draw_mode )
|
const wxPoint& offset, int draw_mode )
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
|
/** Function DrawEdgesOnly
|
||||||
|
* Draws the footprint edges only to the current Device Context
|
||||||
|
* @param panel = The active Draw Panel (used to know the clip box)
|
||||||
|
* @param DC = current Device Context
|
||||||
|
* @param offset = draw offset (usually wxPoint(0,0)
|
||||||
|
* @param draw_mode = GR_OR, GR_XOR, GR_AND
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
EDA_BaseStruct* PtStruct;
|
EDA_BaseStruct* PtStruct;
|
||||||
|
|
||||||
/* impression des graphismes */
|
/* Draw graphic items */
|
||||||
PtStruct = m_Drawings;
|
PtStruct = m_Drawings;
|
||||||
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
for( ; PtStruct != NULL; PtStruct = PtStruct->Pnext )
|
||||||
{
|
{
|
||||||
|
@ -1041,13 +1050,55 @@ void MODULE::SetRectangleExinscrit()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetBoundingBox
|
* Function GetBoundingBox
|
||||||
* returns the bounding box of this Footprint
|
* returns the full bounding box of this Footprint, including texts
|
||||||
*/
|
*/
|
||||||
EDA_Rect MODULE::GetBoundingBox()
|
EDA_Rect MODULE::GetBoundingBox()
|
||||||
{
|
{
|
||||||
|
// Calculate area without text fielsd:
|
||||||
SetRectangleExinscrit();
|
SetRectangleExinscrit();
|
||||||
return m_RealBoundaryBox;
|
EDA_Rect area = m_RealBoundaryBox;
|
||||||
|
|
||||||
|
area.Normalize();
|
||||||
|
// Calculate extended area including text field:
|
||||||
|
EDGE_MODULE* EdgeMod = (EDGE_MODULE*) m_Drawings;
|
||||||
|
TEXTE_MODULE* text;
|
||||||
|
EDA_Rect text_area;
|
||||||
|
wxPoint textstart, textend;
|
||||||
|
wxPoint modstart = area.GetOrigin();
|
||||||
|
wxPoint modend = area.GetEnd();
|
||||||
|
for( int ii = 0 ; ; ii++ )
|
||||||
|
{
|
||||||
|
if ( ii == 0 )
|
||||||
|
text = m_Reference;
|
||||||
|
else if ( ii == 1 )
|
||||||
|
text = m_Value;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( EdgeMod == NULL ) break;
|
||||||
|
text = (TEXTE_MODULE*) EdgeMod;
|
||||||
|
EdgeMod = (EDGE_MODULE*) EdgeMod->Pnext;
|
||||||
|
if( text->Type() != TYPETEXTEMODULE )
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
text_area = text->GetTextRect();
|
||||||
|
textstart = text_area.GetOrigin();
|
||||||
|
textend = text_area.GetEnd();
|
||||||
|
int angle = text->GetDrawRotation();
|
||||||
|
RotatePoint( &textstart, text->m_Pos, angle);
|
||||||
|
RotatePoint( &textend, text->m_Pos, angle);
|
||||||
|
modstart.x = min( modstart.x, textstart.x);
|
||||||
|
modstart.x = min( modstart.x, textend.x);
|
||||||
|
modstart.y = min( modstart.y, textstart.y);
|
||||||
|
modstart.y = min( modstart.y, textend.y);
|
||||||
|
modend.x = max( modend.x, textstart.x);
|
||||||
|
modend.x = max( modend.x, textend.x);
|
||||||
|
modend.y = max( modend.y, textstart.y);
|
||||||
|
modend.y = max( modend.y, textend.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
area.SetOrigin(modstart);
|
||||||
|
area.SetEnd(modend);
|
||||||
|
return area;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************/
|
/*******************************************************/
|
||||||
|
|
|
@ -194,6 +194,31 @@ void TEXTE_MODULE:: SetLocalCoord()
|
||||||
|
|
||||||
|
|
||||||
/* locate functions */
|
/* locate functions */
|
||||||
|
|
||||||
|
/** Function GetTextRect
|
||||||
|
* @return an EDA_Rect which gives the position and size of the text area (for the O orient footprint)
|
||||||
|
*/
|
||||||
|
EDA_Rect TEXTE_MODULE::GetTextRect(void)
|
||||||
|
{
|
||||||
|
EDA_Rect area;
|
||||||
|
|
||||||
|
int dx, dy;
|
||||||
|
dx = ( m_Size.x * GetLength() ) / 2;
|
||||||
|
dx = (dx * 10) / 9 ; /* letter size = 10/9 */
|
||||||
|
dx += m_Width / 2;
|
||||||
|
dy = ( m_Size.y + m_Width ) / 2;
|
||||||
|
|
||||||
|
wxPoint Org = m_Pos; // This is the position of the centre of the area
|
||||||
|
Org.x -= dx;
|
||||||
|
Org.y -= dy;
|
||||||
|
area.SetOrigin( Org);
|
||||||
|
area.SetHeight(2 * dy);
|
||||||
|
area.SetWidth(2 * dx);
|
||||||
|
area.Normalize();
|
||||||
|
|
||||||
|
return area;
|
||||||
|
}
|
||||||
|
|
||||||
bool TEXTE_MODULE::HitTest( const wxPoint& posref )
|
bool TEXTE_MODULE::HitTest( const wxPoint& posref )
|
||||||
{
|
{
|
||||||
int mX, mY, dx, dy;
|
int mX, mY, dx, dy;
|
||||||
|
@ -204,8 +229,9 @@ bool TEXTE_MODULE::HitTest( const wxPoint& posref )
|
||||||
angle += Module->m_Orient;
|
angle += Module->m_Orient;
|
||||||
|
|
||||||
dx = ( m_Size.x * GetLength() ) / 2;
|
dx = ( m_Size.x * GetLength() ) / 2;
|
||||||
dy = m_Size.y / 2;
|
dx = (dx * 10) / 9; /* Facteur de forme des lettres : 10/9 */
|
||||||
dx = ( (dx * 10) / 9 ) + m_Width; /* Facteur de forme des lettres : 10/9 */
|
dx += m_Width / 2;
|
||||||
|
dy = ( m_Size.y + m_Width ) / 2;
|
||||||
|
|
||||||
/* le point de reference est tourn<72>de - angle
|
/* le point de reference est tourn<72>de - angle
|
||||||
* pour se ramener a un rectangle de reference horizontal */
|
* pour se ramener a un rectangle de reference horizontal */
|
||||||
|
|
|
@ -53,6 +53,11 @@ public:
|
||||||
int GetLength(); /* text length */
|
int GetLength(); /* text length */
|
||||||
int Pitch(); /* retourne le pas entre 2 caracteres */
|
int Pitch(); /* retourne le pas entre 2 caracteres */
|
||||||
int GetDrawRotation(); // Return text rotation for drawings and plotting
|
int GetDrawRotation(); // Return text rotation for drawings and plotting
|
||||||
|
|
||||||
|
/** Function GetTextRect
|
||||||
|
* @return an EDA_Rect which gives the position and size of the text area (for the O orient text and footprint)
|
||||||
|
*/
|
||||||
|
EDA_Rect GetTextRect(void);
|
||||||
|
|
||||||
void SetDrawCoord(); // mise a jour des coordonn<6E>s absolues de trac<61>
|
void SetDrawCoord(); // mise a jour des coordonn<6E>s absolues de trac<61>
|
||||||
// a partir des coord relatives
|
// a partir des coord relatives
|
||||||
|
|
|
@ -500,9 +500,6 @@ void WinEDA_ModulePropertiesFrame::OnOkClick( wxCommandEvent& event )
|
||||||
if( m_DC )
|
if( m_DC )
|
||||||
m_Parent->DrawPanel->CursorOff( m_DC );
|
m_Parent->DrawPanel->CursorOff( m_DC );
|
||||||
|
|
||||||
if( m_DC )
|
|
||||||
m_CurrentModule->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_XOR );
|
|
||||||
|
|
||||||
if( m_OrientValue )
|
if( m_OrientValue )
|
||||||
{
|
{
|
||||||
long orient = 0; wxString msg = m_OrientValue->GetValue();
|
long orient = 0; wxString msg = m_OrientValue->GetValue();
|
||||||
|
|
|
@ -126,7 +126,13 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
|
||||||
DrawPanel->m_AutoPAN_Request = TRUE;
|
DrawPanel->m_AutoPAN_Request = TRUE;
|
||||||
|
|
||||||
// effacement module a l'ecran:
|
// effacement module a l'ecran:
|
||||||
module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
|
if ( DC )
|
||||||
|
{
|
||||||
|
int tmp = module->m_Flags;
|
||||||
|
module->m_Flags |= DO_NOT_DRAW;
|
||||||
|
DrawPanel->PostDirtyRect( module->GetBoundingBox() );
|
||||||
|
module->m_Flags = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
// Reaffichage
|
// Reaffichage
|
||||||
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
||||||
|
@ -250,8 +256,7 @@ void Montre_Position_Empreinte( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Redessine le module a la nouvelle place */
|
/* Redessine le module a la nouvelle place */
|
||||||
g_Offset_Module.x = module->m_Pos.x - panel->m_Parent->m_CurrentScreen->m_Curseur.x;
|
g_Offset_Module = module->m_Pos - panel->m_Parent->m_CurrentScreen->m_Curseur;
|
||||||
g_Offset_Module.y = module->m_Pos.y - panel->m_Parent->m_CurrentScreen->m_Curseur.y;
|
|
||||||
DrawModuleOutlines( panel, DC, module );
|
DrawModuleOutlines( panel, DC, module );
|
||||||
|
|
||||||
Dessine_Segments_Dragges( panel, DC );
|
Dessine_Segments_Dragges( panel, DC );
|
||||||
|
@ -333,7 +338,7 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC )
|
||||||
* The mirroring is made from X axis
|
* The mirroring is made from X axis
|
||||||
* if a footprint is not on copper or component layer it is not flipped
|
* if a footprint is not on copper or component layer it is not flipped
|
||||||
* (it could be on an adhesive layer, not supported at this time)
|
* (it could be on an adhesive layer, not supported at this time)
|
||||||
* @param Module the footprint to fli^p
|
* @param Module the footprint to flip
|
||||||
* @param DC Current Device Context. if NULL, no redraw
|
* @param DC Current Device Context. if NULL, no redraw
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
@ -353,7 +358,12 @@ void BOARD::Change_Side_Module( MODULE* Module, wxDC* DC )
|
||||||
{
|
{
|
||||||
m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK);
|
m_Status_Pcb &= ~( LISTE_CHEVELU_OK | CONNEXION_OK);
|
||||||
if( DC && m_PcbFrame )
|
if( DC && m_PcbFrame )
|
||||||
Module->Draw( m_PcbFrame->DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
|
{
|
||||||
|
int tmp = Module->m_Flags;
|
||||||
|
Module->m_Flags |= DO_NOT_DRAW;
|
||||||
|
m_PcbFrame->DrawPanel->PostDirtyRect( Module->GetBoundingBox() );
|
||||||
|
Module->m_Flags = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
/* Effacement chevelu general si necessaire */
|
/* Effacement chevelu general si necessaire */
|
||||||
if( DC && g_Show_Ratsnest )
|
if( DC && g_Show_Ratsnest )
|
||||||
|
@ -709,7 +719,11 @@ void WinEDA_BasePcbFrame::Rotate_Module( wxDC* DC, MODULE* module,
|
||||||
{
|
{
|
||||||
if( DC )
|
if( DC )
|
||||||
{
|
{
|
||||||
module->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
|
int tmp = module->m_Flags;
|
||||||
|
module->m_Flags |= DO_NOT_DRAW;
|
||||||
|
DrawPanel->PostDirtyRect( module->GetBoundingBox() );
|
||||||
|
module->m_Flags = tmp;
|
||||||
|
|
||||||
/* Reaffichage chevelu general si necessaire */
|
/* Reaffichage chevelu general si necessaire */
|
||||||
if( g_Show_Ratsnest )
|
if( g_Show_Ratsnest )
|
||||||
DrawGeneralRatsnest( DC );
|
DrawGeneralRatsnest( DC );
|
||||||
|
|
Loading…
Reference in New Issue