-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Added V-Mapper:Z for flipped orientation panels chains #1014
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
Changes from 11 commits
1c51f89
5a10b55
d79903c
d6c8ffb
51a4b03
28e12fb
b6f6dbd
f4b9eec
308a2b6
af718b0
6df947b
9869469
7ad630d
60ae39d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -228,6 +228,14 @@ class VerticalMapper : public PixelMapper { | |
| virtual bool SetParameters(int chain, int parallel, const char *param) { | ||
| chain_ = chain; | ||
| parallel_ = parallel; | ||
| // optional argument :Z allow for every other panel to be flipped | ||
| // upside down so that cabling can be shorter: | ||
| // [ O < I ] without Z [ O < I ] | ||
| // ,---^ <---- ^ | ||
| // [ O < I ] [ I > O ] | ||
| // ,---^ with Z ^ | ||
| // [ O < I ] ---> [ O < I ] | ||
| z_ = (param && strcmp(param, "Z") == 0) ? 1 : 0; | ||
| return true; | ||
| } | ||
|
|
||
|
|
@@ -237,24 +245,39 @@ class VerticalMapper : public PixelMapper { | |
| *visible_width = matrix_width * parallel_ / chain_; | ||
| *visible_height = matrix_height * chain_ / parallel_; | ||
| #if 0 | ||
| fprintf(stderr, "%s: C:%d P:%d. Turning W:%d H:%d Physical " | ||
| "into W:%d H:%d Virtual\n", | ||
| GetName(), chain_, parallel_, | ||
| *visible_width, *visible_height, matrix_width, matrix_height); | ||
| fprintf(stderr, "%s: C:%d P:%d. Turning W:%d H:%d Physical " | ||
| "into W:%d H:%d Virtual\n", | ||
| GetName(), chain_, parallel_, | ||
| *visible_width, *visible_height, matrix_width, matrix_height); | ||
| #endif | ||
| return true; | ||
| } | ||
|
|
||
| virtual void MapVisibleToMatrix(int matrix_width, int matrix_height, | ||
| int x, int y, | ||
| int *matrix_x, int *matrix_y) const { | ||
| int panel_width = matrix_width / chain_; | ||
| int panel_height = matrix_height / parallel_; | ||
| const int panel_width = matrix_width / chain_; | ||
| const int panel_height = matrix_height / parallel_; | ||
|
|
||
| *matrix_x = (x % panel_width) + int(y/panel_height)* panel_width; | ||
| *matrix_y = (y % panel_height) + int(x/panel_width) * panel_height; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be easier and more readable to figure out if we need flipping first, and then do the one or the other ? It is very hard to follow to first do the assignment, and then additional modifications later. So start with an expression that figures out if we should do flipping And then either some or, maybe even more readable
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, I'm a bit torn. I'll be honest that I had a hard time figuring out what U-mapper was doing, code that was doing smart things with virtually no comments :)
For #1: I'll wager that the transform table is computed once at startup and that loosing maybe a millisecond (just made that up) to a few double assigns, is not a prime concern. For #2: I wrote the codeflow to make it very clear which one of a b or c is happening. I kind of like the code the way it is because it's pretty simple to follow. Keep in mind that we're not top SWEs, so keeping it a bit easier to read, is a plus IMO.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, efficientcy we don't care, it only happens once. But readability. Multiple assignments to things require you to keep track of it when reading. You do and undo things, while all we need to choose is if we need flipping or not, and formulate the expression accordingly. What happens now is
This is really hard to follow.
And once you've done this, you'll notice, that the ?: version of the same is even more readable.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mmmh, so please don't take this as me trying to argue with you :) a) needs to be done regardless, it's not a) or c), nor does c) undo a) If you do see an obvious way to rewrite this in a short and yet still readable way, would you be ok merging this and modifying it the way you had in mind?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (and yes, calculating from the already transposed value is particularly mind-bending)
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disagree that a) needs to be done regardless. We either do a) or we do the 'flipped a'. Right now you have to take the one a) and have to do gymnastics to then flip it. I don't try to make it more complicated or 'smart', I actually suggest this to make it more simple that even I would understand it (right now, it twists my brain). We can merge it and I can have a look later.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "and yes, calculating from the already transposed value is particularly mind-bending" => you'll hate me, I found it easier to vizualize after the transposition than before :) |
||
|
|
||
| if (z_) { | ||
marcmerlin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const int x_panel_offset_cnt = *matrix_x / panel_width; | ||
|
|
||
| if (x_panel_offset_cnt % 2) { | ||
| const int x_panel_offset = x_panel_offset_cnt * panel_width; | ||
| const int y_panel_offset_cnt = *matrix_y / panel_height; | ||
| const int y_panel_offset = y_panel_offset_cnt * panel_height; | ||
|
|
||
marcmerlin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| *matrix_x = panel_width - (*matrix_x - x_panel_offset) - 1 + x_panel_offset; | ||
| *matrix_y = panel_height - (*matrix_y - y_panel_offset) - 1 + y_panel_offset; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private: | ||
| bool z_; | ||
| int chain_; | ||
| int parallel_; | ||
| }; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.