2007-09-15 04:25:54 +00:00
|
|
|
/*****************************************/
|
2009-09-04 18:57:37 +00:00
|
|
|
/* EESchema - libedit_onleftclick.cpp */
|
2007-09-15 04:25:54 +00:00
|
|
|
/*****************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
/* Library editor commands created by a mouse left button simple or double click
|
2007-09-15 04:25:54 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "eeschema_id.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2010-02-16 16:21:52 +00:00
|
|
|
#include "libeditframe.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_libentry.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
LIB_DRAW_ITEM* DrawEntry = m_drawItem;
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component == NULL ) // No component loaded !
|
2007-09-15 04:25:54 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if( m_ID_current_state == 0 )
|
|
|
|
{
|
|
|
|
if( DrawEntry && DrawEntry->m_Flags )
|
|
|
|
{
|
2010-02-04 17:46:12 +00:00
|
|
|
// Don't put copy in undo list while resizing (because it's already done)
|
|
|
|
if (!(DrawEntry->m_Flags & IS_RESIZED))
|
|
|
|
SaveCopyInUndoList( m_component );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
switch( DrawEntry->Type() )
|
|
|
|
{
|
|
|
|
case COMPONENT_FIELD_DRAW_TYPE:
|
2009-10-08 13:19:28 +00:00
|
|
|
PlaceField( DC, (LIB_FIELD*) DrawEntry );
|
2007-09-15 04:25:54 +00:00
|
|
|
DrawEntry = NULL;
|
|
|
|
break;
|
|
|
|
|
2009-12-03 19:11:34 +00:00
|
|
|
case COMPONENT_PIN_DRAW_TYPE:
|
|
|
|
PlacePin( DC );
|
|
|
|
DrawEntry = NULL;
|
|
|
|
break;
|
|
|
|
|
2007-09-15 04:25:54 +00:00
|
|
|
default:
|
|
|
|
EndDrawGraphicItem( DC );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-29 18:38:21 +00:00
|
|
|
DrawEntry =
|
|
|
|
m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
|
|
|
|
GetScreen()->m_MousePosition );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
if( DrawEntry == NULL )
|
|
|
|
{
|
2009-09-29 18:38:21 +00:00
|
|
|
DrawEntry =
|
|
|
|
m_component->LocateDrawItem( m_unit, m_convert,
|
|
|
|
TYPE_NOT_INIT,
|
|
|
|
GetScreen()->m_Curseur );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( DrawEntry )
|
2009-04-05 20:49:15 +00:00
|
|
|
DrawEntry->DisplayInfo( this );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
else
|
2009-09-18 14:56:05 +00:00
|
|
|
DisplayCmpDoc();
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_ID_current_state )
|
|
|
|
{
|
|
|
|
switch( m_ID_current_state )
|
|
|
|
{
|
|
|
|
case ID_NO_SELECT_BUTT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_PIN_BUTT:
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem == NULL || m_drawItem->m_Flags == 0 )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
|
|
|
CreatePin( DC );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
SaveCopyInUndoList( m_component );
|
2007-09-15 04:25:54 +00:00
|
|
|
PlacePin( DC );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_BODY_LINE_BUTT:
|
|
|
|
case ID_LIBEDIT_BODY_ARC_BUTT:
|
|
|
|
case ID_LIBEDIT_BODY_CIRCLE_BUTT:
|
|
|
|
case ID_LIBEDIT_BODY_RECT_BUTT:
|
|
|
|
case ID_LIBEDIT_BODY_TEXT_BUTT:
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem == NULL || m_drawItem->m_Flags == 0 )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
m_drawItem = CreateGraphicItem( m_component, DC );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
2009-09-25 18:49:04 +00:00
|
|
|
else if( m_drawItem )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_drawItem->m_Flags & IS_NEW )
|
2007-09-15 04:25:54 +00:00
|
|
|
GraphicItemBeginDraw( DC );
|
|
|
|
else
|
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
SaveCopyInUndoList( m_component );
|
2007-09-15 04:25:54 +00:00
|
|
|
EndDrawGraphicItem( DC );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_DELETE_ITEM_BUTT:
|
2009-09-29 18:38:21 +00:00
|
|
|
DrawEntry =
|
|
|
|
m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
|
|
|
|
GetScreen()->m_MousePosition );
|
2007-09-15 04:25:54 +00:00
|
|
|
|
|
|
|
if( DrawEntry == NULL )
|
|
|
|
{
|
2009-09-29 18:38:21 +00:00
|
|
|
DrawEntry =
|
|
|
|
m_component->LocateDrawItem( m_unit, m_convert,
|
|
|
|
TYPE_NOT_INIT,
|
|
|
|
GetScreen()->m_Curseur );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
if( DrawEntry == NULL )
|
2009-10-23 14:35:24 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
DisplayCmpDoc();
|
2009-10-23 14:35:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-09-25 18:49:04 +00:00
|
|
|
SaveCopyInUndoList( m_component );
|
2007-09-15 04:25:54 +00:00
|
|
|
if( DrawEntry->Type() == COMPONENT_PIN_DRAW_TYPE )
|
2009-10-08 13:19:28 +00:00
|
|
|
DeletePin( DC, m_component, (LIB_PIN*) DrawEntry );
|
2007-09-15 04:25:54 +00:00
|
|
|
else
|
2009-09-25 18:49:04 +00:00
|
|
|
m_component->RemoveDrawItem( DrawEntry, DrawPanel, DC );
|
2007-09-15 04:25:54 +00:00
|
|
|
DrawEntry = NULL;
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2007-09-15 04:25:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LIBEDIT_ANCHOR_ITEM_BUTT:
|
2009-09-25 18:49:04 +00:00
|
|
|
SaveCopyInUndoList( m_component );
|
2007-09-15 04:25:54 +00:00
|
|
|
PlaceAncre();
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
2009-09-04 18:57:37 +00:00
|
|
|
DisplayError( this,
|
|
|
|
wxT( "WinEDA_LibeditFrame::OnLeftClick error" ) );
|
2007-09-15 04:25:54 +00:00
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/*
|
|
|
|
* Called on a double click:
|
2008-08-11 18:21:21 +00:00
|
|
|
* If an editable item (field, pin, graphic):
|
|
|
|
* Call the suitable dialog editor.
|
2007-09-15 04:25:54 +00:00
|
|
|
*/
|
2009-09-04 18:57:37 +00:00
|
|
|
void WinEDA_LibeditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
wxPoint pos = GetPosition();
|
2007-09-15 04:25:54 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
return;
|
|
|
|
|
2009-12-03 19:11:34 +00:00
|
|
|
if( ( m_drawItem == NULL ) || ( m_drawItem->m_Flags == 0 ) )
|
2008-08-11 18:21:21 +00:00
|
|
|
{ // We can locate an item
|
2009-12-03 19:11:34 +00:00
|
|
|
m_drawItem =
|
2009-09-29 18:38:21 +00:00
|
|
|
m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
|
|
|
|
GetScreen()->m_MousePosition );
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-12-03 19:11:34 +00:00
|
|
|
m_drawItem =
|
2009-09-29 18:38:21 +00:00
|
|
|
m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
|
|
|
|
GetScreen()->m_Curseur );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem == NULL )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-09-14 13:24:17 +00:00
|
|
|
EditComponentProperties();
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem )
|
|
|
|
m_drawItem->DisplayInfo( this );
|
2007-09-15 04:25:54 +00:00
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = TRUE;
|
|
|
|
|
2009-12-03 19:11:34 +00:00
|
|
|
switch( m_drawItem->Type() )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-10-30 19:26:25 +00:00
|
|
|
case COMPONENT_PIN_DRAW_TYPE:
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem->m_Flags == 0 )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-10-30 19:26:25 +00:00
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetId( ID_LIBEDIT_EDIT_PIN );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_ARC_DRAW_TYPE:
|
|
|
|
case COMPONENT_CIRCLE_DRAW_TYPE:
|
|
|
|
case COMPONENT_RECT_DRAW_TYPE:
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem->m_Flags == 0 )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-12-03 19:11:34 +00:00
|
|
|
EditGraphicSymbol( DC, m_drawItem );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_LINE_DRAW_TYPE:
|
|
|
|
case COMPONENT_POLYLINE_DRAW_TYPE:
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem->m_Flags == 0 )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-12-03 19:11:34 +00:00
|
|
|
EditGraphicSymbol( DC, m_drawItem );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
2009-12-03 19:11:34 +00:00
|
|
|
else if( m_drawItem->m_Flags & IS_NEW )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
|
|
|
EndDrawGraphicItem( DC );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_GRAPHIC_TEXT_DRAW_TYPE:
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem->m_Flags == 0 )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-12-03 19:11:34 +00:00
|
|
|
EditSymbolText( DC, m_drawItem );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COMPONENT_FIELD_DRAW_TYPE:
|
2009-12-03 19:11:34 +00:00
|
|
|
if( m_drawItem->m_Flags == 0 )
|
2007-09-15 04:25:54 +00:00
|
|
|
{
|
2009-12-03 19:11:34 +00:00
|
|
|
EditField( DC, (LIB_FIELD*) m_drawItem );
|
2007-09-15 04:25:54 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxString msg;
|
2009-09-04 18:57:37 +00:00
|
|
|
msg.Printf( wxT( "WinEDA_LibeditFrame::OnLeftDClick Error: unknown \
|
|
|
|
StructType %d" ),
|
2009-12-03 19:11:34 +00:00
|
|
|
m_drawItem->Type() );
|
2007-09-15 04:25:54 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|