2007-08-20 01:20:48 +00:00
|
|
|
/******************************************************/
|
|
|
|
/* schedit.cpp: fonctions generales de la schematique */
|
|
|
|
/******************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
|
|
|
|
#include "id.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
2008-02-27 19:38:16 +00:00
|
|
|
#include "schframe.h"
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-02-27 19:38:16 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* Traite les selections d'outils et les commandes appelees du menu POPUP
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
wxPoint pos;
|
|
|
|
wxClientDC dc( DrawPanel );
|
|
|
|
|
|
|
|
DrawPanel->PrepareGraphicContext( &dc );
|
|
|
|
|
|
|
|
pos = wxGetMousePosition();
|
|
|
|
|
|
|
|
pos.y += 20;
|
|
|
|
|
|
|
|
// If needed, stop the current command and deselect current tool
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
2008-02-26 01:07:38 +00:00
|
|
|
if( GetScreen()->BlockLocate.m_Command != BLOCK_IDLE )
|
|
|
|
DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor =
|
|
|
|
DrawPanel->
|
|
|
|
m_PanelDefaultCursor ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
|
|
|
{
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
|
|
|
|
}
|
|
|
|
/* ne devrait pas etre execute, sauf bug: */
|
2008-02-26 01:07:38 +00:00
|
|
|
if( GetScreen()->BlockLocate.m_Command != BLOCK_IDLE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE;
|
|
|
|
GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK;
|
|
|
|
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_DELETE_CMP:
|
|
|
|
case ID_POPUP_SCH_DELETE: // Stop the, current command, keep the current tool
|
|
|
|
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
|
|
|
{
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: // Stop the current command, and deselect the current tool
|
|
|
|
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
|
|
|
{
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
|
|
|
|
}
|
2008-02-26 01:07:38 +00:00
|
|
|
DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor =
|
|
|
|
wxCURSOR_ARROW;
|
2007-08-20 01:20:48 +00:00
|
|
|
SetToolID( 0, DrawPanel->m_PanelCursor, wxEmptyString );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
// End switch commande en cours
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
switch( id ) // Command execution:
|
|
|
|
{
|
|
|
|
case ID_HIERARCHY:
|
|
|
|
InstallHierarchyFrame( &dc, pos );
|
|
|
|
g_ItemToRepeat = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_CUT:
|
2008-02-26 01:07:38 +00:00
|
|
|
if( GetScreen()->BlockLocate.m_Command != BLOCK_MOVE )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
HandleBlockEndByPopUp( BLOCK_DELETE, &dc );
|
|
|
|
g_ItemToRepeat = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_PASTE:
|
2008-02-26 01:07:38 +00:00
|
|
|
HandleBlockBegin( &dc, BLOCK_PASTE, GetScreen()->m_Curseur );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_HIERARCHY_PUSH_POP_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_HAND, _( "Push/Pop Hierarchy" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_NOCONN_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add NoConnect Flag" ) );
|
|
|
|
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 Drawing" ) );
|
|
|
|
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;
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
case ID_HIERLABEL_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add Hierarchal label" ) );
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
case ID_SHEET_LABEL_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add PinSheet" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_IMPORT_GLABEL_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Import PinSheet" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_COMPONENT_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add Component" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PLACE_POWER_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_PENCIL, _( "Add Power" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ENTRY_SELECT_SLASH:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
SetBusEntryShape( &dc,
|
2008-02-26 01:07:38 +00:00
|
|
|
(DrawBusEntryStruct*) GetScreen()->GetCurItem(), '/' );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
SetBusEntryShape( &dc,
|
2008-02-26 01:07:38 +00:00
|
|
|
(DrawBusEntryStruct*) GetScreen()->GetCurItem(), '\\' );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_NO_SELECT_BUTT:
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_CANCEL_CURRENT_COMMAND:
|
|
|
|
if( m_ID_current_state == 0 )
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_END_LINE:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
EndSegment( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_EDIT_TEXT:
|
2008-02-26 01:07:38 +00:00
|
|
|
EditSchematicText( (DrawTextStruct*) GetScreen()->GetCurItem(), &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ROTATE_TEXT:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2008-02-26 01:07:38 +00:00
|
|
|
ChangeTextOrient( (DrawTextStruct*) GetScreen()->GetCurItem(), &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2008-02-26 01:07:38 +00:00
|
|
|
ConvertTextType( (DrawTextStruct*) GetScreen()->GetCurItem(),
|
|
|
|
&dc, DRAW_LABEL_STRUCT_TYPE );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_GLABEL:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2008-02-26 01:07:38 +00:00
|
|
|
ConvertTextType( (DrawTextStruct*) GetScreen()->GetCurItem(),
|
|
|
|
&dc, DRAW_GLOBAL_LABEL_STRUCT_TYPE );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-02-21 12:21:01 +00:00
|
|
|
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2008-02-26 01:07:38 +00:00
|
|
|
ConvertTextType( (DrawTextStruct*) GetScreen()->GetCurItem(),
|
|
|
|
&dc, DRAW_HIER_LABEL_STRUCT_TYPE );
|
2008-02-21 12:21:01 +00:00
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_COMMENT:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2008-02-26 01:07:38 +00:00
|
|
|
ConvertTextType( (DrawTextStruct*) GetScreen()->GetCurItem(),
|
|
|
|
&dc, DRAW_TEXT_STRUCT_TYPE );
|
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:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2008-02-26 01:07:38 +00:00
|
|
|
RotateCmpField( (PartTextStruct*) GetScreen()->GetCurItem(), &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_EDIT_FIELD:
|
2008-02-26 01:07:38 +00:00
|
|
|
EditCmpFieldText( (PartTextStruct*) GetScreen()->GetCurItem(), &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_DELETE_NODE:
|
|
|
|
case ID_POPUP_SCH_DELETE_CONNECTION:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2008-02-26 01:07:38 +00:00
|
|
|
DeleteConnection( &dc,
|
|
|
|
id == ID_POPUP_SCH_DELETE_CONNECTION ? TRUE : FALSE );
|
2008-02-12 21:12:46 +00:00
|
|
|
GetScreen()->SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
g_ItemToRepeat = NULL;
|
2008-02-26 01:07:38 +00:00
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_BREAK_WIRE:
|
|
|
|
{
|
|
|
|
DrawPickedStruct* ListForUndo;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2008-02-26 01:07:38 +00:00
|
|
|
ListForUndo = BreakSegment( (SCH_SCREEN*) GetScreen(),
|
|
|
|
GetScreen()->m_Curseur, TRUE );
|
2007-08-20 01:20:48 +00:00
|
|
|
if( ListForUndo )
|
|
|
|
SaveCopyInUndoList( ListForUndo, IS_NEW | IS_CHANGED );
|
2008-02-26 01:07:38 +00:00
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_DELETE_CMP:
|
2008-02-26 01:07:38 +00:00
|
|
|
if( GetScreen()->GetCurItem() == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
// Ensure the struct is a component (could be a struct of a
|
|
|
|
// component, like Field, text..)
|
|
|
|
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
|
|
|
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
|
|
|
|
GetScreen() ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case ID_POPUP_SCH_DELETE:
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem() == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2008-02-26 01:07:38 +00:00
|
|
|
DeleteStruct( this->DrawPanel, &dc, GetScreen()->GetCurItem() );
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
g_ItemToRepeat = NULL;
|
2008-02-26 01:07:38 +00:00
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, &dc );
|
|
|
|
GetScreen()->SetModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
|
|
|
|
SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_END_SHEET:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->GetCurItem()->Place( this, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_RESIZE_SHEET:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
ReSizeSheet( (DrawSheetStruct*)
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->GetCurItem(), &dc );
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_EDIT_SHEET:
|
|
|
|
EditSheet( (DrawSheetStruct*)
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->GetCurItem(), &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_CLEANUP_SHEET:
|
|
|
|
( (DrawSheetStruct*)
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->GetCurItem() )->CleanupSheet( this, &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_EDIT_PINSHEET:
|
|
|
|
Edit_PinSheet( (DrawSheetLabelStruct*)
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->GetCurItem(), &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_MOVE_PINSHEET:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
StartMove_PinSheet( (DrawSheetLabelStruct*)
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->GetCurItem(), &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:
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_POPUP_SCH_MOVE_CMP_REQUEST:
|
2008-02-26 01:07:38 +00:00
|
|
|
|
|
|
|
// Ensure the struct is a component (could be a struct of a
|
|
|
|
// component, like Field, text..)
|
|
|
|
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
|
|
|
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
|
|
|
|
GetScreen() ) );
|
|
|
|
if( GetScreen()->GetCurItem() == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case ID_POPUP_SCH_MOVE_ITEM_REQUEST:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2008-02-26 01:07:38 +00:00
|
|
|
if( id == ID_POPUP_SCH_DRAG_CMP_REQUEST )
|
|
|
|
{
|
|
|
|
// The easiest way to handle a drag component is simulate a
|
|
|
|
// block drag command
|
|
|
|
if( GetScreen()->BlockLocate.m_State == STATE_NO_BLOCK )
|
2007-09-22 14:31:20 +00:00
|
|
|
{
|
2008-02-26 01:07:38 +00:00
|
|
|
if( !HandleBlockBegin( &dc, BLOCK_DRAG,
|
|
|
|
GetScreen()->m_Curseur ) )
|
|
|
|
break;
|
2007-09-22 14:31:20 +00:00
|
|
|
HandleBlockEnd( &dc );
|
2008-02-26 01:07:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Process_Move_Item( GetScreen()->GetCurItem(), &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
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..)
|
|
|
|
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
|
|
|
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
|
|
|
|
GetScreen() ) );
|
|
|
|
if( GetScreen()->GetCurItem() == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
InstallCmpeditFrame( this, pos,
|
2008-02-26 01:07:38 +00:00
|
|
|
(EDA_SchComponentStruct*) GetScreen()->GetCurItem() );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_MIROR_X_CMP:
|
|
|
|
case ID_POPUP_SCH_MIROR_Y_CMP:
|
|
|
|
case ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE:
|
|
|
|
case ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE:
|
|
|
|
case ID_POPUP_SCH_ORIENT_NORMAL_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..)
|
|
|
|
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
|
|
|
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
|
|
|
|
GetScreen() ) );
|
|
|
|
if( GetScreen()->GetCurItem() == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
{
|
|
|
|
int option;
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_POPUP_SCH_MIROR_X_CMP:
|
|
|
|
option = CMP_MIROIR_X; break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_MIROR_Y_CMP:
|
|
|
|
option = CMP_MIROIR_Y; break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE:
|
|
|
|
option = CMP_ROTATE_COUNTERCLOCKWISE; break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE:
|
|
|
|
option = CMP_ROTATE_CLOCKWISE; break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
case ID_POPUP_SCH_ORIENT_NORMAL_CMP:
|
|
|
|
option = CMP_NORMAL; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem()->m_Flags == 0 )
|
|
|
|
SaveCopyInUndoList( GetScreen()->GetCurItem(), IS_CHANGED );
|
2007-08-20 01:20:48 +00:00
|
|
|
CmpRotationMiroir(
|
2008-02-12 21:12:46 +00:00
|
|
|
(EDA_SchComponentStruct*) GetScreen()->GetCurItem(),
|
2007-08-20 01:20:48 +00:00
|
|
|
&dc, option );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_INIT_CMP:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
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..)
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
|
|
|
|
GetScreen() ) );
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem() == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
EditComponentValue(
|
2008-02-12 21:12:46 +00:00
|
|
|
(EDA_SchComponentStruct*) GetScreen()->GetCurItem(), &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_EDIT_REF_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..)
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
|
|
|
|
GetScreen() ) );
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem() == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
EditComponentReference(
|
2008-02-12 21:12:46 +00:00
|
|
|
(EDA_SchComponentStruct*) GetScreen()->GetCurItem(), &dc );
|
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:
|
|
|
|
// Ensure the struct is a component (could be a struct of a
|
|
|
|
// component, like Field, text..)
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
|
|
|
|
GetScreen() ) );
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem() == NULL )
|
2007-12-11 16:41:43 +00:00
|
|
|
break;
|
|
|
|
EditComponentFootprint(
|
2008-02-12 21:12:46 +00:00
|
|
|
(EDA_SchComponentStruct*) GetScreen()->GetCurItem(), &dc );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
2008-02-26 01:07:38 +00:00
|
|
|
case ID_POPUP_SCH_EDIT_CONVERT_CMP:
|
|
|
|
// Ensure the struct is a component (could be a struct of a
|
|
|
|
// component, like Field, text..)
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
|
|
|
|
GetScreen() ) );
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem() == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
ConvertPart(
|
2008-02-12 21:12:46 +00:00
|
|
|
(EDA_SchComponentStruct*) GetScreen()->GetCurItem(),
|
2007-08-20 01:20:48 +00:00
|
|
|
&dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_COPY_COMPONENT_CMP:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
{
|
|
|
|
EDA_SchComponentStruct* olditem, * newitem;
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
|
|
|
|
GetScreen() ) );
|
2008-02-12 21:12:46 +00:00
|
|
|
olditem = (EDA_SchComponentStruct*) GetScreen()->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
if( olditem == NULL )
|
|
|
|
break;
|
|
|
|
newitem = olditem->GenCopy();
|
2008-02-26 01:07:38 +00:00
|
|
|
newitem->m_TimeStamp = GetTimeStamp();
|
2007-08-20 01:20:48 +00:00
|
|
|
newitem->ClearAnnotation();
|
|
|
|
newitem->m_Flags = IS_NEW;
|
|
|
|
StartMovePart( newitem, &dc );
|
2008-02-26 01:07:38 +00:00
|
|
|
/* Redraw the original part, because StartMovePart() has erase
|
|
|
|
* it from screen */
|
2007-08-20 01:20:48 +00:00
|
|
|
RedrawOneStruct( DrawPanel, &dc, olditem, GR_DEFAULT_DRAWMODE );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT1:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT2:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT3:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT4:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT5:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT6:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT7:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT8:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT9:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT10:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT11:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT12:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT13:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT14:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT15:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT16:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT17:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT18:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT19:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT20:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT21:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT22:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT23:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT24:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT25:
|
|
|
|
case ID_POPUP_SCH_SELECT_UNIT26:
|
2008-02-26 01:07:38 +00:00
|
|
|
// Ensure the struct is a component (could be a struct of a
|
|
|
|
// component, like Field, text..)
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
|
|
|
|
GetScreen() ) );
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem() == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
SelPartUnit(
|
2008-02-12 21:12:46 +00:00
|
|
|
(EDA_SchComponentStruct*) GetScreen()->GetCurItem(),
|
2007-08-20 01:20:48 +00:00
|
|
|
id + 1 - ID_POPUP_SCH_SELECT_UNIT1,
|
|
|
|
&dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_DISPLAYDOC_CMP:
|
2008-02-26 01:07:38 +00:00
|
|
|
// Ensure the struct is a component (could be a piece of a
|
|
|
|
// component, like Field, text..)
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
|
|
|
|
GetScreen() ) );
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem() == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
{
|
|
|
|
EDA_LibComponentStruct* LibEntry;
|
2008-02-26 01:07:38 +00:00
|
|
|
LibEntry = FindLibPart(
|
|
|
|
( (EDA_SchComponentStruct*) GetScreen()->GetCurItem() )->m_ChipName,
|
|
|
|
wxEmptyString,
|
|
|
|
FIND_ALIAS );
|
2007-08-20 01:20:48 +00:00
|
|
|
if( LibEntry && LibEntry->m_DocFile != wxEmptyString )
|
2008-02-26 01:07:38 +00:00
|
|
|
GetAssociatedDocument( this,
|
|
|
|
g_RealLibDirBuffer,
|
|
|
|
LibEntry->m_DocFile );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ENTER_SHEET:
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem();
|
2007-09-01 12:00:30 +00:00
|
|
|
if( DrawStruct && (DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
InstallNextScreen( (DrawSheetStruct*) DrawStruct );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_LEAVE_SHEET:
|
2008-02-12 21:12:46 +00:00
|
|
|
InstallPreviousSheet();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_CLOSE_CURRENT_TOOL:
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case wxID_COPY: // really this is a Save block for paste
|
|
|
|
HandleBlockEndByPopUp( BLOCK_SAVE, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_PLACE_BLOCK:
|
|
|
|
DrawPanel->m_AutoPAN_Request = FALSE;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
HandleBlockPlace( &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ZOOM_BLOCK:
|
|
|
|
HandleBlockEndByPopUp( BLOCK_ZOOM, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_DELETE_BLOCK:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
HandleBlockEndByPopUp( BLOCK_DELETE, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_ROTATE_BLOCK:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
HandleBlockEndByPopUp( BLOCK_ROTATE, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_MIRROR_X_BLOCK:
|
|
|
|
case ID_POPUP_MIRROR_Y_BLOCK:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
HandleBlockEndByPopUp( BLOCK_MIRROR_Y, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_COPY_BLOCK:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
HandleBlockEndByPopUp( BLOCK_COPY, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_DRAG_BLOCK:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
HandleBlockEndByPopUp( BLOCK_DRAG, &dc );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ADD_JUNCTION:
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2008-02-12 21:12:46 +00:00
|
|
|
GetScreen()->SetCurItem(
|
|
|
|
CreateNewJunctionStruct( &dc, GetScreen()->m_Curseur, TRUE ) );
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, &dc );
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_POPUP_SCH_ADD_LABEL:
|
|
|
|
case ID_POPUP_SCH_ADD_GLABEL:
|
2008-02-26 01:07:38 +00:00
|
|
|
GetScreen()->SetCurItem(
|
|
|
|
CreateNewText( &dc,
|
|
|
|
id == ID_POPUP_SCH_ADD_LABEL ?
|
|
|
|
LAYER_LOCLABEL : LAYER_GLOBLABEL ) );
|
2008-02-12 21:12:46 +00:00
|
|
|
if( GetScreen()->GetCurItem() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
GetScreen()->GetCurItem()->Place( this, &dc );
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, &dc );
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_SCHEMATIC_UNDO:
|
2008-02-26 01:07:38 +00:00
|
|
|
if( GetSchematicFromUndoList() )
|
|
|
|
DrawPanel->Refresh( TRUE );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_SCHEMATIC_REDO:
|
2008-02-26 01:07:38 +00:00
|
|
|
if( GetSchematicFromRedoList() )
|
|
|
|
DrawPanel->Refresh( TRUE );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: // Log error:
|
2008-02-26 01:07:38 +00:00
|
|
|
DisplayError( this,
|
|
|
|
wxT( "WinEDA_SchematicFrame::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
|
|
|
|
|
|
|
if( m_ID_current_state == 0 )
|
|
|
|
g_ItemToRepeat = NULL;
|
|
|
|
SetToolbars();
|
|
|
|
|
|
|
|
dc.SetBrush( wxNullBrush );
|
|
|
|
dc.SetPen( wxNullPen );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_SchematicFrame::Process_Move_Item( EDA_BaseStruct* DrawStruct,
|
|
|
|
wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DrawStruct == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( DrawStruct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case DRAW_JUNCTION_STRUCT_TYPE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_BUSENTRY_STRUCT_TYPE:
|
|
|
|
StartMoveBusEntry( (DrawBusEntryStruct*) DrawStruct, DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_LABEL_STRUCT_TYPE:
|
|
|
|
case DRAW_GLOBAL_LABEL_STRUCT_TYPE:
|
2008-02-26 01:07:38 +00:00
|
|
|
case DRAW_HIER_LABEL_STRUCT_TYPE:
|
2007-08-20 01:20:48 +00:00
|
|
|
case DRAW_TEXT_STRUCT_TYPE:
|
|
|
|
StartMoveTexte( (DrawTextStruct*) DrawStruct, DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_LIB_ITEM_STRUCT_TYPE:
|
|
|
|
StartMovePart( (EDA_SchComponentStruct*) DrawStruct, DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_SHEET_STRUCT_TYPE:
|
|
|
|
StartMoveSheet( (DrawSheetStruct*) DrawStruct, DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_NOCONNECT_STRUCT_TYPE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_PART_TEXT_STRUCT_TYPE:
|
|
|
|
StartMoveCmpField( (PartTextStruct*) DrawStruct, DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_MARKER_STRUCT_TYPE:
|
|
|
|
case DRAW_SHEETLABEL_STRUCT_TYPE:
|
|
|
|
default:
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf(
|
|
|
|
wxT( "WinEDA_SchematicFrame::Move_Item Error: Bad DrawType %d" ),
|
2007-09-01 12:00:30 +00:00
|
|
|
DrawStruct->Type() );
|
2007-08-20 01:20:48 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
break;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|