From b700f7c248cb95fa66ee500eb07c2abef76e65bc Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 23 Dec 2010 11:00:55 +0100 Subject: [PATCH] fix bug 692240: a subtle bug in LIB_COMPONENT::LocateDrawItem() that destroys DefaultTransform matrix. --- eeschema/class_libentry.cpp | 19 ++----------------- eeschema/sch_component.cpp | 17 +++++++++-------- eeschema/schedit.cpp | 2 +- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index f69cb03611..93de037539 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -1361,27 +1361,12 @@ LIB_DRAW_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert, KICAD_T a * we temporary copy aTransMat in DefaultTransformMatrix */ LIB_DRAW_ITEM* item; - TRANSFORM transform; - - for ( int ii = 0; ii < 2; ii++ ) - { - for ( int jj = 0; jj < 2; jj++ ) - { - transform = DefaultTransform; - DefaultTransform = aTransform; - } - } + TRANSFORM transform = DefaultTransform; item = LocateDrawItem( aUnit, aConvert, aType, aPoint ); //Restore matrix - for ( int ii = 0; ii < 2; ii++ ) - { - for ( int jj = 0; jj < 2; jj++ ) - { - DefaultTransform = transform; - } - } + DefaultTransform = transform; return item; } diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 379cc4321c..1795bace79 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -685,40 +685,41 @@ void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheet ) void SCH_COMPONENT::SetOrientation( int aOrientation ) { + TRANSFORM temp = TRANSFORM(); bool Transform = false; switch( aOrientation ) { case CMP_ORIENT_0: - case CMP_NORMAL: /* Position Initiale */ + case CMP_NORMAL: // default transform matrix m_transform.x1 = 1; m_transform.y2 = -1; m_transform.x2 = m_transform.y1 = 0; break; - case CMP_ROTATE_CLOCKWISE: /* Rotate + */ + case CMP_ROTATE_CLOCKWISE: // Rotate + (incremental rotation) temp.x1 = temp.y2 = 0; temp.y1 = 1; temp.x2 = -1; Transform = true; break; - case CMP_ROTATE_COUNTERCLOCKWISE: /* Rotate - */ + case CMP_ROTATE_COUNTERCLOCKWISE: // Rotate - (incremental rotation) temp.x1 = temp.y2 = 0; temp.y1 = -1; temp.x2 = 1; Transform = true; break; - case CMP_MIRROR_Y: /* MirrorY */ + case CMP_MIRROR_Y: // Mirror Y (incremental rotation) temp.x1 = -1; temp.y2 = 1; temp.y1 = temp.x2 = 0; Transform = true; break; - case CMP_MIRROR_X: /* MirrorX */ + case CMP_MIRROR_X: // Mirror X (incremental rotation) temp.x1 = 1; temp.y2 = -1; temp.y1 = temp.x2 = 0; @@ -790,14 +791,14 @@ void SCH_COMPONENT::SetOrientation( int aOrientation ) if( Transform ) { /* The new matrix transform is the old matrix transform modified by the - * requested transformation, which is the TempMat transform (rot, + * requested transformation, which is the temp transform (rot, * mirror ..) in order to have (in term of matrix transform): * transform coord = new_m_transform * coord * where transform coord is the coord modified by new_m_transform from * the initial value coord. - * new_m_transform is computed (from old_m_transform and TempMat) to + * new_m_transform is computed (from old_m_transform and temp) to * have: - * transform coord = old_m_transform * coord * TempMat + * transform coord = old_m_transform * temp */ TRANSFORM newTransform; diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index a024327ea2..507e20eee3 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -381,7 +381,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_IMPORT_GLABEL: if( screen->GetCurItem() && screen->GetCurItem()->Type() == SCH_SHEET_T ) - GetScreen()->SetCurItem( Import_PinSheet( (SCH_SHEET*) screen->GetCurItem(), &dc ) ); + screen->SetCurItem( Import_PinSheet( (SCH_SHEET*) screen->GetCurItem(), &dc ) ); break; case ID_POPUP_SCH_CLEANUP_SHEET: