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

[FEATURE] [needs-docs] Classify symmetric #6120

Merged
merged 14 commits into from
Sep 14, 2018

Conversation

pierreloicq
Copy link
Contributor

@pierreloicq pierreloicq commented Jan 20, 2018

Hello,

The goal of this PR is to have symmetric colors and hence classes around a value. It works for equal interval, s.d. method and pretty breaks.
For equal interval and s.d. methods, there is box for the user to put the pivot value. For this, I do not manage to remove the clear button of QgsdoubleSpinBox although ShowClearButton returns false.
For pretty breaks, the pivot value is one of the pretty breaks.

qgis

@pierreloicq
Copy link
Contributor Author

All checks have passed ?? Alleluiaaaaa :-)

@pierreloicq pierreloicq changed the title Classify symmetric [FEATURE] [needs-docs] Classify symmetric Jan 21, 2018
@pierreloicq
Copy link
Contributor Author

@Gustry Would you like to take a look ?

@Gustry
Copy link
Contributor

Gustry commented Mar 15, 2018

I will try your PR later. But I can't review C++ yet ;-)
I already needed this function before I think.

You will need to update your * \since QGIS 3.0 with * \since QGIS 3.2, hopefully, it will land in QGIS this time.

@Gustry
Copy link
Contributor

Gustry commented Mar 15, 2018

Can you also update your branch? Some of your issues with QgsdoubleSpinBox might be fixed. Better to try your PR with a fresh master branch. Thanks

@pierreloicq
Copy link
Contributor Author

pierreloicq commented Mar 18, 2018

So I did:
Update of my master:
git checkout master
git pull upstream master --rebase
git push
rebase classifySummetric and send on github:
git checkout classifySymmetric
git rebase master
git push

change "since 3.0" to "since 3.2", git commit
now if I git push, it tells me:

To https://github.com/pierreloicq/QGIS
! [rejected] classifySymmetric -> classifySymmetric (non-fast-forward)
error: impossible de pousser des références vers 'https://github.com/pierreloicq/QGIS'
astuce: Les mises à jour ont été rejetées car la pointe de la branche courante est derrière
astuce: son homologue distant. Intégrez les changements distants (par exemple 'git pull ...')
astuce: avant de pousser à nouveau.

git branch --vv gives : " 15 behind master, 1265 ahead"
while the distant branch is: 1249 behind master, 15 ahead
1265-1249=15+1
I don't really understand why it tells me that. Is it because I rebased, git does not make the link between the 15 commits ? Did I do something wrong that I need to change to avoid this ?
I could duplicate the branch to make a new one but its a bit messy.
Can I push -f (because I am working alone on this branch )?

Thank you

@DelazJ
Copy link
Contributor

DelazJ commented Mar 18, 2018

Yes you should git push -f because your local and origin branches have diverged (none is the child of the other); afaik it does not have to do with working alone (actually you are not working alone, you have all QGIS team with you in master) but to the rebase action.
And i'm not expert in git but i do not think you made anything wrong, just missed the last bits.

@Gustry
Copy link
Contributor

Gustry commented Mar 18, 2018

If you use the rebase command, yes you have to force push your branch. With rebase, you "re-played" the history of your commits, that you got the error "non-fast-forward".

@pierreloicq
Copy link
Contributor Author

pierreloicq commented Mar 20, 2018

Thank you for your replies.
The warnings in the standard output when I open the layer property window disappeared and the QgsdoubleSpinBox behavior seems ok although the clear button is still there.

A complementary question :
When I do :

git checkout master
git pull upstream master --rebase
git push
git checkout classifySymmetric
git rebase master
git push

the files are changed and after that, the compilation lasts 2h. That's why I would like to avoid checkout (maybe it will not change anything?). Is it possible to update master without checkout ? Something like :

while on my working branch
git pull upstream master --rebase
git push

@Gustry
Copy link
Contributor

Gustry commented Mar 24, 2018

As soon as you update the branch with master, it will take time to re-compile. It depends how old your branch was and files that have been updated in master.
To speed up the compilation, you need to setup ccache and ninja, check in the readme https://github.com/qgis/QGIS/blob/master/INSTALL

@pierreloicq
Copy link
Contributor Author

Yes, it is already installed.
it is written :

Switching git branches will again cause longer initial build times unless
separate build directories are used for each branch.

I have only 1 build directory but I never try to compile master.

@Gustry
Copy link
Contributor

Gustry commented Apr 19, 2018

As soon as you rebase on master, the build will be longer, because it needs to recompile the branch.

Can you include some description and new screenshots in the PR? I know it was in the previous PR, but it will be easier for reviewers to see the UI from this PR.

I gave it it a try today, it was working fine.
Can we have some advice from others who commented on previous PR? @anitagraser @andreasneumann @kannes ? #5161 and #5370

@pierreloicq
Copy link
Contributor Author

Thank you Etienne, I put the description in my first post

@kannes
Copy link
Contributor

kannes commented Apr 24, 2018

This is awesome(!) but I see some problems which I will detail later today.

One that is easy to explain is the width the Styling Panel gets with this. Hit F7 to show it and you will see. I guess the elements should refloat to a vertical layout if needed.

@kannes
Copy link
Contributor

kannes commented Apr 24, 2018

I used ne_10m_admin_1_states_provinces.shp and its attribute OBJECTID_1 for testing.

a) First of all, a screenshot of the layout being too wide for the side-panel:
too wide for the panel

b) I was going to suggest using the median or average of the selected column instead of 1.00 as initial value. BUT then I realised this might entice people to use divergent color schemes without thinking just because they fit that symmetry. So I am not sure. I was confused getting several 1.00-1.00 classes at my first try. Hm...

c and d were QGIS bugs.

e) QGIS crashes shortly after I set Pretty Breaks to a single class.

@pierreloicq
Copy link
Contributor Author

Hello,
I just corrected these 2 problems.
Because of the conflict noticed by github, I updated master but when I want to rebase classifySymmetric, I again have a lot of conflicts on old commits. Is there any way to bypass this ?
Thank you

@pierreloicq
Copy link
Contributor Author

This small conflict can be resolved online, but for the moment, I don't dare to click on the "commit merge" button because it messed up my things last time.

@DelazJ
Copy link
Contributor

DelazJ commented May 10, 2018

Hi @pierreloicq
Maybe you can also squash your commits to a smaller number. I'm not sure all these commits messages (duplicate message, conflict fix) are relevant so a git rebase -i HEAD~17 leading to the necessary commit messages could be of help: less commits (changing the same lines) would reduce the number of time you'd likely hit conflict when rebasing onto master. Hth

@pierreloicq pierreloicq force-pushed the classifySymmetric branch 2 times, most recently from bc5a430 to 1cb26a8 Compare May 13, 2018 15:03
@pierreloicq
Copy link
Contributor Author

Thank you @DelazJ, it worked fine.
I finally improved the problem b) by using the mid-range value as default.

@Gustry
Copy link
Contributor

Gustry commented May 13, 2018

I just gave a quick look on the files. You need to remove the file ending by .sip and keep .sip.in. It's a duplicate.

Do you mean that all issues from @kannes are fixed?

@pierreloicq
Copy link
Contributor Author

Yes, all issues form @kannes are fixed.
I removed the .sip

@Gustry
Copy link
Contributor

Gustry commented May 14, 2018

Another SIP issue due to #6986
You need to update your branch again.

@pierreloicq
Copy link
Contributor Author

Done !

@pierreloicq
Copy link
Contributor Author

Now I have a qgsgraduatedsymbolrenderer.sip generated during the compilation but none in my source. And the compilator says :
sip: core/auto_generated/symbology/qgsgraduatedsymbolrenderer.sip:333: syntax error
line 333 is:
QStringList listForCboPrettyBreaks = {},
What can I do ? @nyalldawson @Gustry
My master is up to date.

@m-kuhn
Copy link
Member

m-kuhn commented Sep 4, 2018

Looks like a problem that sipify doesn't understand list initialization.
There are two possibilities:

  • Fix sipify
  • Replace {} with QStringList()

@pierreloicq
Copy link
Contributor Author

pierreloicq commented Sep 4, 2018

Thank you Matthias, it works.
Is there a way to run a specific test instead of all (with "ninja test") ?

@m-kuhn
Copy link
Member

m-kuhn commented Sep 4, 2018

Yes
ctest -R Graduated or any other regex that matches your test use ctest -V -R Graduated if you need to see more output.

@Gustry
Copy link
Contributor

Gustry commented Sep 4, 2018

If it's a c++ test and if you use QtCreator, instead of choosing qgis, choose qgis_graduated......

qgis master - qgis - qt creator_001

So you can use the debugger

@pierreloicq
Copy link
Contributor Author

pierreloicq commented Sep 4, 2018

Good ! I try to test my function _makeBreaksSymmetric but this is not a class function and it does not seem to be taken into account during the test. I pushed so that you can take a look. Thanks

@@ -31,6 +35,7 @@ class TestQgsGraduatedSymbolRenderer: public QObject
void cleanup();// will be called after every testfunction.
void rangesOverlap();
void rangesHaveGaps();
void _makeBreaksSymmetric(QList<double> &breaks, double symmetryPoint, bool astride);
Copy link
Contributor

@Gustry Gustry Sep 4, 2018

Choose a reason for hiding this comment

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

Shouldn't you call _makeBreaksSymmetric without arguments?

This is a list of function that the test will call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no the 3 functions are linked, if I want to call it line 152, arguments are needed (compilator complains)


QVERIFY( breaks.contains( symmetryPoint) );
// /!\ breaks contain the maximum of the distrib but not the minimum ?
QVERIFY( breaks.count() % 2 == 0 );
Copy link
Member

Choose a reason for hiding this comment

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

instead of using == use QCOMPARE

breaks = unchanged_breaks;
symmetryPoint = 12.0;
astride = false;
_makeBreaksSymmetric( breaks, symmetryPoint, astride );
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit puzzled by this call. Will this not create an infinite recursion on this method?

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 don't understand how I am supposed to apply my function then.
I tried lot of things, its the only version that compiles.
Am I supposed to declare my parameters in init() ? Maybe with a pointer so that I can access them after without parameters ?

Copy link
Member

Choose a reason for hiding this comment

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

I guess you want a test function (without parameters) that calls this function with appropriate parameters?

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 don't know. Something that works will be enough.
Maybe I am obliged to make _makeBreaksSymmetric() a class function ?

@pierreloicq
Copy link
Contributor Author

pierreloicq commented Sep 5, 2018

@kannes you asked me

It would be great if changes to the "around"-value would immediately update the map (without hitting enter or another thing). This is useful if one uses the mouse wheel to change the values for immediate feedback.

I can do that by using the valueChanged signal instead of editingFinished, but then I cannot type the number with keyboard, it's always erased by the initial value, and I didn't find a way to bypass this so I put back the editingFinished.

@pierreloicq
Copy link
Contributor Author

pierreloicq commented Sep 6, 2018

Here are the tests. They are not successful if the values to classify are below something like 1E-6. Is it expected that, using doubles, 2.6E-06 - 2E-06 = 0 ?

@Gustry
Copy link
Contributor

Gustry commented Sep 12, 2018

Nice work about your unittest. It seems you could manage it.
Dev, is-it good from the C++ side?
I can try to compile it

@Gustry
Copy link
Contributor

Gustry commented Sep 14, 2018

I could try the PR. Looks good! No crash. @kannes did a review already.
I don't have the best use case tonight. But as this PR is working only when we enable the checkbox "symmetric around", this looks self-contained regarding this new label "FreakingLastMinutePreFreezeMergeCandidate" ;-)

These are advanced settings which we don't want to show
up front, at risk of hurting UI simplicity
@nyalldawson
Copy link
Collaborator

@pierreloicq I just pushed a couple of last minute fixes/tweaks. Just some minor code conventions (use of switch statements when comparing enums, and hiding some private api from the python bindings -- we don't want single use methods exposed as they become subject to the stable API contract, and we may want to tweak the ui in future and need to modify these methods).

I've also reworked the UI so that it works nicely in the docked widget mode (everything needs to be nice and narrow for that to work).

Let's see what Travis says... if this passes, I'll merge for 3.4!

Thanks for all your hard work here 🎉

@nyalldawson nyalldawson merged commit f2c9160 into qgis:master Sep 14, 2018
@nyalldawson
Copy link
Collaborator

...and in for 3.4! Thanks again @pierreloicq !

@pierreloicq
Copy link
Contributor Author

Thank you guys, I'm so happy :-) :-)

@nyalldawson
Copy link
Collaborator

Better send in a follow up PR, adding yourself to the contributors map! ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Requires Changes! Waiting on the submitter to make requested changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants