Commit 6acce67a authored by dickelbeck's avatar dickelbeck
Browse files

made m_CurrentItem private, beautification

parent 4ca51f75
Loading
Loading
Loading
Loading
+479 −444
Original line number Diff line number Diff line
/////////////////////////////////////////////////////////////////////////////

// Name:        3d_canvas.cpp
/////////////////////////////////////////////////////////////////////////////

@@ -32,8 +33,7 @@
#include "bitmaps3d.h"
#include "bitmaps.h"

enum onrclick_id
{
enum onrclick_id {
    ID_POPUP_3D_VIEW_START = 2000,
    ID_POPUP_ZOOMIN,
    ID_POPUP_ZOOMOUT,
@@ -68,7 +68,8 @@ END_EVENT_TABLE()
/*************************************************************************/
Pcb3D_GLCanvas::Pcb3D_GLCanvas( WinEDA3D_DrawFrame* parent, wxWindowID id,
                                int* gl_attrib ) :
  wxGLCanvas(parent, id, wxPoint(-1,-1), wxSize(-1,-1), 0, wxT("Pcb3D_glcanvas"), gl_attrib)
    wxGLCanvas( parent, id,
                wxPoint( -1, -1 ), wxSize( -1, -1 ), 0, wxT( "Pcb3D_glcanvas" ), gl_attrib )
/*************************************************************************/
{
    m_init   = FALSE;
@@ -85,6 +86,7 @@ Pcb3D_GLCanvas::~Pcb3D_GLCanvas(void)
    ClearLists();
}


/*************************************/
void Pcb3D_GLCanvas::ClearLists( void )
/*************************************/
@@ -95,6 +97,7 @@ void Pcb3D_GLCanvas::ClearLists(void)
    m_gllist = 0;
}


/*********************************************/
void Pcb3D_GLCanvas::OnChar( wxKeyEvent& event )
/*********************************************/
@@ -103,6 +106,7 @@ void Pcb3D_GLCanvas::OnChar(wxKeyEvent& event)
    event.Skip();
}


/*********************************************/
void Pcb3D_GLCanvas::SetView3D( int keycode )
/*********************************************/
@@ -115,12 +119,15 @@ double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom;
    case WXK_LEFT:
        g_Draw3d_dx -= delta_move;
        break;

    case WXK_RIGHT:
        g_Draw3d_dx += delta_move;
        break;

    case WXK_UP:
        g_Draw3d_dy += delta_move;
        break;

    case WXK_DOWN:
        g_Draw3d_dy -= delta_move;
        break;
@@ -155,12 +162,14 @@ double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom;
        g_Draw3d_dx = g_Draw3d_dy = 0;
        for( ii = 0; ii < 4; ii++ )
            g_Parm_3D_Visu.m_Rot[ii] = 0.0;

        trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
        break;

    case 'x':
        for( ii = 0; ii < 4; ii++ )
            g_Parm_3D_Visu.m_Rot[ii] = 0.0;

        trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
        g_Parm_3D_Visu.m_ROTZ = -90;
        g_Parm_3D_Visu.m_ROTX = -90;
@@ -169,6 +178,7 @@ double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom;
    case 'X':
        for( ii = 0; ii < 4; ii++ )
            g_Parm_3D_Visu.m_Rot[ii] = 0.0;

        trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
        g_Parm_3D_Visu.m_ROTZ = 90;
        g_Parm_3D_Visu.m_ROTX = -90;
@@ -177,6 +187,7 @@ double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom;
    case 'y':
        for( ii = 0; ii < 4; ii++ )
            g_Parm_3D_Visu.m_Rot[ii] = 0.0;

        trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
        g_Parm_3D_Visu.m_ROTX = -90;
        break;
@@ -184,6 +195,7 @@ double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom;
    case 'Y':
        for( ii = 0; ii < 4; ii++ )
            g_Parm_3D_Visu.m_Rot[ii] = 0.0;

        trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
        g_Parm_3D_Visu.m_ROTX = -90;
        g_Parm_3D_Visu.m_ROTZ = -180;
@@ -192,12 +204,14 @@ double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom;
    case 'z':
        for( ii = 0; ii < 4; ii++ )
            g_Parm_3D_Visu.m_Rot[ii] = 0.0;

        trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
        break;

    case 'Z':
        for( ii = 0; ii < 4; ii++ )
            g_Parm_3D_Visu.m_Rot[ii] = 0.0;

        trackball( g_Parm_3D_Visu.m_Quat, 0.0, 0.0, 0.0, 0.0 );
        g_Parm_3D_Visu.m_ROTX = -180;
        break;
@@ -210,6 +224,7 @@ double delta_move = 0.7 * g_Parm_3D_Visu.m_Zoom;
    Refresh( FALSE );
}


/********************************************************/
void Pcb3D_GLCanvas::OnMouseEvent( wxMouseEvent& event )
/********************************************************/
@@ -225,31 +240,42 @@ float spin_quat[4];

    if( event.m_wheelRotation )
    {
        if( event.ShiftDown() ) {
            if ( event.GetWheelRotation() < 0 ) {
        if( event.ShiftDown() )
        {
            if( event.GetWheelRotation() < 0 )
            {
                /* up */
                SetView3D( WXK_UP );
            } else {
            }
            else
            {
                /* down */
                SetView3D( WXK_DOWN );
            }
        } else if( event.ControlDown() ) {
            if ( event.GetWheelRotation() > 0 ) {
        }
        else if( event.ControlDown() )
        {
            if( event.GetWheelRotation() > 0 )
            {
                /* right */
                SetView3D( WXK_RIGHT );
            } else {
            }
            else
            {
                /* left */
                SetView3D( WXK_LEFT );
            }
        }
        else {
        else
        {
            if( event.GetWheelRotation() > 0 )
            {
                g_Parm_3D_Visu.m_Zoom /= 1.4;
                if( g_Parm_3D_Visu.m_Zoom <= 0.01 )
                    g_Parm_3D_Visu.m_Zoom = 0.01;
            }
            else g_Parm_3D_Visu.m_Zoom *= 1.4;
            else
                g_Parm_3D_Visu.m_Zoom *= 1.4;
            DisplayStatus();
            Refresh( FALSE );
        }
@@ -275,11 +301,13 @@ float spin_quat[4];
    g_Parm_3D_Visu.m_Beginy = event.GetY();
}


/*******************************************************/
void Pcb3D_GLCanvas::OnRightClick( wxMouseEvent& event )
/*******************************************************/

/* Construit et affiche un menu Popup lorsque on actionne le bouton droit
	de la souris
 *  de la souris
 */
{
    wxPoint     pos;
@@ -354,6 +382,7 @@ wxMenu PopUpMenu;
    PopupMenu( &PopUpMenu, pos );
}


/*******************************************************/
void Pcb3D_GLCanvas::OnPopUpMenu( wxCommandEvent& event )
/*******************************************************/
@@ -413,6 +442,7 @@ int key = 0;
    default:
        return;
    }

    SetView3D( key );
}

@@ -422,6 +452,7 @@ void Pcb3D_GLCanvas::DisplayStatus(void)
/***************************************/
{
    wxString msg;

    msg.Printf( wxT( "dx %3.2f" ), g_Draw3d_dx );
    m_Parent->SetStatusText( msg, 1 );

@@ -440,7 +471,8 @@ void Pcb3D_GLCanvas::OnPaint( wxPaintEvent& event )
    wxPaintDC dc( this );

#ifndef __WXMOTIF__
    if (!GetContext()) return;
    if( !GetContext() )
        return;
#endif
    Redraw();
    event.Skip();
@@ -466,6 +498,7 @@ void Pcb3D_GLCanvas::OnSize(wxSizeEvent& event)
    }
}


/***********************************************************/
void Pcb3D_GLCanvas::OnEraseBackground( wxEraseEvent& event )
/***********************************************************/
@@ -477,6 +510,7 @@ void Pcb3D_GLCanvas::OnEraseBackground(wxEraseEvent& event)
/****************************/
void Pcb3D_GLCanvas::InitGL()
/****************************/

/* Int parametres generaux pour OPENGL
 */
{
@@ -541,6 +575,7 @@ double ratio_HV = (double) size.x / size.y; // Ratio largeur /hauteur de la fene
/***********************************/
void Pcb3D_GLCanvas::SetLights( void )
/***********************************/

/* Init sources lumineuses pour OPENGL
 */
{
@@ -572,15 +607,17 @@ GLfloat light_color[4];
/**********************************************************/
void Pcb3D_GLCanvas::TakeScreenshot( wxCommandEvent& event )
/**********************************************************/

/* Create a Screenshot of the current 3D view.
	Output file format is png or jpeg, or image is copied on clipboard
 *  Output file format is png or jpeg, or image is copied on clipboard
 */
{
    wxString FullFileName;
    wxString file_ext, mask;
    bool     fmt_is_jpeg = FALSE;

	if ( event.GetId() == ID_MENU_SCREENCOPY_JPEG ) fmt_is_jpeg = TRUE;
    if( event.GetId() == ID_MENU_SCREENCOPY_JPEG )
        fmt_is_jpeg = TRUE;
    if( event.GetId() != ID_TOOL_SCREENCOPY_TOCLIBBOARD )
    {
        file_ext = fmt_is_jpeg ? wxT( ".jpg" ) : wxT( ".png"; )
@@ -598,7 +635,8 @@ bool fmt_is_jpeg = FALSE;
                              wxFD_SAVE,
                              TRUE
                              );
		if ( FullFileName.IsEmpty() ) return;
        if( FullFileName.IsEmpty() )
            return;
    }

    Redraw( true );
@@ -619,11 +657,10 @@ bool fmt_is_jpeg = FALSE;
            if( !wxTheClipboard->SetData( dobjBmp ) )
                wxLogError( _T( "Failed to copy image to clipboard" ) );
            wxTheClipboard->Flush();    /* the data on clipboard
					will stay available after the application exits */
                                         *  will stay available after the application exits */
            wxTheClipboard->Close();
        }
    }

    else
    {
        wxImage image = bitmap.ConvertToImage();
@@ -635,5 +672,3 @@ bool fmt_is_jpeg = FALSE;
        image.Destroy();
    }
}

+16 −0
Original line number Diff line number Diff line
@@ -5,6 +5,22 @@ Please add newer entries at the top, list the date and your name with
email address.


2007-Aug-19 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
+ all
  * Made BASE_SCREEN::m_CurrentItem private so we can force usage of the new 
    SetCurItem() function, and use it to put a breakpoint on the only place
    that m_CurrentItem is changed, namely in the new SetCurItem() function.  
    ( Added new function GetCurItem() as well to class BASE_SCREEN in 
    drawpanel_wxstruct.h.)  Using a stack trace at the breakpoint we can tell 
    who called it.  There were in excess of 450 edits to get this done so I
    had to commit it asap so other folks could get on with edits without a 
    merge conflict.
  * Started work on the COLLECTOR class which will assist in giving a choice
    in PCBNEW when there is more than one click candidate at the same mouse
    or cursor coordinates.  COLLECTOR not committed yet.
  * More beautification.
  

2007-Aug-14 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
+398 −328
Original line number Diff line number Diff line
@@ -34,11 +34,14 @@ BASE_SCREEN::BASE_SCREEN(int idscreen): EDA_BaseStruct(SCREEN_STRUCT_TYPE)
BASE_SCREEN::~BASE_SCREEN( void )
/******************************/
{
	if ( m_ZoomList ) free(m_ZoomList);
	if ( m_GridList ) free(m_GridList);
    if( m_ZoomList )
        free( m_ZoomList );
    if( m_GridList )
        free( m_GridList );
    ClearUndoRedoList();
}


/*******************************/
void BASE_SCREEN::InitDatas( void )
/*******************************/
@@ -86,11 +89,12 @@ void BASE_SCREEN::InitDatas(void)
    }

    // DrawOrg est rendu multiple du zoom min :
	m_DrawOrg.x -= m_DrawOrg.x % 256; m_DrawOrg.y -= m_DrawOrg.y % 256;
    m_DrawOrg.x -= m_DrawOrg.x % 256; 
    m_DrawOrg.y -= m_DrawOrg.y % 256;

    m_O_Curseur = m_Curseur;

	m_CurrentItem = NULL;
    SetCurItem( NULL );

    /* indicateurs divers */
    m_FlagRefreshReq = 0;               /* indique que l'ecran doit redessine */
@@ -106,6 +110,7 @@ wxPoint BASE_SCREEN::CursorRealPosition(const wxPoint & ScreenPos)
    wxPoint curpos;

    curpos.x = ScreenPos.x* GetZoom();

    curpos.y = ScreenPos.y* GetZoom();

    curpos.x += m_DrawOrg.x;
@@ -114,6 +119,7 @@ wxPoint curpos;
    return curpos;
}


/***************************************/
int BASE_SCREEN::GetInternalUnits( void )
/***************************************/
@@ -133,11 +139,13 @@ int BASE_SCREEN::GetInternalUnits(void)
    }
}


/*****************************************/
wxSize BASE_SCREEN::ReturnPageSize( void )
/*****************************************/

/* Retourne en unites internes la taille de la feuille de dessin
	(la taille de la feuille est connue en 1/1000 ")
 *  (la taille de la feuille est connue en 1/1000 ")
 */
{
    wxSize PageSize;
@@ -165,18 +173,22 @@ wxSize PageSize;
/********************************************/
void BASE_SCREEN::SetZoomList( int* zoomlist )
/********************************************/

/* init liste des zoom (NULL terminated)
 */
{
    int ii, nbitems, * zoom;

    // Decompte des items
    for( nbitems = 1, zoom = zoomlist;  ; zoom++, nbitems++ )
    {
		if ( *zoom == 0 ) break;
        if( *zoom == 0 )
            break;
    }

    // Init liste
	if ( m_ZoomList ) free(m_ZoomList);
    if( m_ZoomList )
        free( m_ZoomList );
    m_ZoomList = (int*) MyZMalloc( nbitems * sizeof( int) );

    for( ii = 0, zoom = zoomlist; ii < nbitems; zoom++, ii++ )
@@ -185,6 +197,7 @@ int ii, nbitems, * zoom;
    }
}


/***********************************/
void BASE_SCREEN::SetFirstZoom( void )
/***********************************/
@@ -202,71 +215,87 @@ int BASE_SCREEN::GetZoom(void)
    return m_Zoom;
}


/***********************************/
void BASE_SCREEN::SetZoom( int coeff )
/***********************************/
/* ajuste le coeff de zoom a coeff */
{
    m_Zoom = coeff;
	if ( m_Zoom < 1 ) m_Zoom = 1;
    if( m_Zoom < 1 )
        m_Zoom = 1;
}


/********************************/
void BASE_SCREEN::SetNextZoom( void )
/********************************/

/* Selectionne le prochain coeff de zoom
 */
{
    m_Zoom *= 2;

	if ( m_ZoomList == NULL ) return;
    if( m_ZoomList == NULL )
        return;

    int ii, zoom_max = 512;
	for ( ii = 0; m_ZoomList[ii] != 0; ii ++ ) zoom_max = m_ZoomList[ii];
	if ( m_Zoom > zoom_max ) m_Zoom = zoom_max;
    for( ii = 0; m_ZoomList[ii] != 0; ii++ )
        zoom_max = m_ZoomList[ii];

    if( m_Zoom > zoom_max )
        m_Zoom = zoom_max;
}


/*************************************/
void BASE_SCREEN::SetPreviousZoom( void )
/*************************************/

/* Selectionne le precedent coeff de zoom
 */
{
    m_Zoom /= 2;
	if ( m_Zoom < 1 ) m_Zoom = 1;
    if( m_Zoom < 1 )
        m_Zoom = 1;
}


/**********************************/
void BASE_SCREEN::SetLastZoom( void )
/**********************************/

/* ajuste le coeff de zoom au max
 */
{
	if ( m_ZoomList == NULL ) return;
    if( m_ZoomList == NULL )
        return;
    int ii;
	for ( ii = 0; m_ZoomList[ii] != 0; ii ++ ) m_Zoom = m_ZoomList[ii];
    for( ii = 0; m_ZoomList[ii] != 0; ii++ )
        m_Zoom = m_ZoomList[ii];
}


/********************************************/
void BASE_SCREEN::SetGridList( wxSize* gridlist )
/********************************************/

/* init liste des zoom (NULL terminated)
 */
{
    int     ii, nbitems;
    wxSize* grid;

    // Decompte des items
    for( nbitems = 0, grid = gridlist;  ; grid++, nbitems++ )
    {
		if ( (grid->x <= 0) || (grid->y <= 0) ) break;
        if( (grid->x <= 0) || (grid->y <= 0) )
            break;
    }

    // Init liste
	if ( m_GridList ) free(m_GridList);
    if( m_GridList )
        free( m_GridList );
    m_GridList = (wxSize*) MyZMalloc( nbitems * sizeof(wxSize) );

    for( ii = 0, grid = gridlist; ii < nbitems; grid++, ii++ )
@@ -275,11 +304,13 @@ wxSize * grid;
    }
}


/**********************************************/
void BASE_SCREEN::SetGrid( const wxSize& size )
/**********************************************/
{
	if ( m_GridList == NULL ) return;
    if( m_GridList == NULL )
        return;

    if( (size.x <= 0) || (size.y <= 0) )
    {
@@ -293,6 +324,7 @@ void BASE_SCREEN::SetGrid( const wxSize & size )
    }
}


/*********************************/
wxSize BASE_SCREEN::GetGrid( void )
/*********************************/
@@ -300,12 +332,15 @@ wxSize BASE_SCREEN::GetGrid(void)
    wxSize grid = m_Grid;
    double xx, scale;

	if ( m_GridList == NULL ) return wxSize(1,1);
    if( m_GridList == NULL )
        return wxSize( 1, 1 );

    if( m_UserGridIsON || m_Grid.x < 0 || m_Grid.y < 0 )
    {
		if ( m_UserGridUnit == INCHES ) scale = 10000;
		else scale = 10000/25.4;
        if( m_UserGridUnit == INCHES )
            scale = 10000;
        else
            scale = 10000 / 25.4;
        xx     = m_UserGrid.x * scale;
        grid.x = (int) (xx + 0.5);
        xx     = m_UserGrid.y * scale;
@@ -318,19 +353,23 @@ double xx, scale;
/*********************************/
void BASE_SCREEN::SetNextGrid( void )
/*********************************/

/* Selectionne la prochaine grille
 */
{
    int ii;

	if ( m_GridList == NULL ) return;
    if( m_GridList == NULL )
        return;

    for( ii = 0; ; ii++ )
    {
		if ( m_GridList[ii].x <= 0 ) break;
        if( m_GridList[ii].x <= 0 )
            break;
        if( (m_Grid.x == m_GridList[ii].x) && (m_Grid.y == m_GridList[ii].y) )
            break;
    }

    if( (m_GridList[ii].x > 0) && (ii > 0) )
        m_Grid = m_GridList[ii - 1];
}
@@ -339,19 +378,23 @@ int ii;
/*************************************/
void BASE_SCREEN::SetPreviousGrid( void )
/*************************************/

/* Selectionne le precedent coeff de grille
 */
{
    int ii;

	if ( m_GridList == NULL ) return;
    if( m_GridList == NULL )
        return;

    for( ii = 0; ; ii++ )
    {
		if ( m_GridList[ii].x <= 0 ) break;
        if( m_GridList[ii].x <= 0 )
            break;
        if( (m_Grid.x == m_GridList[ii].x) && (m_Grid.y == m_GridList[ii].y) )
            break;
    }

    if( (m_GridList[ii].x > 0) && (m_GridList[ii + 1].x > 0) )
        m_Grid = m_GridList[ii + 1];
}
@@ -360,25 +403,30 @@ int ii;
/**********************************/
void BASE_SCREEN::SetFirstGrid( void )
/**********************************/

/* ajuste le coeff de grille a 1
 */
{
	if ( m_GridList == NULL ) return;
    if( m_GridList == NULL )
        return;

    int ii = 0;
	while ( m_GridList[ii].x > 0 ) ii ++;
    while( m_GridList[ii].x > 0 )
        ii++;

    m_Grid = m_GridList[ii - 1];
}



/**********************************/
void BASE_SCREEN::SetLastGrid( void )
/**********************************/

/* ajuste le coeff de grille au max
 */
{
	if ( m_GridList == NULL ) return;
    if( m_GridList == NULL )
        return;
    m_Grid = m_GridList[0];
}

@@ -386,6 +434,7 @@ void BASE_SCREEN::SetLastGrid(void)
/*****************************************/
void BASE_SCREEN::ClearUndoRedoList( void )
/*****************************************/

/* free the undo and the redo lists
 */
{
@@ -404,20 +453,22 @@ EDA_BaseStruct *nextitem;
        delete m_RedoList;
        m_RedoList = nextitem;
    }
	
}


/***********************************************************/
void BASE_SCREEN::AddItemToUndoList( EDA_BaseStruct* newitem )
/************************************************************/

/* Put newitem in head of undo list
	Deletes olds items if > count max.
 *  Deletes olds items if > count max.
 */
{
    int             ii;
    EDA_BaseStruct* item, * nextitem;

	if ( newitem == NULL ) return;
    if( newitem == NULL )
        return;

    newitem->Pnext = m_UndoList;
    m_UndoList = newitem;
@@ -425,11 +476,13 @@ EDA_BaseStruct * item, *nextitem;
    /* Free first items, if count max reached */
    for( ii = 0, item = m_UndoList; ii < m_UndoRedoCountMax; ii++ )
    {
		if ( item->Pnext == NULL ) return;
        if( item->Pnext == NULL )
            return;
        item = item->Pnext;
    }

	if ( item == NULL ) return;
    if( item == NULL )
        return;

    nextitem    = item->Pnext;
    item->Pnext = NULL; // Set end of chain
@@ -440,9 +493,9 @@ EDA_BaseStruct * item, *nextitem;
        nextitem = item->Pnext;
        delete item;
    }
	
}


/***********************************************************/
void BASE_SCREEN::AddItemToRedoList( EDA_BaseStruct* newitem )
/***********************************************************/
@@ -450,18 +503,21 @@ void BASE_SCREEN::AddItemToRedoList(EDA_BaseStruct * newitem)
    int             ii;
    EDA_BaseStruct* item, * nextitem;

	if ( newitem == NULL ) return;
    if( newitem == NULL )
        return;

    newitem->Pnext = m_RedoList;
    m_RedoList = newitem;
    /* Free first items, if count max reached */
    for( ii = 0, item = m_RedoList; ii < m_UndoRedoCountMax; ii++ )
    {
		if ( item->Pnext == NULL ) break;
        if( item->Pnext == NULL )
            break;
        item = item->Pnext;
    }

	if ( item == NULL ) return;
    if( item == NULL )
        return;

    nextitem    = item->Pnext;
    item->Pnext = NULL; // Set end of chain
@@ -472,26 +528,40 @@ EDA_BaseStruct * item, *nextitem;
        nextitem = item->Pnext;
        delete item;
    }
	
}


/*****************************************************/
EDA_BaseStruct* BASE_SCREEN::GetItemFromUndoList( void )
/*****************************************************/
{
    EDA_BaseStruct* item = m_UndoList;

	if ( item ) m_UndoList = item->Pnext;
    if( item )
        m_UndoList = item->Pnext;
    return item;
}


/******************************************************/
EDA_BaseStruct* BASE_SCREEN::GetItemFromRedoList( void )
/******************************************************/
{
    EDA_BaseStruct* item = m_RedoList;

	if ( item ) m_RedoList = item->Pnext;
    if( item )
        m_RedoList = item->Pnext;
    return item;
}



EDA_BaseStruct* BASE_SCREEN::GetCurItem()
{
    return m_CurrentItem;
}

void BASE_SCREEN::SetCurItem( EDA_BaseStruct* aCurItem )
{
    m_CurrentItem = aCurItem; 
}
+216 −205
Original line number Diff line number Diff line
@@ -18,7 +18,8 @@

/****************************************************************************/
DrawBlockStruct::DrawBlockStruct( void ) :
		EDA_BaseStruct(BLOCK_LOCATE_STRUCT_TYPE), EDA_Rect()
    EDA_BaseStruct( BLOCK_LOCATE_STRUCT_TYPE )
    , EDA_Rect()
/****************************************************************************/
{
    m_State   = STATE_NO_BLOCK; /* Etat (enum BlockState) du block */
@@ -35,12 +36,12 @@ DrawBlockStruct::~DrawBlockStruct(void)
}



/***************************************************************/
void DrawBlockStruct::SetMessageBlock( WinEDA_DrawFrame* frame )
/***************************************************************/

/*
	Print block command message (Block move, Block copy ...) in status bar
 *  Print block command message (Block move, Block copy ...) in status bar
 */
{
    wxString msg;
@@ -110,6 +111,7 @@ void DrawBlockStruct::Draw(WinEDA_DrawPanel * panel, wxDC * DC)
{
    int w = GetWidth() / panel->GetZoom();
    int h = GetHeight() / panel->GetZoom();

    if(  w == 0 || h == 0 )
        GRLine( &panel->m_ClipBox, DC, GetX(), GetY(),
                GetRight(), GetBottom(), 0, m_Color );
@@ -118,18 +120,20 @@ void DrawBlockStruct::Draw(WinEDA_DrawPanel * panel, wxDC * DC)
                GetRight(), GetBottom(), 0, m_Color );
}


/*************************************************************************/
bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key,
                                         const wxPoint& startpos )
/*************************************************************************/

/* 	First command block function:
	Init the Block infos: command type, initial position, and other variables..
 *  Init the Block infos: command type, initial position, and other variables..
 */
{
    DrawBlockStruct* Block = & GetScreen()->BlockLocate;

	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;

    Block->m_Flags   = 0;
@@ -139,7 +143,8 @@ DrawBlockStruct * Block = & GetScreen()->BlockLocate;

    switch( Block->m_Command )
    {
		case BLOCK_IDLE: break;
    case BLOCK_IDLE:
        break;

    case BLOCK_MOVE:                /* Move */
    case BLOCK_DRAG:                /* Drag */
@@ -181,7 +186,8 @@ DrawBlockStruct * Block = & GetScreen()->BlockLocate;
    default:
    {
        wxString msg;
			msg << wxT("WinEDA_DrawFrame::HandleBlockBegin() error: Unknown command ") << Block->m_Command;
        msg << wxT( "WinEDA_DrawFrame::HandleBlockBegin() error: Unknown command " ) <<
        Block->m_Command;
        DisplayError( this, msg );
    }
        break;
@@ -195,8 +201,9 @@ DrawBlockStruct * Block = & GetScreen()->BlockLocate;
/******************************************************************/
void AbortBlockCurrentCommand( WinEDA_DrawPanel* Panel, wxDC* DC )
/******************************************************************/

/*
	Cancel Current block operation.
 *  Cancel Current block operation.
 */
{
    BASE_SCREEN* screen = Panel->GetScreen();
@@ -206,11 +213,11 @@ BASE_SCREEN * screen = Panel->GetScreen();
        Panel->ManageCurseur( Panel, DC, FALSE );   /* Efface dessin fantome */
        Panel->ManageCurseur = NULL;
        Panel->ForceCloseManageCurseur = NULL;
		screen->m_CurrentItem = NULL;
        screen->SetCurItem( NULL );

        /* Delete the picked wrapper if this is a picked list. */
		if( (screen->BlockLocate.m_Command != BLOCK_PASTE) &&
			screen->BlockLocate.m_BlockDrawStruct )
        if( (screen->BlockLocate.m_Command != BLOCK_PASTE)
           && screen->BlockLocate.m_BlockDrawStruct )
        {
            if( screen->BlockLocate.m_BlockDrawStruct->m_StructType == DRAW_PICK_ITEM_STRUCT_TYPE )
            {
@@ -232,14 +239,17 @@ BASE_SCREEN * screen = Panel->GetScreen();
    Panel->m_Parent->DisplayToolMsg( wxEmptyString );
}


/*************************************************************************/
void InitBlockLocateDatas( WinEDA_DrawPanel* Panel, const wxPoint& startpos )
/*************************************************************************/

/*
	Init the initial values of a BlockLocate, before starting a block command
 *  Init the initial values of a BlockLocate, before starting a block command
 */
{
    BASE_SCREEN* screen = Panel->GetScreen();

    screen->BlockLocate.m_State = STATE_BLOCK_INIT;
    screen->BlockLocate.SetOrigin( startpos );
    screen->BlockLocate.SetSize( wxSize( 0, 0 ) );
@@ -249,13 +259,15 @@ BASE_SCREEN * screen = Panel->GetScreen();
    Panel->ForceCloseManageCurseur = AbortBlockCurrentCommand;
}


/********************************************************************************/
void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/********************************************************************************/

/* Redraw the outlines of the block which shows the search area for block commands
	The first point of the rectangle showing the area is initialised
	by InitBlockLocateDatas().
	The other point of the rectangle is the mouse cursor
 *  The first point of the rectangle showing the area is initialised
 *  by InitBlockLocateDatas().
 *  The other point of the rectangle is the mouse cursor
 */
{
    DrawBlockStruct* PtBlock;
@@ -267,7 +279,8 @@ DrawBlockStruct * PtBlock;
    GRSetDrawMode( DC, g_XorMode );

    /* Effacement ancien cadre */
	if( erase ) PtBlock->Draw(panel, DC);
    if( erase )
        PtBlock->Draw( panel, DC );

    PtBlock->m_BlockLastCursorPosition = panel->GetScreen()->m_Curseur;
    PtBlock->SetEnd( panel->GetScreen()->m_Curseur );
@@ -281,5 +294,3 @@ DrawBlockStruct * PtBlock;
            PtBlock->m_State = STATE_BLOCK_END;
    }
}

+1550 −1439

File changed.

Preview size limit exceeded, changes collapsed.

Loading