Commit ffa9feda authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Schematic component library editor rotate item improvements.

* Merge three separate rotate code paths into a single rotate item function.
* Reduce three separate rotate command IDs into a single rotate command ID.
* Move pin rotate code into pin object.
parent bc8f250b
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -166,9 +166,10 @@ enum id_eeschema_frm
	ID_LIBEDIT_EXPORT_BODY_BUTT,
	ID_LIBEDIT_DELETE_ITEM_BUTT,

	ID_LIBEDIT_ROTATE_ITEM,

    /* Library editor context menu IDs */
	ID_LIBEDIT_EDIT_PIN,
	ID_LIBEDIT_ROTATE_PIN,
	ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM,
	ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM,
	ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM,
@@ -180,9 +181,7 @@ enum id_eeschema_frm
	ID_POPUP_LIBEDIT_CANCEL_EDITING,
	ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
	ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM,
	ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM,
	ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT,
	ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT,

    /* Library editor menubar IDs */
    ID_LIBEDIT_SAVE_CURRENT_LIB_AS,
+17 −29
Original line number Diff line number Diff line
@@ -959,6 +959,7 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
         break;

    case HK_EDIT:
        if( itemInEdit )
            m_drawItem = LocateItemUsingCursor( aPosition );

        if( m_drawItem )
@@ -991,30 +992,13 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
        break;

    case HK_ROTATE:
        if( m_drawItem == NULL )
            m_drawItem = LocateItemUsingCursor( aPosition );

        if( m_drawItem )
        {
            switch( m_drawItem->Type() )
            {
            case LIB_PIN_T:
                cmd.SetId( ID_LIBEDIT_ROTATE_PIN );
                GetEventHandler()->ProcessEvent( cmd );
                break;

            case LIB_TEXT_T:
                cmd.SetId( ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT );
                GetEventHandler()->ProcessEvent( cmd );
                break;

            case LIB_FIELD_T:
                cmd.SetId( ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM );
            cmd.SetId( ID_LIBEDIT_ROTATE_ITEM );
            GetEventHandler()->ProcessEvent( cmd );
                break;

            default:
                break;
            }
        }
        break;

@@ -1024,6 +1008,7 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
        break;

    case HK_DELETE:
        if( !itemInEdit )
            m_drawItem = LocateItemUsingCursor( aPosition );

        if( m_drawItem && !m_drawItem->InEditMode() )
@@ -1035,14 +1020,17 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
        break;

    case HK_LIBEDIT_MOVE_GRAPHIC_ITEM:
        if( !itemInEdit )
        {
            m_drawItem = LocateItemUsingCursor( aPosition );

        if( m_drawItem && !m_drawItem->InEditMode() )
            if( m_drawItem )
            {
                wxCommandEvent evt;
                evt.SetId( ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST );
                Process_Special_Functions( evt );
            }
        }
        break;

    case HK_DRAG:
+15 −0
Original line number Diff line number Diff line
@@ -1798,6 +1798,21 @@ int LIB_PIN::GetOrientationCodeIndex( int code )
}


void LIB_PIN::Rotate()
{
	// Get the actual pin orientation index
	int i = GetOrientationCodeIndex( GetOrientation() );

	// Compute the next orientation, swap lower two bits for the right order
	i = ((i & 2) >> 1) | ((i & 1) << 1);
	i = i + 1;
	i = ((i & 2) >> 1) | ((i & 1) << 1);

	// Set the new orientation
	SetOrientation( GetOrientationCode( i ) );
}


wxArrayString LIB_PIN::GetStyleNames( void )
{
    wxArrayString tmp;
+9 −7
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ public:

    /**
     * Function ReturnPinDrawOrient
 * Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT),
     * returns the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT),
     * according to its orientation and the matrix transform (rot, mirror) \a aTransform
     * @param aTransform = transform matrix
     */
@@ -243,6 +243,8 @@ public:
     */
    void SetOrientation( int aOrientation );

    void Rotate();

    int GetShape() const { return m_shape; }

    /**
+3 −1
Original line number Diff line number Diff line
@@ -83,7 +83,9 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
        break;

    case ID_LIBEDIT_DELETE_ITEM_BUTT:
        if( LocateItemUsingCursor( aPosition ) )
        m_drawItem = LocateItemUsingCursor( aPosition );

        if( m_drawItem )
            deleteItem( DC );
        else
            DisplayCmpDoc();
Loading