Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 15:32:50 +0000



Post From: ACSIL: How draw an inclined line with text label and bar calculation

[2023-08-04 18:56:52]
JohnR - User831573 - Posts: 306
There should be either some samples in the ACS_Source, A search with Notepad++ is what I usually do. Also, I kinda remember seeming some source here in the forums, a user submitted. I think that is where I found the code below as a starting place to do my things.

Hope this helps,
JohnR

#include "sierrachart.h"

SCDLLName("Update Issue")

int CreateRay(SCStudyGraphRef sc, int i1, float p1, int i2, float p2)
{
s_UseTool tool;
tool.ChartNumber = sc.ChartNumber;
tool.DrawingType = DRAWING_RAY;
tool.Region = sc.GraphRegion;
tool.AddMethod = UTAM_ADD_OR_ADJUST;
tool.TextAlignment = DT_RIGHT;
tool.BeginValue = p1;
tool.BeginIndex = i1;
tool.EndValue = p2;
tool.EndIndex = i2;
tool.Color = COLOR_GREEN;
tool.LineWidth = 2;
tool.LineStyle = LINESTYLE_SOLID;
tool.AddAsUserDrawnDrawing = 1;
sc.UseTool(tool);
return tool.LineNumber;
}



SCSFExport scsf_update_issue(SCStudyInterfaceRef sc)
{
int& line_num = sc.GetPersistentIntFast(1);
int& index1 = sc.GetPersistentIntFast(2);
if (sc.SetDefaults)
{
sc.GraphName = "Update Issue";
sc.StudyDescription = "";
sc.AutoLoop = 0;
sc.GraphRegion = 0;
sc.ReceivePointerEvents = ACS_RECEIVE_POINTER_EVENTS_ALWAYS;
return;
}


if (sc.UpdateStartIndex == 0)
{
if (line_num == 0)
{
index1 = sc.ArraySize - 10;
line_num = CreateRay(sc, index1, sc.Close[sc.ArraySize-2], index1 + 3, sc.Close[sc.ArraySize - 2]);
}
return;
}


if (sc.PointerEventType == SC_POINTER_BUTTON_DOWN)
{
s_UseTool chart_drawing;
if (sc.GetUserDrawnDrawingByLineNumber(sc.ChartNumber, line_num, chart_drawing))
{
chart_drawing.BeginDateTime.Clear();
chart_drawing.EndDateTime.Clear();
chart_drawing.BeginIndex = sc.ActiveToolIndex;
chart_drawing.BeginValue = sc.ActiveToolYValue;
chart_drawing.EndIndex = sc.ActiveToolIndex + 1;
chart_drawing.EndValue = sc.ActiveToolYValue;
sc.UseTool(chart_drawing);
}

}

}