Search found 16154 matches

by doublemax
Fri Jul 30, 2021 11:09 pm
Forum: C++ Development
Topic: problem with wxDC rectangle lines with width 2 and 4
Replies: 2
Views: 74

Re: problem with wxDC rectangle lines with width 2 and 4

Normal wxDC coordinates are integers, wxGraphicsContext/wxGCDC uses float coordinates with subpixel accuracy. If you pass integer coordinates to wxGCGC, an offset of 0.5 will be added to the coordinates which can lead to some unexpected results. You can disable the offset with wxGraphicsContext::Dis...
by doublemax
Fri Jul 30, 2021 10:22 pm
Forum: C++ Development
Topic: How to remove trailing effect when drawing on a panel?
Replies: 49
Views: 518

Re: How to remove trailing effect when drawing on a panel?

I built this sample which pretty much does what you're trying to do. I tested this under Windows and Linux (GTK3). Under Windows is flickers heavily, but that's intentional in this case for demonstration purposes. It's a drop-in replacement for the "minimal" sample that comes with wxWidgets. I hope ...
by doublemax
Fri Jul 30, 2021 6:31 pm
Forum: C++ Development
Topic: How to remove trailing effect when drawing on a panel?
Replies: 49
Views: 518

Re: How to remove trailing effect when drawing on a panel?

If you update your repo, i can try running in Windows If it doesn't work there either, i should be able to find the bug. I updated the repository, created new branch experimental-draw-waveform, https://gitlab.com/samplehive/sample-hive/-/tree/experimental-draw-waveform Sorry, there are too many mis...
by doublemax
Fri Jul 30, 2021 5:49 pm
Forum: C++ Development
Topic: How to remove trailing effect when drawing on a panel?
Replies: 49
Views: 518

Re: How to remove trailing effect when drawing on a panel?

but when I click on a sample, it prints Cannot update waveform bitmap. "Cannot update" actually means that the code "thinks" it's not needed to update the bitmap. If the waveform changes, you must set a dirty flag or something to make sure that the bitmap gets updated. That's the "anyVisiblePropert...
by doublemax
Fri Jul 30, 2021 5:38 pm
Forum: C++ Development
Topic: How to remove trailing effect when drawing on a panel?
Replies: 49
Views: 518

Re: How to remove trailing effect when drawing on a panel?

Sorry, then i'm out of ideas and I don't know how to debug this remotely.

If you update your repo, i can try running in Windows If it doesn't work there either, i should be able to find the bug.
by doublemax
Fri Jul 30, 2021 5:19 pm
Forum: C++ Development
Topic: How to remove trailing effect when drawing on a panel?
Replies: 49
Views: 518

Re: How to remove trailing effect when drawing on a panel?

Try drawing a cross and check if it appears. If it does, check the all variables involved in the loop: waveform, display_height , display_width, etc wxMemoryDC mdc(m_WaveformBitmap); mdc.SetPen(wxPen(wxColour(255, 255, 255, 255), 2, wxPENSTYLE_SOLID)); mdc.DrawLine(0, 0, 30,30); mdc.DrawLine(0, 30, ...
by doublemax
Fri Jul 30, 2021 5:03 pm
Forum: C++ Development
Topic: How to remove trailing effect when drawing on a panel?
Replies: 49
Views: 518

Re: How to remove trailing effect when drawing on a panel?

Sorry, my last post was nonsense, because it didn't update the bitmap. void MainFrame::UpdateWaveformBitmap(wxDC& dc) { . . . /*===========================Draw code============================*/ wxMemoryDC mdc(m_WaveformBitmap); mdc.SetPen(wxPen(wxColour(255, 255, 255, 255), 2, wxPENSTYLE_SOLID)); f...
by doublemax
Fri Jul 30, 2021 4:34 pm
Forum: C++ Development
Topic: How to remove trailing effect when drawing on a panel?
Replies: 49
Views: 518

Re: How to remove trailing effect when drawing on a panel?

Is this still in your UpdateWaveformBitmap method? /*===========================Draw code============================*/ wxMemoryDC mdc(m_WaveformBitmap); dc.SetPen(wxPen(wxColour(0, 0, 0, 255), 2, wxPENSTYLE_SOLID)); if (!mdc.IsOk()) return; for(int i = 0; i < waveform.size() - 1; i++) { dc.DrawLine...
by doublemax
Fri Jul 30, 2021 1:06 pm
Forum: C++ Development
Topic: How to remove trailing effect when drawing on a panel?
Replies: 49
Views: 518

Re: How to remove trailing effect when drawing on a panel?

Reading the ticket again, i'm not sure if both bmp1 and bmp2 are the problem. Maybe you can draw into an uninitialized bitmap, but the source can't be uninitialized ? Try a workaround using wImage: if(!m_WaveformBitmap.IsOk() || m_WaveformBitmap.IsNull() || m_WaveformBitmap.GetWidth() != size.x || m...
by doublemax
Fri Jul 30, 2021 12:53 pm
Forum: C++ Development
Topic: How to remove trailing effect when drawing on a panel?
Replies: 49
Views: 518

Re: How to remove trailing effect when drawing on a panel?

I also found this bug report, https://trac.wxwidgets.org/ticket/18520 Wow. This is idiotic. And most importantly, it doesn't answer the question: How on earth to you initialize the bitmap then? Looks like its a known issue with GTK3. Maybe in wx3.1.x its fixed? The way i see it, they just removed t...
by doublemax
Fri Jul 30, 2021 11:38 am
Forum: C++ Development
Topic: How to remove trailing effect when drawing on a panel?
Replies: 49
Views: 518

Re: How to remove trailing effect when drawing on a panel?

Looks like no matter what it is, it always stops at m_WaveformBitmap.IsNull(), and never seem to move forward.
Of course, because the bitmap never gets created because of this check. That's not the right solution.
by doublemax
Fri Jul 30, 2021 11:28 am
Forum: C++ Development
Topic: How to remove trailing effect when drawing on a panel?
Replies: 49
Views: 518

Re: How to remove trailing effect when drawing on a panel?

Code: Select all

if (m_WaveformBitmap.IsNull())
I don't think this is correct. This check will prevent the bitmap from ever being created.

Just trace through the code and check what happens. It's probably something simple.
by doublemax
Fri Jul 30, 2021 11:10 am
Forum: C++ Development
Topic: How to remove trailing effect when drawing on a panel?
Replies: 49
Views: 518

Re: How to remove trailing effect when drawing on a panel?

I don't see any way the bitmap size could be 0.

Maybe that's one of the GTK oddities where windows get their size at a later time. Let's try adding a check for the panel size.

Code: Select all

const wxSize size = m_TopWaveformPanel->GetClientSize();
if (size.x < 1 || size.y < 1 ) return
by doublemax
Fri Jul 30, 2021 10:49 am
Forum: C++ Development
Topic: How to remove trailing effect when drawing on a panel?
Replies: 49
Views: 518

Re: How to remove trailing effect when drawing on a panel?

Once again, i can only guess when it comes to GTK specifics. Leave bitmap at 32, but set "useMask" parameter in the DrawBitmap call to true { m_WaveformBitmap.Create(size.x, size.y, 32); UpdateWaveformBitmap(dc); } dc.DrawBitmap(m_WaveformBitmap, 0, 0, true); If that still fails, try to find out whi...
by doublemax
Fri Jul 30, 2021 9:53 am
Forum: C++ Development
Topic: How to remove trailing effect when drawing on a panel?
Replies: 49
Views: 518

Re: How to remove trailing effect when drawing on a panel?

I can only guess here:

Try setting the bitmap depth to 24.

Code: Select all

m_WaveformBitmap.Create(size.x, size.y, 24);