CString COscillogram::GetCurveName(int nIndex) { if(!GetCurve(nIndex)) return ""; return GetCurve(nIndex)->name; }
COLORREF COscillogram::GetCurveColor(int nIndex) { COLORREF col = -1; if(GetCurve(nIndex)) col = GetCurve(nIndex)->lColor; return col; }
COLORREF COscillogram::SetCurveColor(int nIndex, COLORREF nColor) { COLORREF col = -1; if(GetCurve(nIndex)) { col = GetCurve(nIndex)->lColor; GetCurve(nIndex)->lColor = nColor; this->Invalidate(); } return col; }
void COscillogram::DrawPrint(CDC *dc, CRect *dRect) { int oldmode = dc->SetMapMode(MM_LOMETRIC); //获得网格矩形 m_GridRect.top = dRect->top - CS_MARGIN; m_GridRect.left = dRect->left + CS_MARGIN; m_GridRect.bottom = dRect->bottom + CS_MARGIN; m_GridRect.right = dRect->right - CS_MARGIN; //计算标题矩形 m_CaptionRect.top = dRect->top; m_CaptionRect.left = dRect->left; m_CaptionRect.bottom = m_GridRect.top ; m_CaptionRect.right = dRect->right; //计算步长宽度 m_xSpan = (float)m_GridRect.Width() / (m_xCount-1); m_ySpan = (float)m_GridRect.Height() / (m_yCount-1); //绘画工作 DrawCaption(dc); DrawGrid(dc); for(int i=0;i<GetCurveCount();i++) DrawCurve(dc,GetCurve(i)); dc->SetMapMode(oldmode); }
void DL_GroupParameters_EC<EC>::DEREncode(BufferedTransformation &bt) const { if (m_encodeAsOID && !m_oid.m_values.empty()) m_oid.DEREncode(bt); else { DERSequenceEncoder seq(bt); DEREncodeUnsigned<word32>(seq, 1); // version GetCurve().DEREncode(seq); GetCurve().DEREncodePoint(seq, GetSubgroupGenerator(), m_compress); m_n.DEREncode(seq); if (m_k.NotZero()) m_k.DEREncode(seq); seq.MessageEnd(); } }
void QGraph::ExportToFile(QFile &XFile, int FileType) { int i,j, maxpoints; CCurve *pCurve; QString strong; QTextStream out(&XFile); maxpoints = 0; for(i=0; i<m_oaCurves.size(); i++) { pCurve = GetCurve(i); if(pCurve) { maxpoints = qMax(maxpoints,pCurve->n); pCurve->GetTitle(strong); if(FileType==1) out << " "<<m_XTitle<<" "<< strong <<" "; else out << m_XTitle<<","<< strong << ", , "; } } out<<"\n"; //end of title line for(j=0; j<maxpoints; j++) { for(i=0; i<m_oaCurves.size(); i++) { pCurve = GetCurve(i); if(pCurve && j<pCurve->n) { if(FileType==1) strong= QString("%1 %2 ") .arg(pCurve->x[j],13,'g',7).arg(pCurve->y[j],13,'g',7); else strong= QString("%1, %2, , ") .arg(pCurve->x[j],13,'g',7).arg(pCurve->y[j],13,'g',7); } else { if(FileType==1) strong= " "; else strong= ", , , "; } out << strong; } out<<"\n"; //end of data line } out<<"\n"; //end of file XFile.close(); }
bool DL_GroupParameters_EC<EC>::ValidateGroup(RandomNumberGenerator &rng, unsigned int level) const { bool pass = GetCurve().ValidateParameters(rng, level); Integer q = GetCurve().FieldSize(); pass = pass && m_n!=q; if (level >= 2) { Integer qSqrt = q.SquareRoot(); pass = pass && m_n>4*qSqrt; pass = pass && VerifyPrime(rng, m_n, level-2); pass = pass && (m_k.IsZero() || m_k == (q+2*qSqrt+1)/m_n); pass = pass && CheckMOVCondition(q, m_n); } return pass; }
void PageConfigData::Fitcurve(double dx[],double dy[],int nNum,int nCol) { double dParam[5] = {0,0,0,0,0}; int ma = GetOrder(); Polyfit(dx,dy,nNum, dParam,ma); m_Param.SetParam(dParam,ma,nCol); UpDataCurve(GetCurve(nCol),dParam,ma); UpDataMaxFLow(dx,nNum); }
Integer DL_GroupParameters_EC<EC>::GetCofactor() const { if (!m_k) { Integer q = GetCurve().FieldSize(); Integer qSqrt = q.SquareRoot(); m_k = (q+2*qSqrt+1)/m_n; } return m_k; }
float FCurveTableRowHandle::Eval(float XValue) const { SCOPE_CYCLE_COUNTER(STAT_CurveTableRowHandleEval); FRichCurve* Curve = GetCurve(); if(Curve != NULL) { return Curve->Eval(XValue); } return 0; }
void COscillogram::DrawOscillogram(CDC *dc) { int oldmode = dc->SetMapMode(MM_LOMETRIC); SetOscillogramRect(dc); DrawCaption(dc); DrawGrid(dc); for(int i=0;i<GetCurveCount();i++) DrawCurve(dc,GetCurve(i)); dc->SetMapMode(oldmode); }
void COscillogram::AddCurveValue(int nIndex ,float val,BOOL state) { CPointValue * temp; if(GetCurve(nIndex)) temp = &GetCurve(nIndex)->ptVal; else return ; CClientDC dc(this); dc.SetBkMode(TRANSPARENT); int oldMode = dc.SetMapMode(MM_LOMETRIC); SetOscillogramRect(&dc); DrawCurve(&dc,GetCurve(nIndex)); temp->SetValue(val,state); temp->MoveNext(); DrawCurve(&dc,GetCurve(nIndex)); dc.SetMapMode(oldMode); }
bool FCurveTableRowHandle::Eval(float XValue, float* YValue) const { SCOPE_CYCLE_COUNTER(STAT_CurveTableRowHandleEval); FRichCurve* Curve = GetCurve(); if(Curve != NULL && YValue != NULL) { *YValue = Curve->Eval(XValue); return true; } return false; }
void CurvesConfig::CreateSpline(CurveChannel channel, int count, double* points) { assert(channel >= CURVE_CHANNEL_C && channel <= CURVE_CHANNEL_A); assert(count >= 2 && count <= 1024); Curve* curve = GetCurve(channel); curve->SetPointCount(count); for (int i = 0; i < count; i++) { curve->SetPoint(i, points[2 * i + 0], points[2 * i + 1]); } }
bool DL_GroupParameters_EC<EC>::ValidateElement(unsigned int level, const Element &g, const DL_FixedBasePrecomputation<Element> *gpc) const { bool pass = !IsIdentity(g) && GetCurve().VerifyPoint(g); if (level >= 1) { if (gpc) pass = pass && gpc->Exponentiate(GetGroupPrecomputation(), Integer::One()) == g; } if (level >= 2) { const Integer &q = GetSubgroupOrder(); pass = pass && IsIdentity(gpc ? gpc->Exponentiate(GetGroupPrecomputation(), q) : ExponentiateElement(g, q)); } return pass; }
void Graph::DeleteCurves() { int nIndex = (int)m_oaCurves.size(); for (int i=nIndex-1; i>=0;i--) delete GetCurve(i); m_oaCurves.clear();//removes the pointers if (m_bAutoX && !m_Type) { xmin = 0.0; xmax = 0.1; } if (m_bAutoY && !m_Type){ ymin = 0.0; ymax = 0.1; } }
BOOL COscillogram::SetXVal(LPCTSTR xText ,float minVal, float maxVal, int Count, int showCount) { if(Count<2 || showCount<2) return FALSE; m_xCount = Count; m_xShowCount = showCount; m_xMinVal = minVal; m_xMaxVal = maxVal; m_xText = xText; for(int i=0;i<GetCurveCount();i++) GetCurve(i)->ptVal.CreateLink(m_xCount); if(m_hWnd) Invalidate(); return TRUE; }
template <class EC> void DL_GroupParameters_EC<EC>::Initialize(const OID &oid) { const EcRecommendedParameters<EllipticCurve> *begin, *end; GetRecommendedParameters(begin, end); const EcRecommendedParameters<EllipticCurve> *it = std::lower_bound(begin, end, oid, OIDLessThan()); if (it == end || it->oid != oid) throw UnknownOID(); const EcRecommendedParameters<EllipticCurve> ¶m = *it; m_oid = oid; std::auto_ptr<EllipticCurve> ec(param.NewEC()); m_groupPrecomputation.SetCurve(*ec); StringSource ssG(param.g, true, new HexDecoder); Element G; bool result = GetCurve().DecodePoint(G, ssG, ssG.MaxRetrievable()); SetSubgroupGenerator(G); assert(result); StringSource ssN(param.n, true, new HexDecoder); m_n.Decode(ssN, ssN.MaxRetrievable()); m_k = param.h; }
void Graph::DeleteCurve(int index) { CCurve * pCurve = GetCurve(index); m_oaCurves.removeAt(index); delete pCurve; }
void UMovieSceneComposurePostMoveSettingsSection::SetDefault(const struct FComposurePostMoveSettingsKey& Key) { FRichCurve& Curve = GetCurve(Key.Channel, Key.Axis); SetCurveDefault(Curve, Key.Value); }
void UMovieSceneComposurePostMoveSettingsSection::AddKey(float Time, const struct FComposurePostMoveSettingsKey& Key, EMovieSceneKeyInterpolation KeyInterpolation) { FRichCurve& Curve = GetCurve(Key.Channel, Key.Axis); AddKeyToCurve(Curve, Time, Key.Value, KeyInterpolation); }
bool UMovieSceneComposurePostMoveSettingsSection::HasKeys(const struct FComposurePostMoveSettingsKey& Key) const { const FRichCurve& Curve = GetCurve(Key.Channel, Key.Axis); return Curve.GetNumKeys() != 0; }
DL_GroupParameters_EC<EC>::Element DL_GroupParameters_EC<EC>::CascadeExponentiate(const Element &element1, const Integer &exponent1, const Element &element2, const Integer &exponent2) const { return GetCurve().CascadeMultiply(exponent1, element1, exponent2, element2); }
DL_GroupParameters_EC<EC>::Element DL_GroupParameters_EC<EC>::MultiplyElements(const Element &a, const Element &b) const { return GetCurve().Add(a, b); }
void DL_GroupParameters_EC<EC>::SimultaneousExponentiate(Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const { GetCurve().SimultaneousMultiply(results, base, exponents, exponentsCount); }
IOHIDParametricAcceleration * IOHIDParametricAcceleration::CreateWithParameters (CFArrayRef curves, double acceleration, double resolution, double rate) { IOHIDParametricAcceleration * self = NULL; double accelIndex = acceleration; HIDLogDebug("acceleration %f resolution %f rate %f", accelIndex, resolution, rate); if (curves == NULL || accelIndex < 0) { return NULL; } CFArrayRefWrap cfCurves (curves); size_t currentIndex = 0; std::vector <ACCELL_CURVE> accelCurves; for (CFIndex index = 0; index < (CFIndex)cfCurves.Count(); index++) { ACCELL_CURVE curve = GetCurve ((CFDictionaryRef) cfCurves[index]); if (curve.isValid()) { accelCurves.push_back(curve); if (accelIndex >= curve.Index) { currentIndex = index; } } } if (accelCurves.size() == 0) { return self; } self = new IOHIDParametricAcceleration; if (!self) { return self; } self->resolution_ = resolution; self->rate_ = rate; self->accelIndex_ = accelIndex; HIDLogDebug("table index %zu", currentIndex); if (accelCurves[currentIndex].Index < accelIndex && (currentIndex + 1) < accelCurves.size() ) { double ratio = (accelIndex - accelCurves[currentIndex].Index) / (accelCurves[currentIndex + 1].Index - accelCurves[currentIndex ].Index); self->accel.Index = accelCurves[currentIndex].Index + ratio * (accelCurves[currentIndex + 1].Index - accelCurves[currentIndex].Index); self->accel.GainLinear = accelCurves[currentIndex].GainLinear + ratio * (accelCurves[currentIndex + 1].GainLinear - accelCurves[currentIndex].GainLinear); self->accel.GainParabolic = accelCurves[currentIndex].GainParabolic + ratio * (accelCurves[currentIndex + 1].GainParabolic - accelCurves[currentIndex].GainParabolic); self->accel.GainCubic = accelCurves[currentIndex].GainCubic + ratio * (accelCurves[currentIndex + 1].GainCubic - accelCurves[currentIndex].GainCubic); self->accel.GainQudratic = accelCurves[currentIndex].GainQudratic + ratio * (accelCurves[currentIndex + 1].GainQudratic - accelCurves[currentIndex].GainQudratic); self->accel.TangentSpeedLinear = accelCurves[currentIndex].TangentSpeedLinear + ratio * (accelCurves[currentIndex + 1].TangentSpeedLinear - accelCurves[currentIndex].TangentSpeedLinear); self->accel.TangentSpeedParabolicRoot = accelCurves[currentIndex].TangentSpeedParabolicRoot + ratio * (accelCurves[currentIndex + 1].TangentSpeedParabolicRoot - accelCurves[currentIndex].TangentSpeedParabolicRoot); } else { memcpy (&self->accel, &accelCurves[currentIndex], sizeof(self->accel)); } double y0; self->tangent[0] = std::numeric_limits<double>::max(); self->tangent[1] = std::numeric_limits<double>::max(); if (self->accel.TangentSpeedLinear != 0) { y0 = self->accel.GainLinear * self->accel.TangentSpeedLinear + pow (self->accel.GainParabolic * self->accel.TangentSpeedLinear, 2) + pow (self->accel.GainCubic * self->accel.TangentSpeedLinear, 3) + pow (self->accel.GainQudratic * self->accel.TangentSpeedLinear, 4); self->m[0] = self->accel.GainLinear + 2 * self->accel.TangentSpeedLinear * pow(self->accel.GainParabolic,2) + 3 * pow(self->accel.TangentSpeedLinear,2) * pow(self->accel.GainCubic,3) + 4 * pow (self->accel.TangentSpeedLinear, 3) * pow(self->accel.GainQudratic, 4); self->b[0] = y0 - self->m[0] * self->accel.TangentSpeedLinear; self->tangent[0] = self->accel.TangentSpeedLinear; if (self->accel.TangentSpeedParabolicRoot != 0) { double y1 = (self->m[0] * self->accel.TangentSpeedParabolicRoot + self->b[0]); self->m[1] = 2 * y1 * self->m[0]; self->b[1] = pow (y1,2) - self->m[1] * self->accel.TangentSpeedParabolicRoot; self->tangent[1] = self->accel.TangentSpeedParabolicRoot; } } else if ( self->accel.TangentSpeedParabolicRoot != 0) { y0 = self->accel.GainLinear * self->accel.TangentSpeedParabolicRoot + pow (self->accel.GainParabolic * self->accel.TangentSpeedParabolicRoot, 2) + pow (self->accel.GainCubic * self->accel.TangentSpeedParabolicRoot, 3) + pow (self->accel.GainQudratic * self->accel.TangentSpeedParabolicRoot, 4); self->m[1] = self->accel.GainLinear + 2 * self->accel.TangentSpeedParabolicRoot * pow(self->accel.GainParabolic,2) + 3 * pow(self->accel.TangentSpeedParabolicRoot,2) * pow(self->accel.GainCubic,3) + 4 * pow (self->accel.TangentSpeedParabolicRoot, 3) * pow(self->accel.GainQudratic, 4); self->b[1] = pow (y0,2) - self->m[1] * self->accel.TangentSpeedParabolicRoot; self->tangent[0] = self->accel.TangentSpeedParabolicRoot; } return self; }
void COscillogram::OnMouseMove(UINT nFlags, CPoint point) { CStringArray valArray; CDWordArray colArray; CString strVal; CRect mRect; CClientDC dc(this); float length; //鼠标位置绝对象素数 float gValue; int oldMode; int curCell; //所在单元格 CPen pen(PS_SOLID,0,RGB(0,0,0)); BOOL PtState = FALSE; //(整个函数过程的功能)计算所有线所在单元格的数值 oldMode = dc.SetMapMode(MM_LOMETRIC); SetOscillogramRect(&dc); dc.SelectObject(&pen); dc.SetROP2(R2_NOTXORPEN); dc.DPtoLP(&point); //如果 鼠标不在波形图内 或者 没有曲线 不做处理返回 if(!(point.x >= m_GridRect.left && point.x <= m_GridRect.right+3 && point.y <= m_GridRect.top && point.y >= m_GridRect.bottom) || GetCurveCount() < 1 || m_showTitle == FALSE) { if(m_bPt.x != -1) { DrawMouseLine(&dc,m_bPt); m_bPt =-1; } m_TitleTip.ShowWindow(SW_HIDE); return; } //绘画跟随鼠标的十字线 if(m_bPt.x == -1) { m_bPt = point; DrawMouseLine(&dc,point); } else { DrawMouseLine(&dc,m_bPt); m_bPt = point; DrawMouseLine(&dc,point); } //计算个单元格数值 length = (float)( point.x - m_GridRect.left ); curCell = (int)( length / m_xSpan ); if(!m_showTime) { float n1 = (m_xMaxVal - m_xMinVal)/(m_xCount-1); float n2 = m_xMinVal + curCell*n1; strVal.Format("%s: %.2f",m_xText,n2); } else { CTimeSpan m_xTimeSpan = 0; CTimeSpan sc = m_endTime - m_beginTime; CTime cnTime = m_beginTime; double secCount = (sc.GetDays()*86400) + (sc.GetHours()*3600) + (sc.GetMinutes()*60) + sc.GetSeconds(); secCount = secCount / (m_xCount-1); int day = (int)secCount/86400; //天 secCount -= day*86400; int hour = (int)secCount/3600; //小时 secCount -= hour*3600; int minute = (int)secCount/60; //分钟 secCount -= minute*60; int second = (int)secCount; //秒 m_xTimeSpan = CTimeSpan(day,hour,minute,second); for(int j=0;j<curCell;j++) cnTime += m_xTimeSpan; strVal.Format("%s: %s",m_xText,cnTime.Format("%Y/%m/%d %H:%M:%S")); } colArray.Add(RGB(0,0,0)); valArray.Add(strVal); for(int i=0;i<GetCurveCount();i++) { gValue = GetCurve(i)->ptVal.GetPointValue(curCell,PtState); if(PtState) strVal.Format("%s: %.2f",GetCurveName(i),gValue); else strVal.Format("%s: ",GetCurveName(i)); colArray.Add(GetCurve(i)->lColor); valArray.Add(strVal); } //显示浮动窗体 dc.LPtoDP(&point); dc.SetMapMode(oldMode); //窗口跟随鼠标位置移动 GetClientRect(mRect); mRect.left += CS_LMARGIN; mRect.top += CS_LMARGIN; mRect.right -= CS_LMARGIN; mRect.bottom -= CS_LMARGIN; ClientToScreen(&point); ClientToScreen(&mRect); m_TitleTip.SetParentRect(mRect); m_TitleTip.SetStrArray(valArray,colArray); m_TitleTip.SetPos(&point); ScreenToClient(&point); CWnd::OnMouseMove(nFlags, point); }
void QGraph::DrawCurve(int nIndex, QPainter &painter) { painter.save(); static double scaley; static int i, ptside; static QPoint From, To, Min, Max; static QRect rViewRect; ptside = 2; CCurve* pCurve = GetCurve(nIndex); scaley = m_scaley; QBrush FillBrush(m_BkColor); painter.setBrush(FillBrush); QPen CurvePen(pCurve->GetColor()); CurvePen.setStyle(GetStyle(pCurve->GetStyle())); CurvePen.setWidth((int)pCurve->GetWidth()); painter.setPen(CurvePen); Min.setX(int(xmin/m_scalex) +m_ptoffset.x()); Min.setY(int(ymin/scaley) +m_ptoffset.y()); Max.setX(int(xmax/m_scalex) +m_ptoffset.x()); Max.setY(int(ymax/scaley) +m_ptoffset.y()); rViewRect.setTopLeft(Min); rViewRect.setBottomRight(Max); if(pCurve->n>=1) { From.setX(int(pCurve->x[0]/m_scalex+m_ptoffset.x())); From.setY(int(pCurve->y[0]/scaley +m_ptoffset.y())); if(pCurve->IsVisible()) { for (i=1; i<pCurve->n;i++) { To.setX(int(pCurve->x[i]/m_scalex+m_ptoffset.x())); To.setY(int(pCurve->y[i]/scaley +m_ptoffset.y())); painter.drawLine(From, To); From = To; } } if(pCurve->PointsVisible()) { for (i=0; i<pCurve->n;i++) { if(pCurve->GetSelected() !=i) painter.drawRect(int(pCurve->x[i]/m_scalex+m_ptoffset.x())-ptside, int(pCurve->y[i]/ scaley+m_ptoffset.y())-ptside, 2*ptside,2*ptside); } } } if(m_bHighlightPoint) { int point = pCurve->GetSelected(); if(point>=0) { //highlight QColor HighColor(0,40, 150); CurvePen.setWidth((int)pCurve->GetWidth()); CurvePen.setColor(HighColor); painter.setPen(CurvePen); To.setX(int(pCurve->x[point]/m_scalex+m_ptoffset.x())); To.setY(int(pCurve->y[point]/scaley +m_ptoffset.y())); painter.drawRect(To.x()-ptside-1,To.y()-ptside-1, 2*(ptside+1),2*(ptside+1)); } } painter.restore(); }
bool UMovieSceneComposurePostMoveSettingsSection::NewKeyIsNewData(float Time, const struct FComposurePostMoveSettingsKey& Key) const { const FRichCurve& Curve = GetCurve(Key.Channel, Key.Axis); return FMath::IsNearlyEqual(Curve.Eval(Time), Key.Value); }