kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #23803
Re: PATCH: Unify mirror and copy block functions between schematic editor and library aditor
Hi guys,
I didn't have much time to figure out the rotation issue and may not be
able to investigate it much more in the following weeks.
So here are updated patches to unify the CopyBlock and the mirror function
but dont change anything about how rotation is handled.
If I find time to investigate the rotate block issue I'll submit another
patch in the future.
Regards,
Mikael
On Tue, Mar 1, 2016 at 4:17 PM, Wayne Stambaugh <stambaughw@xxxxxxxxx>
wrote:
> No problem. I hold of until you submit the patch with the rotate issue
> resolved.
>
> Thanks,
>
> Wayne
>
> On 3/1/2016 11:25 AM, Mikael Arguedas wrote:
> > Hi,
> >
> > Sorry about that, I'll update the patch to comply to the coding policy.
> > I'm currently investigating the rotate block function. It seems to be
> > working only is the selection rectangle lands on a pin location but
> > doesn't work otherwise. I'm trying to figure out why this appears only
> > for the rotate block function and not the others.
> >
> > Thanks for reviewing it.
> >
> > Cheers,
> > Mikael
> >
> > On Tue, Mar 1, 2016 at 6:56 AM, Wayne Stambaugh <stambaughw@xxxxxxxxx
> > <mailto:stambaughw@xxxxxxxxx>> wrote:
> >
> > Mikael,
> >
> > I just tested your patches and they do unify the block mirror
> behavior
> > but the rotate hot key (R) does not rotate a block in component
> library
> > editor. I would prefer that you fix that before I commit your
> patches.
> > Also, you have some copy policy violations (trailing white space,
> curly
> > bracket placement, and missing spaces between text and braces) in
> your
> > patch. Since it's your first patch, I will cut you some slack but in
> > the future please submit patches that to adhere to the coding
> policy[1].
> >
> > Cheers,
> >
> > Wayne
> >
> > [1]:
> >
> http://ci.kicad-pcb.org/job/kicad-doxygen/ws/Documentation/doxygen/html/md_Documentation_development_coding-style-policy.html
> >
> > On 2/24/2016 12:43 PM, Mikael Arguedas wrote:
> > > Hi guys,
> > >
> > > Here are two patches:
> > > unifyCopyBlock.patch: makes the CopyBlock function in library
> editor
> > > match the behaviour of the one in schematic editor
> > > addMirrorHotkeys.patch:
> > > - adds the HkMirrorX and HkMirrorY hotkeys to library editor
> > > - allor the HkRotate hotkey to rotate blocks and not only items
> > >
> > > Regards,
> > > Mikael
> > >
> > >
> > > _______________________________________________
> > > Mailing list: https://launchpad.net/~kicad-developers
> > > Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> > <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
> > > Unsubscribe : https://launchpad.net/~kicad-developers
> > > More help : https://help.launchpad.net/ListHelp
> > >
> >
> > _______________________________________________
> > Mailing list: https://launchpad.net/~kicad-developers
> > Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> > <mailto:kicad-developers@xxxxxxxxxxxxxxxxxxx>
> > Unsubscribe : https://launchpad.net/~kicad-developers
> > More help : https://help.launchpad.net/ListHelp
> >
> >
>
>
=== modified file 'eeschema/libeditframe.cpp'
--- eeschema/libeditframe.cpp 2016-01-16 23:51:56 +0000
+++ eeschema/libeditframe.cpp 2016-02-24 17:19:51 +0000
@@ -873,7 +873,7 @@
m_canvas->SetAutoPanRequest( false );
GetScreen()->m_BlockLocate.SetCommand( BLOCK_COPY );
m_canvas->MoveCursorToCrossHair();
- HandleBlockPlace( &dc );
+ HandleBlockEnd( &dc );
break;
case ID_POPUP_SELECT_ITEMS_BLOCK:
=== modified file 'eeschema/eeschema_id.h'
--- eeschema/eeschema_id.h 2016-01-29 10:24:39 +0000
+++ eeschema/eeschema_id.h 2016-03-01 16:37:06 +0000
@@ -209,7 +209,11 @@
ID_LIBEDIT_EXPORT_BODY_BUTT,
ID_LIBEDIT_DELETE_ITEM_BUTT,
+ /* Change orientation command ID */
ID_LIBEDIT_ROTATE_ITEM,
+ ID_LIBEDIT_MIRROR_X,
+ ID_LIBEDIT_MIRROR_Y,
+ ID_LIBEDIT_ORIENT_NORMAL,
/* Library editor context menu IDs */
ID_LIBEDIT_EDIT_PIN,
=== modified file 'eeschema/hotkeys.cpp'
--- eeschema/hotkeys.cpp 2016-01-29 14:43:40 +0000
+++ eeschema/hotkeys.cpp 2016-03-01 16:50:31 +0000
@@ -311,6 +311,8 @@
&HkCreatePin,
&HkInsertPin,
&HkMoveLibItem,
+ &HkMirrorX,
+ &HkMirrorY,
NULL
};
@@ -782,6 +784,17 @@
}
}
break;
+ case HK_MIRROR_Y: // Mirror Y
+ m_drawItem = LocateItemUsingCursor( aPosition );
+ cmd.SetId( ID_LIBEDIT_MIRROR_Y );
+ GetEventHandler()->ProcessEvent( cmd );
+ break;
+
+ case HK_MIRROR_X: // Mirror X
+ m_drawItem = LocateItemUsingCursor( aPosition );
+ cmd.SetId( ID_LIBEDIT_MIRROR_X );
+ GetEventHandler()->ProcessEvent( cmd );
+ break;
}
// Hot key handled.
=== modified file 'eeschema/libedit_onrightclick.cpp'
--- eeschema/libedit_onrightclick.cpp 2014-10-15 11:40:38 +0000
+++ eeschema/libedit_onrightclick.cpp 2016-03-01 16:43:57 +0000
@@ -320,6 +320,7 @@
void AddMenusForBlock( wxMenu* PopMenu, LIB_EDIT_FRAME* frame )
{
+ wxString msg;
AddMenuItem( PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _( "Cancel Block" ),
KiBitmap( cancel_xpm ) );
@@ -337,11 +338,14 @@
AddMenuItem( PopMenu, ID_POPUP_SELECT_ITEMS_BLOCK, _( "Select Items" ),
KiBitmap( green_xpm ) );
AddMenuItem( PopMenu, ID_POPUP_COPY_BLOCK, _( "Copy Block" ), KiBitmap( copyblock_xpm ) );
- AddMenuItem( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, _( "Mirror Block ||" ),
+ msg = AddHotkeyName( _( "Mirror Block ||" ), g_Libedit_Hokeys_Descr, HK_MIRROR_Y );
+ AddMenuItem( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, msg,
KiBitmap( mirror_h_xpm ) );
- AddMenuItem( PopMenu, ID_POPUP_MIRROR_X_BLOCK, _( "Mirror Block --" ),
+ msg = AddHotkeyName( _( "Mirror Block --" ), g_Libedit_Hokeys_Descr, HK_MIRROR_X );
+ AddMenuItem( PopMenu, ID_POPUP_MIRROR_X_BLOCK, msg,
KiBitmap( mirror_v_xpm ) );
- AddMenuItem( PopMenu, ID_POPUP_ROTATE_BLOCK, _( "Rotate Block ccw" ),
+ msg = AddHotkeyName( _( "Rotate Block CCW" ), g_Libedit_Hokeys_Descr, HK_ROTATE );
+ AddMenuItem( PopMenu, ID_POPUP_ROTATE_BLOCK, msg,
KiBitmap( rotate_ccw_xpm ) );
AddMenuItem( PopMenu, ID_POPUP_DELETE_BLOCK, _( "Delete Block" ), KiBitmap( delete_xpm ) );
}
=== modified file 'eeschema/libeditframe.cpp'
--- eeschema/libeditframe.cpp 2016-01-16 23:51:56 +0000
+++ eeschema/libeditframe.cpp 2016-03-15 16:50:37 +0000
@@ -150,6 +150,8 @@
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
LIB_EDIT_FRAME::Process_Special_Functions )
+ EVT_MENU_RANGE( ID_LIBEDIT_MIRROR_X, ID_LIBEDIT_ORIENT_NORMAL,
+ LIB_EDIT_FRAME::OnOrient )
// Update user interface elements.
EVT_UPDATE_UI( ExportPartId, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( CreateNewLibAndSavePartId, LIB_EDIT_FRAME::OnUpdateEditingPart )
@@ -1199,6 +1201,31 @@
}
+void LIB_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
+{
+ INSTALL_UNBUFFERED_DC( dc, m_canvas );
+ SCH_SCREEN* screen = GetScreen();
+ // Allows block rotate operation on hot key.
+ if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
+ {
+ if( aEvent.GetId() == ID_LIBEDIT_MIRROR_X )
+ {
+ m_canvas->MoveCursorToCrossHair();
+ screen->m_BlockLocate.SetMessageBlock( this );
+ screen->m_BlockLocate.SetCommand( BLOCK_MIRROR_X );
+ HandleBlockEnd( &dc );
+ }
+ else if( aEvent.GetId() == ID_LIBEDIT_MIRROR_Y )
+ {
+ m_canvas->MoveCursorToCrossHair();
+ screen->m_BlockLocate.SetMessageBlock( this );
+ screen->m_BlockLocate.SetCommand( BLOCK_MIRROR_Y );
+ HandleBlockEnd( &dc );
+ }
+ }
+}
+
+
LIB_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPosition,
const KICAD_T aFilterList[] )
{
=== modified file 'eeschema/libeditframe.h'
--- eeschema/libeditframe.h 2016-01-20 12:11:17 +0000
+++ eeschema/libeditframe.h 2016-03-01 17:09:32 +0000
@@ -510,6 +510,12 @@
void OnRotateItem( wxCommandEvent& aEvent );
/**
+ * Function OnOrient
+ * Handles the ID_LIBEDIT_MIRROR_X and ID_LIBEDIT_MIRROR_Y events.
+ */
+ void OnOrient( wxCommandEvent& aEvent );
+
+ /**
* Function deleteItem
* deletes the currently selected draw item.
* @param aDC The device context to draw upon when removing item.
Follow ups
References