| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | #ifndef PROFILEWIDGET2_H
 | 
					
						
							|  |  |  | #define PROFILEWIDGET2_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QGraphicsView>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // /* The idea of this widget is to display and edit the profile.
 | 
					
						
							|  |  |  | //  * It has:
 | 
					
						
							|  |  |  | //  * 1 - ToolTip / Legend item, displays every information of the current mouse position on it, plus the legends of the maps.
 | 
					
						
							|  |  |  | //  * 2 - ToolBox, displays the QActions that are used to do special stuff on the profile ( like activating the plugins. )
 | 
					
						
							|  |  |  | //  * 3 - Cartesian Axis for depth ( y )
 | 
					
						
							|  |  |  | //  * 4 - Cartesian Axis for Gases ( y )
 | 
					
						
							|  |  |  | //  * 5 - Cartesian Axis for Time  ( x )
 | 
					
						
							|  |  |  | //  *
 | 
					
						
							|  |  |  | //  * It needs to be dynamic, things should *flow* on it, not just appear / disappear.
 | 
					
						
							|  |  |  | //  */
 | 
					
						
							|  |  |  | #include "graphicsview-common.h"
 | 
					
						
							| 
									
										
										
										
											2014-01-18 14:38:21 -08:00
										 |  |  | #include "divelineitem.h"
 | 
					
						
							| 
									
										
										
										
											2014-01-16 15:02:32 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-27 15:20:03 -03:00
										 |  |  | class RulerItem2; | 
					
						
							| 
									
										
										
										
											2014-02-10 20:28:33 -08:00
										 |  |  | struct dive; | 
					
						
							|  |  |  | struct plot_info; | 
					
						
							| 
									
										
										
										
											2014-02-05 14:34:45 -02:00
										 |  |  | class ToolTipItem; | 
					
						
							| 
									
										
										
										
											2014-01-22 15:08:19 -02:00
										 |  |  | class MeanDepthLine; | 
					
						
							| 
									
										
										
										
											2014-01-21 17:34:36 -02:00
										 |  |  | class DiveReportedCeiling; | 
					
						
							| 
									
										
										
										
											2014-01-21 10:48:26 -02:00
										 |  |  | class DiveTextItem; | 
					
						
							| 
									
										
										
										
											2014-01-16 18:39:13 -02:00
										 |  |  | class TemperatureAxis; | 
					
						
							| 
									
										
										
										
											2014-01-16 15:02:32 -02:00
										 |  |  | class DiveEventItem; | 
					
						
							| 
									
										
										
										
											2014-02-10 20:28:33 -08:00
										 |  |  | class DivePlotDataModel; | 
					
						
							|  |  |  | class DivePixmapItem; | 
					
						
							|  |  |  | class DiveRectItem; | 
					
						
							|  |  |  | class DepthAxis; | 
					
						
							|  |  |  | class DiveCartesianAxis; | 
					
						
							|  |  |  | class DiveProfileItem; | 
					
						
							|  |  |  | class TimeAxis; | 
					
						
							|  |  |  | class DiveTemperatureItem; | 
					
						
							| 
									
										
										
										
											2014-02-23 15:28:31 -08:00
										 |  |  | class DiveHeartrateItem; | 
					
						
							| 
									
										
										
										
											2014-02-10 20:28:33 -08:00
										 |  |  | class DiveGasPressureItem; | 
					
						
							|  |  |  | class DiveCalculatedCeiling; | 
					
						
							|  |  |  | class DiveCalculatedTissue; | 
					
						
							|  |  |  | class PartialPressureGasItem; | 
					
						
							|  |  |  | class PartialGasPressureAxis; | 
					
						
							|  |  |  | class AbstractProfilePolygonItem; | 
					
						
							| 
									
										
										
										
											2014-05-21 21:18:10 -03:00
										 |  |  | class DiveHandler; | 
					
						
							|  |  |  | class QGraphicsSimpleTextItem; | 
					
						
							|  |  |  | class QModelIndex; | 
					
						
							| 
									
										
										
										
											2014-06-08 12:43:04 -03:00
										 |  |  | class DivePictureItem; | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | 
 | 
					
						
							|  |  |  | class ProfileWidget2 : public QGraphicsView { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	enum State { | 
					
						
							|  |  |  | 		EMPTY, | 
					
						
							|  |  |  | 		PROFILE, | 
					
						
							|  |  |  | 		EDIT, | 
					
						
							|  |  |  | 		ADD, | 
					
						
							|  |  |  | 		PLAN, | 
					
						
							|  |  |  | 		INVALID | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 	enum Items { | 
					
						
							|  |  |  | 		BACKGROUND, | 
					
						
							|  |  |  | 		PROFILE_Y_AXIS, | 
					
						
							|  |  |  | 		GAS_Y_AXIS, | 
					
						
							|  |  |  | 		TIME_AXIS, | 
					
						
							|  |  |  | 		DEPTH_CONTROLLER, | 
					
						
							|  |  |  | 		TIME_CONTROLLER, | 
					
						
							|  |  |  | 		COLUMNS | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-07 12:42:13 -03:00
										 |  |  | 	ProfileWidget2(QWidget *parent = 0); | 
					
						
							| 
									
										
										
										
											2014-07-09 11:19:08 -07:00
										 |  |  | 	void plotDive(struct dive *d = 0, bool force = false); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	virtual bool eventFilter(QObject *, QEvent *); | 
					
						
							|  |  |  | 	void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue); | 
					
						
							| 
									
										
										
										
											2014-03-25 23:34:09 +02:00
										 |  |  | 	void setPrintMode(bool mode, bool grayscale = false); | 
					
						
							| 
									
										
										
										
											2014-07-09 13:09:52 -07:00
										 |  |  | 	bool getPrintMode(); | 
					
						
							| 
									
										
										
										
											2014-05-22 11:40:22 -07:00
										 |  |  | 	bool isPointOutOfBoundaries(const QPointF &point) const; | 
					
						
							| 
									
										
										
										
											2014-05-26 15:17:34 -07:00
										 |  |  | 	bool isPlanner(); | 
					
						
							| 
									
										
										
										
											2014-05-31 14:54:36 -07:00
										 |  |  | 	bool isAddOrPlanner(); | 
					
						
							| 
									
										
										
										
											2014-07-09 13:09:52 -07:00
										 |  |  | 	double getFontPrintScale(); | 
					
						
							|  |  |  | 	void setFontPrintScale(double scale); | 
					
						
							| 
									
										
										
										
											2014-05-21 14:24:19 -03:00
										 |  |  | 	State currentState; | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | public | 
					
						
							|  |  |  | slots: // Necessary to call from QAction's signals.
 | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | 	void settingsChanged(); | 
					
						
							| 
									
										
										
										
											2014-02-07 16:34:42 -02:00
										 |  |  | 	void setEmptyState(); | 
					
						
							|  |  |  | 	void setProfileState(); | 
					
						
							| 
									
										
										
										
											2014-05-21 15:52:24 -03:00
										 |  |  | 	void setPlanState(); | 
					
						
							|  |  |  | 	void setAddState(); | 
					
						
							| 
									
										
										
										
											2014-02-17 19:15:40 -03:00
										 |  |  | 	void changeGas(); | 
					
						
							| 
									
										
										
										
											2014-03-15 21:12:34 -07:00
										 |  |  | 	void addBookmark(); | 
					
						
							|  |  |  | 	void hideEvents(); | 
					
						
							|  |  |  | 	void unhideEvents(); | 
					
						
							|  |  |  | 	void removeEvent(); | 
					
						
							| 
									
										
										
										
											2014-04-03 21:16:15 +02:00
										 |  |  | 	void editName(); | 
					
						
							| 
									
										
										
										
											2014-05-19 14:39:34 +09:00
										 |  |  | 	void makeFirstDC(); | 
					
						
							| 
									
										
										
										
											2014-06-11 13:56:33 -07:00
										 |  |  | 	void deleteCurrentDC(); | 
					
						
							| 
									
										
										
										
											2014-05-21 21:18:10 -03:00
										 |  |  | 	void pointInserted(const QModelIndex &parent, int start, int end); | 
					
						
							|  |  |  | 	void pointsRemoved(const QModelIndex &, int start, int end); | 
					
						
							| 
									
										
										
										
											2014-06-03 19:24:01 -03:00
										 |  |  | 	void plotPictures(); | 
					
						
							| 
									
										
										
										
											2014-05-21 21:23:19 -03:00
										 |  |  | 	void replot(); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-23 20:51:30 -03:00
										 |  |  | 	/* this is called for every move on the handlers. maybe we can speed up this a bit? */ | 
					
						
							|  |  |  | 	void recreatePlannedDive(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 	/* key press handlers */ | 
					
						
							|  |  |  | 	void keyEscAction(); | 
					
						
							|  |  |  | 	void keyDeleteAction(); | 
					
						
							|  |  |  | 	void keyUpAction(); | 
					
						
							|  |  |  | 	void keyDownAction(); | 
					
						
							|  |  |  | 	void keyLeftAction(); | 
					
						
							|  |  |  | 	void keyRightAction(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-30 19:08:16 -03:00
										 |  |  | 	void divePlannerHandlerClicked(); | 
					
						
							|  |  |  | 	void divePlannerHandlerReleased(); | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	virtual void resizeEvent(QResizeEvent *event); | 
					
						
							|  |  |  | 	virtual void wheelEvent(QWheelEvent *event); | 
					
						
							|  |  |  | 	virtual void mouseMoveEvent(QMouseEvent *event); | 
					
						
							|  |  |  | 	virtual void contextMenuEvent(QContextMenuEvent *event); | 
					
						
							| 
									
										
										
										
											2014-05-21 15:52:24 -03:00
										 |  |  | 	virtual void mouseDoubleClickEvent(QMouseEvent *event); | 
					
						
							| 
									
										
										
										
											2014-05-26 17:51:46 -03:00
										 |  |  | 	virtual void mousePressEvent(QMouseEvent *event); | 
					
						
							|  |  |  | 	virtual void mouseReleaseEvent(QMouseEvent *event); | 
					
						
							| 
									
										
										
										
											2014-06-30 19:08:16 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 15:32:39 -02:00
										 |  |  | private: /*methods*/ | 
					
						
							|  |  |  | 	void fixBackgroundPos(); | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	void scrollViewTo(const QPoint &pos); | 
					
						
							| 
									
										
										
										
											2014-02-07 15:32:39 -02:00
										 |  |  | 	void setupSceneAndFlags(); | 
					
						
							|  |  |  | 	void setupItemSizes(); | 
					
						
							|  |  |  | 	void addItemsToScene(); | 
					
						
							|  |  |  | 	void setupItemOnScene(); | 
					
						
							| 
									
										
										
										
											2014-05-21 21:23:19 -03:00
										 |  |  | 	void disconnectTemporaryConnections(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-15 12:00:23 -02:00
										 |  |  | private: | 
					
						
							|  |  |  | 	DivePlotDataModel *dataModel; | 
					
						
							| 
									
										
										
										
											2014-02-04 21:47:50 -02:00
										 |  |  | 	int zoomLevel; | 
					
						
							| 
									
										
										
										
											2014-03-10 17:59:02 +02:00
										 |  |  | 	qreal zoomFactor; | 
					
						
							| 
									
										
										
										
											2014-02-07 16:34:42 -02:00
										 |  |  | 	DivePixmapItem *background; | 
					
						
							|  |  |  | 	QString backgroundFile; | 
					
						
							| 
									
										
										
										
											2014-02-05 14:34:45 -02:00
										 |  |  | 	ToolTipItem *toolTipItem; | 
					
						
							| 
									
										
										
										
											2014-02-27 12:39:53 -03:00
										 |  |  | 	bool isPlotZoomed; | 
					
						
							| 
									
										
										
										
											2014-01-16 15:02:32 -02:00
										 |  |  | 	// All those here should probably be merged into one structure,
 | 
					
						
							|  |  |  | 	// So it's esyer to replicate for more dives later.
 | 
					
						
							|  |  |  | 	// In the meantime, keep it here.
 | 
					
						
							|  |  |  | 	struct plot_info *plotInfo; | 
					
						
							| 
									
										
										
										
											2014-02-09 19:11:17 +01:00
										 |  |  | 	DepthAxis *profileYAxis; | 
					
						
							| 
									
										
										
										
											2014-01-27 15:14:42 -02:00
										 |  |  | 	PartialGasPressureAxis *gasYAxis; | 
					
						
							| 
									
										
										
										
											2014-01-16 18:39:13 -02:00
										 |  |  | 	TemperatureAxis *temperatureAxis; | 
					
						
							| 
									
										
										
										
											2014-01-15 12:00:23 -02:00
										 |  |  | 	TimeAxis *timeAxis; | 
					
						
							|  |  |  | 	DiveProfileItem *diveProfileItem; | 
					
						
							| 
									
										
										
										
											2014-01-16 18:39:13 -02:00
										 |  |  | 	DiveTemperatureItem *temperatureItem; | 
					
						
							| 
									
										
										
										
											2014-01-17 14:28:59 -02:00
										 |  |  | 	DiveCartesianAxis *cylinderPressureAxis; | 
					
						
							| 
									
										
										
										
											2014-01-17 15:34:15 -02:00
										 |  |  | 	DiveGasPressureItem *gasPressureItem; | 
					
						
							| 
									
										
										
										
											2014-01-22 15:08:19 -02:00
										 |  |  | 	MeanDepthLine *meanDepth; | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	QList<DiveEventItem *> eventItems; | 
					
						
							| 
									
										
										
										
											2014-01-21 10:48:26 -02:00
										 |  |  | 	DiveTextItem *diveComputerText; | 
					
						
							| 
									
										
										
										
											2014-01-21 14:59:19 -02:00
										 |  |  | 	DiveCalculatedCeiling *diveCeiling; | 
					
						
							| 
									
										
										
										
											2014-02-27 20:09:57 -08:00
										 |  |  | 	QList<DiveCalculatedTissue *> allTissues; | 
					
						
							| 
									
										
										
										
											2014-01-21 17:34:36 -02:00
										 |  |  | 	DiveReportedCeiling *reportedCeiling; | 
					
						
							| 
									
										
										
										
											2014-01-23 17:54:34 -02:00
										 |  |  | 	PartialPressureGasItem *pn2GasItem; | 
					
						
							| 
									
										
										
										
											2014-01-23 17:59:14 -02:00
										 |  |  | 	PartialPressureGasItem *pheGasItem; | 
					
						
							| 
									
										
										
										
											2014-01-23 18:03:28 -02:00
										 |  |  | 	PartialPressureGasItem *po2GasItem; | 
					
						
							| 
									
										
										
										
											2014-02-19 17:18:26 -08:00
										 |  |  | 	DiveCartesianAxis *heartBeatAxis; | 
					
						
							| 
									
										
										
										
											2014-02-23 15:28:31 -08:00
										 |  |  | 	DiveHeartrateItem *heartBeatItem; | 
					
						
							| 
									
										
										
										
											2014-08-05 18:27:00 -03:00
										 |  |  | 	DiveLineItem *mouseFollowerVertical; | 
					
						
							|  |  |  | 	DiveLineItem *mouseFollowerHorizontal; | 
					
						
							| 
									
										
										
										
											2014-02-27 15:20:03 -03:00
										 |  |  | 	RulerItem2 *rulerItem; | 
					
						
							| 
									
										
										
										
											2014-03-25 23:34:09 +02:00
										 |  |  | 	bool isGrayscale; | 
					
						
							|  |  |  | 	bool printMode; | 
					
						
							| 
									
										
										
										
											2014-05-21 21:18:10 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	//specifics for ADD and PLAN
 | 
					
						
							|  |  |  | 	QList<DiveHandler *> handles; | 
					
						
							|  |  |  | 	QList<QGraphicsSimpleTextItem *> gases; | 
					
						
							| 
									
										
										
										
											2014-06-08 12:43:04 -03:00
										 |  |  | 	QList<DivePictureItem*> pictures; | 
					
						
							| 
									
										
										
										
											2014-05-21 23:31:26 -03:00
										 |  |  | 	void repositionDiveHandlers(); | 
					
						
							| 
									
										
										
										
											2014-05-23 22:22:02 -03:00
										 |  |  | 	int fixHandlerIndex(DiveHandler *activeHandler); | 
					
						
							| 
									
										
										
										
											2014-05-23 22:39:51 -03:00
										 |  |  | 	friend class DiveHandler; | 
					
						
							| 
									
										
										
										
											2014-05-24 12:39:40 -03:00
										 |  |  | 	QHash<Qt::Key, QAction *> actionsForKeys; | 
					
						
							| 
									
										
										
										
											2014-05-26 17:51:46 -03:00
										 |  |  | 	bool shouldCalculateMaxTime; | 
					
						
							| 
									
										
										
										
											2014-06-30 19:08:16 -03:00
										 |  |  | 	bool shouldCalculateMaxDepth; | 
					
						
							| 
									
										
										
										
											2014-05-26 17:51:46 -03:00
										 |  |  | 	int maxtime; | 
					
						
							| 
									
										
										
										
											2014-06-30 19:08:16 -03:00
										 |  |  | 	int maxdepth; | 
					
						
							| 
									
										
										
										
											2014-07-09 13:09:52 -07:00
										 |  |  | 	double fontPrintScale; | 
					
						
							| 
									
										
										
										
											2014-01-14 14:30:13 -02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-11 19:14:46 +01:00
										 |  |  | #endif // PROFILEWIDGET2_H
 |