mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Make the planner actually work.
This commit makes the planner actually work. There ar still a few edges, but oh, joy - the new Profile gave a very unexpected and nice addition to it - Grab the last handler of the initial dive, and move it to the right, or get any handler, and move it to the bottom to see what I mean. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									e1dcd8eac3
								
							
						
					
					
						commit
						ea4d4ac020
					
				
					 4 changed files with 34 additions and 36 deletions
				
			
		|  | @ -480,36 +480,6 @@ void DivePlannerGraphics::mouseMoveEvent(QMouseEvent *event) | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void DivePlannerGraphics::moveActiveHandler(const QPointF &mappedPos, const int pos) |  | ||||||
| { |  | ||||||
| #if 0 |  | ||||||
| 	divedatapoint data = plannerModel->at(pos); |  | ||||||
| 	int mintime = 0, maxtime = (timeLine->maximum() + 10) * 60; |  | ||||||
| 	if (pos > 0) |  | ||||||
| 		mintime = plannerModel->at(pos - 1).time; |  | ||||||
| 	if (pos < plannerModel->size() - 1) |  | ||||||
| 		maxtime = plannerModel->at(pos + 1).time; |  | ||||||
| 
 |  | ||||||
| 	int minutes = rint(timeLine->valueAt(mappedPos)); |  | ||||||
| 	if (minutes * 60 <= mintime || minutes * 60 >= maxtime) |  | ||||||
| 		return; |  | ||||||
| 
 |  | ||||||
| 	int milimeters = rint(depthLine->valueAt(mappedPos) / M_OR_FT(1, 1)) * M_OR_FT(1, 1); |  | ||||||
| 	double xpos = timeLine->posAtValue(minutes); |  | ||||||
| 	double ypos = depthLine->posAtValue(milimeters); |  | ||||||
| 
 |  | ||||||
| 	data.depth = milimeters; |  | ||||||
| 	data.time = rint(timeLine->valueAt(mappedPos)) * 60; |  | ||||||
| 
 |  | ||||||
| 	plannerModel->editStop(pos, data); |  | ||||||
| 
 |  | ||||||
| 	activeDraggedHandler->setPos(QPointF(xpos, ypos)); |  | ||||||
| 	qDeleteAll(lines); |  | ||||||
| 	lines.clear(); |  | ||||||
| 	drawProfile(); |  | ||||||
| #endif |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void DivePlannerGraphics::mousePressEvent(QMouseEvent *event) | void DivePlannerGraphics::mousePressEvent(QMouseEvent *event) | ||||||
| { | { | ||||||
| 	if (event->modifiers()) { | 	if (event->modifiers()) { | ||||||
|  | @ -586,12 +556,13 @@ void DiveHandler::changeGas() | ||||||
| 	plannerModel->setData(index, action->text()); | 	plannerModel->setData(index, action->text()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| QVariant DiveHandler::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) | void DiveHandler::mouseMoveEvent(QGraphicsSceneMouseEvent *event) | ||||||
| { | { | ||||||
| 	if (change == ItemPositionHasChanged && scene()) { | 	ProfileWidget2 *view = qobject_cast<ProfileWidget2*>(scene()->views().first()); | ||||||
|  | 	if(view->isPointOutOfBoundaries(event->scenePos())) | ||||||
|  | 		return; | ||||||
|  | 	QGraphicsEllipseItem::mouseMoveEvent(event); | ||||||
| 	emit moved(); | 	emit moved(); | ||||||
| 	} |  | ||||||
| 	return QGraphicsItem::itemChange(change, value); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Button::Button(QObject *parent, QGraphicsItem *itemParent) : QObject(parent), | Button::Button(QObject *parent, QGraphicsItem *itemParent) : QObject(parent), | ||||||
|  |  | ||||||
|  | @ -140,7 +140,7 @@ public: | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); | 	void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); | ||||||
| 	virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); | 	void mouseMoveEvent(QGraphicsSceneMouseEvent *event); | ||||||
| signals: | signals: | ||||||
| 	void moved(); | 	void moved(); | ||||||
| private: | private: | ||||||
|  |  | ||||||
|  | @ -964,6 +964,7 @@ void ProfileWidget2::pointInserted(const QModelIndex &parent, int start, int end | ||||||
| 	scene()->addItem(item); | 	scene()->addItem(item); | ||||||
| 	handles << item; | 	handles << item; | ||||||
| 
 | 
 | ||||||
|  | 	connect(item, SIGNAL(moved()), this, SLOT(recreatePlannedDive())); | ||||||
| 	QGraphicsSimpleTextItem *gasChooseBtn = new QGraphicsSimpleTextItem(); | 	QGraphicsSimpleTextItem *gasChooseBtn = new QGraphicsSimpleTextItem(); | ||||||
| 	scene()->addItem(gasChooseBtn); | 	scene()->addItem(gasChooseBtn); | ||||||
| 	gasChooseBtn->setZValue(10); | 	gasChooseBtn->setZValue(10); | ||||||
|  | @ -1007,3 +1008,26 @@ void ProfileWidget2::repositionDiveHandlers() | ||||||
| 		last = i; | 		last = i; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | void ProfileWidget2::recreatePlannedDive() | ||||||
|  | { | ||||||
|  | 	DiveHandler *activeHandler = qobject_cast<DiveHandler*>(sender()); | ||||||
|  | 	DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); | ||||||
|  | 	int index = handles.indexOf(activeHandler); | ||||||
|  | 
 | ||||||
|  | 	int mintime = 0, maxtime = (timeAxis->maximum() + 10) * 60; | ||||||
|  | 	if (index > 0) | ||||||
|  | 		mintime = plannerModel->at(index - 1).time; | ||||||
|  | 	if (index < plannerModel->size() - 1) | ||||||
|  | 		maxtime = plannerModel->at(index + 1).time; | ||||||
|  | 
 | ||||||
|  | 	int minutes = rint(timeAxis->valueAt(activeHandler->pos()) / 60); | ||||||
|  | 	if (minutes * 60 <= mintime || minutes * 60 >= maxtime) | ||||||
|  | 		return; | ||||||
|  | 
 | ||||||
|  | 	divedatapoint data = plannerModel->at(index); | ||||||
|  | 	data.depth = rint(profileYAxis->valueAt(activeHandler->pos()) / M_OR_FT(1, 1)) * M_OR_FT(1, 1);; | ||||||
|  | 	data.time = rint(timeAxis->valueAt(activeHandler->pos())); | ||||||
|  | 
 | ||||||
|  | 	plannerModel->editStop(index, data); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -91,6 +91,9 @@ slots: // Necessary to call from QAction's signals. | ||||||
| 	void pointsRemoved(const QModelIndex &, int start, int end); | 	void pointsRemoved(const QModelIndex &, int start, int end); | ||||||
| 	void replot(); | 	void replot(); | ||||||
| 
 | 
 | ||||||
|  | 	/* this is called for every move on the handlers. maybe we can speed up this a bit? */ | ||||||
|  | 	void recreatePlannedDive(); | ||||||
|  | 
 | ||||||
| protected: | protected: | ||||||
| 	virtual void resizeEvent(QResizeEvent *event); | 	virtual void resizeEvent(QResizeEvent *event); | ||||||
| 	virtual void wheelEvent(QWheelEvent *event); | 	virtual void wheelEvent(QWheelEvent *event); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue