Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #210 when starting and resizing, waterfall appears garbled #205

Merged
merged 1 commit into from
Jan 8, 2022
Merged

fix #210 when starting and resizing, waterfall appears garbled #205

merged 1 commit into from
Jan 8, 2022

Conversation

cybork42
Copy link
Contributor

@cybork42 cybork42 commented Jan 7, 2022

It seems there was some migration issue left behind when implementing device context handling with wxWidgets.
The waterfall is an area of its own and odes not have any borders or such.
The old code was
gc->DrawRectangle(PLOT_BORDER + XLEFT_OFFSET, PLOT_BORDER + YBOTTOM_OFFSET, m_imgWidth, m_imgHeight);
The correct one seems to be:
gc->DrawRectangle(0, 0, m_imgWidth, m_imgHeight); // DC waterfall bitmap starts at origin and spans full width

@drowe67
Copy link
Owner

drowe67 commented Jan 8, 2022

Thanks @cybork42. Unfortunately I can't reproduce #210 on my machine using master so I can't determine if this PR fixes the issue. @tmiw can you reproduce the issue?

@tmiw
Copy link
Collaborator

tmiw commented Jan 8, 2022

Thanks @cybork42. Unfortunately I can't reproduce #210 on my machine using master so I can't determine if this PR fixes the issue. @tmiw can you reproduce the issue?

I could never reproduce this issue myself but the changes in this PR seem okay on macOS and Ubuntu at least.

Also, looking at the code, it does make sense to draw on the bitmap at 0,0. Note that the bitmap is then drawn in the correct location further down:

        // Reset bitmap to black.   
        {
            wxMemoryDC dc(*m_fullBmp);
            wxGraphicsContext *mGc = wxGraphicsContext::Create( dc );
        
            wxBrush ltGraphBkgBrush = wxBrush(BLACK_COLOR);
            mGc->SetBrush(ltGraphBkgBrush);
            mGc->SetPen(wxPen(BLACK_COLOR, 0));
            mGc->DrawRectangle(0, 0, m_imgWidth, m_imgHeight); // DC waterfall bitmap starts at origin and spans full width
            delete mGc;
        }
    }

    ...

    wxGraphicsBitmap tmpBmp = gc->CreateBitmap(*m_fullBmp);
    gc->DrawBitmap(tmpBmp, PLOT_BORDER + XLEFT_OFFSET, PLOT_BORDER + YBOTTOM_OFFSET, m_imgWidth, m_imgHeight);
    m_dT = DT;

@drowe67 drowe67 merged commit cd1555d into drowe67:master Jan 8, 2022
@cybork42 cybork42 deleted the fix_201 branch January 13, 2022 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants