| 
									
										
										
										
											2017-04-27 20:26:36 +02:00
										 |  |  | // SPDX-License-Identifier: GPL-2.0
 | 
					
						
							| 
									
										
										
										
											2016-04-04 22:02:03 -07:00
										 |  |  | #include "profile-widget/profilewidget2.h"
 | 
					
						
							| 
									
										
										
										
											2016-03-06 06:52:55 -08:00
										 |  |  | #include "qt-models/diveplotdatamodel.h"
 | 
					
						
							| 
									
										
										
										
											2020-10-25 09:14:16 +01:00
										 |  |  | #include "core/event.h"
 | 
					
						
							| 
									
										
										
										
											2018-05-11 08:25:41 -07:00
										 |  |  | #include "core/subsurface-string.h"
 | 
					
						
							| 
									
										
										
										
											2018-06-03 22:15:19 +02:00
										 |  |  | #include "core/qthelper.h"
 | 
					
						
							| 
									
										
										
										
											2020-04-10 09:42:14 +02:00
										 |  |  | #include "core/picture.h"
 | 
					
						
							| 
									
										
										
										
											2016-04-04 22:02:03 -07:00
										 |  |  | #include "core/profile.h"
 | 
					
						
							| 
									
										
										
										
											2018-08-20 11:51:48 +02:00
										 |  |  | #include "core/settings/qPrefDisplay.h"
 | 
					
						
							| 
									
										
										
										
											2018-08-15 11:52:50 +02:00
										 |  |  | #include "core/settings/qPrefTechnicalDetails.h"
 | 
					
						
							|  |  |  | #include "core/settings/qPrefPartialPressureGas.h"
 | 
					
						
							| 
									
										
										
										
											2016-04-04 22:02:03 -07:00
										 |  |  | #include "profile-widget/diveeventitem.h"
 | 
					
						
							|  |  |  | #include "profile-widget/divetextitem.h"
 | 
					
						
							|  |  |  | #include "profile-widget/divetooltipitem.h"
 | 
					
						
							| 
									
										
										
										
											2020-11-25 18:30:49 +01:00
										 |  |  | #include "profile-widget/divehandler.h"
 | 
					
						
							| 
									
										
										
										
											2016-04-04 22:02:03 -07:00
										 |  |  | #include "core/planner.h"
 | 
					
						
							|  |  |  | #include "core/device.h"
 | 
					
						
							|  |  |  | #include "profile-widget/ruleritem.h"
 | 
					
						
							|  |  |  | #include "profile-widget/tankitem.h"
 | 
					
						
							|  |  |  | #include "core/pref.h"
 | 
					
						
							| 
									
										
										
										
											2016-03-06 06:52:55 -08:00
										 |  |  | #include "qt-models/diveplannermodel.h"
 | 
					
						
							|  |  |  | #include "qt-models/models.h"
 | 
					
						
							| 
									
										
										
										
											2020-04-14 22:07:00 +02:00
										 |  |  | #include "qt-models/divepicturemodel.h" // TODO: remove once divepictures have been undo-ified
 | 
					
						
							| 
									
										
										
										
											2016-04-04 22:02:03 -07:00
										 |  |  | #include "core/divelist.h"
 | 
					
						
							| 
									
										
										
										
											2019-08-05 19:41:15 +02:00
										 |  |  | #include "core/errorhelper.h"
 | 
					
						
							| 
									
										
										
										
											2015-11-05 16:05:44 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2016-04-04 22:02:03 -07:00
										 |  |  | #include "desktop-widgets/simplewidgets.h"
 | 
					
						
							|  |  |  | #include "desktop-widgets/divepicturewidget.h"
 | 
					
						
							| 
									
										
										
										
											2018-07-02 21:13:44 +02:00
										 |  |  | #include "desktop-widgets/mainwindow.h"
 | 
					
						
							| 
									
										
										
										
											2019-11-13 15:08:40 +01:00
										 |  |  | #include "commands/command.h"
 | 
					
						
							| 
									
										
										
										
											2017-01-07 03:01:14 +01:00
										 |  |  | #include "core/qthelper.h"
 | 
					
						
							| 
									
										
										
										
											2018-06-17 08:48:54 +02:00
										 |  |  | #include "core/gettextfromc.h"
 | 
					
						
							| 
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 |  |  | #include "core/imagedownloader.h"
 | 
					
						
							| 
									
										
										
										
											2015-11-05 16:05:44 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2020-11-24 12:50:52 +01:00
										 |  |  | #include "core/subsurface-qt/divelistnotifier.h"
 | 
					
						
							| 
									
										
										
										
											2015-02-09 18:27:59 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | #include <libdivecomputer/parser.h>
 | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | #include <QScrollBar>
 | 
					
						
							| 
									
										
										
										
											2014-03-10 17:59:02 +02:00
										 |  |  | #include <QtCore/qmath.h>
 | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | #include <QMessageBox>
 | 
					
						
							| 
									
										
										
										
											2014-04-03 21:16:15 +02:00
										 |  |  | #include <QInputDialog>
 | 
					
						
							| 
									
										
										
										
											2015-01-17 07:02:03 -08:00
										 |  |  | #include <QDebug>
 | 
					
						
							| 
									
										
										
										
											2015-02-09 18:58:40 -02:00
										 |  |  | #include <QWheelEvent>
 | 
					
						
							| 
									
										
										
										
											2015-11-05 12:50:51 -08:00
										 |  |  | #include <QMenu>
 | 
					
						
							| 
									
										
										
										
											2018-05-29 12:49:47 +02:00
										 |  |  | #include <QElapsedTimer>
 | 
					
						
							| 
									
										
										
										
											2014-01-16 15:02:32 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-15 13:20:05 -02:00
										 |  |  | #ifndef QT_NO_DEBUG
 | 
					
						
							|  |  |  | #include <QTableView>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2015-11-03 21:17:50 +01:00
										 |  |  | #include <QtWidgets>
 | 
					
						
							| 
									
										
										
										
											2014-01-15 13:20:05 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-13 17:06:46 +02:00
										 |  |  | #define PP_GRAPHS_ENABLED (prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-05 10:05:22 -08:00
										 |  |  | // a couple of helpers we need
 | 
					
						
							|  |  |  | extern bool haveFilesOnCommandLine(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 15:32:39 -02:00
										 |  |  | /* This is the global 'Item position' variable.
 | 
					
						
							|  |  |  |  * it should tell you where to position things up | 
					
						
							|  |  |  |  * on the canvas. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * please, please, please, use this instead of | 
					
						
							|  |  |  |  * hard coding the item on the scene with a random | 
					
						
							|  |  |  |  * value. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | static struct _ItemPos { | 
					
						
							|  |  |  | 	struct _Pos { | 
					
						
							| 
									
										
										
										
											2014-02-07 15:32:39 -02:00
										 |  |  | 		QPointF on; | 
					
						
							|  |  |  | 		QPointF off; | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	struct _Axis { | 
					
						
							|  |  |  | 		_Pos pos; | 
					
						
							|  |  |  | 		QLineF shrinked; | 
					
						
							|  |  |  | 		QLineF expanded; | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 		QLineF intermediate; | 
					
						
							| 
									
										
										
										
											2014-02-07 15:32:39 -02:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 	_Pos background; | 
					
						
							| 
									
										
										
										
											2014-02-07 21:17:14 -02:00
										 |  |  | 	_Pos dcLabel; | 
					
						
							| 
									
										
										
										
											2014-08-15 07:30:31 -06:00
										 |  |  | 	_Pos tankBar; | 
					
						
							| 
									
										
										
										
											2014-02-07 15:32:39 -02:00
										 |  |  | 	_Axis depth; | 
					
						
							| 
									
										
										
										
											2014-02-11 10:55:07 -08:00
										 |  |  | 	_Axis partialPressure; | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 	_Axis partialPressureTissue; | 
					
						
							| 
									
										
										
										
											2014-08-15 08:11:14 -06:00
										 |  |  | 	_Axis partialPressureWithTankBar; | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 	_Axis percentage; | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 	_Axis percentageWithTankBar; | 
					
						
							| 
									
										
										
										
											2014-02-07 15:32:39 -02:00
										 |  |  | 	_Axis time; | 
					
						
							|  |  |  | 	_Axis cylinder; | 
					
						
							|  |  |  | 	_Axis temperature; | 
					
						
							| 
									
										
										
										
											2014-11-02 19:41:41 +01:00
										 |  |  | 	_Axis temperatureAll; | 
					
						
							| 
									
										
										
										
											2014-02-19 17:18:26 -08:00
										 |  |  | 	_Axis heartBeat; | 
					
						
							| 
									
										
										
										
											2015-01-17 19:54:10 +01:00
										 |  |  | 	_Axis heartBeatWithTankBar; | 
					
						
							| 
									
										
										
										
											2014-02-07 15:32:39 -02:00
										 |  |  | } itemPos; | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 |  |  | // Constant describing at which z-level the thumbnails are located.
 | 
					
						
							|  |  |  | // We might add more constants here for easier customability.
 | 
					
						
							| 
									
										
										
										
											2018-08-06 18:34:52 +02:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 |  |  | static const double thumbnailBaseZValue = 100.0; | 
					
						
							| 
									
										
										
										
											2018-08-06 18:34:52 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), | 
					
						
							| 
									
										
										
										
											2014-01-15 12:00:23 -02:00
										 |  |  | 	currentState(INVALID), | 
					
						
							| 
									
										
										
										
											2014-06-10 00:06:00 +03:00
										 |  |  | 	dataModel(new DivePlotDataModel(this)), | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | 	zoomLevel(0), | 
					
						
							| 
									
										
										
										
											2014-03-10 17:59:02 +02:00
										 |  |  | 	zoomFactor(1.15), | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	background(new DivePixmapItem()), | 
					
						
							| 
									
										
										
										
											2017-11-29 10:57:08 +01:00
										 |  |  | 	backgroundFile(":poster-icon"), | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-02-05 14:34:45 -02:00
										 |  |  | 	toolTipItem(new ToolTipItem()), | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2015-10-05 22:21:44 -07:00
										 |  |  | 	isPlotZoomed(prefs.zoomed_plot),// no! bad use of prefs. 'PreferencesDialog::loadSettings' NOT CALLED yet.
 | 
					
						
							| 
									
										
										
										
											2015-11-06 13:54:35 +02:00
										 |  |  | 	profileYAxis(new DepthAxis(this)), | 
					
						
							|  |  |  | 	gasYAxis(new PartialGasPressureAxis(this)), | 
					
						
							|  |  |  | 	temperatureAxis(new TemperatureAxis(this)), | 
					
						
							|  |  |  | 	timeAxis(new TimeAxis(this)), | 
					
						
							| 
									
										
										
										
											2014-02-07 14:14:36 -02:00
										 |  |  | 	diveProfileItem(new DiveProfileItem()), | 
					
						
							|  |  |  | 	temperatureItem(new DiveTemperatureItem()), | 
					
						
							| 
									
										
										
										
											2015-01-04 22:36:01 +01:00
										 |  |  | 	meanDepthItem(new DiveMeanDepthItem()), | 
					
						
							| 
									
										
										
										
											2015-11-06 13:54:35 +02:00
										 |  |  | 	cylinderPressureAxis(new DiveCartesianAxis(this)), | 
					
						
							| 
									
										
										
										
											2014-02-07 14:14:36 -02:00
										 |  |  | 	gasPressureItem(new DiveGasPressureItem()), | 
					
						
							| 
									
										
										
										
											2014-01-21 14:59:19 -02:00
										 |  |  | 	diveComputerText(new DiveTextItem()), | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | 	reportedCeiling(new DiveReportedCeiling()), | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	pn2GasItem(new PartialPressureGasItem()), | 
					
						
							|  |  |  | 	pheGasItem(new PartialPressureGasItem()), | 
					
						
							|  |  |  | 	po2GasItem(new PartialPressureGasItem()), | 
					
						
							| 
									
										
										
										
											2015-01-05 09:20:26 +02:00
										 |  |  | 	o2SetpointGasItem(new PartialPressureGasItem()), | 
					
						
							| 
									
										
										
										
											2015-01-20 20:13:53 +02:00
										 |  |  | 	ccrsensor1GasItem(new PartialPressureGasItem()), | 
					
						
							|  |  |  | 	ccrsensor2GasItem(new PartialPressureGasItem()), | 
					
						
							|  |  |  | 	ccrsensor3GasItem(new PartialPressureGasItem()), | 
					
						
							| 
									
										
										
										
											2018-03-14 17:13:37 +02:00
										 |  |  | 	ocpo2GasItem(new PartialPressureGasItem()), | 
					
						
							| 
									
										
										
										
											2017-03-25 13:03:37 +01:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							|  |  |  | 	diveCeiling(new DiveCalculatedCeiling(this)), | 
					
						
							|  |  |  | 	decoModelParameters(new DiveTextItem()), | 
					
						
							| 
									
										
										
										
											2015-11-06 13:54:35 +02:00
										 |  |  | 	heartBeatAxis(new DiveCartesianAxis(this)), | 
					
						
							| 
									
										
										
										
											2014-02-27 12:39:53 -03:00
										 |  |  | 	heartBeatItem(new DiveHeartrateItem()), | 
					
						
							| 
									
										
										
										
											2015-11-06 13:54:35 +02:00
										 |  |  | 	percentageAxis(new DiveCartesianAxis(this)), | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 	ambPressureItem(new DiveAmbPressureItem()), | 
					
						
							|  |  |  | 	gflineItem(new DiveGFLineItem()), | 
					
						
							| 
									
										
										
										
											2014-08-05 18:27:00 -03:00
										 |  |  | 	mouseFollowerVertical(new DiveLineItem()), | 
					
						
							| 
									
										
										
										
											2014-08-06 10:54:37 -07:00
										 |  |  | 	mouseFollowerHorizontal(new DiveLineItem()), | 
					
						
							| 
									
										
										
										
											2014-03-25 23:34:09 +02:00
										 |  |  | 	rulerItem(new RulerItem2()), | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-08-14 18:22:27 -06:00
										 |  |  | 	tankItem(new TankItem()), | 
					
						
							| 
									
										
										
										
											2014-03-25 23:34:09 +02:00
										 |  |  | 	isGrayscale(false), | 
					
						
							| 
									
										
										
										
											2014-05-26 17:51:46 -03:00
										 |  |  | 	printMode(false), | 
					
						
							| 
									
										
										
										
											2014-06-30 19:08:16 -03:00
										 |  |  | 	shouldCalculateMaxTime(true), | 
					
						
							| 
									
										
										
										
											2014-07-09 13:09:52 -07:00
										 |  |  | 	shouldCalculateMaxDepth(true), | 
					
						
							|  |  |  | 	fontPrintScale(1.0) | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-10-05 22:21:44 -07:00
										 |  |  | 	// would like to be able to ASSERT here that PreferencesDialog::loadSettings has been called.
 | 
					
						
							|  |  |  | 	isPlotZoomed = prefs.zoomed_plot; // now it seems that 'prefs' has loaded our preferences
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-25 12:56:41 +02:00
										 |  |  | 	init_plot_info(&plotInfo); | 
					
						
							| 
									
										
										
										
											2014-02-09 19:11:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | 	setupSceneAndFlags(); | 
					
						
							|  |  |  | 	setupItemSizes(); | 
					
						
							|  |  |  | 	setupItemOnScene(); | 
					
						
							|  |  |  | 	addItemsToScene(); | 
					
						
							|  |  |  | 	scene()->installEventFilter(this); | 
					
						
							| 
									
										
										
										
											2015-11-12 01:37:18 +01:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2015-11-03 21:17:50 +01:00
										 |  |  | 	setAcceptDrops(true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-10 16:50:57 +01:00
										 |  |  | 	addActionShortcut(Qt::Key_Escape, &ProfileWidget2::keyEscAction); | 
					
						
							|  |  |  | 	addActionShortcut(Qt::Key_Delete, &ProfileWidget2::keyDeleteAction); | 
					
						
							|  |  |  | 	addActionShortcut(Qt::Key_Up, &ProfileWidget2::keyUpAction); | 
					
						
							|  |  |  | 	addActionShortcut(Qt::Key_Down, &ProfileWidget2::keyDownAction); | 
					
						
							|  |  |  | 	addActionShortcut(Qt::Key_Left, &ProfileWidget2::keyLeftAction); | 
					
						
							|  |  |  | 	addActionShortcut(Qt::Key_Right, &ProfileWidget2::keyRightAction); | 
					
						
							| 
									
										
										
										
											2018-06-28 19:36:53 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 |  |  | 	connect(Thumbnailer::instance(), &Thumbnailer::thumbnailChanged, this, &ProfileWidget2::updateThumbnail, Qt::QueuedConnection); | 
					
						
							| 
									
										
										
										
											2020-04-17 23:18:58 +02:00
										 |  |  | 	connect(&diveListNotifier, &DiveListNotifier::picturesRemoved, this, &ProfileWidget2::picturesRemoved); | 
					
						
							|  |  |  | 	connect(&diveListNotifier, &DiveListNotifier::picturesAdded, this, &ProfileWidget2::picturesAdded); | 
					
						
							| 
									
										
										
										
											2020-03-03 22:42:51 +01:00
										 |  |  | 	connect(&diveListNotifier, &DiveListNotifier::cylinderEdited, this, &ProfileWidget2::profileChanged); | 
					
						
							|  |  |  | 	connect(&diveListNotifier, &DiveListNotifier::eventsChanged, this, &ProfileWidget2::profileChanged); | 
					
						
							| 
									
										
										
										
											2020-04-14 22:07:00 +02:00
										 |  |  | 	connect(&diveListNotifier, &DiveListNotifier::pictureOffsetChanged, this, &ProfileWidget2::pictureOffsetChanged); | 
					
						
							| 
									
										
										
										
											2015-11-12 01:37:18 +01:00
										 |  |  | #endif // SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-02 13:12:11 -08:00
										 |  |  | #if !defined(QT_NO_DEBUG) && defined(SHOW_PLOT_INFO_TABLE)
 | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | 	QTableView *diveDepthTableView = new QTableView(); | 
					
						
							|  |  |  | 	diveDepthTableView->setModel(dataModel); | 
					
						
							| 
									
										
										
										
											2014-03-07 12:42:13 -03:00
										 |  |  | 	diveDepthTableView->show(); | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2020-11-25 20:03:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	auto tec = qPrefTechnicalDetails::instance(); | 
					
						
							|  |  |  | 	connect(tec, &qPrefTechnicalDetails::calcalltissuesChanged           , this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(tec, &qPrefTechnicalDetails::calcceilingChanged              , this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(tec, &qPrefTechnicalDetails::dcceilingChanged                , this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(tec, &qPrefTechnicalDetails::eadChanged                      , this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(tec, &qPrefTechnicalDetails::calcceiling3mChanged            , this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(tec, &qPrefTechnicalDetails::modChanged                      , this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(tec, &qPrefTechnicalDetails::calcndlttsChanged               , this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(tec, &qPrefTechnicalDetails::hrgraphChanged                  , this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(tec, &qPrefTechnicalDetails::rulergraphChanged               , this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(tec, &qPrefTechnicalDetails::show_sacChanged                 , this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(tec, &qPrefTechnicalDetails::zoomed_plotChanged              , this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(tec, &qPrefTechnicalDetails::show_pictures_in_profileChanged , this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(tec, &qPrefTechnicalDetails::tankbarChanged                  , this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(tec, &qPrefTechnicalDetails::percentagegraphChanged          , this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	auto pp_gas = qPrefPartialPressureGas::instance(); | 
					
						
							|  |  |  | 	connect(pp_gas, &qPrefPartialPressureGas::pheChanged, this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(pp_gas, &qPrefPartialPressureGas::pn2Changed, this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							|  |  |  | 	connect(pp_gas, &qPrefPartialPressureGas::po2Changed, this, &ProfileWidget2::actionRequestedReplot); | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-01-15 12:23:40 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-15 20:41:42 +02:00
										 |  |  | ProfileWidget2::~ProfileWidget2() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	free_plot_info_data(&plotInfo); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-10 16:50:57 +01:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							|  |  |  | void ProfileWidget2::addActionShortcut(const Qt::Key shortcut, void (ProfileWidget2::*slot)()) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	QAction *action = new QAction(this); | 
					
						
							|  |  |  | 	action->setShortcut(shortcut); | 
					
						
							|  |  |  | 	action->setShortcutContext(Qt::WindowShortcut); | 
					
						
							|  |  |  | 	addAction(action); | 
					
						
							|  |  |  | 	connect(action, &QAction::triggered, this, slot); | 
					
						
							|  |  |  | 	actionsForKeys[shortcut] = action; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif // SUBSURFACE_MOBILE
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-19 14:39:34 +09:00
										 |  |  | #define SUBSURFACE_OBJ_DATA 1
 | 
					
						
							|  |  |  | #define SUBSURFACE_OBJ_DC_TEXT 0x42
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | void ProfileWidget2::addItemsToScene() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	scene()->addItem(background); | 
					
						
							|  |  |  | 	scene()->addItem(profileYAxis); | 
					
						
							|  |  |  | 	scene()->addItem(gasYAxis); | 
					
						
							|  |  |  | 	scene()->addItem(temperatureAxis); | 
					
						
							|  |  |  | 	scene()->addItem(timeAxis); | 
					
						
							|  |  |  | 	scene()->addItem(diveProfileItem); | 
					
						
							|  |  |  | 	scene()->addItem(cylinderPressureAxis); | 
					
						
							|  |  |  | 	scene()->addItem(temperatureItem); | 
					
						
							| 
									
										
										
										
											2015-01-01 16:28:37 -08:00
										 |  |  | 	scene()->addItem(meanDepthItem); | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | 	scene()->addItem(gasPressureItem); | 
					
						
							| 
									
										
										
										
											2014-05-19 14:39:34 +09:00
										 |  |  | 	// I cannot seem to figure out if an object that I find with itemAt() on the scene
 | 
					
						
							|  |  |  | 	// is the object I am looking for - my guess is there's a simple way in Qt to do that
 | 
					
						
							|  |  |  | 	// but nothing I tried worked.
 | 
					
						
							|  |  |  | 	// so instead this adds a special magic key/value pair to the object to mark it
 | 
					
						
							|  |  |  | 	diveComputerText->setData(SUBSURFACE_OBJ_DATA, SUBSURFACE_OBJ_DC_TEXT); | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | 	scene()->addItem(diveComputerText); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | 	scene()->addItem(reportedCeiling); | 
					
						
							| 
									
										
										
										
											2017-02-04 10:46:02 +01:00
										 |  |  | 	scene()->addItem(tankItem); | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | 	scene()->addItem(pn2GasItem); | 
					
						
							|  |  |  | 	scene()->addItem(pheGasItem); | 
					
						
							|  |  |  | 	scene()->addItem(po2GasItem); | 
					
						
							| 
									
										
										
										
											2015-01-05 09:20:26 +02:00
										 |  |  | 	scene()->addItem(o2SetpointGasItem); | 
					
						
							| 
									
										
										
										
											2015-01-20 20:13:53 +02:00
										 |  |  | 	scene()->addItem(ccrsensor1GasItem); | 
					
						
							|  |  |  | 	scene()->addItem(ccrsensor2GasItem); | 
					
						
							|  |  |  | 	scene()->addItem(ccrsensor3GasItem); | 
					
						
							| 
									
										
										
										
											2018-03-14 17:13:37 +02:00
										 |  |  | 	scene()->addItem(ocpo2GasItem); | 
					
						
							| 
									
										
										
										
											2017-03-25 13:03:37 +01:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							|  |  |  | 	scene()->addItem(toolTipItem); | 
					
						
							|  |  |  | 	scene()->addItem(diveCeiling); | 
					
						
							|  |  |  | 	scene()->addItem(decoModelParameters); | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 	scene()->addItem(percentageAxis); | 
					
						
							| 
									
										
										
										
											2014-02-19 17:18:26 -08:00
										 |  |  | 	scene()->addItem(heartBeatAxis); | 
					
						
							|  |  |  | 	scene()->addItem(heartBeatItem); | 
					
						
							| 
									
										
										
										
											2014-02-27 15:20:03 -03:00
										 |  |  | 	scene()->addItem(rulerItem); | 
					
						
							|  |  |  | 	scene()->addItem(rulerItem->sourceNode()); | 
					
						
							|  |  |  | 	scene()->addItem(rulerItem->destNode()); | 
					
						
							| 
									
										
										
										
											2014-08-05 18:27:00 -03:00
										 |  |  | 	scene()->addItem(mouseFollowerHorizontal); | 
					
						
							|  |  |  | 	scene()->addItem(mouseFollowerVertical); | 
					
						
							| 
									
										
										
										
											2014-08-05 15:47:02 -07:00
										 |  |  | 	QPen pen(QColor(Qt::red).lighter()); | 
					
						
							|  |  |  | 	pen.setWidth(0); | 
					
						
							|  |  |  | 	mouseFollowerHorizontal->setPen(pen); | 
					
						
							|  |  |  | 	mouseFollowerVertical->setPen(pen); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-22 11:40:22 -07:00
										 |  |  | 	Q_FOREACH (DiveCalculatedTissue *tissue, allTissues) { | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | 		scene()->addItem(tissue); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 	Q_FOREACH (DivePercentageItem *percentage, allPercentages) { | 
					
						
							|  |  |  | 		scene()->addItem(percentage); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	scene()->addItem(ambPressureItem); | 
					
						
							|  |  |  | 	scene()->addItem(gflineItem); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-01-15 12:23:40 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | void ProfileWidget2::setupItemOnScene() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-02-07 16:34:42 -02:00
										 |  |  | 	background->setZValue(9999); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-03-12 00:09:54 +02:00
										 |  |  | 	toolTipItem->setZValue(9998); | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | 	toolTipItem->setTimeAxis(timeAxis); | 
					
						
							| 
									
										
										
										
											2014-03-12 00:09:54 +02:00
										 |  |  | 	rulerItem->setZValue(9997); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-08-14 18:22:27 -06:00
										 |  |  | 	tankItem->setZValue(100); | 
					
						
							| 
									
										
										
										
											2014-01-23 17:54:34 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 17:59:21 -02:00
										 |  |  | 	profileYAxis->setOrientation(DiveCartesianAxis::TopToBottom); | 
					
						
							|  |  |  | 	profileYAxis->setMinimum(0); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	profileYAxis->setTickInterval(M_OR_FT(10, 30)); | 
					
						
							| 
									
										
										
										
											2014-03-19 17:06:18 -03:00
										 |  |  | 	profileYAxis->setTickSize(0.5); | 
					
						
							| 
									
										
										
										
											2014-02-15 22:43:27 -02:00
										 |  |  | 	profileYAxis->setLineSize(96); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-16 14:16:39 -08:00
										 |  |  | 	timeAxis->setLineSize(92); | 
					
						
							| 
									
										
										
										
											2014-03-19 17:06:18 -03:00
										 |  |  | 	timeAxis->setTickSize(-0.5); | 
					
						
							| 
									
										
										
										
											2014-02-07 17:59:21 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-23 17:54:34 -02:00
										 |  |  | 	gasYAxis->setOrientation(DiveCartesianAxis::BottomToTop); | 
					
						
							|  |  |  | 	gasYAxis->setTickInterval(1); | 
					
						
							| 
									
										
										
										
											2014-02-07 19:42:47 -02:00
										 |  |  | 	gasYAxis->setTickSize(1); | 
					
						
							| 
									
										
										
										
											2014-01-27 15:14:42 -02:00
										 |  |  | 	gasYAxis->setMinimum(0); | 
					
						
							|  |  |  | 	gasYAxis->setModel(dataModel); | 
					
						
							| 
									
										
										
										
											2014-02-15 11:15:57 -08:00
										 |  |  | 	gasYAxis->setFontLabelScale(0.7); | 
					
						
							| 
									
										
										
										
											2014-02-15 22:43:27 -02:00
										 |  |  | 	gasYAxis->setLineSize(96); | 
					
						
							| 
									
										
										
										
											2014-01-16 18:39:13 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-02-19 17:18:26 -08:00
										 |  |  | 	heartBeatAxis->setOrientation(DiveCartesianAxis::BottomToTop); | 
					
						
							| 
									
										
										
										
											2014-04-07 22:15:21 +02:00
										 |  |  | 	heartBeatAxis->setTickSize(0.2); | 
					
						
							| 
									
										
										
										
											2014-02-19 17:18:26 -08:00
										 |  |  | 	heartBeatAxis->setTickInterval(10); | 
					
						
							|  |  |  | 	heartBeatAxis->setFontLabelScale(0.7); | 
					
						
							|  |  |  | 	heartBeatAxis->setLineSize(96); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 	percentageAxis->setOrientation(DiveCartesianAxis::BottomToTop); | 
					
						
							|  |  |  | 	percentageAxis->setTickSize(0.2); | 
					
						
							|  |  |  | 	percentageAxis->setTickInterval(10); | 
					
						
							|  |  |  | 	percentageAxis->setFontLabelScale(0.7); | 
					
						
							|  |  |  | 	percentageAxis->setLineSize(96); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-16 19:28:33 -02:00
										 |  |  | 	temperatureAxis->setOrientation(DiveCartesianAxis::BottomToTop); | 
					
						
							| 
									
										
										
										
											2014-01-16 18:39:13 -02:00
										 |  |  | 	temperatureAxis->setTickSize(2); | 
					
						
							|  |  |  | 	temperatureAxis->setTickInterval(300); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-17 15:34:15 -02:00
										 |  |  | 	cylinderPressureAxis->setOrientation(DiveCartesianAxis::BottomToTop); | 
					
						
							| 
									
										
										
										
											2014-01-17 14:28:59 -02:00
										 |  |  | 	cylinderPressureAxis->setTickSize(2); | 
					
						
							|  |  |  | 	cylinderPressureAxis->setTickInterval(30000); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-15 12:23:40 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-16 14:16:39 -08:00
										 |  |  | 	diveComputerText->setAlignment(Qt::AlignRight | Qt::AlignTop); | 
					
						
							| 
									
										
										
										
											2014-03-25 23:34:10 +02:00
										 |  |  | 	diveComputerText->setBrush(getColor(TIME_TEXT, isGrayscale)); | 
					
						
							| 
									
										
										
										
											2014-01-21 10:48:26 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-14 18:22:27 -06:00
										 |  |  | 	tankItem->setHorizontalAxis(timeAxis); | 
					
						
							| 
									
										
										
										
											2014-02-27 16:42:00 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							|  |  |  | 	rulerItem->setAxis(timeAxis, profileYAxis); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-24 20:03:46 +11:00
										 |  |  | 	// show the deco model parameters at the top in the center
 | 
					
						
							|  |  |  | 	decoModelParameters->setY(0); | 
					
						
							|  |  |  | 	decoModelParameters->setX(50); | 
					
						
							|  |  |  | 	decoModelParameters->setBrush(getColor(PRESSURE_TEXT)); | 
					
						
							|  |  |  | 	decoModelParameters->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); | 
					
						
							| 
									
										
										
										
											2018-01-10 17:08:56 +01:00
										 |  |  | 	setupItem(diveCeiling, profileYAxis, DivePlotDataModel::CEILING, DivePlotDataModel::TIME, 1); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	for (int i = 0; i < 16; i++) { | 
					
						
							| 
									
										
										
										
											2015-11-06 14:40:20 +02:00
										 |  |  | 		DiveCalculatedTissue *tissueItem = new DiveCalculatedTissue(this); | 
					
						
							| 
									
										
										
										
											2018-01-10 17:08:56 +01:00
										 |  |  | 		setupItem(tissueItem, profileYAxis, DivePlotDataModel::TISSUE_1 + i, DivePlotDataModel::TIME, 1 + i); | 
					
						
							| 
									
										
										
										
											2014-01-23 15:02:12 -02:00
										 |  |  | 		allTissues.append(tissueItem); | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 		DivePercentageItem *percentageItem = new DivePercentageItem(i); | 
					
						
							| 
									
										
										
										
											2018-01-10 17:08:56 +01:00
										 |  |  | 		setupItem(percentageItem, percentageAxis, DivePlotDataModel::PERCENTAGE_1 + i, DivePlotDataModel::TIME, 1 + i); | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 		allPercentages.append(percentageItem); | 
					
						
							| 
									
										
										
										
											2014-01-23 15:02:12 -02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-01-10 17:08:56 +01:00
										 |  |  | 	setupItem(heartBeatItem, heartBeatAxis, DivePlotDataModel::HEARTBEAT, DivePlotDataModel::TIME, 1); | 
					
						
							|  |  |  | 	setupItem(ambPressureItem, percentageAxis, DivePlotDataModel::AMBPRESSURE, DivePlotDataModel::TIME, 1); | 
					
						
							|  |  |  | 	setupItem(gflineItem, percentageAxis, DivePlotDataModel::GFLINE, DivePlotDataModel::TIME, 1); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-01-10 17:08:56 +01:00
										 |  |  | 	setupItem(reportedCeiling, profileYAxis, DivePlotDataModel::CEILING, DivePlotDataModel::TIME, 1); | 
					
						
							|  |  |  | 	setupItem(gasPressureItem, cylinderPressureAxis, DivePlotDataModel::TEMPERATURE, DivePlotDataModel::TIME, 1); | 
					
						
							|  |  |  | 	setupItem(temperatureItem, temperatureAxis, DivePlotDataModel::TEMPERATURE, DivePlotDataModel::TIME, 1); | 
					
						
							|  |  |  | 	setupItem(diveProfileItem, profileYAxis, DivePlotDataModel::DEPTH, DivePlotDataModel::TIME, 0); | 
					
						
							|  |  |  | 	setupItem(meanDepthItem, profileYAxis, DivePlotDataModel::INSTANT_MEANDEPTH, DivePlotDataModel::TIME, 1); | 
					
						
							| 
									
										
										
										
											2015-01-02 00:28:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-10 17:28:24 +01:00
										 |  |  | 	createPPGas(pn2GasItem, DivePlotDataModel::PN2, PN2, PN2_ALERT, NULL, &prefs.pp_graphs.pn2_threshold); | 
					
						
							|  |  |  | 	createPPGas(pheGasItem, DivePlotDataModel::PHE, PHE, PHE_ALERT, NULL, &prefs.pp_graphs.phe_threshold); | 
					
						
							|  |  |  | 	createPPGas(po2GasItem, DivePlotDataModel::PO2, PO2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max); | 
					
						
							| 
									
										
										
										
											2018-04-29 07:00:17 +02:00
										 |  |  | 	createPPGas(o2SetpointGasItem, DivePlotDataModel::O2SETPOINT, O2SETPOINT, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max); | 
					
						
							| 
									
										
										
										
											2018-01-10 17:28:24 +01:00
										 |  |  | 	createPPGas(ccrsensor1GasItem, DivePlotDataModel::CCRSENSOR1, CCRSENSOR1, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max); | 
					
						
							|  |  |  | 	createPPGas(ccrsensor2GasItem, DivePlotDataModel::CCRSENSOR2, CCRSENSOR2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max); | 
					
						
							|  |  |  | 	createPPGas(ccrsensor3GasItem, DivePlotDataModel::CCRSENSOR3, CCRSENSOR3, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max); | 
					
						
							| 
									
										
										
										
											2018-03-14 17:13:37 +02:00
										 |  |  | 	createPPGas(ocpo2GasItem, DivePlotDataModel::SCR_OC_PO2, SCR_OCPO2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max); | 
					
						
							| 
									
										
										
										
											2017-03-24 19:11:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-25 13:03:37 +01:00
										 |  |  | #undef CREATE_PP_GAS
 | 
					
						
							|  |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2017-03-24 19:11:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-25 17:20:18 -02:00
										 |  |  | 	// Visibility Connections
 | 
					
						
							| 
									
										
										
										
											2018-09-02 14:20:15 +02:00
										 |  |  | 	connect(qPrefPartialPressureGas::instance(), &qPrefPartialPressureGas::pheChanged, pheGasItem, &PartialPressureGasItem::setVisible); | 
					
						
							|  |  |  | 	connect(qPrefPartialPressureGas::instance(), &qPrefPartialPressureGas::po2Changed, po2GasItem, &PartialPressureGasItem::setVisible); | 
					
						
							|  |  |  | 	connect(qPrefPartialPressureGas::instance(), &qPrefPartialPressureGas::pn2Changed, pn2GasItem, &PartialPressureGasItem::setVisible); | 
					
						
							| 
									
										
										
										
											2016-01-25 17:20:18 -02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// because it was using a wrong settings.
 | 
					
						
							| 
									
										
										
										
											2018-09-02 14:20:15 +02:00
										 |  |  | 	connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::show_ccr_setpointChanged, o2SetpointGasItem, &PartialPressureGasItem::setVisible); | 
					
						
							|  |  |  | 	connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::show_scr_ocpo2Changed, ocpo2GasItem, &PartialPressureGasItem::setVisible); | 
					
						
							|  |  |  | 	connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::show_ccr_sensorsChanged, ccrsensor1GasItem, &PartialPressureGasItem::setVisible); | 
					
						
							|  |  |  | 	connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::show_ccr_sensorsChanged, ccrsensor2GasItem, &PartialPressureGasItem::setVisible); | 
					
						
							|  |  |  | 	connect(qPrefTechnicalDetails::instance(), &qPrefTechnicalDetails::show_ccr_sensorsChanged, ccrsensor3GasItem, &PartialPressureGasItem::setVisible); | 
					
						
							| 
									
										
										
										
											2014-01-23 18:03:28 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | 	heartBeatAxis->setTextVisible(true); | 
					
						
							|  |  |  | 	heartBeatAxis->setLinesVisible(true); | 
					
						
							|  |  |  | 	percentageAxis->setTextVisible(true); | 
					
						
							|  |  |  | 	percentageAxis->setLinesVisible(true); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-02-12 14:24:19 -02:00
										 |  |  | 	temperatureAxis->setTextVisible(false); | 
					
						
							| 
									
										
										
										
											2014-02-15 22:54:41 -02:00
										 |  |  | 	temperatureAxis->setLinesVisible(false); | 
					
						
							| 
									
										
										
										
											2014-02-12 14:24:19 -02:00
										 |  |  | 	cylinderPressureAxis->setTextVisible(false); | 
					
						
							| 
									
										
										
										
											2014-02-15 22:54:41 -02:00
										 |  |  | 	cylinderPressureAxis->setLinesVisible(false); | 
					
						
							|  |  |  | 	timeAxis->setLinesVisible(true); | 
					
						
							|  |  |  | 	profileYAxis->setLinesVisible(true); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	gasYAxis->setZValue(timeAxis->zValue() + 1); | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-01-15 13:01:29 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-12 12:20:25 +02:00
										 |  |  | void ProfileWidget2::replot() | 
					
						
							| 
									
										
										
										
											2014-03-09 10:59:31 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-04-13 13:45:52 +02:00
										 |  |  | 	plotDive(current_dive, true, false); | 
					
						
							| 
									
										
										
										
											2014-03-09 10:59:31 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-10 17:33:20 +01:00
										 |  |  | void ProfileWidget2::createPPGas(PartialPressureGasItem *item, int verticalColumn, color_index_t color, color_index_t colorAlert, | 
					
						
							| 
									
										
										
										
											2018-09-02 22:26:19 +02:00
										 |  |  | 				 const double *thresholdSettingsMin, const double *thresholdSettingsMax) | 
					
						
							| 
									
										
										
										
											2018-01-10 17:28:24 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	setupItem(item, gasYAxis, verticalColumn, DivePlotDataModel::TIME, 0); | 
					
						
							| 
									
										
										
										
											2018-01-10 17:39:25 +01:00
										 |  |  | 	item->setThresholdSettingsKey(thresholdSettingsMin, thresholdSettingsMax); | 
					
						
							| 
									
										
										
										
											2018-01-10 17:28:24 +01:00
										 |  |  | 	item->setColors(getColor(color, isGrayscale), getColor(colorAlert, isGrayscale)); | 
					
						
							|  |  |  | 	item->settingsChanged(); | 
					
						
							|  |  |  | 	item->setZValue(99); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | void ProfileWidget2::setupItemSizes() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-02-07 17:38:00 -02:00
										 |  |  | 	// Scene is *always* (double) 100 / 100.
 | 
					
						
							|  |  |  | 	// Background Config
 | 
					
						
							|  |  |  | 	/* Much probably a better math is needed here.
 | 
					
						
							|  |  |  | 	 * good thing is that we only need to change the | 
					
						
							|  |  |  | 	 * Axis and everything else is auto-adjusted.* | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 15:32:39 -02:00
										 |  |  | 	itemPos.background.on.setX(0); | 
					
						
							|  |  |  | 	itemPos.background.on.setY(0); | 
					
						
							|  |  |  | 	itemPos.background.off.setX(0); | 
					
						
							|  |  |  | 	itemPos.background.off.setY(110); | 
					
						
							| 
									
										
										
										
											2014-02-07 17:38:00 -02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	//Depth Axis Config
 | 
					
						
							|  |  |  | 	itemPos.depth.pos.on.setX(3); | 
					
						
							|  |  |  | 	itemPos.depth.pos.on.setY(3); | 
					
						
							|  |  |  | 	itemPos.depth.pos.off.setX(-2); | 
					
						
							|  |  |  | 	itemPos.depth.pos.off.setY(3); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	itemPos.depth.expanded.setP1(QPointF(0, 0)); | 
					
						
							| 
									
										
										
										
											2018-06-08 11:24:50 +02:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 	itemPos.depth.expanded.setP2(QPointF(0, 85)); | 
					
						
							| 
									
										
										
										
											2018-06-08 11:24:50 +02:00
										 |  |  | #else
 | 
					
						
							|  |  |  | 	itemPos.depth.expanded.setP2(QPointF(0, 65)); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	itemPos.depth.shrinked.setP1(QPointF(0, 0)); | 
					
						
							| 
									
										
										
										
											2014-11-02 19:41:41 +01:00
										 |  |  | 	itemPos.depth.shrinked.setP2(QPointF(0, 55)); | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 	itemPos.depth.intermediate.setP1(QPointF(0, 0)); | 
					
						
							| 
									
										
										
										
											2014-11-02 19:41:41 +01:00
										 |  |  | 	itemPos.depth.intermediate.setP2(QPointF(0, 65)); | 
					
						
							| 
									
										
										
										
											2014-02-07 17:38:00 -02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Time Axis Config
 | 
					
						
							|  |  |  | 	itemPos.time.pos.on.setX(3); | 
					
						
							| 
									
										
										
										
											2018-06-08 11:24:50 +02:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-02-16 14:16:39 -08:00
										 |  |  | 	itemPos.time.pos.on.setY(95); | 
					
						
							| 
									
										
										
										
											2018-06-08 11:24:50 +02:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2017-02-04 10:46:02 +01:00
										 |  |  | 	itemPos.time.pos.on.setY(89.5); | 
					
						
							| 
									
										
										
										
											2016-01-05 15:00:06 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-02-07 17:38:00 -02:00
										 |  |  | 	itemPos.time.pos.off.setX(3); | 
					
						
							|  |  |  | 	itemPos.time.pos.off.setY(110); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	itemPos.time.expanded.setP1(QPointF(0, 0)); | 
					
						
							|  |  |  | 	itemPos.time.expanded.setP2(QPointF(94, 0)); | 
					
						
							| 
									
										
										
										
											2014-02-07 19:42:47 -02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Partial Gas Axis Config
 | 
					
						
							| 
									
										
										
										
											2014-02-11 10:55:07 -08:00
										 |  |  | 	itemPos.partialPressure.pos.on.setX(97); | 
					
						
							| 
									
										
										
										
											2018-06-08 11:24:50 +02:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 	itemPos.partialPressure.pos.on.setY(75); | 
					
						
							| 
									
										
										
										
											2018-06-08 11:24:50 +02:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2017-03-25 13:03:37 +01:00
										 |  |  | 	itemPos.partialPressure.pos.on.setY(70); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-02-11 10:55:07 -08:00
										 |  |  | 	itemPos.partialPressure.pos.off.setX(110); | 
					
						
							| 
									
										
										
										
											2014-02-15 23:01:20 -02:00
										 |  |  | 	itemPos.partialPressure.pos.off.setY(63); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	itemPos.partialPressure.expanded.setP1(QPointF(0, 0)); | 
					
						
							| 
									
										
										
										
											2018-06-08 11:24:50 +02:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-11-02 19:41:41 +01:00
										 |  |  | 	itemPos.partialPressure.expanded.setP2(QPointF(0, 19)); | 
					
						
							| 
									
										
										
										
											2018-06-08 11:24:50 +02:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2017-03-25 13:03:37 +01:00
										 |  |  | 	itemPos.partialPressure.expanded.setP2(QPointF(0, 20)); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-08-15 08:11:14 -06:00
										 |  |  | 	itemPos.partialPressureWithTankBar = itemPos.partialPressure; | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 	itemPos.partialPressureWithTankBar.expanded.setP2(QPointF(0, 17)); | 
					
						
							|  |  |  | 	itemPos.partialPressureTissue = itemPos.partialPressure; | 
					
						
							|  |  |  | 	itemPos.partialPressureTissue.pos.on.setX(97); | 
					
						
							| 
									
										
										
										
											2014-11-02 19:41:41 +01:00
										 |  |  | 	itemPos.partialPressureTissue.pos.on.setY(65); | 
					
						
							|  |  |  | 	itemPos.partialPressureTissue.expanded.setP2(QPointF(0, 16)); | 
					
						
							| 
									
										
										
										
											2014-02-07 19:42:47 -02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// cylinder axis config
 | 
					
						
							|  |  |  | 	itemPos.cylinder.pos.on.setX(3); | 
					
						
							|  |  |  | 	itemPos.cylinder.pos.on.setY(20); | 
					
						
							|  |  |  | 	itemPos.cylinder.pos.off.setX(-10); | 
					
						
							|  |  |  | 	itemPos.cylinder.pos.off.setY(20); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	itemPos.cylinder.expanded.setP1(QPointF(0, 15)); | 
					
						
							|  |  |  | 	itemPos.cylinder.expanded.setP2(QPointF(0, 50)); | 
					
						
							|  |  |  | 	itemPos.cylinder.shrinked.setP1(QPointF(0, 0)); | 
					
						
							|  |  |  | 	itemPos.cylinder.shrinked.setP2(QPointF(0, 20)); | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 	itemPos.cylinder.intermediate.setP1(QPointF(0, 0)); | 
					
						
							|  |  |  | 	itemPos.cylinder.intermediate.setP2(QPointF(0, 20)); | 
					
						
							| 
									
										
										
										
											2014-02-07 21:17:14 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-16 14:16:39 -08:00
										 |  |  | 	// Temperature axis config
 | 
					
						
							| 
									
										
										
										
											2014-02-07 21:17:14 -02:00
										 |  |  | 	itemPos.temperature.pos.on.setX(3); | 
					
						
							|  |  |  | 	itemPos.temperature.pos.off.setX(-10); | 
					
						
							|  |  |  | 	itemPos.temperature.pos.off.setY(40); | 
					
						
							| 
									
										
										
										
											2014-11-02 19:41:41 +01:00
										 |  |  | 	itemPos.temperature.expanded.setP1(QPointF(0, 20)); | 
					
						
							|  |  |  | 	itemPos.temperature.expanded.setP2(QPointF(0, 33)); | 
					
						
							|  |  |  | 	itemPos.temperature.shrinked.setP1(QPointF(0, 2)); | 
					
						
							|  |  |  | 	itemPos.temperature.shrinked.setP2(QPointF(0, 12)); | 
					
						
							| 
									
										
										
										
											2018-06-08 11:24:50 +02:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							|  |  |  | 	itemPos.temperature.pos.on.setY(60); | 
					
						
							|  |  |  | 	itemPos.temperatureAll.pos.on.setY(51); | 
					
						
							| 
									
										
										
										
											2014-11-02 19:41:41 +01:00
										 |  |  | 	itemPos.temperature.intermediate.setP1(QPointF(0, 2)); | 
					
						
							|  |  |  | 	itemPos.temperature.intermediate.setP2(QPointF(0, 12)); | 
					
						
							| 
									
										
										
										
											2018-06-08 11:24:50 +02:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2017-02-04 10:46:02 +01:00
										 |  |  | 	itemPos.temperature.pos.on.setY(51); | 
					
						
							|  |  |  | 	itemPos.temperatureAll.pos.on.setY(47); | 
					
						
							|  |  |  | 	itemPos.temperature.intermediate.setP1(QPointF(0, 2)); | 
					
						
							|  |  |  | 	itemPos.temperature.intermediate.setP2(QPointF(0, 12)); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-02-07 21:17:14 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-20 09:29:20 +01:00
										 |  |  | 	// Heart rate axis config
 | 
					
						
							| 
									
										
										
										
											2014-02-19 17:18:26 -08:00
										 |  |  | 	itemPos.heartBeat.pos.on.setX(3); | 
					
						
							| 
									
										
										
										
											2015-01-17 19:54:10 +01:00
										 |  |  | 	itemPos.heartBeat.pos.on.setY(82); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	itemPos.heartBeat.expanded.setP1(QPointF(0, 0)); | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 	itemPos.heartBeat.expanded.setP2(QPointF(0, 10)); | 
					
						
							| 
									
										
										
										
											2015-01-17 19:54:10 +01:00
										 |  |  | 	itemPos.heartBeatWithTankBar = itemPos.heartBeat; | 
					
						
							|  |  |  | 	itemPos.heartBeatWithTankBar.expanded.setP2(QPointF(0, 7)); | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 	// Percentage axis config
 | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 	itemPos.percentage.pos.on.setX(3); | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 	itemPos.percentage.pos.on.setY(80); | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 	itemPos.percentage.expanded.setP1(QPointF(0, 0)); | 
					
						
							| 
									
										
										
										
											2014-09-19 08:48:19 +02:00
										 |  |  | 	itemPos.percentage.expanded.setP2(QPointF(0, 15)); | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 	itemPos.percentageWithTankBar = itemPos.percentage; | 
					
						
							| 
									
										
										
										
											2017-01-16 18:52:18 +01:00
										 |  |  | 	itemPos.percentageWithTankBar.expanded.setP2(QPointF(0, 11.9)); | 
					
						
							| 
									
										
										
										
											2014-02-19 17:18:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 21:17:14 -02:00
										 |  |  | 	itemPos.dcLabel.on.setX(3); | 
					
						
							| 
									
										
										
										
											2014-02-16 14:16:39 -08:00
										 |  |  | 	itemPos.dcLabel.on.setY(100); | 
					
						
							| 
									
										
										
										
											2014-02-07 21:17:14 -02:00
										 |  |  | 	itemPos.dcLabel.off.setX(-10); | 
					
						
							| 
									
										
										
										
											2014-02-16 14:16:39 -08:00
										 |  |  | 	itemPos.dcLabel.off.setY(100); | 
					
						
							| 
									
										
										
										
											2014-08-15 07:30:31 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	itemPos.tankBar.on.setX(0); | 
					
						
							| 
									
										
										
										
											2018-06-08 11:24:50 +02:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2017-01-16 18:52:18 +01:00
										 |  |  | 	itemPos.tankBar.on.setY(91.95); | 
					
						
							| 
									
										
										
										
											2018-06-08 11:24:50 +02:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2017-02-04 10:46:02 +01:00
										 |  |  | 	itemPos.tankBar.on.setY(86.4); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-10 17:08:56 +01:00
										 |  |  | void ProfileWidget2::setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *vAxis, | 
					
						
							| 
									
										
										
										
											2015-01-01 16:28:37 -08:00
										 |  |  | 			       int vData, int hData, int zValue) | 
					
						
							| 
									
										
										
										
											2014-02-07 14:14:36 -02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-01-10 17:08:56 +01:00
										 |  |  | 	item->setHorizontalAxis(timeAxis); | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | 	item->setVerticalAxis(vAxis); | 
					
						
							| 
									
										
										
										
											2018-01-10 17:08:56 +01:00
										 |  |  | 	item->setModel(dataModel); | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | 	item->setVerticalDataColumn(vData); | 
					
						
							|  |  |  | 	item->setHorizontalDataColumn(hData); | 
					
						
							|  |  |  | 	item->setZValue(zValue); | 
					
						
							| 
									
										
										
										
											2014-02-07 14:14:36 -02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | void ProfileWidget2::setupSceneAndFlags() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-12-18 10:47:00 -08:00
										 |  |  | 	setScene(new QGraphicsScene(this)); | 
					
						
							| 
									
										
										
										
											2014-02-07 14:59:58 -02:00
										 |  |  | 	scene()->setSceneRect(0, 0, 100, 100); | 
					
						
							|  |  |  | 	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | 
					
						
							|  |  |  | 	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | 
					
						
							|  |  |  | 	scene()->setItemIndexMethod(QGraphicsScene::NoIndex); | 
					
						
							|  |  |  | 	setOptimizationFlags(QGraphicsView::DontSavePainterState); | 
					
						
							|  |  |  | 	setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); | 
					
						
							|  |  |  | 	setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); | 
					
						
							|  |  |  | 	setMouseTracking(true); | 
					
						
							|  |  |  | 	background->setFlag(QGraphicsItem::ItemIgnoresTransformations); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-11 14:21:13 +03:00
										 |  |  | void ProfileWidget2::resetZoom() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (!zoomLevel) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	const qreal defScale = 1.0 / qPow(zoomFactor, (qreal)zoomLevel); | 
					
						
							|  |  |  | 	scale(defScale, defScale); | 
					
						
							|  |  |  | 	zoomLevel = 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | // Currently just one dive, but the plan is to enable All of the selected dives.
 | 
					
						
							| 
									
										
										
										
											2019-07-10 22:47:53 +02:00
										 |  |  | void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPictures, bool instant) | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-03-11 18:54:28 -03:00
										 |  |  | 	static bool firstCall = true; | 
					
						
							| 
									
										
										
										
											2015-12-01 15:36:20 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2018-05-29 12:49:47 +02:00
										 |  |  | 	QElapsedTimer measureDuration; // let's measure how long this takes us (maybe we'll turn of TTL calculation later
 | 
					
						
							| 
									
										
										
										
											2014-06-04 13:41:50 -07:00
										 |  |  | 	measureDuration.start(); | 
					
						
							| 
									
										
										
										
											2018-05-21 09:41:35 +02:00
										 |  |  | #else
 | 
					
						
							|  |  |  | 	Q_UNUSED(doClearPictures); | 
					
						
							| 
									
										
										
										
											2015-12-01 15:36:20 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-07-03 14:34:24 -07:00
										 |  |  | 	if (currentState != ADD && currentState != PLAN) { | 
					
						
							|  |  |  | 		if (!d) { | 
					
						
							| 
									
										
										
										
											2020-04-13 13:45:52 +02:00
										 |  |  | 			setEmptyState(); | 
					
						
							|  |  |  | 			return; | 
					
						
							| 
									
										
										
										
											2014-07-03 14:34:24 -07:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-01-15 13:34:55 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-03 14:34:24 -07:00
										 |  |  | 		// No need to do this again if we are already showing the same dive
 | 
					
						
							|  |  |  | 		// computer of the same dive, so we check the unique id of the dive
 | 
					
						
							|  |  |  | 		// and the selected dive computer number against the ones we are
 | 
					
						
							|  |  |  | 		// showing (can't compare the dive pointers as those might change).
 | 
					
						
							| 
									
										
										
										
											2014-07-09 11:19:08 -07:00
										 |  |  | 		if (d->id == displayed_dive.id && dc_number == dataModel->dcShown() && !force) | 
					
						
							| 
									
										
										
										
											2014-07-03 14:34:24 -07:00
										 |  |  | 			return; | 
					
						
							| 
									
										
										
										
											2014-07-02 20:00:57 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-03 14:34:24 -07:00
										 |  |  | 		// this copies the dive and makes copies of all the relevant additional data
 | 
					
						
							|  |  |  | 		copy_dive(d, &displayed_dive); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2017-01-07 03:01:14 +01:00
										 |  |  | 		if (decoMode() == VPMB) | 
					
						
							| 
									
										
										
										
											2016-09-24 18:02:07 +10:00
										 |  |  | 			decoModelParameters->setText(QString("VPM-B +%1").arg(prefs.vpmb_conservatism)); | 
					
						
							| 
									
										
										
										
											2015-10-24 20:03:46 +11:00
										 |  |  | 		else | 
					
						
							|  |  |  | 			decoModelParameters->setText(QString("GF %1/%2").arg(prefs.gflow).arg(prefs.gfhigh)); | 
					
						
							| 
									
										
										
										
											2014-07-03 14:34:24 -07:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2014-05-21 23:31:26 -03:00
										 |  |  | 		DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | 
					
						
							|  |  |  | 		plannerModel->createTemporaryPlan(); | 
					
						
							| 
									
										
										
										
											2015-07-29 10:31:34 -07:00
										 |  |  | 		struct diveplan &diveplan = plannerModel->getDiveplan(); | 
					
						
							|  |  |  | 		if (!diveplan.dp) { | 
					
						
							| 
									
										
										
										
											2014-05-21 23:31:26 -03:00
										 |  |  | 			plannerModel->deleteTemporaryPlan(); | 
					
						
							|  |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-01-07 03:01:14 +01:00
										 |  |  | 		if (decoMode() == VPMB) | 
					
						
							| 
									
										
										
										
											2016-09-24 18:02:08 +10:00
										 |  |  | 			decoModelParameters->setText(QString("VPM-B +%1").arg(diveplan.vpmb_conservatism)); | 
					
						
							| 
									
										
										
										
											2015-10-24 20:03:46 +11:00
										 |  |  | 		else | 
					
						
							| 
									
										
										
										
											2016-03-19 13:45:04 +11:00
										 |  |  | 			decoModelParameters->setText(QString("GF %1/%2").arg(diveplan.gflow).arg(diveplan.gfhigh)); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-05-21 23:31:26 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-02 20:00:57 -07:00
										 |  |  | 	// special handling for the first time we display things
 | 
					
						
							| 
									
										
										
										
											2019-07-10 22:47:53 +02:00
										 |  |  | 	animSpeed = instant ? 0 : qPrefDisplay::animation_speed(); | 
					
						
							| 
									
										
										
										
											2015-11-05 10:05:22 -08:00
										 |  |  | 	if (firstCall && haveFilesOnCommandLine()) { | 
					
						
							| 
									
										
										
										
											2019-07-10 22:40:06 +02:00
										 |  |  | 		animSpeed = 0; | 
					
						
							| 
									
										
										
										
											2014-03-11 18:54:28 -03:00
										 |  |  | 		firstCall = false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-13 10:23:20 -07:00
										 |  |  | 	// restore default zoom level
 | 
					
						
							| 
									
										
										
										
											2015-10-11 14:21:13 +03:00
										 |  |  | 	resetZoom(); | 
					
						
							| 
									
										
										
										
											2014-03-10 17:59:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-01 15:36:20 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-03-25 23:34:12 +02:00
										 |  |  | 	// reset some item visibility on printMode changes
 | 
					
						
							| 
									
										
										
										
											2014-06-17 20:01:15 +02:00
										 |  |  | 	toolTipItem->setVisible(!printMode); | 
					
						
							| 
									
										
										
										
											2015-01-28 16:55:55 -02:00
										 |  |  | 	rulerItem->setVisible(prefs.rulergraph && !printMode && currentState != PLAN && currentState != ADD); | 
					
						
							| 
									
										
										
										
											2015-12-01 15:36:20 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-05-12 21:26:12 -03:00
										 |  |  | 	if (currentState == EMPTY) | 
					
						
							|  |  |  | 		setProfileState(); | 
					
						
							| 
									
										
										
										
											2014-02-26 11:42:55 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// next get the dive computer structure - if there are no samples
 | 
					
						
							|  |  |  | 	// let's create a fake profile that's somewhat reasonable for the
 | 
					
						
							|  |  |  | 	// data that we have
 | 
					
						
							| 
									
										
										
										
											2014-07-02 20:00:57 -07:00
										 |  |  | 	struct divecomputer *currentdc = select_dc(&displayed_dive); | 
					
						
							| 
									
										
										
										
											2014-01-15 13:34:55 -02:00
										 |  |  | 	Q_ASSERT(currentdc); | 
					
						
							| 
									
										
										
										
											2018-05-05 19:26:48 +02:00
										 |  |  | 	if (!currentdc || !currentdc->samples) | 
					
						
							|  |  |  | 		fake_dc(currentdc); | 
					
						
							| 
									
										
										
										
											2014-01-15 13:34:55 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-23 09:47:33 +02:00
										 |  |  | 	bool setpointflag = (currentdc->divemode == CCR) && prefs.pp_graphs.po2 && current_dive; | 
					
						
							|  |  |  | 	bool sensorflag = setpointflag && prefs.show_ccr_sensors; | 
					
						
							|  |  |  | 	o2SetpointGasItem->setVisible(setpointflag && prefs.show_ccr_setpoint); | 
					
						
							|  |  |  | 	ccrsensor1GasItem->setVisible(sensorflag); | 
					
						
							|  |  |  | 	ccrsensor2GasItem->setVisible(sensorflag && (currentdc->no_o2sensors > 1)); | 
					
						
							|  |  |  | 	ccrsensor3GasItem->setVisible(sensorflag && (currentdc->no_o2sensors > 2)); | 
					
						
							| 
									
										
										
										
											2018-03-14 17:13:37 +02:00
										 |  |  | 	ocpo2GasItem->setVisible((currentdc->divemode == PSCR) && prefs.show_scr_ocpo2); | 
					
						
							| 
									
										
										
										
											2015-01-05 09:20:26 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-15 13:34:55 -02:00
										 |  |  | 	/* This struct holds all the data that's about to be plotted.
 | 
					
						
							|  |  |  | 	 * I'm not sure this is the best approach ( but since we are | 
					
						
							|  |  |  | 	 * interpolating some points of the Dive, maybe it is... ) | 
					
						
							|  |  |  | 	 * The  Calculation of the points should be done per graph, | 
					
						
							|  |  |  | 	 * so I'll *not* calculate everything if something is not being | 
					
						
							|  |  |  | 	 * shown. | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2018-01-09 19:32:41 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-06 15:34:31 +02:00
										 |  |  | 	// create_plot_info_new() automatically frees old plot data
 | 
					
						
							| 
									
										
										
										
											2018-01-09 19:32:41 +01:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2017-11-24 14:17:01 +01:00
										 |  |  | 	create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth, &DivePlannerPointsModel::instance()->final_deco_state); | 
					
						
							| 
									
										
										
										
											2018-01-09 19:32:41 +01:00
										 |  |  | #else
 | 
					
						
							|  |  |  | 	create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth, nullptr); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-01-28 21:00:47 -08:00
										 |  |  | 	int newMaxtime = get_maxtime(&plotInfo); | 
					
						
							|  |  |  | 	if (shouldCalculateMaxTime || newMaxtime > maxtime) | 
					
						
							|  |  |  | 		maxtime = newMaxtime; | 
					
						
							| 
									
										
										
										
											2014-06-30 19:08:16 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-06 13:27:39 +01:00
										 |  |  | 	/* Only update the max. depth if it's bigger than the current ones
 | 
					
						
							| 
									
										
										
										
											2014-06-30 19:08:16 -03:00
										 |  |  | 	 * when we are dragging the handler to plan / add dive. | 
					
						
							|  |  |  | 	 * otherwhise, update normally. | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2014-11-19 22:28:16 +00:00
										 |  |  | 	int newMaxDepth = get_maxdepth(&plotInfo); | 
					
						
							| 
									
										
										
										
											2015-01-01 16:28:37 -08:00
										 |  |  | 	if (!shouldCalculateMaxDepth) { | 
					
						
							| 
									
										
										
										
											2014-06-30 19:08:16 -03:00
										 |  |  | 		if (maxdepth < newMaxDepth) { | 
					
						
							|  |  |  | 			maxdepth = newMaxDepth; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		maxdepth = newMaxDepth; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-01-15 13:34:55 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-19 22:28:16 +00:00
										 |  |  | 	dataModel->setDive(&displayed_dive, plotInfo); | 
					
						
							| 
									
										
										
										
											2015-12-01 15:36:20 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-11-19 22:28:16 +00:00
										 |  |  | 	toolTipItem->setPlotInfo(plotInfo); | 
					
						
							| 
									
										
										
										
											2015-12-01 15:36:20 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-01-16 15:02:32 -02:00
										 |  |  | 	// It seems that I'll have a lot of boilerplate setting the model / axis for
 | 
					
						
							|  |  |  | 	// each item, I'll mostly like to fix this in the future, but I'll keep at this for now.
 | 
					
						
							| 
									
										
										
										
											2014-01-18 14:33:12 -08:00
										 |  |  | 	profileYAxis->setMaximum(maxdepth); | 
					
						
							| 
									
										
										
										
											2014-01-15 13:34:55 -02:00
										 |  |  | 	profileYAxis->updateTicks(); | 
					
						
							| 
									
										
										
										
											2014-02-07 17:59:21 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-19 22:28:16 +00:00
										 |  |  | 	temperatureAxis->setMinimum(plotInfo.mintemp); | 
					
						
							| 
									
										
										
										
											2014-12-10 15:48:19 -07:00
										 |  |  | 	temperatureAxis->setMaximum(plotInfo.maxtemp - plotInfo.mintemp > 2000 ? plotInfo.maxtemp : plotInfo.mintemp + 2000); | 
					
						
							| 
									
										
										
										
											2014-02-19 17:18:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-11-19 22:28:16 +00:00
										 |  |  | 	if (plotInfo.maxhr) { | 
					
						
							| 
									
										
										
										
											2018-03-15 23:12:45 +01:00
										 |  |  | 		int heartBeatAxisMin = lrint(plotInfo.minhr / 5.0 - 0.5) * 5; | 
					
						
							|  |  |  | 		int heartBeatAxisMax, heartBeatAxisTick; | 
					
						
							|  |  |  | 		if (plotInfo.maxhr - plotInfo.minhr < 40) | 
					
						
							|  |  |  | 			heartBeatAxisTick = 10; | 
					
						
							|  |  |  | 		else if (plotInfo.maxhr - plotInfo.minhr < 80) | 
					
						
							|  |  |  | 			heartBeatAxisTick = 20; | 
					
						
							|  |  |  | 		else if (plotInfo.maxhr - plotInfo.minhr < 100) | 
					
						
							|  |  |  | 			heartBeatAxisTick = 25; | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			heartBeatAxisTick = 50; | 
					
						
							|  |  |  | 		for (heartBeatAxisMax = heartBeatAxisMin; heartBeatAxisMax < plotInfo.maxhr; heartBeatAxisMax += heartBeatAxisTick); | 
					
						
							|  |  |  | 		heartBeatAxis->setMinimum(heartBeatAxisMin); | 
					
						
							|  |  |  | 		heartBeatAxis->setMaximum(heartBeatAxisMax + 1); | 
					
						
							|  |  |  | 		heartBeatAxis->setTickInterval(heartBeatAxisTick); | 
					
						
							| 
									
										
										
										
											2014-07-21 19:32:46 -03:00
										 |  |  | 		heartBeatAxis->updateTicks(HR_AXIS); // this shows the ticks
 | 
					
						
							| 
									
										
										
										
											2014-02-23 14:32:25 -08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-11-19 22:28:16 +00:00
										 |  |  | 	heartBeatAxis->setVisible(prefs.hrgraph && plotInfo.maxhr); | 
					
						
							| 
									
										
										
										
											2014-07-21 19:32:46 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 	percentageAxis->setMinimum(0); | 
					
						
							|  |  |  | 	percentageAxis->setMaximum(100); | 
					
						
							|  |  |  | 	percentageAxis->setVisible(false); | 
					
						
							|  |  |  | 	percentageAxis->updateTicks(HR_AXIS); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-12-01 12:46:51 +01:00
										 |  |  | 	if (shouldCalculateMaxTime) | 
					
						
							|  |  |  | 		timeAxis->setMaximum(maxtime); | 
					
						
							| 
									
										
										
										
											2014-01-27 17:09:08 -02:00
										 |  |  | 	int i, incr; | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	static int increments[8] = { 10, 20, 30, 60, 5 * 60, 10 * 60, 15 * 60, 30 * 60 }; | 
					
						
							| 
									
										
										
										
											2014-01-27 17:09:08 -02:00
										 |  |  | 	/* Time markers: at most every 10 seconds, but no more than 12 markers.
 | 
					
						
							|  |  |  | 	 * We start out with 10 seconds and increment up to 30 minutes, | 
					
						
							|  |  |  | 	 * depending on the dive time. | 
					
						
							|  |  |  | 	 * This allows for 6h dives - enough (I hope) for even the craziest | 
					
						
							|  |  |  | 	 * divers - but just in case, for those 8h depth-record-breaking dives, | 
					
						
							|  |  |  | 	 * we double the interval if this still doesn't get us to 12 or fewer | 
					
						
							|  |  |  | 	 * time markers */ | 
					
						
							|  |  |  | 	i = 0; | 
					
						
							|  |  |  | 	while (i < 7 && maxtime / increments[i] > 12) | 
					
						
							|  |  |  | 		i++; | 
					
						
							|  |  |  | 	incr = increments[i]; | 
					
						
							|  |  |  | 	while (maxtime / incr > 12) | 
					
						
							|  |  |  | 		incr *= 2; | 
					
						
							|  |  |  | 	timeAxis->setTickInterval(incr); | 
					
						
							| 
									
										
										
										
											2014-01-15 13:34:55 -02:00
										 |  |  | 	timeAxis->updateTicks(); | 
					
						
							| 
									
										
										
										
											2014-11-19 22:28:16 +00:00
										 |  |  | 	cylinderPressureAxis->setMinimum(plotInfo.minpressure); | 
					
						
							|  |  |  | 	cylinderPressureAxis->setMaximum(plotInfo.maxpressure); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2019-03-19 20:05:39 +01:00
										 |  |  | 	rulerItem->setPlotInfo(plotInfo); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-02-05 10:56:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef SUBSURFACE_MOBILE
 | 
					
						
							|  |  |  | 	if (currentdc->divemode == CCR) { | 
					
						
							| 
									
										
										
										
											2017-10-26 15:55:49 +02:00
										 |  |  | 		gasYAxis->setPos(itemPos.partialPressure.pos.on); | 
					
						
							| 
									
										
										
										
											2017-03-25 13:03:37 +01:00
										 |  |  | 		gasYAxis->setLine(itemPos.partialPressure.expanded); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-05 10:56:43 +01:00
										 |  |  | 		tankItem->setVisible(false); | 
					
						
							| 
									
										
										
										
											2017-03-25 13:03:37 +01:00
										 |  |  | 		pn2GasItem->setVisible(false); | 
					
						
							|  |  |  | 		po2GasItem->setVisible(prefs.pp_graphs.po2); | 
					
						
							|  |  |  | 		pheGasItem->setVisible(false); | 
					
						
							|  |  |  | 		o2SetpointGasItem->setVisible(prefs.show_ccr_setpoint); | 
					
						
							|  |  |  | 		ccrsensor1GasItem->setVisible(prefs.show_ccr_sensors); | 
					
						
							|  |  |  | 		ccrsensor2GasItem->setVisible(prefs.show_ccr_sensors && (currentdc->no_o2sensors > 1)); | 
					
						
							|  |  |  | 		ccrsensor3GasItem->setVisible(prefs.show_ccr_sensors && (currentdc->no_o2sensors > 1)); | 
					
						
							| 
									
										
										
										
											2018-03-14 17:13:37 +02:00
										 |  |  | 		ocpo2GasItem->setVisible((currentdc->divemode == PSCR) && prefs.show_scr_ocpo2); | 
					
						
							| 
									
										
										
										
											2018-10-08 10:53:05 +02:00
										 |  |  | 		//when no gas graph, we can show temperature
 | 
					
						
							|  |  |  | 		if (!po2GasItem->isVisible() && | 
					
						
							|  |  |  | 		    !o2SetpointGasItem->isVisible() && | 
					
						
							|  |  |  | 		    !ccrsensor1GasItem->isVisible() && | 
					
						
							|  |  |  | 		    !ccrsensor2GasItem->isVisible() && | 
					
						
							|  |  |  | 		    !ccrsensor3GasItem->isVisible() && | 
					
						
							|  |  |  | 		    !ocpo2GasItem->isVisible()) | 
					
						
							|  |  |  | 			temperatureItem->setVisible(true); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			temperatureItem->setVisible(false); | 
					
						
							| 
									
										
										
										
											2017-02-05 10:56:43 +01:00
										 |  |  | 	} else { | 
					
						
							|  |  |  | 		tankItem->setVisible(prefs.tankbar); | 
					
						
							| 
									
										
										
										
											2017-03-25 13:03:37 +01:00
										 |  |  | 		gasYAxis->setPos(itemPos.partialPressure.pos.off); | 
					
						
							|  |  |  | 		pn2GasItem->setVisible(false); | 
					
						
							|  |  |  | 		po2GasItem->setVisible(false); | 
					
						
							|  |  |  | 		pheGasItem->setVisible(false); | 
					
						
							|  |  |  | 		o2SetpointGasItem->setVisible(false); | 
					
						
							|  |  |  | 		ccrsensor1GasItem->setVisible(false); | 
					
						
							|  |  |  | 		ccrsensor2GasItem->setVisible(false); | 
					
						
							|  |  |  | 		ccrsensor3GasItem->setVisible(false); | 
					
						
							| 
									
										
										
										
											2018-03-14 17:13:37 +02:00
										 |  |  | 		ocpo2GasItem->setVisible(false); | 
					
						
							| 
									
										
										
										
											2017-02-05 10:56:43 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-11-19 22:28:16 +00:00
										 |  |  | 	tankItem->setData(dataModel, &plotInfo, &displayed_dive); | 
					
						
							| 
									
										
										
										
											2014-01-23 17:54:34 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-27 15:14:42 -02:00
										 |  |  | 	dataModel->emitDataChanged(); | 
					
						
							| 
									
										
										
										
											2014-01-23 16:12:18 -02:00
										 |  |  | 	// The event items are a bit special since we don't know how many events are going to
 | 
					
						
							|  |  |  | 	// exist on a dive, so I cant create cache items for that. that's why they are here
 | 
					
						
							|  |  |  | 	// while all other items are up there on the constructor.
 | 
					
						
							| 
									
										
										
										
											2014-01-16 15:02:32 -02:00
										 |  |  | 	qDeleteAll(eventItems); | 
					
						
							|  |  |  | 	eventItems.clear(); | 
					
						
							|  |  |  | 	struct event *event = currentdc->events; | 
					
						
							| 
									
										
										
										
											2018-08-16 17:11:51 +02:00
										 |  |  | 	struct gasmix lastgasmix = get_gasmix_at_time(&displayed_dive, current_dc, duration_t{1}); | 
					
						
							| 
									
										
										
										
											2018-05-22 10:49:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-16 15:02:32 -02:00
										 |  |  | 	while (event) { | 
					
						
							| 
									
										
										
										
											2018-05-22 10:49:29 +02:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2015-08-03 22:55:46 +02:00
										 |  |  | 		// if print mode is selected only draw headings, SP change, gas events or bookmark event
 | 
					
						
							|  |  |  | 		if (printMode) { | 
					
						
							| 
									
										
										
										
											2018-01-07 11:12:48 +01:00
										 |  |  | 			if (empty_string(event->name) || | 
					
						
							| 
									
										
										
										
											2015-08-03 22:55:46 +02:00
										 |  |  | 			    !(strcmp(event->name, "heading") == 0 || | 
					
						
							|  |  |  | 			      (same_string(event->name, "SP change") && event->time.seconds == 0) || | 
					
						
							|  |  |  | 			      event_is_gaschange(event) || | 
					
						
							|  |  |  | 			      event->type == SAMPLE_EVENT_BOOKMARK)) { | 
					
						
							|  |  |  | 				event = event->next; | 
					
						
							|  |  |  | 				continue; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-05-22 10:49:29 +02:00
										 |  |  | #else
 | 
					
						
							|  |  |  | 		// printMode is always selected for SUBSURFACE_MOBILE due to font problems
 | 
					
						
							|  |  |  | 		// BUT events are wanted.
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-01-16 15:02:32 -02:00
										 |  |  | 		DiveEventItem *item = new DiveEventItem(); | 
					
						
							|  |  |  | 		item->setHorizontalAxis(timeAxis); | 
					
						
							| 
									
										
										
										
											2019-07-10 21:57:51 +02:00
										 |  |  | 		item->setVerticalAxis(profileYAxis, qPrefDisplay::animation_speed()); | 
					
						
							| 
									
										
										
										
											2014-01-16 15:02:32 -02:00
										 |  |  | 		item->setModel(dataModel); | 
					
						
							| 
									
										
										
										
											2018-08-16 19:10:10 +02:00
										 |  |  | 		item->setEvent(event, lastgasmix); | 
					
						
							| 
									
										
										
										
											2014-01-19 20:16:08 -02:00
										 |  |  | 		item->setZValue(2); | 
					
						
							| 
									
										
										
										
											2020-08-07 21:10:46 +02:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							|  |  |  | 		item->setScale(printMode ? 4 :1); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-01-16 15:02:32 -02:00
										 |  |  | 		scene()->addItem(item); | 
					
						
							|  |  |  | 		eventItems.push_back(item); | 
					
						
							| 
									
										
										
										
											2020-05-01 11:30:50 +02:00
										 |  |  | 		if (event_is_gaschange(event)) | 
					
						
							|  |  |  | 			lastgasmix = get_gasmix_from_event(&displayed_dive, event); | 
					
						
							| 
									
										
										
										
											2014-01-16 15:02:32 -02:00
										 |  |  | 		event = event->next; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-22 10:49:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-17 08:14:58 -07:00
										 |  |  | 	// Only set visible the events that should be visible
 | 
					
						
							| 
									
										
										
										
											2014-05-22 11:40:22 -07:00
										 |  |  | 	Q_FOREACH (DiveEventItem *event, eventItems) { | 
					
						
							| 
									
										
										
										
											2014-03-16 15:10:03 -07:00
										 |  |  | 		event->setVisible(!event->shouldBeHidden()); | 
					
						
							| 
									
										
										
										
											2014-02-23 08:33:58 -08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-04-23 23:17:19 +02:00
										 |  |  | 	QString dcText = get_dc_nickname(currentdc); | 
					
						
							| 
									
										
										
										
											2017-06-21 20:53:47 +02:00
										 |  |  | 	if (dcText == "planned dive") | 
					
						
							|  |  |  | 		dcText = tr("Planned dive"); | 
					
						
							|  |  |  | 	else if (dcText == "manually added dive") | 
					
						
							|  |  |  | 		dcText = tr("Manually added dive"); | 
					
						
							|  |  |  | 	else if (dcText.isEmpty()) | 
					
						
							| 
									
										
										
										
											2015-01-24 06:54:16 +12:00
										 |  |  | 		dcText = tr("Unknown dive computer"); | 
					
						
							| 
									
										
										
										
											2017-10-20 08:51:20 +02:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							|  |  |  | 	int nr; | 
					
						
							|  |  |  | 	if ((nr = number_of_computers(&displayed_dive)) > 1) | 
					
						
							|  |  |  | 		dcText += tr(" (#%1 of %2)").arg(dc_number + 1).arg(nr); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-05-19 14:29:43 +09:00
										 |  |  | 	diveComputerText->setText(dcText); | 
					
						
							| 
									
										
										
										
											2014-05-21 23:31:26 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-05 16:05:44 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-05-25 17:49:26 -03:00
										 |  |  | 	if (currentState == ADD || currentState == PLAN) { // TODO: figure a way to move this from here.
 | 
					
						
							| 
									
										
										
										
											2014-05-21 23:31:26 -03:00
										 |  |  | 		repositionDiveHandlers(); | 
					
						
							|  |  |  | 		DivePlannerPointsModel *model = DivePlannerPointsModel::instance(); | 
					
						
							|  |  |  | 		model->deleteTemporaryPlan(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-16 15:25:57 +02:00
										 |  |  | 	if (doClearPictures) | 
					
						
							| 
									
										
										
										
											2018-04-06 17:58:16 +02:00
										 |  |  | 		clearPictures(); | 
					
						
							|  |  |  | 	else | 
					
						
							| 
									
										
										
										
											2019-07-10 22:47:53 +02:00
										 |  |  | 		plotPicturesInternal(d, instant); | 
					
						
							| 
									
										
										
										
											2018-10-17 11:28:33 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	toolTipItem->refresh(mapToScene(mapFromGlobal(QCursor::pos()))); | 
					
						
							| 
									
										
										
										
											2018-01-10 13:55:29 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-07-21 18:54:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-04 13:41:50 -07:00
										 |  |  | 	// OK, how long did this take us? Anything above the second is way too long,
 | 
					
						
							|  |  |  | 	// so if we are calculation TTS / NDL then let's force that off.
 | 
					
						
							| 
									
										
										
										
											2015-12-01 15:36:20 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-06-04 13:41:50 -07:00
										 |  |  | 	if (measureDuration.elapsed() > 1000 && prefs.calcndltts) { | 
					
						
							| 
									
										
										
										
											2018-08-15 11:52:50 +02:00
										 |  |  | 		qPrefTechnicalDetails::set_calcndltts(false); | 
					
						
							| 
									
										
										
										
											2015-11-05 10:51:12 -08:00
										 |  |  | 		report_error(qPrintable(tr("Show NDL / TTS was disabled because of excessive processing time"))); | 
					
						
							| 
									
										
										
										
											2014-06-04 13:41:50 -07:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-12-01 15:36:20 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-06 14:40:20 +02:00
										 |  |  | void ProfileWidget2::dateTimeChanged() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	emit dateTimeChangedItems(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-21 18:20:29 +02:00
										 |  |  | void ProfileWidget2::actionRequestedReplot(bool) | 
					
						
							| 
									
										
										
										
											2016-01-25 15:54:23 -02:00
										 |  |  | { | 
					
						
							|  |  |  | 	settingsChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | void ProfileWidget2::settingsChanged() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-05-05 15:58:25 -07:00
										 |  |  | 	// if we are showing calculated ceilings then we have to replot()
 | 
					
						
							|  |  |  | 	// because the GF could have changed; otherwise we try to avoid replot()
 | 
					
						
							| 
									
										
										
										
											2018-01-29 13:13:29 +01:00
										 |  |  | 	// but always replot in PLAN/ADD/EDIT mode to avoid a bug of DiveHandlers not
 | 
					
						
							|  |  |  | 	// being redrawn on setting changes, causing them to become unattached
 | 
					
						
							|  |  |  | 	// to the profile
 | 
					
						
							|  |  |  | 	bool needReplot; | 
					
						
							|  |  |  | 	if (currentState == ADD || currentState == PLAN || currentState ==  EDIT) | 
					
						
							|  |  |  | 		needReplot = true; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		needReplot = prefs.calcceiling; | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2017-11-25 10:38:15 +01:00
										 |  |  | 	gasYAxis->settingsChanged();	// Initialize ticks of partial pressure graph
 | 
					
						
							| 
									
										
										
										
											2015-01-17 19:54:10 +01:00
										 |  |  | 	if ((prefs.percentagegraph||prefs.hrgraph) && PP_GRAPHS_ENABLED) { | 
					
						
							| 
									
										
										
										
											2014-02-12 13:50:35 -02:00
										 |  |  | 		profileYAxis->animateChangeLine(itemPos.depth.shrinked); | 
					
						
							| 
									
										
										
										
											2014-11-02 19:41:41 +01:00
										 |  |  | 		temperatureAxis->setPos(itemPos.temperatureAll.pos.on); | 
					
						
							| 
									
										
										
										
											2014-02-12 14:08:01 -02:00
										 |  |  | 		temperatureAxis->animateChangeLine(itemPos.temperature.shrinked); | 
					
						
							| 
									
										
										
										
											2014-02-12 14:12:56 -02:00
										 |  |  | 		cylinderPressureAxis->animateChangeLine(itemPos.cylinder.shrinked); | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (prefs.tankbar) { | 
					
						
							|  |  |  | 			percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on); | 
					
						
							|  |  |  | 			percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded); | 
					
						
							| 
									
										
										
										
											2015-01-17 19:54:10 +01:00
										 |  |  | 			heartBeatAxis->setPos(itemPos.heartBeatWithTankBar.pos.on); | 
					
						
							|  |  |  | 			heartBeatAxis->animateChangeLine(itemPos.heartBeatWithTankBar.expanded); | 
					
						
							| 
									
										
										
										
											2017-11-23 22:39:17 +01:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 			percentageAxis->setPos(itemPos.percentage.pos.on); | 
					
						
							| 
									
										
										
										
											2015-01-17 19:54:10 +01:00
										 |  |  | 			percentageAxis->animateChangeLine(itemPos.percentage.expanded); | 
					
						
							|  |  |  | 			heartBeatAxis->setPos(itemPos.heartBeat.pos.on); | 
					
						
							|  |  |  | 			heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded); | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		gasYAxis->setPos(itemPos.partialPressureTissue.pos.on); | 
					
						
							|  |  |  | 		gasYAxis->animateChangeLine(itemPos.partialPressureTissue.expanded); | 
					
						
							| 
									
										
										
										
											2014-12-10 15:49:12 -07:00
										 |  |  | 	} else if (PP_GRAPHS_ENABLED || prefs.hrgraph || prefs.percentagegraph) { | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 		profileYAxis->animateChangeLine(itemPos.depth.intermediate); | 
					
						
							| 
									
										
										
										
											2014-11-02 19:41:41 +01:00
										 |  |  | 		temperatureAxis->setPos(itemPos.temperature.pos.on); | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 		temperatureAxis->animateChangeLine(itemPos.temperature.intermediate); | 
					
						
							|  |  |  | 		cylinderPressureAxis->animateChangeLine(itemPos.cylinder.intermediate); | 
					
						
							|  |  |  | 		if (prefs.tankbar) { | 
					
						
							|  |  |  | 			percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on); | 
					
						
							|  |  |  | 			percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded); | 
					
						
							|  |  |  | 			gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on); | 
					
						
							| 
									
										
										
										
											2017-11-23 22:39:17 +01:00
										 |  |  | 			gasYAxis->animateChangeLine(itemPos.partialPressureWithTankBar.expanded); | 
					
						
							| 
									
										
										
										
											2015-01-17 19:54:10 +01:00
										 |  |  | 			heartBeatAxis->setPos(itemPos.heartBeatWithTankBar.pos.on); | 
					
						
							|  |  |  | 			heartBeatAxis->animateChangeLine(itemPos.heartBeatWithTankBar.expanded); | 
					
						
							| 
									
										
										
										
											2014-12-10 15:49:12 -07:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 			gasYAxis->setPos(itemPos.partialPressure.pos.on); | 
					
						
							|  |  |  | 			gasYAxis->animateChangeLine(itemPos.partialPressure.expanded); | 
					
						
							|  |  |  | 			percentageAxis->setPos(itemPos.percentage.pos.on); | 
					
						
							| 
									
										
										
										
											2017-11-23 22:39:17 +01:00
										 |  |  | 			percentageAxis->animateChangeLine(itemPos.percentage.expanded); | 
					
						
							| 
									
										
										
										
											2015-01-17 19:54:10 +01:00
										 |  |  | 			heartBeatAxis->setPos(itemPos.heartBeat.pos.on); | 
					
						
							|  |  |  | 			heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded); | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #else
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-02-12 13:50:35 -02:00
										 |  |  | 		profileYAxis->animateChangeLine(itemPos.depth.expanded); | 
					
						
							| 
									
										
										
										
											2014-12-12 20:44:14 +01:00
										 |  |  | 		if (prefs.tankbar) { | 
					
						
							|  |  |  | 			temperatureAxis->setPos(itemPos.temperatureAll.pos.on); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			temperatureAxis->setPos(itemPos.temperature.pos.on); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-02-12 14:08:01 -02:00
										 |  |  | 		temperatureAxis->animateChangeLine(itemPos.temperature.expanded); | 
					
						
							| 
									
										
										
										
											2014-02-12 14:12:56 -02:00
										 |  |  | 		cylinderPressureAxis->animateChangeLine(itemPos.cylinder.expanded); | 
					
						
							| 
									
										
										
										
											2014-02-12 13:50:35 -02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-21 07:52:14 -05:00
										 |  |  | 	tankItem->setVisible(prefs.tankbar); | 
					
						
							| 
									
										
										
										
											2014-04-16 22:03:44 +02:00
										 |  |  | 	if (prefs.zoomed_plot != isPlotZoomed) { | 
					
						
							|  |  |  | 		isPlotZoomed = prefs.zoomed_plot; | 
					
						
							| 
									
										
										
										
											2014-05-05 15:58:25 -07:00
										 |  |  | 		needReplot = true; | 
					
						
							| 
									
										
										
										
											2014-02-27 12:39:53 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-05-05 15:58:25 -07:00
										 |  |  | 	if (needReplot) | 
					
						
							|  |  |  | 		replot(); | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | void ProfileWidget2::resizeEvent(QResizeEvent *event) | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-02-10 20:45:08 -08:00
										 |  |  | 	QGraphicsView::resizeEvent(event); | 
					
						
							| 
									
										
										
										
											2014-01-15 12:55:33 -02:00
										 |  |  | 	fitInView(sceneRect(), Qt::IgnoreAspectRatio); | 
					
						
							| 
									
										
										
										
											2014-02-07 16:34:42 -02:00
										 |  |  | 	fixBackgroundPos(); | 
					
						
							| 
									
										
										
										
											2014-01-15 12:55:33 -02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-05-26 17:51:46 -03:00
										 |  |  | void ProfileWidget2::mousePressEvent(QMouseEvent *event) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-03-11 03:23:45 +02:00
										 |  |  | 	if (zoomLevel) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2014-05-26 17:51:46 -03:00
										 |  |  | 	QGraphicsView::mousePressEvent(event); | 
					
						
							| 
									
										
										
										
											2017-01-28 21:00:47 -08:00
										 |  |  | 	if (currentState == PLAN || currentState == ADD || currentState == EDIT) | 
					
						
							| 
									
										
										
										
											2018-01-12 16:57:11 +01:00
										 |  |  | 		shouldCalculateMaxDepth = shouldCalculateMaxTime = false; | 
					
						
							| 
									
										
										
										
											2014-05-26 17:51:46 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-30 19:08:16 -03:00
										 |  |  | void ProfileWidget2::divePlannerHandlerClicked() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-03-11 03:23:45 +02:00
										 |  |  | 	if (zoomLevel) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2018-01-12 16:57:11 +01:00
										 |  |  | 	shouldCalculateMaxDepth = shouldCalculateMaxTime = false; | 
					
						
							| 
									
										
										
										
											2014-06-30 19:08:16 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::divePlannerHandlerReleased() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-03-11 03:23:45 +02:00
										 |  |  | 	if (zoomLevel) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2018-01-12 16:57:11 +01:00
										 |  |  | 	shouldCalculateMaxDepth = shouldCalculateMaxTime = true; | 
					
						
							| 
									
										
										
										
											2014-06-30 19:08:16 -03:00
										 |  |  | 	replot(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-26 17:51:46 -03:00
										 |  |  | void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-03-11 03:23:45 +02:00
										 |  |  | 	if (zoomLevel) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2014-05-26 17:51:46 -03:00
										 |  |  | 	QGraphicsView::mouseReleaseEvent(event); | 
					
						
							| 
									
										
										
										
											2017-01-28 21:00:47 -08:00
										 |  |  | 	if (currentState == PLAN || currentState == ADD || currentState == EDIT) { | 
					
						
							| 
									
										
										
										
											2018-01-24 11:42:42 +01:00
										 |  |  | 		shouldCalculateMaxTime = shouldCalculateMaxDepth = true; | 
					
						
							| 
									
										
										
										
											2014-05-26 17:51:46 -03:00
										 |  |  | 		replot(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-05-26 17:51:46 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-15 12:55:33 -02:00
										 |  |  | void ProfileWidget2::fixBackgroundPos() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-05-28 15:43:32 -03:00
										 |  |  | 	static QPixmap toBeScaled(backgroundFile); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	if (currentState != EMPTY) | 
					
						
							| 
									
										
										
										
											2014-02-07 19:42:47 -02:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2014-03-10 17:59:01 +02:00
										 |  |  | 	QPixmap p = toBeScaled.scaledToHeight(viewport()->height() - 40, Qt::SmoothTransformation); | 
					
						
							| 
									
										
										
										
											2014-01-16 11:50:56 +07:00
										 |  |  | 	int x = viewport()->width() / 2 - p.width() / 2; | 
					
						
							| 
									
										
										
										
											2014-03-10 17:59:01 +02:00
										 |  |  | 	int y = viewport()->height() / 2 - p.height() / 2; | 
					
						
							| 
									
										
										
										
											2014-02-07 15:32:39 -02:00
										 |  |  | 	background->setPixmap(p); | 
					
						
							|  |  |  | 	background->setX(mapToScene(x, 0).x()); | 
					
						
							| 
									
										
										
										
											2014-03-10 17:59:01 +02:00
										 |  |  | 	background->setY(mapToScene(y, 20).y()); | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 |  |  | void ProfileWidget2::scale(qreal sx, qreal sy) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	QGraphicsView::scale(sx, sy); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							|  |  |  | 	// Since the zoom level changed, adjust the duration bars accordingly.
 | 
					
						
							|  |  |  | 	// We want to grow/shrink the length, but not the height and pen.
 | 
					
						
							|  |  |  | 	for (PictureEntry &p: pictures) | 
					
						
							|  |  |  | 		updateDurationLine(p); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Since we created new duration lines, we have to update the order in which the thumbnails is painted.
 | 
					
						
							|  |  |  | 	updateThumbnailPaintOrder(); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-25 18:30:49 +01:00
										 |  |  | bool ProfileWidget2::isPointOutOfBoundaries(const QPointF &point) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	double xpos = timeAxis->valueAt(point); | 
					
						
							|  |  |  | 	double ypos = profileYAxis->valueAt(point); | 
					
						
							|  |  |  | 	return xpos > timeAxis->maximum() || | 
					
						
							|  |  |  | 	       xpos < timeAxis->minimum() || | 
					
						
							|  |  |  | 	       ypos > profileYAxis->maximum() || | 
					
						
							|  |  |  | 	       ypos < profileYAxis->minimum(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | void ProfileWidget2::wheelEvent(QWheelEvent *event) | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-03-10 17:59:01 +02:00
										 |  |  | 	if (currentState == EMPTY) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2014-02-05 14:34:45 -02:00
										 |  |  | 	QPoint toolTipPos = mapFromScene(toolTipItem->pos()); | 
					
						
							| 
									
										
										
										
											2015-01-01 16:28:37 -08:00
										 |  |  | 	if (event->buttons() == Qt::LeftButton) | 
					
						
							| 
									
										
										
										
											2014-08-06 13:51:54 +02:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2020-10-26 07:50:13 -07:00
										 |  |  | 	if (event->angleDelta().y() > 0 && zoomLevel < 20) { | 
					
						
							| 
									
										
										
										
											2014-03-10 17:59:02 +02:00
										 |  |  | 		scale(zoomFactor, zoomFactor); | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | 		zoomLevel++; | 
					
						
							| 
									
										
										
										
											2020-10-26 07:50:13 -07:00
										 |  |  | 	} else if (event->angleDelta().y() < 0 && zoomLevel > 0) { | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | 		// Zooming out
 | 
					
						
							| 
									
										
										
										
											2014-03-10 17:59:02 +02:00
										 |  |  | 		scale(1.0 / zoomFactor, 1.0 / zoomFactor); | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | 		zoomLevel--; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-10-26 10:02:23 -07:00
										 |  |  | #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
 | 
					
						
							|  |  |  | 	scrollViewTo(event->position().toPoint()); | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | 	scrollViewTo(event->pos()); | 
					
						
							| 
									
										
										
										
											2020-10-26 10:02:23 -07:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-02-05 14:34:45 -02:00
										 |  |  | 	toolTipItem->setPos(mapToScene(toolTipPos)); | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-21 15:52:24 -03:00
										 |  |  | void ProfileWidget2::mouseDoubleClickEvent(QMouseEvent *event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (currentState == PLAN || currentState == ADD) { | 
					
						
							|  |  |  | 		DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | 
					
						
							|  |  |  | 		QPointF mappedPos = mapToScene(event->pos()); | 
					
						
							|  |  |  | 		if (isPointOutOfBoundaries(mappedPos)) | 
					
						
							|  |  |  | 			return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-08 13:41:41 +07:00
										 |  |  | 		int minutes = lrint(timeAxis->valueAt(mappedPos) / 60); | 
					
						
							|  |  |  | 		int milimeters = lrint(profileYAxis->valueAt(mappedPos) / M_OR_FT(1, 1)) * M_OR_FT(1, 1); | 
					
						
							| 
									
										
										
										
											2018-06-17 13:41:06 +02:00
										 |  |  | 		plannerModel->addStop(milimeters, minutes * 60, -1, 0, true, UNDEF_COMP_TYPE); | 
					
						
							| 
									
										
										
										
											2014-05-21 15:52:24 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | void ProfileWidget2::scrollViewTo(const QPoint &pos) | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	/* since we cannot use translate() directly on the scene we hack on
 | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  |  * the scroll bars (hidden) functionality */ | 
					
						
							| 
									
										
										
										
											2014-03-10 17:59:01 +02:00
										 |  |  | 	if (!zoomLevel || currentState == EMPTY) | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 	QScrollBar *vs = verticalScrollBar(); | 
					
						
							|  |  |  | 	QScrollBar *hs = horizontalScrollBar(); | 
					
						
							| 
									
										
										
										
											2014-02-05 18:57:02 +02:00
										 |  |  | 	const qreal yRat = (qreal)pos.y() / viewport()->height(); | 
					
						
							|  |  |  | 	const qreal xRat = (qreal)pos.x() / viewport()->width(); | 
					
						
							| 
									
										
										
										
											2017-03-23 08:13:49 +07:00
										 |  |  | 	vs->setValue(lrint(yRat * vs->maximum())); | 
					
						
							|  |  |  | 	hs->setValue(lrint(xRat * hs->maximum())); | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | void ProfileWidget2::mouseMoveEvent(QMouseEvent *event) | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-01-14 14:41:56 -02:00
										 |  |  | 	QPointF pos = mapToScene(event->pos()); | 
					
						
							| 
									
										
										
										
											2018-10-17 11:28:33 +02:00
										 |  |  | 	toolTipItem->refresh(mapToScene(mapFromGlobal(QCursor::pos()))); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | 	if (zoomLevel == 0) { | 
					
						
							|  |  |  | 		QGraphicsView::mouseMoveEvent(event); | 
					
						
							| 
									
										
										
										
											2014-02-05 14:34:45 -02:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2015-01-14 14:41:56 -02:00
										 |  |  | 		QPoint toolTipPos = mapFromScene(toolTipItem->pos()); | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | 		scrollViewTo(event->pos()); | 
					
						
							| 
									
										
										
										
											2014-02-07 21:38:06 -02:00
										 |  |  | 		toolTipItem->setPos(mapToScene(toolTipPos)); | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-08-05 18:27:00 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	qreal vValue = profileYAxis->valueAt(pos); | 
					
						
							|  |  |  | 	qreal hValue = timeAxis->valueAt(pos); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-01 16:28:37 -08:00
										 |  |  | 	if (profileYAxis->maximum() >= vValue && profileYAxis->minimum() <= vValue) { | 
					
						
							| 
									
										
										
										
											2014-08-05 18:27:00 -03:00
										 |  |  | 		mouseFollowerHorizontal->setPos(timeAxis->pos().x(), pos.y()); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-01-01 16:28:37 -08:00
										 |  |  | 	if (timeAxis->maximum() >= hValue && timeAxis->minimum() <= hValue) { | 
					
						
							| 
									
										
										
										
											2014-08-05 18:27:00 -03:00
										 |  |  | 		mouseFollowerVertical->setPos(pos.x(), profileYAxis->line().y1()); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-05 16:15:59 -02:00
										 |  |  | bool ProfileWidget2::eventFilter(QObject *object, QEvent *event) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	QGraphicsScene *s = qobject_cast<QGraphicsScene *>(object); | 
					
						
							|  |  |  | 	if (s && event->type() == QEvent::GraphicsSceneHelp) { | 
					
						
							| 
									
										
										
										
											2014-02-05 16:15:59 -02:00
										 |  |  | 		event->ignore(); | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return QGraphicsView::eventFilter(object, event); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-02-07 16:34:42 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-10 16:36:45 +01:00
										 |  |  | template <typename T> | 
					
						
							| 
									
										
										
										
											2019-04-01 22:15:19 +02:00
										 |  |  | static void hideAll(const T &container) | 
					
						
							| 
									
										
										
										
											2018-01-10 16:36:45 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-01 22:15:19 +02:00
										 |  |  | 	for (auto *item: container) | 
					
						
							| 
									
										
										
										
											2018-01-10 16:36:45 +01:00
										 |  |  | 		item->setVisible(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 16:34:42 -02:00
										 |  |  | void ProfileWidget2::setEmptyState() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	// Then starting Empty State, move the background up.
 | 
					
						
							|  |  |  | 	if (currentState == EMPTY) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-19 19:33:19 +02:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							|  |  |  | 	clearPictures(); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-05-21 21:23:19 -03:00
										 |  |  | 	disconnectTemporaryConnections(); | 
					
						
							| 
									
										
										
										
											2014-05-21 20:34:06 -03:00
										 |  |  | 	setBackgroundBrush(getColor(::BACKGROUND, isGrayscale)); | 
					
						
							| 
									
										
										
										
											2014-02-10 14:41:59 -02:00
										 |  |  | 	dataModel->clear(); | 
					
						
							| 
									
										
										
										
											2014-02-07 16:34:42 -02:00
										 |  |  | 	currentState = EMPTY; | 
					
						
							| 
									
										
										
										
											2015-11-05 09:32:19 -08:00
										 |  |  | 	emit enableToolbar(false); | 
					
						
							| 
									
										
										
										
											2014-03-10 17:59:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 16:34:42 -02:00
										 |  |  | 	fixBackgroundPos(); | 
					
						
							| 
									
										
										
										
											2014-02-10 15:01:04 -02:00
										 |  |  | 	background->setVisible(true); | 
					
						
							| 
									
										
										
										
											2014-03-10 17:59:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	profileYAxis->setVisible(false); | 
					
						
							|  |  |  | 	gasYAxis->setVisible(false); | 
					
						
							|  |  |  | 	timeAxis->setVisible(false); | 
					
						
							|  |  |  | 	temperatureAxis->setVisible(false); | 
					
						
							|  |  |  | 	cylinderPressureAxis->setVisible(false); | 
					
						
							| 
									
										
										
										
											2014-02-07 16:34:42 -02:00
										 |  |  | 	diveComputerText->setVisible(false); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | 	reportedCeiling->setVisible(false); | 
					
						
							|  |  |  | 	tankItem->setVisible(false); | 
					
						
							| 
									
										
										
										
											2014-03-19 02:08:23 +08:00
										 |  |  | 	pn2GasItem->setVisible(false); | 
					
						
							|  |  |  | 	po2GasItem->setVisible(false); | 
					
						
							| 
									
										
										
										
											2017-03-25 13:03:37 +01:00
										 |  |  | 	pheGasItem->setVisible(false); | 
					
						
							| 
									
										
										
										
											2015-01-05 09:20:26 +02:00
										 |  |  | 	o2SetpointGasItem->setVisible(false); | 
					
						
							| 
									
										
										
										
											2015-01-20 20:13:53 +02:00
										 |  |  | 	ccrsensor1GasItem->setVisible(false); | 
					
						
							|  |  |  | 	ccrsensor2GasItem->setVisible(false); | 
					
						
							|  |  |  | 	ccrsensor3GasItem->setVisible(false); | 
					
						
							| 
									
										
										
										
											2018-03-14 17:13:37 +02:00
										 |  |  | 	ocpo2GasItem->setVisible(false); | 
					
						
							| 
									
										
										
										
											2017-03-25 13:03:37 +01:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2019-11-15 20:50:44 +01:00
										 |  |  | 	toolTipItem->clearPlotInfo(); | 
					
						
							| 
									
										
										
										
											2017-03-25 13:03:37 +01:00
										 |  |  | 	toolTipItem->setVisible(false); | 
					
						
							|  |  |  | 	diveCeiling->setVisible(false); | 
					
						
							|  |  |  | 	decoModelParameters->setVisible(false); | 
					
						
							|  |  |  | 	rulerItem->setVisible(false); | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 	ambPressureItem->setVisible(false); | 
					
						
							|  |  |  | 	gflineItem->setVisible(false); | 
					
						
							| 
									
										
										
										
											2014-08-05 18:27:00 -03:00
										 |  |  | 	mouseFollowerHorizontal->setVisible(false); | 
					
						
							|  |  |  | 	mouseFollowerVertical->setVisible(false); | 
					
						
							| 
									
										
										
										
											2015-12-06 21:36:21 +02:00
										 |  |  | 	heartBeatAxis->setVisible(false); | 
					
						
							|  |  |  | 	heartBeatItem->setVisible(false); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-05-28 15:43:32 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2018-01-10 16:36:45 +01:00
										 |  |  | 	hideAll(allTissues); | 
					
						
							|  |  |  | 	hideAll(allPercentages); | 
					
						
							|  |  |  | 	hideAll(handles); | 
					
						
							| 
									
										
										
										
											2015-11-05 16:05:44 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-06-08 11:24:50 +02:00
										 |  |  | 	hideAll(eventItems); | 
					
						
							| 
									
										
										
										
											2018-01-10 16:36:45 +01:00
										 |  |  | 	hideAll(gases); | 
					
						
							| 
									
										
										
										
											2014-02-07 16:34:42 -02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::setProfileState() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-02-07 16:54:12 -02:00
										 |  |  | 	// Then starting Empty State, move the background up.
 | 
					
						
							|  |  |  | 	if (currentState == PROFILE) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2014-02-07 16:34:42 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-21 21:23:19 -03:00
										 |  |  | 	disconnectTemporaryConnections(); | 
					
						
							| 
									
										
										
										
											2014-06-03 19:09:12 -03:00
										 |  |  | 	/* show the same stuff that the profile shows. */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-05 11:12:22 -08:00
										 |  |  | 	emit enableShortcuts(); | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 16:54:12 -02:00
										 |  |  | 	currentState = PROFILE; | 
					
						
							| 
									
										
										
										
											2015-11-05 09:32:19 -08:00
										 |  |  | 	emit enableToolbar(true); | 
					
						
							| 
									
										
										
										
											2014-03-25 23:34:10 +02:00
										 |  |  | 	setBackgroundBrush(getColor(::BACKGROUND, isGrayscale)); | 
					
						
							| 
									
										
										
										
											2014-02-07 17:38:00 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 19:42:47 -02:00
										 |  |  | 	background->setVisible(false); | 
					
						
							| 
									
										
										
										
											2014-03-10 17:59:01 +02:00
										 |  |  | 	profileYAxis->setVisible(true); | 
					
						
							|  |  |  | 	gasYAxis->setVisible(true); | 
					
						
							|  |  |  | 	timeAxis->setVisible(true); | 
					
						
							|  |  |  | 	temperatureAxis->setVisible(true); | 
					
						
							|  |  |  | 	cylinderPressureAxis->setVisible(true); | 
					
						
							| 
									
										
										
										
											2014-02-07 17:38:00 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 19:42:47 -02:00
										 |  |  | 	profileYAxis->setPos(itemPos.depth.pos.on); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							|  |  |  | 	toolTipItem->readPos(); | 
					
						
							|  |  |  | 	toolTipItem->setVisible(true); | 
					
						
							| 
									
										
										
										
											2015-01-17 19:54:10 +01:00
										 |  |  | 	if ((prefs.percentagegraph||prefs.hrgraph) && PP_GRAPHS_ENABLED) { | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 		profileYAxis->animateChangeLine(itemPos.depth.shrinked); | 
					
						
							| 
									
										
										
										
											2014-11-02 19:41:41 +01:00
										 |  |  | 		temperatureAxis->setPos(itemPos.temperatureAll.pos.on); | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 		temperatureAxis->animateChangeLine(itemPos.temperature.shrinked); | 
					
						
							|  |  |  | 		cylinderPressureAxis->animateChangeLine(itemPos.cylinder.shrinked); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (prefs.tankbar) { | 
					
						
							|  |  |  | 			percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on); | 
					
						
							|  |  |  | 			percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded); | 
					
						
							| 
									
										
										
										
											2015-01-17 19:54:10 +01:00
										 |  |  | 			heartBeatAxis->setPos(itemPos.heartBeatWithTankBar.pos.on); | 
					
						
							|  |  |  | 			heartBeatAxis->animateChangeLine(itemPos.heartBeatWithTankBar.expanded); | 
					
						
							|  |  |  | 		}else { | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 			percentageAxis->setPos(itemPos.percentage.pos.on); | 
					
						
							| 
									
										
										
										
											2015-01-17 19:54:10 +01:00
										 |  |  | 			percentageAxis->animateChangeLine(itemPos.percentage.expanded); | 
					
						
							|  |  |  | 			heartBeatAxis->setPos(itemPos.heartBeat.pos.on); | 
					
						
							|  |  |  | 			heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded); | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		gasYAxis->setPos(itemPos.partialPressureTissue.pos.on); | 
					
						
							|  |  |  | 		gasYAxis->animateChangeLine(itemPos.partialPressureTissue.expanded); | 
					
						
							| 
									
										
										
										
											2015-01-17 19:54:10 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 15:49:12 -07:00
										 |  |  | 	} else if (PP_GRAPHS_ENABLED || prefs.hrgraph || prefs.percentagegraph) { | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 		profileYAxis->animateChangeLine(itemPos.depth.intermediate); | 
					
						
							| 
									
										
										
										
											2014-11-02 19:41:41 +01:00
										 |  |  | 		temperatureAxis->setPos(itemPos.temperature.pos.on); | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 		temperatureAxis->animateChangeLine(itemPos.temperature.intermediate); | 
					
						
							|  |  |  | 		cylinderPressureAxis->animateChangeLine(itemPos.cylinder.intermediate); | 
					
						
							|  |  |  | 		if (prefs.tankbar) { | 
					
						
							|  |  |  | 			percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on); | 
					
						
							|  |  |  | 			percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded); | 
					
						
							|  |  |  | 			gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on); | 
					
						
							|  |  |  | 			gasYAxis->setLine(itemPos.partialPressureWithTankBar.expanded); | 
					
						
							| 
									
										
										
										
											2015-01-17 19:54:10 +01:00
										 |  |  | 			heartBeatAxis->setPos(itemPos.heartBeatWithTankBar.pos.on); | 
					
						
							|  |  |  | 			heartBeatAxis->animateChangeLine(itemPos.heartBeatWithTankBar.expanded); | 
					
						
							| 
									
										
										
										
											2014-12-10 15:49:12 -07:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 			gasYAxis->setPos(itemPos.partialPressure.pos.on); | 
					
						
							|  |  |  | 			gasYAxis->animateChangeLine(itemPos.partialPressure.expanded); | 
					
						
							|  |  |  | 			percentageAxis->setPos(itemPos.percentage.pos.on); | 
					
						
							|  |  |  | 			percentageAxis->setLine(itemPos.percentage.expanded); | 
					
						
							| 
									
										
										
										
											2015-01-17 19:54:10 +01:00
										 |  |  | 			heartBeatAxis->setPos(itemPos.heartBeat.pos.on); | 
					
						
							|  |  |  | 			heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded); | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #else
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 		profileYAxis->animateChangeLine(itemPos.depth.expanded); | 
					
						
							| 
									
										
										
										
											2014-12-12 20:44:14 +01:00
										 |  |  | 		if (prefs.tankbar) { | 
					
						
							|  |  |  | 			temperatureAxis->setPos(itemPos.temperatureAll.pos.on); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			temperatureAxis->setPos(itemPos.temperature.pos.on); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 		temperatureAxis->animateChangeLine(itemPos.temperature.expanded); | 
					
						
							|  |  |  | 		cylinderPressureAxis->animateChangeLine(itemPos.cylinder.expanded); | 
					
						
							| 
									
										
										
										
											2014-02-07 19:42:47 -02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-04-16 22:03:44 +02:00
										 |  |  | 	pn2GasItem->setVisible(prefs.pp_graphs.pn2); | 
					
						
							|  |  |  | 	po2GasItem->setVisible(prefs.pp_graphs.po2); | 
					
						
							|  |  |  | 	pheGasItem->setVisible(prefs.pp_graphs.phe); | 
					
						
							| 
									
										
										
										
											2015-01-23 09:47:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-24 14:42:25 -08:00
										 |  |  | 	bool setpointflag = current_dive && (current_dc->divemode == CCR) && prefs.pp_graphs.po2; | 
					
						
							| 
									
										
										
										
											2015-01-23 09:47:33 +02:00
										 |  |  | 	bool sensorflag = setpointflag && prefs.show_ccr_sensors; | 
					
						
							|  |  |  | 	o2SetpointGasItem->setVisible(setpointflag && prefs.show_ccr_setpoint); | 
					
						
							|  |  |  | 	ccrsensor1GasItem->setVisible(sensorflag); | 
					
						
							|  |  |  | 	ccrsensor2GasItem->setVisible(sensorflag && (current_dc->no_o2sensors > 1)); | 
					
						
							|  |  |  | 	ccrsensor3GasItem->setVisible(sensorflag && (current_dc->no_o2sensors > 2)); | 
					
						
							| 
									
										
										
										
											2018-05-02 13:21:00 +02:00
										 |  |  | 	ocpo2GasItem->setVisible(current_dive && (current_dc->divemode == PSCR) && prefs.show_scr_ocpo2); | 
					
						
							| 
									
										
										
										
											2014-02-07 19:42:47 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-16 22:03:44 +02:00
										 |  |  | 	heartBeatItem->setVisible(prefs.hrgraph); | 
					
						
							|  |  |  | 	diveCeiling->setVisible(prefs.calcceiling); | 
					
						
							| 
									
										
										
										
											2015-10-24 20:03:46 +11:00
										 |  |  | 	decoModelParameters->setVisible(prefs.calcceiling); | 
					
						
							| 
									
										
										
										
											2014-02-07 21:28:59 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-16 22:03:44 +02:00
										 |  |  | 	if (prefs.calcalltissues) { | 
					
						
							| 
									
										
										
										
											2014-05-22 11:40:22 -07:00
										 |  |  | 		Q_FOREACH (DiveCalculatedTissue *tissue, allTissues) { | 
					
						
							| 
									
										
										
										
											2014-02-07 21:28:59 -02:00
										 |  |  | 			tissue->setVisible(true); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 	if (prefs.percentagegraph) { | 
					
						
							|  |  |  | 		Q_FOREACH (DivePercentageItem *percentage, allPercentages) { | 
					
						
							|  |  |  | 			percentage->setVisible(true); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-09-28 10:11:38 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-09-15 14:09:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-21 12:57:48 -03:00
										 |  |  | 	rulerItem->setVisible(prefs.rulergraph); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 	timeAxis->setPos(itemPos.time.pos.on); | 
					
						
							|  |  |  | 	timeAxis->setLine(itemPos.time.expanded); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	cylinderPressureAxis->setPos(itemPos.cylinder.pos.on); | 
					
						
							|  |  |  | 	meanDepthItem->setVisible(prefs.show_average_depth); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	diveComputerText->setVisible(true); | 
					
						
							|  |  |  | 	diveComputerText->setPos(itemPos.dcLabel.on); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	reportedCeiling->setVisible(prefs.dcceiling); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-15 08:11:14 -06:00
										 |  |  | 	tankItem->setVisible(prefs.tankbar); | 
					
						
							| 
									
										
										
										
											2014-08-15 07:30:31 -06:00
										 |  |  | 	tankItem->setPos(itemPos.tankBar.on); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-05 16:05:44 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2018-01-10 16:36:45 +01:00
										 |  |  | 	hideAll(handles); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | 	mouseFollowerHorizontal->setVisible(false); | 
					
						
							|  |  |  | 	mouseFollowerVertical->setVisible(false); | 
					
						
							| 
									
										
										
										
											2015-11-05 16:05:44 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-01-10 16:36:45 +01:00
										 |  |  | 	hideAll(gases); | 
					
						
							| 
									
										
										
										
											2014-02-07 16:34:42 -02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-02-17 19:15:40 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-05 16:05:44 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-08-19 20:59:34 -05:00
										 |  |  | void ProfileWidget2::clearHandlers() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (handles.count()) { | 
					
						
							|  |  |  | 		foreach (DiveHandler *handle, handles) { | 
					
						
							|  |  |  | 			scene()->removeItem(handle); | 
					
						
							| 
									
										
										
										
											2015-03-13 02:32:49 +02:00
										 |  |  | 			delete handle; | 
					
						
							| 
									
										
										
										
											2014-08-19 20:59:34 -05:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		handles.clear(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-31 10:32:02 -08:00
										 |  |  | void ProfileWidget2::setToolTipVisibile(bool visible) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	toolTipItem->setVisible(visible); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-21 15:52:24 -03:00
										 |  |  | void ProfileWidget2::setAddState() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (currentState == ADD) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-13 02:32:50 +02:00
										 |  |  | 	clearHandlers(); | 
					
						
							| 
									
										
										
										
											2014-05-21 23:31:26 -03:00
										 |  |  | 	setProfileState(); | 
					
						
							| 
									
										
										
										
											2014-08-06 12:33:36 -07:00
										 |  |  | 	mouseFollowerHorizontal->setVisible(true); | 
					
						
							|  |  |  | 	mouseFollowerVertical->setVisible(true); | 
					
						
							|  |  |  | 	mouseFollowerHorizontal->setLine(timeAxis->line()); | 
					
						
							|  |  |  | 	mouseFollowerVertical->setLine(QLineF(0, profileYAxis->pos().y(), 0, timeAxis->pos().y())); | 
					
						
							| 
									
										
										
										
											2014-05-21 21:23:19 -03:00
										 |  |  | 	disconnectTemporaryConnections(); | 
					
						
							| 
									
										
										
										
											2015-11-05 11:12:22 -08:00
										 |  |  | 	emit disableShortcuts(false); | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 	actionsForKeys[Qt::Key_Left]->setShortcut(Qt::Key_Left); | 
					
						
							|  |  |  | 	actionsForKeys[Qt::Key_Right]->setShortcut(Qt::Key_Right); | 
					
						
							|  |  |  | 	actionsForKeys[Qt::Key_Up]->setShortcut(Qt::Key_Up); | 
					
						
							|  |  |  | 	actionsForKeys[Qt::Key_Down]->setShortcut(Qt::Key_Down); | 
					
						
							|  |  |  | 	actionsForKeys[Qt::Key_Escape]->setShortcut(Qt::Key_Escape); | 
					
						
							|  |  |  | 	actionsForKeys[Qt::Key_Delete]->setShortcut(Qt::Key_Delete); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-21 23:31:26 -03:00
										 |  |  | 	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | 
					
						
							| 
									
										
										
										
											2020-04-12 12:48:38 +02:00
										 |  |  | 	connect(plannerModel, &DivePlannerPointsModel::dataChanged, this, &ProfileWidget2::replot); | 
					
						
							|  |  |  | 	connect(plannerModel, &DivePlannerPointsModel::cylinderModelEdited, this, &ProfileWidget2::replot); | 
					
						
							| 
									
										
										
										
											2015-11-12 01:37:18 +01:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2020-04-12 12:48:38 +02:00
										 |  |  | 	connect(plannerModel, &DivePlannerPointsModel::rowsInserted, this, &ProfileWidget2::pointInserted); | 
					
						
							|  |  |  | 	connect(plannerModel, &DivePlannerPointsModel::rowsRemoved, this, &ProfileWidget2::pointsRemoved); | 
					
						
							| 
									
										
										
										
											2015-11-12 01:37:18 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-05-21 15:52:24 -03:00
										 |  |  | 	/* show the same stuff that the profile shows. */ | 
					
						
							|  |  |  | 	currentState = ADD; /* enable the add state. */ | 
					
						
							| 
									
										
										
										
											2014-05-27 21:55:29 +02:00
										 |  |  | 	diveCeiling->setVisible(true); | 
					
						
							| 
									
										
										
										
											2015-10-24 20:03:46 +11:00
										 |  |  | 	decoModelParameters->setVisible(true); | 
					
						
							| 
									
										
										
										
											2014-06-30 18:46:51 -03:00
										 |  |  | 	setBackgroundBrush(QColor("#A7DCFF")); | 
					
						
							| 
									
										
										
										
											2014-05-21 15:52:24 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::setPlanState() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (currentState == PLAN) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2014-05-25 15:12:00 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-25 07:40:09 +01:00
										 |  |  | 	clearHandlers(); | 
					
						
							| 
									
										
										
										
											2014-05-21 23:31:26 -03:00
										 |  |  | 	setProfileState(); | 
					
						
							| 
									
										
										
										
											2014-08-06 12:33:36 -07:00
										 |  |  | 	mouseFollowerHorizontal->setVisible(true); | 
					
						
							|  |  |  | 	mouseFollowerVertical->setVisible(true); | 
					
						
							|  |  |  | 	mouseFollowerHorizontal->setLine(timeAxis->line()); | 
					
						
							|  |  |  | 	mouseFollowerVertical->setLine(QLineF(0, profileYAxis->pos().y(), 0, timeAxis->pos().y())); | 
					
						
							| 
									
										
										
										
											2014-05-21 21:23:19 -03:00
										 |  |  | 	disconnectTemporaryConnections(); | 
					
						
							| 
									
										
										
										
											2015-11-05 11:12:22 -08:00
										 |  |  | 	emit disableShortcuts(true); | 
					
						
							| 
									
										
										
										
											2014-05-25 15:12:00 -03:00
										 |  |  | 	actionsForKeys[Qt::Key_Left]->setShortcut(Qt::Key_Left); | 
					
						
							|  |  |  | 	actionsForKeys[Qt::Key_Right]->setShortcut(Qt::Key_Right); | 
					
						
							|  |  |  | 	actionsForKeys[Qt::Key_Up]->setShortcut(Qt::Key_Up); | 
					
						
							|  |  |  | 	actionsForKeys[Qt::Key_Down]->setShortcut(Qt::Key_Down); | 
					
						
							|  |  |  | 	actionsForKeys[Qt::Key_Escape]->setShortcut(Qt::Key_Escape); | 
					
						
							|  |  |  | 	actionsForKeys[Qt::Key_Delete]->setShortcut(Qt::Key_Delete); | 
					
						
							| 
									
										
										
										
											2014-05-25 14:16:43 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | 
					
						
							| 
									
										
										
										
											2020-04-12 12:48:38 +02:00
										 |  |  | 	connect(plannerModel, &DivePlannerPointsModel::dataChanged, this, &ProfileWidget2::replot); | 
					
						
							|  |  |  | 	connect(plannerModel, &DivePlannerPointsModel::cylinderModelEdited, this, &ProfileWidget2::replot); | 
					
						
							|  |  |  | 	connect(plannerModel, &DivePlannerPointsModel::rowsInserted, this, &ProfileWidget2::pointInserted); | 
					
						
							|  |  |  | 	connect(plannerModel, &DivePlannerPointsModel::rowsRemoved, this, &ProfileWidget2::pointsRemoved); | 
					
						
							| 
									
										
										
										
											2014-05-25 15:12:00 -03:00
										 |  |  | 	/* show the same stuff that the profile shows. */ | 
					
						
							| 
									
										
										
										
											2014-05-21 15:52:24 -03:00
										 |  |  | 	currentState = PLAN; /* enable the add state. */ | 
					
						
							| 
									
										
										
										
											2014-05-27 21:55:29 +02:00
										 |  |  | 	diveCeiling->setVisible(true); | 
					
						
							| 
									
										
										
										
											2015-10-24 20:03:46 +11:00
										 |  |  | 	decoModelParameters->setVisible(true); | 
					
						
							| 
									
										
										
										
											2014-06-30 18:46:51 -03:00
										 |  |  | 	setBackgroundBrush(QColor("#D7E3EF")); | 
					
						
							| 
									
										
										
										
											2014-05-21 15:52:24 -03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-05-21 15:52:24 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-26 15:17:34 -07:00
										 |  |  | bool ProfileWidget2::isPlanner() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return currentState == PLAN; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-06 12:09:15 +02:00
										 |  |  | #if 0 // TODO::: FINISH OR DISABLE
 | 
					
						
							| 
									
										
										
										
											2019-07-06 12:35:33 +02:00
										 |  |  | struct int ProfileWidget2::getEntryFromPos(QPointF pos) | 
					
						
							| 
									
										
										
										
											2014-11-19 22:31:28 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	// find the time stamp corresponding to the mouse position
 | 
					
						
							| 
									
										
										
										
											2017-03-23 08:13:49 +07:00
										 |  |  | 	int seconds = lrint(timeAxis->valueAt(pos)); | 
					
						
							| 
									
										
										
										
											2014-11-19 22:31:28 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	for (int i = 0; i < plotInfo.nr; i++) { | 
					
						
							| 
									
										
										
										
											2019-07-06 12:35:33 +02:00
										 |  |  | 		if (plotInfo.entry[i].sec >= seconds) | 
					
						
							|  |  |  | 			return i; | 
					
						
							| 
									
										
										
										
											2014-11-19 22:31:28 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-07-06 12:35:33 +02:00
										 |  |  | 	return plotInfo.nr - 1; | 
					
						
							| 
									
										
										
										
											2014-11-19 22:31:28 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-07-06 12:09:15 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-11-19 22:31:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-05 16:05:44 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2020-08-25 05:37:08 +09:00
										 |  |  | /// Prints cylinder information for display.
 | 
					
						
							|  |  |  | /// eg : "Cyl 1 (AL80 EAN32)"
 | 
					
						
							|  |  |  | static QString printCylinderDescription(int i, const cylinder_t *cylinder) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	QString label = gettextFromC::tr("Cyl") + QString(" %1").arg(i+1); | 
					
						
							|  |  |  | 	if( cylinder != NULL ) { | 
					
						
							|  |  |  | 		QString mix = get_gas_string(cylinder->gasmix); | 
					
						
							|  |  |  | 		label += QString(" (%2 %3)").arg(cylinder->type.description).arg(mix); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return label; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event) | 
					
						
							| 
									
										
										
										
											2014-02-17 19:15:40 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-05-25 00:33:39 -03:00
										 |  |  | 	if (currentState == ADD || currentState == PLAN) { | 
					
						
							|  |  |  | 		QGraphicsView::contextMenuEvent(event); | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-05-19 14:39:34 +09:00
										 |  |  | 	QMenu m; | 
					
						
							|  |  |  | 	bool isDCName = false; | 
					
						
							| 
									
										
											  
											
												Undo: select dives after add, remove, merge, split dive commands
Select the proper dives after the add, remove, split and merge
dives commands on undo *and* redo. Generally, select the added
dives. For undo of add, remember the pre-addition selection.
For redo of remove, select the closest dive to the first removed
dive.
The biggest part of the commit is the signal-interface between
the dive commands and the dive-list model and dive-list view.
This is done in two steps:
1) To the DiveTripModel in batches of trips. The dive trip model
   transforms the dives into indices.
2) To the DiveListView. The DiveListView has to translate the
   DiveTripModel indexes to actual indexes via its QSortFilterProxy-
   model.
For code-reuse, derive all divelist-changing commands from a new base-class,
which has a flag that describes whether the divelist changed. The helper
functions which add and remove dives are made members of the base class and
set the flag is a selected dive is added or removed.
To properly detect when the current dive was deleted it
became necessary to turn the current dive from an index
to a pointer, because indices are not stable.
Unfortunately, in some cases an index was expected and these
places now have to transform the dive into an index. These
should be converted in due course.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
											
										 
											2018-08-03 11:35:43 +02:00
										 |  |  | 	if (!current_dive) | 
					
						
							| 
									
										
										
										
											2014-02-17 19:15:40 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2014-05-19 14:39:34 +09:00
										 |  |  | 	// figure out if we are ontop of the dive computer name in the profile
 | 
					
						
							|  |  |  | 	QGraphicsItem *sceneItem = itemAt(mapFromGlobal(event->globalPos())); | 
					
						
							|  |  |  | 	if (sceneItem) { | 
					
						
							|  |  |  | 		QGraphicsItem *parentItem = sceneItem; | 
					
						
							|  |  |  | 		while (parentItem) { | 
					
						
							|  |  |  | 			if (parentItem->data(SUBSURFACE_OBJ_DATA) == SUBSURFACE_OBJ_DC_TEXT) { | 
					
						
							|  |  |  | 				isDCName = true; | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			parentItem = parentItem->parentItem(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (isDCName) { | 
					
						
							| 
									
										
										
										
											2020-09-06 17:41:25 +02:00
										 |  |  | 			if (dc_number == 0 && number_of_computers(current_dive) == 1) | 
					
						
							| 
									
										
										
										
											2014-06-11 13:56:33 -07:00
										 |  |  | 				// nothing to do, can't delete or reorder
 | 
					
						
							| 
									
										
										
										
											2014-05-19 14:39:34 +09:00
										 |  |  | 				return; | 
					
						
							|  |  |  | 			// create menu to show when right clicking on dive computer name
 | 
					
						
							| 
									
										
										
										
											2014-06-11 13:56:33 -07:00
										 |  |  | 			if (dc_number > 0) | 
					
						
							| 
									
										
										
										
											2019-10-14 20:57:13 +02:00
										 |  |  | 				m.addAction(tr("Make first dive computer"), this, &ProfileWidget2::makeFirstDC); | 
					
						
							| 
									
										
										
										
											2020-09-06 17:41:25 +02:00
										 |  |  | 			if (number_of_computers(current_dive) > 1) { | 
					
						
							| 
									
										
										
										
											2019-10-14 20:57:13 +02:00
										 |  |  | 				m.addAction(tr("Delete this dive computer"), this, &ProfileWidget2::deleteCurrentDC); | 
					
						
							|  |  |  | 				m.addAction(tr("Split this dive computer into own dive"), this, &ProfileWidget2::splitCurrentDC); | 
					
						
							| 
									
										
										
										
											2019-03-31 10:20:13 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-05-19 14:39:34 +09:00
										 |  |  | 			m.exec(event->globalPos()); | 
					
						
							|  |  |  | 			// don't show the regular profile context menu
 | 
					
						
							|  |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	// create the profile context menu
 | 
					
						
							| 
									
										
										
										
											2020-01-30 15:03:48 +01:00
										 |  |  | 	QPointF scenePos = mapToScene(mapFromGlobal(event->globalPos())); | 
					
						
							|  |  |  | 	qreal sec_val = timeAxis->valueAt(scenePos); | 
					
						
							|  |  |  | 	int seconds = (sec_val < 0.0) ? 0 : (int)sec_val; | 
					
						
							| 
									
										
										
										
											2020-08-25 05:37:08 +09:00
										 |  |  | 	DiveEventItem *item = dynamic_cast<DiveEventItem *>(sceneItem); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Add or edit Gas Change
 | 
					
						
							|  |  |  | 	if (current_dive && item && event_is_gaschange(item->getEvent())) { | 
					
						
							|  |  |  | 		int eventTime = item->getEvent()->time.seconds; | 
					
						
							|  |  |  | 		QMenu *gasChange = m.addMenu(tr("Edit Gas Change")); | 
					
						
							|  |  |  | 		for (int i = 0; i < current_dive->cylinders.nr; i++) { | 
					
						
							|  |  |  | 			const cylinder_t *cylinder = get_cylinder(current_dive, i); | 
					
						
							|  |  |  | 			QString label = printCylinderDescription(i, cylinder); | 
					
						
							|  |  |  | 			gasChange->addAction(label, [this, i, eventTime] { changeGas(i, eventTime); }); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else if (current_dive && current_dive->cylinders.nr > 1) { | 
					
						
							| 
									
										
										
										
											2014-11-19 21:03:58 +00:00
										 |  |  | 		// if we have more than one gas, offer to switch to another one
 | 
					
						
							|  |  |  | 		QMenu *gasChange = m.addMenu(tr("Add gas change")); | 
					
						
							| 
									
										
										
										
											2020-08-25 05:37:08 +09:00
										 |  |  | 		for (int i = 0; i < current_dive->cylinders.nr; i++) { | 
					
						
							|  |  |  | 			const cylinder_t *cylinder = get_cylinder(current_dive, i); | 
					
						
							|  |  |  | 			QString label = printCylinderDescription(i, cylinder); | 
					
						
							|  |  |  | 			gasChange->addAction(label, [this, i, seconds] { changeGas(i, seconds); }); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-02-17 19:15:40 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-03-02 22:02:33 +01:00
										 |  |  | 	m.addAction(tr("Add setpoint change"), [this, seconds]() { ProfileWidget2::addSetpointChange(seconds); }); | 
					
						
							|  |  |  | 	m.addAction(tr("Add bookmark"), [this, seconds]() { addBookmark(seconds); }); | 
					
						
							|  |  |  | 	m.addAction(tr("Split dive into two"), [this, seconds]() { splitDive(seconds); }); | 
					
						
							| 
									
										
										
										
											2018-08-17 00:58:30 +02:00
										 |  |  | 	const struct event *ev = NULL; | 
					
						
							| 
									
										
										
										
											2018-05-08 16:24:51 +02:00
										 |  |  | 	enum divemode_t divemode = UNDEF_COMP_TYPE; | 
					
						
							| 
									
										
										
										
											2018-04-08 22:09:26 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	get_current_divemode(current_dc, seconds, &ev, &divemode); | 
					
						
							|  |  |  | 	QMenu *changeMode = m.addMenu(tr("Change divemode")); | 
					
						
							| 
									
										
										
										
											2020-03-02 22:34:39 +01:00
										 |  |  | 	if (divemode != OC) | 
					
						
							|  |  |  | 		changeMode->addAction(gettextFromC::tr(divemode_text_ui[OC]), | 
					
						
							|  |  |  | 				      [this, seconds](){ addDivemodeSwitch(seconds, OC); }); | 
					
						
							|  |  |  | 	if (divemode != CCR) | 
					
						
							|  |  |  | 		changeMode->addAction(gettextFromC::tr(divemode_text_ui[CCR]), | 
					
						
							|  |  |  | 				      [this, seconds](){ addDivemodeSwitch(seconds, CCR); }); | 
					
						
							|  |  |  | 	if (divemode != PSCR) | 
					
						
							|  |  |  | 		changeMode->addAction(gettextFromC::tr(divemode_text_ui[PSCR]), | 
					
						
							|  |  |  | 				      [this, seconds](){ addDivemodeSwitch(seconds, PSCR); }); | 
					
						
							| 
									
										
										
										
											2015-04-23 13:56:24 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (same_string(current_dc->model, "manually added dive")) | 
					
						
							| 
									
										
										
										
											2020-04-12 12:48:38 +02:00
										 |  |  | 		m.addAction(tr("Edit the profile"), this, &ProfileWidget2::editCurrentDive); | 
					
						
							| 
									
										
										
										
											2015-04-23 13:56:24 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | 	if (DiveEventItem *item = dynamic_cast<DiveEventItem *>(sceneItem)) { | 
					
						
							| 
									
										
										
										
											2020-03-02 22:34:39 +01:00
										 |  |  | 		m.addAction(tr("Remove event"), [this,item] { removeEvent(item); }); | 
					
						
							|  |  |  | 		m.addAction(tr("Hide similar events"), [this, item] { hideEvents(item); }); | 
					
						
							| 
									
										
										
										
											2014-11-19 16:15:10 -08:00
										 |  |  | 		struct event *dcEvent = item->getEvent(); | 
					
						
							| 
									
										
										
										
											2020-03-02 22:34:39 +01:00
										 |  |  | 		if (dcEvent->type == SAMPLE_EVENT_BOOKMARK) | 
					
						
							|  |  |  | 			m.addAction(tr("Edit name"), [this, item] { editName(item); }); | 
					
						
							| 
									
										
										
										
											2019-07-06 12:09:15 +02:00
										 |  |  | #if 0 // TODO::: FINISH OR DISABLE
 | 
					
						
							| 
									
										
										
										
											2017-08-26 12:11:44 -07:00
										 |  |  | 		QPointF scenePos = mapToScene(event->pos()); | 
					
						
							| 
									
										
										
										
											2019-07-06 12:35:33 +02:00
										 |  |  | 		int idx = getEntryFromPos(scenePos); | 
					
						
							| 
									
										
										
										
											2014-11-19 16:15:10 -08:00
										 |  |  | 		// this shows how to figure out if we should ask the user if they want adjust interpolated pressures
 | 
					
						
							|  |  |  | 		// at either side of a gas change
 | 
					
						
							|  |  |  | 		if (dcEvent->type == SAMPLE_EVENT_GASCHANGE || dcEvent->type == SAMPLE_EVENT_GASCHANGE2) { | 
					
						
							|  |  |  | 			qDebug() << "figure out if there are interpolated pressures"; | 
					
						
							| 
									
										
										
										
											2019-07-06 12:35:33 +02:00
										 |  |  | 			int gasChangeIdx = idx; | 
					
						
							|  |  |  | 			while (gasChangeIdx > 0) { | 
					
						
							|  |  |  | 				--gasChangeIdx; | 
					
						
							|  |  |  | 				if (plotInfo.entry[gasChangeIdx].sec <= dcEvent->time.seconds) | 
					
						
							| 
									
										
										
										
											2014-11-19 16:15:10 -08:00
										 |  |  | 					break; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-07-06 12:35:33 +02:00
										 |  |  | 			const struct plot_data &gasChangeEntry = plotInfo.entry[newGasIdx]; | 
					
						
							|  |  |  | 			qDebug() << "at gas change at" << gasChangeEntry->sec << ": sensor pressure" << get_plot_sensor_pressure(&plotInfo, newGasIdx) | 
					
						
							|  |  |  | 				 << "interpolated" << ;get_plot_sensor_pressure(&plotInfo, newGasIdx); | 
					
						
							| 
									
										
										
										
											2014-11-19 16:15:10 -08:00
										 |  |  | 			// now gasChangeEntry points at the gas change, that entry has the final pressure of
 | 
					
						
							|  |  |  | 			// the old tank, the next entry has the starting pressure of the next tank
 | 
					
						
							| 
									
										
										
										
											2019-07-06 12:35:33 +02:00
										 |  |  | 			if (gasChangeIdx < plotInfo.nr - 1) { | 
					
						
							|  |  |  | 				int newGasIdx = gasChangeIdx + 1; | 
					
						
							|  |  |  | 				const struct plot_data &newGasEntry = plotInfo.entry[newGasIdx]; | 
					
						
							| 
									
										
										
										
											2014-11-19 16:15:10 -08:00
										 |  |  | 				qDebug() << "after gas change at " << newGasEntry->sec << ": sensor pressure" << newGasEntry->pressure[0] << "interpolated" << newGasEntry->pressure[1]; | 
					
						
							| 
									
										
										
										
											2019-08-04 22:13:49 +02:00
										 |  |  | 				if (get_plot_sensor_pressure(&plotInfo, gasChangeIdx) == 0 || get_cylinder(&displayed_dive, gasChangeEntry->sensor[0])->sample_start.mbar == 0) { | 
					
						
							| 
									
										
										
										
											2014-11-19 16:15:10 -08:00
										 |  |  | 					// if we have no sensorpressure or if we have no pressure from samples we can assume that
 | 
					
						
							|  |  |  | 					// we only have interpolated pressure (the pressure in the entry may be stored in the sensor
 | 
					
						
							|  |  |  | 					// pressure field if this is the first or last entry for this tank... see details in gaspressures.c
 | 
					
						
							|  |  |  | 					pressure_t pressure; | 
					
						
							| 
									
										
										
										
											2019-07-06 12:35:33 +02:00
										 |  |  | 					pressure.mbar = get_plot_interpolated_pressure(&plotInfo, gasChangeIdx) ? : get_plot_sensor_pressure(&plotInfo, gasChangeIdx); | 
					
						
							| 
									
										
										
										
											2017-11-18 09:35:06 +01:00
										 |  |  | 					QAction *adjustOldPressure = m.addAction(tr("Adjust pressure of cyl. %1 (currently interpolated as %2)") | 
					
						
							| 
									
										
											  
											
												Start cleaning up sensor indexing for multiple sensors
This is a very timid start at making us actually use multiple sensors
without the magical special case for just CCR oxygen tracking.
It mainly does:
 - turn the "sample->sensor" index into an array of two indexes, to
   match the pressures themselves.
 - get rid of dive->{oxygen_cylinder_index,diluent_cylinder_index},
   since a CCR dive should now simply set the sample->sensor[] indices
   correctly instead.
 - in a couple of places, start actually looping over the sensors rather
   than special-case the O2 case (although often the small "loops" are
   just unrolled, since it's just two cases.
but in many cases we still end up only covering the zero sensor case,
because the CCR O2 sensor code coverage was fairly limited.
It's entirely possible (even likely) that this migth break some existing
case: it tries to be a fairly direct ("stupid") translation of the old
code, but unlike the preparatory patch this does actually does change
some semantics.
For example, right now the git loader code assumes that if the git save
data contains a o2pressure entry, it just hardcodes the O2 sensor index
to 1.
In fact, one issue is going to simply be that our file formats do not
have that multiple sensor format, but instead had very clearly encoded
things as being the CCR O2 pressure sensor.
But this is hopefully close to usable, and I will need feedback (and
maybe test cases) from people who have existing CCR dives with pressure
data.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
											
										 
											2017-07-20 19:49:45 -07:00
										 |  |  | 										 .arg(gasChangeEntry->sensor[0] + 1).arg(get_pressure_string(pressure))); | 
					
						
							| 
									
										
										
										
											2014-11-19 16:15:10 -08:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2019-08-04 22:13:49 +02:00
										 |  |  | 				if (get_plot_sensor_pressure(&plotInfo, newGasIdx) == 0 || get_cylinder(&displayed_dive, newGasEntry->sensor[0])->sample_start.mbar == 0) { | 
					
						
							| 
									
										
										
										
											2014-11-19 16:15:10 -08:00
										 |  |  | 					// we only have interpolated press -- see commend above
 | 
					
						
							|  |  |  | 					pressure_t pressure; | 
					
						
							| 
									
										
										
										
											2019-07-06 12:35:33 +02:00
										 |  |  | 					pressure.mbar = get_plot_interpolated_pressure(&plotInfo, newGasIdx) ? : get_plot_sensor_pressure(&plotInfo, newGasIdx); | 
					
						
							| 
									
										
										
										
											2017-11-18 09:35:06 +01:00
										 |  |  | 					QAction *adjustOldPressure = m.addAction(tr("Adjust pressure of cyl. %1 (currently interpolated as %2)") | 
					
						
							| 
									
										
											  
											
												Start cleaning up sensor indexing for multiple sensors
This is a very timid start at making us actually use multiple sensors
without the magical special case for just CCR oxygen tracking.
It mainly does:
 - turn the "sample->sensor" index into an array of two indexes, to
   match the pressures themselves.
 - get rid of dive->{oxygen_cylinder_index,diluent_cylinder_index},
   since a CCR dive should now simply set the sample->sensor[] indices
   correctly instead.
 - in a couple of places, start actually looping over the sensors rather
   than special-case the O2 case (although often the small "loops" are
   just unrolled, since it's just two cases.
but in many cases we still end up only covering the zero sensor case,
because the CCR O2 sensor code coverage was fairly limited.
It's entirely possible (even likely) that this migth break some existing
case: it tries to be a fairly direct ("stupid") translation of the old
code, but unlike the preparatory patch this does actually does change
some semantics.
For example, right now the git loader code assumes that if the git save
data contains a o2pressure entry, it just hardcodes the O2 sensor index
to 1.
In fact, one issue is going to simply be that our file formats do not
have that multiple sensor format, but instead had very clearly encoded
things as being the CCR O2 pressure sensor.
But this is hopefully close to usable, and I will need feedback (and
maybe test cases) from people who have existing CCR dives with pressure
data.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
											
										 
											2017-07-20 19:49:45 -07:00
										 |  |  | 										 .arg(newGasEntry->sensor[0] + 1).arg(get_pressure_string(pressure))); | 
					
						
							| 
									
										
										
										
											2014-11-19 16:15:10 -08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-02-17 19:15:40 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	bool some_hidden = false; | 
					
						
							|  |  |  | 	for (int i = 0; i < evn_used; i++) { | 
					
						
							|  |  |  | 		if (ev_namelist[i].plot_ev == false) { | 
					
						
							|  |  |  | 			some_hidden = true; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-03-02 21:58:09 +01:00
										 |  |  | 	if (some_hidden) | 
					
						
							|  |  |  | 		m.addAction(tr("Unhide all events"), this, &ProfileWidget2::unhideEvents); | 
					
						
							| 
									
										
										
										
											2014-02-17 19:15:40 -03:00
										 |  |  | 	m.exec(event->globalPos()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-11 13:56:33 -07:00
										 |  |  | void ProfileWidget2::deleteCurrentDC() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-19 14:27:10 +02:00
										 |  |  | 	Command::deleteDiveComputer(current_dive, dc_number); | 
					
						
							| 
									
										
										
										
											2014-06-11 13:56:33 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-31 10:20:13 +02:00
										 |  |  | void ProfileWidget2::splitCurrentDC() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Command::splitDiveComputer(current_dive, dc_number); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-19 14:39:34 +09:00
										 |  |  | void ProfileWidget2::makeFirstDC() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-17 22:22:55 +02:00
										 |  |  | 	Command::moveDiveComputerToFront(current_dive, dc_number); | 
					
						
							| 
									
										
										
										
											2014-05-19 14:39:34 +09:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-02 22:23:40 +01:00
										 |  |  | void ProfileWidget2::hideEvents(DiveEventItem *item) | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct event *event = item->getEvent(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-05 12:58:24 -08:00
										 |  |  | 	if (QMessageBox::question(this, | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | 				  TITLE_OR_TEXT(tr("Hide events"), tr("Hide all %1 events?").arg(event->name)), | 
					
						
							|  |  |  | 				  QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { | 
					
						
							| 
									
										
										
										
											2018-01-07 11:12:48 +01:00
										 |  |  | 		if (!empty_string(event->name)) { | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | 			for (int i = 0; i < evn_used; i++) { | 
					
						
							| 
									
										
										
										
											2014-05-14 21:45:39 -03:00
										 |  |  | 				if (same_string(event->name, ev_namelist[i].ev_name)) { | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | 					ev_namelist[i].plot_ev = false; | 
					
						
							|  |  |  | 					break; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-05-14 21:45:39 -03:00
										 |  |  | 			Q_FOREACH (DiveEventItem *evItem, eventItems) { | 
					
						
							| 
									
										
										
										
											2014-05-22 11:40:22 -07:00
										 |  |  | 				if (same_string(evItem->getEvent()->name, event->name)) | 
					
						
							| 
									
										
										
										
											2014-05-14 21:45:39 -03:00
										 |  |  | 					evItem->hide(); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			item->hide(); | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::unhideEvents() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	for (int i = 0; i < evn_used; i++) { | 
					
						
							|  |  |  | 		ev_namelist[i].plot_ev = true; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-05-14 21:51:45 -03:00
										 |  |  | 	Q_FOREACH (DiveEventItem *item, eventItems) | 
					
						
							|  |  |  | 		item->show(); | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-04 18:13:02 +01:00
										 |  |  | // The profile displays a copy of the current_dive, namely displayed_dive.
 | 
					
						
							|  |  |  | // Therefore, the events we get are likewise copies. This function finds
 | 
					
						
							|  |  |  | // the original event. TODO: Remove function once the profile can display
 | 
					
						
							|  |  |  | // arbitrary dives.
 | 
					
						
							|  |  |  | static event *find_event(const struct event *ev) | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-03-04 18:13:02 +01:00
										 |  |  | 	struct divecomputer *dc = current_dc; | 
					
						
							|  |  |  | 	if (!dc) | 
					
						
							|  |  |  | 		return nullptr; | 
					
						
							|  |  |  | 	for (struct event *act = current_dc->events; act; act = act->next) { | 
					
						
							|  |  |  | 		if (same_event(act, ev)) | 
					
						
							|  |  |  | 			return act; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return nullptr; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-02 22:23:40 +01:00
										 |  |  | void ProfileWidget2::removeEvent(DiveEventItem *item) | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-03-04 18:25:47 +01:00
										 |  |  | 	struct event *event = find_event(item->getEvent()); | 
					
						
							|  |  |  | 	if (!event) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-05 12:58:24 -08:00
										 |  |  | 	if (QMessageBox::question(this, TITLE_OR_TEXT( | 
					
						
							|  |  |  | 					  tr("Remove the selected event?"), | 
					
						
							|  |  |  | 					  tr("%1 @ %2:%3").arg(event->name).arg(event->time.seconds / 60).arg(event->time.seconds % 60, 2, 10, QChar('0'))), | 
					
						
							| 
									
										
										
										
											2020-03-04 18:25:47 +01:00
										 |  |  | 				  QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) | 
					
						
							|  |  |  | 		Command::removeEvent(current_dive, dc_number, event); | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-02 22:02:33 +01:00
										 |  |  | void ProfileWidget2::addBookmark(int seconds) | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-03-03 22:34:50 +01:00
										 |  |  | 	Command::addEventBookmark(current_dive, dc_number, seconds); | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-02 21:48:53 +01:00
										 |  |  | void ProfileWidget2::addDivemodeSwitch(int seconds, int divemode) | 
					
						
							| 
									
										
										
										
											2018-04-07 20:39:41 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-03-03 22:54:54 +01:00
										 |  |  | 	Command::addEventDivemodeSwitch(current_dive, dc_number, seconds, divemode); | 
					
						
							| 
									
										
										
										
											2018-04-07 20:39:41 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-02 22:02:33 +01:00
										 |  |  | void ProfileWidget2::addSetpointChange(int seconds) | 
					
						
							| 
									
										
										
										
											2014-11-26 14:22:41 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-03-03 23:17:08 +01:00
										 |  |  | 	SetpointDialog dialog(current_dive, dc_number, seconds); | 
					
						
							| 
									
										
										
										
											2020-03-03 23:09:25 +01:00
										 |  |  | 	dialog.exec(); | 
					
						
							| 
									
										
										
										
											2014-11-26 14:22:41 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-02 22:02:33 +01:00
										 |  |  | void ProfileWidget2::splitDive(int seconds) | 
					
						
							| 
									
										
										
										
											2018-07-02 21:13:44 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-20 20:26:06 +02:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							|  |  |  | 	// Make sure that this is an actual dive and we're not in add mode
 | 
					
						
							|  |  |  | 	dive *d = get_dive_by_uniq_id(displayed_dive.id); | 
					
						
							|  |  |  | 	if (!d) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2020-03-02 22:02:33 +01:00
										 |  |  | 	Command::splitDives(d, duration_t{ seconds }); | 
					
						
							| 
									
										
										
										
											2018-07-20 20:26:06 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-07-02 21:13:44 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-30 15:03:48 +01:00
										 |  |  | void ProfileWidget2::changeGas(int tank, int seconds) | 
					
						
							| 
									
										
										
										
											2014-02-17 19:15:40 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-01-30 15:03:48 +01:00
										 |  |  | 	if (!current_dive || tank < 0 || tank >= current_dive->cylinders.nr) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2015-03-11 11:23:50 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-04 21:10:05 +01:00
										 |  |  | 	Command::addGasSwitch(current_dive, dc_number, seconds, tank); | 
					
						
							| 
									
										
										
										
											2014-02-19 17:18:26 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-11-05 16:05:44 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-03-25 23:34:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-09 13:09:52 -07:00
										 |  |  | bool ProfileWidget2::getPrintMode() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return printMode; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-25 23:34:09 +02:00
										 |  |  | void ProfileWidget2::setPrintMode(bool mode, bool grayscale) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	printMode = mode; | 
					
						
							| 
									
										
										
										
											2015-10-11 14:21:13 +03:00
										 |  |  | 	resetZoom(); | 
					
						
							| 
									
										
										
										
											2015-10-11 14:21:14 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// set printMode for axes
 | 
					
						
							|  |  |  | 	profileYAxis->setPrintMode(mode); | 
					
						
							|  |  |  | 	gasYAxis->setPrintMode(mode); | 
					
						
							|  |  |  | 	temperatureAxis->setPrintMode(mode); | 
					
						
							|  |  |  | 	timeAxis->setPrintMode(mode); | 
					
						
							|  |  |  | 	cylinderPressureAxis->setPrintMode(mode); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | 	isGrayscale = mode ? grayscale : false; | 
					
						
							|  |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2015-10-11 14:21:14 +03:00
										 |  |  | 	heartBeatAxis->setPrintMode(mode); | 
					
						
							|  |  |  | 	percentageAxis->setPrintMode(mode); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-01 16:28:37 -08:00
										 |  |  | 	mouseFollowerHorizontal->setVisible(!mode); | 
					
						
							|  |  |  | 	mouseFollowerVertical->setVisible(!mode); | 
					
						
							| 
									
										
										
										
											2015-11-15 23:02:02 +02:00
										 |  |  | 	toolTipItem->setVisible(!mode); | 
					
						
							| 
									
										
										
										
											2016-02-06 13:25:58 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-03-25 23:34:09 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-04-03 21:16:15 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-09 13:09:52 -07:00
										 |  |  | void ProfileWidget2::setFontPrintScale(double scale) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	fontPrintScale = scale; | 
					
						
							| 
									
										
										
										
											2015-07-29 12:21:27 -07:00
										 |  |  | 	emit fontPrintScaleChanged(scale); | 
					
						
							| 
									
										
										
										
											2014-07-09 13:09:52 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | double ProfileWidget2::getFontPrintScale() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (printMode) | 
					
						
							|  |  |  | 		return fontPrintScale; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		return 1.0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-05 16:05:44 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2020-03-02 22:23:40 +01:00
										 |  |  | void ProfileWidget2::editName(DiveEventItem *item) | 
					
						
							| 
									
										
										
										
											2014-04-03 21:16:15 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-03-04 18:13:02 +01:00
										 |  |  | 	struct event *event = find_event(item->getEvent()); | 
					
						
							|  |  |  | 	if (!event) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2014-04-03 21:16:15 +02:00
										 |  |  | 	bool ok; | 
					
						
							| 
									
										
										
										
											2015-11-05 12:58:24 -08:00
										 |  |  | 	QString newName = QInputDialog::getText(this, tr("Edit name of bookmark"), | 
					
						
							| 
									
										
										
										
											2014-04-03 21:16:15 +02:00
										 |  |  | 						tr("Custom name:"), QLineEdit::Normal, | 
					
						
							|  |  |  | 						event->name, &ok); | 
					
						
							| 
									
										
										
										
											2014-04-03 12:52:05 -07:00
										 |  |  | 	if (ok && !newName.isEmpty()) { | 
					
						
							|  |  |  | 		if (newName.length() > 22) { //longer names will display as garbage.
 | 
					
						
							| 
									
										
										
										
											2014-04-03 21:16:15 +02:00
										 |  |  | 			QMessageBox lengthWarning; | 
					
						
							| 
									
										
										
										
											2014-07-28 18:12:51 +04:00
										 |  |  | 			lengthWarning.setText(tr("Name is too long!")); | 
					
						
							| 
									
										
										
										
											2014-04-03 21:16:15 +02:00
										 |  |  | 			lengthWarning.exec(); | 
					
						
							|  |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-03-04 18:13:02 +01:00
										 |  |  | 		Command::renameEvent(current_dive, dc_number, event, qPrintable(newName)); | 
					
						
							| 
									
										
										
										
											2014-04-03 21:16:15 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-11-05 16:05:44 -08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-05-21 21:18:10 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-21 21:23:19 -03:00
										 |  |  | void ProfileWidget2::disconnectTemporaryConnections() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-01-09 19:32:41 +01:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2014-05-21 21:23:19 -03:00
										 |  |  | 	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | 
					
						
							| 
									
										
										
										
											2020-04-12 12:48:38 +02:00
										 |  |  | 	disconnect(plannerModel, &DivePlannerPointsModel::dataChanged, this, &ProfileWidget2::replot); | 
					
						
							|  |  |  | 	disconnect(plannerModel, &DivePlannerPointsModel::cylinderModelEdited, this, &ProfileWidget2::replot); | 
					
						
							| 
									
										
										
										
											2014-05-21 21:23:19 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-12 12:48:38 +02:00
										 |  |  | 	disconnect(plannerModel, &DivePlannerPointsModel::rowsInserted, this, &ProfileWidget2::pointInserted); | 
					
						
							|  |  |  | 	disconnect(plannerModel, &DivePlannerPointsModel::rowsRemoved, this, &ProfileWidget2::pointsRemoved); | 
					
						
							| 
									
										
										
										
											2015-11-12 01:37:18 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2014-06-03 15:28:06 -07:00
										 |  |  | 	Q_FOREACH (QAction *action, actionsForKeys.values()) { | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 		action->setShortcut(QKeySequence()); | 
					
						
							| 
									
										
										
										
											2014-06-03 15:28:06 -07:00
										 |  |  | 		action->setShortcutContext(Qt::WidgetShortcut); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-05-21 21:23:19 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-05 16:05:44 -08:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2018-05-21 18:20:29 +02:00
										 |  |  | void ProfileWidget2::pointInserted(const QModelIndex&, int, int) | 
					
						
							| 
									
										
										
										
											2014-05-21 21:18:10 -03:00
										 |  |  | { | 
					
						
							|  |  |  | 	DiveHandler *item = new DiveHandler(); | 
					
						
							|  |  |  | 	scene()->addItem(item); | 
					
						
							|  |  |  | 	handles << item; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-12 12:48:38 +02:00
										 |  |  | 	connect(item, &DiveHandler::moved, this, &ProfileWidget2::recreatePlannedDive); | 
					
						
							|  |  |  | 	connect(item, &DiveHandler::clicked, this, &ProfileWidget2::divePlannerHandlerClicked); | 
					
						
							|  |  |  | 	connect(item, &DiveHandler::released, this, &ProfileWidget2::divePlannerHandlerReleased); | 
					
						
							| 
									
										
										
										
											2014-05-21 21:18:10 -03:00
										 |  |  | 	QGraphicsSimpleTextItem *gasChooseBtn = new QGraphicsSimpleTextItem(); | 
					
						
							|  |  |  | 	scene()->addItem(gasChooseBtn); | 
					
						
							|  |  |  | 	gasChooseBtn->setZValue(10); | 
					
						
							|  |  |  | 	gasChooseBtn->setFlag(QGraphicsItem::ItemIgnoresTransformations); | 
					
						
							|  |  |  | 	gases << gasChooseBtn; | 
					
						
							|  |  |  | 	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | 
					
						
							|  |  |  | 	if (plannerModel->recalcQ()) | 
					
						
							|  |  |  | 		replot(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::pointsRemoved(const QModelIndex &, int start, int end) | 
					
						
							|  |  |  | { // start and end are inclusive.
 | 
					
						
							|  |  |  | 	int num = (end - start) + 1; | 
					
						
							|  |  |  | 	for (int i = num; i != 0; i--) { | 
					
						
							|  |  |  | 		delete handles.back(); | 
					
						
							|  |  |  | 		handles.pop_back(); | 
					
						
							|  |  |  | 		delete gases.back(); | 
					
						
							|  |  |  | 		gases.pop_back(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	scene()->clearSelection(); | 
					
						
							|  |  |  | 	replot(); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-05-21 23:31:26 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::repositionDiveHandlers() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | 
					
						
							| 
									
										
										
										
											2018-01-10 16:36:45 +01:00
										 |  |  | 	hideAll(gases); | 
					
						
							| 
									
										
										
										
											2014-05-21 23:31:26 -03:00
										 |  |  | 	// Re-position the user generated dive handlers
 | 
					
						
							|  |  |  | 	for (int i = 0; i < plannerModel->rowCount(); i++) { | 
					
						
							|  |  |  | 		struct divedatapoint datapoint = plannerModel->at(i); | 
					
						
							|  |  |  | 		if (datapoint.time == 0) // those are the magic entries for tanks
 | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 		DiveHandler *h = handles.at(i); | 
					
						
							| 
									
										
										
										
											2014-05-29 23:47:03 -03:00
										 |  |  | 		h->setVisible(datapoint.entered); | 
					
						
							| 
									
										
										
										
											2017-03-10 13:37:54 +01:00
										 |  |  | 		h->setPos(timeAxis->posAtValue(datapoint.time), profileYAxis->posAtValue(datapoint.depth.mm)); | 
					
						
							| 
									
										
										
										
											2014-10-21 14:27:50 -07:00
										 |  |  | 		QPointF p1; | 
					
						
							|  |  |  | 		if (i == 0) { | 
					
						
							|  |  |  | 			if (prefs.drop_stone_mode) | 
					
						
							|  |  |  | 				// place the text on the straight line from the drop to stone position
 | 
					
						
							| 
									
										
										
										
											2017-03-10 13:37:54 +01:00
										 |  |  | 				p1 = QPointF(timeAxis->posAtValue(datapoint.depth.mm / prefs.descrate), | 
					
						
							|  |  |  | 					     profileYAxis->posAtValue(datapoint.depth.mm)); | 
					
						
							| 
									
										
										
										
											2014-10-21 14:27:50 -07:00
										 |  |  | 			else | 
					
						
							|  |  |  | 				// place the text on the straight line from the origin to the first position
 | 
					
						
							|  |  |  | 				p1 = QPointF(timeAxis->posAtValue(0), profileYAxis->posAtValue(0)); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			// place the text on the line from the last position
 | 
					
						
							|  |  |  | 			p1 = handles[i - 1]->pos(); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-05-21 23:31:26 -03:00
										 |  |  | 		QPointF p2 = handles[i]->pos(); | 
					
						
							|  |  |  | 		QLineF line(p1, p2); | 
					
						
							|  |  |  | 		QPointF pos = line.pointAt(0.5); | 
					
						
							|  |  |  | 		gases[i]->setPos(pos); | 
					
						
							| 
									
										
										
										
											2019-08-04 22:13:49 +02:00
										 |  |  | 		gases[i]->setText(get_gas_string(get_cylinder(&displayed_dive, datapoint.cylinderid)->gasmix)); | 
					
						
							| 
									
										
										
										
											2015-05-07 23:40:34 +02:00
										 |  |  | 		gases[i]->setVisible(datapoint.entered && | 
					
						
							|  |  |  | 				(i == 0 || gases[i]->text() != gases[i-1]->text())); | 
					
						
							| 
									
										
										
										
											2014-05-21 23:31:26 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-05-23 20:51:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-23 22:22:02 -03:00
										 |  |  | int ProfileWidget2::fixHandlerIndex(DiveHandler *activeHandler) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int index = handles.indexOf(activeHandler); | 
					
						
							|  |  |  | 	if (index > 0 && index < handles.count() - 1) { | 
					
						
							|  |  |  | 		DiveHandler *before = handles[index - 1]; | 
					
						
							|  |  |  | 		if (before->pos().x() > activeHandler->pos().x()) { | 
					
						
							| 
									
										
										
										
											2020-10-26 10:04:53 -07:00
										 |  |  | 			std::swap(handles[index], handles[index - 1]); | 
					
						
							| 
									
										
										
										
											2014-05-23 22:22:02 -03:00
										 |  |  | 			return index - 1; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		DiveHandler *after = handles[index + 1]; | 
					
						
							|  |  |  | 		if (after->pos().x() < activeHandler->pos().x()) { | 
					
						
							| 
									
										
										
										
											2020-10-26 10:04:53 -07:00
										 |  |  | 			std::swap(handles[index], handles[index + 1]); | 
					
						
							| 
									
										
										
										
											2014-05-23 22:22:02 -03:00
										 |  |  | 			return index + 1; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return index; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-23 20:51:30 -03:00
										 |  |  | void ProfileWidget2::recreatePlannedDive() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 	DiveHandler *activeHandler = qobject_cast<DiveHandler *>(sender()); | 
					
						
							| 
									
										
										
										
											2014-05-23 20:51:30 -03:00
										 |  |  | 	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | 
					
						
							| 
									
										
										
										
											2014-05-23 22:22:02 -03:00
										 |  |  | 	int index = fixHandlerIndex(activeHandler); | 
					
						
							| 
									
										
										
										
											2017-05-17 22:22:50 +02:00
										 |  |  | 	int mintime = 0; | 
					
						
							|  |  |  | 	int maxtime = plannerModel->at(plannerModel->size() - 1).time * 3 / 2; | 
					
						
							| 
									
										
										
										
											2014-05-23 20:51:30 -03:00
										 |  |  | 	if (index > 0) | 
					
						
							|  |  |  | 		mintime = plannerModel->at(index - 1).time; | 
					
						
							|  |  |  | 	if (index < plannerModel->size() - 1) | 
					
						
							|  |  |  | 		maxtime = plannerModel->at(index + 1).time; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-08 13:41:41 +07:00
										 |  |  | 	int minutes = lrint(timeAxis->valueAt(activeHandler->pos()) / 60); | 
					
						
							| 
									
										
										
										
											2014-05-23 20:51:30 -03:00
										 |  |  | 	if (minutes * 60 <= mintime || minutes * 60 >= maxtime) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2017-12-01 12:46:51 +01:00
										 |  |  | 	if (minutes * 60 > timeAxis->maximum() * 0.9) | 
					
						
							|  |  |  | 		timeAxis->setMaximum(timeAxis->maximum() * 1.02); | 
					
						
							| 
									
										
										
										
											2014-05-23 20:51:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	divedatapoint data = plannerModel->at(index); | 
					
						
							| 
									
										
										
										
											2017-12-01 12:49:38 +01:00
										 |  |  | 	depth_t oldDepth = data.depth; | 
					
						
							|  |  |  | 	int oldtime = data.time; | 
					
						
							| 
									
										
										
										
											2017-03-11 08:41:41 -08:00
										 |  |  | 	data.depth.mm = lrint(profileYAxis->valueAt(activeHandler->pos()) / M_OR_FT(1, 1)) * M_OR_FT(1, 1); | 
					
						
							| 
									
										
										
										
											2017-03-08 13:41:41 +07:00
										 |  |  | 	data.time = lrint(timeAxis->valueAt(activeHandler->pos())); | 
					
						
							| 
									
										
										
										
											2014-05-23 20:51:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-01 12:49:38 +01:00
										 |  |  | 	if (data.depth.mm != oldDepth.mm || data.time != oldtime) | 
					
						
							|  |  |  | 		plannerModel->editStop(index, data); | 
					
						
							| 
									
										
										
										
											2014-05-23 20:51:30 -03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::keyDownAction() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (currentState != ADD && currentState != PLAN) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | 
					
						
							| 
									
										
										
										
											2017-12-01 12:49:38 +01:00
										 |  |  | 	bool oldRecalc = plannerModel->setRecalc(false); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 	Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) { | 
					
						
							|  |  |  | 		if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) { | 
					
						
							|  |  |  | 			int row = handles.indexOf(handler); | 
					
						
							|  |  |  | 			divedatapoint dp = plannerModel->at(row); | 
					
						
							| 
									
										
										
										
											2017-03-10 13:37:54 +01:00
										 |  |  | 			if (dp.depth.mm >= profileYAxis->maximum()) | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 				continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-10 13:37:54 +01:00
										 |  |  | 			dp.depth.mm += M_OR_FT(1, 5); | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 			plannerModel->editStop(row, dp); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-01 12:49:38 +01:00
										 |  |  | 	plannerModel->setRecalc(oldRecalc); | 
					
						
							|  |  |  | 	replot(); | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::keyUpAction() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (currentState != ADD && currentState != PLAN) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | 
					
						
							| 
									
										
										
										
											2017-12-01 12:49:38 +01:00
										 |  |  | 	bool oldRecalc = plannerModel->setRecalc(false); | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 	Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) { | 
					
						
							|  |  |  | 		if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) { | 
					
						
							|  |  |  | 			int row = handles.indexOf(handler); | 
					
						
							|  |  |  | 			divedatapoint dp = plannerModel->at(row); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-10 13:37:54 +01:00
										 |  |  | 			if (dp.depth.mm <= 0) | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 				continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-10 13:37:54 +01:00
										 |  |  | 			dp.depth.mm -= M_OR_FT(1, 5); | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 			plannerModel->editStop(row, dp); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-01 12:49:38 +01:00
										 |  |  | 	plannerModel->setRecalc(oldRecalc); | 
					
						
							|  |  |  | 	replot(); | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::keyLeftAction() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (currentState != ADD && currentState != PLAN) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | 
					
						
							| 
									
										
										
										
											2017-12-01 12:49:38 +01:00
										 |  |  | 	bool oldRecalc = plannerModel->setRecalc(false); | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 	Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) { | 
					
						
							|  |  |  | 		if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) { | 
					
						
							|  |  |  | 			int row = handles.indexOf(handler); | 
					
						
							|  |  |  | 			divedatapoint dp = plannerModel->at(row); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (dp.time / 60 <= 0) | 
					
						
							|  |  |  | 				continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// don't overlap positions.
 | 
					
						
							|  |  |  | 			// maybe this is a good place for a 'goto'?
 | 
					
						
							|  |  |  | 			double xpos = timeAxis->posAtValue((dp.time - 60) / 60); | 
					
						
							|  |  |  | 			bool nextStep = false; | 
					
						
							|  |  |  | 			Q_FOREACH (DiveHandler *h, handles) { | 
					
						
							|  |  |  | 				if (IS_FP_SAME(h->pos().x(), xpos)) { | 
					
						
							|  |  |  | 					nextStep = true; | 
					
						
							|  |  |  | 					break; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			if (nextStep) | 
					
						
							|  |  |  | 				continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			dp.time -= 60; | 
					
						
							|  |  |  | 			plannerModel->editStop(row, dp); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-01 12:49:38 +01:00
										 |  |  | 	plannerModel->setRecalc(oldRecalc); | 
					
						
							|  |  |  | 	replot(); | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::keyRightAction() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (currentState != ADD && currentState != PLAN) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | 
					
						
							| 
									
										
										
										
											2017-12-01 12:49:38 +01:00
										 |  |  | 	bool oldRecalc = plannerModel->setRecalc(false); | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 	Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) { | 
					
						
							|  |  |  | 		if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) { | 
					
						
							|  |  |  | 			int row = handles.indexOf(handler); | 
					
						
							|  |  |  | 			divedatapoint dp = plannerModel->at(row); | 
					
						
							| 
									
										
										
										
											2015-06-21 22:09:33 -07:00
										 |  |  | 			if (dp.time / 60.0 >= timeAxis->maximum()) | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 				continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// don't overlap positions.
 | 
					
						
							|  |  |  | 			// maybe this is a good place for a 'goto'?
 | 
					
						
							|  |  |  | 			double xpos = timeAxis->posAtValue((dp.time + 60) / 60); | 
					
						
							|  |  |  | 			bool nextStep = false; | 
					
						
							|  |  |  | 			Q_FOREACH (DiveHandler *h, handles) { | 
					
						
							|  |  |  | 				if (IS_FP_SAME(h->pos().x(), xpos)) { | 
					
						
							|  |  |  | 					nextStep = true; | 
					
						
							|  |  |  | 					break; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			if (nextStep) | 
					
						
							|  |  |  | 				continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			dp.time += 60; | 
					
						
							|  |  |  | 			plannerModel->editStop(row, dp); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-01 12:49:38 +01:00
										 |  |  | 	plannerModel->setRecalc(oldRecalc); | 
					
						
							|  |  |  | 	replot(); | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::keyDeleteAction() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (currentState != ADD && currentState != PLAN) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | 
					
						
							|  |  |  | 	int selCount = scene()->selectedItems().count(); | 
					
						
							|  |  |  | 	if (selCount) { | 
					
						
							| 
									
										
										
										
											2020-03-11 11:30:51 +01:00
										 |  |  | 		QVector<int> selectedIndices; | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 		Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) { | 
					
						
							|  |  |  | 			if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) { | 
					
						
							| 
									
										
										
										
											2020-03-11 11:30:51 +01:00
										 |  |  | 				selectedIndices.push_back(handles.indexOf(handler)); | 
					
						
							| 
									
										
										
										
											2014-07-30 09:31:22 -07:00
										 |  |  | 				handler->hide(); | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-03-11 11:30:51 +01:00
										 |  |  | 		plannerModel->removeSelectedPoints(selectedIndices); | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::keyEscAction() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (currentState != ADD && currentState != PLAN) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (scene()->selectedItems().count()) { | 
					
						
							|  |  |  | 		scene()->clearSelection(); | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | 
					
						
							|  |  |  | 	if (plannerModel->isPlanner()) | 
					
						
							|  |  |  | 		plannerModel->cancelPlan(); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-06-03 19:24:01 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-06 17:58:16 +02:00
										 |  |  | void ProfileWidget2::clearPictures() | 
					
						
							| 
									
										
										
										
											2014-06-03 19:24:01 -03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-21 18:54:28 -03:00
										 |  |  | 	pictures.clear(); | 
					
						
							| 
									
										
										
										
											2018-04-06 17:58:16 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-07-21 18:54:28 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 |  |  | static const double unscaledDurationLineWidth = 2.5; | 
					
						
							|  |  |  | static const double unscaledDurationLinePenWidth = 0.5; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Reset the duration line after an image was moved or we found a new duration
 | 
					
						
							|  |  |  | void ProfileWidget2::updateDurationLine(PictureEntry &e) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (e.duration.seconds > 0) { | 
					
						
							|  |  |  | 		// We know the duration of this video, reset the line symbolizing its extent accordingly
 | 
					
						
							|  |  |  | 		double begin = timeAxis->posAtValue(e.offset.seconds); | 
					
						
							|  |  |  | 		double end = timeAxis->posAtValue(e.offset.seconds + e.duration.seconds); | 
					
						
							|  |  |  | 		double y = e.thumbnail->y(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Undo scaling for pen-width and line-width. For this purpose, we use the scaling of the y-axis.
 | 
					
						
							|  |  |  | 		double scale = transform().m22(); | 
					
						
							|  |  |  | 		double durationLineWidth = unscaledDurationLineWidth / scale; | 
					
						
							|  |  |  | 		double durationLinePenWidth = unscaledDurationLinePenWidth / scale; | 
					
						
							|  |  |  | 		e.durationLine.reset(new QGraphicsRectItem(begin, y - durationLineWidth - durationLinePenWidth, end - begin, durationLineWidth)); | 
					
						
							|  |  |  | 		e.durationLine->setPen(QPen(getColor(GF_LINE, isGrayscale), durationLinePenWidth)); | 
					
						
							|  |  |  | 		e.durationLine->setBrush(getColor(::BACKGROUND, isGrayscale)); | 
					
						
							|  |  |  | 		e.durationLine->setVisible(prefs.show_pictures_in_profile); | 
					
						
							|  |  |  | 		scene()->addItem(e.durationLine.get()); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		// This is either a picture or a video with unknown duration.
 | 
					
						
							|  |  |  | 		// In case there was a line (how could that be?) remove it.
 | 
					
						
							|  |  |  | 		e.durationLine.reset(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 |  |  | // This function is called asynchronously by the thumbnailer if a thumbnail
 | 
					
						
							|  |  |  | // was fetched from disk or freshly calculated.
 | 
					
						
							| 
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 |  |  | void ProfileWidget2::updateThumbnail(QString filename, QImage thumbnail, duration_t duration) | 
					
						
							| 
									
										
										
										
											2018-04-06 17:58:16 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 |  |  | 	// Find the picture with the given filename
 | 
					
						
							|  |  |  | 	auto it = std::find_if(pictures.begin(), pictures.end(), [&filename](const PictureEntry &e) | 
					
						
							|  |  |  | 			       { return e.filename == filename; }); | 
					
						
							| 
									
										
										
										
											2014-07-02 13:58:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 |  |  | 	// If we didn't find a picture, it does either not belong to the current dive,
 | 
					
						
							|  |  |  | 	// or its timestamp is outside of the profile.
 | 
					
						
							|  |  |  | 	if (it != pictures.end()) { | 
					
						
							|  |  |  | 		// Replace the pixmap of the thumbnail with the newly calculated one.
 | 
					
						
							|  |  |  | 		int size = Thumbnailer::defaultThumbnailSize(); | 
					
						
							|  |  |  | 		it->thumbnail->setPixmap(QPixmap::fromImage(thumbnail.scaled(size, size, Qt::KeepAspectRatio))); | 
					
						
							| 
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// If the duration changed, update the line
 | 
					
						
							|  |  |  | 		if (duration.seconds != it->duration.seconds) { | 
					
						
							|  |  |  | 			it->duration = duration; | 
					
						
							|  |  |  | 			updateDurationLine(*it); | 
					
						
							|  |  |  | 			// If we created / removed a duration line, we have to update the thumbnail paint order.
 | 
					
						
							|  |  |  | 			updateThumbnailPaintOrder(); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-04-06 17:58:16 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 21:32:14 +02:00
										 |  |  | // Create a PictureEntry object and add its thumbnail to the scene if profile pictures are shown.
 | 
					
						
							| 
									
										
										
										
											2019-02-02 21:23:52 +01:00
										 |  |  | ProfileWidget2::PictureEntry::PictureEntry(offset_t offsetIn, const QString &filenameIn, QGraphicsScene *scene, bool synchronous) : offset(offsetIn), | 
					
						
							| 
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 |  |  | 	duration(duration_t {0}), | 
					
						
							| 
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 |  |  | 	filename(filenameIn), | 
					
						
							|  |  |  | 	thumbnail(new DivePictureItem) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-06-30 21:32:14 +02:00
										 |  |  | 	int size = Thumbnailer::defaultThumbnailSize(); | 
					
						
							|  |  |  | 	scene->addItem(thumbnail.get()); | 
					
						
							|  |  |  | 	thumbnail->setVisible(prefs.show_pictures_in_profile); | 
					
						
							| 
									
										
										
										
											2019-02-02 21:23:52 +01:00
										 |  |  | 	QImage img = Thumbnailer::instance()->fetchThumbnail(filename, synchronous).scaled(size, size, Qt::KeepAspectRatio); | 
					
						
							| 
									
										
										
										
											2018-06-30 21:32:14 +02:00
										 |  |  | 	thumbnail->setPixmap(QPixmap::fromImage(img)); | 
					
						
							|  |  |  | 	thumbnail->setFileUrl(filename); | 
					
						
							| 
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Define a default sort order for picture-entries: sort lexicographically by timestamp and filename.
 | 
					
						
							|  |  |  | bool ProfileWidget2::PictureEntry::operator< (const PictureEntry &e) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	// Use std::tie() for lexicographical sorting.
 | 
					
						
							|  |  |  | 	return std::tie(offset.seconds, filename) < std::tie(e.offset.seconds, e.filename); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 |  |  | // This function updates the paint order of the thumbnails and duration-lines, such that later
 | 
					
						
							|  |  |  | // thumbnails are painted on top of previous thumbnails and duration-lines on top of the thumbnail
 | 
					
						
							|  |  |  | // they belong to.
 | 
					
						
							|  |  |  | void ProfileWidget2::updateThumbnailPaintOrder() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (!pictures.size()) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	// To get the correct sort order, we place in thumbnails at equal z-distances
 | 
					
						
							|  |  |  | 	// between thumbnailBaseZValue and (thumbnailBaseZValue + 1.0).
 | 
					
						
							|  |  |  | 	// Duration-lines are placed between the thumbnails.
 | 
					
						
							|  |  |  | 	double z = thumbnailBaseZValue; | 
					
						
							|  |  |  | 	double step = 1.0 / (double)pictures.size(); | 
					
						
							|  |  |  | 	for (PictureEntry &e: pictures) { | 
					
						
							|  |  |  | 		e.thumbnail->setBaseZValue(z); | 
					
						
							|  |  |  | 		if (e.durationLine) | 
					
						
							|  |  |  | 			e.durationLine->setZValue(z + step / 2.0); | 
					
						
							|  |  |  | 		z += step; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 21:32:14 +02:00
										 |  |  | // Calculate the y-coordinates of the thumbnails, which are supposed to be sorted by x-coordinate.
 | 
					
						
							|  |  |  | // This will also change the order in which the thumbnails are painted, to avoid weird effects,
 | 
					
						
							| 
									
										
										
										
											2018-07-15 17:30:34 +02:00
										 |  |  | // when items are added later to the scene. This is done using the QGraphicsItem::packBefore() function.
 | 
					
						
							|  |  |  | // We can't use the z-value, because that will be modified on hoverEnter and hoverExit events.
 | 
					
						
							| 
									
										
										
										
											2018-06-30 12:55:55 +02:00
										 |  |  | void ProfileWidget2::calculatePictureYPositions() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-15 17:30:34 +02:00
										 |  |  | 	double lastX = -1.0, lastY = 0.0; | 
					
						
							| 
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 |  |  | 	for (PictureEntry &e: pictures) { | 
					
						
							| 
									
										
										
										
											2018-06-30 12:55:55 +02:00
										 |  |  | 		// let's put the picture at the correct time, but at a fixed "depth" on the profile
 | 
					
						
							|  |  |  | 		// not sure this is ideal, but it seems to look right.
 | 
					
						
							| 
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 |  |  | 		double x = e.thumbnail->x(); | 
					
						
							| 
									
										
										
										
											2018-06-30 12:55:55 +02:00
										 |  |  | 		double y; | 
					
						
							|  |  |  | 		if (lastX >= 0.0 && fabs(x - lastX) < 3 && lastY <= (10 + 14 * 3)) | 
					
						
							|  |  |  | 			y = lastY + 3; | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			y = 10; | 
					
						
							|  |  |  | 		lastX = x; | 
					
						
							|  |  |  | 		lastY = y; | 
					
						
							| 
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 |  |  | 		e.thumbnail->setY(y); | 
					
						
							|  |  |  | 		updateDurationLine(e); // If we changed the y-position, we also have to change the duration-line.
 | 
					
						
							| 
									
										
										
										
											2018-06-30 12:55:55 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-15 17:56:18 +02:00
										 |  |  | 	updateThumbnailPaintOrder(); | 
					
						
							| 
									
										
										
										
											2018-06-30 12:55:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 21:32:14 +02:00
										 |  |  | void ProfileWidget2::updateThumbnailXPos(PictureEntry &e) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	// Here, we only set the x-coordinate of the picture. The y-coordinate
 | 
					
						
							|  |  |  | 	// will be set later in calculatePictureYPositions().
 | 
					
						
							|  |  |  | 	double x = timeAxis->posAtValue(e.offset.seconds); | 
					
						
							|  |  |  | 	e.thumbnail->setX(x); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 |  |  | // This function resets the picture thumbnails of the current dive.
 | 
					
						
							| 
									
										
										
										
											2018-04-06 17:58:16 +02:00
										 |  |  | void ProfileWidget2::plotPictures() | 
					
						
							| 
									
										
										
										
											2019-02-02 21:23:52 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-02-02 21:31:12 +01:00
										 |  |  | 	plotPicturesInternal(current_dive, false); | 
					
						
							| 
									
										
										
										
											2019-02-02 21:23:52 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-03 13:28:33 +01:00
										 |  |  | void ProfileWidget2::plotPicturesInternal(const struct dive *d, bool synchronous) | 
					
						
							| 
									
										
										
										
											2018-04-06 17:58:16 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 |  |  | 	pictures.clear(); | 
					
						
							|  |  |  | 	if (currentState == ADD || currentState == PLAN) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2018-04-06 17:58:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-02 21:31:12 +01:00
										 |  |  | 	// Fetch all pictures of the dive, but consider only those that are within the dive time.
 | 
					
						
							| 
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 |  |  | 	// For each picture, create a PictureEntry object in the pictures-vector.
 | 
					
						
							|  |  |  | 	// emplace_back() constructs an object at the end of the vector. The parameters are passed directly to the constructor.
 | 
					
						
							| 
									
										
										
										
											2019-02-02 21:31:12 +01:00
										 |  |  | 	// Note that FOR_EACH_PICTURE handles d being null gracefully.
 | 
					
						
							|  |  |  | 	FOR_EACH_PICTURE(d) { | 
					
						
							|  |  |  | 		if (picture->offset.seconds > 0 && picture->offset.seconds <= d->duration.seconds) | 
					
						
							| 
									
										
										
										
											2019-02-02 21:23:52 +01:00
										 |  |  | 			pictures.emplace_back(picture->offset, QString(picture->filename), scene(), synchronous); | 
					
						
							| 
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if (pictures.empty()) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	// Sort pictures by timestamp (and filename if equal timestamps).
 | 
					
						
							|  |  |  | 	// This will allow for proper location of the pictures on the profile plot.
 | 
					
						
							|  |  |  | 	std::sort(pictures.begin(), pictures.end()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 21:32:14 +02:00
										 |  |  | 	// Calculate thumbnail positions. First the x-coordinates and and then the y-coordinates.
 | 
					
						
							|  |  |  | 	for (PictureEntry &e: pictures) | 
					
						
							|  |  |  | 		updateThumbnailXPos(e); | 
					
						
							| 
									
										
										
										
											2018-06-30 12:55:55 +02:00
										 |  |  | 	calculatePictureYPositions(); | 
					
						
							| 
									
										
										
										
											2014-06-03 19:24:01 -03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-05-19 21:18:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 |  |  | // Remove the pictures with the given filenames from the profile plot.
 | 
					
						
							| 
									
										
										
										
											2020-04-17 23:18:58 +02:00
										 |  |  | void ProfileWidget2::picturesRemoved(dive *d, QVector<QString> fileUrls) | 
					
						
							| 
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-04-17 23:18:58 +02:00
										 |  |  | 	if (d->id != displayed_dive.id) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2018-06-30 11:36:37 +02:00
										 |  |  | 	// To remove the pictures, we use the std::remove_if() algorithm.
 | 
					
						
							|  |  |  | 	// std::remove_if() does not actually delete the elements, but moves
 | 
					
						
							|  |  |  | 	// them to the end of the given range. It returns an iterator to the
 | 
					
						
							|  |  |  | 	// end of the new range of non-deleted elements. A subsequent call to
 | 
					
						
							|  |  |  | 	// std::erase on the range of deleted elements then ultimately shrinks the vector.
 | 
					
						
							|  |  |  | 	// (c.f. erase-remove idiom: https://en.wikipedia.org/wiki/Erase%E2%80%93remove_idiom)
 | 
					
						
							|  |  |  | 	auto it = std::remove_if(pictures.begin(), pictures.end(), [&fileUrls](const PictureEntry &e) | 
					
						
							|  |  |  | 			// Check whether filename of entry is in list of provided filenames
 | 
					
						
							|  |  |  | 			{ return std::find(fileUrls.begin(), fileUrls.end(), e.filename) != fileUrls.end(); }); | 
					
						
							|  |  |  | 	pictures.erase(it, pictures.end()); | 
					
						
							| 
									
										
										
										
											2018-06-30 12:55:55 +02:00
										 |  |  | 	calculatePictureYPositions(); | 
					
						
							| 
									
										
										
										
											2018-05-19 21:18:39 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-17 23:18:58 +02:00
										 |  |  | void ProfileWidget2::picturesAdded(dive *d, QVector<PictureObj> pics) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (d->id != displayed_dive.id) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (const PictureObj &pic: pics) { | 
					
						
							|  |  |  | 		if (pic.offset.seconds > 0 && pic.offset.seconds <= d->duration.seconds) { | 
					
						
							|  |  |  | 			pictures.emplace_back(pic.offset, QString::fromStdString(pic.filename), scene(), false); | 
					
						
							|  |  |  | 			updateThumbnailXPos(pictures.back()); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Sort pictures by timestamp (and filename if equal timestamps).
 | 
					
						
							|  |  |  | 	// This will allow for proper location of the pictures on the profile plot.
 | 
					
						
							|  |  |  | 	std::sort(pictures.begin(), pictures.end()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	calculatePictureYPositions(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-03 22:42:51 +01:00
										 |  |  | void ProfileWidget2::profileChanged(dive *d) | 
					
						
							| 
									
										
										
										
											2020-03-01 17:16:08 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	if (!d || d->id != displayed_dive.id) | 
					
						
							|  |  |  | 		return; // Cylinders of a differnt dive than the shown one changed.
 | 
					
						
							|  |  |  | 	replot(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-10 13:55:29 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2015-11-03 21:17:50 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::dropEvent(QDropEvent *event) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-04-14 22:07:00 +02:00
										 |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							| 
									
										
										
										
											2015-11-03 21:17:50 +01:00
										 |  |  | 	if (event->mimeData()->hasFormat("application/x-subsurfaceimagedrop")) { | 
					
						
							|  |  |  | 		QByteArray itemData = event->mimeData()->data("application/x-subsurfaceimagedrop"); | 
					
						
							|  |  |  | 		QDataStream dataStream(&itemData, QIODevice::ReadOnly); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		QString filename; | 
					
						
							| 
									
										
										
										
											2020-04-14 22:07:00 +02:00
										 |  |  | 		dataStream >> filename; | 
					
						
							| 
									
										
										
										
											2015-11-03 21:17:50 +01:00
										 |  |  | 		QPointF mappedPos = mapToScene(event->pos()); | 
					
						
							| 
									
										
										
										
											2018-06-30 21:32:14 +02:00
										 |  |  | 		offset_t offset { (int32_t)lrint(timeAxis->valueAt(mappedPos)) }; | 
					
						
							| 
									
										
										
										
											2020-04-14 22:07:00 +02:00
										 |  |  | 		Command::setPictureOffset(current_dive, filename, offset); | 
					
						
							| 
									
										
										
										
											2015-11-03 21:17:50 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (event->source() == this) { | 
					
						
							|  |  |  | 			event->setDropAction(Qt::MoveAction); | 
					
						
							|  |  |  | 			event->accept(); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			event->acceptProposedAction(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		event->ignore(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-04-14 22:07:00 +02:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef SUBSURFACE_MOBILE
 | 
					
						
							|  |  |  | void ProfileWidget2::pictureOffsetChanged(dive *d, QString filename, offset_t offset) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (d->id != displayed_dive.id) | 
					
						
							|  |  |  | 		return; // Picture of a different dive than the one shown changed.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Calculate time in dive where picture was dropped and whether the new position is during the dive.
 | 
					
						
							|  |  |  | 	bool duringDive = current_dive && offset.seconds > 0 && offset.seconds < current_dive->duration.seconds; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// A picture was drag&dropped onto the profile: We have four cases to consider:
 | 
					
						
							|  |  |  | 	//	1a) The image was already shown on the profile and is moved to a different position on the profile.
 | 
					
						
							|  |  |  | 	//	    Calculate the new position and move the picture.
 | 
					
						
							|  |  |  | 	//	1b) The image was on the profile and is moved outside of the dive time.
 | 
					
						
							|  |  |  | 	//	    Remove the picture.
 | 
					
						
							|  |  |  | 	//	2a) The image was not on the profile and is moved into the dive time.
 | 
					
						
							|  |  |  | 	//	    Add the picture to the profile.
 | 
					
						
							|  |  |  | 	//	2b) The image was not on the profile and is moved outside of the dive time.
 | 
					
						
							|  |  |  | 	//	    Do nothing.
 | 
					
						
							|  |  |  | 	auto oldPos = std::find_if(pictures.begin(), pictures.end(), [filename](const PictureEntry &e) | 
					
						
							|  |  |  | 				   { return e.filename == filename; }); | 
					
						
							|  |  |  | 	if (oldPos != pictures.end()) { | 
					
						
							|  |  |  | 		// Cases 1a) and 1b): picture is on profile
 | 
					
						
							|  |  |  | 		if (duringDive) { | 
					
						
							|  |  |  | 			// Case 1a): move to new position
 | 
					
						
							|  |  |  | 			// First, find new position. Note that we also have to compare filenames,
 | 
					
						
							|  |  |  | 			// because it is quite easy to generate equal offsets.
 | 
					
						
							|  |  |  | 			auto newPos = std::find_if(pictures.begin(), pictures.end(), [offset, &filename](const PictureEntry &e) | 
					
						
							|  |  |  | 						   { return std::tie(e.offset.seconds, e.filename) > std::tie(offset.seconds, filename); }); | 
					
						
							|  |  |  | 			// Set new offset
 | 
					
						
							|  |  |  | 			oldPos->offset.seconds = offset.seconds; | 
					
						
							|  |  |  | 			updateThumbnailXPos(*oldPos); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// Move image from old to new position
 | 
					
						
							|  |  |  | 			int oldIndex = oldPos - pictures.begin(); | 
					
						
							|  |  |  | 			int newIndex = newPos - pictures.begin(); | 
					
						
							|  |  |  | 			moveInVector(pictures, oldIndex, oldIndex + 1, newIndex); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			// Case 1b): remove picture
 | 
					
						
							|  |  |  | 			pictures.erase(oldPos); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// In both cases the picture list changed, therefore we must recalculate the y-coordinatesA.
 | 
					
						
							|  |  |  | 		calculatePictureYPositions(); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		// Cases 2a) and 2b): picture not on profile. We only have to take action for
 | 
					
						
							|  |  |  | 		// the first case: picture is moved into dive-time.
 | 
					
						
							|  |  |  | 		if (duringDive) { | 
					
						
							|  |  |  | 			// Case 2a): add the picture at the appropriate position.
 | 
					
						
							|  |  |  | 			// The case move from outside-to-outside of the profile plot was handled by
 | 
					
						
							|  |  |  | 			// the "&& duringDive" condition in the if above.
 | 
					
						
							|  |  |  | 			// As for case 1a), we have to also consider filenames in the case of equal offsets.
 | 
					
						
							|  |  |  | 			auto newPos = std::find_if(pictures.begin(), pictures.end(), [offset, &filename](const PictureEntry &e) | 
					
						
							|  |  |  | 						   { return std::tie(e.offset.seconds, e.filename) > std::tie(offset.seconds, filename); }); | 
					
						
							|  |  |  | 			// emplace() constructs the element at the given position in the vector.
 | 
					
						
							|  |  |  | 			// The parameters are passed directly to the contructor.
 | 
					
						
							|  |  |  | 			// The call returns an iterator to the new element (which might differ from
 | 
					
						
							|  |  |  | 			// the old iterator, since the buffer might have been reallocated).
 | 
					
						
							|  |  |  | 			newPos = pictures.emplace(newPos, offset, filename, scene(), false); | 
					
						
							|  |  |  | 			updateThumbnailXPos(*newPos); | 
					
						
							|  |  |  | 			calculatePictureYPositions(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-11-03 21:17:50 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-04-14 22:07:00 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2015-11-03 21:17:50 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::dragEnterEvent(QDragEnterEvent *event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (event->mimeData()->hasFormat("application/x-subsurfaceimagedrop")) { | 
					
						
							|  |  |  | 		if (event->source() == this) { | 
					
						
							|  |  |  | 			event->setDropAction(Qt::MoveAction); | 
					
						
							|  |  |  | 			event->accept(); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			event->acceptProposedAction(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		event->ignore(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ProfileWidget2::dragMoveEvent(QDragMoveEvent *event) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (event->mimeData()->hasFormat("application/x-subsurfaceimagedrop")) { | 
					
						
							|  |  |  | 		if (event->source() == this) { | 
					
						
							|  |  |  | 			event->setDropAction(Qt::MoveAction); | 
					
						
							|  |  |  | 			event->accept(); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			event->acceptProposedAction(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		event->ignore(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |