43 qRegisterMetaType<pappso::BasePlotContext>(
"pappso::BasePlotContext");
45 qRegisterMetaType<pappso::BasePlotContext *>(
"pappso::BasePlotContext *");
52 qFatal(
"Programming error.");
55 m_pen.setStyle(Qt::SolidLine);
56 m_pen.setBrush(Qt::black);
76 qFatal(
"Programming error.");
110 const QString &x_axis_label,
111 const QString &y_axis_label)
116 if(parent ==
nullptr)
117 qFatal(
"Programming error.");
120 m_pen.setStyle(Qt::SolidLine);
121 m_pen.setBrush(Qt::black);
124 xAxis->setLabel(x_axis_label);
125 yAxis->setLabel(y_axis_label);
144 qFatal(
"Programming error.");
177 for(
int iter = 0; iter < layerCount(); ++iter)
180 QString(
"Layer index %1: %2\n").arg(iter).arg(layer(iter)->name());
189 if(layerable_p ==
nullptr)
190 qFatal(
"Programming error.");
192 QCPLayer *layer_p = layerable_p->layer();
194 return layer_p->name();
200 if(layerable_p ==
nullptr)
201 qFatal(
"Programming error.");
203 QCPLayer *layer_p = layerable_p->layer();
205 for(
int iter = 0; iter < layerCount(); ++iter)
207 if(layer(iter) == layer_p)
229 pen.setColor(QColor(
"steelblue"));
254 pen.setColor(QColor(
"green"));
265 pen.setColor(QColor(
"red"));
296 pen.setColor(
"steelblue");
361 "plotsLayer", layer(
"background"), QCustomPlot::LayerInsertMode::limAbove);
363 addLayer(
"labelsLayer", layer(
"background"), QCustomPlot::LayerInsertMode::limAbove);
368 setFocusPolicy(Qt::StrongFocus);
369 setInteractions(QCP::iRangeZoom | QCP::iSelectPlottables | QCP::iMultiSelect);
379 &QCustomPlot::mouseRelease,
387 &QCustomPlot::axisDoubleClick,
391 connect(
this, &QCustomPlot::beforeReplot,
this, [&]() { emit
beforeReplotSignal(); });
392 connect(
this, &QCustomPlot::afterLayout,
this, [&]() { emit
afterLayoutSignal(); });
393 connect(
this, &QCustomPlot::afterReplot,
this, [&]() { emit
afterReplotSignal(); });
412 const QColor &new_color)
414 if(plottable_p ==
nullptr)
415 qFatal(
"Pointer cannot be nullptr.");
420 pen = plottable_p->pen();
421 pen.setColor(new_color);
422 plottable_p->setPen(pen);
430 if(!new_color.isValid())
433 QCPGraph *graph_p = graph(index);
435 if(graph_p ==
nullptr)
436 qFatal(
"Programming error.");
444 if(plottable_p ==
nullptr)
445 qFatal(
"Programming error.");
447 return plottable_p->pen().color();
453 QCPGraph *graph_p = graph(index);
455 if(graph_p ==
nullptr)
456 qFatal(
"Programming error.");
464 xAxis->setLabel(label);
470 yAxis->setLabel(label);
568 qFatal(
"Programming error.");
612 m_context.m_pressedKeyCode =
event->key();
613 m_context.m_keyboardModifiers = QGuiApplication::queryKeyboardModifiers();
615 if(event->key() == Qt::Key_Left || event->key() == Qt::Key_Right ||
616 event->key() == Qt::Key_Up || event->key() == Qt::Key_Down)
637 m_context.m_releasedKeyCode =
event->key();
642 m_context.m_keyboardModifiers = QGuiApplication::queryKeyboardModifiers();
645 if(event->key() == Qt::Key_Backspace)
654 else if(event->key() == Qt::Key_Space)
658 else if(event->key() == Qt::Key_Delete)
671 int graph_count = plottableCount();
694 QList<QCPGraph *> selected_graph_list;
696 selected_graph_list = selectedGraphs();
698 if(!selected_graph_list.size())
707 for(
int iter = 0; iter < selected_graph_list.size(); ++iter)
714 this, selected_graph_list.at(iter),
m_context);
727 else if(event->key() == Qt::Key_T)
739 else if(event->key() == Qt::Key_Left || event->key() == Qt::Key_Right ||
740 event->key() == Qt::Key_Up || event->key() == Qt::Key_Down)
749 else if(event->key() == Qt::Key_S)
767 m_context.m_integrationScopeRhombWidth = 0;
768 m_context.m_integrationScopeRhombHeight = abs(
780 m_context.m_integrationScopeRhombWidth = abs(
782 m_context.m_integrationScopeRhombHeight = 0;
819 int pixel_increment = 0;
821 if(
m_context.m_keyboardModifiers == Qt::NoModifier)
823 else if(
m_context.m_keyboardModifiers == Qt::AltModifier)
824 pixel_increment = 50;
830 if(event->key() == Qt::Key_Left)
832 else if(event->key() == Qt::Key_Right)
834 else if(event->key() == Qt::Key_Up)
836 else if(event->key() == Qt::Key_Down)
851 [[maybe_unused]] QKeyEvent *event)
860 QPointF pixel_coordinates(
861 xAxis->coordToPixel(
m_context.m_lastCursorHoveredPoint.x()),
862 yAxis->coordToPixel(
m_context.m_lastCursorHoveredPoint.y()));
864 Qt::MouseButton button = Qt::NoButton;
865 QEvent::Type q_event_type = QEvent::MouseButtonPress;
871 button = Qt::LeftButton;
873 m_context.m_isLeftPseudoButtonKeyPressed =
874 !
m_context.m_isLeftPseudoButtonKeyPressed;
876 if(
m_context.m_isLeftPseudoButtonKeyPressed)
877 q_event_type = QEvent::MouseButtonPress;
879 q_event_type = QEvent::MouseButtonRelease;
885 button = Qt::RightButton;
887 m_context.m_isRightPseudoButtonKeyPressed =
888 !
m_context.m_isRightPseudoButtonKeyPressed;
890 if(
m_context.m_isRightPseudoButtonKeyPressed)
891 q_event_type = QEvent::MouseButtonPress;
893 q_event_type = QEvent::MouseButtonRelease;
901 QMouseEvent *mouse_event_p =
902 new QMouseEvent(q_event_type,
904 mapToGlobal(pixel_coordinates.toPoint()),
905 mapToGlobal(pixel_coordinates.toPoint()),
909 Qt::MouseEventSynthesizedByApplication);
911 if(q_event_type == QEvent::MouseButtonPress)
916 delete mouse_event_p;
943 QPointF mousePoint =
event->position();
947 m_context.m_lastCursorHoveredPoint.setX(xAxis->pixelToCoord(mousePoint.x()));
948 m_context.m_lastCursorHoveredPoint.setY(yAxis->pixelToCoord(mousePoint.y()));
958 if(
m_context.m_pressedMouseButtons & Qt::LeftButton ||
959 m_context.m_pressedMouseButtons & Qt::RightButton)
1006 xAxis->range().lower,
m_context.m_lastCursorHoveredPoint.y());
1008 xAxis->range().upper,
m_context.m_lastCursorHoveredPoint.y());
1019 m_context.m_lastCursorHoveredPoint.x(), yAxis->range().upper);
1021 m_context.m_lastCursorHoveredPoint.x(), yAxis->range().lower);
1042 m_context.m_keyboardModifiers = QGuiApplication::queryKeyboardModifiers();
1060 yAxis->range().upper);
1063 yAxis->range().lower);
1106 if(
m_context.m_mouseButtonsAtMousePress & Qt::LeftButton)
1110 else if(
m_context.m_mouseButtonsAtMousePress & Qt::RightButton)
1130 m_context.m_isMeasuringDistance =
false;
1139 if(
m_context.m_keyboardModifiers & Qt::ControlModifier)
1161 if(
m_context.m_pressedKeyCode == Qt::Key_Q)
1265 m_context.m_isMeasuringDistance =
false;
1312 QPointF mousePoint =
event->position();
1314 m_context.m_lastPressedMouseButton =
event->button();
1315 m_context.m_mouseButtonsAtMousePress =
event->buttons();
1319 m_context.m_pressedMouseButtons |=
event->button();
1394 m_context.m_startDragPoint.setX(xAxis->pixelToCoord(mousePoint.x()));
1395 m_context.m_startDragPoint.setY(yAxis->pixelToCoord(mousePoint.y()));
1405 m_context.m_lastCursorHoveredPoint.x(), yAxis->range().upper);
1407 m_context.m_lastCursorHoveredPoint.x(), yAxis->range().lower);
1426 m_context.m_lastReleasedMouseButton =
event->button();
1431 m_context.m_mouseButtonsAtMouseRelease =
event->buttons();
1435 m_context.m_pressedMouseButtons ^=
event->button();
1441 m_context.m_keyboardModifiers = QGuiApplication::keyboardModifiers();
1471 m_context.m_lastCursorHoveredPoint.y());
1473 m_context.m_lastCursorHoveredPoint.y());
1480 yAxis->range().upper);
1482 yAxis->range().lower);
1504 if(
m_context.m_lastReleasedMouseButton == Qt::LeftButton)
1508 else if(
m_context.m_lastReleasedMouseButton == Qt::RightButton)
1601 if(
m_context.m_keyboardModifiers & Qt::ControlModifier)
1639 double x_delta_pixel =
1640 fabs(xAxis->coordToPixel(
m_context.m_currentDragPoint.x()) -
1641 xAxis->coordToPixel(
m_context.m_startDragPoint.x()));
1643 if(x_delta_pixel > 3)
1658 m_context.m_xRange = QCPRange(xAxis->range());
1659 m_context.m_yRange = QCPRange(yAxis->range());
1675 [[maybe_unused]] QCPAxis::SelectablePart part,
1680 m_context.m_keyboardModifiers = QGuiApplication::queryKeyboardModifiers();
1682 if(
m_context.m_keyboardModifiers & Qt::ControlModifier)
1711 m_context.m_pressedMouseButtons ^=
event->button();
1723 QCPLayoutElement *layoutElement = layoutElementAt(mousePoint);
1726 layoutElement ==
dynamic_cast<QCPLayoutElement *
>(axisRect()))
1732 QCPAxis::SelectablePart selectablePart;
1734 selectablePart = xAxis->getPartAt(mousePoint);
1736 if(selectablePart == QCPAxis::spAxisLabel ||
1737 selectablePart == QCPAxis::spAxis ||
1738 selectablePart == QCPAxis::spTickLabels)
1748 QCPLayoutElement *layoutElement = layoutElementAt(mousePoint);
1751 layoutElement ==
dynamic_cast<QCPLayoutElement *
>(axisRect()))
1757 QCPAxis::SelectablePart selectablePart;
1759 selectablePart = yAxis->getPartAt(mousePoint);
1761 if(selectablePart == QCPAxis::spAxisLabel ||
1762 selectablePart == QCPAxis::spAxis ||
1763 selectablePart == QCPAxis::spTickLabels)
1788 double x_delta_pixel =
1789 fabs(xAxis->coordToPixel(
m_context.m_currentDragPoint.x()) -
1790 xAxis->coordToPixel(
m_context.m_startDragPoint.x()));
1792 double y_delta_pixel =
1793 fabs(yAxis->coordToPixel(
m_context.m_currentDragPoint.y()) -
1794 yAxis->coordToPixel(
m_context.m_startDragPoint.y()));
1796 if(x_delta_pixel > y_delta_pixel)
1797 return Qt::Horizontal;
1799 return Qt::Vertical;
1807 QPointF pixels_coordinates(xAxis->coordToPixel(graph_coordinates.x()),
1808 yAxis->coordToPixel(graph_coordinates.y()));
1817 QCursor::setPos(mapToGlobal(pixel_coordinates.toPoint()));
1825 QPointF pixel_coord(xAxis->coordToPixel(graph_coord.x()),
1826 yAxis->coordToPixel(graph_coord.y()));
1838 QPointF pixel_coordinates(
1839 xAxis->coordToPixel(
m_context.m_lastCursorHoveredPoint.x()) + pixel_count,
1840 yAxis->coordToPixel(
m_context.m_lastCursorHoveredPoint.y()));
1844 QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
1845 yAxis->pixelToCoord(pixel_coordinates.y()));
1847 return graph_coordinates;
1856 QPointF pixel_coord(xAxis->coordToPixel(graph_coord.x()),
1857 yAxis->coordToPixel(graph_coord.y()));
1869 QPointF pixel_coordinates(
1870 xAxis->coordToPixel(
m_context.m_lastCursorHoveredPoint.x()),
1871 yAxis->coordToPixel(
m_context.m_lastCursorHoveredPoint.y()) + pixel_count);
1875 QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
1876 yAxis->pixelToCoord(pixel_coordinates.y()));
1878 return graph_coordinates;
1889 QCPGraph *graph_p = graph(index);
1891 if(graph_p ==
nullptr)
1892 qFatal(
"Programming error.");
1894 return graph_p->getKeyRange(found_range);
1900 QCPGraph *graph_p = graph(index);
1902 if(graph_p ==
nullptr)
1903 qFatal(
"Programming error.");
1905 return graph_p->getValueRange(found_range);
1911 bool &found_range)
const
1920 found_range =
false;
1922 return QCPRange(0, 1);
1925 if(graphCount() == 1)
1926 return graph()->getKeyRange(found_range);
1928 bool found_at_least_one_range =
false;
1931 QCPRange result_range(QCPRange::minRange + 1, QCPRange::maxRange + 1);
1933 for(
int iter = 0; iter < graphCount(); ++iter)
1935 QCPRange temp_range;
1937 bool found_range_for_iter =
false;
1939 QCPGraph *graph_p = graph(iter);
1944 temp_range = graph_p->getKeyRange(found_range_for_iter);
1946 temp_range = graph_p->getValueRange(found_range_for_iter);
1948 qFatal(
"Cannot reach this point. Programming error.");
1953 if(!found_range_for_iter)
1959 if(!QCPRange::validRange(result_range))
1960 qFatal(
"The obtained range is invalid !");
1963 result_range = temp_range;
1966 found_at_least_one_range =
true;
1973 if(temp_range.lower > result_range.lower)
1974 result_range.lower = temp_range.lower;
1975 if(temp_range.upper < result_range.upper)
1976 result_range.upper = temp_range.upper;
1980 if(temp_range.lower < result_range.lower)
1981 result_range.lower = temp_range.lower;
1982 if(temp_range.upper > result_range.upper)
1983 result_range.upper = temp_range.upper;
1986 qFatal(
"Cannot reach this point. Programming error.");
1994 found_range = found_at_least_one_range;
1996 return result_range;
2035 double xLower = xAxis->range().lower;
2036 double xUpper = xAxis->range().upper;
2040 double yLower = yAxis->range().lower;
2041 double yUpper = yAxis->range().upper;
2061 xAxis->setRange(xLower, xUpper -
m_context.m_xDelta);
2071 yAxis->setRange(yLower, yUpper -
m_context.m_yDelta);
2103 yAxis->setRange(xAxis->range().lower,
2104 std::max<double>(
m_context.m_yRegionRangeStart,
2148 "This function can only be called if the mouse click was on one of the "
2183 QCPRange yAxisRange,
2190 xAxis->setRange(xAxisRange.lower, xAxisRange.upper);
2195 yAxis->setRange(yAxisRange.lower, yAxisRange.upper);
2211 xAxis->setRange(lower, upper);
2221 yAxis->setRange(lower, upper);
2281 bool for_integration)
2301 m_context.m_isMeasuringDistance =
false;
2346 QPointF leftmost_point;
2347 if(!
m_context.msp_integrationScope->getLeftMostPoint(leftmost_point))
2348 qFatal(
"Could not get the left-most point.");
2351 if(!
m_context.msp_integrationScope->getWidth(width))
2352 qFatal(
"Could not get width.");
2355 double x_axis_center_position = leftmost_point.x() + width / 2;
2365 int pixels_away_from_line = 15;
2367 QPointF reference_point_for_y_axis_label_position;
2372 if(
static_cast<int>(
m_context.m_dragDirections) &
2381 pixels_away_from_line *= -1;
2383 if(!
m_context.msp_integrationScope->getTopMostPoint(
2384 reference_point_for_y_axis_label_position))
2385 qFatal(
"Failed to get top most point.");
2389 if(!
m_context.msp_integrationScope->getBottomMostPoint(
2390 reference_point_for_y_axis_label_position))
2391 qFatal(
"Failed to get bottom most point.");
2396 double y_axis_pixel_coordinate =
2397 yAxis->coordToPixel(reference_point_for_y_axis_label_position.y());
2401 double y_axis_modified_pixel_coordinate =
2402 y_axis_pixel_coordinate + pixels_away_from_line;
2405 QPointF pixel_coordinates;
2407 pixel_coordinates.setX(x_axis_center_position);
2408 pixel_coordinates.setY(y_axis_modified_pixel_coordinate);
2411 QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
2412 yAxis->pixelToCoord(pixel_coordinates.y()));
2419 graph_coordinates.y());
2430 QString label_text = QString(
"full x span %1 -- x drag delta %2")
2431 .arg(width, 0,
'f', decimals)
2432 .arg(fabs(
m_context.m_xDelta), 0,
'f', decimals);
2460 if(!
m_context.msp_integrationScope->getHeight(height))
2461 qFatal(
"Could not get height.");
2478 QPointF bottom_most_point;
2479 if(!
m_context.msp_integrationScope->getBottomMostPoint(bottom_most_point))
2480 qFatal(
"Could not get the bottom-most bottom point.");
2482 double y_axis_center_position = bottom_most_point.y() + height / 2;
2492 int pixels_away_from_line = 15;
2493 double x_axis_coordinate;
2494 double x_axis_pixel_coordinate;
2496 if(
static_cast<int>(
m_context.m_dragDirections) &
2499 QPointF left_most_point;
2501 if(!
m_context.msp_integrationScope->getLeftMostPoint(left_most_point))
2502 qFatal(
"Failed to get left most point.");
2504 x_axis_coordinate = left_most_point.x();
2506 pixels_away_from_line *= -1;
2510 QPointF right_most_point;
2512 if(!
m_context.msp_integrationScope->getRightMostPoint(right_most_point))
2513 qFatal(
"Failed to get right most point.");
2515 x_axis_coordinate = right_most_point.x();
2517 x_axis_pixel_coordinate = xAxis->coordToPixel(x_axis_coordinate);
2519 double x_axis_modified_pixel_coordinate =
2520 x_axis_pixel_coordinate + pixels_away_from_line;
2523 QPointF pixel_coordinates;
2525 pixel_coordinates.setX(x_axis_modified_pixel_coordinate);
2526 pixel_coordinates.setY(y_axis_center_position);
2530 QPointF graph_coordinates(xAxis->pixelToCoord(pixel_coordinates.x()),
2531 yAxis->pixelToCoord(pixel_coordinates.y()));
2534 y_axis_center_position);
2538 QString label_text = QString(
"full y span %1 -- y drag delta %2")
2539 .arg(height, 0,
'f', decimals)
2540 .arg(fabs(
m_context.m_yDelta), 0,
'f', decimals);
2582 double plotHeight = yAxis->range().upper - yAxis->range().lower;
2587 double heightDiffRatio = (heightDiff / plotHeight) * 100;
2589 if(heightDiffRatio > 10)
2608 double x_range_start =
2610 double x_range_end =
2616 double y_position =
m_context.m_startDragPoint.y();
2622 QPointF(x_range_start, y_position));
2647 QPointF(x_range_start, y_position));
2678 QPointF bottom_left_point;
2679 if(!
m_context.msp_integrationScope->getPoint(bottom_left_point))
2680 qFatal(
"Failed to get point.");
2684 if(!
m_context.msp_integrationScope->getWidth(width))
2685 qFatal(
"Failed to get width.");
2689 if(!
m_context.msp_integrationScope->getHeight(height))
2690 qFatal(
"Failed to get height.");
2693 QPointF bottom_right_point(bottom_left_point.x() + width,
2694 bottom_left_point.y());
2697 QPointF top_right_point(bottom_left_point.x() + width,
2698 bottom_left_point.y() + height);
2701 QPointF top_left_point(bottom_left_point.x(), bottom_left_point.y() + height);
2772 scope_features =
m_context.msp_integrationScope->getLeftMostTopPoint(point_1);
2792 qFatal(
"The rhomboid should be horizontal!");
2796 if(!
m_context.msp_integrationScope->getLeftMostTopPoint(point_1))
2797 qFatal(
"Failed to getLeftMostTopPoint.");
2799 if(!
m_context.msp_integrationScope->getRightMostTopPoint(point_2))
2800 qFatal(
"Failed to getRightMostTopPoint.");
2823 if(!
m_context.msp_integrationScope->getRightMostBottomPoint(point_1))
2824 qFatal(
"Failed to getRightMostBottomPoint.");
2832 if(!
m_context.msp_integrationScope->getLeftMostBottomPoint(point_2))
2833 qFatal(
"Failed to getLeftMostBottomPoint.");
2841 if(!
m_context.msp_integrationScope->getLeftMostTopPoint(point_1))
2842 qFatal(
"Failed to getLeftMostTopPoint.");
2884 scope_features =
m_context.msp_integrationScope->getLeftMostTopPoint(point_1);
2904 qFatal(
"The rhomboid should be vertical!");
2909 if(!
m_context.msp_integrationScope->getLeftMostBottomPoint(point_2))
2910 qFatal(
"Failed to getLeftMostBottomPoint.");
2934 if(!
m_context.msp_integrationScope->getRightMostBottomPoint(point_1))
2935 qFatal(
"Failed to getRightMostBottomPoint.");
2944 if(!
m_context.msp_integrationScope->getRightMostTopPoint(point_2))
2945 qFatal(
"Failed to getRightMostTopPoint.");
2954 if(!
m_context.msp_integrationScope->getLeftMostTopPoint(point_1))
2955 qFatal(
"Failed to get the LeftMostTopPoint.");
3024 m_context.updateIntegrationScopeRhomb();
3042 if(
m_context.m_integrationScopeRhombWidth > 0)
3045 else if(
m_context.m_integrationScopeRhombHeight > 0)
3049 qFatal(
"Cannot be both the width or height of rhomboid scope be 0.");
3054 bool for_integration)
3080 if(!(
m_context.m_keyboardModifiers & Qt::AltModifier))
3086 else if(
m_context.m_keyboardModifiers & Qt::AltModifier)
3092 if(!
m_context.m_integrationScopeRhombHeight &&
3093 !
m_context.m_integrationScopeRhombWidth)
3109 std::vector<QPointF> points;
3117 if(
m_context.msp_integrationScope->getPoints(points))
3121 if(!
m_context.msp_integrationScope->getLeftMostPoint(point))
3122 qFatal(
"Failed to get LeftMost point.");
3123 m_context.m_xRegionRangeStart = point.x();
3125 if(!
m_context.msp_integrationScope->getRightMostPoint(point))
3126 qFatal(
"Failed to get RightMost point.");
3127 m_context.m_xRegionRangeEnd = point.x();
3129 else if(
m_context.msp_integrationScope->getHeight(height))
3133 if(!
m_context.msp_integrationScope->getPoint(point))
3134 qFatal(
"Failed to get point.");
3135 m_context.m_xRegionRangeStart = point.x();
3139 if(!
m_context.msp_integrationScope->getWidth(width))
3140 qFatal(
"Failed to get width.");
3144 m_context.m_yRegionRangeStart = point.y();
3146 m_context.m_yRegionRangeEnd = point.y() + height;
3152 if(!
m_context.msp_integrationScope->getPoint(point))
3153 qFatal(
"Failed to get point.");
3154 m_context.m_xRegionRangeStart = point.x();
3158 if(!
m_context.msp_integrationScope->getWidth(width))
3159 qFatal(
"Failed to get width.");
3189 std::const_pointer_cast<IntegrationScopeBase>(
m_context.msp_integrationScope)
3199 int current_selection_polygon =
3204 current_selection_polygon |=
3211 current_selection_polygon |=
3218 current_selection_polygon |=
3225 current_selection_polygon |=
3258 QCustomPlot::setFocus();
3269 if(focusedPlotWidget ==
nullptr)
3271 "baseplotwidget.cpp @ redrawPlotBackground(QWidget *focusedPlotWidget "
3273 "ERROR focusedPlotWidget cannot be nullptr.");
3275 if(
dynamic_cast<QWidget *
>(
this) != focusedPlotWidget)
3294 m_context.m_xRange = QCPRange(xAxis->range().lower, xAxis->range().upper);
3295 m_context.m_yRange = QCPRange(yAxis->range().lower, yAxis->range().upper);
static int zeroDecimalsInValue(pappso_double value)
Determine the number of zero decimals between the decimal point and the first non-zero decimal.
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...