本文整理汇总了C++中Series::GetRangeId方法的典型用法代码示例。如果您正苦于以下问题:C++ Series::GetRangeId方法的具体用法?C++ Series::GetRangeId怎么用?C++ Series::GetRangeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Series
的用法示例。
在下文中一共展示了Series::GetRangeId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}