bool DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
{
    bool eventHandled = true;

    // Filter out the 'fake' mouse motion after a keyboard movement
    if( !aHotKey && m_movingCursorWithKeyboard )
    {
        m_movingCursorWithKeyboard = false;
        return false;
    }

    wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
    cmd.SetEventObject( this );

    wxPoint pos = aPosition;
    wxPoint oldpos = GetCrossHairPosition();
    GeneralControlKeyMovement( aHotKey, &pos, true );

    switch( aHotKey )
    {
    case WXK_F1:
        cmd.SetId( ID_POPUP_ZOOM_IN );
        GetEventHandler()->ProcessEvent( cmd );
        break;

    case WXK_F2:
        cmd.SetId( ID_POPUP_ZOOM_OUT );
        GetEventHandler()->ProcessEvent( cmd );
        break;

    case WXK_F3:
        cmd.SetId( ID_ZOOM_REDRAW );
        GetEventHandler()->ProcessEvent( cmd );
        break;

    case WXK_F4:
        cmd.SetId( ID_POPUP_ZOOM_CENTER );
        GetEventHandler()->ProcessEvent( cmd );
        break;

    case WXK_HOME:
        cmd.SetId( ID_ZOOM_PAGE );
        GetEventHandler()->ProcessEvent( cmd );
        break;

    case ' ':
        GetScreen()->m_O_Curseur = GetCrossHairPosition();
        break;

    default:
        eventHandled = false;
    }

    SetCrossHairPosition( pos );
    RefreshCrossHair( oldpos, aPosition, aDC );

    UpdateStatusBar();    /* Display new cursor coordinates */

    return eventHandled;
}
void PL_EDITOR_FRAME::MoveItem( WORKSHEET_DATAITEM* aItem )
{
    wxCHECK_RET( aItem != NULL, wxT( "Cannot move NULL item" ) );
    initialPosition = aItem->GetStartPos();
    initialPositionUi = aItem->GetStartPosUi();
    initialCursorPosition = GetCrossHairPosition();

    if( (aItem->GetFlags() & LOCATE_ENDPOINT) )
    {
        initialPosition = aItem->GetEndPos();
        initialPositionUi = aItem->GetEndPosUi();
    }

    if( aItem->GetFlags() & (LOCATE_STARTPOINT|LOCATE_ENDPOINT) )
    {
        SetCrossHairPosition( initialPositionUi, false );
        initialCursorPosition = GetCrossHairPosition();

        if( m_canvas->IsPointOnDisplay( initialCursorPosition ) )
        {
            m_canvas->MoveCursorToCrossHair();
            m_canvas->Refresh();
        }
        else
        {
            RedrawScreen( initialCursorPosition, true );
        }
    }

    m_canvas->SetMouseCapture( moveItem, abortMoveItem );
    GetScreen()->SetCurItem( aItem );
}
예제 #3
0
/* Initialize the drawing of a segment of type other than trace.
 */
DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T shape, wxDC* DC )
{
    int          lineWidth;
    DRAWSEGMENT* DrawItem;

    lineWidth = GetDesignSettings().GetLineThickness( GetActiveLayer() );

    if( Segment == NULL )        // Create new segment.
    {
        SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) );
        Segment->SetFlags( IS_NEW );
        Segment->SetLayer( GetActiveLayer() );
        Segment->SetWidth( lineWidth );
        Segment->SetShape( shape );
        Segment->SetAngle( 900 );
        Segment->SetStart( GetCrossHairPosition() );
        Segment->SetEnd( GetCrossHairPosition() );
        m_canvas->SetMouseCapture( DrawSegment, Abort_EditEdge );
    }
    else
    {
        // The ending point coordinate Segment->m_End was updated by the function
        // DrawSegment() called on a move mouse event during the segment creation
        if( Segment->GetStart() != Segment->GetEnd() )
        {
            if( Segment->GetShape() == S_SEGMENT )
            {
                SaveCopyInUndoList( Segment, UR_NEW );
                GetBoard()->Add( Segment );

                OnModify();
                Segment->ClearFlags();

                Segment->Draw( m_canvas, DC, GR_OR );

                DrawItem = Segment;

                SetCurItem( Segment = new DRAWSEGMENT( GetBoard() ) );

                Segment->SetFlags( IS_NEW );
                Segment->SetLayer( DrawItem->GetLayer() );
                Segment->SetWidth( lineWidth );
                Segment->SetShape( DrawItem->GetShape() );
                Segment->SetType( DrawItem->GetType() );
                Segment->SetAngle( DrawItem->GetAngle() );
                Segment->SetStart( DrawItem->GetEnd() );
                Segment->SetEnd( DrawItem->GetEnd() );
                DrawSegment( m_canvas, DC, wxDefaultPosition, false );
            }
            else
            {
                End_Edge( Segment, DC );
                Segment = NULL;
            }
        }
    }

    return Segment;
}
예제 #4
0
void PL_EDITOR_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition,
                                      int aHotKey )
{
    // Filter out the 'fake' mouse motion after a keyboard movement
    if( !aHotKey && m_movingCursorWithKeyboard )
    {
        m_movingCursorWithKeyboard = false;
        return;
    }

    wxPoint pos = aPosition;
    wxPoint oldpos = GetCrossHairPosition();
    GeneralControlKeyMovement( aHotKey, &pos, true );

    // Update cursor position.
    SetCrossHairPosition( pos, true );
    RefreshCrossHair( oldpos, aPosition, aDC );

    if( aHotKey )
    {
        OnHotKey( aDC, aHotKey, aPosition );
    }

    UpdateStatusBar();
}
예제 #5
0
// Create hierarchy sheet.
SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC )
{
    SetRepeatItem( NULL );

    SCH_SHEET* sheet = new SCH_SHEET( GetCrossHairPosition() );

    sheet->SetFlags( IS_NEW | IS_RESIZED );
    sheet->SetTimeStamp( GetNewTimeStamp() );
    sheet->SetParent( GetScreen() );
    sheet->SetScreen( NULL );

    // need to check if this is being added to the GetDrawItems().
    // also need to update the hierarchy, if we are adding
    // a sheet to a screen that already has multiple instances (!)
    GetScreen()->SetCurItem( sheet );
    m_canvas->SetMouseCapture( resizeSheetWithMouseCursor, ExitSheet );
    m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
    m_canvas->CrossHairOff( aDC );

    SetCrossHairPosition( sheet->GetResizePosition() );

    m_canvas->MoveCursorToCrossHair();
    m_canvas->CrossHairOn( aDC );

    return sheet;
}
예제 #6
0
void EDA_DRAW_FRAME::RefreshCrossHair( const wxPoint &aOldPos,
                                       const wxPoint &aEvtPos,
                                       wxDC* aDC )
{
    wxPoint newpos = GetCrossHairPosition();

    // Redraw the crosshair if it moved
    if( aOldPos != newpos )
    {
        SetCrossHairPosition( aOldPos, false );
        m_canvas->CrossHairOff( aDC );
        SetCrossHairPosition( newpos, false );
        m_canvas->CrossHairOn( aDC );

        if( m_canvas->IsMouseCaptured() )
        {
#ifdef USE_WX_OVERLAY
            wxDCOverlay oDC( m_overlay, (wxWindowDC*)aDC );
            oDC.Clear();
            m_canvas->CallMouseCapture( aDC, aEvtPos, false );
#else
            m_canvas->CallMouseCapture( aDC, aEvtPos, true );
#endif
        }
#ifdef USE_WX_OVERLAY
        else
        {
            m_overlay.Reset();
        }
#endif
    }
}
예제 #7
0
void GERBVIEW_FRAME::Block_Move( wxDC* DC )
{
    wxPoint delta;
    wxPoint oldpos;

    oldpos = GetCrossHairPosition();
    m_canvas->SetMouseCaptureCallback( NULL );

    SetCrossHairPosition( oldpos );
    m_canvas->MoveCursorToCrossHair();
    GetScreen()->SetModify();
    GetScreen()->m_BlockLocate.Normalize();

    /* Calculate displacement vectors. */
    delta = GetScreen()->m_BlockLocate.GetMoveVector();

    /* Move items in block */
    for( GERBER_DRAW_ITEM* item = GetItemsList(); item; item = item->Next() )
    {
        GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;

        if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) )
            gerb_item->MoveAB( delta );
    }

    m_canvas->Refresh( true );
}
예제 #8
0
bool LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
{
    bool eventHandled = true;

    // Filter out the 'fake' mouse motion after a keyboard movement
    if( !aHotKey && m_movingCursorWithKeyboard )
    {
        m_movingCursorWithKeyboard = false;
        return false;
    }

    wxPoint pos = aPosition;
    wxPoint oldpos = GetCrossHairPosition();
    GeneralControlKeyMovement( aHotKey, &pos, true );

    // Update cursor position.
    SetCrossHairPosition( pos, true );
    RefreshCrossHair( oldpos, aPosition, aDC );

    if( aHotKey )
    {
        SCH_SCREEN* screen = GetScreen();

        if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
            eventHandled = OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
        else
            eventHandled = OnHotKey( aDC, aHotKey, aPosition, NULL );
    }

    UpdateStatusBar();    // Display cursor coordinates info.

    return eventHandled;
}
예제 #9
0
void PCB_EDIT_FRAME::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* aZone )
{
    // Show the Net
    if( aZone->IsOnCopperLayer() ) // Show the Net
    {
        if( GetBoard()->IsHighLightNetON() )
        {
            HighLight( DC );  // Remove old highlight selection
        }

        ZONE_SETTINGS zoneInfo = GetZoneSettings();
        zoneInfo.m_NetcodeSelection = aZone->GetNet();
        SetZoneSettings( zoneInfo );

        GetBoard()->SetHighLightNet( aZone->GetNet() );
        HighLight( DC );
    }

    s_PickedList.ClearListAndDeleteItems();
    s_AuxiliaryList.ClearListAndDeleteItems();
    SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNet(),
                     aZone->GetLayer() );

    aZone->SetFlags( IS_MOVED );
    m_canvas->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse,
                                Abort_Zone_Move_Corner_Or_Outlines );
    s_CursorLastPosition = s_CornerInitialPosition = GetCrossHairPosition();
    s_CornerIsNew = false;
    s_AddCutoutToCurrentZone = false;
    s_CurrentZone = NULL;
}
bool FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
{
    bool eventHandled = true;

    // Filter out the 'fake' mouse motion after a keyboard movement
    if( !aHotKey && m_movingCursorWithKeyboard )
    {
        m_movingCursorWithKeyboard = false;
        return false;
    }

    // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
    // for next cursor position
    // ( shift or ctrl key down are PAN command with mouse wheel)
    bool snapToGrid = true;

    if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
        snapToGrid = false;

    wxPoint oldpos = GetCrossHairPosition();
    wxPoint pos = aPosition;
    GeneralControlKeyMovement( aHotKey, &pos, snapToGrid );

    SetCrossHairPosition( pos, snapToGrid );
    RefreshCrossHair( oldpos, aPosition, aDC );

    if( aHotKey )
    {
        eventHandled = OnHotKey( aDC, aHotKey, aPosition );
    }

    UpdateStatusBar();

    return eventHandled;
}
예제 #11
0
SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
{
    wxString       line;
    SCH_SHEET_PIN* sheetPin;

    sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), line );
    sheetPin->SetFlags( IS_NEW );
    sheetPin->SetSize( m_lastSheetPinTextSize );
    sheetPin->SetShape( m_lastSheetPinType );

    int response = EditSheetPin( sheetPin, NULL );

    if( sheetPin->GetText().IsEmpty() || (response == wxID_CANCEL) )
    {
        delete sheetPin;
        return NULL;
    }

    m_lastSheetPinType = sheetPin->GetShape();
    m_lastSheetPinTextSize = sheetPin->GetSize();

    sheetPin->SetPosition( GetCrossHairPosition() );
    sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
    MoveItem( (SCH_ITEM*) sheetPin, aDC );

    OnModify();
    return sheetPin;
}
예제 #12
0
void PCB_BASE_FRAME::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
{
    if( Text != NULL )
    {
        m_canvas->RefreshDrawingRect( Text->GetBoundingBox() );
        Text->DrawUmbilical( m_canvas, DC, GR_XOR, -MoveVector );

        // Update the coordinates for anchor.
        MODULE* Module = static_cast<MODULE*>( Text->GetParent() );

        if( Module )
        {
            // Prepare undo command (a rotation can be made while moving)
            double tmp = Text->GetTextAngle();
            Text->SetTextAngle( TextInitialOrientation );

            if( IsType( FRAME_PCB ) )
                SaveCopyInUndoList( Module, UR_CHANGED );
            else
                SaveCopyInUndoList( Module, UR_CHANGED );

            Text->SetTextAngle( tmp );

            // Set the new position for text.
            Text->SetTextPos( GetCrossHairPosition() );
            wxPoint textRelPos = Text->GetTextPos() - Module->GetPosition();
            RotatePoint( &textRelPos, -Module->GetOrientation() );
            Text->SetPos0( textRelPos );
            Text->ClearFlags();
            Module->ClearFlags();
            Module->SetLastEditTime();
            OnModify();

            // Redraw text.
            m_canvas->RefreshDrawingRect( Text->GetBoundingBox() );
        }
        else
        {
            Text->SetTextPos( GetCrossHairPosition() );
        }
    }

    // leave it at (0,0) so we can use it Rotate when not moving.
    MoveVector.x = MoveVector.y = 0;

    m_canvas->SetMouseCapture( NULL, NULL );
}
예제 #13
0
void PCB_EDIT_FRAME::Block_Flip()
{
#define INVERT( pos ) (pos) = center.y - ( (pos) - center.y )
    wxPoint memo;
    wxPoint center; // Position of the axis for inversion of all elements

    OnModify();

    PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems();
    itemsList->m_Status = UR_FLIPPED;

    memo = GetCrossHairPosition();

    center = GetScreen()->m_BlockLocate.Centre();

    for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
    {
        BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
        wxASSERT( item );
        itemsList->SetPickedItemStatus( UR_FLIPPED, ii );
        item->Flip( center );

        switch( item->Type() )
        {
        case PCB_MODULE_T:
            item->ClearFlags();
            m_Pcb->m_Status_Pcb = 0;
            break;

        // Move and rotate the track segments
        case PCB_TRACE_T:       // a track segment (segment on a copper layer)
        case PCB_VIA_T:         // a via (like track segment on a copper layer)
            m_Pcb->m_Status_Pcb = 0;
            break;

        case PCB_ZONE_AREA_T:
        case PCB_LINE_T:
        case PCB_TEXT_T:
        case PCB_TARGET_T:
        case PCB_DIMENSION_T:
            break;

        // This item is not put in undo list
        case PCB_ZONE_T:         // SEG_ZONE items are now deprecated
            itemsList->RemovePicker( ii );
            ii--;
            break;


        default:
            wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Flip( ) error: unexpected type" ) );
            break;
        }
    }

    SaveCopyInUndoList( *itemsList, UR_FLIPPED, center );
    Compile_Ratsnest( NULL, true );
    m_canvas->Refresh( true );
}
SCH_BUS_WIRE_ENTRY* SCH_EDIT_FRAME::CreateBusWireEntry()
{
    // Create and place a new bus entry at cursor position
    SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( GetCrossHairPosition(), s_LastShape );

    busEntry->SetFlags( IS_NEW );
    GetScreen()->SetCurItem( busEntry );
    addCurrentItemToList();
    return busEntry;
}
예제 #15
0
void PCB_EDIT_FRAME::Begin_Self( wxDC* DC )
{
    if( s_inductor_pattern.m_Flag )
    {
        Genere_Self( DC );
        return;
    }

    s_inductor_pattern.m_Start = GetCrossHairPosition();
    s_inductor_pattern.m_End   = s_inductor_pattern.m_Start;

    s_inductor_pattern.m_Flag = true;

    // Update the initial coordinates.
    GetScreen()->m_O_Curseur = GetCrossHairPosition();
    UpdateStatusBar();

    m_canvas->SetMouseCapture( ShowBoundingBoxMicroWaveInductor, Exit_Self );
    m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
}
예제 #16
0
MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName )
{
    MODULE*  module;
    wxString moduleName;
    wxPoint  newpos;

    moduleName = aModuleName;

    // Ask for the new module reference
    if( moduleName.IsEmpty() )
    {
        wxTextEntryDialog dlg( this, FMT_MOD_REF, FMT_MOD_CREATE, moduleName );
        dlg.SetTextValidator( FOOTPRINT_NAME_VALIDATOR( &moduleName ) );

        if( dlg.ShowModal() != wxID_OK )
            return NULL;    //Aborted by user
    }

    moduleName.Trim( true );
    moduleName.Trim( false );

    if( moduleName.IsEmpty() )
    {
        DisplayInfoMessage( this, FMT_NO_REF_ABORTED );
        return NULL;
    }

    // Creates the new module and add it to the head of the linked list of modules
    module = new MODULE( GetBoard() );

    GetBoard()->Add( module );

    // Update parameters: position, timestamp ...
    newpos = GetCrossHairPosition();
    module->SetPosition( newpos );
    module->SetLastEditTime();

    // Update its name in lib
    module->SetFPID( FPID( moduleName ) );

    // Update reference:
    module->SetReference( moduleName );
    module->Reference().SetThickness( GetDesignSettings().m_ModuleTextWidth );
    module->Reference().SetSize( GetDesignSettings().m_ModuleTextSize );

    // Set the value field to a default value
    module->SetValue( wxT( "VAL**" ) );
    module->Value().SetThickness( GetDesignSettings().m_ModuleTextWidth );
    module->Value().SetSize( GetDesignSettings().m_ModuleTextSize );
    module->SetPosition( wxPoint( 0, 0 ) );

    SetMsgPanel( module );
    return module;
}
예제 #17
0
파일: dimension.cpp 프로젝트: OpenEE/micad
DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC )
{
    wxPoint pos;

    if( aDimension == NULL )
    {
        status_dimension = 1;
        pos = GetCrossHairPosition();

        aDimension = new DIMENSION( GetBoard() );
        aDimension->SetFlags( IS_NEW );
        aDimension->SetLayer( GetActiveLayer() );
        aDimension->SetOrigin( pos );
        aDimension->SetEnd( pos );

        aDimension->Text().SetSize( GetBoard()->GetDesignSettings().m_PcbTextSize );
        int width = GetBoard()->GetDesignSettings().m_PcbTextWidth;
        int maxthickness = Clamp_Text_PenSize(width, aDimension->Text().GetSize() );

        if( width > maxthickness )
        {
            width = maxthickness;
        }

        aDimension->Text().SetThickness( width );
        aDimension->SetWidth( width );
        aDimension->AdjustDimensionDetails();
        aDimension->Draw( m_canvas, aDC, GR_XOR );

        m_canvas->SetMouseCapture( BuildDimension, AbortBuildDimension );
        return aDimension;
    }

    // Dimension != NULL
    if( status_dimension == 1 )
    {
        status_dimension = 2;
        return aDimension;
    }

    aDimension->Draw( m_canvas, aDC, GR_OR );
    aDimension->ClearFlags();

    /* ADD this new item in list */
    GetBoard()->Add( aDimension );

    // Add store it in undo/redo list
    SaveCopyInUndoList( aDimension, UR_NEW );

    OnModify();
    m_canvas->SetMouseCapture( NULL, NULL );

    return NULL;
}
예제 #18
0
void PCB_EDIT_FRAME::Begin_Self( wxDC* DC )
{
    if( s_inductor_pattern.m_Flag )
    {
        m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
        m_canvas->SetMouseCapture( NULL, NULL );

        wxString errorMessage;

        // Prepare parameters for inductor
        // s_inductor_pattern.m_Start is already initialized,
        // when s_inductor_pattern.m_Flag == false
        s_inductor_pattern.m_Width = GetDesignSettings().GetCurrentTrackWidth();
        s_inductor_pattern.m_End = GetCrossHairPosition();

        MODULE* footprint = CreateMicrowaveInductor( this, errorMessage );

        if( footprint )
        {
            SetMsgPanel( footprint );
            footprint->Draw( m_canvas, DC, GR_OR );
        }

        else if( !errorMessage.IsEmpty() )
            DisplayError( this, errorMessage );

        return;
    }

    s_inductor_pattern.m_Start = GetCrossHairPosition();
    s_inductor_pattern.m_End   = s_inductor_pattern.m_Start;

    s_inductor_pattern.m_Flag = true;

    // Update the initial coordinates.
    GetScreen()->m_O_Curseur = GetCrossHairPosition();
    UpdateStatusBar();

    m_canvas->SetMouseCapture( ShowBoundingBoxMicroWaveInductor, Exit_Self );
    m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
}
예제 #19
0
void SCH_EDIT_FRAME::DeleteConnection( bool aFullConnection )
{
    PICKED_ITEMS_LIST   pickList;
    SCH_SCREEN*         screen = GetScreen();
    wxPoint             pos = GetCrossHairPosition();

    if( screen->GetConnection( pos, pickList, aFullConnection ) != 0 )
    {
        DeleteItemsInList( m_canvas, pickList );
        OnModify();
    }
}
예제 #20
0
파일: symbdraw.cpp 프로젝트: cpavlina/kicad
void LIB_EDIT_FRAME::StartModifyDrawSymbol( wxDC* DC )
{
    LIB_ITEM* item = GetDrawItem();

    if( item == NULL )
        return;

    TempCopyComponent();
    item->BeginEdit( IS_RESIZED, GetCrossHairPosition( true ) );
    m_canvas->SetMouseCapture( SymbolDisplayDraw, AbortSymbolTraceOn );
    m_canvas->CallMouseCapture( DC, wxDefaultPosition, true );
}
예제 #21
0
void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC )
{
    wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) );

    SetRepeatItem( NULL );

    if( !aItem->IsNew() )
    {
        if( (aItem->Type() == SCH_SHEET_PIN_T) || (aItem->Type() == SCH_FIELD_T) )
            SetUndoItem( (SCH_ITEM*) aItem->GetParent() );
        else
            SetUndoItem( aItem );
    }

    if( aItem->Type() == SCH_FIELD_T && aItem->GetParent()->Type() == SCH_COMPONENT_T )
    {
        // Now that we're moving a field, they're no longer autoplaced.
        SCH_COMPONENT *parent = static_cast<SCH_COMPONENT*>( aItem->GetParent() );
        parent->ClearFieldsAutoplaced();
    }

    aItem->SetFlags( IS_MOVED );

    // For some items, moving the cursor to anchor is not good
    // (for instance large hierarchical sheets od componants can have
    // the anchor position outside the canvas)
    // these items return IsMovableFromAnchorPoint() == false
    // For these items, do not wrap the cursor
    if( aItem->IsMovableFromAnchorPoint() )
    {
        SetCrossHairPosition( aItem->GetPosition() );
        m_canvas->MoveCursorToCrossHair();
        aItem->SetStoredPos( wxPoint( 0,0 ) );
    }
    else
    {
        // Round the point under the cursor to a multiple of the grid
        wxPoint cursorpos = GetCrossHairPosition() - aItem->GetPosition();
        wxPoint gridsize = GetScreen()->GetGridSize();
        cursorpos.x = ( cursorpos.x / gridsize.x ) * gridsize.x;
        cursorpos.y = ( cursorpos.y / gridsize.y ) * gridsize.y;

        aItem->SetStoredPos( cursorpos );
    }

    OnModify();

    GetScreen()->SetCurItem( aItem );
    m_canvas->SetMouseCapture( moveItemWithMouseCursor, abortMoveItem );

    m_canvas->Refresh();
}
void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
{
    SCH_ITEM*   repeater = GetRepeatItem();

    if( !repeater )
        return;

    //D( repeater>Show( 0, std::cout ); )

    // clone the repeater, move it, insert into display list, then save a copy
    // via SetRepeatItem();

    SCH_ITEM* my_clone = (SCH_ITEM*) repeater->Clone();

    // If cloning a component then put into 'move' mode.
    if( my_clone->Type() == SCH_COMPONENT_T )
    {
        wxPoint pos = GetCrossHairPosition() -
                      ( (SCH_COMPONENT*) my_clone )->GetPosition();

        my_clone->SetFlags( IS_NEW );
        ( (SCH_COMPONENT*) my_clone )->SetTimeStamp( GetNewTimeStamp() );
        my_clone->Move( pos );
        my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
        PrepareMoveItem( my_clone, DC );
    }
    else
    {
        my_clone->Move( GetRepeatStep() );

        if( my_clone->CanIncrementLabel() )
            ( (SCH_TEXT*) my_clone )->IncrementLabel( GetRepeatDeltaLabel() );

        GetScreen()->Append( my_clone );

        if( my_clone->IsConnectable() )
        {
            GetScreen()->TestDanglingEnds();
            m_canvas->Refresh();
        }
        else
        {
            my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
        }

        SaveCopyInUndoList( my_clone, UR_NEW );
        my_clone->ClearFlags();
    }

    // clone my_clone, now that it has been moved, thus saving new position.
    SetRepeatItem( my_clone );
}
예제 #23
0
// Start move of a graphic element type DRAWSEGMENT
void PCB_EDIT_FRAME::Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC )
{
    if( drawitem == NULL )
        return;

    drawitem->Draw( m_canvas, DC, GR_XOR );
    drawitem->SetFlags( IS_MOVED );
    s_InitialPosition = s_LastPosition = GetCrossHairPosition();
    SetMsgPanel( drawitem );
    m_canvas->SetMouseCapture( Move_Segment, Abort_EditEdge );
    SetCurItem( drawitem );
    m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
}
예제 #24
0
파일: edgemod.cpp 프로젝트: johnbeard/kicad
void FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod( EDGE_MODULE* aEdge, wxDC* DC )
{
    if( aEdge == NULL )
        return;

    aEdge->Draw( m_canvas, DC, GR_XOR );
    aEdge->SetFlags( IS_MOVED );
    MoveVector.x   = MoveVector.y = 0;
    CursorInitialPosition    = GetCrossHairPosition();
    m_canvas->SetMouseCapture( ShowCurrentOutlineWhileMoving, Abort_Move_ModuleOutline );
    SetCurItem( aEdge );
    m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
}
void PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge( wxDC*           DC,
                                                        ZONE_CONTAINER* aZone,
                                                        int             corner_id )
{
    aZone->SetFlags( IS_DRAGGED );
    aZone->SetSelectedCorner( corner_id );
    m_canvas->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse,
                                Abort_Zone_Move_Corner_Or_Outlines );
    s_CursorLastPosition     = s_CornerInitialPosition = GetCrossHairPosition();
    s_AddCutoutToCurrentZone = false;
    s_CurrentZone = NULL;

    s_PickedList.ClearListAndDeleteItems();
    s_AuxiliaryList.ClearListAndDeleteItems();
    SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNetCode(), aZone->GetLayer() );
}
예제 #26
0
파일: symbdraw.cpp 프로젝트: cpavlina/kicad
void LIB_EDIT_FRAME::GraphicItemBeginDraw( wxDC* DC )
{
    if( GetDrawItem() == NULL )
        return;

    wxPoint pos = GetCrossHairPosition( true );

    if( GetDrawItem()->ContinueEdit( pos ) )
    {
        GetDrawItem()->Draw( m_canvas, DC, pos, COLOR4D::UNSPECIFIED, g_XorMode, NULL,
                          DefaultTransform );
        return;
    }

    EndDrawGraphicItem( DC );
}
예제 #27
0
PCB_TARGET* PCB_EDIT_FRAME::CreateTarget( wxDC* DC )
{
    PCB_TARGET* target = new PCB_TARGET( GetBoard() );

    target->SetFlags( IS_NEW );

    GetBoard()->Add( target );

    target->SetLayer( Edge_Cuts );
    target->SetWidth( GetDesignSettings().m_EdgeSegmentWidth );
    target->SetSize( MireDefaultSize );
    target->SetPosition( GetCrossHairPosition() );

    PlaceTarget( target, DC );

    return target;
}
예제 #28
0
void LIB_EDIT_FRAME::PlaceAnchor()
{
    if( LIB_PART*      part = GetCurPart() )
    {
        const wxPoint& cross_hair = GetCrossHairPosition();

        wxPoint offset( -cross_hair.x, cross_hair.y );

        OnModify( );

        part->SetOffset( offset );

        // Redraw the symbol
        RedrawScreen( wxPoint( 0 , 0 ), true );
        m_canvas->Refresh();
    }
}
예제 #29
0
bool SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
{
    bool eventHandled = true;

    // Filter out the 'fake' mouse motion after a keyboard movement
    if( !aHotKey && m_movingCursorWithKeyboard )
    {
        m_movingCursorWithKeyboard = false;
        return false;
    }

    // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
    // for next cursor position
    // ( shift or ctrl key down are PAN command with mouse wheel)
    bool snapToGrid = true;

    if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
        snapToGrid = false;

    // Cursor is left off grid only if no block in progress
    if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
        snapToGrid = true;

    wxPoint pos = aPosition;
    wxPoint oldpos = GetCrossHairPosition();
    GeneralControlKeyMovement( aHotKey, &pos, snapToGrid );

    // Update cursor position.
    SetCrossHairPosition( pos, snapToGrid );
    RefreshCrossHair( oldpos, aPosition, aDC );

    if( aHotKey )
    {
        SCH_SCREEN* screen = GetScreen();

        if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
            eventHandled = OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
        else
            eventHandled = OnHotKey( aDC, aHotKey, aPosition, NULL );
    }

    UpdateStatusBar();    /* Display cursor coordinates info */

    return eventHandled;
}
TEXTE_PCB* PCB_EDIT_FRAME::CreateTextePcb( wxDC* aDC, TEXTE_PCB* aText )
{
    TEXTE_PCB* textePcb = new TEXTE_PCB( GetBoard() );

    if( aText )
    {
        textePcb->Copy( aText );
        GetBoard()->Add( textePcb );
        textePcb->SetFlags( IS_NEW );
        if( aDC )
            StartMoveTextePcb( textePcb, aDC, false ); // Don't erase aText when copying
    }
    else
    {
        GetBoard()->Add( textePcb );
        textePcb->SetFlags( IS_NEW );
        LAYER_NUM layer = ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
        textePcb->SetLayer( layer );

        // Set the mirrored option for layers on the BACK side of the board
        if( layer == LAYER_N_BACK || layer == SILKSCREEN_N_BACK ||
            layer == SOLDERPASTE_N_BACK || layer == SOLDERMASK_N_BACK ||
            layer == ADHESIVE_N_BACK
            )
            textePcb->SetMirrored( true );

        textePcb->SetSize( GetBoard()->GetDesignSettings().m_PcbTextSize );
        textePcb->SetTextPosition( GetCrossHairPosition() );
        textePcb->SetThickness( GetBoard()->GetDesignSettings().m_PcbTextWidth );

        InstallTextPCBOptionsFrame( textePcb, aDC );

        if( textePcb->GetText().IsEmpty() )
        {
            textePcb->DeleteStructure();
            textePcb = NULL;
        }
        else if( aDC )
        {
            StartMoveTextePcb( textePcb, aDC );
        }
    }

    return textePcb;
}