2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************/
|
|
|
|
/* Module to handle Get & Place Library Part */
|
|
|
|
/*************************************************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
#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
|
|
|
/*******************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxString name;
|
|
|
|
WinEDA_ViewlibFrame* Viewer;
|
|
|
|
wxSemaphore semaphore( 0, 1 );
|
|
|
|
|
2007-10-01 15:37:42 +00:00
|
|
|
Viewer = parent->m_Parent->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();
|
|
|
|
|
2007-10-01 15:37:42 +00:00
|
|
|
Viewer = parent->m_Parent->m_ViewlibFrame = new
|
2007-08-20 01:20:48 +00:00
|
|
|
WinEDA_ViewlibFrame(
|
2007-10-01 15:37:42 +00:00
|
|
|
parent->m_Parent->m_SchematicFrame,
|
2007-08-20 01:20:48 +00:00
|
|
|
parent->m_Parent,
|
|
|
|
NULL,
|
|
|
|
&semaphore );
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
EDA_SchComponentStruct* 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
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int ii, CmpCount = 0;
|
|
|
|
LibDrawField* Field;
|
|
|
|
EDA_LibComponentStruct* Entry = NULL;
|
|
|
|
EDA_SchComponentStruct* DrawLibItem = NULL;
|
|
|
|
LibraryStruct* Library = NULL;
|
|
|
|
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;
|
|
|
|
|
|
|
|
DrawLibItem = new EDA_SchComponentStruct( m_CurrentScreen->m_Curseur );
|
|
|
|
DrawLibItem->m_Multi = 1;/* Selection de l'unite 1 dans le boitier */
|
|
|
|
DrawLibItem->m_Convert = 1;
|
|
|
|
DrawLibItem->m_ChipName = Name;
|
|
|
|
DrawLibItem->m_TimeStamp = GetTimeStamp();
|
|
|
|
DrawLibItem->m_Flags = IS_NEW | IS_MOVED;
|
|
|
|
|
|
|
|
/* Init champ Valeur */
|
|
|
|
DrawLibItem->m_Field[VALUE].m_Pos.x =
|
|
|
|
Entry->m_Name.m_Pos.x + DrawLibItem->m_Pos.x;
|
|
|
|
DrawLibItem->m_Field[VALUE].m_Pos.y =
|
|
|
|
Entry->m_Name.m_Pos.y + DrawLibItem->m_Pos.y;
|
|
|
|
DrawLibItem->m_Field[VALUE].m_Orient = Entry->m_Name.m_Orient;
|
|
|
|
DrawLibItem->m_Field[VALUE].m_Size = Entry->m_Name.m_Size;
|
|
|
|
DrawLibItem->m_Field[VALUE].m_Text = DrawLibItem->m_ChipName;
|
|
|
|
DrawLibItem->m_Field[VALUE].m_Attributs = Entry->m_Name.m_Attributs;
|
|
|
|
DrawLibItem->m_Field[VALUE].m_HJustify = Entry->m_Name.m_HJustify;
|
|
|
|
DrawLibItem->m_Field[VALUE].m_VJustify = Entry->m_Name.m_VJustify;
|
|
|
|
|
|
|
|
msg = Entry->m_Prefix.m_Text;
|
|
|
|
if( msg.IsEmpty() )
|
|
|
|
msg = wxT( "U" );
|
|
|
|
msg += wxT( "?" );
|
|
|
|
|
|
|
|
/* Init champ Reference */
|
|
|
|
DrawLibItem->m_Field[REFERENCE].m_Pos.x =
|
|
|
|
Entry->m_Prefix.m_Pos.x + DrawLibItem->m_Pos.x;
|
|
|
|
DrawLibItem->m_Field[REFERENCE].m_Pos.y =
|
|
|
|
Entry->m_Prefix.m_Pos.y + DrawLibItem->m_Pos.y;
|
|
|
|
DrawLibItem->m_Field[REFERENCE].m_Orient = Entry->m_Prefix.m_Orient;
|
|
|
|
DrawLibItem->m_Field[REFERENCE].m_Size = Entry->m_Prefix.m_Size;
|
|
|
|
DrawLibItem->m_Field[REFERENCE].m_Text = msg;
|
|
|
|
DrawLibItem->m_Field[REFERENCE].m_Attributs = Entry->m_Prefix.m_Attributs;
|
|
|
|
DrawLibItem->m_Field[REFERENCE].m_HJustify = Entry->m_Prefix.m_HJustify;
|
|
|
|
DrawLibItem->m_Field[REFERENCE].m_VJustify = Entry->m_Prefix.m_VJustify;
|
|
|
|
|
|
|
|
/* Init des autres champs si predefinis dans la librairie */
|
|
|
|
for( Field = Entry->Fields; Field != NULL; Field = (LibDrawField*) Field->Pnext )
|
|
|
|
{
|
|
|
|
if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() )
|
|
|
|
continue;
|
|
|
|
ii = Field->m_FieldId;
|
|
|
|
if( ii < 2 )
|
|
|
|
continue;
|
|
|
|
if( ii >= NUMBER_OF_FIELDS )
|
|
|
|
continue;
|
|
|
|
DrawLibItem->m_Field[ii].m_Pos.x += Field->m_Pos.x;
|
|
|
|
DrawLibItem->m_Field[ii].m_Pos.y += Field->m_Pos.y;
|
|
|
|
DrawLibItem->m_Field[ii].m_Size = Field->m_Size;
|
|
|
|
DrawLibItem->m_Field[ii].m_Attributs = Field->m_Attributs;
|
|
|
|
DrawLibItem->m_Field[ii].m_Orient = Field->m_Orient;
|
|
|
|
DrawLibItem->m_Field[ii].m_Text = Field->m_Text;
|
|
|
|
DrawLibItem->m_Field[ii].m_Name = Field->m_Name;
|
|
|
|
DrawLibItem->m_Field[ii].m_HJustify = Field->m_HJustify;
|
|
|
|
DrawLibItem->m_Field[ii].m_VJustify = Field->m_VJustify;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Trace du composant */
|
|
|
|
DrawStructsInGhost( DrawPanel, DC, DrawLibItem, 0, 0 );
|
|
|
|
MsgPanel->EraseMsgBox();
|
|
|
|
DrawLibItem->Display_Infos( this );
|
|
|
|
|
|
|
|
return DrawLibItem;
|
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 deplacement du composant. ***/
|
|
|
|
/*** 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
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxPoint move_vector;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
EDA_SchComponentStruct* DrawLibItem = (EDA_SchComponentStruct*)
|
|
|
|
panel->m_Parent->m_CurrentScreen->GetCurItem();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/* Effacement du composant */
|
|
|
|
if( erase )
|
|
|
|
DrawStructsInGhost( panel, DC, DrawLibItem, 0, 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
move_vector.x = panel->m_Parent->m_CurrentScreen->m_Curseur.x - DrawLibItem->m_Pos.x;
|
|
|
|
move_vector.y = panel->m_Parent->m_CurrentScreen->m_Curseur.y - DrawLibItem->m_Pos.y;
|
|
|
|
MoveOneStruct( DrawLibItem, move_vector );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawStructsInGhost( panel, DC, DrawLibItem, 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(
|
2007-08-20 01:20:48 +00:00
|
|
|
EDA_SchComponentStruct* 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
|
|
|
|
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawComponent->SetRotationMiroir( type_rotate );
|
|
|
|
|
|
|
|
/* Redessine le composant dans la nouvelle position */
|
|
|
|
if( DC )
|
|
|
|
{
|
|
|
|
if( DrawComponent->m_Flags )
|
|
|
|
DrawStructsInGhost( DrawPanel, DC, DrawComponent, 0, 0 );
|
|
|
|
else
|
|
|
|
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
|
|
|
DrawPanel->CursorOn( DC );
|
|
|
|
}
|
|
|
|
|
|
|
|
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
|
|
|
|
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
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
EDA_SchComponentStruct* DrawLibItem = (EDA_SchComponentStruct*)
|
|
|
|
Panel->m_Parent->m_CurrentScreen->GetCurItem();
|
|
|
|
|
|
|
|
if( DrawLibItem->m_Flags & IS_NEW ) /* Nouveau Placement en cours, on l'efface */
|
|
|
|
{
|
|
|
|
DrawStructsInGhost( Panel, DC, DrawLibItem, 0, 0 );
|
|
|
|
delete DrawLibItem;
|
|
|
|
}
|
|
|
|
else if( DrawLibItem ) /* Deplacement ancien composant en cours */
|
|
|
|
{
|
|
|
|
wxPoint move_vector;
|
|
|
|
DrawStructsInGhost( Panel, DC, DrawLibItem, 0, 0 );
|
|
|
|
|
|
|
|
move_vector.x = OldPos.x - DrawLibItem->m_Pos.x;
|
|
|
|
move_vector.y = OldPos.y - DrawLibItem->m_Pos.y;
|
|
|
|
|
|
|
|
MoveOneStruct( DrawLibItem, move_vector );
|
|
|
|
|
|
|
|
memcpy( DrawLibItem->m_Transform, OldTransMat, sizeof(OldTransMat) );
|
|
|
|
DrawLibItem->Draw( Panel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawLibItem->m_Flags = 0;
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
|
|
|
Panel->m_Parent->m_CurrentScreen->SetCurItem( NULL );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_SchematicFrame::SelPartUnit( EDA_SchComponentStruct* DrawComponent,
|
|
|
|
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
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
LibEntry = FindLibPart( DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
|
|
|
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 */
|
|
|
|
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
|
|
|
|
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
|
|
|
|
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
|
|
|
void WinEDA_SchematicFrame::ConvertPart( EDA_SchComponentStruct* DrawComponent,
|
|
|
|
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;
|
|
|
|
|
|
|
|
LibEntry = FindLibPart( DrawComponent->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
|
|
|
|
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
|
|
|
|
DrawComponent->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
|
|
|
|
|
|
|
TestDanglingEnds( m_CurrentScreen->EEDrawList, DC );
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_SchematicFrame::StartMovePart( EDA_SchComponentStruct* Component,
|
|
|
|
wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Component == NULL )
|
|
|
|
return;
|
2007-09-01 12:00:30 +00:00
|
|
|
if( Component->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if( Component->m_Flags == 0 )
|
|
|
|
{
|
|
|
|
if( g_ItemToUndoCopy )
|
|
|
|
delete g_ItemToUndoCopy;
|
|
|
|
g_ItemToUndoCopy = Component->GenCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->CursorOff( DC );
|
|
|
|
m_CurrentScreen->m_Curseur = Component->m_Pos;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = ShowWhileMoving;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = ExitPlaceCmp;
|
|
|
|
m_CurrentScreen->SetCurItem( Component );
|
|
|
|
OldPos = Component->m_Pos;
|
|
|
|
memcpy( OldTransMat, Component->m_Transform, sizeof(OldTransMat) );
|
|
|
|
|
|
|
|
RedrawOneStruct( DrawPanel, DC, Component, g_XorMode );
|
|
|
|
Component->m_Flags |= IS_MOVED;
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
DrawPanel->m_AutoPAN_Request = TRUE;
|
|
|
|
|
|
|
|
DrawPanel->CursorOn( DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|