Esempio n. 1
0
/**
 * Display the given vector on screen
 * @param v specific vector to display on overlay
 * @param step step of the display
 * @param height maximal height
 * @param width maximal width
 * @param color color used to display
 */
void displayASpecificHistogram(const HistogramVector& v,const HistogramVector& selection_v, const double step, const double height, const double width, const HistogramColor color,float selectionMultiplier)
{
	if(v.size())
	{
		//maximum data in the current channel vector
		const Number max_value = *(std::max_element(v.begin(),v.end()));
		const float ratio = height/max_value;
		//OpenGL 2.X
		glEnable(GL_BLEND);
		glBlendFunc(GL_ONE, GL_ONE); //additive blending active
		glColor3f(color._colorFill.r, color._colorFill.g, color._colorFill.b);
		//Display option
		glBegin( GL_QUAD_STRIP );
		double base_step = 0.0;//first point
		for(unsigned int i=0; i<v.size(); ++i)
		{
			const float value = (float)(v.at(i)*ratio);
			float selection_value = (float)(selection_v.at(i)*ratio);
			selection_value*= selectionMultiplier;
			if(selection_value > value) //if selection value is bigger than normal value replace it
				selection_value = value;
			glVertex2f((float)(base_step), (float)(value));
			glVertex2f((float)(base_step), (float)(selection_value));
			base_step += step;
		}
		glVertex2f((float)width,0.0f);//last point
		glEnd();
		glDisable(GL_BLEND);
	}
}
Esempio n. 2
0
/**
 * Display the given vector on screen (only border)
 * @param v specific vector to display on overlay
 * @param step step of the display
 * @param height maximal height
 * @param width maximal width
 * @param color color used to display
 */
void displayASpecificHistogramBorder(const HistogramVector& v, const double step, const double height, const double width, const HistogramColor color)
{
	//Draw the border line
	glBegin( GL_LINE_STRIP );
	//maximum data in the current channel vector
	const Number max_value = *(std::max_element(v.begin(),v.end()));
	const float ratio = height/max_value;
	double base_step = 0.0;
	glColor3f(color._colorBorder.r, color._colorBorder.g, color._colorBorder.b);
	for(unsigned int i=0; i<v.size(); ++i)
	{
		const float value = (float)(v.at(i)*ratio);
		glVertex2f((float)(base_step), float(value));
		base_step += step;
	}
	glEnd();
}