nitroxcalc/src/ 0000775 0001750 0001750 00000000000 14727310114 013047 5 ustar salvo salvo nitroxcalc/src/calcwrapper.h 0000664 0001750 0001750 00000002034 14727310114 015522 0 ustar salvo salvo /*
nitroxcalc
Copyright (C) 2015-2024 Salvo "LtWorf" Tomaselli
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
author Salvo "LtWorf" Tomaselli
*/
#ifndef CALCWRAPPER_H
#define CALCWRAPPER_H
#include
#include
class CalcWrapper : public QObject
{
Q_OBJECT
public:
Q_INVOKABLE QString mod(int ean);
Q_INVOKABLE QString bod(int ean);
Q_INVOKABLE QString ead(int ean, int depth);
};
#endif // CALCWRAPPER_H
nitroxcalc/src/calcwrapper.cpp 0000664 0001750 0001750 00000002717 14727310114 016065 0 ustar salvo salvo /*
nitroxcalc
Copyright (C) 2015-2024 Salvo "LtWorf" Tomaselli
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
author Salvo "LtWorf" Tomaselli
*/
#include "calcwrapper.h"
#include "calc.h"
QString CalcWrapper::mod(int ean) {
if (ean < 21 || ean > 40) {
return QString(" --- ");
}
return QString::number(maximum_operative_depth(ean)) + QString('m');
}
QString CalcWrapper::bod(int ean) {
if (ean < 21 || ean > 40) {
return QString(" --- ");
}
return QString::number(best_operative_depth(ean, 1)) + QString('m');
}
QString CalcWrapper::ead(int ean, int depth) {
if (ean < 21 || ean > 40 || depth < 5) {
return QString(" --- ");
}
int d = equivalent_air_depth(ean, depth);
if (depth >= maximum_operative_depth(ean)) {
return QString("Too deep!");
}
return QString::number(d) + QString('m');
}
nitroxcalc/src/calc.h 0000664 0001750 0001750 00000003426 14727310114 014127 0 ustar salvo salvo /*
nitroxcalc
Copyright (C) 2015-2024 Salvo "LtWorf" Tomaselli
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
author Salvo "LtWorf" Tomaselli
*/
#ifndef CALC
#define CALC
/**
* @brief equivalent_air_depth
* Calculates the equivalent depth for a planned
* nitrox dive.
*
* The parameters are the used gas and the planned
* depth. It returns the equivalent depth on air.
*
* @param ean, in %
* For example 21 is normal air, and 100 is pure O₂
* @param depth
* Expressed in meters
* @return
* The equivalent depth on an air dive, in meters
*/
int equivalent_air_depth(int ean,double depth);
/**
* @brief maximum_operative_depth
* Returns the maximum possible depth reacheable
* using a certain mix
* @param ean, in %
* For example 21 is normal air, and 100 is pure O₂
* @return
* expressed in meters
*/
int maximum_operative_depth(int ean);
/**
* @brief best_operative_depth
* same as maximum_operative_depth but returns the
* depth that is best for the gas mix
* @param ean
* @param factors
* Adding factors to the count increases the safety
* margin by 0.1 atm
* @return
*/
int best_operative_depth(int ean, unsigned int factors = 0);
#endif // CALC
nitroxcalc/src/calc.cpp 0000664 0001750 0001750 00000002562 14727310114 014462 0 ustar salvo salvo /*
nitroxcalc
Copyright (C) 2015-2024 Salvo "LtWorf" Tomaselli
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
author Salvo "LtWorf" Tomaselli
*/
#include
#include "calc.h"
#define MAX_PO2 1.6 //atm
static int best_depth(int ean, double factors) {
double o2 = (double)ean / 100;
double margin = (factors) / 10;
double pressure = (MAX_PO2 - margin) / o2;
return (int)floor((pressure - 1) * 10);
}
int maximum_operative_depth(int ean) {
return best_depth(ean, 0);
}
int best_operative_depth(int ean, unsigned int factors) {
return best_depth(ean, factors+1);
}
int equivalent_air_depth(int ean, double depth) {
//Amount of nitrogen in the mix. [0, 1]
double n = 1-((double)ean/100);
return (int)floor(((n*(depth+10)) / 0.79) - 10);
}
nitroxcalc/src/main.cpp 0000664 0001750 0001750 00000002167 14727310114 014505 0 ustar salvo salvo /*
nitroxcalc
Copyright (C) 2015-2024 Salvo "LtWorf" Tomaselli
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
author Salvo "LtWorf" Tomaselli
*/
#include
#include
#include
#include "calcwrapper.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
CalcWrapper calc;
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("calc", &calc);
engine.load(QUrl(QStringLiteral("qrc:/ui/main.qml")));
return app.exec();
}
nitroxcalc/src/ui.qrc 0000664 0001750 0001750 00000000470 14727310114 014174 0 ustar salvo salvo
ui/background.jpg
ui/Background.qml
ui/bubble.png
ui/FormLabel.qml
ui/main.qml
ui/sparkleSize.png
ui/UI.qml
nitroxcalc/src/ui/ 0000775 0001750 0001750 00000000000 14727310114 013464 5 ustar salvo salvo nitroxcalc/src/ui/Background.qml 0000664 0001750 0001750 00000003636 14727310114 016266 0 ustar salvo salvo /*
nitroxcalc
Copyright (C) 2015-2024 Salvo "LtWorf" Tomaselli
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
author Salvo "LtWorf" Tomaselli
*/
import QtQuick 2.0
import QtQuick.Particles 2.0
Rectangle {
color: "#0170FE"
Image {
source: "background.jpg"
fillMode: Image.PreserveAspectCrop
anchors.fill: parent
}
Timer {
interval: 8000
triggeredOnStart: true
repeat: true
running: true
onTriggered: {
emitter.burst(50);
}
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
}
ParticleSystem {
id: particles
running: true
}
ImageParticle {
anchors.fill: parent
system: particles
source: "bubble.png"
sizeTable: "sparkleSize.png"
alpha: 0
colorVariation: 0.6
}
Rectangle {
width: parent.width
height: 5
anchors.bottom: parent.bottom
opacity: 0
Emitter {
id: emitter
anchors.fill: parent
system: particles
emitRate: 3
lifeSpan: 30000
size: 20
endSize: 30
velocity: PointDirection {y: -72; yVariation: 24}
sizeVariation: 10
}
}
}
nitroxcalc/src/ui/sparkleSize.png 0000664 0001750 0001750 00000000572 14727310114 016472 0 ustar salvo salvo PNG
IHDR l pHYs
aF tEXtSoftware Adobe ImageReadyqe<