← Back to team overview

kicad-developers team mailing list archive

Re: EESchema XOR-Artifacts

 

Hi,

I have fixed artefacts for (some?) block commands, see attached patch.

The patch also reorganizes the code a bit: I have removed the check of whether 
a class has a GetBoundingBox() or not (block.cpp, lines 960+). Instead, the 
default GetBoundingBox() spits out the debug message.

Best regards
Jonas.

 --Boundary-00=_nrS3HNWd9xzuW6D Content-Type: text/x-diff;
charset="utf-8";
name="eeschema_redraw-3.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="eeschema_redraw-3.patch"

diff -r ae9d1357f96f kicad/common/base_struct.cpp
--- a/kicad/common/base_struct.cpp	Sun Mar 16 04:47:04 2008 +0000
+++ b/kicad/common/base_struct.cpp	Sun Mar 16 15:02:39 2008 +0100
@@ -808,6 +808,29 @@ DrawPickedStruct::~DrawPickedStruct()
{
}

+#if defined(DEBUG)
+void DrawPickedStruct::Show( int nestLevel, std::ostream& os )
+{
+ NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << "/>\n";
+}
+#endif
+
+EDA_Rect DrawPickedStruct::GetBoundingBox()
+{
+ EDA_BaseStruct* item = m_PickedStruct;
+ if (!item) // empty list
+ return EDA_BaseStruct::GetBoundingBox();
+
+ EDA_Rect box = item->GetBoundingBox();
+ EDA_BaseStruct* Structs = (DrawPickedStruct*) Pnext;
+
+ while( Structs ){
+ item = ((DrawPickedStruct*)Structs)->m_PickedStruct;
+ box.Merge(item->GetBoundingBox());
+ Structs = Structs->Pnext;
+ }
+ return box;
+}

/*********************************************/
void DrawPickedStruct::DeleteWrapperList()
diff -r ae9d1357f96f kicad/eeschema/block.cpp
--- a/kicad/eeschema/block.cpp	Sun Mar 16 04:47:04 2008 +0000
+++ b/kicad/eeschema/block.cpp	Sun Mar 16 15:02:39 2008 +0100
@@ -563,7 +563,7 @@ bool MoveStruct( WinEDA_DrawPanel* panel
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{
if( DC )
- RedrawStructList( panel, DC, DrawStruct, g_XorMode );
+ panel->PostDirtyRect( DrawStruct->GetBoundingBox() );
PlaceStruct( panel->GetScreen(), DrawStruct ); /* Place it in its new position. */
if( DC )
RedrawStructList( panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
@@ -575,7 +575,7 @@ bool MoveStruct( WinEDA_DrawPanel* panel
else
{
if( DC )
- RedrawOneStruct( panel, DC, DrawStruct, g_XorMode );
+ panel->PostDirtyRect( DrawStruct->GetBoundingBox());
PlaceStruct( panel->GetScreen(), DrawStruct ); /* Place it in its new position. */
if( DC )
RedrawOneStruct( panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
@@ -762,7 +762,7 @@ bool MirrorStruct( WinEDA_DrawPanel* pan
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{
if( DC )
- RedrawStructList( panel, DC, DrawStruct, g_XorMode );
+ panel->PostDirtyRect( DrawStruct->GetBoundingBox() );
DrawStructs = (DrawPickedStruct*) DrawStruct;
while( DrawStructs )
{
@@ -781,7 +781,7 @@ bool MirrorStruct( WinEDA_DrawPanel* pan
else
{
if( DC )
- RedrawOneStruct( panel, DC, DrawStruct, g_XorMode );
+ panel->PostDirtyRect( DrawStruct->GetBoundingBox() );
MirrorOneStruct( DrawStruct, Center ); /* Place it in its new position. */
if( DC )
RedrawOneStruct( panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
@@ -947,13 +947,12 @@ void DeleteStruct( WinEDA_DrawPanel* pan
while( PickedList )
{
screen->RemoveFromDrawList( PickedList->m_PickedStruct );
+ panel->PostDirtyRect( PickedList->m_PickedStruct->GetBoundingBox() );
PickedList->m_PickedStruct->Pnext =
- PickedList->m_PickedStruct->Pback = NULL;
+ PickedList->m_PickedStruct->Pback = NULL;
PickedList->m_PickedStruct->m_Flags = IS_DELETED;
PickedList = PickedList->Next();
}
-
- RedrawStructList( panel, DC, DrawStruct, g_XorMode );

/* Removed items are put to the Undo list */
frame->SaveCopyInUndoList( DrawStruct, IS_DELETED );
@@ -961,18 +960,7 @@ void DeleteStruct( WinEDA_DrawPanel* pan
else /* structure classique */
{
screen->RemoveFromDrawList( DrawStruct );
-
- if( (DrawStruct->Type() == DRAW_SEGMENT_STRUCT_TYPE) ||
- (DrawStruct->Type() == DRAW_JUNCTION_STRUCT_TYPE) ||
- (DrawStruct->Type() == DRAW_LIB_ITEM_STRUCT_TYPE) )
- {
- panel->PostDirtyRect( DrawStruct->GetBoundingBox() );
- }
- else
- {
- D( DrawStruct->Show( 0, std::cout ); ) // tell me which classes still need GetBoundingBox support
- RedrawOneStruct( panel, DC, DrawStruct, g_XorMode );
- }
+ panel->PostDirtyRect( DrawStruct->GetBoundingBox() );

/* Unlink the structure */
DrawStruct->Pnext = DrawStruct->Pback = NULL; // Only one struct -> no link
diff -r ae9d1357f96f kicad/eeschema/getpart.cpp
--- a/kicad/eeschema/getpart.cpp	Sun Mar 16 04:47:04 2008 +0000
+++ b/kicad/eeschema/getpart.cpp	Sun Mar 16 15:02:39 2008 +0100
@@ -292,8 +292,9 @@ void WinEDA_SchematicFrame::CmpRotationM
DrawPanel->CursorOff( DC );
if( DrawComponent->m_Flags )
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
- else
- DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
+ else{
+ DrawPanel->PostDirtyRect( DrawComponent->GetBoundingBox());
+ }
}

DrawComponent->SetRotationMiroir( type_rotate );
diff -r ae9d1357f96f kicad/include/base_struct.h
--- a/kicad/include/base_struct.h	Sun Mar 16 04:47:04 2008 +0000
+++ b/kicad/include/base_struct.h	Sun Mar 16 15:02:39 2008 +0100
@@ -357,6 +357,10 @@ public:
*/
virtual EDA_Rect GetBoundingBox()
{
+#if defined (DEBUG)
+ printf("Missing GetBoundingBox() -> no good! :-)\n");
+ Show( 0, std::cout ); // tell me which classes still need GetBoundingBox support
+#endif
// return a zero-sized box per default. derived classes should override this
EDA_Rect ret( wxPoint( 0, 0 ), wxSize( 0, 0 ) );
return ret;
@@ -691,6 +695,9 @@ public:
void DeleteWrapperList();

DrawPickedStruct* Next() { return (DrawPickedStruct*) Pnext; }
+ void Show( int nestLevel, std::ostream& os );
+ wxString GetClass() const { return wxT( "DrawPickedStruct" ); }
+ EDA_Rect GetBoundingBox();
};

#endif /* BASE_STRUCT_H */
 --Boundary-00=_nrS3HNWd9xzuW6D-- 




Follow ups

References