2013-05-28 16:54:59 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file modedit.cpp
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <gestfich.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <3d_viewer.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <kicad_device_context.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <pcbcommon.h>
|
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_edge_mod.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <protos.h>
|
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <module_editor_frame.h>
|
2012-02-09 20:33:38 +00:00
|
|
|
#include <modview_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <collectors.h>
|
|
|
|
|
|
|
|
#include <dialog_edit_module_for_Modedit.h>
|
2012-03-08 17:47:23 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2012-04-09 09:16:47 +00:00
|
|
|
#include <menus_helpers.h>
|
2012-05-09 17:37:25 +00:00
|
|
|
#include <footprint_wizard_frame.h>
|
2013-04-11 18:29:56 +00:00
|
|
|
#include <pcbnew_config.h>
|
2012-05-09 17:37:25 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-02-19 19:53:11 +00:00
|
|
|
// Functions defined in block_module_editor, but used here
|
|
|
|
// These 2 functions are used in modedit to rotate or mirror the whole footprint
|
|
|
|
// so they are called with force_all = true
|
|
|
|
void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
|
|
|
|
void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
BOARD_ITEM* FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay( int aHotKeyCode )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-04-06 16:05:25 +00:00
|
|
|
BOARD_ITEM* item = GetCurItem();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard()->m_Modules == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-10-27 18:05:50 +00:00
|
|
|
GENERAL_COLLECTORS_GUIDE guide = GetCollectorsGuide();
|
|
|
|
|
|
|
|
// Assign to scanList the proper item types desired based on tool type
|
|
|
|
// or hotkey that is in play.
|
|
|
|
|
|
|
|
const KICAD_T* scanList = NULL;
|
|
|
|
|
|
|
|
if( aHotKeyCode )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
// @todo: add switch here and add calls to PcbGeneralLocateAndDisplay(
|
|
|
|
// int aHotKeyCode ) when searching is needed from a hotkey handler
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
2007-10-27 18:05:50 +00:00
|
|
|
{
|
|
|
|
scanList = GENERAL_COLLECTOR::ModulesAndTheirItems;
|
|
|
|
}
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
m_Collector->Collect( GetBoard(), scanList, RefPos( true ), guide );
|
2007-10-27 18:05:50 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// Remove redundancies: when an item is found, we can remove the module from list
|
2007-11-12 05:53:48 +00:00
|
|
|
if( m_Collector->GetCount() > 1 )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
for( int ii = 0; ii < m_Collector->GetCount(); ii++ )
|
2007-11-12 05:53:48 +00:00
|
|
|
{
|
|
|
|
item = (*m_Collector)[ii];
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( item->Type() != PCB_MODULE_T )
|
2007-11-12 05:53:48 +00:00
|
|
|
continue;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-11-12 05:53:48 +00:00
|
|
|
m_Collector->Remove( ii );
|
|
|
|
ii--;
|
|
|
|
}
|
|
|
|
}
|
2007-10-27 18:05:50 +00:00
|
|
|
|
|
|
|
if( m_Collector->GetCount() <= 1 )
|
|
|
|
{
|
|
|
|
item = (*m_Collector)[0];
|
|
|
|
SetCurItem( item );
|
|
|
|
}
|
2011-08-26 17:01:17 +00:00
|
|
|
else // we can't figure out which item user wants, do popup menu so user can choose
|
2007-10-27 18:05:50 +00:00
|
|
|
{
|
2009-04-06 16:05:25 +00:00
|
|
|
wxMenu itemMenu;
|
2007-10-27 18:05:50 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// Give a title to the selection menu. This is also a cancel menu item *
|
2011-08-26 17:01:17 +00:00
|
|
|
wxMenuItem* item_title = new wxMenuItem( &itemMenu, -1, _( "Selection Clarification" ) );
|
|
|
|
|
2007-10-27 18:05:50 +00:00
|
|
|
#ifdef __WINDOWS__
|
2009-04-06 16:05:25 +00:00
|
|
|
wxFont bold_font( *wxNORMAL_FONT );
|
|
|
|
bold_font.SetWeight( wxFONTWEIGHT_BOLD );
|
|
|
|
bold_font.SetStyle( wxFONTSTYLE_ITALIC );
|
|
|
|
item_title->SetFont( bold_font );
|
2007-10-27 18:05:50 +00:00
|
|
|
#endif
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2009-04-06 16:05:25 +00:00
|
|
|
itemMenu.Append( item_title );
|
2007-10-27 18:05:50 +00:00
|
|
|
itemMenu.AppendSeparator();
|
|
|
|
|
2012-09-22 11:19:37 +00:00
|
|
|
int limit = std::min( MAX_ITEMS_IN_PICKER, m_Collector->GetCount() );
|
2007-10-27 18:05:50 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
for( int ii = 0; ii<limit; ++ii )
|
2007-10-27 18:05:50 +00:00
|
|
|
{
|
|
|
|
item = (*m_Collector)[ii];
|
|
|
|
|
2011-09-08 05:58:45 +00:00
|
|
|
wxString text = item->GetSelectMenuText();
|
|
|
|
BITMAP_DEF xpm = item->GetMenuImage();
|
2007-10-27 18:05:50 +00:00
|
|
|
|
2011-09-01 12:54:34 +00:00
|
|
|
AddMenuItem( &itemMenu,
|
|
|
|
ID_POPUP_PCB_ITEM_SELECTION_START + ii,
|
|
|
|
text,
|
2011-09-08 05:58:45 +00:00
|
|
|
KiBitmap( xpm ) );
|
2007-10-27 18:05:50 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
// this menu's handler is void
|
2011-03-01 19:26:17 +00:00
|
|
|
// PCB_BASE_FRAME::ProcessItemSelection()
|
2009-11-18 12:52:19 +00:00
|
|
|
// and it calls SetCurItem() which in turn calls DisplayInfo() on the
|
|
|
|
// item.
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAbortRequest( true ); // changed in false if an item
|
|
|
|
PopupMenu( &itemMenu ); // m_AbortRequest = false if an item is selected
|
2007-10-27 18:05:50 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetIgnoreMouseEvents( false );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
// The function ProcessItemSelection() has set the current item, return it.
|
2007-10-27 18:05:50 +00:00
|
|
|
item = GetCurItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
{
|
2013-01-12 17:32:24 +00:00
|
|
|
SetMsgPanel( item );
|
2007-10-27 18:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
void FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard( wxCommandEvent& event )
|
2009-05-21 17:42:42 +00:00
|
|
|
{
|
2011-08-26 17:01:17 +00:00
|
|
|
if( GetScreen()->IsModify() )
|
2010-06-14 20:16:47 +00:00
|
|
|
{
|
|
|
|
if( !IsOK( this,
|
2011-08-26 17:01:17 +00:00
|
|
|
_( "Current footprint changes will be lost and this operation cannot be undone. Continue?" ) ) )
|
2010-06-14 20:16:47 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ! Load_Module_From_BOARD( NULL ) )
|
|
|
|
return;
|
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
GetScreen()->ClearUndoRedoList();
|
|
|
|
GetScreen()->ClrModify();
|
|
|
|
|
|
|
|
if( m_Draw3DFrame )
|
|
|
|
m_Draw3DFrame->NewDisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
wxPoint pos;
|
|
|
|
bool redraw = false;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
INSTALL_UNBUFFERED_DC( dc, m_canvas );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
wxGetMousePosition( &pos.x, &pos.y );
|
|
|
|
|
|
|
|
pos.y += 20;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
switch( id )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case wxID_CUT:
|
|
|
|
case wxID_COPY:
|
|
|
|
case ID_TOOLBARH_PCB_SELECT_LAYER:
|
|
|
|
case ID_MODEDIT_PAD_SETTINGS:
|
|
|
|
case ID_PCB_USER_GRID_SETUP:
|
|
|
|
case ID_POPUP_PCB_ROTATE_TEXTEPCB:
|
|
|
|
case ID_POPUP_PCB_EDIT_TEXTEPCB:
|
|
|
|
case ID_POPUP_PCB_ROTATE_TEXTMODULE:
|
|
|
|
case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
|
|
|
|
case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE:
|
|
|
|
case ID_POPUP_PCB_EDIT_TEXTMODULE:
|
|
|
|
case ID_POPUP_PCB_IMPORT_PAD_SETTINGS:
|
|
|
|
case ID_POPUP_PCB_EXPORT_PAD_SETTINGS:
|
|
|
|
case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
|
|
|
|
case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
|
2012-02-12 19:39:37 +00:00
|
|
|
case ID_POPUP_MODEDIT_EDIT_BODY_ITEM:
|
|
|
|
case ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE:
|
|
|
|
case ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE:
|
|
|
|
case ID_POPUP_MODEDIT_ENTER_EDGE_WIDTH:
|
2012-08-31 19:19:48 +00:00
|
|
|
case ID_POPUP_PCB_DELETE_EDGE:
|
|
|
|
case ID_POPUP_PCB_DELETE_TEXTMODULE:
|
|
|
|
case ID_POPUP_PCB_DELETE_PAD:
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
|
|
|
case ID_POPUP_MIRROR_X_BLOCK:
|
|
|
|
case ID_POPUP_ROTATE_BLOCK:
|
|
|
|
case ID_POPUP_COPY_BLOCK:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
2009-05-23 07:16:05 +00:00
|
|
|
default:
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-05-23 07:16:05 +00:00
|
|
|
// for all other commands: stop the move in progress
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallEndMouseCapture( &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2009-05-23 07:16:05 +00:00
|
|
|
if( id != ID_POPUP_CANCEL_CURRENT_COMMAND )
|
2011-12-22 13:28:11 +00:00
|
|
|
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
switch( id )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case ID_EXIT:
|
2009-01-15 08:12:03 +00:00
|
|
|
Close( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
case ID_MODEDIT_SELECT_CURRENT_LIB:
|
2013-11-27 06:04:04 +00:00
|
|
|
{
|
|
|
|
wxString library = SelectLibrary( getLibNickName() );
|
|
|
|
|
|
|
|
if( library.size() )
|
|
|
|
{
|
|
|
|
setLibNickName( library );
|
|
|
|
updateTitle();
|
|
|
|
}
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
case ID_OPEN_MODULE_VIEWER:
|
2013-05-28 16:54:59 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
FOOTPRINT_VIEWER_FRAME * viewer = FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer();
|
|
|
|
|
|
|
|
if( viewer == NULL )
|
|
|
|
{
|
|
|
|
viewer = new FOOTPRINT_VIEWER_FRAME( this, m_footprintLibTable, NULL );
|
|
|
|
viewer->Show( true );
|
|
|
|
viewer->Zoom_Automatique( false );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( viewer->IsIconized() )
|
|
|
|
viewer->Iconize( false );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
viewer->Raise();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// Raising the window does not set the focus on Linux. This should work on
|
|
|
|
// any platform.
|
|
|
|
if( wxWindow::FindFocus() != viewer )
|
|
|
|
viewer->SetFocus();
|
|
|
|
}
|
2012-09-12 09:53:11 +00:00
|
|
|
}
|
2013-08-03 05:15:23 +00:00
|
|
|
break;
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
case ID_MODEDIT_DELETE_PART:
|
2012-11-19 16:19:38 +00:00
|
|
|
DeleteModuleFromCurrentLibrary();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_NEW_MODULE:
|
2013-11-29 18:29:41 +00:00
|
|
|
{
|
|
|
|
Clear_Pcb( true );
|
|
|
|
GetScreen()->ClearUndoRedoList();
|
|
|
|
SetCurItem( NULL );
|
|
|
|
SetCrossHairPosition( wxPoint( 0, 0 ) );
|
2008-09-18 12:07:34 +00:00
|
|
|
|
2013-11-29 18:29:41 +00:00
|
|
|
MODULE* module = Create_1_Module( wxEmptyString );
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2013-11-29 18:29:41 +00:00
|
|
|
if( module ) // i.e. if create module command not aborted
|
|
|
|
{
|
|
|
|
// Initialize data relative to nets and netclasses (for a new
|
|
|
|
// module the defaults are used)
|
|
|
|
// This is mandatory to handle and draw pads
|
|
|
|
GetBoard()->BuildListOfNets();
|
|
|
|
redraw = true;
|
|
|
|
module->SetPosition( wxPoint( 0, 0 ) );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2013-11-29 18:29:41 +00:00
|
|
|
if( GetBoard()->m_Modules )
|
|
|
|
GetBoard()->m_Modules->ClearFlags();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2013-11-29 18:29:41 +00:00
|
|
|
Zoom_Automatique( false );
|
2008-09-18 12:07:34 +00:00
|
|
|
}
|
2013-11-29 18:29:41 +00:00
|
|
|
}
|
2013-08-03 05:15:23 +00:00
|
|
|
break;
|
2012-08-31 19:19:48 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
case ID_MODEDIT_NEW_MODULE_FROM_WIZARD:
|
2013-05-28 16:54:59 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
wxSemaphore semaphore( 0, 1 );
|
|
|
|
FOOTPRINT_WIZARD_FRAME *wizard = new FOOTPRINT_WIZARD_FRAME( this, &semaphore,
|
|
|
|
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT );
|
|
|
|
wizard->Show( true );
|
|
|
|
wizard->Zoom_Automatique( false );
|
|
|
|
|
|
|
|
while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event
|
|
|
|
{
|
|
|
|
wxYield();
|
|
|
|
wxMilliSleep( 50 );
|
|
|
|
}
|
2012-08-31 19:19:48 +00:00
|
|
|
|
2013-08-05 13:43:15 +00:00
|
|
|
// Creates the new footprint from python script wizard
|
2013-08-03 05:15:23 +00:00
|
|
|
MODULE* module = wizard->GetBuiltFootprint();
|
2012-08-04 22:15:57 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
if( module ) // i.e. if create module command not aborted
|
|
|
|
{
|
2013-08-05 13:43:15 +00:00
|
|
|
Clear_Pcb( true );
|
|
|
|
GetScreen()->ClearUndoRedoList();
|
|
|
|
SetCurItem( NULL );
|
|
|
|
SetCrossHairPosition( wxPoint( 0, 0 ) );
|
|
|
|
|
|
|
|
// Add the new object to board
|
2013-08-03 05:15:23 +00:00
|
|
|
module->SetParent( (EDA_ITEM*)GetBoard() );
|
|
|
|
GetBoard()->m_Modules.Append( module );
|
|
|
|
|
|
|
|
// Initialize data relative to nets and netclasses (for a new
|
|
|
|
// module the defaults are used)
|
|
|
|
// This is mandatory to handle and draw pads
|
|
|
|
GetBoard()->BuildListOfNets();
|
|
|
|
redraw = true;
|
|
|
|
module->SetPosition( wxPoint( 0, 0 ) );
|
2013-08-05 13:43:15 +00:00
|
|
|
module->ClearFlags();
|
2013-08-03 05:15:23 +00:00
|
|
|
}
|
2013-05-28 16:54:59 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
wizard->Destroy();
|
|
|
|
}
|
2012-05-09 17:37:25 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_MODEDIT_SAVE_LIBMODULE:
|
2013-11-27 06:04:04 +00:00
|
|
|
if( GetBoard()->m_Modules && getLibNickName().size() )
|
|
|
|
{
|
|
|
|
Save_Module_In_Library( getLibNickName(), GetBoard()->m_Modules, true, true );
|
|
|
|
GetScreen()->ClrModify();
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_INSERT_MODULE_IN_BOARD:
|
|
|
|
case ID_MODEDIT_UPDATE_MODULE_IN_BOARD:
|
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
// update module in the current board,
|
|
|
|
// not just add it to the board with total disregard for the netlist...
|
|
|
|
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) GetParent();
|
|
|
|
BOARD* mainpcb = pcbframe->GetBoard();
|
|
|
|
MODULE* source_module = NULL;
|
|
|
|
MODULE* module_in_edit = GetBoard()->m_Modules;
|
|
|
|
|
|
|
|
// Search the old module (source) if exists
|
|
|
|
// Because this source could be deleted when editing the main board...
|
|
|
|
if( module_in_edit->GetLink() ) // this is not a new module ...
|
|
|
|
{
|
|
|
|
source_module = mainpcb->m_Modules;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
for( ; source_module != NULL; source_module = (MODULE*) source_module->Next() )
|
|
|
|
{
|
|
|
|
if( module_in_edit->GetLink() == source_module->GetTimeStamp() )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ( source_module == NULL )
|
|
|
|
&& ( id == ID_MODEDIT_UPDATE_MODULE_IN_BOARD ) ) // source not found
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Unable to find the footprint source on the main board" ) );
|
|
|
|
msg << _( "\nCannot update the footprint" );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
if( ( source_module != NULL )
|
|
|
|
&& ( id == ID_MODEDIT_INSERT_MODULE_IN_BOARD ) ) // source not found
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "A footprint source was found on the main board" ) );
|
|
|
|
msg << _( "\nCannot insert this footprint" );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
break;
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// Create the "new" module
|
|
|
|
MODULE* newmodule = new MODULE( *module_in_edit );
|
|
|
|
newmodule->SetParent( mainpcb );
|
|
|
|
newmodule->SetLink( 0 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// Put the footprint in the main pcb linked list.
|
|
|
|
mainpcb->Add( newmodule );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
if( source_module ) // this is an update command
|
|
|
|
{
|
|
|
|
// In the main board,
|
|
|
|
// the new module replace the old module (pos, orient, ref, value
|
|
|
|
// and connexions are kept)
|
|
|
|
// and the source_module (old module) is deleted
|
|
|
|
PICKED_ITEMS_LIST pickList;
|
|
|
|
pcbframe->Exchange_Module( source_module, newmodule, &pickList );
|
|
|
|
newmodule->SetTimeStamp( module_in_edit->GetLink() );
|
|
|
|
|
|
|
|
if( pickList.GetCount() )
|
|
|
|
pcbframe->SaveCopyInUndoList( pickList, UR_UNSPECIFIED );
|
|
|
|
}
|
|
|
|
else // This is an insert command
|
|
|
|
{
|
|
|
|
wxPoint cursor_pos = pcbframe->GetCrossHairPosition();
|
|
|
|
pcbframe->SetCrossHairPosition( wxPoint( 0, 0 ) );
|
|
|
|
pcbframe->PlaceModule( newmodule, NULL );
|
|
|
|
pcbframe->SetCrossHairPosition( cursor_pos );
|
|
|
|
newmodule->SetTimeStamp( GetNewTimeStamp() );
|
|
|
|
pcbframe->SaveCopyInUndoList( newmodule, UR_NEW );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
newmodule->ClearFlags();
|
|
|
|
GetScreen()->ClrModify();
|
|
|
|
pcbframe->SetCurItem( NULL );
|
|
|
|
mainpcb->m_Status_Pcb = 0;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2013-08-03 05:15:23 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
case ID_MODEDIT_IMPORT_PART:
|
2010-06-14 20:16:47 +00:00
|
|
|
if( ! Clear_Pcb( true ) )
|
|
|
|
break; // //this command is aborted
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->ClearUndoRedoList();
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( wxPoint( 0, 0 ) );
|
2011-08-26 17:01:17 +00:00
|
|
|
Import_Module();
|
2009-05-23 07:16:05 +00:00
|
|
|
redraw = true;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard()->m_Modules )
|
2011-12-21 13:42:02 +00:00
|
|
|
GetBoard()->m_Modules->ClearFlags();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->ClrModify();
|
2011-03-01 18:45:21 +00:00
|
|
|
Zoom_Automatique( false );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_Draw3DFrame )
|
|
|
|
m_Draw3DFrame->NewDisplay();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
case ID_MODEDIT_EXPORT_PART:
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard()->m_Modules )
|
2012-11-19 16:19:38 +00:00
|
|
|
Export_Module( GetBoard()->m_Modules );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
case ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART:
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard()->m_Modules )
|
2012-11-19 16:19:38 +00:00
|
|
|
{
|
|
|
|
// CreateModuleLibrary() only creates a new library, does not save footprint
|
|
|
|
wxString libPath = CreateNewLibrary();
|
|
|
|
if( libPath.size() )
|
|
|
|
SaveCurrentModule( &libPath );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_SHEET_SET:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_LOAD_MODULE:
|
2013-05-28 16:54:59 +00:00
|
|
|
wxLogDebug( wxT( "Loading module from library " ) + getLibPath() );
|
2009-04-08 18:06:22 +00:00
|
|
|
|
2013-05-28 16:54:59 +00:00
|
|
|
GetScreen()->ClearUndoRedoList();
|
|
|
|
SetCurItem( NULL );
|
|
|
|
Clear_Pcb( true );
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( wxPoint( 0, 0 ) );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2013-05-28 16:54:59 +00:00
|
|
|
LoadModuleFromLibrary( getLibNickName(), m_footprintLibTable, true );
|
|
|
|
redraw = true;
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard()->m_Modules )
|
2013-05-28 16:54:59 +00:00
|
|
|
GetBoard()->m_Modules->ClearFlags();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-06 15:42:09 +00:00
|
|
|
// if either m_Reference or m_Value are gone, reinstall them -
|
|
|
|
// otherwise you cannot see what you are doing on board
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard() && GetBoard()->m_Modules )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-03-13 18:53:58 +00:00
|
|
|
TEXTE_MODULE* ref = &GetBoard()->m_Modules->Reference();
|
|
|
|
TEXTE_MODULE* val = &GetBoard()->m_Modules->Value();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( val && ref )
|
|
|
|
{
|
2013-04-07 11:55:18 +00:00
|
|
|
ref->SetType( TEXTE_MODULE::TEXT_is_REFERENCE ); // just in case ...
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( ref->GetLength() == 0 )
|
|
|
|
ref->SetText( wxT( "Ref**" ) );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
val->SetType( TEXTE_MODULE::TEXT_is_VALUE ); // just in case ...
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( val->GetLength() == 0 )
|
|
|
|
val->SetText( L"Val**" );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->ClrModify();
|
2011-03-01 18:45:21 +00:00
|
|
|
Zoom_Automatique( false );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_Draw3DFrame )
|
|
|
|
m_Draw3DFrame->NewDisplay();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_PAD_SETTINGS:
|
2009-12-19 19:24:49 +00:00
|
|
|
InstallPadOptionsFrame( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_CHECK:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_EDIT_MODULE_PROPERTIES:
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard()->m_Modules )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
SetCurItem( GetBoard()->m_Modules );
|
2011-08-26 17:01:17 +00:00
|
|
|
DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) GetScreen()-> GetCurItem() );
|
2009-08-11 10:27:21 +00:00
|
|
|
int ret = dialog.ShowModal();
|
2011-12-21 13:42:02 +00:00
|
|
|
GetScreen()->GetCurItem()->ClearFlags();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
if( ret > 0 )
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_CLOSE_CURRENT_TOOL:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2009-05-21 12:45:21 +00:00
|
|
|
Rotate_Module( NULL, (MODULE*) GetScreen()->GetCurItem(), 900, true );
|
2009-05-23 07:16:05 +00:00
|
|
|
redraw = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2009-05-23 07:16:05 +00:00
|
|
|
Rotate_Module( NULL, (MODULE*) GetScreen()->GetCurItem(), -900, true );
|
|
|
|
redraw = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2013-03-01 19:59:29 +00:00
|
|
|
case ID_POPUP_PCB_EDIT_MODULE_PRMS:
|
2012-11-19 16:19:38 +00:00
|
|
|
{
|
|
|
|
DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) GetScreen()->GetCurItem() );
|
|
|
|
int ret = dialog.ShowModal();
|
|
|
|
GetScreen()->GetCurItem()->ClearFlags();
|
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
if( ret > 0 )
|
|
|
|
m_canvas->Refresh();
|
|
|
|
}
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_PCB_MOVE_PAD_REQUEST:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2012-09-11 07:33:17 +00:00
|
|
|
StartMovePad( (D_PAD*) GetScreen()->GetCurItem(), &dc, false );
|
2012-11-19 16:19:38 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_PCB_EDIT_PAD:
|
2009-12-19 19:24:49 +00:00
|
|
|
InstallPadOptionsFrame( (D_PAD*) GetScreen()->GetCurItem() );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2009-05-23 07:16:05 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_PCB_DELETE_PAD:
|
2009-08-03 18:54:48 +00:00
|
|
|
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
|
2010-08-11 13:15:30 +00:00
|
|
|
DeletePad( (D_PAD*) GetScreen()->GetCurItem(), false );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_IMPORT_PAD_SETTINGS:
|
2009-08-03 18:54:48 +00:00
|
|
|
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2008-04-18 13:28:56 +00:00
|
|
|
Import_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem(), true );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
|
2009-08-03 18:54:48 +00:00
|
|
|
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
|
2011-12-30 12:29:54 +00:00
|
|
|
// Calls the global change dialog:
|
|
|
|
DlgGlobalChange_PadSettings( (D_PAD*) GetScreen()->GetCurItem() );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_EXPORT_PAD_SETTINGS:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
Export_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem() );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_EDIT_TEXTMODULE:
|
2011-08-26 17:01:17 +00:00
|
|
|
InstallTextModOptionsFrame( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2012-11-19 16:19:38 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2009-05-23 07:16:05 +00:00
|
|
|
StartMoveTexteModule( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc );
|
2012-11-19 16:19:38 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_PCB_ROTATE_TEXTMODULE:
|
2009-08-11 10:27:21 +00:00
|
|
|
RotateTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2012-11-19 16:19:38 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_PCB_DELETE_TEXTMODULE:
|
2009-08-03 18:54:48 +00:00
|
|
|
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
|
2009-05-23 07:16:05 +00:00
|
|
|
DeleteTextModule( (TEXTE_MODULE*) GetScreen()->GetCurItem() );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_MOVE_EDGE:
|
|
|
|
Start_Move_EdgeMod( (EDGE_MODULE*) GetScreen()->GetCurItem(), &dc );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2012-11-19 16:19:38 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( GetScreen()->GetCurItem()->IsNew() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-07-20 18:11:34 +00:00
|
|
|
End_Edge_Module( (EDGE_MODULE*) GetScreen()->GetCurItem() );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-02-12 19:39:37 +00:00
|
|
|
case ID_POPUP_MODEDIT_ENTER_EDGE_WIDTH:
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
EDGE_MODULE* edge = NULL;
|
|
|
|
if( GetScreen()->GetCurItem()
|
|
|
|
&& ( GetScreen()->GetCurItem()->Type() == PCB_MODULE_EDGE_T ) )
|
|
|
|
{
|
|
|
|
edge = (EDGE_MODULE*) GetScreen()->GetCurItem();
|
|
|
|
}
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
Enter_Edge_Width( edge );
|
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
if( edge )
|
|
|
|
m_canvas->Refresh();
|
|
|
|
}
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-12 19:39:37 +00:00
|
|
|
case ID_POPUP_MODEDIT_EDIT_BODY_ITEM :
|
|
|
|
m_canvas->MoveCursorToCrossHair();
|
|
|
|
InstallFootprintBodyItemPropertiesDlg( (EDGE_MODULE*) GetScreen()->GetCurItem() );
|
|
|
|
m_canvas->Refresh();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2009-05-23 07:16:05 +00:00
|
|
|
Edit_Edge_Width( NULL );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2012-02-12 19:39:37 +00:00
|
|
|
case ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE:
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2009-05-23 07:16:05 +00:00
|
|
|
Edit_Edge_Layer( NULL );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PCB_DELETE_EDGE:
|
2009-08-03 18:54:48 +00:00
|
|
|
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->MoveCursorToCrossHair();
|
2009-05-23 07:16:05 +00:00
|
|
|
RemoveStruct( GetScreen()->GetCurItem() );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_MODULE_ROTATE:
|
|
|
|
case ID_MODEDIT_MODULE_MIRROR:
|
2009-08-03 18:54:48 +00:00
|
|
|
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
|
2009-05-23 07:16:05 +00:00
|
|
|
Transform( (MODULE*) GetScreen()->GetCurItem(), id );
|
|
|
|
redraw = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PCB_DRAWINGS_WIDTHS_SETUP:
|
|
|
|
InstallOptionsFrame( pos );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PCB_PAD_SETUP:
|
2007-11-12 05:53:48 +00:00
|
|
|
{
|
2012-11-19 16:19:38 +00:00
|
|
|
BOARD_ITEM* item = GetCurItem();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2012-11-19 16:19:38 +00:00
|
|
|
if( item )
|
|
|
|
{
|
|
|
|
if( item->Type() != PCB_PAD_T )
|
|
|
|
item = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
InstallPadOptionsFrame( (D_PAD*) item );
|
|
|
|
}
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_PCB_USER_GRID_SETUP:
|
2013-07-09 05:48:26 +00:00
|
|
|
InvokeDialogGrid();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetCommand( BLOCK_MOVE );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2009-11-18 12:52:19 +00:00
|
|
|
HandleBlockPlace( &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_COPY_BLOCK:
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetCommand( BLOCK_COPY );
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetMessageBlock( this );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetAutoPanRequest( false );
|
2009-11-18 12:52:19 +00:00
|
|
|
HandleBlockPlace( &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetCommand( BLOCK_ZOOM );
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetMessageBlock( this );
|
2009-11-18 12:52:19 +00:00
|
|
|
HandleBlockEnd( &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetCommand( BLOCK_DELETE );
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetMessageBlock( this );
|
2009-11-18 12:52:19 +00:00
|
|
|
HandleBlockEnd( &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ROTATE_BLOCK:
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetCommand( BLOCK_ROTATE );
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetMessageBlock( this );
|
2009-11-18 12:52:19 +00:00
|
|
|
HandleBlockEnd( &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_MIRROR_X_BLOCK:
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetCommand( BLOCK_MIRROR_X );
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetMessageBlock( this );
|
2009-11-18 12:52:19 +00:00
|
|
|
HandleBlockEnd( &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DisplayError( this,
|
2011-08-26 17:01:17 +00:00
|
|
|
wxT( "FOOTPRINT_EDIT_FRAME::Process_Special_Functions error" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-05-23 07:16:05 +00:00
|
|
|
if( redraw )
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2011-11-24 17:32:51 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-02-19 19:53:11 +00:00
|
|
|
TEXTE_MODULE* textmod;
|
|
|
|
wxPoint pos;
|
|
|
|
double angle = 900; // Necessary +- 900 (+- 90 degrees).
|
|
|
|
// Be prudent: because RotateMarkedItems is used to rotate some items
|
|
|
|
// used the same value as RotateMarkedItems
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
switch( transform )
|
|
|
|
{
|
|
|
|
case ID_MODEDIT_MODULE_ROTATE:
|
2012-02-19 19:53:11 +00:00
|
|
|
#define ROTATE( z ) RotatePoint( (&z), angle )
|
|
|
|
RotateMarkedItems( module, wxPoint(0,0), true );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
pos = module->Reference().GetTextPosition();
|
2012-02-19 19:53:11 +00:00
|
|
|
ROTATE( pos );
|
2013-03-18 19:36:07 +00:00
|
|
|
module->Reference().SetTextPosition( pos );
|
|
|
|
module->Reference().SetPos0( module->Reference().GetTextPosition() );
|
2013-03-13 18:53:58 +00:00
|
|
|
module->Reference().m_Orient += angle;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( module->Reference().m_Orient >= 1800 )
|
|
|
|
module->Reference().m_Orient -= 1800;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
pos = module->Value().GetTextPosition();
|
2012-02-19 19:53:11 +00:00
|
|
|
ROTATE( pos );
|
2013-03-18 19:36:07 +00:00
|
|
|
module->Value().SetTextPosition( pos );
|
2013-03-13 18:53:58 +00:00
|
|
|
module->Value().SetPos0( module->Value().m_Pos );
|
|
|
|
module->Value().m_Orient += angle;
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( module->Value().m_Orient >= 1800 )
|
|
|
|
module->Value().m_Orient -= 1800;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_MODULE_MIRROR:
|
2012-02-19 19:53:11 +00:00
|
|
|
// Mirror reference.
|
2013-03-13 18:53:58 +00:00
|
|
|
textmod = &module->Reference();
|
2012-02-19 19:53:11 +00:00
|
|
|
NEGATE( textmod->m_Pos.x );
|
|
|
|
NEGATE( textmod->m_Pos0.x );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( textmod->m_Orient )
|
|
|
|
textmod->m_Orient = 3600 - textmod->m_Orient;
|
|
|
|
|
2012-02-19 19:53:11 +00:00
|
|
|
// Mirror value.
|
2013-03-13 18:53:58 +00:00
|
|
|
textmod = &module->Value();
|
2012-02-19 19:53:11 +00:00
|
|
|
NEGATE( textmod->m_Pos.x );
|
|
|
|
NEGATE( textmod->m_Pos0.x );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( textmod->m_Orient )
|
|
|
|
textmod->m_Orient = 3600 - textmod->m_Orient;
|
|
|
|
|
2012-02-19 19:53:11 +00:00
|
|
|
// Mirror pads and graphic items of the footprint:
|
|
|
|
MirrorMarkedItems( module, wxPoint(0,0), true );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-08-12 10:40:01 +00:00
|
|
|
default:
|
2009-11-18 12:52:19 +00:00
|
|
|
DisplayInfoMessage( this, wxT( "Not available" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
module->CalculateBoundingBox();
|
2010-05-01 12:46:33 +00:00
|
|
|
OnModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::OnVerticalToolbar( wxCommandEvent& aEvent )
|
2011-02-21 13:54:29 +00:00
|
|
|
{
|
|
|
|
int id = aEvent.GetId();
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
case ID_NO_TOOL_SELECTED:
|
|
|
|
break;
|
|
|
|
|
2011-02-21 13:54:29 +00:00
|
|
|
case ID_MODEDIT_LINE_TOOL:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add line" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_ARC_TOOL:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add arc" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_CIRCLE_TOOL:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add circle" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_TEXT_TOOL:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_ANCHOR_TOOL:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Place anchor" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_PLACE_GRID_COORD:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Set grid origin" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_PAD_TOOL:
|
|
|
|
if( GetBoard()->m_Modules )
|
2011-08-26 17:01:17 +00:00
|
|
|
{
|
2011-02-21 13:54:29 +00:00
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add pad" ) );
|
2011-08-26 17:01:17 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
SetToolID( id, wxCURSOR_ARROW, _( "Pad settings" ) );
|
|
|
|
InstallPadOptionsFrame( NULL );
|
2011-12-22 13:28:11 +00:00
|
|
|
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODEDIT_DELETE_TOOL:
|
|
|
|
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxFAIL_MSG( wxT( "Unknown command id." ) );
|
2011-12-22 13:28:11 +00:00
|
|
|
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-11 18:29:56 +00:00
|
|
|
|
2013-05-28 16:54:59 +00:00
|
|
|
|
2013-04-11 18:29:56 +00:00
|
|
|
EDA_COLOR_T FOOTPRINT_EDIT_FRAME::GetGridColor() const
|
|
|
|
{
|
|
|
|
return g_ColorsSettings.GetItemColor( GRID_VISIBLE );
|
|
|
|
}
|
|
|
|
|