mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Plotting depth text.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
		
							parent
							
								
									c62e8e5baa
								
							
						
					
					
						commit
						d6d1a10195
					
				
					 3 changed files with 60 additions and 52 deletions
				
			
		|  | @ -246,7 +246,7 @@ void ProfileGraphicsView::plot(struct dive *dive) | |||
| 	/* Text on top of all graphs.. */ | ||||
| 	plot_temperature_text(); | ||||
| 
 | ||||
| 	plot_depth_text(gc, pi); | ||||
| 	plot_depth_text(); | ||||
| 
 | ||||
| #if 0 | ||||
| 	plot_cylinder_pressure_text(gc, pi); | ||||
|  | @ -292,6 +292,61 @@ void ProfileGraphicsView::plot(struct dive *dive) | |||
| #endif | ||||
| } | ||||
| 
 | ||||
| void ProfileGraphicsView::plot_depth_text() | ||||
| { | ||||
| 	int maxtime, maxdepth; | ||||
| 
 | ||||
| 	/* Get plot scaling limits */ | ||||
| 	maxtime = get_maxtime(&gc.pi); | ||||
| 	maxdepth = get_maxdepth(&gc.pi); | ||||
| 
 | ||||
| 	gc.leftx = 0; gc.rightx = maxtime; | ||||
| 	gc.topy = 0; gc.bottomy = maxdepth; | ||||
| 
 | ||||
| 	plot_text_samples(); | ||||
| } | ||||
| 
 | ||||
| void ProfileGraphicsView::plot_text_samples() | ||||
| { | ||||
| 	static text_render_options_t deep = {14, SAMPLE_DEEP, CENTER, TOP}; | ||||
| 	static text_render_options_t shallow = {14, SAMPLE_SHALLOW, CENTER, BOTTOM}; | ||||
| 	int i; | ||||
| 	int last = -1; | ||||
| 
 | ||||
| 	struct plot_info* pi = &gc.pi; | ||||
| 
 | ||||
| 	for (i = 0; i < pi->nr; i++) { | ||||
| 		struct plot_data *entry = pi->entry + i; | ||||
| 
 | ||||
| 		if (entry->depth < 2000) | ||||
| 			continue; | ||||
| 
 | ||||
| 		if ((entry == entry->max[2]) && entry->depth != last) { | ||||
| 			plot_depth_sample(entry, &deep); | ||||
| 			last = entry->depth; | ||||
| 		} | ||||
| 
 | ||||
| 		if ((entry == entry->min[2]) && entry->depth != last) { | ||||
| 			plot_depth_sample(entry, &shallow); | ||||
| 			last = entry->depth; | ||||
| 		} | ||||
| 
 | ||||
| 		if (entry->depth != last) | ||||
| 			last = -1; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void ProfileGraphicsView::plot_depth_sample(struct plot_data *entry,text_render_options_t *tro) | ||||
| { | ||||
| 	int sec = entry->sec, decimals; | ||||
| 	double d; | ||||
| 
 | ||||
| 	d = get_depth_units(entry->depth, &decimals, NULL); | ||||
| 
 | ||||
| 	plot_text(tro, sec, entry->depth, QString("%1").arg(d)); // , decimals, d);
 | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void ProfileGraphicsView::plot_temperature_text() | ||||
| { | ||||
| 	int i; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue