2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************/
|
|
|
|
/* Module to handle Get & Place Library Part */
|
|
|
|
/*************************************************/
|
|
|
|
|
|
|
|
#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"
|
|
|
|
#include "get_component_dialog.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Routines Locales */
|
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
|
|
|
|
|
|
|
/* Variables locales */
|
2007-08-20 01:20:48 +00:00
|
|
|
static int OldTransMat[2][2];
|
2007-06-05 12:10:51 +00:00
|
|
|
static wxPoint OldPos;
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
wxString SelectFromLibBrowser( WinEDA_DrawFrame* parent )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*******************************************************/
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
wxString name;
|
|
|
|
WinEDA_ViewlibFrame* Viewer;
|
|
|
|
wxSemaphore semaphore( 0, 1 );
|
|
|
|
WinEDA_SchematicFrame* frame;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
frame = (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
|
2008-12-08 15:27:13 +00:00
|
|
|
|
|
|
|
Viewer = frame->m_ViewlibFrame;
|
2007-08-20 01:20:48 +00:00
|
|
|
/* Close the current Lib browser, if open, and open a new one, in "modal" mode */
|
|
|
|
if( Viewer )
|
|
|
|
Viewer->Destroy();
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
Viewer = frame->m_ViewlibFrame =
|
2008-12-31 09:27:19 +00:00
|
|
|
new WinEDA_ViewlibFrame( frame, NULL, &semaphore );
|
2007-08-20 01:20:48 +00:00
|
|
|
Viewer->AdjustScrollBars();
|
|
|
|
|
|
|
|
// Show the library viewer frame until it is closed
|
|
|
|
while( semaphore.TryWait() == wxSEMA_BUSY ) // Wait for viewer closing event
|
|
|
|
{
|
|
|
|
wxYield();
|
|
|
|
wxMilliSleep( 50 );
|
|
|
|
}
|
|
|
|
|
|
|
|
name = g_CurrentViewComponentName;
|
|
|
|
return name;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2008-12-31 09:27:19 +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
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +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
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-31 09:27:19 +00:00
|
|
|
int ii, CmpCount = 0;
|
2008-12-31 16:49:45 +00:00
|
|
|
EDA_LibComponentStruct* Entry = NULL;
|
|
|
|
SCH_COMPONENT* Component = NULL;
|
|
|
|
LibraryStruct* Library = NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
wxString Name, keys, msg;
|
|
|
|
bool AllowWildSeach = TRUE;
|
|
|
|
|
|
|
|
g_ItemToRepeat = NULL;
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = TRUE;
|
|
|
|
|
|
|
|
if( !libname.IsEmpty() )
|
|
|
|
{
|
|
|
|
Library = g_LibraryList;
|
|
|
|
while( Library )
|
|
|
|
{
|
|
|
|
if( Library->m_Name == libname )
|
|
|
|
{
|
|
|
|
CmpCount = Library->m_NumOfParts;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Library = Library->m_Pnext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LibraryStruct* lib = g_LibraryList;
|
|
|
|
while( lib )
|
|
|
|
{
|
|
|
|
CmpCount += lib->m_NumOfParts;
|
|
|
|
lib = lib->m_Pnext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ask for a component name or key words */
|
|
|
|
msg.Printf( _( "component selection (%d items loaded):" ), CmpCount );
|
|
|
|
|
|
|
|
Name = GetComponentName( this, HistoryList, msg,
|
|
|
|
UseLibBrowser ? SelectFromLibBrowser : NULL );
|
|
|
|
Name.MakeUpper();
|
|
|
|
if( Name.IsEmpty() )
|
|
|
|
{
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
return NULL; /* annulation de commande */
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Name.GetChar( 0 ) == '=' )
|
|
|
|
{
|
|
|
|
AllowWildSeach = FALSE;
|
|
|
|
keys = Name.AfterFirst( '=' );
|
|
|
|
if( DataBaseGetName( this, keys, Name ) == 0 )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
if( DataBaseGetName( this, keys, Name ) == 0 )
|
|
|
|
{
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Entry = FindLibPart( Name.GetData(), libname, FIND_ROOT );
|
|
|
|
if( (Entry == NULL) && AllowWildSeach ) /* Attemp to search with wildcard */
|
|
|
|
{
|
|
|
|
AllowWildSeach = FALSE;
|
|
|
|
wxString wildname = wxChar( '*' ) + Name + wxChar( '*' );
|
|
|
|
Name = wildname;
|
|
|
|
if( DataBaseGetName( this, keys, Name ) )
|
|
|
|
Entry = FindLibPart( Name.GetData(), libname, FIND_ROOT );
|
|
|
|
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" );
|
|
|
|
DisplayError( this, msg, 10 );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
AddHistoryComponentName( HistoryList, Name );
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = ShowWhileMoving;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp;
|
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
Component = new SCH_COMPONENT( GetScreen()->m_Curseur );
|
|
|
|
Component->m_Multi = 1; /* Selection de l'unite 1 dans le boitier */
|
|
|
|
Component->m_Convert = 1;
|
|
|
|
Component->m_ChipName = Name;
|
|
|
|
Component->m_TimeStamp = GetTimeStamp();
|
|
|
|
Component->m_Flags = IS_NEW | IS_MOVED;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Init champ Valeur */
|
2008-12-31 16:49:45 +00:00
|
|
|
Component->GetField( VALUE )->m_Pos = Entry->m_Name.m_Pos + Component->m_Pos;
|
|
|
|
Component->GetField( VALUE )->ImportValues( Entry->m_Name );
|
|
|
|
Component->GetField( VALUE )->m_Text = Component->m_ChipName;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
msg = Entry->m_Prefix.m_Text;
|
|
|
|
if( msg.IsEmpty() )
|
|
|
|
msg = wxT( "U" );
|
|
|
|
msg += wxT( "?" );
|
2008-03-16 04:47:43 +00:00
|
|
|
|
2008-12-31 15:01:29 +00:00
|
|
|
// update the reference -- just the prefix for now.
|
2008-12-31 16:49:45 +00:00
|
|
|
Component->SetRef( GetSheet(), msg );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Init champ Reference */
|
2008-12-31 16:49:45 +00:00
|
|
|
Component->GetField( REFERENCE )->m_Pos = Entry->m_Prefix.m_Pos + Component->m_Pos;
|
|
|
|
Component->GetField( REFERENCE )->ImportValues( Entry->m_Prefix );
|
|
|
|
Component->m_PrefixString = Entry->m_Prefix.m_Text;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Init des autres champs si predefinis dans la librairie */
|
2008-12-31 16:49:45 +00:00
|
|
|
LibDrawField* EntryField;
|
|
|
|
for( EntryField = Entry->m_Fields; EntryField != NULL; EntryField = EntryField->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-31 16:49:45 +00:00
|
|
|
if( EntryField->m_Text.IsEmpty() && EntryField->m_Name.IsEmpty() )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
ii = EntryField->m_FieldId;
|
2008-12-31 15:01:29 +00:00
|
|
|
if( ii < 2 ) // Reference or value, already done
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
if( ii >= Component->GetFieldCount() )
|
|
|
|
{ // This entry has more than the default count: add extra fields
|
|
|
|
while( ii >= Component->GetFieldCount() )
|
|
|
|
{
|
|
|
|
int field_id = Component->GetFieldCount();
|
|
|
|
SCH_CMP_FIELD field( wxPoint( 0, 0 ), field_id, Component, ReturnDefaultFieldName( ii ) );
|
|
|
|
Component->AddField( field );
|
|
|
|
}
|
|
|
|
}
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
SCH_CMP_FIELD* curr_field = Component->GetField( ii );
|
2008-10-06 05:44:29 +00:00
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
curr_field->m_Pos = Component->m_Pos + EntryField->m_Pos;
|
|
|
|
curr_field->ImportValues( *EntryField );
|
|
|
|
curr_field->m_Text = EntryField->m_Text;
|
|
|
|
curr_field->m_Name = ( ii < FIELD1 ) ? ReturnDefaultFieldName( ii ) : EntryField->m_Name;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
DrawStructsInGhost( DrawPanel, DC, Component, 0, 0 );
|
2008-03-16 04:47:43 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
MsgPanel->EraseMsgBox();
|
2009-04-17 08:51:02 +00:00
|
|
|
Component->DisplayInfo( this );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
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
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
/*** Routine de deplacement du composant. ***/
|
2007-06-05 12:10:51 +00:00
|
|
|
/*** Appele par GeneralControle grace a ActiveScreen->ManageCurseur. ***/
|
|
|
|
/**************************************************************************/
|
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
|
|
|
/* Effacement du composant */
|
|
|
|
if( erase )
|
2008-03-16 04:47:43 +00:00
|
|
|
{
|
2008-12-31 16:49:45 +00:00
|
|
|
DrawStructsInGhost( panel, DC, Component, 0, 0 );
|
2008-03-16 04:47:43 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
move_vector.x = screen->m_Curseur.x - Component->m_Pos.x;
|
|
|
|
move_vector.y = screen->m_Curseur.y - Component->m_Pos.y;
|
|
|
|
MoveOneStruct( Component, move_vector );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
DrawStructsInGhost( panel, DC, Component, 0, 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
void WinEDA_SchematicFrame::CmpRotationMiroir(
|
2008-03-20 01:50:21 +00:00
|
|
|
SCH_COMPONENT* DrawComponent, wxDC* DC, int type_rotate )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Routine permettant les rotations et les miroirs d'un composant
|
2007-08-20 01:20:48 +00:00
|
|
|
* Si DC = NULL : pas de redessin
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DrawComponent == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Efface le trace precedent */
|
|
|
|
if( DC )
|
|
|
|
{
|
|
|
|
DrawPanel->CursorOff( DC );
|
|
|
|
if( DrawComponent->m_Flags )
|
|
|
|
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
DrawComponent->SetRotationMiroir( type_rotate );
|
|
|
|
|
|
|
|
/* Redessine le composant dans la nouvelle position */
|
|
|
|
if( DC )
|
|
|
|
{
|
|
|
|
if( DrawComponent->m_Flags )
|
|
|
|
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
|
|
|
|
else
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0,
|
|
|
|
0 ),
|
|
|
|
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 );
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ExitPlaceCmp( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Routine de sortie de la fonction de placement de composant
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
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
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
if( Component->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */
|
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
|
|
|
}
|
2008-12-31 16:49:45 +00:00
|
|
|
else if( Component ) /* Deplacement ancien composant en cours */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
wxPoint move_vector;
|
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
move_vector.x = OldPos.x - Component->m_Pos.x;
|
|
|
|
move_vector.y = OldPos.y - Component->m_Pos.y;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
MoveOneStruct( Component, move_vector );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-31 16:49:45 +00:00
|
|
|
memcpy( Component->m_Transform, OldTransMat, sizeof(OldTransMat) );
|
2008-03-16 04:47:43 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************/
|
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
|
|
|
/************************************************************************/
|
|
|
|
/* Selection de l'unite dans les boitiers a multiples Parts */
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int m_UnitCount;
|
|
|
|
EDA_LibComponentStruct* 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
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
LibEntry = FindLibPart(
|
|
|
|
DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
2007-08-20 01:20:48 +00:00
|
|
|
if( LibEntry == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
m_UnitCount = LibEntry->m_UnitCount;
|
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
|
|
|
/* Efface le trace precedent */
|
|
|
|
if( DrawComponent->m_Flags )
|
|
|
|
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
|
|
|
|
else
|
|
|
|
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/* Mise a jour du numero d'unite */
|
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
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/* Redessine le composant dans la nouvelle position */
|
|
|
|
if( DrawComponent->m_Flags )
|
|
|
|
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
|
|
|
|
else
|
2008-12-08 15:27:13 +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 );
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +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
|
|
|
/************************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int ii;
|
|
|
|
EDA_LibComponentStruct* LibEntry;
|
|
|
|
|
|
|
|
if( DrawComponent == NULL )
|
|
|
|
return;
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
LibEntry = FindLibPart(
|
|
|
|
DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
2007-08-20 01:20:48 +00:00
|
|
|
if( LibEntry == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( ( ii = LookForConvertPart( LibEntry ) ) < 2 )
|
|
|
|
{
|
|
|
|
DisplayError( this, wxT( "No Convert found" ), 10 ); return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Efface le trace precedent */
|
|
|
|
if( DrawComponent->m_Flags )
|
|
|
|
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
|
|
|
|
else
|
|
|
|
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
|
|
|
|
|
|
|
|
DrawComponent->m_Convert++;
|
|
|
|
if( DrawComponent->m_Convert > ii )
|
|
|
|
DrawComponent->m_Convert = 1;
|
|
|
|
|
|
|
|
/* Redessine le composant dans la nouvelle position */
|
|
|
|
if( DrawComponent->m_Flags & IS_MOVED )
|
|
|
|
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
|
|
|
|
else
|
2008-12-08 15:27:13 +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 );
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
int LookForConvertPart( EDA_LibComponentStruct* LibEntry )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Retourne la plus grande valeur trouvee dans la liste des elements
|
2007-08-20 01:20:48 +00:00
|
|
|
* "drawings" du composant LibEntry, pour le membre .Convert
|
|
|
|
* Si il n'y a pas de representation type "convert", la valeur
|
|
|
|
* retournee est 0 ou 1
|
|
|
|
* Si il y a une representation type "convert",
|
|
|
|
* la valeur retournee est > 1 (typiquement 2)
|
2007-06-05 12:10:51 +00:00
|
|
|
*/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int ii;
|
|
|
|
LibEDA_BaseStruct* DrawLibEntry;
|
|
|
|
|
|
|
|
DrawLibEntry = LibEntry->m_Drawings;
|
|
|
|
ii = 0;
|
|
|
|
while( DrawLibEntry )
|
|
|
|
{
|
|
|
|
if( ii < DrawLibEntry->m_Convert )
|
|
|
|
ii = DrawLibEntry->m_Convert;
|
|
|
|
DrawLibEntry = DrawLibEntry->Next();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ii;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************************/
|
2008-03-20 01:50:21 +00:00
|
|
|
void WinEDA_SchematicFrame::StartMovePart( SCH_COMPONENT* Component,
|
2008-12-08 15:27:13 +00:00
|
|
|
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;
|
|
|
|
memcpy( OldTransMat, Component->m_Transform, sizeof(OldTransMat) );
|
|
|
|
|
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
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
Component->m_Flags |= IS_MOVED; // omit redrawing the component, erase only
|
|
|
|
DrawPanel->PostDirtyRect( Component->GetBoundingBox() );
|
|
|
|
|
|
|
|
DrawStructsInGhost( DrawPanel, DC, Component, 0, 0 );
|
|
|
|
|
|
|
|
#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
|
|
|
}
|