예제 #1
0
void DrawPageLayout( wxDC*            aDC,
                     EDA_RECT*        aClipBox,
                     const PAGE_INFO& aPageInfo,
                     const wxString&  aFullSheetName,
                     const wxString&  aFileName,
                     TITLE_BLOCK&     aTitleBlock,
                     int              aSheetCount,
                     int              aSheetNumber,
                     int              aPenWidth,
                     double           aScalar,
                     COLOR4D          aColor,
                     const wxString&  aSheetLayer )
{
    WS_DRAW_ITEM_LIST drawList;

    drawList.SetDefaultPenSize( aPenWidth );
    drawList.SetMilsToIUfactor( aScalar );
    drawList.SetSheetNumber( aSheetNumber );
    drawList.SetSheetCount( aSheetCount );
    drawList.SetFileName( aFileName );
    drawList.SetSheetName( aFullSheetName );
    drawList.SetSheetLayer( aSheetLayer );

    drawList.BuildWorkSheetGraphicList( aPageInfo, aTitleBlock );

    // Draw item list
    drawList.Draw( aClipBox, aDC, aColor );
}
예제 #2
0
static void DrawMovingItems( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
{
    auto screen = static_cast<PL_EDITOR_SCREEN*>( aPanel->GetScreen() );
    auto frame = static_cast<PL_EDITOR_FRAME*>( aPanel->GetParent() );

    // Get items
    std::vector<WS_DRAW_ITEM_BASE*> items;
    WS_DRAW_ITEM_LIST drawList;
    ConfigureDrawList( &drawList, screen, frame );
    drawList.GetAllItems( &items );

    // Draw items
    for( auto item: items )
    {
        if( item->HitTest( screen->m_BlockLocate ) )
        {
            item->DrawWsItem( NULL, aDC, screen->m_BlockLocate.GetMoveVector(),
                    g_XorMode, g_GhostColor );
        }
    }
}
예제 #3
0
void PL_EDITOR_FRAME::Block_Move( wxDC* DC )
{
    auto screen = static_cast<PL_EDITOR_SCREEN*>( GetScreen() );

    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();

    // Get the items
    std::vector<WS_DRAW_ITEM_BASE*> items;
    WS_DRAW_ITEM_LIST drawList;
    ConfigureDrawList( &drawList, screen, this );
    drawList.GetAllItems( &items );

    // Move items in block
    SaveCopyInUndoList();
    for( auto item: items )
    {
        if( item->HitTest( screen->m_BlockLocate ) )
        {
            auto data_item = item->GetParent();
            data_item->MoveToUi( data_item->GetStartPosUi() + delta );
        }
    }

    m_canvas->Refresh( true );
}
void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
                    const PAGE_INFO& aPageInfo,
                    int aSheetNumber, int aNumberOfSheets,
                    const wxString &aSheetDesc, const wxString &aFilename )
{
    /* Note: Page sizes values are given in mils
     */
    double   iusPerMil = plotter->GetIUsPerDecimil() * 10.0;

    EDA_COLOR_T plotColor = plotter->GetColorMode() ? RED : BLACK;
    plotter->SetColor( plotColor );
    plotter->SetCurrentLineWidth( PLOTTER::DEFAULT_LINE_WIDTH );
    WS_DRAW_ITEM_LIST drawList;

    // Print only a short filename, if aFilename is the full filename
    wxFileName fn( aFilename );

    // Prepare plot parameters
    drawList.SetPenSize(PLOTTER::DEFAULT_LINE_WIDTH );
    drawList.SetMilsToIUfactor( iusPerMil );
    drawList.SetSheetNumber( aSheetNumber );
    drawList.SetSheetCount( aNumberOfSheets );
    drawList.SetFileName( fn.GetFullName() );   // Print only the short filename
    drawList.SetSheetName( aSheetDesc );


    drawList.BuildWorkSheetGraphicList( aPageInfo,
                            aTitleBlock, plotColor, plotColor );

    // Draw item list
    for( WS_DRAW_ITEM_BASE* item = drawList.GetFirst(); item;
         item = drawList.GetNext() )
    {
        switch( item->GetType() )
        {
        case WS_DRAW_ITEM_BASE::wsg_line:
            {
                WS_DRAW_ITEM_LINE* line = (WS_DRAW_ITEM_LINE*) item;
                plotter->MoveTo( line->GetStart() );
                plotter->FinishTo( line->GetEnd() );
            }
            break;

        case WS_DRAW_ITEM_BASE::wsg_rect:
            {
                WS_DRAW_ITEM_RECT* rect = (WS_DRAW_ITEM_RECT*) item;
                plotter->Rect( rect->GetStart(), rect->GetEnd(), NO_FILL );           }
            break;

        case WS_DRAW_ITEM_BASE::wsg_text:
            {
                WS_DRAW_ITEM_TEXT* text = (WS_DRAW_ITEM_TEXT*) item;
                plotter->Text( text->GetTextPosition(), text->GetColor(),
                               text->GetText(), text->GetOrientation(),
                               text->GetSize(),
                               text->GetHorizJustify(), text->GetVertJustify(),
                               text->GetPenWidth(),
                               text->IsItalic(), text->IsBold() );
            }
            break;

        case WS_DRAW_ITEM_BASE::wsg_poly:
            {
                WS_DRAW_ITEM_POLYGON* poly = (WS_DRAW_ITEM_POLYGON*) item;
                plotter->PlotPoly( poly->m_Corners,
                                   poly->IsFilled() ? FILLED_SHAPE : NO_FILL );
            }
            break;

        case WS_DRAW_ITEM_BASE::wsg_bitmap:
            {
                WS_DRAW_ITEM_BITMAP* bm = (WS_DRAW_ITEM_BITMAP*) item;

                WORKSHEET_DATAITEM_BITMAP* parent = (WORKSHEET_DATAITEM_BITMAP*)bm->GetParent();

                if( parent->m_ImageBitmap == NULL )
                    break;

                parent->m_ImageBitmap->PlotImage( plotter, bm->GetPosition(),
                               plotColor, PLOTTER::DEFAULT_LINE_WIDTH );
            }
            break;
        }
    }
}
/* return the page layout item found at position aPosition
 * aPosition = the position (in user units) of the reference point
 */
WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( const wxPoint& aPosition )
{
    const PAGE_INFO&    pageInfo = GetPageSettings();
    TITLE_BLOCK         t_block = GetTitleBlock();
    EDA_COLOR_T         color = RED;    // Needed, not used
    PL_EDITOR_SCREEN*   screen = (PL_EDITOR_SCREEN*) GetScreen();

    screen-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;

    WS_DRAW_ITEM_LIST drawList;
    drawList.SetPenSize( 0 );
    drawList.SetMilsToIUfactor( IU_PER_MILS );
    drawList.SetSheetNumber( screen->m_ScreenNumber );
    drawList.SetSheetCount( screen->m_NumberOfScreens );
    drawList.SetFileName( GetCurrFileName() );
    // GetScreenDesc() returns a temporary string. Store it to avoid issues.
    wxString descr = GetScreenDesc();
    drawList.SetSheetName( descr );

    drawList.BuildWorkSheetGraphicList( pageInfo, t_block, color, color );

    // locate items.
    // We do not use here the COLLECTOR classes in use in pcbnew and eeschema
    // because the locate requirements are very basic.
    std::vector <WS_DRAW_ITEM_BASE*> list;
    drawList.Locate( list, aPosition );

    if( list.size() == 0 )
        return NULL;

    WS_DRAW_ITEM_BASE* drawitem = list[0];

    // Choose item in list if more than 1 item
    if( list.size() > 1 )
    {
        wxArrayString choices;
        wxString text;
        wxPoint cursPos = GetCrossHairPosition();

        for( unsigned ii = 0; ii < list.size(); ++ii )
        {
            drawitem = list[ii];
            text = drawitem->GetParent()->m_Name;

            if( (drawitem->m_Flags & (LOCATE_STARTPOINT|LOCATE_ENDPOINT))
                == (LOCATE_STARTPOINT|LOCATE_ENDPOINT) )
                text << wxT(" ") << _("(start or end point)");
            else
            {
                if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
                    text << wxT(" ") << _("(start point)");

                if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
                    text << wxT(" ") << _("(end point)");
            }

            if( ! drawitem->GetParent()->m_Info.IsEmpty() )
                text << wxT(" \"") << drawitem->GetParent()->m_Info << wxT("\"");

            choices.Add( text );
        }
        int selection = wxGetSingleChoiceIndex ( wxEmptyString,
                                                _( "Selection Clarification" ),
                                                choices, this );
        if( selection < 0 )
            return NULL;

        SetCrossHairPosition( cursPos );
        m_canvas->MoveCursorToCrossHair();
        drawitem = list[selection];
    }

    WORKSHEET_DATAITEM* item = drawitem->GetParent();
    item->ClearFlags(LOCATE_STARTPOINT|LOCATE_ENDPOINT);

    if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
        item->SetFlags( LOCATE_STARTPOINT );

    if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
        item->SetFlags( LOCATE_ENDPOINT );

    return item;
}