Skip to content

issue 18 : Inverted background colors #64

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

Merged
merged 2 commits into from
Sep 11, 2017

Conversation

alixdamman
Copy link
Contributor

No description provided.

@alixdamman alixdamman requested a review from gdementen September 8, 2017 08:25
hue = self.hue0 + self.dhue * (self.vmax - color_val) / maxdiff
color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
return to_qvariant(color)
bg_gradient = LinearGradient([(self.vmin, self.hsv_min), (self.vmax, self.hsv_max)])
Copy link
Collaborator

Choose a reason for hiding this comment

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

You shouldn't recreate the gradient object over and over for each cell! Why not storing it in self.bg_gradient?

Also, I wonder if we couldn't get rid of bgcolor_enabled: if all bg color goes through self.bg_gradient, I think self.bg_gradient is not None <=> bgcolor_enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I may misunderstood the LinearGradient class. It is possible to change positions without changing colors, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, it is not really meant to work at the moment (*), but you can still only create the gradient object when vmin/vmax changes, not for each cell displayed.

Actually, setting the gradient .positions attribute directly should work, but I wouldn't do that unless we wrap that in a property to make sure .positions and .colors keep the same size.

If you go down that route, maybe changing the constructor to take positions and colors separately, would make it more obvious that we can change either individually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we drop bgcolor_enabled, it means that we need to create a new LinearGradient when vmin and vman are changed but also in bgcolor() method if state > 0?

Copy link
Collaborator

@gdementen gdementen Sep 8, 2017

Choose a reason for hiding this comment

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

Yes, I did not realize that. Forget it then, that seems more trouble than it is worth.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In DataArrayModel.data(), what is the purpose of the following piece of code? :

    bg_value = self.bg_value
     x, y = index.row(), index.column()
     # FIXME: this is buggy on filtered data. We should change
     # bg_value when changing the filter.
     idx = y + x * bg_value.shape[-1]
     value = bg_value.data.flat[idx]
     return self.bg_gradient[value]

The background color of each cell is given by its position?

Copy link
Collaborator

Choose a reason for hiding this comment

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

the value used to compute the background color comes from another array. This is used to let compare color values depending on the difference between arrays instead of the array values themselves. This code is a hack though and (as the comment states) breaks as soon as the data is filtered.

@alixdamman alixdamman merged commit a090443 into larray-project:master Sep 11, 2017
@alixdamman alixdamman deleted the invert_colors_18 branch September 11, 2017 10:07
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.

2 participants