Select curve only, when clicked near curve
ClosedPublic

Authored by Murmele on Dec 22 2018, 10:53 AM.

Details

Summary

The current behavior is, that when you click into a cartesianPlot with a curve, it is not possible to call the contextmenu of the cartesianPlot or select a curve, which is behind the most in front curve, because the clicks and mouse hovers gets the most in front object and for a curve the complete boundingrect will be used. With this patch it will be looked, if the mousecursor is near to the curve points and only a action on the curve will occur, when the distance to the curve is lower than a factor.

It is an alternative to the selection detection with the shape

video:

Diff Detail

Repository
R262 LabPlot
Lint
Lint Skipped
Unit
Unit Tests Skipped
Murmele created this revision.Dec 22 2018, 10:53 AM
Restricted Application added a project: KDE Edu. · View Herald TranscriptDec 22 2018, 10:53 AM
Restricted Application added a subscriber: kde-edu. · View Herald Transcript
Murmele requested review of this revision.Dec 22 2018, 10:53 AM

Thanks.

src/backend/core/AbstractColumn.cpp
567

This line should be removed (there is no parameter "recalculate" to describe).

This patch doesn't seem to contain the logic required for what you demonstrated in the video. It's only about the calculation of properties. Did you forget to add some other changes to this patch?

Please be aware of our code style which is documented src/doc/coding_style.dox. The relevant parts for this patch are:

  • we don't use any brackets for one-line if-else statements
  • we use spacing after 'if' and before the opening bracket - if (condition) {...

You can also check the file admin/READMY.astyle to see how to quickly re-format the code according to LabPlot's code style.

src/backend/core/column/Column.cpp
436

why do you update the column properties here? Why not to update only when asked for in Column::columnProperties() similar to how this is done for statistics in Column::statistics()?

453

same here.

470

same here.

487

same here.

713

this part should't be required. It's enough to set d->columnPropertiesAvailable = false; below and to update the properties on demand in Column::columnProperties().

src/backend/core/column/ColumnPrivate.cpp
1252

this variable is only used in the DEBUG output below where name() can be used directly.

Murmele updated this revision to Diff 48088.Dec 23 2018, 5:42 PM
Murmele marked 2 inline comments as done.
  • change codestyle
  • add CartesianPlot logic
Murmele updated this revision to Diff 48102.Dec 23 2018, 10:58 PM
Murmele marked 5 inline comments as done.

we mostly used the camel case naming convention. You seem to mix different conventions like in xdistsquare (instead of xDistSquare) and lower_index(instead of lowerIndex). Can you please unify the naming?

Furthermore, we'll need to extend this logic to datetime data type where we store QDateTime instead of doubles in the column. But let's finalize this patch firs and extend/adjust the logic after that.

src/backend/worksheet/plots/cartesian/XYCurve.cpp
1694 ↗(On Diff #48102)

this is a very valid question :-)

2371 ↗(On Diff #48102)

this block can be simplified to

m_hovered = on;
on ? emit q->hovered() : emit q->unhovered();
update()
Murmele marked an inline comment as done.Dec 25 2018, 9:12 PM

Can the code:

    //to select curves having overlapping bounding boxes we need to check whether the cursor
    //is inside of item's shapes and not inside of the bounding boxes (Qt's default behaviour).
    if(m_cartesianPlotMouseMode == CartesianPlot::MouseMode::SelectionMode){
		for (auto* item : items(event->pos())) {
			if (!dynamic_cast<XYCurvePrivate*>(item))
				continue;

			if ( item->shape().contains(item->mapFromScene(mapToScene(event->pos()))) ) {
				//deselect currently selected items
				for (auto* selectedItem : scene()->selectedItems())
					selectedItem->setSelected(false);

				//select the item under the cursor and update the current selection
				item->setSelected(true);
				selectionChanged();

				return;
			}
		}
    }

In worksheetView.cpp, line944 to 963 be deleted?

src/backend/core/column/Column.cpp
436

Problem is, that in XYCurve the column member is const, so I'm not able to update from XYCurve.
Should I reset AbstractColumn to not const?

436

made columnPropertiesAvailable and columnProperties mutable

Murmele updated this revision to Diff 48323.Dec 28 2018, 10:28 PM
Murmele updated this revision to Diff 50259.Jan 25 2019, 2:29 PM

Must be added after increase draw velocity. If it will be used

Murmele edited the summary of this revision. (Show Details)Jan 25 2019, 2:30 PM
Murmele updated this revision to Diff 56659.Apr 21 2019, 1:46 PM
Murmele updated this revision to Diff 57443.May 3 2019, 8:52 AM

Disable selection when clicking on shape.

Murmele updated this revision to Diff 57445.May 3 2019, 8:52 AM

don't hover invisible curves

Murmele updated this revision to Diff 57456.May 3 2019, 12:08 PM
  • remove brackets for one line conditions
  • add comments

Thanks in advance for fixing this minor issue.

src/backend/worksheet/plots/cartesian/XYCurve.cpp
2485 ↗(On Diff #48102)

"\p p1 and \p p2" to not break Doxygen syntax.

http://www.doxygen.nl/manual/commands.html#cmdp

asemke accepted this revision.May 4 2019, 8:22 AM

I'll remove the unused parameters lowerIndex, higherIndex and max_steps in XYCurvePrivate::activateCurve(), use \p instead of \param as mentioned by @yurchor and land your patch. Thanks.

This revision is now accepted and ready to land.May 4 2019, 8:22 AM
This revision was automatically updated to reflect the committed changes.