Пример #1
0
static void Exit_DuplicTrack(WinEDA_DrawFrame * frame, wxDC *DC)
/***************************************************************/
/* routine d'annulation de la Commande Begin_Route si une piste est en cours
	de tracage, ou de sortie de l'application EDITRACK.
	Appel par la touche ESC
 */
{
TRACK * NextS;
int ii;
wxDC * DC = Cmd->DC;

	frame->GetScreen()->ManageCurseur = NULL;

	if( NewTrack )
		{
		/* Effacement du trace en cours */
		DisplayOpt.DisplayPcbTrackFill = SKETCH ;
		Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_XOR);
		DisplayOpt.DisplayPcbTrackFill = Track_fill_copy ;

		if (FlagState == COPY_ROUTE )
			{
			for( ii = 0; ii < NbPtNewTrack; ii++, NewTrack = NextS)
				{
				if(NewTrack == NULL) break;
				NextS = (TRACK*) NewTrack->Pnext;
				delete NewTrack;
				}
			}
		else	/* Move : remise en ancienne position */
			{
			TRACK * Track = NewTrack;
			PosInitX -= Track->m_Start.x;
			PosInitY -= Track->m_Start.y;
			for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext)
				{
				if( Track == NULL ) break;
				Track->m_Start.x += PosInitX;
				Track->m_Start.y += PosInitY;
				Track->m_End.x += PosInitX;
				Track->m_End.y += PosInitY;
				}
			Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_OR);
			}

		if(Etat_Surbrillance) Hight_Light(DC);
		EraseMsgBox();
		NewTrack = NULL;
		}
	else
		{
		EraseMsgBox();
		}
}
void GERBVIEW_FRAME::SetCurItem( GERBER_DRAW_ITEM* aItem, bool aDisplayInfo )
{
    GetScreen()->SetCurItem( aItem );

    if( aItem )
    {
        if( aDisplayInfo )
        {
            MSG_PANEL_ITEMS items;
            aItem->GetMsgPanelInfo( items );
            SetMsgPanel( items );
        }
    }
    else
    {
        EraseMsgBox();
    }
}
Пример #3
0
/* Route all traces
 * :
 *  1 if OK
 * -1 if escape (stop being routed) request
 * -2 if default memory allocation
 */
int PCB_EDIT_FRAME::Solve( wxDC* DC, int aLayersCount )
{
    int           current_net_code;
    int           row_source, col_source, row_target, col_target;
    int           success, nbsucces = 0, nbunsucces = 0;
    NETINFO_ITEM* net;
    bool          stop = false;
    wxString      msg;
    int           routedCount = 0;      // routed ratsnest count
    bool          two_sides = aLayersCount == 2;

    m_canvas->SetAbortRequest( false );

    s_Clearance = GetBoard()->GetDesignSettings().GetDefault()->GetClearance();

    // Prepare the undo command info
    s_ItemsListPicker.ClearListAndDeleteItems();  // Should not be necessary, but...

    // go until no more work to do
    GetWork( &row_source, &col_source, &current_net_code,
             &row_target, &col_target, &pt_cur_ch ); // First net to route.

    for( ; row_source != ILLEGAL; GetWork( &row_source, &col_source,
                                           &current_net_code, &row_target,
                                           &col_target,
                                           &pt_cur_ch ) )
    {
        // Test to stop routing ( escape key pressed )
        wxYield();

        if( m_canvas->GetAbortRequest() )
        {
            if( IsOK( this, _( "Abort routing?" ) ) )
            {
                success = STOP_FROM_ESC;
                stop    = true;
                break;
            }
            else
            {
                m_canvas->SetAbortRequest( false );
            }
        }

        EraseMsgBox();

        routedCount++;
        net = GetBoard()->FindNet( current_net_code );

        if( net )
        {
            msg.Printf( wxT( "[%8.8s]" ), GetChars( net->GetNetname() ) );
            AppendMsgPanel( wxT( "Net route" ), msg, BROWN );
            msg.Printf( wxT( "%d / %d" ), routedCount, RoutingMatrix.m_RouteCount );
            AppendMsgPanel( wxT( "Activity" ), msg, BROWN );
        }

        segm_oX = GetBoard()->GetBoundingBox().GetX() + (RoutingMatrix.m_GridRouting * col_source);
        segm_oY = GetBoard()->GetBoundingBox().GetY() + (RoutingMatrix.m_GridRouting * row_source);
        segm_fX = GetBoard()->GetBoundingBox().GetX() + (RoutingMatrix.m_GridRouting * col_target);
        segm_fY = GetBoard()->GetBoundingBox().GetY() + (RoutingMatrix.m_GridRouting * row_target);

        // Draw segment.
        GRLine( m_canvas->GetClipBox(), DC,
                segm_oX, segm_oY, segm_fX, segm_fY,
                0, WHITE );
        pt_cur_ch->m_PadStart->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT );
        pt_cur_ch->m_PadEnd->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT );

        success = Autoroute_One_Track( this, DC,
                                       two_sides, row_source, col_source,
                                       row_target, col_target, pt_cur_ch );

        switch( success )
        {
        case NOSUCCESS:
            pt_cur_ch->m_Status |= CH_UNROUTABLE;
            nbunsucces++;
            break;

        case STOP_FROM_ESC:
            stop = true;
            break;

        case ERR_MEMORY:
            stop = true;
            break;

        default:
            nbsucces++;
            break;
        }

        msg.Printf( wxT( "%d" ), nbsucces );
        AppendMsgPanel( wxT( "OK" ), msg, GREEN );
        msg.Printf( wxT( "%d" ), nbunsucces );
        AppendMsgPanel( wxT( "Fail" ), msg, RED );
        msg.Printf( wxT( "  %d" ), GetBoard()->GetUnconnectedNetCount() );
        AppendMsgPanel( wxT( "Not Connected" ), msg, CYAN );

        // Delete routing from display.
        pt_cur_ch->m_PadStart->Draw( m_canvas, DC, GR_AND );
        pt_cur_ch->m_PadEnd->Draw( m_canvas, DC, GR_AND );

        if( stop )
            break;
    }

    SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED );
    s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items

    return SUCCESS;
}
void WinEDA_LibeditFrame::OnLeftClick(wxDC * DC, const wxPoint& MousePos)
/************************************************************************/
{
LibEDA_BaseStruct* DrawEntry = CurrentDrawItem;

	if( CurrentLibEntry == NULL) return;

	if ( m_ID_current_state == 0 )
		{
		if ( DrawEntry && DrawEntry->m_Flags )
			{
			switch (DrawEntry->m_StructType )
				{
				case COMPONENT_PIN_DRAW_TYPE:
					SaveCopyInUndoList();
					PlacePin(DC);
					break;

				case COMPONENT_FIELD_DRAW_TYPE:
					SaveCopyInUndoList();
					PlaceField(DC,  (LibDrawField *) DrawEntry);
					DrawEntry = NULL;
					break;

				default:
					SaveCopyInUndoList();
					EndDrawGraphicItem(DC);
					break;
				}
			}
		else
			{
			DrawEntry =	LocatePin(m_CurrentScreen->m_Curseur, CurrentLibEntry,
							CurrentUnit, CurrentConvert);
			if (DrawEntry == NULL )
				{
				DrawEntry = LocateDrawItem(GetScreen(), CurrentLibEntry,CurrentUnit,
   							CurrentConvert,LOCATE_ALL_DRAW_ITEM);
				}

			if ( DrawEntry ) DrawEntry->Display_Infos_DrawEntry(this);

			else
				{
				EraseMsgBox();
				AfficheDoc(this, CurrentLibEntry->m_Doc.GetData(),
            			CurrentLibEntry->m_KeyWord.GetData());
				}
			}
		}

	if ( m_ID_current_state )
		{
		switch ( m_ID_current_state )
			{
			case ID_NO_SELECT_BUTT:
				break;

			case ID_LIBEDIT_PIN_BUTT :
				if( CurrentDrawItem == NULL )
				{
					CreatePin(DC);
				}
				else
				{
					SaveCopyInUndoList();
					PlacePin(DC);
				}
				break;

			case ID_LIBEDIT_BODY_LINE_BUTT :
			case ID_LIBEDIT_BODY_ARC_BUTT :
			case ID_LIBEDIT_BODY_CIRCLE_BUTT :
			case ID_LIBEDIT_BODY_RECT_BUTT :
			case ID_LIBEDIT_BODY_TEXT_BUTT :
				if ( CurrentDrawItem == NULL)
				{
					CurrentDrawItem = CreateGraphicItem(DC);
				}
				else
				{
					if ( CurrentDrawItem->m_Flags & IS_NEW )
						GraphicItemBeginDraw(DC);
					else
					{
						SaveCopyInUndoList();
						EndDrawGraphicItem(DC);
					}
				}
				break;

			case ID_LIBEDIT_DELETE_ITEM_BUTT :
				DrawEntry =	LocatePin(m_CurrentScreen->m_Curseur, CurrentLibEntry,
							CurrentUnit, CurrentConvert);
				if (DrawEntry == NULL )
				{
					DrawEntry = LocateDrawItem(GetScreen(), CurrentLibEntry,CurrentUnit,
								CurrentConvert,LOCATE_ALL_DRAW_ITEM);
				}

				if ( DrawEntry == NULL )
				{
					AfficheDoc(this, CurrentLibEntry->m_Doc.GetData(),
               			CurrentLibEntry->m_KeyWord.GetData());
					break;
				}
				SaveCopyInUndoList();
				if ( DrawEntry->m_StructType == COMPONENT_PIN_DRAW_TYPE )
					DeletePin(DC, CurrentLibEntry, (LibDrawPin*)DrawEntry);
				else
					DeleteOneLibraryDrawStruct(DrawPanel, DC, CurrentLibEntry,DrawEntry, TRUE);
				DrawEntry = NULL;
				m_CurrentScreen->SetModify();
				break;

			case ID_LIBEDIT_ANCHOR_ITEM_BUTT :
				SaveCopyInUndoList();
				PlaceAncre();
				SetToolID( 0, wxCURSOR_ARROW, wxEmptyString);
				break;


			default :
				DisplayError(this,  wxT("WinEDA_LibeditFrame::OnLeftClick error") );
				SetToolID( 0, wxCURSOR_ARROW, wxEmptyString);
				break;
			}
		}
}