Copy root value or (x,y) pair to clipboard
ClosedPublic

Authored by yurchor on Dec 7 2018, 1:56 PM.

Details

Summary
Test Plan
  1. Plot some function with a known root (e.g. f(x) = x^2).
  2. Left-click on the curve then right-click on it.
  3. Choose "Copy (x, y)". Paste the result somewhere (e.g. in KWrite).
  4. Move mouse pointer close to the root then right-click.
  5. Choose "Copy Root Value". Paste the result somewhere (e.g. in KWrite).
  6. Move mouse elsewhere then right-click. The "Copy Root Value" item should disappear from the popup menu.

Diff Detail

Repository
R334 KmPlot
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
yurchor created this revision.Dec 7 2018, 1:56 PM
Restricted Application added a project: KDE Edu. · View Herald TranscriptDec 7 2018, 1:56 PM
Restricted Application added a subscriber: kde-edu. · View Herald Transcript
yurchor requested review of this revision.Dec 7 2018, 1:56 PM
yurchor updated this revision to Diff 47180.Dec 9 2018, 1:36 PM

Add some documentation.

Restricted Application added a project: Documentation. · View Herald TranscriptDec 9 2018, 1:36 PM
Restricted Application added a subscriber: kde-doc-english. · View Herald Transcript
aacid added a subscriber: aacid.Dec 9 2018, 5:17 PM

Why do i get a "copy root value" option on f(x) = x that doesn't really have a root?

Why do i get a "copy root value" option on f(x) = x that doesn't really have a root?

Because technically it has a root (x=0) and exactly this value will be copied.

To be honest, this new feature introduces nothing that has not already been in the interface. Statusbar shows "root: x_0 = +0.00000" as well.

aacid added inline comments.Dec 9 2018, 9:19 PM
kmplot/maindlg.h
219

for consistence i'd initialzie this in the constructor to 0 or something

kmplot/view.cpp
3519

spacing here looks weird to me and looks like it should be on the same horizontal position as "else" but since you didn't use arc i can't see the rest of the file to see if that's actually the style for the file, feel free to ignore this.

kmplot/view.h
215

please add a getter, don't make this member variable public.

243

i was going to complain how callign a signal setXXX makes no sense, because the signal is not setting anything, it's just saying something happened, so it should be really called rootValueChanged or updateRootValue or something like that but i see the one above is call set, so meh, i guess leave it if you don't agree with rootValueChanged being a better name.

yurchor marked 4 inline comments as done.Dec 10 2018, 6:06 AM

All issues should be fixed now. Thanks.

yurchor updated this revision to Diff 47236.Dec 10 2018, 6:09 AM

Fix getter, indentation and signal name.

yurchor updated this revision to Diff 47470.Dec 12 2018, 5:43 PM

Get rid of unrelated changes, more locale-friendly result formatting for "Copy (x, y)".

yurchor updated this revision to Diff 47588.Dec 14 2018, 7:44 PM

Fix indentation. Sorry.

tcanabrava requested changes to this revision.Dec 24 2018, 1:08 PM
tcanabrava added a subscriber: tcanabrava.
tcanabrava added inline comments.
kmplot/view.h
215

this should be const. please take a look on const correctness

This revision now requires changes to proceed.Dec 24 2018, 1:08 PM
yurchor updated this revision to Diff 48128.Dec 24 2018, 1:32 PM
yurchor marked an inline comment as done.

Add "const".

tcanabrava requested changes to this revision.Dec 24 2018, 2:20 PM
tcanabrava added inline comments.
kmplot/view.h
215

Sorry, you added the wrong const.

const QPointF getCrosshairPosition(); means that the QPointF that's being returned is a const.

QPointF getCrosshairPosition() const; means that the *method* is constant and cannot change the this-pointer or any internals.

take the time to look at the link I provided about const correctness.

This revision now requires changes to proceed.Dec 24 2018, 2:20 PM
yurchor updated this revision to Diff 48134.Dec 24 2018, 3:22 PM

Move "const" to the place where it should be.

tcanabrava accepted this revision.Jan 14 2019, 5:26 PM
This revision is now accepted and ready to land.Jan 14 2019, 5:26 PM
This revision was automatically updated to reflect the committed changes.