Skip to content

Commit

Permalink
adjust y axis colors based on axis mode selected
Browse files Browse the repository at this point in the history
  • Loading branch information
ElderOrb committed Jun 23, 2024
1 parent 4eb003d commit 54aa3bf
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 9 deletions.
23 changes: 23 additions & 0 deletions Source/GUI/Plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,20 @@ bool Plot::isBarchart() const
void Plot::setYAxisMinMaxMode(YMinMaxMode mode)
{
m_yminMaxMode = mode;
QColor color;
switch(m_yminMaxMode) {
case MinMaxOfThePlot:
color = "darkblue";
break;
case Formula:
color = "black";
break;
case Custom:
color = QColor(85, 0, 127);
break;
}

setYAxisColor(color);
initYAxis();
}

Expand Down Expand Up @@ -732,6 +746,15 @@ QSize Plot::minimumSizeHint() const
return QSize( hint.width(), -1 );
}

void Plot::setYAxisColor(QColor color)
{
auto yAxis = axisWidget(QwtPlot::yLeft);
QPalette palette = yAxis->palette();
palette.setColor(QPalette::WindowText, color); // for ticks
palette.setColor(QPalette::Text, color); // for ticks' labels
yAxis->setPalette(palette);
}

const QwtPlotCurve* Plot::curve( int index ) const
{
const QwtPlotItemList curves = itemList( QwtPlotItem::Rtti_PlotCurve );
Expand Down
1 change: 1 addition & 0 deletions Source/GUI/Plot.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ class Plot : public QwtPlot
virtual QSize sizeHint() const;
virtual QSize minimumSizeHint() const;

void setYAxisColor(QColor color);
void setYAxis( double min, double max, int numSteps );
void setCursorPos( double x );

Expand Down
66 changes: 57 additions & 9 deletions Source/GUI/yminmaxselector.ui
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@
<string>Set the y-axis range</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="minMaxOfThePlot_radioButton">
<item row="0" column="1">
<widget class="QRadioButton" name="minMaxSystemProvided_radioButton">
<property name="text">
<string>Fit to the plotted data</string>
<string>Full Range</string>
</property>
<property name="checked">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="minMaxSystemProvided_radioButton">
<item row="1" column="1">
<widget class="QRadioButton" name="minMaxOfThePlot_radioButton">
<property name="text">
<string>Full Range</string>
<string>Fit to the plotted data</string>
</property>
<property name="checked">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="customMinMax_radioButton">
Expand Down Expand Up @@ -112,6 +112,54 @@
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: &quot;black&quot;;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QFrame" name="frame_2">
<property name="styleSheet">
<string notr="true">background-color: &quot;dark blue&quot;;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QFrame" name="frame_3">
<property name="styleSheet">
<string notr="true">background-color: rgb(85, 0, 127)</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 54aa3bf

Please sign in to comment.