2009-11-22 20:55:05 +00:00
|
|
|
/***************************************/
|
|
|
|
/* edit.cpp: Gerbview events functions */
|
|
|
|
/***************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2009-11-22 20:55:05 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "gestfich.h"
|
2009-04-05 20:49:15 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "gerbview.h"
|
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "protos.h"
|
2009-12-20 19:48:58 +00:00
|
|
|
#include "kicad_device_context.h"
|
2010-01-24 13:46:01 +00:00
|
|
|
#include "gerbview_id.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
/* Process the command triggered by the left button of the mouse when a tool
|
|
|
|
* is already selected.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-09 14:00:22 +00:00
|
|
|
void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem();
|
|
|
|
wxString msg;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( m_ID_current_state == 0 )
|
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
if( DrawStruct && DrawStruct->m_Flags )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
msg.Printf( wxT( "WinEDA_GerberFrame::ProcessCommand err: Struct %d, m_Flags = %X" ),
|
|
|
|
(unsigned) DrawStruct->Type(),
|
|
|
|
(unsigned) DrawStruct->m_Flags );
|
|
|
|
DisplayError( this, msg );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawStruct = GerberGeneralLocateAndDisplay();
|
|
|
|
GetScreen()->SetCurItem( DrawStruct );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( m_ID_current_state )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_NO_SELECT_BUTT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2010-02-03 14:05:17 +00:00
|
|
|
case ID_GERBVIEW_DELETE_ITEM_BUTT:
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawStruct = GerberGeneralLocateAndDisplay();
|
|
|
|
if( DrawStruct == NULL )
|
|
|
|
break;
|
2008-12-04 04:28:11 +00:00
|
|
|
if( DrawStruct->Type() == TYPE_TRACK )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
Delete_Segment( DC, (TRACK*) DrawStruct );
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this, wxT( "WinEDA_GerberFrame::ProcessCommand error" ) );
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
/* Handles the selection of tools, menu, and popup menu commands.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-09 14:00:22 +00:00
|
|
|
void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
int layer = GetScreen()->m_Active_Layer;
|
|
|
|
GERBER* gerber_layer = g_GERBER_List[layer];
|
|
|
|
wxPoint pos;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
wxGetMousePosition( &pos.x, &pos.y );
|
|
|
|
|
|
|
|
pos.y += 20;
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
switch( id )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case wxID_CUT:
|
|
|
|
case wxID_COPY:
|
2009-05-02 18:53:04 +00:00
|
|
|
case ID_POPUP_MIRROR_X_BLOCK:
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
2009-08-12 10:40:01 +00:00
|
|
|
case ID_POPUP_FLIP_BLOCK:
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_POPUP_ROTATE_BLOCK:
|
|
|
|
case ID_POPUP_COPY_BLOCK:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
2009-12-20 19:48:58 +00:00
|
|
|
DrawPanel->UnManageCursor( );
|
2009-11-09 14:00:22 +00:00
|
|
|
/* Should not be executed, except bug */
|
2009-07-25 04:53:39 +00:00
|
|
|
if( GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
|
|
|
|
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
|
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
if( m_ID_current_state == 0 )
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
else
|
|
|
|
SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
|
|
|
|
break;
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
default:
|
2009-12-20 19:48:58 +00:00
|
|
|
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW, wxEmptyString );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-12-20 19:48:58 +00:00
|
|
|
INSTALL_DC( dc, DrawPanel );
|
2009-11-09 14:00:22 +00:00
|
|
|
switch( id )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case ID_EXIT:
|
|
|
|
Close( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_NEW_PROJECT:
|
|
|
|
case ID_LOAD_PROJECT:
|
|
|
|
Files_io( event );
|
|
|
|
break;
|
|
|
|
|
2010-02-03 14:05:17 +00:00
|
|
|
case ID_GERBVIEW_GLOBAL_DELETE:
|
2007-12-03 06:54:19 +00:00
|
|
|
Erase_Current_Layer( TRUE );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-08-12 10:40:01 +00:00
|
|
|
case ID_GET_TOOLS:
|
2009-11-09 14:00:22 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// InstallToolsFrame(this, wxPoint(-1,-1) );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_FIND_ITEMS:
|
2009-11-09 14:00:22 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// InstallFindFrame(this, pos);
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_NO_SELECT_BUTT:
|
|
|
|
SetToolID( 0, 0, wxEmptyString );
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_POPUP_CLOSE_CURRENT_TOOL:
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
|
|
|
break;
|
|
|
|
|
2010-02-03 14:05:17 +00:00
|
|
|
case ID_GERBVIEW_DELETE_ITEM_BUTT:
|
2007-09-10 04:51:01 +00:00
|
|
|
SetToolID( id, wxCURSOR_BULLSEYE, wxT( "Delete item" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-02-03 14:05:17 +00:00
|
|
|
case ID_TOOLBARH_GERBVIEW_SELECT_LAYER:
|
2010-02-04 09:08:08 +00:00
|
|
|
setActiveLayer(m_SelLayerBox->GetChoice());
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->Refresh( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TOOLBARH_GERBER_SELECT_TOOL:
|
|
|
|
if( gerber_layer )
|
|
|
|
{
|
|
|
|
int tool = m_SelLayerTool->GetChoice();
|
|
|
|
if( tool > 0 )
|
|
|
|
tool = tool - 1 + FIRST_DCODE;
|
|
|
|
else
|
|
|
|
tool = 0;
|
|
|
|
gerber_layer->m_Selected_Tool = tool;
|
|
|
|
DrawPanel->Refresh( TRUE );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DisplayError( this, _( "No layer selected" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GERBVIEW_SHOW_LIST_DCODES:
|
2009-12-20 19:48:58 +00:00
|
|
|
Liste_D_Codes( );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GERBVIEW_SHOW_SOURCE:
|
|
|
|
if( gerber_layer )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString editorname = wxGetApp().GetEditorName();
|
2007-08-20 01:20:48 +00:00
|
|
|
if( !editorname.IsEmpty() )
|
2009-04-29 17:09:00 +00:00
|
|
|
{
|
|
|
|
wxFileName fn( gerber_layer->m_FileName );
|
|
|
|
ExecuteFile( this, editorname, QuoteFullPath( fn ) );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_MOVE;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->m_AutoPAN_Request = FALSE;
|
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_COPY_BLOCK:
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_COPY;
|
|
|
|
GetScreen()->m_BlockLocate.SetMessageBlock( this );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->m_AutoPAN_Request = FALSE;
|
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_ZOOM;
|
|
|
|
GetScreen()->m_BlockLocate.SetMessageBlock( this );
|
|
|
|
GetScreen()->m_BlockLocate.SetMessageBlock( this );
|
2007-08-20 01:20:48 +00:00
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_DELETE;
|
|
|
|
GetScreen()->m_BlockLocate.SetMessageBlock( this );
|
2007-08-20 01:20:48 +00:00
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
2009-05-02 18:53:04 +00:00
|
|
|
case ID_POPUP_MIRROR_X_BLOCK:
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_MIRROR_X;
|
|
|
|
GetScreen()->m_BlockLocate.SetMessageBlock( this );
|
2009-05-02 18:53:04 +00:00
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS:
|
|
|
|
if( gerber_layer )
|
2009-11-09 14:00:22 +00:00
|
|
|
Delete_DCode_Items( &dc, gerber_layer->m_Selected_Tool,
|
|
|
|
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxMessageBox( wxT( "WinEDA_GerberFrame::Process_Special_Functions error" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetToolbars();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
/* Called on a double click of left mouse button.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-09 14:00:22 +00:00
|
|
|
void WinEDA_GerberFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem();
|
|
|
|
|
|
|
|
switch( m_ID_current_state )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
|
|
|
|
{
|
|
|
|
DrawStruct = GerberGeneralLocateAndDisplay();
|
|
|
|
}
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-12 10:40:01 +00:00
|
|
|
default:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|