Commit bd022c23 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Libedit: fixed draw artefacts when editing a graphic symbol. fixed minor...

Libedit: fixed draw artefacts when editing a graphic symbol. fixed minor issues in undo and abort commands when editing graphic items.
parent 0c24113d
Loading
Loading
Loading
Loading
+2 −6
Original line number Original line Diff line number Diff line
@@ -785,11 +785,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawSt
    case HK_REPEAT_LAST:
    case HK_REPEAT_LAST:
        if( m_lastDrawItem && (m_lastDrawItem->m_Flags == 0)
        if( m_lastDrawItem && (m_lastDrawItem->m_Flags == 0)
           && ( m_lastDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) )
           && ( m_lastDrawItem->Type() == COMPONENT_PIN_DRAW_TYPE ) )
        {
            RepeatPinItem( DC, (LIB_PIN*) m_lastDrawItem );
            RepeatPinItem( DC, (LIB_PIN*) m_lastDrawItem );
        }
        else
            wxBell();
         break;
         break;


    case HK_EDIT:
    case HK_EDIT:
@@ -827,7 +823,7 @@ void WinEDA_LibeditFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawSt
    case HK_ROTATE:
    case HK_ROTATE:
        m_drawItem = LocateItemUsingCursor();
        m_drawItem = LocateItemUsingCursor();


        if( m_drawItem && !m_drawItem->InEditMode() )
        if( m_drawItem )
        {
        {
            switch( m_drawItem->Type() )
            switch( m_drawItem->Type() )
            {
            {
+0 −1
Original line number Original line Diff line number Diff line
@@ -75,7 +75,6 @@ void WinEDA_LibeditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
            }
            }
            else
            else
            {
            {
                SaveCopyInUndoList( m_component );
                PlacePin( DC );
                PlacePin( DC );
            }
            }
            break;
            break;
+14 −24
Original line number Original line Diff line number Diff line
@@ -816,53 +816,31 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
    case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT:
    case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT:
        if( m_drawItem == NULL && m_drawItem->Type() != COMPONENT_GRAPHIC_TEXT_DRAW_TYPE )
        if( m_drawItem == NULL && m_drawItem->Type() != COMPONENT_GRAPHIC_TEXT_DRAW_TYPE )
            break;
            break;
        DrawPanel->CursorOff( &dc );
        DrawPanel->MouseToCursorSchema();
        DrawPanel->MouseToCursorSchema();
        if( !m_drawItem->InEditMode() )
        if( !m_drawItem->InEditMode() )
        {
        {
            SaveCopyInUndoList( m_component );
            SaveCopyInUndoList( m_component );
            m_drawItem->SetUnit( m_unit );
            m_drawItem->SetUnit( m_unit );
            m_drawItem->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
                              DefaultTransform );
        }
        }


        m_drawItem->Rotate();
        m_drawItem->Rotate();

        if( !m_drawItem->InEditMode() )
        {
            m_drawItem->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
                              DefaultTransform );
        DrawPanel->Refresh();
        DrawPanel->Refresh();
        }

        DrawPanel->CursorOn( &dc );
        break;
        break;


    case ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM:
    case ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM:
    {
    {
        if( m_drawItem == NULL || ( m_drawItem->Type() != COMPONENT_FIELD_DRAW_TYPE ) )
        if( m_drawItem == NULL || ( m_drawItem->Type() != COMPONENT_FIELD_DRAW_TYPE ) )
            break;
            break;
        DrawPanel->CursorOff( &dc );
        DrawPanel->MouseToCursorSchema();
        DrawPanel->MouseToCursorSchema();


        if( !m_drawItem->InEditMode() )
        if( !m_drawItem->InEditMode() )
        {
        {
            SaveCopyInUndoList( m_component );
            SaveCopyInUndoList( m_component );
            m_drawItem->SetUnit( m_unit );
            m_drawItem->SetUnit( m_unit );
            m_drawItem->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
                              DefaultTransform );
        }
        }


        m_drawItem->Rotate();
        m_drawItem->Rotate();

        if( !m_drawItem->InEditMode() )
        {
            m_drawItem->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), -1, g_XorMode, NULL,
                              DefaultTransform );
        DrawPanel->Refresh();
        DrawPanel->Refresh();
        }

        DrawPanel->CursorOn( &dc );
        break;
        break;
    }
    }


@@ -980,6 +958,7 @@ void WinEDA_LibeditFrame::TempCopyComponent()
{
{
    if( m_tempCopyComponent )
    if( m_tempCopyComponent )
        delete m_tempCopyComponent;
        delete m_tempCopyComponent;
    m_tempCopyComponent = NULL;
    if( m_component )
    if( m_component )
        m_tempCopyComponent = new LIB_COMPONENT( *m_component );
        m_tempCopyComponent = new LIB_COMPONENT( *m_component );
}
}
@@ -990,8 +969,19 @@ void WinEDA_LibeditFrame::TempCopyComponent()
 */
 */
void WinEDA_LibeditFrame::RestoreComponent()
void WinEDA_LibeditFrame::RestoreComponent()
{
{
    if( m_tempCopyComponent == NULL )
        return;
    if( m_component )
    if( m_component )
        delete m_component;
        delete m_component;
    m_component = m_tempCopyComponent;
    m_component = m_tempCopyComponent;
    m_tempCopyComponent = NULL;
    m_tempCopyComponent = NULL;
}
}

/** Function ClearTempCopyComponent
 * delete temporary copy of the current component and clear pointer
 */
void WinEDA_LibeditFrame::ClearTempCopyComponent()
{
    delete m_tempCopyComponent;
    m_tempCopyComponent = NULL;
}
+5 −0
Original line number Original line Diff line number Diff line
@@ -188,6 +188,11 @@ public:
     */
     */
    LIB_COMPONENT* GetTempCopyComponent() { return m_tempCopyComponent; }
    LIB_COMPONENT* GetTempCopyComponent() { return m_tempCopyComponent; }


    /** Function ClearTempCopyComponent
     * delete temporary copy of the current component and clear pointer
     */
    void ClearTempCopyComponent();

    bool           IsEditingDrawItem() { return m_drawItem && m_drawItem->InEditMode(); }
    bool           IsEditingDrawItem() { return m_drawItem && m_drawItem->InEditMode(); }


private:
private:
+15 −3
Original line number Original line Diff line number Diff line
@@ -50,6 +50,7 @@ void WinEDA_LibeditFrame::OnRotatePin( wxCommandEvent& event ){


	// Save old pin orientation
	// Save old pin orientation
	LastPinOrient = pin -> m_Orient;
	LastPinOrient = pin -> m_Orient;
    if( !pin->InEditMode() )
        SaveCopyInUndoList( pin->GetParent() );
        SaveCopyInUndoList( pin->GetParent() );


	// Get the actual pin orientation index
	// Get the actual pin orientation index
@@ -159,7 +160,7 @@ void WinEDA_LibeditFrame::OnEditPin( wxCommandEvent& event )


    if( pin->IsModified() || pin->IsNew() )
    if( pin->IsModified() || pin->IsNew() )
    {
    {
        if( !pin->IsNew() )
        if( !pin->InEditMode() )
            SaveCopyInUndoList( pin->GetParent() );
            SaveCopyInUndoList( pin->GetParent() );


        OnModify( );
        OnModify( );
@@ -192,7 +193,7 @@ static void AbortPinMove( WinEDA_DrawPanel* Panel, wxDC* DC )
    if( CurrentPin->m_Flags & IS_NEW )
    if( CurrentPin->m_Flags & IS_NEW )
        delete CurrentPin;
        delete CurrentPin;
    else
    else
        CurrentPin->m_Flags = 0;
        parent->RestoreComponent();


    /* clear edit flags */
    /* clear edit flags */
    Panel->ManageCurseur = NULL;
    Panel->ManageCurseur = NULL;
@@ -246,6 +247,13 @@ another pin. Continue?" ) );
        }
        }
    }
    }


    // Create Undo from GetTempCopyComponent() if exists ( i.e. after a pin move)
    // or from m_component (pin add ...)
    if( GetTempCopyComponent() )
        SaveCopyInUndoList( GetTempCopyComponent() );
    else
        SaveCopyInUndoList( m_component );

    DrawPanel->ManageCurseur = NULL;
    DrawPanel->ManageCurseur = NULL;
    DrawPanel->ForceCloseManageCurseur = NULL;
    DrawPanel->ForceCloseManageCurseur = NULL;
    OnModify( );
    OnModify( );
@@ -294,6 +302,8 @@ void WinEDA_LibeditFrame::StartMovePin( wxDC* DC )
    LIB_PIN* CurrentPin = (LIB_PIN*) m_drawItem;
    LIB_PIN* CurrentPin = (LIB_PIN*) m_drawItem;
    wxPoint  startPos;
    wxPoint  startPos;


    TempCopyComponent();

    /* Mark pins for moving. */
    /* Mark pins for moving. */
    Pin = m_component->GetNextPin();
    Pin = m_component->GetNextPin();
    for( ; Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
    for( ; Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
@@ -466,6 +476,7 @@ void WinEDA_LibeditFrame::CreatePin( wxDC* DC )
    }
    }
    else
    else
    {
    {
        ClearTempCopyComponent();
        DrawPanel->ManageCurseur = DrawMovePin;
        DrawPanel->ManageCurseur = DrawMovePin;
        DrawPanel->ForceCloseManageCurseur = AbortPinMove;
        DrawPanel->ForceCloseManageCurseur = AbortPinMove;
        if( DC )
        if( DC )
@@ -609,6 +620,7 @@ void WinEDA_LibeditFrame::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )


    // Add this new pin in list, and creates pins for others parts if needed
    // Add this new pin in list, and creates pins for others parts if needed
    m_drawItem = Pin;
    m_drawItem = Pin;
    ClearTempCopyComponent();
    PlacePin( DC );
    PlacePin( DC );
    m_lastDrawItem = Pin;
    m_lastDrawItem = Pin;


Loading