Commit f28062ac authored by dickelbeck's avatar dickelbeck
Browse files

Matt Wright 20090502_gerbview_mirror_block.patch

parent 7258d23b
Loading
Loading
Loading
Loading
+66 −1
Original line number Original line Diff line number Diff line
@@ -174,6 +174,12 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
            Block_Delete( DC );
            Block_Delete( DC );
            break;
            break;


        case BLOCK_MIRROR_X: /* Mirror*/
            GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP;
            DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
            Block_Mirror_X( DC );
            break;

        case BLOCK_ROTATE: /* Unused */
        case BLOCK_ROTATE: /* Unused */
            break;
            break;


@@ -192,7 +198,6 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )


        case BLOCK_ABORT:
        case BLOCK_ABORT:
        case BLOCK_SELECT_ITEMS_ONLY:
        case BLOCK_SELECT_ITEMS_ONLY:
        case BLOCK_MIRROR_X:
        case BLOCK_MIRROR_Y:
        case BLOCK_MIRROR_Y:
            break;
            break;
        }
        }
@@ -366,6 +371,66 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
}
}




/************************************************/
void WinEDA_BasePcbFrame::Block_Mirror_X( wxDC* DC )
/************************************************/

/*
 *  Function to mirror items in the current selected block
 */
{
    int     xoffset = 0;
    wxPoint oldpos;

    oldpos = GetScreen()->m_Curseur;
    DrawPanel->ManageCurseur = NULL;

    GetScreen()->m_Curseur = oldpos;
    DrawPanel->MouseToCursorSchema();
    GetScreen()->SetModify();
    GetScreen()->BlockLocate.Normalize();

    /* Calculate offset to mirror track points from block edges */
    xoffset = GetScreen()->BlockLocate.m_Pos.x + GetScreen()->BlockLocate.m_Pos.x
              + GetScreen()->BlockLocate.m_Size.x;

    /* Move the Track segments in block */
    for( TRACK* track = m_Pcb->m_Track;  track;  track = track->Next() )
    {
        if( IsSegmentInBox( GetScreen()->BlockLocate, track ) )
        {
            m_Pcb->m_Status_Pcb = 0;
            track->Draw( DrawPanel, DC, GR_XOR );   // erase the display
            track->m_Start.x = xoffset - track->m_Start.x;
            track->m_End.x   = xoffset - track->m_End.x;

            // the two parameters are used in gerbview to store centre coordinates for arcs.
            // move this centre
            track->m_Param = xoffset - track->m_Param;
            track->Draw( DrawPanel, DC, GR_OR ); // redraw the moved track
        }
    }

    /* Move the Zone segments in block */
    for( SEGZONE* zsegment = m_Pcb->m_Zone; zsegment; zsegment = zsegment->Next() )
    {
        if( IsSegmentInBox( GetScreen()->BlockLocate, zsegment ) )
        {
            zsegment->Draw( DrawPanel, DC, GR_XOR );   // erase the display
            zsegment->m_Start.x = xoffset - zsegment->m_Start.x;
            zsegment->m_End.x   = xoffset - zsegment->m_End.x;

            // the two parameters are used in gerbview to store centre coordinates for arcs.
            // move this centre
            zsegment->m_Param = xoffset - zsegment->m_Param;
            zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone zegment
        }
    }
    
    DrawPanel->Refresh( TRUE );
}


/**************************************************/
/**************************************************/
void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
/**************************************************/
/**************************************************/
+7 −0
Original line number Original line Diff line number Diff line
@@ -100,6 +100,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
    {
    {
    case wxID_CUT:
    case wxID_CUT:
    case wxID_COPY:
    case wxID_COPY:
    case ID_POPUP_MIRROR_X_BLOCK:
    case ID_POPUP_DELETE_BLOCK:
    case ID_POPUP_DELETE_BLOCK:
    case ID_POPUP_PLACE_BLOCK:
    case ID_POPUP_PLACE_BLOCK:
    case ID_POPUP_ZOOM_BLOCK:
    case ID_POPUP_ZOOM_BLOCK:
@@ -287,6 +288,12 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
        HandleBlockEnd( &dc );
        HandleBlockEnd( &dc );
        break;
        break;


    case ID_POPUP_MIRROR_X_BLOCK:
        GetScreen()->BlockLocate.m_Command = BLOCK_MIRROR_X;
        GetScreen()->BlockLocate.SetMessageBlock( this );
        HandleBlockEnd( &dc );
        break;

    case ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS:
    case ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS:
        if( gerber_layer )
        if( gerber_layer )
            Delete_DCode_Items( &dc, gerber_layer->m_Selected_Tool, ((PCB_SCREEN*)GetScreen())->m_Active_Layer );
            Delete_DCode_Items( &dc, gerber_layer->m_Selected_Tool, ((PCB_SCREEN*)GetScreen())->m_Active_Layer );
+1 −0
Original line number Original line Diff line number Diff line
@@ -53,6 +53,7 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
                PopMenu->Append( ID_POPUP_PLACE_BLOCK, _( "Place Block" ) );
                PopMenu->Append( ID_POPUP_PLACE_BLOCK, _( "Place Block" ) );
                PopMenu->Append( ID_POPUP_COPY_BLOCK, _( "Copy Block (shift mouse)" ) );
                PopMenu->Append( ID_POPUP_COPY_BLOCK, _( "Copy Block (shift mouse)" ) );
                PopMenu->Append( ID_POPUP_DELETE_BLOCK, _( "Delete Block (ctrl + drag mouse)" ) );
                PopMenu->Append( ID_POPUP_DELETE_BLOCK, _( "Delete Block (ctrl + drag mouse)" ) );
                PopMenu->Append( ID_POPUP_MIRROR_X_BLOCK, _( "Mirror Block" ) );
            }
            }
            else
            else
                PopMenu->Append( ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ) );
                PopMenu->Append( ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ) );
+31 −1
Original line number Original line Diff line number Diff line
@@ -316,10 +316,40 @@ public:
                                            int garde, int tracevia, int modetrace );
                                            int garde, int tracevia, int modetrace );


    /* Block operations: */
    /* Block operations: */
    /**
     * Function Block_Delete
     * deletes all tracks and segments within the selected block.
     * Defined separately in pcbnew and gerbview
     *
     * @param DC A device context to draw on.
     */    
    void                     Block_Delete( wxDC* DC );
    void                     Block_Delete( wxDC* DC );
    void                     Block_Rotate( wxDC* DC );
    void                     Block_Rotate( wxDC* DC );
    void                     Block_Invert( wxDC* DC );
    void                     Block_Invert( wxDC* DC );
    /**
     * Function Block_Move
     * moves all tracks and segments within the selected block.
     * New location is determined by the current offset from the selected block's original location.
     * Defined separately in pcbnew and gerbview
     *
     * @param DC A device context to draw on.
     */
    void                     Block_Move( wxDC* DC );
    void                     Block_Move( wxDC* DC );
    /**
     * Function Block_Mirror_X
     * mirrors all tracks and segments within the currently selected block in the X axis.
     *
     * @param DC A device context to draw on.
     */
    void                     Block_Mirror_X( wxDC* DC );
    /**
     * Function Block_Duplicate
     * copies-and-moves all tracks and segments within the selected block. 
     * New location is determined by the current offset from the selected block's original location.
     * Defined separately in pcbnew and gerbview
     *
     * @param DC A device context to draw on.
     */
     void                     Block_Duplicate( wxDC* DC );
     void                     Block_Duplicate( wxDC* DC );