2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************/
|
2009-09-02 18:12:45 +00:00
|
|
|
/* Module to handle Get & Place Library Part */
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2009-01-29 14:26:20 +00:00
|
|
|
#include "gr_basic.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2009-09-18 14:56:05 +00:00
|
|
|
#include "class_library.h"
|
2010-02-16 16:21:52 +00:00
|
|
|
#include "viewlib_frame.h"
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "get_component_dialog.h"
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
#include <boost/foreach.hpp>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
|
|
|
static void ExitPlaceCmp( WinEDA_DrawPanel* Panel, wxDC* DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
static TRANSFORM OldTransform;
|
|
|
|
static wxPoint OldPos;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
wxString WinEDA_SchematicFrame::SelectFromLibBrowser( void )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-10-16 17:18:23 +00:00
|
|
|
wxSemaphore semaphore( 0, 1 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-10-01 14:17:47 +00:00
|
|
|
/* Close the current Lib browser, if open, and open a new one, in
|
|
|
|
* "modal" mode */
|
2009-10-16 17:18:23 +00:00
|
|
|
if( m_ViewlibFrame )
|
|
|
|
{
|
|
|
|
m_ViewlibFrame->Destroy();
|
|
|
|
m_ViewlibFrame = NULL;
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
m_ViewlibFrame = new WinEDA_ViewlibFrame( this, NULL, &semaphore );
|
|
|
|
m_ViewlibFrame->AdjustScrollBars();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
// Show the library viewer frame until it is closed
|
2009-10-01 14:17:47 +00:00
|
|
|
while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
wxYield();
|
|
|
|
wxMilliSleep( 50 );
|
|
|
|
}
|
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
return m_ViewlibFrame->GetEntryName();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
/*
|
|
|
|
* load from a library and place a component
|
2007-08-20 01:20:48 +00:00
|
|
|
* if libname != "", search in lib "libname"
|
|
|
|
* else search in all loaded libs
|
|
|
|
*/
|
2009-09-02 18:12:45 +00:00
|
|
|
SCH_COMPONENT* WinEDA_SchematicFrame::Load_Component( wxDC* DC,
|
|
|
|
const wxString& libname,
|
|
|
|
wxArrayString& HistoryList,
|
|
|
|
bool UseLibBrowser )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-10-16 17:18:23 +00:00
|
|
|
int CmpCount = 0;
|
|
|
|
int unit = 1;
|
|
|
|
int convert = 1;
|
|
|
|
LIB_COMPONENT* Entry = NULL;
|
|
|
|
SCH_COMPONENT* Component = NULL;
|
|
|
|
CMP_LIBRARY* Library = NULL;
|
|
|
|
wxString Name, keys, msg;
|
|
|
|
bool AllowWildSeach = TRUE;
|
|
|
|
static wxString lastCommponentName;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
g_ItemToRepeat = NULL;
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = TRUE;
|
|
|
|
|
|
|
|
if( !libname.IsEmpty() )
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
Library = CMP_LIBRARY::FindLibrary( libname );
|
|
|
|
|
|
|
|
if( Library != NULL )
|
|
|
|
CmpCount = Library->GetCount();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
CmpCount += lib.GetCount();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ask for a component name or key words */
|
|
|
|
msg.Printf( _( "component selection (%d items loaded):" ), CmpCount );
|
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
WinEDA_SelectCmp dlg( this, GetComponentDialogPosition(), HistoryList,
|
|
|
|
msg, UseLibBrowser );
|
|
|
|
dlg.SetComponentName( lastCommponentName );
|
|
|
|
|
|
|
|
if ( dlg.ShowModal() == wxID_CANCEL )
|
2009-10-18 13:12:00 +00:00
|
|
|
{
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2009-10-16 17:18:23 +00:00
|
|
|
return NULL;
|
2009-10-18 13:12:00 +00:00
|
|
|
}
|
2009-10-16 17:18:23 +00:00
|
|
|
|
|
|
|
if( dlg.m_GetExtraFunction )
|
|
|
|
{
|
|
|
|
Name = SelectFromLibBrowser();
|
|
|
|
unit = m_ViewlibFrame->GetUnit();
|
|
|
|
convert = m_ViewlibFrame->GetConvert();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Name = dlg.GetComponentName();
|
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Name.IsEmpty() )
|
|
|
|
{
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
2009-10-16 17:18:23 +00:00
|
|
|
return NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 15:02:11 +00:00
|
|
|
#ifndef KICAD_KEEPCASE
|
2009-10-16 17:18:23 +00:00
|
|
|
Name.MakeUpper();
|
2010-10-22 15:02:11 +00:00
|
|
|
#endif
|
2009-10-16 17:18:23 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Name.GetChar( 0 ) == '=' )
|
|
|
|
{
|
|
|
|
AllowWildSeach = FALSE;
|
|
|
|
keys = Name.AfterFirst( '=' );
|
2009-08-27 11:41:56 +00:00
|
|
|
Name = DataBaseGetName( this, keys, Name );
|
|
|
|
if( Name.IsEmpty() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( Name == wxT( "*" ) )
|
|
|
|
{
|
|
|
|
AllowWildSeach = FALSE;
|
|
|
|
if( GetNameOfPartToLoad( this, Library, Name ) == 0 )
|
|
|
|
{
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( Name.Contains( wxT( "?" ) ) || Name.Contains( wxT( "*" ) ) )
|
|
|
|
{
|
|
|
|
AllowWildSeach = FALSE;
|
2009-08-27 11:41:56 +00:00
|
|
|
Name = DataBaseGetName( this, keys, Name );
|
|
|
|
if( Name.IsEmpty() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
Entry = CMP_LIBRARY::FindLibraryComponent( Name, libname );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
if( ( Entry == NULL ) && AllowWildSeach ) /* Search with wildcard */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
AllowWildSeach = FALSE;
|
|
|
|
wxString wildname = wxChar( '*' ) + Name + wxChar( '*' );
|
|
|
|
Name = wildname;
|
2009-08-27 11:41:56 +00:00
|
|
|
Name = DataBaseGetName( this, keys, Name );
|
|
|
|
|
|
|
|
if( !Name.IsEmpty() )
|
2009-09-18 14:56:05 +00:00
|
|
|
Entry = CMP_LIBRARY::FindLibraryComponent( Name, libname );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Entry == NULL )
|
|
|
|
{
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
if( Entry == NULL )
|
|
|
|
{
|
|
|
|
msg = _( "Failed to find part " ) + Name + _( " in library" );
|
2009-10-16 17:18:23 +00:00
|
|
|
DisplayError( this, msg );
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
lastCommponentName = Name;
|
2007-08-20 01:20:48 +00:00
|
|
|
AddHistoryComponentName( HistoryList, Name );
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = ShowWhileMoving;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp;
|
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
Component = new SCH_COMPONENT( *Entry, GetSheet(), unit, convert,
|
|
|
|
GetScreen()->m_Curseur, true );
|
2010-02-17 13:22:25 +00:00
|
|
|
// Set the m_ChipName value, from component name in lib, for aliases
|
|
|
|
// Note if Entry is found, and if Name is an alias of a component,
|
|
|
|
// alias exists because its root component was found
|
|
|
|
Component->m_ChipName = Name;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-02-17 13:22:25 +00:00
|
|
|
// Set the component value that can differ from component name in lib, for aliases
|
2009-10-27 10:55:46 +00:00
|
|
|
Component->GetField( VALUE )->m_Text = Name;
|
2009-04-17 08:51:02 +00:00
|
|
|
Component->DisplayInfo( this );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-10-27 10:55:46 +00:00
|
|
|
DrawStructsInGhost( DrawPanel, DC, Component, wxPoint( 0, 0 ) );
|
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
return Component;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/**
|
|
|
|
* Move a component.
|
|
|
|
*/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
wxPoint move_vector;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_SCREEN* screen = (SCH_SCREEN*) panel->GetScreen();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
SCH_COMPONENT* Component = (SCH_COMPONENT*) screen->GetCurItem();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( erase )
|
2008-03-16 04:47:43 +00:00
|
|
|
{
|
2009-07-26 17:16:42 +00:00
|
|
|
DrawStructsInGhost( panel, DC, Component, wxPoint(0,0) );
|
2008-03-16 04:47:43 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
move_vector = screen->m_Curseur - Component->m_Pos;
|
|
|
|
Component->Move( move_vector );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-07-26 17:16:42 +00:00
|
|
|
DrawStructsInGhost( panel, DC, Component, wxPoint(0,0) );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
/*
|
2009-11-04 20:46:53 +00:00
|
|
|
* Routine to rotate and mirror a component.
|
|
|
|
*
|
|
|
|
** If DC == NULL: no repaint
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-09-02 18:12:45 +00:00
|
|
|
void WinEDA_SchematicFrame::CmpRotationMiroir( SCH_COMPONENT* DrawComponent,
|
|
|
|
wxDC* DC, int type_rotate )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DrawComponent == NULL )
|
|
|
|
return;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Deletes the previous component. */
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DC )
|
|
|
|
{
|
|
|
|
DrawPanel->CursorOff( DC );
|
|
|
|
if( DrawComponent->m_Flags )
|
2009-09-02 18:12:45 +00:00
|
|
|
DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint( 0, 0 ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2008-03-20 01:50:21 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawPanel->PostDirtyRect( DrawComponent->GetBoundingBox() );
|
2008-03-20 01:50:21 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
DrawComponent->SetOrientation( type_rotate );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Redraw the component in the new position. */
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DC )
|
|
|
|
{
|
|
|
|
if( DrawComponent->m_Flags )
|
2009-07-26 17:16:42 +00:00
|
|
|
DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint(0,0) );
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2009-09-02 18:12:45 +00:00
|
|
|
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ),
|
2008-12-08 15:27:13 +00:00
|
|
|
GR_DEFAULT_DRAWMODE );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->CursorOn( DC );
|
|
|
|
}
|
|
|
|
|
2008-03-16 04:47:43 +00:00
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
/*
|
2009-11-04 20:46:53 +00:00
|
|
|
* Abort a place component command in progress.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-09-02 18:12:45 +00:00
|
|
|
static void ExitPlaceCmp( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_SCREEN* screen = (SCH_SCREEN*) Panel->GetScreen();
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
SCH_COMPONENT* Component = (SCH_COMPONENT*) screen->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
if( Component->m_Flags & IS_NEW )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-31 16:49:45 +00:00
|
|
|
Component->m_Flags = 0;
|
|
|
|
SAFE_DELETE( Component );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-11-04 20:46:53 +00:00
|
|
|
else if( Component )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-27 14:32:40 +00:00
|
|
|
wxPoint move_vector = OldPos - Component->m_Pos;
|
|
|
|
Component->Move( move_vector );
|
2010-10-20 20:24:26 +00:00
|
|
|
Component->m_Transform = OldTransform;
|
2008-12-31 16:49:45 +00:00
|
|
|
Component->m_Flags = 0;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2008-03-16 04:47:43 +00:00
|
|
|
Panel->Refresh( TRUE );
|
2007-08-20 01:20:48 +00:00
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
2008-04-17 16:25:29 +00:00
|
|
|
screen->SetCurItem( NULL );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
/*
|
2009-11-04 20:46:53 +00:00
|
|
|
* Handle select part in multi-part component.
|
2009-09-02 18:12:45 +00:00
|
|
|
*/
|
2008-03-20 01:50:21 +00:00
|
|
|
void WinEDA_SchematicFrame::SelPartUnit( SCH_COMPONENT* DrawComponent,
|
2007-08-20 01:20:48 +00:00
|
|
|
int unit, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int m_UnitCount;
|
2009-09-18 14:56:05 +00:00
|
|
|
LIB_COMPONENT* LibEntry;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DrawComponent == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
LibEntry = CMP_LIBRARY::FindLibraryComponent( DrawComponent->m_ChipName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( LibEntry == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-10-05 17:52:41 +00:00
|
|
|
m_UnitCount = LibEntry->GetPartCount();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( m_UnitCount <= 1 )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DrawComponent->m_Multi == unit )
|
|
|
|
return;
|
|
|
|
if( unit < 1 )
|
|
|
|
unit = 1;
|
|
|
|
if( unit > m_UnitCount )
|
|
|
|
unit = m_UnitCount;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DrawComponent->m_Flags )
|
2009-09-02 18:12:45 +00:00
|
|
|
DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint( 0, 0 ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
|
|
|
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Update the unit number. */
|
2008-05-21 09:18:14 +00:00
|
|
|
DrawComponent->SetUnitSelection( GetSheet(), unit );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawComponent->m_Multi = unit;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Redraw the component in the new position. */
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DrawComponent->m_Flags )
|
2009-09-02 18:12:45 +00:00
|
|
|
DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint( 0, 0 ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2009-09-02 18:12:45 +00:00
|
|
|
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ),
|
|
|
|
GR_DEFAULT_DRAWMODE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-16 04:47:43 +00:00
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
void WinEDA_SchematicFrame::ConvertPart( SCH_COMPONENT* DrawComponent,
|
2008-12-08 15:27:13 +00:00
|
|
|
wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
LIB_COMPONENT* LibEntry;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( DrawComponent == NULL )
|
|
|
|
return;
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
LibEntry = CMP_LIBRARY::FindLibraryComponent( DrawComponent->m_ChipName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( LibEntry == NULL )
|
|
|
|
return;
|
|
|
|
|
2009-09-29 18:38:21 +00:00
|
|
|
if( !LibEntry->HasConversion() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-09-02 18:12:45 +00:00
|
|
|
DisplayError( this, wxT( "No convert found" ) );
|
|
|
|
return;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( DrawComponent->m_Flags )
|
2009-09-02 18:12:45 +00:00
|
|
|
DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint( 0, 0 ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
|
|
|
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
|
|
|
|
|
|
|
|
DrawComponent->m_Convert++;
|
2009-10-01 16:46:13 +00:00
|
|
|
// ensure m_Convert = 0, 1 or 2
|
|
|
|
// 0 and 1 = shape 1 = not converted
|
|
|
|
// 2 = shape 2 = first converted shape
|
|
|
|
// > 2 is not used but could be used for more shapes
|
|
|
|
// like multiple shapes for a programmable component
|
|
|
|
// When m_Convert = val max, return to the first shape
|
|
|
|
if( DrawComponent->m_Convert > 2 )
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawComponent->m_Convert = 1;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Redraw the component in the new position. */
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DrawComponent->m_Flags & IS_MOVED )
|
2009-09-02 18:12:45 +00:00
|
|
|
DrawStructsInGhost( DrawPanel, DC, DrawComponent, wxPoint( 0, 0 ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2009-09-02 18:12:45 +00:00
|
|
|
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ),
|
|
|
|
GR_DEFAULT_DRAWMODE );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-03-16 04:47:43 +00:00
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-20 20:24:26 +00:00
|
|
|
void WinEDA_SchematicFrame::StartMovePart( SCH_COMPONENT* Component, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Component == NULL )
|
|
|
|
return;
|
2008-03-20 01:50:21 +00:00
|
|
|
if( Component->Type() != TYPE_SCH_COMPONENT )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if( Component->m_Flags == 0 )
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
if( g_ItemToUndoCopy )
|
|
|
|
{
|
2008-03-16 04:47:43 +00:00
|
|
|
SAFE_DELETE( g_ItemToUndoCopy );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
g_ItemToUndoCopy = Component->GenCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->CursorOff( DC );
|
2008-03-16 04:47:43 +00:00
|
|
|
GetScreen()->m_Curseur = Component->m_Pos;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = ShowWhileMoving;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp;
|
2008-03-16 04:47:43 +00:00
|
|
|
GetScreen()->SetCurItem( Component );
|
2007-08-20 01:20:48 +00:00
|
|
|
OldPos = Component->m_Pos;
|
2010-10-20 20:24:26 +00:00
|
|
|
OldTransform = Component->m_Transform;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-03-16 04:47:43 +00:00
|
|
|
#if 1
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2008-03-16 04:47:43 +00:00
|
|
|
// switch from normal mode to xor mode for the duration of the move, first
|
2009-11-04 20:46:53 +00:00
|
|
|
// by erasing fully any "normal drawing mode" primitives with the
|
|
|
|
// PostDirtyRect(), then by drawing the first time in xor mode so that
|
|
|
|
// subsequent xor drawing modes will fully erase this first copy.
|
2008-03-16 04:47:43 +00:00
|
|
|
|
|
|
|
Component->m_Flags |= IS_MOVED; // omit redrawing the component, erase only
|
|
|
|
DrawPanel->PostDirtyRect( Component->GetBoundingBox() );
|
|
|
|
|
2009-07-26 17:16:42 +00:00
|
|
|
DrawStructsInGhost( DrawPanel, DC, Component, wxPoint(0,0) );
|
2008-03-16 04:47:43 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
RedrawOneStruct( DrawPanel, DC, Component, g_XorMode );
|
2008-03-16 04:47:43 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Component->m_Flags |= IS_MOVED;
|
2008-03-16 04:47:43 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
2008-03-16 04:47:43 +00:00
|
|
|
#endif
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->m_AutoPAN_Request = TRUE;
|
|
|
|
|
|
|
|
DrawPanel->CursorOn( DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|