Commit c5b42440 authored by dickelbeck's avatar dickelbeck
Browse files

dirty rectangle screening, pending EDA_BaseStruct::GetBoundingBox()

parent 0f0ced37
Loading
Loading
Loading
Loading
+460 −398
Original line number Original line Diff line number Diff line
@@ -74,17 +74,22 @@ void SetHighLightStruct(EDA_BaseStruct *HighLight)
    HighLightStruct = HighLight;
    HighLightStruct = HighLight;
}
}



/**********************************************************************/
/**********************************************************************/
void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/**********************************************************************/
/**********************************************************************/

/*
/*
 Redraws only the active window which is assumed to be whole visible.
  * Redraws only the active window which is assumed to be whole visible.
 */
 */
{
{
    wxString title;
    wxString title;
	if( GetScreen() == NULL ) return;

    if( GetScreen() == NULL )
        return;


    ActiveScreen = GetScreen();
    ActiveScreen = GetScreen();

    /* Forcage de la reinit de la brosse et plume courante */
    /* Forcage de la reinit de la brosse et plume courante */
    GRResetPenAndBrush( DC );
    GRResetPenAndBrush( DC );
    DC->SetBackground( *wxBLACK_BRUSH );
    DC->SetBackground( *wxBLACK_BRUSH );
@@ -97,7 +102,8 @@ wxString title;
        DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
        DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
    }
    }


	if ( EraseBg ) DrawPanel->EraseScreen(DC);
    if( EraseBg )
        DrawPanel->EraseScreen( DC );


    DrawPanel->DrawBackGround( DC );
    DrawPanel->DrawBackGround( DC );


@@ -124,9 +130,9 @@ wxString title;
        title.Printf( wxT( "[%s]" ), GetScreen()->m_FileName.GetData() );
        title.Printf( wxT( "[%s]" ), GetScreen()->m_FileName.GetData() );
        SetTitle( title );
        SetTitle( title );
    }
    }

}
}



/*******************************************************************************/
/*******************************************************************************/
void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int PrintMask )
void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int PrintMask )
/*******************************************************************************/
/*******************************************************************************/
@@ -135,7 +141,6 @@ BASE_SCREEN * screen;


    wxBeginBusyCursor();
    wxBeginBusyCursor();



    ActiveScreen = screen = m_Parent->GetScreen();
    ActiveScreen = screen = m_Parent->GetScreen();
    RedrawStructList( this, DC, screen->EEDrawList, GR_COPY );
    RedrawStructList( this, DC, screen->EEDrawList, GR_COPY );


@@ -153,40 +158,58 @@ BASE_SCREEN * screen;
void RedrawStructList( WinEDA_DrawPanel* panel, wxDC* DC,
void RedrawStructList( WinEDA_DrawPanel* panel, wxDC* DC,
                       EDA_BaseStruct* Structs, int DrawMode, int Color )
                       EDA_BaseStruct* Structs, int DrawMode, int Color )
{
{

#if 0
    // enable this when we have virtual GetBoundingBox():
    wxRegion    upd = panel->GetUpdateRegion(); // get the update rect list

    // get the union of all rectangles in the update region, 'upd'
    wxRect      dirtyRects = upd.GetBox();

    EDA_Rect boxtest;
#endif


    while( Structs )
    while( Structs )
    {
    {
        if( Structs->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
        if( Structs->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
        {
        {
			RedrawOneStruct(panel, DC,
            EDA_BaseStruct* item = ( (DrawPickedStruct*) Structs )->m_PickedStruct;
						((DrawPickedStruct *) Structs)->m_PickedStruct,
//            if( dirtyRects.Intersects( item->GetBoundingBox() ) )
									 DrawMode, Color);
            {
                RedrawOneStruct( panel, DC, item, DrawMode, Color );
            }
        }
        }
        else
        else
        {
        {
            if( !(Structs->m_Flags & IS_MOVED) )
            if( !(Structs->m_Flags & IS_MOVED) )
            {
//                if( dirtyRects.Intersects( Structs->GetBoundingBox() ) )
                    RedrawOneStruct( panel, DC, Structs, DrawMode, Color );
                    RedrawOneStruct( panel, DC, Structs, DrawMode, Color );
            }
            }
        }


        Structs = Structs->Pnext;
        Structs = Structs->Pnext;
    }
    }
}
}



/*****************************************************************************
/*****************************************************************************
* Routine to redraw list of structs.										 *
* Routine to redraw list of structs.										 *
*****************************************************************************/
*****************************************************************************/
void RedrawOneStruct( WinEDA_DrawPanel* panel, wxDC* DC,
void RedrawOneStruct( WinEDA_DrawPanel* panel, wxDC* DC,
                      EDA_BaseStruct* Struct, int DrawMode, int Color )
                      EDA_BaseStruct* Struct, int DrawMode, int Color )
{
{
    if( Struct == NULL )
        return;


	if ( Struct == NULL ) return;
    if( HighLightStruct == Struct )
	if (HighLightStruct == Struct) Color = HIGHLIGHT_COLOR;
        Color = HIGHLIGHT_COLOR;


    Struct->Draw( panel, DC, wxPoint( 0, 0 ), DrawMode, Color );
    Struct->Draw( panel, DC, wxPoint( 0, 0 ), DrawMode, Color );
}
}






/*****************************************************************************************/
/*****************************************************************************************/
void EDA_DrawLineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
void EDA_DrawLineStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
                               int DrawMode, int Color )
                               int DrawMode, int Color )
@@ -197,8 +220,11 @@ int color;
    int zoom  = panel->GetZoom();
    int zoom  = panel->GetZoom();
    int width = MAX( m_Width, g_DrawMinimunLineWidth );
    int width = MAX( m_Width, g_DrawMinimunLineWidth );


	if( Color >= 0 ) color = Color;
    if( Color >= 0 )
	else color = ReturnLayerColor(m_Layer);
        color = Color;
    else
        color = ReturnLayerColor( m_Layer );

    GRSetDrawMode( DC, DrawMode );
    GRSetDrawMode( DC, DrawMode );
    if( (m_Layer == LAYER_BUS) && (zoom <= 16) )
    if( (m_Layer == LAYER_BUS) && (zoom <= 16) )
        width *= 3;
        width *= 3;
@@ -206,7 +232,6 @@ int width = MAX(m_Width, g_DrawMinimunLineWidth);
    if( m_Layer == LAYER_NOTES )
    if( m_Layer == LAYER_NOTES )
        GRDashedLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, m_Start.y + offset.y,
        GRDashedLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, m_Start.y + offset.y,
            m_End.x + offset.x, m_End.y + offset.y, width, color );
            m_End.x + offset.x, m_End.y + offset.y, width, color );

    else
    else
        GRLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, m_Start.y + offset.y,
        GRLine( &panel->m_ClipBox, DC, m_Start.x + offset.x, m_Start.y + offset.y,
            m_End.x + offset.x, m_End.y + offset.y, width, color );
            m_End.x + offset.x, m_End.y + offset.y, width, color );
@@ -237,10 +262,11 @@ void DrawMarkerStruct::Draw(WinEDA_DrawPanel * panel,wxDC * DC, const wxPoint &
        }
        }
        Draw_Marqueur( panel, DC, m_Pos + offset, marqERC_bitmap, DrawMode, color );
        Draw_Marqueur( panel, DC, m_Pos + offset, marqERC_bitmap, DrawMode, color );
    }
    }

    else
	else Draw_Marqueur(panel, DC, m_Pos+offset, marq_bitmap, DrawMode, Color);
        Draw_Marqueur( panel, DC, m_Pos + offset, marq_bitmap, DrawMode, Color );
}
}



/*************************************************************************/
/*************************************************************************/
void DrawNoConnectStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
void DrawNoConnectStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
                                int DrawMode, int Color )
                                int DrawMode, int Color )
@@ -253,15 +279,17 @@ int width = g_DrawMinimunLineWidth;


    pX = m_Pos.x + offset.x; pY = m_Pos.y + offset.y;
    pX = m_Pos.x + offset.x; pY = m_Pos.y + offset.y;


	if( Color >= 0 ) color = Color;
    if( Color >= 0 )
	else color = ReturnLayerColor(LAYER_NOCONNECT);
        color = Color;
    else
        color = ReturnLayerColor( LAYER_NOCONNECT );
    GRSetDrawMode( DC, DrawMode );
    GRSetDrawMode( DC, DrawMode );


    GRLine( &panel->m_ClipBox, DC, pX - DELTA, pY - DELTA, pX + DELTA, pY + DELTA, width, color );
    GRLine( &panel->m_ClipBox, DC, pX - DELTA, pY - DELTA, pX + DELTA, pY + DELTA, width, color );
    GRLine( &panel->m_ClipBox, DC, pX + DELTA, pY - DELTA, pX - DELTA, pY + DELTA, width, color );
    GRLine( &panel->m_ClipBox, DC, pX + DELTA, pY - DELTA, pX - DELTA, pY + DELTA, width, color );

}
}



/**************************************************************/
/**************************************************************/
void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
void DrawBusEntryStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
                               int DrawMode, int Color )
                               int DrawMode, int Color )
@@ -274,8 +302,10 @@ int color;
    int zoom  = panel->GetZoom();
    int zoom  = panel->GetZoom();
    int width = MAX( m_Width, g_DrawMinimunLineWidth );
    int width = MAX( m_Width, g_DrawMinimunLineWidth );


	if( Color >= 0 ) color = Color;
    if( Color >= 0 )
	else color = ReturnLayerColor(m_Layer);
        color = Color;
    else
        color = ReturnLayerColor( m_Layer );
    GRSetDrawMode( DC, DrawMode );
    GRSetDrawMode( DC, DrawMode );


    if( (m_Layer == LAYER_BUS) && (zoom <= 16) )
    if( (m_Layer == LAYER_BUS) && (zoom <= 16) )
@@ -283,9 +313,9 @@ int width = MAX(m_Width, g_DrawMinimunLineWidth);


    GRLine( &panel->m_ClipBox, DC, m_Pos.x + offset.x, m_Pos.y + offset.y,
    GRLine( &panel->m_ClipBox, DC, m_Pos.x + offset.x, m_Pos.y + offset.y,
        m_End().x + offset.x, m_End().y + offset.y, width, color );
        m_End().x + offset.x, m_End().y + offset.y, width, color );

}
}



/*****************************************************************************
/*****************************************************************************
* Routine to redraw polyline struct.										 *
* Routine to redraw polyline struct.										 *
*****************************************************************************/
*****************************************************************************/
@@ -296,8 +326,11 @@ int i, color ;
    int zoom  = panel->GetZoom();
    int zoom  = panel->GetZoom();
    int width = MAX( m_Width, g_DrawMinimunLineWidth );
    int width = MAX( m_Width, g_DrawMinimunLineWidth );


	if( Color >= 0 ) color = Color;
    if( Color >= 0 )
	else color = ReturnLayerColor(m_Layer);
        color = Color;
    else
        color = ReturnLayerColor( m_Layer );

    GRSetDrawMode( DC, DrawMode );
    GRSetDrawMode( DC, DrawMode );


    if( (m_Layer == LAYER_BUS) && (zoom <= 16) )
    if( (m_Layer == LAYER_BUS) && (zoom <= 16) )
@@ -315,11 +348,16 @@ int width = MAX(m_Width, g_DrawMinimunLineWidth);
    else
    else
    {
    {
        for( i = 1; i < m_NumOfPoints; i++ )
        for( i = 1; i < m_NumOfPoints; i++ )
			GRLineTo(&panel->m_ClipBox, DC, m_Points[i * 2] + offset.x, m_Points[i * 2 + 1] + offset.y,
            GRLineTo( &panel->m_ClipBox,
				width, color);
                DC,
                m_Points[i * 2] + offset.x,
                m_Points[i * 2 + 1] + offset.y,
                width,
                color );
    }
    }
}
}



/*****************************************************************************
/*****************************************************************************
* Routine to redraw connection struct.										 *
* Routine to redraw connection struct.										 *
*****************************************************************************/
*****************************************************************************/
@@ -329,22 +367,26 @@ void DrawJunctionStruct::Draw(WinEDA_DrawPanel * panel,wxDC * DC, const wxPoint
    int color;
    int color;
    int Width = DRAWJUNCTION_SIZE;
    int Width = DRAWJUNCTION_SIZE;


	if( Color >= 0 ) color = Color;
    if( Color >= 0 )
	else color = ReturnLayerColor(m_Layer);
        color = Color;
    else
        color = ReturnLayerColor( m_Layer );
    GRSetDrawMode( DC, DrawMode );
    GRSetDrawMode( DC, DrawMode );


    GRFilledRect( &panel->m_ClipBox, DC, m_Pos.x - Width + offset.x, m_Pos.y - Width + offset.y,
    GRFilledRect( &panel->m_ClipBox, DC, m_Pos.x - Width + offset.x, m_Pos.y - Width + offset.y,
        m_Pos.x + Width + offset.x, m_Pos.y + Width + offset.y, color, color );
        m_Pos.x + Width + offset.x, m_Pos.y + Width + offset.y, color, color );
}
}



/**********************************************************/
/**********************************************************/
void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
void DrawStructsInGhost( WinEDA_DrawPanel* panel, wxDC* DC,
                         EDA_BaseStruct* DrawStruct, int dx, int dy )
                         EDA_BaseStruct* DrawStruct, int dx, int dy )
/**********************************************************/
/**********************************************************/

/* Routine de redessin en mode fantome (Dessin simplifie en g_XorMode et
/* Routine de redessin en mode fantome (Dessin simplifie en g_XorMode et
 g_GhostColor
  * g_GhostColor
de structures.
  * de structures.
	Utilisee dans les deplacements de blocs
  * Utilisee dans les deplacements de blocs
 */
 */
{
{
    int Width, ii;
    int Width, ii;
@@ -364,6 +406,7 @@ int width = g_DrawMinimunLineWidth;
        for( ii = 1; ii < Struct->m_NumOfPoints; ii++ )
        for( ii = 1; ii < Struct->m_NumOfPoints; ii++ )
            GRLineTo( &panel->m_ClipBox, DC, Struct->m_Points[ii * 2] + dx,
            GRLineTo( &panel->m_ClipBox, DC, Struct->m_Points[ii * 2] + dx,
                Struct->m_Points[ii * 2 + 1] + dy, width, g_GhostColor );
                Struct->m_Points[ii * 2 + 1] + dy, width, g_GhostColor );

        break;
        break;
    }
    }


@@ -381,7 +424,12 @@ int width = g_DrawMinimunLineWidth;
        }
        }
        if( (Struct->m_Flags & ENDPOINT) == 0 )
        if( (Struct->m_Flags & ENDPOINT) == 0 )
        {
        {
				GRLineTo(&panel->m_ClipBox, DC, Struct->m_End.x + dx, Struct->m_End.y + dy, width, g_GhostColor);
            GRLineTo( &panel->m_ClipBox,
                DC,
                Struct->m_End.x + dx,
                Struct->m_End.y + dy,
                width,
                g_GhostColor );
        }
        }
        else
        else
        {
        {
@@ -395,7 +443,12 @@ int width = g_DrawMinimunLineWidth;
        DrawBusEntryStruct* Struct = (DrawBusEntryStruct*) DrawStruct;
        DrawBusEntryStruct* Struct = (DrawBusEntryStruct*) DrawStruct;
        int xx = Struct->m_Pos.x + dx, yy = Struct->m_Pos.y + dy;
        int xx = Struct->m_Pos.x + dx, yy = Struct->m_Pos.y + dy;
        GRMoveTo( xx, yy );
        GRMoveTo( xx, yy );
			GRLineTo(&panel->m_ClipBox, DC, Struct->m_Size.x + xx, Struct->m_Size.y + yy, width, g_GhostColor);
        GRLineTo( &panel->m_ClipBox,
            DC,
            Struct->m_Size.x + xx,
            Struct->m_Size.y + yy,
            width,
            g_GhostColor );
        break;
        break;
    }
    }


@@ -404,9 +457,14 @@ int width = g_DrawMinimunLineWidth;
        DrawJunctionStruct* Struct;
        DrawJunctionStruct* Struct;
        Struct = (DrawJunctionStruct*) DrawStruct;
        Struct = (DrawJunctionStruct*) DrawStruct;
        Width  = DRAWJUNCTION_SIZE;
        Width  = DRAWJUNCTION_SIZE;
			GRFilledRect(&panel->m_ClipBox, DC, Struct->m_Pos.x - Width + dx, Struct->m_Pos.y - Width + dy,
        GRFilledRect( &panel->m_ClipBox,
				Struct->m_Pos.x + Width + dx, Struct->m_Pos.y + Width + dy,
            DC,
				g_GhostColor, g_GhostColor);
            Struct->m_Pos.x - Width + dx,
            Struct->m_Pos.y - Width + dy,
            Struct->m_Pos.x + Width + dx,
            Struct->m_Pos.y + Width + dy,
            g_GhostColor,
            g_GhostColor );
        break;
        break;
    }
    }


@@ -448,7 +506,8 @@ int width = g_DrawMinimunLineWidth;
        EDA_SchComponentStruct* Struct;
        EDA_SchComponentStruct* Struct;
        Struct   = (EDA_SchComponentStruct*) DrawStruct;
        Struct   = (EDA_SchComponentStruct*) DrawStruct;
        LibEntry = FindLibPart( Struct->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
        LibEntry = FindLibPart( Struct->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
			if( LibEntry == NULL ) break;
        if( LibEntry == NULL )
            break;
        DrawingLibInGhost( panel, DC, LibEntry, Struct, Struct->m_Pos.x + dx,
        DrawingLibInGhost( panel, DC, LibEntry, Struct, Struct->m_Pos.x + dx,
            Struct->m_Pos.y + dy,
            Struct->m_Pos.y + dy,
            Struct->m_Multi, Struct->m_Convert,
            Struct->m_Multi, Struct->m_Convert,
@@ -479,20 +538,22 @@ int width = g_DrawMinimunLineWidth;
void Draw_Marqueur( WinEDA_DrawPanel* panel, wxDC* DC,
void Draw_Marqueur( WinEDA_DrawPanel* panel, wxDC* DC,
                    wxPoint pos, char* pt_bitmap, int DrawMode, int Color )
                    wxPoint pos, char* pt_bitmap, int DrawMode, int Color )
/************************************************************/
/************************************************************/
/*
 Place un repere sur l'ecran au point de coordonnees PCB pos_X, pos_Y
	Le marqueur est defini par un tableau de 2 + (lig*col) elements:
	 1er element: dim nbre ligne
	 2er element: dim nbre col
	 suite: lig * col elements a 0 ou 1 : si 1 mise a color du pixel


 copie la description du marqueur en current_marqueur (global)
/*
  * Place un repere sur l'ecran au point de coordonnees PCB pos_X, pos_Y
  * Le marqueur est defini par un tableau de 2 + (lig*col) elements:
  *  1er element: dim nbre ligne
  *  2er element: dim nbre col
  *  suite: lig * col elements a 0 ou 1 : si 1 mise a color du pixel
 *
  * copie la description du marqueur en current_marqueur (global)
 */
 */
{
{
    int  px, py, color;
    int  px, py, color;
    char ii, ii_max, jj, jj_max;
    char ii, ii_max, jj, jj_max;


	if ( pt_bitmap == NULL ) pt_bitmap = marq_bitmap;
    if( pt_bitmap == NULL )
        pt_bitmap = marq_bitmap;


    px = GRMapX( pos.x ); py = GRMapY( pos.y );
    px = GRMapX( pos.x ); py = GRMapY( pos.y );


@@ -503,8 +564,10 @@ char ii, ii_max, jj, jj_max;
    px += *(pt_bitmap++); py += *(pt_bitmap++);
    px += *(pt_bitmap++); py += *(pt_bitmap++);


    color = *(pt_bitmap++);
    color = *(pt_bitmap++);
	if ( (Color > 0) ) color = Color;
    if( (Color > 0) )
	if (color < 0) color = 0;
        color = Color;
    if( color < 0 )
        color = 0;
    GRSetDrawMode( DC, DrawMode );
    GRSetDrawMode( DC, DrawMode );


    /* Trace du bitmap */
    /* Trace du bitmap */
@@ -512,9 +575,8 @@ char ii, ii_max, jj, jj_max;
    {
    {
        for( jj = 0; jj < jj_max; jj++, pt_bitmap++ )
        for( jj = 0; jj < jj_max; jj++, pt_bitmap++ )
        {
        {
			if(*pt_bitmap)  GRSPutPixel(&panel->m_ClipBox, DC, px+ii , py+jj , color);
            if( *pt_bitmap )
                GRSPutPixel( &panel->m_ClipBox, DC, px + ii, py + jj, color );
        }
        }
    }
    }
}
}