当前位置: 首页>>代码示例>>C++>>正文


C++ wxGraphicsContext::StrokeLine方法代码示例

本文整理汇总了C++中wxGraphicsContext::StrokeLine方法的典型用法代码示例。如果您正苦于以下问题:C++ wxGraphicsContext::StrokeLine方法的具体用法?C++ wxGraphicsContext::StrokeLine怎么用?C++ wxGraphicsContext::StrokeLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wxGraphicsContext的用法示例。


在下文中一共展示了wxGraphicsContext::StrokeLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawGrid

void ElementCanvasWindow::DrawGrid(wxGraphicsContext &gc)
{
    wxPen pen(wxColor(0x7F, 0x7F, 0x7F), 1);
    gc.SetPen(pen);
    for (size_t i = 0; i < 20; i += 10)
    {
        gc.StrokeLine(i, 0, i, 20);
    }
}
开发者ID:Kvaz1r,项目名称:wxCharts,代码行数:9,代码来源:elementcanvaswindow.cpp

示例2: DrawYAxisVals

void GCDCGraphs::DrawYAxisVals(wxGraphicsContext& dc) {
	Draw* draw = m_draws_wdg->GetSelectedDraw();
	if (draw == NULL) 
		return;
	DrawInfo *di = draw->GetDrawInfo();

	if (!di->IsValid())
		return;

	double min = di->GetMin();
	double max = di->GetMax();
	if( max <= min  ) {
		// FIXME:  Draw3 should atomaticly detect axes in that case, but
		//         it currently doesnt :(
		wxLogWarning(_T("Parameter %s has invalid min/max values: min %f, max %f. Min is set to 0, and max to 100."), di->GetName().c_str(), min, max);
		min = 0;
		max = 100;
	}

	//procedure for calculating distance between marks stolen from SzarpDraw2
	double x = max - min;
	double step;
	int i = 0;

	if (x < 1)
		for (;x < 1; x *=10, --i);
	else
		for (;(int)x / 10; x /=10, ++i);

	if (x <= 1.5)
		step = .1;
	else if (x <= 3.)
		step = .2;
	else if (x <= 7.5)
		step = .5;
	else
		step = 1.;

	double acc = 1;

	int prec = di->GetPrec();
				
	for (int p = prec; p > 0; --p)
		acc /= 10;

	double factor  = (i > 0) ? 10 : .1;

	for (;i; i -= i / abs(i))
		step *= factor;

	if (step < acc)
		step = acc;

    	dc.SetPen(wxPen(*wxWHITE, 1, wxSOLID));

	int w, h;
	GetClientSize(&w, &h);

	h -= m_screen_margins.bottommargin + m_screen_margins.topmargin;

	for (double val = max; (min - val) < acc; val -= step) {

		int y = GetY(val, di);

		dc.StrokeLine(m_screen_margins.leftmargin - 8, y, m_screen_margins.leftmargin, y);

		wxString sval = di->GetValueStr(val, _T("- -"));
		double textw, texth, textd, textel;
		dc.GetTextExtent(sval, &textw, &texth, &textd, &textel);
		dc.DrawText(sval, m_screen_margins.leftmargin - textw - 1, y + 2);
	}

}
开发者ID:,项目名称:,代码行数:73,代码来源:


注:本文中的wxGraphicsContext::StrokeLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。