Пример #1
0
wxBitmap Canvas::zoomed_bitmap_for_canvas_region
    ( const wxRect& unclipped_rect )
{
    wxRect image_area = wxRect( wxSize(contents->GetWidth(),
                                       contents->GetHeight()) );
    wxRect rect = unclipped_rect.Intersect( canvas_coords( image_area ) );

    wxRect subimage = image_coords( rect );
    wxRect smoothing_region_in_image = subimage,
            smoothing_region_in_canvas;

    smoothing_region_in_image.Inflate( Overlap * zoom_out_level )
        .Intersect( image_area );

    smoothing_region_in_canvas = 
        canvas_coords( smoothing_region_in_image );

    wxImage toScale = contents->GetSubImage( smoothing_region_in_image );
    toScale.Rescale( smoothing_region_in_canvas.GetWidth(), 
                        smoothing_region_in_canvas.GetHeight() );
    wxRect update_region_in_enlarged( rect );
    update_region_in_enlarged.Offset( 
        - smoothing_region_in_canvas.GetTopLeft() );
    wxImage toDraw = toScale.GetSubImage( update_region_in_enlarged );
    
    return wxBitmap( toDraw );
}
Пример #2
0
void Stage::InvalidateRect(const wxRect &inRect) {
    wxLogTrace(TRACE_STAGE_DRAWING, wxT("Invalidating: %d %d %d %d"),
               inRect.x, inRect.y, inRect.GetRight(), inRect.GetBottom());

    // We want to make sure that we never try to do any drawing off
    // the edges of the screen. Certain platforms, (like wxMac) get
    // very upset when you try to draw from or to rects that lie off
    // the screen. Since this is how all of the dirty regions enter
    // the system, we clip our dirty rect to the screen and make sure
    // we have something left before continuing.
    wxRect r(inRect.Intersect(wxRect(wxPoint(0, 0), GetSize())));
    if (r.IsEmpty())
        return;

    // It's a little bit inelegant to maintain two different dirty lists,
    // but they get cleared by different actions.
    mRectsToComposite.MergeRect(r);

    // Trigger screen repaint events--and update our manual refresh
    // list--but only if Quake 2 is not being displayed.  (Quake 2 covers
    // the entire stage, and if we repaint the screen, it will flicker.)
    // The entire screen will automatically be refreshed when Quake 2
    // is hidden.
    if (!GameEngineIsDisplayed()) {
        mRectsToRefresh.MergeRect(r);
        Refresh(FALSE, &r);
    }
}
Пример #3
0
vector< wxRect > GetCoverage( const wxRect& viewport, const wxRect& canvas, const wxSize& gridSize )
{
    const wxRect clippedViewport( canvas.Intersect( viewport ) );

    vector< wxRect > coverage;
    const int top    = clippedViewport.GetTop()    / gridSize.y;
    const int bottom = clippedViewport.GetBottom() / gridSize.y;
    const int left   = clippedViewport.GetLeft()   / gridSize.x;
    const int right  = clippedViewport.GetRight()  / gridSize.x;
    for( int y = top; y <= bottom; ++y )
    {
        for( int x = left; x <= right; ++x )
        {
            const wxRect candidate( x * gridSize.x, y * gridSize.y, gridSize.x, gridSize.y );
            const wxRect clipped( canvas.Intersect( candidate ) );
            coverage.push_back( clipped );
        }
    }
    return coverage;
}
Пример #4
0
wxMatrix2D wxMatrix2D::SubMatrix(const wxRect& rect) const
{
    wxMatrix2D temp;
    wxCHECK_MSG(Ok(), temp, wxT("Invalid wxMatrix2D"));
    wxCHECK_MSG((rect.width > 0) && (rect.height > 0), temp, wxT("Invalid sub matrix rect"));

    int width = M_MATRIXDATA->m_width, height = M_MATRIXDATA->m_height;
    const wxRect r(0, 0, width, height);
    wxCHECK_MSG(r.Intersect(rect) == rect, temp, wxT("Invalid sub matrix"));

    if (!temp.Create(rect.width, rect.height, false))
        return temp;

    double *data      = GetData();
    double *temp_data = temp.GetData();

    int j, data_size = rect.width*sizeof(double);
    for (j = 0; j < rect.height; j++)
    {
        memcpy(&temp_data[j*rect.width], &data[rect.x + (j+rect.y)*width], data_size);
    }

    return temp;
}