| 
									
										
										
										
											2013-05-04 16:12:43 -03:00
										 |  |  | #ifndef PROFILEGRAPHICS_H
 | 
					
						
							|  |  |  | #define PROFILEGRAPHICS_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-13 18:18:26 +03:00
										 |  |  | #include "graphicsview-common.h"
 | 
					
						
							| 
									
										
										
										
											2013-05-08 14:56:06 -07:00
										 |  |  | #include "../display.h"
 | 
					
						
							| 
									
										
										
										
											2013-05-04 16:12:43 -03:00
										 |  |  | #include <QGraphicsView>
 | 
					
						
							| 
									
										
										
										
											2013-05-07 15:44:54 -03:00
										 |  |  | #include <QGraphicsItem>
 | 
					
						
							|  |  |  | #include <QIcon>
 | 
					
						
							| 
									
										
										
										
											2013-06-10 19:02:06 -03:00
										 |  |  | #include <QDoubleSpinBox>
 | 
					
						
							|  |  |  | #include <QPushButton>
 | 
					
						
							|  |  |  | #include <QGraphicsProxyWidget>
 | 
					
						
							| 
									
										
										
										
											2013-05-04 16:12:43 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-06 15:35:17 -03:00
										 |  |  | struct text_render_options; | 
					
						
							|  |  |  | struct graphics_context; | 
					
						
							|  |  |  | struct plot_info; | 
					
						
							|  |  |  | typedef struct text_render_options text_render_options_t; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-09 18:45:58 -03:00
										 |  |  | /* To use a tooltip, simply ->setToolTip on the QGraphicsItem that you want
 | 
					
						
							|  |  |  |  * or, if it's a "global" tooltip, set it on the mouseMoveEvent of the ProfileGraphicsView. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-05-07 16:12:01 -07:00
										 |  |  | class ToolTipItem :public QObject, public QGraphicsPathItem | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-05-07 15:44:54 -03:00
										 |  |  | 	Q_OBJECT | 
					
						
							| 
									
										
										
										
											2013-05-07 16:09:51 -07:00
										 |  |  | 	void updateTitlePosition(); | 
					
						
							| 
									
										
										
										
											2013-05-07 15:44:54 -03:00
										 |  |  | 	Q_PROPERTY(QRectF rect READ boundingRect WRITE setRect) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2013-05-07 16:09:51 -07:00
										 |  |  | 	enum Status{COLLAPSED, EXPANDED}; | 
					
						
							|  |  |  | 	enum {ICON_SMALL = 16, ICON_MEDIUM = 24, ICON_BIG = 32, SPACING=4}; | 
					
						
							| 
									
										
										
										
											2013-05-07 15:44:54 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-07 16:09:51 -07:00
										 |  |  | 	explicit ToolTipItem(QGraphicsItem* parent = 0); | 
					
						
							| 
									
										
										
										
											2013-06-10 13:54:17 -03:00
										 |  |  | 	virtual ~ToolTipItem(); | 
					
						
							| 
									
										
										
										
											2013-05-07 15:44:54 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void collapse(); | 
					
						
							|  |  |  | 	void expand(); | 
					
						
							|  |  |  | 	void clear(); | 
					
						
							|  |  |  | 	void addToolTip(const QString& toolTip, const QIcon& icon = QIcon()); | 
					
						
							| 
									
										
										
										
											2013-05-10 11:07:44 -03:00
										 |  |  | 	void refresh(struct graphics_context* gc, QPointF pos); | 
					
						
							| 
									
										
										
										
											2013-06-07 22:49:57 -03:00
										 |  |  | 	bool isExpanded(); | 
					
						
							| 
									
										
										
										
											2013-06-10 14:28:44 -03:00
										 |  |  | 	void persistPos(); | 
					
						
							|  |  |  | 	void readPos(); | 
					
						
							| 
									
										
										
										
											2013-06-10 14:48:31 -03:00
										 |  |  | 	void mouseReleaseEvent(QGraphicsSceneMouseEvent* event); | 
					
						
							| 
									
										
										
										
											2013-06-19 10:20:16 -07:00
										 |  |  | public slots: | 
					
						
							| 
									
										
										
										
											2013-05-07 15:44:54 -03:00
										 |  |  | 	void setRect(const QRectF& rect); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	typedef QPair<QGraphicsPixmapItem*, QGraphicsSimpleTextItem*> ToolTip; | 
					
						
							| 
									
										
										
										
											2013-07-30 23:36:20 +02:00
										 |  |  | 	QList<ToolTip> toolTips; | 
					
						
							| 
									
										
										
										
											2013-05-07 23:00:05 -03:00
										 |  |  | 	QGraphicsPathItem *background; | 
					
						
							| 
									
										
										
										
											2013-05-07 16:09:51 -07:00
										 |  |  | 	QGraphicsLineItem *separator; | 
					
						
							|  |  |  | 	QGraphicsSimpleTextItem *title; | 
					
						
							| 
									
										
										
										
											2013-06-07 22:49:57 -03:00
										 |  |  | 	Status status; | 
					
						
							| 
									
										
										
										
											2013-05-07 15:44:54 -03:00
										 |  |  | 	QRectF rectangle; | 
					
						
							| 
									
										
										
										
											2013-07-05 15:33:50 +03:00
										 |  |  | 	QRectF nextRectangle; | 
					
						
							| 
									
										
										
										
											2013-05-07 15:44:54 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-25 02:07:07 +02:00
										 |  |  | class RulerItem; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class RulerNodeItem : public QObject, public QGraphicsEllipseItem | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | 	friend class RulerItem; | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	explicit RulerNodeItem(QGraphicsItem* parent, graphics_context gc); | 
					
						
							|  |  |  | 	void setRuler(RulerItem *r); | 
					
						
							|  |  |  | 	void recalculate(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | 	QVariant itemChange(GraphicsItemChange change, const QVariant & value ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	graphics_context gc; | 
					
						
							|  |  |  | 	struct plot_data *entry; | 
					
						
							|  |  |  | 	RulerItem* ruler; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class RulerItem : public QGraphicsObject | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	explicit RulerItem(QGraphicsItem* parent, | 
					
						
							|  |  |  | 			   RulerNodeItem *sourceMarker, | 
					
						
							|  |  |  | 			   RulerNodeItem *destMarker); | 
					
						
							|  |  |  | 	void recalculate(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	RulerNodeItem* sourceNode() const; | 
					
						
							|  |  |  | 	RulerNodeItem* destNode() const; | 
					
						
							|  |  |  | 	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * widget = 0); | 
					
						
							|  |  |  | 	QRectF boundingRect() const; | 
					
						
							|  |  |  | 	QPainterPath shape() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	QPointF startPoint, endPoint; | 
					
						
							|  |  |  | 	RulerNodeItem *source, *dest; | 
					
						
							|  |  |  | 	QString text; | 
					
						
							|  |  |  | 	int height; | 
					
						
							|  |  |  | 	int paint_direction; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-04 23:53:53 -02:00
										 |  |  | class EventItem : public QGraphicsPixmapItem | 
					
						
							| 
									
										
										
										
											2013-05-07 16:12:01 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-05-07 16:09:51 -07:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2013-11-19 23:37:45 -02:00
										 |  |  | 	explicit EventItem(struct event *ev, QGraphicsItem* parent = 0, bool grayscale = FALSE); | 
					
						
							|  |  |  | 	struct event* ev; | 
					
						
							| 
									
										
										
										
											2013-05-07 16:09:51 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	QString text; | 
					
						
							| 
									
										
										
										
											2013-07-13 18:18:26 +03:00
										 |  |  | 	bool isGrayscale; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	QColor getColor(const color_indice_t i); | 
					
						
							| 
									
										
										
										
											2013-05-07 16:09:51 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-10 19:02:06 -03:00
										 |  |  | class GraphicsTextEditor : public QGraphicsTextItem{ | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2013-10-15 04:37:31 -07:00
										 |  |  | 	GraphicsTextEditor(QGraphicsItem* parent = 0); | 
					
						
							| 
									
										
										
										
											2013-06-10 19:02:06 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							| 
									
										
										
										
											2013-10-15 04:37:31 -07:00
										 |  |  | 	virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event); | 
					
						
							|  |  |  | 	virtual void keyReleaseEvent(QKeyEvent* event); | 
					
						
							| 
									
										
										
										
											2013-06-10 19:02:06 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | signals: | 
					
						
							|  |  |  | 	void textChanged(const QString& text); | 
					
						
							|  |  |  | 	void editingFinished(const QString& text); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-07 16:12:01 -07:00
										 |  |  | class ProfileGraphicsView : public QGraphicsView | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-05-04 16:12:43 -03:00
										 |  |  | Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2013-06-10 17:33:46 -03:00
										 |  |  | 	enum Mode{DIVE, PLAN}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-04 16:12:43 -03:00
										 |  |  | 	ProfileGraphicsView(QWidget* parent = 0); | 
					
						
							| 
									
										
										
										
											2013-05-26 11:33:45 -07:00
										 |  |  | 	void plot(struct dive *d, bool forceRedraw = FALSE); | 
					
						
							| 
									
										
										
										
											2013-05-08 07:22:23 -03:00
										 |  |  | 	bool eventFilter(QObject* obj, QEvent* event); | 
					
						
							| 
									
										
										
										
											2013-05-16 16:00:33 -03:00
										 |  |  | 	void clear(); | 
					
						
							| 
									
										
										
										
											2013-07-13 17:02:06 +03:00
										 |  |  | 	void setPrintMode(bool mode, bool grayscale = FALSE); | 
					
						
							| 
									
										
										
										
											2013-05-04 16:12:43 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | 	void resizeEvent(QResizeEvent *event); | 
					
						
							| 
									
										
										
										
											2013-05-22 21:25:05 -07:00
										 |  |  | 	void mouseMoveEvent(QMouseEvent* event); | 
					
						
							|  |  |  | 	void wheelEvent(QWheelEvent* event); | 
					
						
							|  |  |  | 	void showEvent(QShowEvent* event); | 
					
						
							| 
									
										
										
										
											2013-11-19 23:03:18 -02:00
										 |  |  | 	void contextMenuEvent(QContextMenuEvent* event); | 
					
						
							| 
									
										
										
										
											2013-05-04 16:12:43 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-19 10:20:16 -07:00
										 |  |  | public slots: | 
					
						
							| 
									
										
										
										
											2013-05-26 11:33:45 -07:00
										 |  |  | 	void refresh(); | 
					
						
							| 
									
										
										
										
											2013-06-10 19:35:22 -03:00
										 |  |  | 	void edit_dive_time(const QString& time); | 
					
						
							| 
									
										
										
										
											2013-09-25 02:39:21 +02:00
										 |  |  | 	void on_rulerAction(); | 
					
						
							|  |  |  | 	void on_scaleAction(); | 
					
						
							| 
									
										
										
										
											2013-11-19 23:03:18 -02:00
										 |  |  | 	void changeGas(); | 
					
						
							|  |  |  | 	void hideEvents(); | 
					
						
							| 
									
										
										
										
											2013-12-18 21:55:53 +00:00
										 |  |  | 	void unhideEvents(); | 
					
						
							| 
									
										
										
										
											2013-11-19 23:03:18 -02:00
										 |  |  | 	void removeEvent(); | 
					
						
							|  |  |  | 	void addBookmark(); | 
					
						
							| 
									
										
										
										
											2013-05-04 19:20:49 -03:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2013-05-08 14:56:06 -07:00
										 |  |  | 	void plot_depth_profile(); | 
					
						
							| 
									
										
										
										
											2013-07-01 15:21:01 +03:00
										 |  |  | 	QGraphicsItemGroup *plot_text(text_render_options_t *tro, const QPointF& pos, const QString &text, QGraphicsItem *parent = 0); | 
					
						
							| 
									
										
										
										
											2013-05-08 14:56:06 -07:00
										 |  |  | 	void plot_events(struct divecomputer *dc); | 
					
						
							|  |  |  | 	void plot_one_event(struct event *event); | 
					
						
							|  |  |  | 	void plot_temperature_profile(); | 
					
						
							| 
									
										
										
										
											2013-10-11 18:52:38 +02:00
										 |  |  | 	void plot_cylinder_pressure(); | 
					
						
							| 
									
										
										
										
											2013-05-09 15:28:50 -03:00
										 |  |  | 	void plot_temperature_text(); | 
					
						
							|  |  |  | 	void plot_single_temp_text(int sec, int mkelvin); | 
					
						
							| 
									
										
										
										
											2013-05-09 15:37:43 -03:00
										 |  |  | 	void plot_depth_text(); | 
					
						
							|  |  |  | 	void plot_text_samples(); | 
					
						
							|  |  |  | 	void plot_depth_sample(struct plot_data *entry, text_render_options_t *tro); | 
					
						
							| 
									
										
										
										
											2013-05-09 15:42:38 -03:00
										 |  |  | 	void plot_cylinder_pressure_text(); | 
					
						
							| 
									
										
										
										
											2013-05-10 08:56:56 -07:00
										 |  |  | 	void plot_pressure_value(int mbar, int sec, double xalign, double yalign); | 
					
						
							| 
									
										
										
										
											2013-05-31 16:21:39 +10:00
										 |  |  | 	void plot_gas_value(int mbar, int sec, double xalign, double yalign, int o2, int he); | 
					
						
							| 
									
										
										
										
											2013-05-09 15:47:39 -03:00
										 |  |  | 	void plot_deco_text(); | 
					
						
							| 
									
										
										
										
											2013-06-13 19:52:30 +02:00
										 |  |  | 	void plot_add_line(int sec, double val, QColor c, QPointF &from); | 
					
						
							| 
									
										
										
										
											2013-05-09 15:47:39 -03:00
										 |  |  | 	void plot_pp_gas_profile(); | 
					
						
							| 
									
										
										
										
											2013-05-09 17:30:16 -03:00
										 |  |  | 	void plot_pp_text(); | 
					
						
							| 
									
										
										
										
											2013-05-09 18:02:52 -03:00
										 |  |  | 	void plot_depth_scale(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-25 02:39:21 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-01 09:33:39 -04:00
										 |  |  | 	void addControlItems(struct dive *d); | 
					
						
							| 
									
										
										
										
											2013-09-25 02:39:21 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-25 02:07:07 +02:00
										 |  |  | 	void create_ruler(); | 
					
						
							|  |  |  | 	void add_ruler(); | 
					
						
							|  |  |  | 	void remove_ruler(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-13 18:18:26 +03:00
										 |  |  | 	QColor getColor(const color_indice_t i); | 
					
						
							| 
									
										
										
										
											2013-05-09 00:24:03 -03:00
										 |  |  | 	QColor get_sac_color(int sac, int avg_sac); | 
					
						
							| 
									
										
										
										
											2013-07-04 23:55:27 +03:00
										 |  |  | 	void scrollViewTo(const QPoint pos); | 
					
						
							| 
									
										
										
										
											2013-12-03 18:27:44 -02:00
										 |  |  | 	void createPPLegend(QString tr, const QColor& c, QPointF& legendPos); | 
					
						
							| 
									
										
										
										
											2013-05-04 20:18:16 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	QPen defaultPen; | 
					
						
							|  |  |  | 	QBrush defaultBrush; | 
					
						
							| 
									
										
										
										
											2013-05-07 15:44:54 -03:00
										 |  |  | 	ToolTipItem *toolTip; | 
					
						
							| 
									
										
										
										
											2013-05-08 14:56:06 -07:00
										 |  |  | 	graphics_context gc; | 
					
						
							| 
									
										
										
										
											2013-05-09 19:59:55 -03:00
										 |  |  | 	struct dive *dive; | 
					
						
							| 
									
										
										
										
											2013-05-22 20:31:27 -07:00
										 |  |  | 	struct divecomputer *diveDC; | 
					
						
							| 
									
										
										
										
											2013-05-10 11:45:07 -03:00
										 |  |  | 	int zoomLevel; | 
					
						
							| 
									
										
										
										
											2013-09-25 02:07:07 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	bool rulerEnabled; | 
					
						
							| 
									
										
										
										
											2013-07-12 17:20:59 +03:00
										 |  |  | 	bool printMode; | 
					
						
							| 
									
										
										
										
											2013-07-13 17:02:06 +03:00
										 |  |  | 	bool isGrayscale; | 
					
						
							| 
									
										
										
										
											2013-05-10 13:57:36 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Top Level Items.
 | 
					
						
							|  |  |  | 	QGraphicsItem* profileGrid; | 
					
						
							|  |  |  | 	QGraphicsItem* timeMarkers; | 
					
						
							|  |  |  | 	QGraphicsItem* depthMarkers; | 
					
						
							|  |  |  | 	QGraphicsItem* diveComputer; | 
					
						
							| 
									
										
										
										
											2013-09-25 02:07:07 +02:00
										 |  |  | 	RulerItem *rulerItem; | 
					
						
							| 
									
										
										
										
											2013-09-25 02:39:21 +02:00
										 |  |  | 	QGraphicsProxyWidget *toolBarProxy; | 
					
						
							| 
									
										
										
										
											2013-06-10 17:33:46 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-10 19:02:06 -03:00
										 |  |  | 	// For 'Plan' mode.:
 | 
					
						
							|  |  |  | 	GraphicsTextEditor *depthEditor; | 
					
						
							|  |  |  | 	GraphicsTextEditor *timeEditor; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-10 17:33:46 -03:00
										 |  |  | 	enum Mode mode; | 
					
						
							| 
									
										
										
										
											2013-05-04 16:12:43 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 |