Пример #1
0
private void MoveToT( char  *str ) {
   TimeType  start;
   double    tmp;

   if( str == NULL ) {
      XBell( display, 0 );
      return;
   }
   tmp = atof( str );
   start = ( int ) ns2d( tmp );
   if( start < tims.first or start > tims.last or start == tims.start )
      return;

   tims.start = start;
   tims.end = start + tims.steps;
   RedrawTimes();
   UpdateScrollBar();
   DrawTraces( start, tims.end );
}
Пример #2
0
/* Insert the new track created in the list of tracks.
 * amend the points of beginning and end of the track so that they are
 * connected
 * Center on pads even if they are off grid.
 */
static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
{
    if( g_FirstTrackSegment == NULL )
        return;

    int dx0, dy0, dx1, dy1;
    int marge, via_marge;
    EDA_DRAW_PANEL* panel = pcbframe->GetCanvas();
    PCB_SCREEN* screen = pcbframe->GetScreen();

    marge = s_Clearance + ( pcbframe->GetDesignSettings().GetCurrentTrackWidth() / 2 );
    via_marge = s_Clearance + ( pcbframe->GetDesignSettings().GetCurrentViaSize() / 2 );

    dx1 = g_CurrentTrackSegment->GetEnd().x - g_CurrentTrackSegment->GetStart().x;
    dy1 = g_CurrentTrackSegment->GetEnd().y - g_CurrentTrackSegment->GetStart().y;

    // Place on center of pad if off grid.
    dx0 = pt_cur_ch->m_PadStart->GetPosition().x - g_CurrentTrackSegment->GetStart().x;
    dy0 = pt_cur_ch->m_PadStart->GetPosition().y - g_CurrentTrackSegment->GetStart().y;

    // If aligned, change the origin point.
    if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) )
    {
        g_CurrentTrackSegment->SetEnd( pt_cur_ch->m_PadStart->GetPosition() );
    }
    else
    {
        TRACK* newTrack = (TRACK*)g_CurrentTrackSegment->Clone();

        newTrack->SetEnd( pt_cur_ch->m_PadStart->GetPosition() );
        newTrack->SetStart( g_CurrentTrackSegment->GetEnd() );

        g_CurrentTrackList.PushBack( newTrack );
    }

    g_FirstTrackSegment->start = pcbframe->GetBoard()->GetPad( g_FirstTrackSegment,
            ENDPOINT_START );

    if( g_FirstTrackSegment->start )
        g_FirstTrackSegment->SetState( BEGIN_ONPAD, true );

    g_CurrentTrackSegment->end = pcbframe->GetBoard()->GetPad( g_CurrentTrackSegment,
            ENDPOINT_END );

    if( g_CurrentTrackSegment->end )
        g_CurrentTrackSegment->SetState( END_ONPAD, true );

    // Out the new track on the matrix board
    for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() )
    {
        TraceSegmentPcb( track, HOLE, marge, WRITE_CELL );
        TraceSegmentPcb( track, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL );
    }

    // Insert new segments in  real board
    int    netcode    = g_FirstTrackSegment->GetNetCode();
    TRACK* firstTrack = g_FirstTrackSegment;
    int    newCount   = g_CurrentTrackList.GetCount();

    // Put entire new current segment list in BOARD
    TRACK* track;
    TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( pcbframe->GetBoard() );

    while( ( track = g_CurrentTrackList.PopFront() ) != NULL )
    {
        ITEM_PICKER picker( track, UR_NEW );
        s_ItemsListPicker.PushItem( picker );
        pcbframe->GetBoard()->m_Track.Insert( track, insertBeforeMe );
    }

    DrawTraces( panel, DC, firstTrack, newCount, GR_OR );

    pcbframe->TestNetConnection( DC, netcode );

    screen->SetModify();
}
Пример #3
0
int main(void) 
{
    
    WINDOW*  mainwin;
    WINDOW*  childwin;
    WINDOW*  traceWin;
    PANEL*   mainPanel;
    PANEL*   childPanel;
    PANEL*   tracePanel;
    int      ch;


    //
    //
    //
    for(uint32_t i=0; i<sizeof(data); i++)
    {
        data[i] = rand();
    }

    //
    //
    //
    pthread_t   threadId;
    pthread_create(&threadId, NULL, DataUpdateThread, NULL);


    /*  Set the dimensions and initial
	position for our child window   */

    int      width = 23, height = 7;
    int      rows  = 25, cols   = 80;
    int      x = (cols - width)  / 2;
    int      y = (rows - height) / 2;


    /*  Initialize ncurses  */

    if ( (mainwin = initscr()) == NULL ) 
    {
	    fprintf(stderr, "Error initialising ncurses.\n");
	    exit(EXIT_FAILURE);
    }
    

    /*  Switch of echoing and enable keypad (for arrow keys)  */

    noecho();
    nodelay(mainwin, TRUE);
    keypad(mainwin, TRUE);


    /*  Make our child window, and add
	a border and some text to it.   */

    int         maxX;
    int         maxY;
    getmaxyx(mainwin, maxY,maxX);
    traceWin = newwin(maxY, maxX, 0, 0);

    childwin = newwin(height, width, 2, maxX-width-2);
    box(childwin, 0, 0);
    mvwaddstr(childwin, 1, 4, "Move the window");
    mvwaddstr(childwin, 2, 2, "with the arrow keys");
    mvwaddstr(childwin, 3, 6, "or HOME/END");
    mvwaddstr(childwin, 5, 3, "Press 'q' to quit");

    //
    //
    //
    start_color();
    init_pair(0, COLOR_RED, COLOR_BLACK);
    init_pair(1, COLOR_YELLOW, COLOR_BLACK);
    init_pair(2, COLOR_GREEN, COLOR_BLACK);
    init_pair(3, COLOR_BLUE, COLOR_BLACK);
    init_pair(4, COLOR_MAGENTA, COLOR_BLACK);
    init_pair(5, COLOR_CYAN, COLOR_BLACK);
    init_pair(6, COLOR_WHITE, COLOR_BLACK);
    init_pair(7, COLOR_RED, COLOR_BLACK);


    tracePanel  = new_panel( traceWin );
    mainPanel   = new_panel( mainwin );
    childPanel  = new_panel( childwin );

    uint32_t    wx   = 100;
    while (true)
    {
        //
        //
        //
        int ch  = getch();
        if(ch != ERR)
        {
            if(ch == 'q')
            {
                break;
            }

            if(ch == ' ')
            {
                TogglePauseRun();
            }

            if(ch == KEY_UP)
            {
                if(scale > 0)
                {
                    scale--;
                }
            }
            if(ch == KEY_DOWN)
            {
                scale++;
            }
            if(ch == KEY_LEFT)
            {
                if(offset > 0)
                {
                    offset-=scale;
                }
            }
            if(ch == KEY_RIGHT)
            {
                offset+=scale;
            }


            if(ch == KEY_NPAGE)
            {
                offset+=scale*10;
            }
            if(ch == KEY_PPAGE)
            {
                if(offset > scale*10)
                {
                    offset-=scale*10;
                }
                else
                {
                    offset  = 0;
                }
            }
        }

        //
        // Draw the traces.
        //
        DrawTraces(traceWin);

        //touchwin(childwin);
        //wnoutrefresh(traceWin);
        //wnoutrefresh(childwin);
        update_panels();
        doupdate();

        usleep(1000000/30);
    }


    /*  Clean up after ourselves  */

    delwin(childwin);
    delwin(mainwin);
    endwin();
    refresh();

    return EXIT_SUCCESS;
}