2009-11-04 20:46:53 +00:00
|
|
|
/*****************/
|
|
|
|
/* schedit.cpp */
|
|
|
|
/*****************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
2009-04-07 15:54:40 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
#include "eda_doc.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "wxEeschemaStruct.h"
|
|
|
|
#include "class_sch_screen.h"
|
|
|
|
#include "kicad_device_context.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "general.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "eeschema_id.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "protos.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_library.h"
|
2010-12-21 15:13:09 +00:00
|
|
|
#include "sch_bus_entry.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_marker.h"
|
|
|
|
#include "sch_component.h"
|
2011-01-12 21:47:54 +00:00
|
|
|
#include "sch_junction.h"
|
2010-12-21 15:13:09 +00:00
|
|
|
#include "sch_line.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_sheet.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-04-17 16:25:29 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
wxPoint pos;
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
2011-03-25 19:16:05 +00:00
|
|
|
SCH_ITEM* item = screen->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
pos = wxGetMousePosition();
|
|
|
|
|
|
|
|
pos.y += 20;
|
|
|
|
|
|
|
|
// If needed, stop the current command and deselect current tool
|
|
|
|
switch( id )
|
|
|
|
{
|
2011-03-11 14:44:08 +00:00
|
|
|
case wxID_CUT:
|
|
|
|
case wxID_COPY:
|
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
2008-03-10 11:42:41 +00:00
|
|
|
case ID_POPUP_SCH_ENTRY_SELECT_SLASH:
|
|
|
|
case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH:
|
|
|
|
case ID_POPUP_END_LINE:
|
|
|
|
case ID_POPUP_SCH_EDIT_TEXT:
|
|
|
|
case ID_POPUP_SCH_SET_SHAPE_TEXT:
|
|
|
|
case ID_POPUP_SCH_ROTATE_TEXT:
|
|
|
|
case ID_POPUP_SCH_EDIT_SHEET:
|
|
|
|
case ID_POPUP_SCH_CLEANUP_SHEET:
|
|
|
|
case ID_POPUP_SCH_END_SHEET:
|
|
|
|
case ID_POPUP_SCH_RESIZE_SHEET:
|
2009-05-16 05:38:38 +00:00
|
|
|
case ID_POPUP_IMPORT_GLABEL:
|
2011-03-30 19:26:05 +00:00
|
|
|
case ID_POPUP_SCH_EDIT_SHEET_PIN:
|
|
|
|
case ID_POPUP_SCH_MOVE_SHEET_PIN:
|
2008-03-10 11:42:41 +00:00
|
|
|
case ID_POPUP_SCH_DRAG_CMP_REQUEST:
|
2009-08-28 07:11:56 +00:00
|
|
|
case ID_POPUP_SCH_DRAG_WIRE_REQUEST:
|
2008-03-10 11:42:41 +00:00
|
|
|
case ID_POPUP_SCH_EDIT_CMP:
|
|
|
|
case ID_POPUP_SCH_INIT_CMP:
|
|
|
|
case ID_POPUP_SCH_DISPLAYDOC_CMP:
|
|
|
|
case ID_POPUP_SCH_EDIT_VALUE_CMP:
|
|
|
|
case ID_POPUP_SCH_EDIT_REF_CMP:
|
|
|
|
case ID_POPUP_SCH_EDIT_FOOTPRINT_CMP:
|
|
|
|
case ID_POPUP_SCH_EDIT_CONVERT_CMP:
|
|
|
|
case ID_POPUP_SCH_ROTATE_FIELD:
|
|
|
|
case ID_POPUP_SCH_EDIT_FIELD:
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
|
|
|
case ID_POPUP_DRAG_BLOCK:
|
|
|
|
case ID_POPUP_COPY_BLOCK:
|
|
|
|
case ID_POPUP_ROTATE_BLOCK:
|
|
|
|
case ID_POPUP_MIRROR_X_BLOCK:
|
|
|
|
case ID_POPUP_MIRROR_Y_BLOCK:
|
|
|
|
case ID_POPUP_SCH_DELETE_NODE:
|
|
|
|
case ID_POPUP_SCH_DELETE_CONNECTION:
|
|
|
|
case ID_POPUP_SCH_ENTER_SHEET:
|
|
|
|
case ID_POPUP_SCH_LEAVE_SHEET:
|
|
|
|
case ID_POPUP_SCH_ADD_JUNCTION:
|
|
|
|
case ID_POPUP_SCH_ADD_LABEL:
|
2009-07-08 15:42:45 +00:00
|
|
|
case ID_POPUP_SCH_GETINFO_MARKER:
|
2008-03-10 11:42:41 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* At this point: Do nothing. these commands do not need to stop the
|
|
|
|
* current command (mainly a block command) or reset the current state
|
|
|
|
* They will be executed later, in next switch structure.
|
2008-03-10 11:42:41 +00:00
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_POPUP_SCH_DELETE_CMP:
|
2009-11-04 20:46:53 +00:00
|
|
|
case ID_POPUP_SCH_DELETE:
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2009-12-20 19:48:58 +00:00
|
|
|
// Stop the current command (if any) but keep the current tool
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->EndMouseCapture();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
default:
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
// Stop the current command and deselect the current tool
|
2011-02-24 20:22:12 +00:00
|
|
|
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-01-30 22:22:38 +00:00
|
|
|
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
|
2011-05-16 19:32:57 +00:00
|
|
|
item = screen->GetCurItem(); // Can be modified by previous calls.
|
2011-01-30 22:22:38 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
switch( id )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case ID_HIERARCHY:
|
|
|
|
InstallHierarchyFrame( &dc, pos );
|
2011-01-12 21:47:54 +00:00
|
|
|
m_itemToRepeat = NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_CUT:
|
2009-07-25 04:53:39 +00:00
|
|
|
if( screen->m_BlockLocate.m_Command != BLOCK_MOVE )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
HandleBlockEndByPopUp( BLOCK_DELETE, &dc );
|
2011-01-12 21:47:54 +00:00
|
|
|
m_itemToRepeat = NULL;
|
2009-01-06 20:09:32 +00:00
|
|
|
SetSheetNumberAndCount();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_PASTE:
|
2011-02-11 20:48:13 +00:00
|
|
|
HandleBlockBegin( &dc, BLOCK_PASTE, screen->GetCrossHairPosition() );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ENTRY_SELECT_SLASH:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2011-03-25 19:16:05 +00:00
|
|
|
SetBusEntryShape( &dc, (SCH_BUS_ENTRY*) item, '/' );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2011-03-25 19:16:05 +00:00
|
|
|
SetBusEntryShape( &dc, (SCH_BUS_ENTRY*) item, '\\' );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
2011-03-11 14:44:08 +00:00
|
|
|
if( DrawPanel->IsMouseCaptured() )
|
|
|
|
{
|
|
|
|
DrawPanel->EndMouseCapture();
|
|
|
|
SetToolID( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_END_LINE:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
EndSegment( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_EDIT_TEXT:
|
2011-03-25 19:16:05 +00:00
|
|
|
EditSchematicText( (SCH_TEXT*) item );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ROTATE_TEXT:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2011-03-25 19:16:05 +00:00
|
|
|
ChangeTextOrient( (SCH_TEXT*) item, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_SET_SHAPE_TEXT:
|
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
// Not used
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ROTATE_FIELD:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2011-03-29 15:21:35 +00:00
|
|
|
RotateField( (SCH_FIELD*) item, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_EDIT_FIELD:
|
2011-03-25 19:16:05 +00:00
|
|
|
EditComponentFieldText( (SCH_FIELD*) item, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_DELETE_NODE:
|
|
|
|
case ID_POPUP_SCH_DELETE_CONNECTION:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2011-04-15 12:40:56 +00:00
|
|
|
DeleteConnection( id == ID_POPUP_SCH_DELETE_CONNECTION );
|
2008-04-17 16:25:29 +00:00
|
|
|
screen->SetCurItem( NULL );
|
2011-01-12 21:47:54 +00:00
|
|
|
m_itemToRepeat = NULL;
|
2011-01-21 19:30:59 +00:00
|
|
|
screen->TestDanglingEnds( DrawPanel, &dc );
|
2009-07-25 07:31:07 +00:00
|
|
|
DrawPanel->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_BREAK_WIRE:
|
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2009-08-27 05:53:24 +00:00
|
|
|
SCH_ITEM* oldWiresList = screen->ExtractWires( true );
|
2011-02-11 20:48:13 +00:00
|
|
|
screen->BreakSegment( screen->GetCrossHairPosition() );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-08-27 05:53:24 +00:00
|
|
|
if( oldWiresList )
|
|
|
|
SaveCopyInUndoList( oldWiresList, UR_WIRE_IMAGE );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
screen->TestDanglingEnds( DrawPanel, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2010-09-05 17:01:48 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_SCH_DELETE_CMP:
|
|
|
|
case ID_POPUP_SCH_DELETE:
|
2010-09-05 17:01:48 +00:00
|
|
|
if( item == NULL )
|
|
|
|
break;
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2011-03-10 19:36:30 +00:00
|
|
|
DeleteItem( item );
|
2010-09-05 17:01:48 +00:00
|
|
|
screen->SetCurItem( NULL );
|
2011-01-12 21:47:54 +00:00
|
|
|
m_itemToRepeat = NULL;
|
2011-01-21 19:30:59 +00:00
|
|
|
screen->TestDanglingEnds( DrawPanel, &dc );
|
2010-09-05 17:01:48 +00:00
|
|
|
SetSheetNumberAndCount();
|
|
|
|
OnModify();
|
2011-03-25 19:16:05 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_SCH_END_SHEET:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2011-03-25 19:16:05 +00:00
|
|
|
item->Place( this, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_RESIZE_SHEET:
|
2011-03-25 19:16:05 +00:00
|
|
|
ReSizeSheet( (SCH_SHEET*) item, &dc );
|
2011-01-21 19:30:59 +00:00
|
|
|
screen->TestDanglingEnds( DrawPanel, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_EDIT_SHEET:
|
2011-03-25 19:16:05 +00:00
|
|
|
if( EditSheet( (SCH_SHEET*) item, &dc ) )
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2009-05-16 05:38:38 +00:00
|
|
|
case ID_POPUP_IMPORT_GLABEL:
|
2011-03-25 19:16:05 +00:00
|
|
|
if( item != NULL && item->Type() == SCH_SHEET_T )
|
2011-03-30 19:26:05 +00:00
|
|
|
screen->SetCurItem( ImportSheetPin( (SCH_SHEET*) item, &dc ) );
|
2009-05-16 05:38:38 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_SCH_CLEANUP_SHEET:
|
2011-03-25 19:16:05 +00:00
|
|
|
if( item != NULL && item->Type() == SCH_SHEET_T )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
2011-03-25 19:16:05 +00:00
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
2010-06-24 18:31:43 +00:00
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
if( !sheet->HasUndefinedPins() )
|
2010-06-24 18:31:43 +00:00
|
|
|
{
|
|
|
|
DisplayInfoMessage( this,
|
2010-12-08 20:12:46 +00:00
|
|
|
_( "There are no undefined labels in this sheet to clean up." ) );
|
2010-06-24 18:31:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-11 16:33:43 +00:00
|
|
|
if( !IsOK( this, _( "Do you wish to cleanup this sheet?" ) ) )
|
2010-06-24 18:31:43 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Save sheet in undo list before cleaning up unreferenced hierarchical labels. */
|
|
|
|
SaveCopyInUndoList( sheet, UR_CHANGED );
|
|
|
|
sheet->CleanupSheet();
|
|
|
|
OnModify();
|
2011-01-30 22:22:38 +00:00
|
|
|
DrawPanel->RefreshDrawingRect( sheet->GetBoundingBox() );
|
2010-06-24 18:31:43 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
case ID_POPUP_SCH_EDIT_SHEET_PIN:
|
|
|
|
EditSheetPin( (SCH_SHEET_PIN*) item, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
case ID_POPUP_SCH_MOVE_SHEET_PIN:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2011-03-30 19:26:05 +00:00
|
|
|
MoveSheetPin( (SCH_SHEET_PIN*) item, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2007-09-22 14:31:20 +00:00
|
|
|
case ID_POPUP_SCH_DRAG_CMP_REQUEST:
|
2011-03-25 19:16:05 +00:00
|
|
|
case ID_POPUP_SCH_DRAG_WIRE_REQUEST:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-04-19 12:08:12 +00:00
|
|
|
// The easiest way to handle a drag component or sheet command
|
|
|
|
// is to simulate a block drag command
|
|
|
|
if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
2011-04-19 12:08:12 +00:00
|
|
|
if( !HandleBlockBegin( &dc, BLOCK_DRAG, screen->GetCrossHairPosition() ) )
|
|
|
|
break;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2011-04-19 12:08:12 +00:00
|
|
|
// Give a non null size to the search block:
|
|
|
|
screen->m_BlockLocate.Inflate( 1 );
|
|
|
|
HandleBlockEnd( &dc );
|
2008-02-26 01:07:38 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-28 07:11:56 +00:00
|
|
|
break;
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
case ID_POPUP_SCH_EDIT_CMP:
|
2008-02-26 01:07:38 +00:00
|
|
|
// Ensure the struct is a component (could be a struct of a
|
|
|
|
// component, like Field, text..)
|
2011-03-25 19:16:05 +00:00
|
|
|
if( item && item->Type() == SCH_COMPONENT_T )
|
|
|
|
InstallCmpeditFrame( this, (SCH_COMPONENT*) item );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_INIT_CMP:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_EDIT_VALUE_CMP:
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
// Ensure the struct is a component (could be a struct of a
|
|
|
|
// component, like Field, text..)
|
2011-03-25 19:16:05 +00:00
|
|
|
if( item != NULL && item->Type() == SCH_COMPONENT_T )
|
2011-03-29 15:21:35 +00:00
|
|
|
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( VALUE ), &dc );
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_EDIT_REF_CMP:
|
2008-03-10 11:42:41 +00:00
|
|
|
|
2011-03-29 15:21:35 +00:00
|
|
|
// Ensure the struct is a component (could be a struct of a component, like Field, text..)
|
2011-03-25 19:16:05 +00:00
|
|
|
if( item != NULL && item->Type() == SCH_COMPONENT_T )
|
2011-03-29 15:21:35 +00:00
|
|
|
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( REFERENCE ), &dc );
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
break;
|
2007-12-11 16:41:43 +00:00
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
case ID_POPUP_SCH_EDIT_FOOTPRINT_CMP:
|
2008-03-10 11:42:41 +00:00
|
|
|
|
2011-03-29 15:21:35 +00:00
|
|
|
// Ensure the struct is a component (could be a struct of a component, like Field, text..)
|
2011-03-25 19:16:05 +00:00
|
|
|
if( item && item->Type() == SCH_COMPONENT_T )
|
2011-03-29 15:21:35 +00:00
|
|
|
EditComponentFieldText( ( (SCH_COMPONENT*) item )->GetField( FOOTPRINT ), &dc );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
case ID_POPUP_SCH_EDIT_CONVERT_CMP:
|
2008-03-10 11:42:41 +00:00
|
|
|
|
2011-03-29 15:21:35 +00:00
|
|
|
// Ensure the struct is a component (could be a struct of a component, like Field, text..)
|
2011-03-25 19:16:05 +00:00
|
|
|
if( item && item->Type() == SCH_COMPONENT_T )
|
|
|
|
{
|
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
|
|
|
ConvertPart( (SCH_COMPONENT*) item, &dc );
|
|
|
|
}
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_DISPLAYDOC_CMP:
|
2008-03-10 11:42:41 +00:00
|
|
|
|
2011-03-29 15:21:35 +00:00
|
|
|
// Ensure the struct is a component (could be a piece of a component, like Field, text..)
|
2011-03-25 19:16:05 +00:00
|
|
|
if( item && item->Type() == SCH_COMPONENT_T )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-10-25 15:43:42 +00:00
|
|
|
LIB_ALIAS* LibEntry;
|
2011-03-25 19:16:05 +00:00
|
|
|
LibEntry = CMP_LIBRARY::FindLibraryEntry( ( (SCH_COMPONENT*) item )->GetLibName() );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
if( LibEntry && LibEntry->GetDocFileName() != wxEmptyString )
|
2009-04-07 11:53:58 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
GetAssociatedDocument( this, LibEntry->GetDocFileName(),
|
2010-10-25 15:43:42 +00:00
|
|
|
&wxGetApp().GetLibraryPathList() );
|
2009-04-07 11:53:58 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ENTER_SHEET:
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-02-05 02:21:11 +00:00
|
|
|
if( item && (item->Type() == SCH_SHEET_T) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-05 02:21:11 +00:00
|
|
|
m_CurrentSheet->Push( (SCH_SHEET*) item );
|
|
|
|
DisplayCurrentSheet();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-03-25 19:16:05 +00:00
|
|
|
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_SCH_LEAVE_SHEET:
|
2011-02-05 02:21:11 +00:00
|
|
|
m_CurrentSheet->Pop();
|
|
|
|
DisplayCurrentSheet();
|
2007-08-20 01:20:48 +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 );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_COPY: // really this is a Save block for paste
|
|
|
|
HandleBlockEndByPopUp( BLOCK_SAVE, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
2011-03-03 01:58:12 +00:00
|
|
|
DrawPanel->m_AutoPAN_Request = false;
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
|
|
|
HandleBlockEndByPopUp( BLOCK_ZOOM, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
HandleBlockEndByPopUp( BLOCK_DELETE, &dc );
|
2009-01-06 20:09:32 +00:00
|
|
|
SetSheetNumberAndCount();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ROTATE_BLOCK:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
HandleBlockEndByPopUp( BLOCK_ROTATE, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_MIRROR_X_BLOCK:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2010-09-05 17:01:48 +00:00
|
|
|
HandleBlockEndByPopUp( BLOCK_MIRROR_X, &dc );
|
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_POPUP_MIRROR_Y_BLOCK:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
HandleBlockEndByPopUp( BLOCK_MIRROR_Y, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_COPY_BLOCK:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
HandleBlockEndByPopUp( BLOCK_COPY, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_DRAG_BLOCK:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
HandleBlockEndByPopUp( BLOCK_DRAG, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ADD_JUNCTION:
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
|
|
|
screen->SetCurItem( AddJunction( &dc, screen->GetCrossHairPosition(), true ) );
|
2011-01-21 19:30:59 +00:00
|
|
|
screen->TestDanglingEnds( DrawPanel, &dc );
|
2008-04-17 16:25:29 +00:00
|
|
|
screen->SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ADD_LABEL:
|
|
|
|
case ID_POPUP_SCH_ADD_GLABEL:
|
2010-12-08 20:12:46 +00:00
|
|
|
screen->SetCurItem( CreateNewText( &dc, id == ID_POPUP_SCH_ADD_LABEL ?
|
|
|
|
LAYER_LOCLABEL : LAYER_GLOBLABEL ) );
|
2011-03-25 19:16:05 +00:00
|
|
|
item = screen->GetCurItem();
|
|
|
|
|
|
|
|
if( item )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-03-25 19:16:05 +00:00
|
|
|
item->Place( this, &dc );
|
2011-01-21 19:30:59 +00:00
|
|
|
screen->TestDanglingEnds( DrawPanel, &dc );
|
2008-04-17 16:25:29 +00:00
|
|
|
screen->SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-03-25 19:16:05 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
case ID_POPUP_SCH_GETINFO_MARKER:
|
2011-03-25 19:16:05 +00:00
|
|
|
if( item && item->Type() == SCH_MARKER_T )
|
|
|
|
( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
default: // Log error:
|
2010-12-08 20:12:46 +00:00
|
|
|
DisplayError( this, wxT( "SCH_EDIT_FRAME::Process_Special_Functions error" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
// End switch ( id ) (Command execution)
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-24 20:22:12 +00:00
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
2011-01-12 21:47:54 +00:00
|
|
|
m_itemToRepeat = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-19 12:08:12 +00:00
|
|
|
void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-04-19 12:08:12 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
SCH_ITEM* item = screen->GetCurItem();
|
|
|
|
|
|
|
|
if( item == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2011-04-19 12:08:12 +00:00
|
|
|
INSTALL_UNBUFFERED_DC( dc, DrawPanel );
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-04-19 12:08:12 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_JUNCTION_T:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_BUS_ENTRY_T:
|
2011-04-19 12:08:12 +00:00
|
|
|
StartMoveBusEntry( (SCH_BUS_ENTRY*) item, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIERARCHICAL_LABEL_T:
|
|
|
|
case SCH_TEXT_T:
|
2011-04-19 12:08:12 +00:00
|
|
|
MoveText( (SCH_TEXT*) item, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_COMPONENT_T:
|
2011-04-19 12:08:12 +00:00
|
|
|
StartMovePart( (SCH_COMPONENT*) item, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_LINE_T:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_SHEET_T:
|
2011-04-19 12:08:12 +00:00
|
|
|
StartMoveSheet( (SCH_SHEET*) item, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_NO_CONNECT_T:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_FIELD_T:
|
2011-04-19 12:08:12 +00:00
|
|
|
MoveField( (SCH_FIELD*) item, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_MARKER_T:
|
2011-03-30 19:26:05 +00:00
|
|
|
case SCH_SHEET_PIN_T:
|
2007-08-20 01:20:48 +00:00
|
|
|
default:
|
2011-04-19 12:08:12 +00:00
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "Cannot move item type %s" ),
|
|
|
|
GetChars( item->GetClass() ) ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-04-19 12:08:12 +00:00
|
|
|
|
|
|
|
if( GetToolId() == ID_NO_TOOL_SELECTED )
|
|
|
|
m_itemToRepeat = NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2011-02-05 19:22:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::OnCancelCurrentCommand( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
|
|
|
|
if( screen->IsBlockActive() )
|
|
|
|
{
|
2011-02-08 14:48:38 +00:00
|
|
|
DrawPanel->SetCursor( wxCursor( DrawPanel->GetDefaultCursor() ) );
|
2011-02-05 19:22:58 +00:00
|
|
|
screen->ClearBlockCommand();
|
|
|
|
|
|
|
|
// Stop the current command (if any) but keep the current tool
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->EndMouseCapture();
|
2011-02-05 19:22:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-05 10:35:18 +00:00
|
|
|
if( DrawPanel->IsMouseCaptured() ) // Stop the current command but keep the current tool
|
|
|
|
DrawPanel->EndMouseCapture();
|
|
|
|
else // Deselect current tool
|
|
|
|
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
|
|
|
|
}
|
2011-02-05 19:22:58 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
int id = aEvent.GetId();
|
|
|
|
|
|
|
|
// Stop the current command and deselect the current tool.
|
2011-02-24 20:22:12 +00:00
|
|
|
DrawPanel->EndMouseCapture( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor() );
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
2011-02-24 20:22:12 +00:00
|
|
|
case ID_NO_TOOL_SELECTED:
|
2011-02-21 13:54:29 +00:00
|
|
|
SetToolID( id, DrawPanel->GetDefaultCursor(), _( "No tool selected" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_HIERARCHY_PUSH_POP_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_HAND, _( "Descend or ascend hierarchy" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_NOCONN_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add no connect" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_WIRE_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add wire" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_BUS_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add bus" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LINE_COMMENT_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add lines" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_JUNCTION_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add junction" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LABEL_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add label" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_GLABEL_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add global label" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_HIERLABEL_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add hierarchical label" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_TEXT_COMMENT_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_WIRETOBUS_ENTRY_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add wire to bus entry" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_BUSTOBUS_ENTRY_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add bus to bus entry" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_SHEET_SYMBOL_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet" ) );
|
|
|
|
break;
|
|
|
|
|
2011-03-30 19:26:05 +00:00
|
|
|
case ID_SHEET_PIN_BUTT:
|
2011-02-21 13:54:29 +00:00
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add sheet pins" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_IMPORT_HLABEL_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Import sheet pins" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_SCH_PLACE_COMPONENT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add component" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PLACE_POWER_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add power" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
m_itemToRepeat = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( aEvent.GetEventObject() == m_VToolBar )
|
2011-02-24 20:22:12 +00:00
|
|
|
aEvent.Check( GetToolId() == aEvent.GetId() );
|
2011-02-21 13:54:29 +00:00
|
|
|
}
|
2011-04-15 12:40:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection )
|
|
|
|
{
|
|
|
|
PICKED_ITEMS_LIST pickList;
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
wxPoint pos = screen->GetCrossHairPosition();
|
|
|
|
|
|
|
|
if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
|
|
|
|
{
|
|
|
|
DeleteItemsInList( DrawPanel, pickList );
|
|
|
|
OnModify();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_EDIT_FRAME::DeleteItemAtCrossHair( wxDC* DC )
|
|
|
|
{
|
|
|
|
SCH_ITEM* item;
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
|
|
|
|
item = LocateItem( screen->GetCrossHairPosition(), SCH_COLLECTOR::ParentItems );
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
{
|
|
|
|
bool itemHasConnections = item->IsConnectable();
|
|
|
|
|
|
|
|
screen->SetCurItem( NULL );
|
|
|
|
SetRepeatItem( NULL );
|
|
|
|
DeleteItem( item );
|
|
|
|
|
|
|
|
if( itemHasConnections )
|
|
|
|
screen->TestDanglingEnds( DrawPanel, DC );
|
|
|
|
|
|
|
|
OnModify();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|