예제 #1
0
void draw()
{
	background(224,224,224,255);
	//background(pLightGray);
	//background(aliceblue);

	// plot area as white box
	fill(255);
	rectMode(CORNERS);
	noStroke();
	rect(plotX1, plotY1, plotX2, plotY2);

	drawTitle();

	// plot the actual columnar data
	stroke(0x56, 0x79, 0xc1, 255);
	strokeWeight(5);
	drawDataPoints(currentColumn);

	drawYearLabels();
	drawVolumeLabels();
	drawAxisLabels();
}
예제 #2
0
파일: plot.cpp 프로젝트: zhgn/scigraphics
void scigraphics::plot::replot()
{
  if ( getDrawer() == NULL )
    throw std::runtime_error( "Drawer is not initialized" );

  prepareForPainting();

  clearPlotArea();
  drawGraphicsUnderGrid();
  drawGrid();
  drawGraphicsOverGrid();
  drawSelections();
  
  clearBorders();
  drawAxis();
  drawAxisTicks();
  drawAxisLabels();
  drawAxisTitles();
  drawFloatRectangles();
  drawZoomRectangle();

  flush();
}
예제 #3
0
	void GraphPlotter::updateVertexArrays() {
		if (!valid)
		{
			Engine::out(Engine::ERROR) << "[GraphPlotter] no valid graph set!" << std::endl;
			return;
		}

		if (g.AxisSize.x <= 0 || g.AxisSize.y <= 0)
		{
			Engine::out(Engine::ERROR) << "[GraphPlotter] Invalid Settings ( AxisSize < 0 ) !" << std::endl;
			return;
		}

		if (g.AxesPoints.x <= 0 || g.AxesPoints.y <= 0)
		{
			Engine::out(Engine::ERROR) << "[GraphPlotter] Invalid Settings ( AxesPoints < 0 ) !" << std::endl;
			return;
		}

		if (g.MinPointDist <= 0)
		{
			Engine::out(Engine::ERROR) << "[GraphPlotter] Invalid Settings ( MinPointDist < 0 ) !" << std::endl;
			return;
		}

		if (g.Size.x <= 0 || g.Size.y <= 0)
		{
			Engine::out(Engine::ERROR) << "[GraphPlotter] Invalid Settings ( Size < 0 ) !" << std::endl;
			return;
		}

		RenderArrays.clear();
		AxisLabels.clear();
		Legend.clear();
		Axes.clear();
		Axes.setPrimitiveType(sf::Lines);
		RenderArrays.insert(RenderArrays.end(), 2 + g.Curves.size(), sf::VertexArray());
		for (sf::VertexArray& vA : RenderArrays)
		{
			vA.clear();
			vA.setPrimitiveType(sf::Lines);
		}

		boost::mutex::scoped_lock data_mutex_lock(data_mutex);

		glm::ipoint2 maximas = g.getMaximas();

		dynScaleAxes(maximas);
		if (g.AxisStart.x > maximas.x) g.AxisStart.x = maximas.x;
		//if ( g.AxisStart.x < 0) g.AxisStart.x = maximas.x + g.AxisStart.x;

		if (g.AxisStart.y > maximas.y) g.AxisStart.y = maximas.y;
		//if ( g.AxisStart.y < 0) g.AxisStart.y = maximas.y + g.AxisStart.y;


		if (g.AxisSize.x <= 0 || g.AxisSize.y <= 0)
		{
			Engine::out(Engine::ERROR) << "[GraphPlotter] Invalid Settings ( AxisSize < 0 ) !" << std::endl;
			//printSettings();
			return;
		}

		if (g.drawLegend) drawLegend();
		if (g.drawAxisLabels) drawAxisLabels();
		if (g.drawAxes) drawAxes();

		for (unsigned int i = 0; i < g.Curves.size(); ++i)
		{
			drawCurve(g.Curves[i], RenderArrays[i]);
		}
	}