2010-07-27 16:49:38 +00:00
|
|
|
/***************************************/
|
|
|
|
/* edit.cpp: Gerbview events functions */
|
|
|
|
/***************************************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "gestfich.h"
|
|
|
|
#include "appl_wxstruct.h"
|
|
|
|
|
|
|
|
#include "gerbview.h"
|
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "kicad_device_context.h"
|
|
|
|
#include "gerbview_id.h"
|
2010-10-06 17:28:07 +00:00
|
|
|
#include "class_GERBER.h"
|
2010-11-18 21:16:28 +00:00
|
|
|
#include "dialog_helpers.h"
|
2010-12-17 20:34:29 +00:00
|
|
|
#include "class_DCodeSelectionbox.h"
|
2010-07-27 16:49:38 +00:00
|
|
|
|
|
|
|
/* Process the command triggered by the left button of the mouse when a tool
|
|
|
|
* is already selected.
|
|
|
|
*/
|
2011-02-21 13:54:29 +00:00
|
|
|
void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
|
2010-07-27 16:49:38 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem();
|
|
|
|
wxString msg;
|
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
2010-07-27 16:49:38 +00:00
|
|
|
{
|
2010-10-16 14:51:22 +00:00
|
|
|
if( DrawStruct && DrawStruct->m_Flags )
|
2010-07-27 16:49:38 +00:00
|
|
|
{
|
|
|
|
msg.Printf( wxT( "WinEDA_GerberFrame::ProcessCommand err: Struct %d, m_Flags = %X" ),
|
|
|
|
(unsigned) DrawStruct->Type(),
|
|
|
|
(unsigned) DrawStruct->m_Flags );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-21 13:54:29 +00:00
|
|
|
DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE );
|
2010-07-27 16:49:38 +00:00
|
|
|
GetScreen()->SetCurItem( DrawStruct );
|
2010-10-17 12:32:35 +00:00
|
|
|
if( DrawStruct == NULL )
|
|
|
|
{
|
|
|
|
GERBER_IMAGE* gerber = g_GERBER_List[getActiveLayer() ];
|
|
|
|
if( gerber )
|
|
|
|
gerber->DisplayImageInfo( );
|
|
|
|
}
|
2010-07-27 16:49:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
switch( GetToolId() )
|
2010-07-27 16:49:38 +00:00
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
case ID_NO_TOOL_SELECTED:
|
2010-07-27 16:49:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GERBVIEW_DELETE_ITEM_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
DrawStruct = Locate( aPosition, CURSEUR_OFF_GRILLE );
|
|
|
|
|
2010-07-27 16:49:38 +00:00
|
|
|
if( DrawStruct == NULL )
|
|
|
|
break;
|
2010-09-28 14:42:05 +00:00
|
|
|
/* TODO:
|
|
|
|
Delete_Item( DC, (GERBER_DRAW_ITEM*) DrawStruct );
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
*/
|
2010-07-27 16:49:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this, wxT( "WinEDA_GerberFrame::ProcessCommand error" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Handles the selection of tools, menu, and popup menu commands.
|
|
|
|
*/
|
|
|
|
void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
int id = event.GetId();
|
|
|
|
int layer = GetScreen()->m_Active_Layer;
|
2010-10-16 14:51:22 +00:00
|
|
|
GERBER_IMAGE* gerber_layer = g_GERBER_List[layer];
|
2010-07-27 16:49:38 +00:00
|
|
|
wxPoint pos;
|
|
|
|
|
|
|
|
wxGetMousePosition( &pos.x, &pos.y );
|
|
|
|
|
|
|
|
pos.y += 20;
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case wxID_CUT:
|
|
|
|
case wxID_COPY:
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->EndMouseCapture( );
|
|
|
|
|
2010-07-27 16:49:38 +00:00
|
|
|
/* Should not be executed, except bug */
|
|
|
|
if( GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE )
|
|
|
|
{
|
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
|
|
|
|
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
|
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
|
|
|
}
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
|
|
|
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
|
2010-07-27 16:49:38 +00:00
|
|
|
else
|
2011-02-08 14:48:38 +00:00
|
|
|
DrawPanel->SetCursor( DrawPanel->GetDefaultCursor() );
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2010-07-27 16:49:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->EndMouseCapture( );
|
2010-07-27 16:49:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
INSTALL_DC( dc, DrawPanel );
|
2011-01-30 22:22:38 +00:00
|
|
|
|
2010-07-27 16:49:38 +00:00
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_EXIT:
|
|
|
|
Close( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GERBVIEW_GLOBAL_DELETE:
|
|
|
|
Erase_Current_Layer( TRUE );
|
2010-10-17 16:42:06 +00:00
|
|
|
ClearMsgPanel();
|
2010-07-27 16:49:38 +00:00
|
|
|
break;
|
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
case ID_NO_TOOL_SELECTED:
|
|
|
|
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
|
2010-07-27 16:49:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_CLOSE_CURRENT_TOOL:
|
2011-02-24 20:22:12 +00:00
|
|
|
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
|
2010-07-27 16:49:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GERBVIEW_DELETE_ITEM_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_BULLSEYE, wxT( "Delete item" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TOOLBARH_GERBVIEW_SELECT_LAYER:
|
|
|
|
setActiveLayer(m_SelLayerBox->GetChoice());
|
2010-12-17 20:34:29 +00:00
|
|
|
DrawPanel->Refresh();
|
2010-07-27 16:49:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TOOLBARH_GERBER_SELECT_TOOL:
|
|
|
|
if( gerber_layer )
|
|
|
|
{
|
2010-12-17 20:34:29 +00:00
|
|
|
int tool = m_DCodeSelector->GetSelectedDCodeId();
|
|
|
|
if( tool != gerber_layer->m_Selected_Tool )
|
|
|
|
{
|
|
|
|
gerber_layer->m_Selected_Tool = tool;
|
|
|
|
DrawPanel->Refresh();
|
|
|
|
}
|
2010-07-27 16:49:38 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GERBVIEW_SHOW_LIST_DCODES:
|
|
|
|
Liste_D_Codes( );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GERBVIEW_SHOW_SOURCE:
|
|
|
|
if( gerber_layer )
|
|
|
|
{
|
|
|
|
wxString editorname = wxGetApp().GetEditorName();
|
|
|
|
if( !editorname.IsEmpty() )
|
|
|
|
{
|
|
|
|
wxFileName fn( gerber_layer->m_FileName );
|
|
|
|
ExecuteFile( this, editorname, QuoteFullPath( fn ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_MOVE;
|
|
|
|
DrawPanel->m_AutoPAN_Request = FALSE;
|
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_ZOOM;
|
|
|
|
GetScreen()->m_BlockLocate.SetMessageBlock( this );
|
|
|
|
GetScreen()->m_BlockLocate.SetMessageBlock( this );
|
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_DELETE;
|
|
|
|
GetScreen()->m_BlockLocate.SetMessageBlock( this );
|
|
|
|
HandleBlockEnd( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS:
|
|
|
|
if( gerber_layer )
|
|
|
|
Delete_DCode_Items( &dc, gerber_layer->m_Selected_Tool,
|
|
|
|
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxMessageBox( wxT( "WinEDA_GerberFrame::Process_Special_Functions error" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Called on a double click of left mouse button.
|
|
|
|
*/
|
2011-02-21 13:54:29 +00:00
|
|
|
void WinEDA_GerberFrame::OnLeftDClick( wxDC* DC, const wxPoint& aPosition )
|
2010-07-27 16:49:38 +00:00
|
|
|
{
|
2010-10-13 19:50:23 +00:00
|
|
|
// Currently: no nothing
|
2010-07-27 16:49:38 +00:00
|
|
|
}
|