Skip to content

Commit

Permalink
(Experimental) Aggressive bar width downscaling
Browse files Browse the repository at this point in the history
This change allows the application to display as much as 8192 elements without the visualization going past the screen borders. It is possible to go past 8192 elements, but the application will lag at this point. 0.2 downscaling will not work for displaying large array sizes, 0.1 downscaling will allow displaying up to 12000 array elements, but again, this will cause huge lag.
  • Loading branch information
Unbreakable-Syntax authored Oct 10, 2024
1 parent 2297869 commit 5d364ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/SortTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ bool SortTestApp::OnInit()
}

static size_t testsize[] = {
10, 11, 12, 13, 14, 15, 16, 32,
100, 101, 102, 103, 200,
1024, 1337, 2048,
0
10, 11, 12, 13, 14, 15, 16, 32, 100, 101, 102, 103, 200, 1024, 1337, 1600, 2048, 2500,
3072, 3500, 4096, 4500, 5000, 5600, 6144, 6500, 7000, 7500, 8192, 0
};

struct SortedCheck
Expand Down
8 changes: 5 additions & 3 deletions src/WSortView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,12 @@ void WSortView::paint(wxDC& dc, const wxSize& dcsize)
//double bstep = 1.5 * wbar;

// 2nd variant: one pixel between bars
double wbar = (width - (size-1)) / (double)size;
if (width <= (size-1)) wbar = 0.0;

double wbar = wxMax(1.0, (width - (size - 1)) / (double)size);
double bstep = wbar + 1.0;
if (size > width) {
wbar = wxMax(0.1, width / (double)size); // Scale down further if too many elements
bstep = wbar;
}

// special case for bstep = 2 pixel -> draw 2 pixel bars instead of 1px
// bar/1px gaps.
Expand Down

1 comment on commit 5d364ec

@Unbreakable-Syntax
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that this change should be stable now.

Please sign in to comment.