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


C++ Series::GetColor方法代码示例

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


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

示例1: DrawCurrentValues

void LineChart::DrawCurrentValues(wxMemoryDC &dc, size_t dataIndex, int x, int y){
	int currentOffset = 0;
	wxFont labelFont = GetFont();
	int labelWidth,labelHeight,descent,externalLeading;

	for (SeriesMap::iterator it = m_seriesMap.begin(); it != m_seriesMap.end(); ++it){

		Series *series = it->second;
		double dataValue = series->GetValueAtOrNear(dataIndex);
		wxString numberFormat = "% 2." + wxString::Format("%df", series->GetPrecision());
		wxString valueString = (DatalogValue::NULL_VALUE == dataValue ? "---" : wxString::Format(numberFormat.ToAscii(), dataValue)) + " " + series->GetLabel();
		dc.SetTextForeground(series->GetColor());
		dc.GetTextExtent(valueString, &labelHeight, &labelWidth, &descent, &externalLeading, &labelFont);

		dc.DrawRotatedText(valueString, x + CURRENT_VALUES_RIGHT_OFFSET, y + currentOffset,0);
		currentOffset += labelWidth;
	}
}
开发者ID:BMWPower,项目名称:RaceAnalyzer,代码行数:18,代码来源:lineChart.cpp

示例2: DrawScale

int LineChart::DrawScale(wxMemoryDC &dc){
	int leftOrientationEdge = 0;
	int rightOrientationEdge = _currentWidth - 1;

	int scaleOrientation = LineChart::ORIENTATION_LEFT;

	wxFont labelFont = GetFont();



	int tickLabelWidth = 0;
	for (SeriesMap::iterator it = m_seriesMap.begin(); it != m_seriesMap.end(); ++it){

		int maxLabelWidth = 0;
		Series *series = it->second;
		Range * range = m_rangeArray[series->GetRangeId()];


		double minValue = range->GetMin();
		double maxValue = range->GetMax();
		double rangeSize = maxValue - minValue;
		double stepInterval = (maxValue - minValue) / 10;
		if (stepInterval == 0) stepInterval = 1;

		dc.SetPen(*wxThePenList->FindOrCreatePen(series->GetColor(), 1, wxSOLID));

		dc.SetTextForeground(series->GetColor());

		bool labelOn = false;
		int tickLabelHeight,tickDescent,tickExternalLeading;
		dc.DrawLine(leftOrientationEdge, 0, leftOrientationEdge, _currentHeight);

		for (double tick = minValue; tick <=maxValue; tick += stepInterval){

			int y = _currentHeight - (double)_currentHeight * ((tick - minValue) / rangeSize);
			int nextY = _currentHeight - (double)_currentHeight * ((tick + stepInterval - minValue) / rangeSize);

			if (labelOn){
				wxString numberFormat = "%." + wxString::Format("%df", range->GetPrecision());
				wxString tickLabel = wxString::Format(numberFormat, tick);
				dc.GetTextExtent(tickLabel, &tickLabelHeight, &tickLabelWidth, &tickDescent, &tickExternalLeading, &labelFont);
				if (tickLabelHeight > maxLabelWidth) maxLabelWidth = tickLabelHeight;

				if (tickLabelWidth < y - nextY ){
					switch (scaleOrientation){
						case LineChart::ORIENTATION_LEFT:
						{
							dc.DrawRotatedText(tickLabel, leftOrientationEdge, y, 0);
							break;
						}
						case LineChart::ORIENTATION_RIGHT:
						{
							dc.DrawRotatedText(tickLabel, rightOrientationEdge, y, 0);
							break;
						}
					}
				}
			}
			labelOn = !labelOn;
			dc.DrawLine(leftOrientationEdge, y, leftOrientationEdge + tickLabelWidth, y);
		}

		maxLabelWidth+=(tickLabelWidth / 2);
		switch (scaleOrientation){
			case LineChart::ORIENTATION_LEFT:
			{
				leftOrientationEdge += (maxLabelWidth);
				break;
			}
			case LineChart::ORIENTATION_RIGHT:
			{
				rightOrientationEdge -= (maxLabelWidth);
				break;
			}
		}
	}
	return leftOrientationEdge;
}
开发者ID:BMWPower,项目名称:RaceAnalyzer,代码行数:78,代码来源:lineChart.cpp

示例3: OnPaint

void LineChart::OnPaint(wxPaintEvent &event){

	wxPaintDC old_dc(this);

	float zoomFactor = (float)_zoomPercentage / 100;

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

	if (w != _currentWidth || h != _currentHeight){
		delete (_memBitmap);
		_currentWidth = w;
		_currentHeight = h;
		_memBitmap = new wxBitmap(_currentWidth, _currentHeight);
	}
	/////////////////
	// Create a memory DC
	wxMemoryDC dc;
	dc.SelectObject(*_memBitmap);

	wxColor backColor = GetBackgroundColour();
	dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(backColor,wxSOLID));
	dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(backColor,wxSOLID));
	dc.Clear();
	DrawGrid(dc);

	if (m_showScale){
		m_leftEdge = DrawScale(dc);
	}
	else{
		m_leftEdge = 0;
	}

	size_t largestBufferSize = GetMaxSeriesBufferSize();
	double lastValue = 0;
	for (SeriesMap::iterator it = m_seriesMap.begin(); it != m_seriesMap.end(); ++it){

		float currentX = (float)m_leftEdge;
		int lastX = (int)currentX;
		int lastY;

		Series *series = it->second;
		dc.SetPen(*wxThePenList->FindOrCreatePen(series->GetColor(), 1, wxSOLID));
		size_t bufSize = series->GetBufferSize();
		Range *range = m_rangeArray[series->GetRangeId()];
		if (bufSize > 0){

			double minValue = range->GetMin();
			double maxValue = range->GetMax();

			double loggedValue = series->GetValueAt(0);

			double percentageOfMax = (loggedValue - minValue) / (maxValue - minValue);
			lastY = h - (int)(((double)h) * percentageOfMax);

			size_t i = (size_t)(((double)largestBufferSize) * m_viewOffsetFactor);

			while (i < bufSize && currentX < _currentWidth ){
				if (i == m_markerIndex){
					wxPen pen = dc.GetPen();
					dc.SetPen(*wxThePenList->FindOrCreatePen(*wxLIGHT_GREY, 1, wxSOLID));
					dc.DrawLine(currentX, 0, currentX, _currentHeight);
					DrawCurrentValues(dc, i, currentX, CURRENT_VALUES_TOP_OFFSET);
					dc.SetPen(pen);
				}

				loggedValue = series->GetValueAt(i);

				if (DatalogValue::NULL_VALUE == loggedValue){
					loggedValue = lastValue;
				}
				else{
					lastValue = loggedValue;
				}

				double percentageOfMax = (loggedValue - minValue) / (maxValue - minValue);

				int y = h - (int)(((double)h) * percentageOfMax);

				dc.DrawLine(lastX, lastY, (int)currentX, y);
				lastX = (int)currentX;
				lastY = y;
				currentX += zoomFactor;
				i++;
			}
		}
	}
	if (m_showData) DrawMouseoverMarker(dc);
	//blit into the real DC
	old_dc.Blit(0,0,_currentWidth,_currentHeight,&dc,0,0);

}
开发者ID:BMWPower,项目名称:RaceAnalyzer,代码行数:92,代码来源:lineChart.cpp


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