mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Added option to choose between different depth grid quantization schema.
This allows having 3m depth grid for metric users. * All original properties ( named diferently ) were renamed to three_m_based_grid everywhere to be consistent. * Plus other small changes requested during review. Signed-off-by: Vlad A. <elf128@gmail.com> Signed-off-by: Vlad A <elf128@gmail.com>
This commit is contained in:
parent
15f3918171
commit
30a964c508
10 changed files with 85 additions and 8 deletions
|
@ -92,6 +92,7 @@ struct preferences default_prefs = {
|
|||
.auto_recalculate_thumbnails = true,
|
||||
.extract_video_thumbnails = true,
|
||||
.extract_video_thumbnails_position = 20, // The first fifth seems like a reasonable place
|
||||
.three_m_based_grid = false,
|
||||
};
|
||||
|
||||
/* copy a preferences block, including making copies of all included strings */
|
||||
|
|
|
@ -103,6 +103,7 @@ struct preferences {
|
|||
double font_size;
|
||||
double mobile_scale;
|
||||
bool show_developer;
|
||||
bool three_m_based_grid;
|
||||
|
||||
// ********** Equipment tab *******
|
||||
const char *default_cylinder;
|
||||
|
|
|
@ -67,6 +67,7 @@ void qPrefDisplay::loadSync(bool doSync)
|
|||
load_lastState();
|
||||
load_singleColumnPortrait();
|
||||
}
|
||||
disk_three_m_based_grid(doSync);
|
||||
}
|
||||
|
||||
void qPrefDisplay::set_divelist_font(const QString &value)
|
||||
|
@ -148,6 +149,8 @@ HANDLE_PREFERENCE_BOOL(Display, "displayinvalid", display_invalid_dives);
|
|||
|
||||
HANDLE_PREFERENCE_BOOL(Display, "show_developer", show_developer);
|
||||
|
||||
HANDLE_PREFERENCE_BOOL(Display, "three_m_based_grid", three_m_based_grid);
|
||||
|
||||
void qPrefDisplay::setCorrectFont()
|
||||
{
|
||||
// get the font from the settings or our defaults
|
||||
|
|
|
@ -25,6 +25,7 @@ class qPrefDisplay : public QObject {
|
|||
Q_PROPERTY(QByteArray windowState READ windowState WRITE set_windowState NOTIFY windowStateChanged)
|
||||
Q_PROPERTY(int lastState READ lastState WRITE set_lastState NOTIFY lastStateChanged)
|
||||
Q_PROPERTY(bool singleColumnPortrait READ singleColumnPortrait WRITE set_singleColumnPortrait NOTIFY singleColumnPortraitChanged)
|
||||
Q_PROPERTY(bool three_m_based_grid READ three_m_based_grid WRITE set_three_m_based_grid NOTIFY three_m_based_gridChanged)
|
||||
|
||||
public:
|
||||
static qPrefDisplay *instance();
|
||||
|
@ -52,6 +53,7 @@ public:
|
|||
static QByteArray windowState() { return st_windowState; }
|
||||
static int lastState() { return st_lastState; }
|
||||
static bool singleColumnPortrait() { return st_singleColumnPortrait; }
|
||||
static bool three_m_based_grid() { return prefs.three_m_based_grid; }
|
||||
|
||||
public slots:
|
||||
static void set_animation_speed(int value);
|
||||
|
@ -71,6 +73,7 @@ public slots:
|
|||
static void set_windowState(const QByteArray& value);
|
||||
static void set_lastState(int value);
|
||||
static void set_singleColumnPortrait(bool value);
|
||||
static void set_three_m_based_grid(bool value);
|
||||
|
||||
signals:
|
||||
void animation_speedChanged(int value);
|
||||
|
@ -90,6 +93,7 @@ signals:
|
|||
void windowStateChanged(const QByteArray& value);
|
||||
void lastStateChanged(int value);
|
||||
void singleColumnPortraitChanged(bool value);
|
||||
void three_m_based_gridChanged(bool value);
|
||||
|
||||
private:
|
||||
qPrefDisplay() {}
|
||||
|
@ -101,6 +105,7 @@ private:
|
|||
static void disk_mobile_scale(bool doSync);
|
||||
static void disk_display_invalid_dives(bool doSync);
|
||||
static void disk_show_developer(bool doSync);
|
||||
static void disk_three_m_based_grid(bool doSync);
|
||||
|
||||
// functions to handle class variables
|
||||
static void load_lastDir();
|
||||
|
|
|
@ -28,6 +28,10 @@ void PreferencesDefaults::refreshSettings()
|
|||
ui->fontsize->setValue(qPrefDisplay::font_size());
|
||||
ui->velocitySlider->setValue(qPrefDisplay::animation_speed());
|
||||
|
||||
if (qPrefDisplay::three_m_based_grid())
|
||||
ui->grid3MBased->setChecked(true);
|
||||
else
|
||||
ui->gridGeneric->setChecked(true);
|
||||
}
|
||||
|
||||
void PreferencesDefaults::syncSettings()
|
||||
|
@ -35,4 +39,5 @@ void PreferencesDefaults::syncSettings()
|
|||
qPrefDisplay::set_divelist_font(ui->font->currentFont().toString());
|
||||
qPrefDisplay::set_font_size(ui->fontsize->value());
|
||||
qPrefDisplay::set_animation_speed(ui->velocitySlider->value());
|
||||
qPrefDisplay::set_three_m_based_grid(ui->grid3MBased->isChecked());
|
||||
}
|
||||
|
|
|
@ -118,6 +118,36 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_gridDepth">
|
||||
<property name="title">
|
||||
<string>Dive profile depth grid</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Depth line intevals.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="gridGeneric">
|
||||
<property name="text">
|
||||
<string>generic ( 1, 2, 4, 5, 10 )</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="grid3MBased">
|
||||
<property name="text">
|
||||
<string>based on ×3 intervals ( 1, 3, 6, 15 )</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
|
|
|
@ -576,6 +576,16 @@ TemplatePage {
|
|||
PrefDisplay.singleColumnPortrait = checked
|
||||
}
|
||||
}
|
||||
TemplateLabel {
|
||||
text: qsTr("Depth line based on ×3 intervals")
|
||||
}
|
||||
SsrfSwitch {
|
||||
checked: PrefDisplay.three_m_based_grid
|
||||
onClicked: {
|
||||
PrefDisplay.three_m_based_grid = checked
|
||||
rootItem.settingsChanged()
|
||||
}
|
||||
}
|
||||
TemplateLine {
|
||||
visible: sectionAdvanced.isExpanded
|
||||
Layout.columnSpan: 2
|
||||
|
|
|
@ -30,6 +30,7 @@ DiveCartesianAxis::DiveCartesianAxis(Position position, bool inverted, int integ
|
|||
max(0),
|
||||
textVisibility(textVisible),
|
||||
lineVisibility(linesVisible),
|
||||
gridIsMultipleOfThree(false),
|
||||
labelScale(labelScale),
|
||||
dpr(dpr),
|
||||
transform({1.0, 0.0})
|
||||
|
@ -101,7 +102,7 @@ int DiveCartesianAxis::getMinLabelDistance(const DiveCartesianAxis &timeAxis) co
|
|||
return int(ceil(interval));
|
||||
}
|
||||
|
||||
static double sensibleInterval(double inc, int decimals, bool is_time_axis)
|
||||
static double sensibleInterval(double inc, int decimals, bool is_time_axis, bool is_multiple_of_three)
|
||||
{
|
||||
if (is_time_axis && inc < 60.0) {
|
||||
// for time axes and less than one hour increments, round to
|
||||
|
@ -130,11 +131,22 @@ static double sensibleInterval(double inc, int decimals, bool is_time_axis)
|
|||
|
||||
double digits_factor = pow(10.0, digits);
|
||||
int inc_int = std::max((int)ceil(inc / digits_factor), 1);
|
||||
// Do "nice" increments of the leading digit. In general: 1, 2, 4, 5.
|
||||
if (inc_int > 5)
|
||||
inc_int = 10;
|
||||
if (inc_int == 3)
|
||||
inc_int = 4;
|
||||
if (is_multiple_of_three)
|
||||
{
|
||||
// Do increments quantized to 3. In general: 1, 3, 6, 15
|
||||
if (inc_int > 6)
|
||||
inc_int = 15;
|
||||
else if (inc_int > 3)
|
||||
inc_int = 6;
|
||||
else if (inc_int == 2)
|
||||
inc_int = 3;
|
||||
} else {
|
||||
// Do "nice" increments of the leading digit. In general: 1, 2, 4, 5.
|
||||
if (inc_int > 5)
|
||||
inc_int = 10;
|
||||
if (inc_int == 3)
|
||||
inc_int = 4;
|
||||
}
|
||||
inc = inc_int * digits_factor;
|
||||
|
||||
return inc;
|
||||
|
@ -165,7 +177,7 @@ void DiveCartesianAxis::updateTicks(int animSpeed)
|
|||
|
||||
// Round the interval to a sensible size in display units
|
||||
double intervalDisplay = stepValue * transform.a;
|
||||
intervalDisplay = sensibleInterval(intervalDisplay, fractionalDigits, position == Position::Bottom);
|
||||
intervalDisplay = sensibleInterval(intervalDisplay, fractionalDigits, position == Position::Bottom, gridIsMultipleOfThree);
|
||||
|
||||
// Choose full multiples of the interval as minumum and maximum values
|
||||
double minDisplay = transform.to(dataMin);
|
||||
|
@ -478,6 +490,11 @@ double DiveCartesianAxis::minimum() const
|
|||
return min;
|
||||
}
|
||||
|
||||
void DiveCartesianAxis::setGridIsMultipleOfThree(bool arg1)
|
||||
{
|
||||
gridIsMultipleOfThree = arg1;
|
||||
}
|
||||
|
||||
std::pair<double, double> DiveCartesianAxis::screenMinMax() const
|
||||
{
|
||||
return position == Position::Bottom ? std::make_pair(rect.left(), rect.right())
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
double pointInRange(double pos) const; // Point on screen is in range of axis
|
||||
void setTextVisible(bool arg1);
|
||||
void setLinesVisible(bool arg1);
|
||||
void setGridIsMultipleOfThree(bool arg1);
|
||||
void updateTicks(int animSpeed);
|
||||
double width() const; // only for vertical axes
|
||||
double height() const; // only for horizontal axes
|
||||
|
@ -75,6 +76,7 @@ private:
|
|||
double min, max;
|
||||
bool textVisibility;
|
||||
bool lineVisibility;
|
||||
bool gridIsMultipleOfThree;
|
||||
double labelScale;
|
||||
double dpr;
|
||||
double labelWidth, labelHeight; // maximum expected sizes of label width and height
|
||||
|
|
|
@ -164,6 +164,7 @@ ProfileScene::ProfileScene(double dpr, bool printMode, bool isGrayscale) :
|
|||
addTissueItems<0,16>(dpr);
|
||||
|
||||
percentageItem->setZValue(1.0);
|
||||
profileYAxis->setGridIsMultipleOfThree( qPrefDisplay::three_m_based_grid() );
|
||||
|
||||
// Add items to scene
|
||||
addItem(diveComputerText);
|
||||
|
@ -304,6 +305,8 @@ void ProfileScene::updateAxes(bool diveHasHeartBeat, bool simplified)
|
|||
if (width <= 10.0 * dpr)
|
||||
return clear();
|
||||
|
||||
profileYAxis->setGridIsMultipleOfThree( qPrefDisplay::three_m_based_grid() );
|
||||
|
||||
// Place the fixed dive computer text at the bottom
|
||||
double bottomBorder = sceneRect().height() - diveComputerText->height() - 2.0 * dpr * diveComputerTextBorder;
|
||||
diveComputerText->setPos(0.0, bottomBorder + dpr * diveComputerTextBorder);
|
||||
|
|
Loading…
Reference in a new issue