Select curve only, when clicked near curve
Closed, ResolvedPublic

Description

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.

Limitations: At the moment only the distance to the curve points will be calculated. It will not respect the interpolation line. Problem, at very high gradients, or zoomed in where there is a big scene distance between two points.

video:
patch:

Murmele created this task.Dec 20 2018, 2:00 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?

asemke closed this task as Resolved.Oct 14 2019, 8:15 AM
asemke moved this task from Current Release to Done on the LabPlot board.Oct 15 2019, 6:48 AM