Option to show markers symbols at top/bottom of graph for out-of-range markers

This commit is contained in:
Jan Käberich 2025-04-13 14:27:44 +02:00
parent a28dd50e36
commit b1c4c4ffad
4 changed files with 39 additions and 9 deletions

View file

@ -638,13 +638,25 @@ void TraceXYPlot::draw(QPainter &p)
p.drawLine(p1, p2);
}
if(pref.Marker.clipToYAxis) {
// clip Y coordinate of markers to visible area (always show markers, even when out of range)
if(point.y() < plotRect.top()) {
point.ry() = plotRect.top();
} else if(point.y() > plotRect.bottom()) {
point.ry() = plotRect.bottom();
}
}
if(!plotRect.contains(point)) {
// out of screen
continue;
}
auto symbol = m->getSymbol();
point += QPoint(-symbol.width()/2, -symbol.height());
// ignore clipRect for markers
p.setClipping(false);
p.drawPixmap(point, symbol);
p.setClipping(true);
}
}
}

View file

@ -322,6 +322,7 @@ void PreferencesDialog::setInitialGUIState()
ui->MarkerInterpolate->setCurrentIndex(p->Marker.interpolatePoints ? 1 : 0);
ui->MarkerSortOrder->setCurrentIndex((int) p->Marker.sortOrder);
ui->MarkerSymbolStyle->setCurrentIndex((int) p->Marker.symbolStyle);
ui->MarkerClipToYAxis->setChecked(p->Marker.clipToYAxis);
ui->SCPIServerEnabled->setChecked(p->SCPIServer.enabled);
ui->SCPIServerPort->setValue(p->SCPIServer.port);
@ -437,6 +438,7 @@ void PreferencesDialog::updateFromGUI()
p->Marker.interpolatePoints = ui->MarkerInterpolate->currentIndex() == 1;
p->Marker.sortOrder = (MarkerSortOrder) ui->MarkerSortOrder->currentIndex();
p->Marker.symbolStyle = (MarkerSymbolStyle) ui->MarkerSymbolStyle->currentIndex();
p->Marker.clipToYAxis = ui->MarkerClipToYAxis->isChecked();
p->SCPIServer.enabled = ui->SCPIServerEnabled->isChecked();
p->SCPIServer.port = ui->SCPIServerPort->value();

View file

@ -165,6 +165,7 @@ public:
bool interpolatePoints;
MarkerSortOrder sortOrder;
MarkerSymbolStyle symbolStyle;
bool clipToYAxis;
} Marker;
struct {
bool enabled;
@ -304,6 +305,7 @@ private:
{&Marker.interpolatePoints, "Marker.interpolatePoints", false},
{&Marker.sortOrder, "Marker.sortOrder", MarkerSortOrder::PrefMarkerSortXCoord},
{&Marker.symbolStyle, "Marker.symbolStyle", MarkerSymbolStyle::FilledNumberAbove},
{&Marker.clipToYAxis, "Marker.clipToYAxis", true},
{&SCPIServer.enabled, "SCPIServer.enabled", true},
{&SCPIServer.port, "SCPIServer.port", 19542},
{&StreamingServers.VNARawData.enabled, "StreamingServers.VNARawData.enabled", false},

View file

@ -98,7 +98,7 @@
</size>
</property>
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="Startup">
<layout class="QHBoxLayout" name="horizontalLayout_4">
@ -713,8 +713,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>564</width>
<height>477</height>
<width>697</width>
<height>563</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
@ -1475,9 +1475,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-65</y>
<width>683</width>
<height>605</height>
<height>628</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
@ -1787,6 +1787,20 @@
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_64">
<property name="text">
<string>Show out-of-range marker at top/bottom:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="MarkerClipToYAxis">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -1822,8 +1836,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>697</width>
<height>563</height>
<width>168</width>
<height>127</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_12">
@ -2105,8 +2119,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>697</width>
<height>563</height>
<width>258</width>
<height>241</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_19">