Commit 3f6f3c7b authored by charras's avatar charras

eeschema bug fix: wires connected to a component non dragged in drag component command

parent fbcc2b30
...@@ -22,22 +22,22 @@ ...@@ -22,22 +22,22 @@
/* Fonctions exportees */ /* Fonctions exportees */
/* Fonctions Locales */ /* Fonctions Locales */
static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel, static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel,
wxDC* DC, wxDC* DC,
BASE_SCREEN* screen, BASE_SCREEN* screen,
SCH_ITEM* DrawStruct ); SCH_ITEM* DrawStruct );
static void CollectStructsToDrag( SCH_SCREEN* screen ); static void CollectStructsToDrag( SCH_SCREEN* screen );
static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition ); static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition );
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
wxPoint& aPosition ); wxPoint& aPosition );
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
wxDC* DC, wxDC* DC,
bool erase ); bool erase );
static SCH_ITEM* SaveStructListForPaste( SCH_ITEM* DrawStruct ); static SCH_ITEM* SaveStructListForPaste( SCH_ITEM* DrawStruct );
static bool MirrorStruct( WinEDA_DrawPanel* panel, wxDC* DC, static bool MirrorStruct( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_ITEM* DrawStruct, wxPoint& Center ); SCH_ITEM* DrawStruct, wxPoint& Center );
static void MirrorOneStruct( SCH_ITEM* DrawStruct, static void MirrorOneStruct( SCH_ITEM* DrawStruct,
wxPoint& Center ); wxPoint& Center );
/*************************************************************************/ /*************************************************************************/
int WinEDA_SchematicFrame::ReturnBlockCommand( int key ) int WinEDA_SchematicFrame::ReturnBlockCommand( int key )
...@@ -220,7 +220,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -220,7 +220,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
* -1 si commande terminee et composants trouves (block delete, block save) * -1 si commande terminee et composants trouves (block delete, block save)
*/ */
{ {
int ii = 0; int ii = 0;
bool zoom_command = FALSE; bool zoom_command = FALSE;
DrawBlockStruct* block = &GetScreen()->BlockLocate; DrawBlockStruct* block = &GetScreen()->BlockLocate;
...@@ -301,7 +301,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -301,7 +301,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
GetScreen()->m_Curseur = wxPoint( 0, 0 ); GetScreen()->m_Curseur = wxPoint( 0, 0 );
SCH_ITEM* DrawStructCopy = SCH_ITEM* DrawStructCopy =
SaveStructListForPaste( SaveStructListForPaste(
(SCH_ITEM*) block->m_BlockDrawStruct ); (SCH_ITEM*) block->m_BlockDrawStruct );
PlaceStruct( GetScreen(), DrawStructCopy ); PlaceStruct( GetScreen(), DrawStructCopy );
GetScreen()->m_Curseur = oldpos; GetScreen()->m_Curseur = oldpos;
ii = -1; ii = -1;
...@@ -640,14 +640,14 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center ) ...@@ -640,14 +640,14 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )
Hierarchical_PIN_Sheet_Struct* DrawSheetLabel; Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
DrawMarkerStruct* DrawMarker; DrawMarkerStruct* DrawMarker;
DrawNoConnectStruct* DrawNoConnect; DrawNoConnectStruct* DrawNoConnect;
SCH_TEXT* DrawText; SCH_TEXT* DrawText;
wxPoint px; wxPoint px;
WinEDA_SchematicFrame* frame; WinEDA_SchematicFrame* frame;
if( !DrawStruct ) if( !DrawStruct )
return; return;
frame = (WinEDA_SchematicFrame*)wxGetApp().GetTopWindow(); frame = (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
switch( DrawStruct->Type() ) switch( DrawStruct->Type() )
{ {
...@@ -869,7 +869,7 @@ static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel, ...@@ -869,7 +869,7 @@ static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel,
( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp(); ( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL ); ( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL );
} }
break; break;
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
{ {
...@@ -972,8 +972,8 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct ) ...@@ -972,8 +972,8 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
{ {
/* Cette stucture est rattachee a une feuille, et n'est pas /* Cette stucture est rattachee a une feuille, et n'est pas
* accessible par la liste globale directement */ * accessible par la liste globale directement */
frame->SaveCopyInUndoList( (SCH_ITEM*)( (Hierarchical_PIN_Sheet_Struct frame->SaveCopyInUndoList( (SCH_ITEM*) ( (Hierarchical_PIN_Sheet_Struct
*) DrawStruct )->GetParent(), *) DrawStruct )->GetParent(),
IS_CHANGED ); IS_CHANGED );
frame->DeleteSheetLabel( DC ? true : false, frame->DeleteSheetLabel( DC ? true : false,
(Hierarchical_PIN_Sheet_Struct*) DrawStruct ); (Hierarchical_PIN_Sheet_Struct*) DrawStruct );
...@@ -1405,7 +1405,7 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct ) ...@@ -1405,7 +1405,7 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct )
DrawStruct->Type() << wxT( " " ) << DrawStruct->GetClass(); DrawStruct->Type() << wxT( " " ) << DrawStruct->GetClass();
DisplayError( NULL, msg ); DisplayError( NULL, msg );
} }
break; break;
} }
NewDrawStruct->m_Image = DrawStruct; NewDrawStruct->m_Image = DrawStruct;
...@@ -1416,20 +1416,28 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct ) ...@@ -1416,20 +1416,28 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct )
/****************************************************/ /****************************************************/
static void CollectStructsToDrag( SCH_SCREEN* screen ) static void CollectStructsToDrag( SCH_SCREEN* screen )
/****************************************************/ /****************************************************/
/* creates the list of items found when a drag block is initiated.
* items are those slected in window block an some items outside this area but connected
* to a selected item (connected wires to a component or an entry )
*/
{ {
DrawPickedStruct* DrawStructs, * FirstPicked; DrawPickedStruct* DrawStructs, * FirstPicked;
SCH_ITEM* Struct; SCH_ITEM* Struct;
EDA_DrawLineStruct* SegmStruct; EDA_DrawLineStruct* SegmStruct;
int ox, oy, fx, fy; int ox, oy, fx, fy;
/* Set membre .m_Flags des segments */ /* .m_Flags member is used to handle how a wire is exactly slected
* (fully selected, or partially selected by an end point )
*/
for( Struct = screen->EEDrawList; Struct != NULL; Struct = Struct->Next() ) for( Struct = screen->EEDrawList; Struct != NULL; Struct = Struct->Next() )
Struct->m_Flags = 0; Struct->m_Flags = 0;
if( screen->BlockLocate.m_BlockDrawStruct->Type() == // Sel .m_Flags to selected for a wire or buss in selected area if there is only one item:
DRAW_SEGMENT_STRUCT_TYPE ) if( screen->BlockLocate.m_BlockDrawStruct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
screen->BlockLocate.m_BlockDrawStruct->m_Flags = SELECTED; screen->BlockLocate.m_BlockDrawStruct->m_Flags = SELECTED;
// Sel .m_Flags to selected for a wire or buss in selected area for a list of items:
else if( screen->BlockLocate.m_BlockDrawStruct->Type() == else if( screen->BlockLocate.m_BlockDrawStruct->Type() ==
DRAW_PICK_ITEM_STRUCT_TYPE ) DRAW_PICK_ITEM_STRUCT_TYPE )
{ {
...@@ -1437,7 +1445,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -1437,7 +1445,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
(DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
while( DrawStructs ) while( DrawStructs )
{ {
Struct = DrawStructs->m_PickedStruct; Struct = DrawStructs->m_PickedStruct;
DrawStructs = DrawStructs->Next(); DrawStructs = DrawStructs->Next();
Struct->m_Flags = SELECTED; Struct->m_Flags = SELECTED;
} }
...@@ -1456,13 +1464,15 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -1456,13 +1464,15 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
if( fy < oy ) if( fy < oy )
EXCHG( fy, oy ); EXCHG( fy, oy );
/* Pour Drag Block: remise sous forme de liste de structure, s'il n'y /* For drag block only:
* a qu'un seul element ( pour homogeneiser les traitements ulterieurs */ * If only one item, change for a list of one item
* in order to have always a list to handle.
*/
if( screen->BlockLocate.m_BlockDrawStruct->Type() != if( screen->BlockLocate.m_BlockDrawStruct->Type() !=
DRAW_PICK_ITEM_STRUCT_TYPE ) DRAW_PICK_ITEM_STRUCT_TYPE )
{ {
DrawStructs = new DrawPickedStruct( DrawStructs = new DrawPickedStruct(
(SCH_ITEM*) screen->BlockLocate.m_BlockDrawStruct ); (SCH_ITEM*) screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct = DrawStructs; screen->BlockLocate.m_BlockDrawStruct = DrawStructs;
} }
...@@ -1471,7 +1481,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -1471,7 +1481,7 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
while( DrawStructs ) while( DrawStructs )
{ {
Struct = DrawStructs->m_PickedStruct; Struct = DrawStructs->m_PickedStruct;
DrawStructs = DrawStructs->Next(); DrawStructs = DrawStructs->Next();
if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE ) if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
{ {
...@@ -1486,34 +1496,36 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -1486,34 +1496,36 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
} }
} }
/* Recherche des elements complementaires a "dragger", c'est a dire les /* Search for other items to drag. They are end wires connected to selected items
* fils et connexions hors bloc relies a des pins ou entries elles meme */
* draggees */
FirstPicked = DrawStructs = FirstPicked = DrawStructs =
(DrawPickedStruct*) screen->BlockLocate. (DrawPickedStruct*) screen->BlockLocate.
m_BlockDrawStruct; m_BlockDrawStruct;
while( DrawStructs ) while( DrawStructs )
{ {
Struct = DrawStructs->m_PickedStruct; Struct = DrawStructs->m_PickedStruct;
DrawStructs = DrawStructs->Next(); DrawStructs = DrawStructs->Next();
if( Struct->Type() == TYPE_SCH_COMPONENT ) if( Struct->Type() == TYPE_SCH_COMPONENT )
{ { // Add all pins of the selected component to list
LibEDA_BaseStruct* DrawItem; LibEDA_BaseStruct* DrawItem;
wxPoint pos; wxPoint pos;
DrawItem = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos ); DrawItem = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos );
while( DrawItem ) while( DrawItem )
{ {
if( (pos.x < ox) || (pos.x > fx) || (pos.y < oy) if( (pos.x < ox) || (pos.x > fx) || (pos.y < oy) || (pos.y > fy) )
|| (pos.y > fy) ) { // This pin is outside area,
// but because it it the pin of a selected component
// we must also select connected items to this pin
AddPickedItem( screen, pos ); AddPickedItem( screen, pos );
}
DrawItem = GetNextPinPosition( NULL, pos ); DrawItem = GetNextPinPosition( NULL, pos );
} }
} }
if( Struct->Type() == DRAW_SHEET_STRUCT_TYPE ) if( Struct->Type() == DRAW_SHEET_STRUCT_TYPE )
{ { // Add all pins sheets of a selected hierarchical sheet to the list
Hierarchical_PIN_Sheet_Struct* SLabel = Hierarchical_PIN_Sheet_Struct* SLabel =
( (DrawSheetStruct*) Struct )->m_Label; ( (DrawSheetStruct*) Struct )->m_Label;
while( SLabel ) while( SLabel )
...@@ -1545,7 +1557,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -1545,7 +1557,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
while( DrawStructs ) while( DrawStructs )
{ {
Struct = DrawStructs->m_PickedStruct; Struct = DrawStructs->m_PickedStruct;
DrawStructs = (DrawPickedStruct*) DrawStructs->Next(); DrawStructs = (DrawPickedStruct*) DrawStructs->Next();
switch( Struct->Type() ) switch( Struct->Type() )
...@@ -1705,13 +1717,25 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -1705,13 +1717,25 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
wxPoint& aPosition ) wxPoint& aPosition )
/*********************************************************************************/ /*********************************************************************************/
/** GetNextPinPosition()
* calculate position of the "next" pin of the aDrawLibItem component
* if aDrawLibItem is non null : search for the first pin
* if aDrawLibItem == NULL, search the next pin
* returns its position
* @param aDrawLibItem = component test. search for the first pin
* if NULL, serach for the next pin for each call
* @param aPosition = the calculated pin position, according to the component orientation and position
* @return a pointer to the pin
*/
{ {
EDA_LibComponentStruct* Entry; EDA_LibComponentStruct* Entry;
static LibEDA_BaseStruct* NextItem; static LibEDA_BaseStruct* NextItem;
static int Multi, convert, PartX, PartY, TransMat[2][2]; static int Multi, convert, TransMat[2][2];
LibEDA_BaseStruct* DEntry; LibEDA_BaseStruct* DEntry;
int orient; int orient;
LibDrawPin* Pin; LibDrawPin* Pin;
static wxPoint CmpPosition;
if( aDrawLibItem ) if( aDrawLibItem )
{ {
...@@ -1720,11 +1744,10 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, ...@@ -1720,11 +1744,10 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
FindLibPart( aDrawLibItem->m_ChipName.GetData(), wxEmptyString, FindLibPart( aDrawLibItem->m_ChipName.GetData(), wxEmptyString,
FIND_ROOT ) ) == NULL ) FIND_ROOT ) ) == NULL )
return NULL; return NULL;
DEntry = Entry->m_Drawings; DEntry = Entry->m_Drawings;
Multi = aDrawLibItem->m_Multi; Multi = aDrawLibItem->m_Multi;
convert = aDrawLibItem->m_Convert; convert = aDrawLibItem->m_Convert;
PartX = aDrawLibItem->m_Pos.x; CmpPosition = aDrawLibItem->m_Pos;
PartY = aDrawLibItem->m_Pos.y;
memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) ); memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) );
} }
else else
...@@ -1746,8 +1769,8 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, ...@@ -1746,8 +1769,8 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
orient = Pin->ReturnPinDrawOrient( TransMat ); orient = Pin->ReturnPinDrawOrient( TransMat );
/* Calcul de la position du point de reference */ /* Calcul de la position du point de reference */
aPosition = TransformCoordinate( TransMat, Pin->m_Pos); aPosition = TransformCoordinate( TransMat, Pin->m_Pos ) + CmpPosition;
NextItem = DEntry->Next(); NextItem = DEntry->Next();
return DEntry; return DEntry;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment