From f81c237d43dce3c728ee34d7904285279f8201cc Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 20 May 2011 20:29:35 +0200 Subject: [PATCH] Libedit: add block rotate and block mirror horizontally --- eeschema/block_libedit.cpp | 27 +++++++++++++++++------ eeschema/class_libentry.cpp | 32 +++++++++++++++++++++++++++ eeschema/class_libentry.h | 14 ++++++++++++ eeschema/lib_arc.cpp | 22 +++++++++++++++++++ eeschema/lib_arc.h | 2 ++ eeschema/lib_bezier.cpp | 36 +++++++++++++++++++++++++++++++ eeschema/lib_bezier.h | 2 ++ eeschema/lib_circle.cpp | 12 +++++++++++ eeschema/lib_circle.h | 2 ++ eeschema/lib_draw_item.h | 22 +++++++++++++++++++ eeschema/lib_field.cpp | 12 +++++++++++ eeschema/lib_field.h | 2 ++ eeschema/lib_pin.cpp | 35 ++++++++++++++++++++++++++++++ eeschema/lib_pin.h | 2 ++ eeschema/lib_polyline.cpp | 22 +++++++++++++++++++ eeschema/lib_polyline.h | 2 ++ eeschema/lib_rectangle.cpp | 16 ++++++++++++++ eeschema/lib_rectangle.h | 2 ++ eeschema/lib_text.cpp | 15 ++++++++++++- eeschema/lib_text.h | 2 ++ eeschema/libedit_onrightclick.cpp | 2 ++ eeschema/libedit_undo_redo.cpp | 7 ++---- eeschema/libeditframe.cpp | 16 ++++++++++++++ 23 files changed, 294 insertions(+), 12 deletions(-) diff --git a/eeschema/block_libedit.cpp b/eeschema/block_libedit.cpp index eaf22f6cdc..9c41c4df33 100644 --- a/eeschema/block_libedit.cpp +++ b/eeschema/block_libedit.cpp @@ -140,12 +140,12 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) case BLOCK_SAVE: /* Save */ case BLOCK_PASTE: - case BLOCK_ROTATE: - case BLOCK_MIRROR_X: case BLOCK_FLIP: break; + case BLOCK_ROTATE: + case BLOCK_MIRROR_X: case BLOCK_MIRROR_Y: if ( m_component ) ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate, @@ -158,7 +158,13 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) if ( m_component ) { OnModify(); - m_component->MirrorSelectedItemsH( pt ); + int block_cmd = GetScreen()->m_BlockLocate.m_Command; + if( block_cmd == BLOCK_MIRROR_Y) + m_component->MirrorSelectedItemsH( pt ); + else if( block_cmd == BLOCK_MIRROR_X) + m_component->MirrorSelectedItemsV( pt ); + else if( block_cmd == BLOCK_ROTATE) + m_component->RotateSelectedItems( pt ); } break; @@ -240,19 +246,28 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) GetScreen()->m_BlockLocate.ClearItemsList(); break; - case BLOCK_MIRROR_Y: /* Invert by popup menu, from block move */ + case BLOCK_ROTATE: // Invert by popup menu, from block move + case BLOCK_MIRROR_X: // Invert by popup menu, from block move + case BLOCK_MIRROR_Y: // Invert by popup menu, from block move if ( m_component ) SaveCopyInUndoList( m_component ); pt = GetScreen()->m_BlockLocate.Centre(); pt.y *= -1; if ( m_component ) - m_component->MirrorSelectedItemsH( pt ); + { + int block_cmd = GetScreen()->m_BlockLocate.m_Command; + if( block_cmd == BLOCK_MIRROR_Y) + m_component->MirrorSelectedItemsH( pt ); + else if( block_cmd == BLOCK_MIRROR_X) + m_component->MirrorSelectedItemsV( pt ); + else if( block_cmd == BLOCK_ROTATE ) + m_component->RotateSelectedItems( pt ); + } break; case BLOCK_ZOOM: // Handled by HandleBlockEnd case BLOCK_DELETE: case BLOCK_SAVE: - case BLOCK_ROTATE: case BLOCK_ABORT: default: break; diff --git a/eeschema/class_libentry.cpp b/eeschema/class_libentry.cpp index 08bc716d8a..77785078d9 100644 --- a/eeschema/class_libentry.cpp +++ b/eeschema/class_libentry.cpp @@ -1215,7 +1215,10 @@ bool LIB_COMPONENT::HasConversion() const void LIB_COMPONENT::ClearStatus() { BOOST_FOREACH( LIB_ITEM& item, drawings ) + { item.m_Flags = 0; + item.m_Selected = 0; + } } @@ -1346,6 +1349,35 @@ void LIB_COMPONENT::MirrorSelectedItemsH( const wxPoint& aCenter ) drawings.sort(); } +void LIB_COMPONENT::MirrorSelectedItemsV( const wxPoint& aCenter ) +{ + BOOST_FOREACH( LIB_ITEM& item, drawings ) + { + if( item.m_Selected == 0 ) + continue; + + item.MirrorVertical( aCenter ); + item.m_Flags = item.m_Selected = 0; + } + + drawings.sort(); +} + +void LIB_COMPONENT::RotateSelectedItems( const wxPoint& aCenter ) +{ + BOOST_FOREACH( LIB_ITEM& item, drawings ) + { + if( item.m_Selected == 0 ) + continue; + + item.Rotate( aCenter ); + item.m_Flags = item.m_Selected = 0; + } + + drawings.sort(); +} + + LIB_ITEM* LIB_COMPONENT::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType, const wxPoint& aPoint ) diff --git a/eeschema/class_libentry.h b/eeschema/class_libentry.h index 1e674013fc..32ef0830a5 100644 --- a/eeschema/class_libentry.h +++ b/eeschema/class_libentry.h @@ -512,6 +512,20 @@ public: */ void MirrorSelectedItemsH( const wxPoint& aCenter ); + /** + * Vertically (Y axis) mirror selected draw items about a point. + * + * @param aCenter - Center point to mirror around. + */ + void MirrorSelectedItemsV( const wxPoint& aCenter ); + + /** + * Rotate CCW selected draw items about a point. + * + * @param aCenter - Center point to mirror around. + */ + void RotateSelectedItems( const wxPoint& aCenter ); + /** * Locate a draw object. * diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index 7e269c6f69..2360503782 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -277,6 +277,28 @@ void LIB_ARC::DoMirrorHorizontal( const wxPoint& aCenter ) EXCHG( m_ArcStart, m_ArcEnd ); } +void LIB_ARC::DoMirrorVertical( const wxPoint& aCenter ) +{ + m_Pos.y -= aCenter.y; + m_Pos.y *= -1; + m_Pos.y += aCenter.y; + m_ArcStart.y -= aCenter.y; + m_ArcStart.y *= -1; + m_ArcStart.y += aCenter.y; + m_ArcEnd.y -= aCenter.y; + m_ArcEnd.y *= -1; + m_ArcEnd.y += aCenter.y; + EXCHG( m_ArcStart, m_ArcEnd ); +} + +void LIB_ARC::DoRotate( const wxPoint& aCenter ) +{ + RotatePoint( &m_Pos, aCenter, -900 ); + RotatePoint( &m_ArcStart, aCenter, -900 ); + RotatePoint( &m_ArcEnd, aCenter, -900 ); +} + + void LIB_ARC::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) diff --git a/eeschema/lib_arc.h b/eeschema/lib_arc.h index e96460e78a..86846562bf 100644 --- a/eeschema/lib_arc.h +++ b/eeschema/lib_arc.h @@ -141,6 +141,8 @@ protected: virtual void DoMove( const wxPoint& aPosition ); virtual wxPoint DoGetPosition() const { return m_Pos; } virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoMirrorVertical( const wxPoint& aCenter ); + virtual void DoRotate( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ); virtual int DoGetWidth() const { return m_Width; } diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index 7fc8244009..680156a24f 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -190,6 +190,42 @@ void LIB_BEZIER::DoMirrorHorizontal( const wxPoint& aCenter ) } } +void LIB_BEZIER::DoMirrorVertical( const wxPoint& aCenter ) +{ + size_t i, imax = m_PolyPoints.size(); + + for( i = 0; i < imax; i++ ) + { + m_PolyPoints[i].y -= aCenter.y; + m_PolyPoints[i].y *= -1; + m_PolyPoints[i].y += aCenter.y; + } + + imax = m_BezierPoints.size(); + for( i = 0; i < imax; i++ ) + { + m_BezierPoints[i].y -= aCenter.y; + m_BezierPoints[i].y *= -1; + m_BezierPoints[i].y += aCenter.y; + } +} + +void LIB_BEZIER::DoRotate( const wxPoint& aCenter ) +{ + size_t i, imax = m_PolyPoints.size(); + + for( i = 0; i < imax; i++ ) + { + RotatePoint( &m_PolyPoints[i], aCenter, -900 ); + } + + imax = m_BezierPoints.size(); + for( i = 0; i < imax; i++ ) + { + RotatePoint( &m_BezierPoints[i], aCenter, -900 ); + } +} + void LIB_BEZIER::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) diff --git a/eeschema/lib_bezier.h b/eeschema/lib_bezier.h index 71c427475c..3f2c5a2a53 100644 --- a/eeschema/lib_bezier.h +++ b/eeschema/lib_bezier.h @@ -93,6 +93,8 @@ protected: virtual void DoMove( const wxPoint& aPosition ); virtual wxPoint DoGetPosition() const { return m_PolyPoints[0]; } virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoMirrorVertical( const wxPoint& aCenter ); + virtual void DoRotate( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ); virtual int DoGetWidth() const { return m_Width; } diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index 6bb70966cb..a00aef2c4f 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -162,6 +162,18 @@ void LIB_CIRCLE::DoMirrorHorizontal( const wxPoint& aCenter ) m_Pos.x += aCenter.x; } +void LIB_CIRCLE::DoMirrorVertical( const wxPoint& aCenter ) +{ + m_Pos.y -= aCenter.y; + m_Pos.y *= -1; + m_Pos.y += aCenter.y; +} + +void LIB_CIRCLE::DoRotate( const wxPoint& aCenter ) +{ + RotatePoint( &m_Pos, aCenter, -900 ); +} + void LIB_CIRCLE::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) diff --git a/eeschema/lib_circle.h b/eeschema/lib_circle.h index be4d1783b5..bf3ae2fd90 100644 --- a/eeschema/lib_circle.h +++ b/eeschema/lib_circle.h @@ -109,6 +109,8 @@ protected: virtual void DoMove( const wxPoint& aPosition ); virtual wxPoint DoGetPosition() const { return m_Pos; } virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoMirrorVertical( const wxPoint& aCenter ); + virtual void DoRotate( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ); virtual int DoGetWidth() const { return m_Width; } diff --git a/eeschema/lib_draw_item.h b/eeschema/lib_draw_item.h index 6128ab8bd5..5447d0002d 100644 --- a/eeschema/lib_draw_item.h +++ b/eeschema/lib_draw_item.h @@ -299,6 +299,26 @@ public: DoMirrorHorizontal( aCenter ); } + /** + * Mirror the draw object along the MirrorVertical (Y) axis about a point. + * + * @param aCenter - Point to mirror around. + */ + void MirrorVertical( const wxPoint& aCenter ) + { + DoMirrorVertical( aCenter ); + } + + /** + * Rotate about a point. + * + * @param aCenter - Point to mirror around. + */ + void Rotate( const wxPoint& aCenter ) + { + DoRotate( aCenter ); + } + /** * Rotate the draw item. */ @@ -377,6 +397,8 @@ protected: virtual void DoMove( const wxPoint& aPosition ) = 0; virtual wxPoint DoGetPosition() const = 0; virtual void DoMirrorHorizontal( const wxPoint& aCenter ) = 0; + virtual void DoMirrorVertical( const wxPoint& aCenter ) = 0; + virtual void DoRotate( const wxPoint& aCenter ) = 0; virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) = 0; virtual int DoGetWidth() const = 0; diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 3f845cbfc1..e9d6c55c0a 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -476,6 +476,18 @@ void LIB_FIELD::DoMirrorHorizontal( const wxPoint& center ) m_Pos.x += center.x; } +void LIB_FIELD::DoMirrorVertical( const wxPoint& center ) +{ + m_Pos.y -= center.y; + m_Pos.y *= -1; + m_Pos.y += center.y; +} + +void LIB_FIELD::DoRotate( const wxPoint& center ) +{ + RotatePoint( &m_Pos, center, -900 ); +} + void LIB_FIELD::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const TRANSFORM& aTransform ) diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index 1fffc8bba3..b36c1c0bec 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -245,6 +245,8 @@ protected: virtual void DoMove( const wxPoint& newPosition ); virtual wxPoint DoGetPosition( void ) const { return m_Pos; } virtual void DoMirrorHorizontal( const wxPoint& center ); + virtual void DoMirrorVertical( const wxPoint& aCenter ); + virtual void DoRotate( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const TRANSFORM& aTransform ); virtual int DoGetWidth( void ) const { return m_Thickness; } diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index affec60500..02a483d4bf 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1673,6 +1673,41 @@ void LIB_PIN::DoMirrorHorizontal( const wxPoint& center ) m_orientation = PIN_RIGHT; } +void LIB_PIN::DoMirrorVertical( const wxPoint& center ) +{ + m_position.y -= center.y; + m_position.y *= -1; + m_position.y += center.y; + + if( m_orientation == PIN_UP ) + m_orientation = PIN_DOWN; + else if( m_orientation == PIN_DOWN ) + m_orientation = PIN_UP; +} + +void LIB_PIN::DoRotate( const wxPoint& center ) +{ + RotatePoint( &m_position, center, -900 ); + + switch( m_orientation ) + { + case PIN_RIGHT: + m_orientation = PIN_UP; + break; + + case PIN_UP: + m_orientation = PIN_LEFT; + break; + case PIN_LEFT: + m_orientation = PIN_DOWN; + break; + + case PIN_DOWN: + m_orientation = PIN_RIGHT; + break; + } +} + void LIB_PIN::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const TRANSFORM& aTransform ) diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index a13cc49376..a482bd1bd0 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -472,6 +472,8 @@ protected: virtual void DoMove( const wxPoint& aPosition ); virtual wxPoint DoGetPosition() const { return m_position; } virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoMirrorVertical( const wxPoint& aCenter ); + virtual void DoRotate( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ); virtual int DoGetWidth() const { return m_width; } diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 39916b334f..b352661d90 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -177,6 +177,28 @@ void LIB_POLYLINE::DoMirrorHorizontal( const wxPoint& aCenter ) } } +void LIB_POLYLINE::DoMirrorVertical( const wxPoint& aCenter ) +{ + size_t i, imax = m_PolyPoints.size(); + + for( i = 0; i < imax; i++ ) + { + m_PolyPoints[i].y -= aCenter.y; + m_PolyPoints[i].y *= -1; + m_PolyPoints[i].y += aCenter.y; + } +} + +void LIB_POLYLINE::DoRotate( const wxPoint& aCenter ) +{ + size_t i, imax = m_PolyPoints.size(); + + for( i = 0; i < imax; i++ ) + { + RotatePoint( &m_PolyPoints[i], aCenter, -900 ); + } +} + void LIB_POLYLINE::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) diff --git a/eeschema/lib_polyline.h b/eeschema/lib_polyline.h index 2cbe75bbf6..d3c2942cdf 100644 --- a/eeschema/lib_polyline.h +++ b/eeschema/lib_polyline.h @@ -126,6 +126,8 @@ protected: virtual void DoMove( const wxPoint& aPosition ); virtual wxPoint DoGetPosition() const { return m_PolyPoints[0]; } virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoMirrorVertical( const wxPoint& aCenter ); + virtual void DoRotate( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ); virtual int DoGetWidth() const { return m_Width; } diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index eb25fef4d4..a3c8e633f3 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -132,6 +132,22 @@ void LIB_RECTANGLE::DoMirrorHorizontal( const wxPoint& aCenter ) m_End.x += aCenter.x; } +void LIB_RECTANGLE::DoMirrorVertical( const wxPoint& aCenter ) +{ + m_Pos.y -= aCenter.y; + m_Pos.y *= -1; + m_Pos.y += aCenter.y; + m_End.y -= aCenter.y; + m_End.y *= -1; + m_End.y += aCenter.y; +} + +void LIB_RECTANGLE::DoRotate( const wxPoint& aCenter ) +{ + RotatePoint( &m_Pos, aCenter, -900 ); + RotatePoint( &m_End, aCenter, -900 ); +} + void LIB_RECTANGLE::DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) diff --git a/eeschema/lib_rectangle.h b/eeschema/lib_rectangle.h index bfe41bab3c..a2a87ac3ba 100644 --- a/eeschema/lib_rectangle.h +++ b/eeschema/lib_rectangle.h @@ -116,6 +116,8 @@ protected: virtual void DoMove( const wxPoint& aPosition ); virtual wxPoint DoGetPosition() const { return m_Pos; } virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoMirrorVertical( const wxPoint& aCenter ); + virtual void DoRotate( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ); virtual int DoGetWidth() const { return m_Width; } diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 8061c642f2..db0da60f16 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -1,5 +1,5 @@ /***************************/ -/* class_BodyItem_Text.cpp */ +/* lib_text.cpp */ /***************************/ /** @@ -264,6 +264,19 @@ void LIB_TEXT::DoMirrorHorizontal( const wxPoint& center ) m_Pos.x += center.x; } +void LIB_TEXT::DoMirrorVertical( const wxPoint& center ) +{ + m_Pos.y -= center.y; + m_Pos.y *= -1; + m_Pos.y += center.y; +} + +void LIB_TEXT::DoRotate( const wxPoint& center ) +{ + RotatePoint( &m_Pos, center, -900 ); + m_Orient = m_Orient ? 0 : 900; +} + void LIB_TEXT::DoPlot( PLOTTER* plotter, const wxPoint& offset, bool fill, const TRANSFORM& aTransform ) diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index dc9e926eee..27551c1b39 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -141,6 +141,8 @@ protected: virtual void DoMove( const wxPoint& aPosition ); virtual wxPoint DoGetPosition() const { return m_Pos; } virtual void DoMirrorHorizontal( const wxPoint& aCenter ); + virtual void DoMirrorVertical( const wxPoint& aCenter ); + virtual void DoRotate( const wxPoint& aCenter ); virtual void DoPlot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ); virtual int DoGetWidth() const { return m_Thickness; } diff --git a/eeschema/libedit_onrightclick.cpp b/eeschema/libedit_onrightclick.cpp index 007da67efe..d8fe14a288 100644 --- a/eeschema/libedit_onrightclick.cpp +++ b/eeschema/libedit_onrightclick.cpp @@ -299,6 +299,8 @@ void AddMenusForBlock( wxMenu* PopMenu, LIB_EDIT_FRAME* frame ) ADD_MENUITEM( PopMenu, ID_POPUP_SELECT_ITEMS_BLOCK, _( "Select Items" ), green_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_COPY_BLOCK, _( "Copy Block" ), copyblock_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, _( "Mirror Block ||" ), mirror_H_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_MIRROR_X_BLOCK, _( "Mirror Block --" ), mirror_V_xpm ); + ADD_MENUITEM( PopMenu, ID_POPUP_ROTATE_BLOCK, _( "Rotate Block ccw" ), rotate_pos_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_DELETE_BLOCK, _( "Delete Block" ), delete_xpm ); } } diff --git a/eeschema/libedit_undo_redo.cpp b/eeschema/libedit_undo_redo.cpp index 3944d36334..dfb7af9d9c 100644 --- a/eeschema/libedit_undo_redo.cpp +++ b/eeschema/libedit_undo_redo.cpp @@ -19,17 +19,14 @@ void LIB_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* ItemToCopy, int unused_flag ) CopyItem = new LIB_COMPONENT( *( (LIB_COMPONENT*) ItemToCopy ) ); - if( CopyItem == NULL ) - return; + // Clear current flags (which can be temporary set by a current edit command). + CopyItem->ClearStatus(); lastcmd = new PICKED_ITEMS_LIST(); ITEM_PICKER wrapper( CopyItem, UR_LIBEDIT ); lastcmd->PushItem(wrapper); GetScreen()->PushCommandToUndoList( lastcmd ); - // Clear current flags (which can be temporary set by a current edit command). - CopyItem->ClearStatus(); - // Clear redo list, because after new save there is no redo to do. GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList ); } diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 6b8848fed6..18a5c9c75b 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -626,7 +626,9 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_DELETE_BLOCK: case ID_POPUP_COPY_BLOCK: case ID_POPUP_SELECT_ITEMS_BLOCK: + case ID_POPUP_MIRROR_X_BLOCK: case ID_POPUP_MIRROR_Y_BLOCK: + case ID_POPUP_ROTATE_BLOCK: case ID_POPUP_PLACE_BLOCK: case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT: break; @@ -806,6 +808,20 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) HandleBlockPlace( &dc ); break; + case ID_POPUP_MIRROR_X_BLOCK: + DrawPanel->m_AutoPAN_Request = false; + GetScreen()->m_BlockLocate.m_Command = BLOCK_MIRROR_X; + DrawPanel->MoveCursorToCrossHair(); + HandleBlockPlace( &dc ); + break; + + case ID_POPUP_ROTATE_BLOCK: + DrawPanel->m_AutoPAN_Request = false; + GetScreen()->m_BlockLocate.m_Command = BLOCK_ROTATE; + DrawPanel->MoveCursorToCrossHair(); + HandleBlockPlace( &dc ); + break; + case ID_POPUP_PLACE_BLOCK: DrawPanel->m_AutoPAN_Request = false; DrawPanel->MoveCursorToCrossHair();