在包含趋势点的数组中分配指向数据的指针!! [英] Assigning a pointer to the data in an array containing Trend Points!!
本文介绍了在包含趋势点的数组中分配指向数据的指针!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
for (long trend = 1; trend <= m_Trends.GetCount(); trend++)
{
CRect rect;
float iteration_factor;
short pen(0);
CCsTrendPoint trendpoint;
CCsOpcValue DisplayMaxPoint, DisplayMinPoint;
POSITION pos;
double curtime;
rect = CRect(CPoint(0,0), m_Trends[trend-1].m_TrendRect.Size());
iteration_factor = m_TrendDurationSeconds/rect.right;
for (pen = 0; pen < m_TrendItems.GetSize(); pen++) // redraw each pen
{
pos = m_TrendItems[pen].GetTrendPoints().GetTailPosition();
if(pos)
trendpoint = m_TrendItems[pen].GetTrendPoints().GetPrev(pos);
while(pos)
{
DisplayMaxPoint.SetValue(trendpoint.m_Value);
DisplayMaxPoint.SetTimeStamp(trendpoint.m_Time);
DisplayMinPoint.SetValue(trendpoint.m_Value);
DisplayMinPoint.SetTimeStamp(trendpoint.m_Time);
curtime = (trendpoint.m_Time).GetTotalSeconds();
while(pos && ((trendpoint.m_Time).GetTotalSeconds() >= curtime) && ((trendpoint.m_Time).GetTotalSeconds() < (curtime + iteration_factor)))
{
if(trendpoint.m_Value > DisplayMaxPoint.GetFloatValue())
{
DisplayMaxPoint.SetValue(trendpoint.m_Value);
DisplayMaxPoint.SetTimeStamp(trendpoint.m_Time);
MaxPoint = trendpoint;
}
if(trendpoint.m_Value < DisplayMinPoint.GetFloatValue())
{
DisplayMinPoint.SetValue(trendpoint.m_Value);
DisplayMinPoint.SetTimeStamp(trendpoint.m_Time);
MinPoint = trendpoint;
}
trendpoint = m_TrendItems[pen].GetTrendPoints().GetPrev(pos);
}
if (pen >= m_TrendDisplayItems.GetSize())
{
m_TrendDisplayItems.SetSize(pen+1);
}
m_TrendDisplayItems[pen].AddNewPoint(DisplayMaxPoint);
m_TrendDisplayItems[pen].AddNewPoint(DisplayMinPoint);
}
}
}
我知道这是一个简单的问题.上面的方式是我将趋势数组的数据传递到新数组,但是出于传递数据的目的,我想传递趋势点的指针(MinPoint和MaxPoint),我尝试了很多方法但无法做到这一点.
所以我的问题是,如何获取最小和最大点的指针以及如何将它们放置在数组中?请帮我急!!
I know this is a simple question. The above way i was passing the data of a trend array to the new array, but instaed of passing the data, i want to pass the pointer of the trendpoint(MinPoint and MaxPoint), i tried many ways but was not able to do it.
So my question is, how can i get the pointer of the min and max point and how to put these in an array? Plz help me its urgent!!
推荐答案
您能遵循吗? :):
Can you follow ? :) :
class CCsOpcValue;
class CTrend
{
CArray<CCsOpcValue*,CCsOpcValue*> m_arDisplayItems;
..
public:
~CTrend() { RemoveDisplayItems(); };
void FillDiasplayItems(..);
void RemoveDisplayItems(int iHowMuch = -1);
void DrawDisplayItems(CDC* pcDC, const CRect& crBounds, ...);
..
};
void CTrend::FillDisplayItems(..)
{
for (..) {
CCsOpcValue* pcMin = new CCsOpcValue(this, CCsOpcValue::minItem, ..);
CCsOpcValue* pcMax = new CCsOpcValue(this, CCsOpcValue::maxItem, ..);
while (..) {
// Modifications of the values
// ..
}
m_arDisplayItems.Add(pcMin);
m_arDisplayItems.Add(pcMax);
}
}
void CTrend::RemoveDisplayItems(int iHowMuch /*= -1*/)
{
int iCount = m_arDisplayItems.GetCount();
int iUntil = (iHowMuch < 0 || iCount < iHowMuch) ?
iCount :
iHowMuch;
for (int i = 0; i < iUntil; i++) {
delete m_arDisplayItems[i];
m_arDisplayItems.RemoveAt(i);
}
}
void CTrend::DrawDisplayItems(CDC* pcDC, const CRect& crBounds, ...)
{
for (int i = 0; i < m_arDisplayItems.GetCount(); i++) {
// Check the stamps, indexes, values an draw
// ...
}
}
这篇关于在包含趋势点的数组中分配指向数据的指针!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文