mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Merge branch 'PlotsV2' of https://github.com/tcanabrava/subsurface into Qt
Minor conflicts based on my cleanup of Tomaz' earlier commits. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
						commit
						1238fde17c
					
				
					 1 changed files with 60 additions and 47 deletions
				
			
		|  | @ -42,6 +42,7 @@ typedef enum { | |||
| 	CEILING_SHALLOW, CEILING_DEEP, CALC_CEILING_SHALLOW, CALC_CEILING_DEEP | ||||
| } color_indice_t; | ||||
| 
 | ||||
| 
 | ||||
| #define COLOR(x, y, z) QVector<QColor>() << x << y << z; | ||||
| /* profile_color[color indice] = COLOR(screen color, b/w printer color, color printer}} printer & screen colours could be different */ | ||||
| QMap<color_indice_t, QVector<QColor> > profile_color; | ||||
|  | @ -95,6 +96,7 @@ void fill_profile_color() | |||
| 	profile_color[CEILING_DEEP]    = COLOR(RED1_MED_TRANS, BLACK1_HIGH_TRANS, RED1_MED_TRANS); | ||||
| 	profile_color[CALC_CEILING_SHALLOW] = COLOR(FUNGREEN1_HIGH_TRANS, BLACK1_HIGH_TRANS, FUNGREEN1_HIGH_TRANS); | ||||
| 	profile_color[CALC_CEILING_DEEP]    = COLOR(APPLE1_HIGH_TRANS, BLACK1_HIGH_TRANS, APPLE1_HIGH_TRANS); | ||||
| 
 | ||||
| } | ||||
| #undef COLOR | ||||
| 
 | ||||
|  | @ -102,7 +104,7 @@ ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent | |||
| { | ||||
| 	setScene(new QGraphicsScene()); | ||||
| 	setBackgroundBrush(QColor("#F3F3E6")); | ||||
| 	scene()->setSceneRect(0,0,100,100); | ||||
| 	scene()->setSceneRect(0,0,1000,1000); | ||||
| 	fill_profile_color(); | ||||
| } | ||||
| 
 | ||||
|  | @ -348,8 +350,10 @@ void ProfileGraphicsView::plot_depth_profile(struct graphics_context *gc, struct | |||
| 
 | ||||
| 	entry = pi->entry; | ||||
| 
 | ||||
| 	QGraphicsPolygonItem *neatFill = new QGraphicsPolygonItem(); | ||||
| 	QPolygonF p; | ||||
| 	QLinearGradient pat(0.0,0.0,0.0,scene()->height()); | ||||
| 	QGraphicsPolygonItem *neatFill = NULL; | ||||
| 
 | ||||
| 	for (i = 0; i < pi->nr; i++, entry++) | ||||
| 		p.append( QPointF( SCALE(gc, entry->sec, entry->depth) )); | ||||
| 
 | ||||
|  | @ -364,79 +368,90 @@ void ProfileGraphicsView::plot_depth_profile(struct graphics_context *gc, struct | |||
| 			p.append( QPointF( SCALE(gc, entry->sec, entry->depth) )); | ||||
| 		} | ||||
| 	} | ||||
| 	neatFill->setPolygon(p); | ||||
| 	QLinearGradient pat(0.0,0.0,0.0,p.boundingRect().height()); | ||||
| 
 | ||||
| 	pat.setColorAt(1, profile_color[DEPTH_BOTTOM].first()); | ||||
| 	pat.setColorAt(0, profile_color[DEPTH_TOP].first()); | ||||
| 
 | ||||
| 	neatFill = new QGraphicsPolygonItem(); | ||||
| 	neatFill->setPolygon(p); | ||||
| 	neatFill->setBrush(QBrush(pat)); | ||||
| 	neatFill->setPen(QPen()); | ||||
| 	scene()->addItem(neatFill); | ||||
| 
 | ||||
| #if 0 | ||||
| 	/* if the user wants the deco ceiling more visible, do that here (this
 | ||||
| 	 * basically draws over the background that we had allowed to shine | ||||
| 	 * through so far) */ | ||||
| 	if (prefs.profile_red_ceiling) { | ||||
| 		pat = cairo_pattern_create_linear (0.0, 0.0,  0.0, 256.0 * plot_scale); | ||||
| 		pattern_add_color_stop_rgba (gc, pat, 0, CEILING_SHALLOW); | ||||
| 		pattern_add_color_stop_rgba (gc, pat, 1, CEILING_DEEP); | ||||
| 		cairo_set_source(gc->cr, pat); | ||||
| 		cairo_pattern_destroy(pat); | ||||
| 	// TODO: port the prefs.profile_red_ceiling to QSettings
 | ||||
| 	//if (prefs.profile_red_ceiling) {
 | ||||
| 		p.clear(); | ||||
| 		pat.setColorAt(0, profile_color[CEILING_SHALLOW].first()); | ||||
| 		pat.setColorAt(1, profile_color[CEILING_DEEP].first()); | ||||
| 
 | ||||
| 		entry = pi->entry; | ||||
| 		move_to(gc, 0, 0); | ||||
| 		for (i = 0; i < pi->nr; i++, entry++) { | ||||
| 			if (entry->ndl == 0 && entry->stopdepth) { | ||||
| 				if (entry->ndl == 0 && entry->stopdepth < entry->depth) { | ||||
| 					line_to(gc, entry->sec, entry->stopdepth); | ||||
| 					p.append( QPointF( SCALE(gc, entry->sec, entry->stopdepth) )); | ||||
| 				} else { | ||||
| 					line_to(gc, entry->sec, entry->depth); | ||||
| 					p.append( QPointF( SCALE(gc, entry->sec, entry->depth) )); | ||||
| 				} | ||||
| 			} else { | ||||
| 				line_to(gc, entry->sec, 0); | ||||
| 				p.append( QPointF( SCALE(gc, entry->sec, 0) )); | ||||
| 			} | ||||
| 		} | ||||
| 		cairo_close_path(gc->cr); | ||||
| 		cairo_fill(gc->cr); | ||||
| 	} | ||||
| 
 | ||||
| 		neatFill = new QGraphicsPolygonItem(); | ||||
| 		neatFill->setBrush(QBrush(pat)); | ||||
| 		neatFill->setPolygon(p); | ||||
| 		neatFill->setPen(QPen()); | ||||
| 		scene()->addItem(neatFill); | ||||
| 	//}
 | ||||
| 
 | ||||
| 	/* finally, plot the calculated ceiling over all this */ | ||||
| 	if (prefs.profile_calc_ceiling) { | ||||
| 		pat = cairo_pattern_create_linear (0.0, 0.0,  0.0, 256.0 * plot_scale); | ||||
| 		pattern_add_color_stop_rgba (gc, pat, 0, CALC_CEILING_SHALLOW); | ||||
| 		pattern_add_color_stop_rgba (gc, pat, 1, CALC_CEILING_DEEP); | ||||
| 		cairo_set_source(gc->cr, pat); | ||||
| 		cairo_pattern_destroy(pat); | ||||
| 	// TODO: Port the profile_calc_ceiling to QSettings
 | ||||
| 	// if (prefs.profile_calc_ceiling) {
 | ||||
| 		pat.setColorAt(0, profile_color[CALC_CEILING_SHALLOW].first()); | ||||
| 		pat.setColorAt(1, profile_color[CALC_CEILING_DEEP].first()); | ||||
| 
 | ||||
| 		entry = pi->entry; | ||||
| 		move_to(gc, 0, 0); | ||||
| 		p.clear(); | ||||
| 		p.append( QPointF(0,0)); | ||||
| 		for (i = 0; i < pi->nr; i++, entry++) { | ||||
| 			if (entry->ceiling) | ||||
| 				line_to(gc, entry->sec, entry->ceiling); | ||||
| 				p.append( QPointF( SCALE(gc, entry->sec, entry->ceiling) )); | ||||
| 			else | ||||
| 				line_to(gc, entry->sec, 0); | ||||
| 				p.append( QPointF( SCALE(gc, entry->sec, 0) )); | ||||
| 		} | ||||
| 		line_to(gc, (entry-1)->sec, 0); /* make sure we end at 0 */ | ||||
| 		cairo_close_path(gc->cr); | ||||
| 		cairo_fill(gc->cr); | ||||
| 	} | ||||
| 		p.append( QPointF( SCALE(gc, (entry-1)->sec, 0) )); | ||||
| 		neatFill = new QGraphicsPolygonItem(); | ||||
| 		neatFill->setPolygon(p); | ||||
| 		neatFill->setPen(QPen()); | ||||
| 		scene()->addItem(neatFill); | ||||
| 	//}
 | ||||
| 
 | ||||
| 	/* next show where we have been bad and crossed the dc's ceiling */ | ||||
| 	pat = cairo_pattern_create_linear (0.0, 0.0,  0.0, 256.0 * plot_scale); | ||||
| 	pattern_add_color_stop_rgba (gc, pat, 0, CEILING_SHALLOW); | ||||
| 	pattern_add_color_stop_rgba (gc, pat, 1, CEILING_DEEP); | ||||
| 	cairo_set_source(gc->cr, pat); | ||||
| 	cairo_pattern_destroy(pat); | ||||
| 	pat.setColorAt(0, profile_color[CEILING_SHALLOW].first()); | ||||
| 	pat.setColorAt(1, profile_color[CEILING_DEEP].first()); | ||||
| 
 | ||||
| 	entry = pi->entry; | ||||
| 	move_to(gc, 0, 0); | ||||
| 	p.clear(); | ||||
| 	p.append( QPointF(0,0)); | ||||
| 	for (i = 0; i < pi->nr; i++, entry++) | ||||
| 		line_to(gc, entry->sec, entry->depth); | ||||
| 		p.append( QPointF( SCALE(gc, entry->sec, entry->depth) )); | ||||
| 
 | ||||
| 	for (i = pi->nr - 1; i >= 0; i--, entry--) { | ||||
| 		if (entry->ndl == 0 && entry->stopdepth > entry->depth) { | ||||
| 			line_to(gc, entry->sec, entry->stopdepth); | ||||
| 			p.append( QPointF( SCALE(gc, entry->sec, entry->stopdepth) )); | ||||
| 		} else { | ||||
| 			line_to(gc, entry->sec, entry->depth); | ||||
| 			p.append( QPointF( SCALE(gc, entry->sec, entry->depth) )); | ||||
| 		} | ||||
| 	} | ||||
| 	cairo_close_path(gc->cr); | ||||
| 	cairo_fill(gc->cr); | ||||
| 
 | ||||
| 	neatFill = new QGraphicsPolygonItem(); | ||||
| 	neatFill->setPolygon(p); | ||||
| 	neatFill->setPen(QPen()); | ||||
| 	neatFill->setBrush(QBrush(pat)); | ||||
| 	scene()->addItem(neatFill); | ||||
| 
 | ||||
| 	/* Now do it again for the velocity colors */ | ||||
| 	entry = pi->entry; | ||||
|  | @ -447,12 +462,10 @@ void ProfileGraphicsView::plot_depth_profile(struct graphics_context *gc, struct | |||
| 		 * representing the vertical velocity, so we need to | ||||
| 		 * chop this into short segments */ | ||||
| 		depth = entry->depth; | ||||
| 		set_source_rgba(gc, VELOCITY_COLORS_START_IDX + entry->velocity); | ||||
| 		move_to(gc, entry[-1].sec, entry[-1].depth); | ||||
| 		line_to(gc, sec, depth); | ||||
| 		cairo_stroke(cr); | ||||
| 		QGraphicsLineItem *colorLine = new QGraphicsLineItem( SCALE(gc, entry[-1].sec, entry[-1].depth), SCALE(gc, sec, depth)); | ||||
| 		colorLine->setPen(QPen(QBrush(profile_color[ (color_indice_t) (VELOCITY_COLORS_START_IDX + entry->velocity)].first()), 2 )); | ||||
| 		scene()->addItem(colorLine); | ||||
| 	} | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue