04-23-2009 07:31 AM
Bonjour
I tried to add annotations to CWGraph , but I cannot modifiy Shape & Arrow.
I tried to modify the example project in Ui\Graph\Annotations and all works, but not in my project (CWGraph allocated dynamically)
VARIANT PlotIdx;
::VariantInit(&PlotIdx);
PlotIdx.vt = VT_I4;
PlotIdx.lVal = 1;
VARIANT XCoord;
::VariantInit(&XCoord);
XCoord.vt = VT_R8;
VARIANT YCoord;
::VariantInit(&YCoord);
YCoord.vt = VT_R8;
XCoord.dblVal = GetCursorXPosition(1,FALSE);
YCoord.dblVal = 1.0;
CCWShape l_Shape;
l_Shape.SetColor(0x00ff00);
l_Shape.SetLineColor(0x0000ff);
l_Shape.SetPointStyle(CNiShape::Point);
l_Shape.SetCoordinates(XCoord, YCoord);
CCWArrow l_Arrow;
l_Arrow.SetColor(0xff0000);
l_Arrow.SetHeadStyle(CNiArrow::Diamond);
l_Arrow.SetTailStyle(CNiArrow::Diamond);
CCWAnnotation l_Annotation = m_GraphComponent->GetAnnotations().Add();
l_Annotation.SetPlot(m_GraphComponent->GetPlots().Item(PlotIdx));
l_Annotation.SetSnapMode(CNiAnnotation::SnapAnchoredToPoint);
l_Annotation.SetCoordinateType(CNiAnnotation::AxesCoordinates);
l_Annotation.SetBuiltinStyle(CNiAnnotation::ArrowOnly);
l_Annotation.SetEnabled(TRUE);
l_Annotation.SetVisible(TRUE);
l_Annotation.SetPointIndex(GetCursorXPointIndex(1));
l_Annotation.SetShape(l_Shape); // doesn't work
l_Annotation.SetArrow(l_Arrow); // doesn't work also
Is there somethig else to do ?
The result is always the same (I cannot change shape & arrow)
The version of CWGraph is v8.1.11 Release(472)(602).
Regards
04-24-2009 01:35 AM - edited 04-24-2009 01:36 AM
I finally found the solution.
these 2 lines have no effect (do these 2 functions are useless ?)
l_Annotation.SetShape(l_Shape);
l_Annotation.SetArrow(l_Arrow);
The solution was :
l_Annotation.GetShape().SetColor(0x00ff00);
l_Annotation.GetShape().SetLineColor(0x0000ff);
l_Annotation.GetShape().SetPointStyle(CNiShape::Point);
l_Annotation.GetShape().SetCoordinates(XCoord, YCoord);
l_Annotation.GetArrow().SetColor(0xff0000);
l_Annotation.GetArrow().SetHeadStyle(CNiArrow::Diamond);
l_Annotation.GetArrow().SetTailStyle(CNiArrow::Diamond);