Support Board
Date/Time: Sun, 24 Nov 2024 22:58:51 +0000
Post From: Issue with UseTool - PLEASE HELP
[2024-02-28 22:57:39] |
User719512 - Posts: 264 |
There are a few things going on here. 1) you should follow the patterns in the samples and save the LineNumber in a persistent (but that is not the cause of your issue) 2) you could make your drawings User Drawings, and better see what is happening via inspection. (I updated your code to do so for debugging purposes) 3) Once user drawings, you can see them in the manage user drawings dialog, Ctrl-Alt-M, and see that the red TEXT is text on the X marker, not a 3rd drawing. 4) Looks like Tool.Clear() does not reset Tool.Text. That seems like a bug to me. Adding Tool.Text.Clear() seems to resolve that and can be used till Sierra fixes this bug. Below is updated code... SCSFExport scsf_DrawingMarker(SCStudyInterfaceRef sc) { SCInputRef Color1 = sc.Input[1]; SCInputRef Color2 = sc.Input[2]; if (sc.SetDefaults) { sc.GraphName = "Drawing Marker"; sc.AutoLoop = 1; sc.GraphRegion = 0; sc.FreeDLL = 0; Color1.Name = "Color 1"; Color1.SetColor(0, 200, 0); Color2.Name = "Color 2"; Color2.SetColor(255, 0, 0); return; } s_UseTool Tool; int& r_LineNumber1 = sc.GetPersistentInt(1); int& r_LineNumber2 = sc.GetPersistentInt(2); // Drawing Text Tool.Clear(); Tool.Text.Clear(); Tool.ChartNumber = sc.ChartNumber; Tool.Region = 0; Tool.AddMethod = UTAM_ADD_OR_ADJUST; if (r_LineNumber1 != 0) Tool.LineNumber = r_LineNumber1; Tool.DrawingType = DRAWING_TEXT; Tool.FontSize = 8; Tool.Color = Color1.GetColor(); Tool.BeginIndex = sc.Index; Tool.BeginValue = sc.High[sc.Index]; Tool.Text = " TEXT "; Tool.TextAlignment = DT_CENTER | DT_VCENTER; Tool.AddAsUserDrawnDrawing = 1; sc.UseTool(Tool); r_LineNumber1 = Tool.LineNumber;//Remember line number which has been automatically set // Drawing Marker Tool.Clear(); Tool.Text.Clear(); Tool.ChartNumber = sc.ChartNumber; Tool.Region = 0; Tool.AddMethod = UTAM_ADD_OR_ADJUST; if (r_LineNumber2 != 0) Tool.LineNumber = r_LineNumber2; Tool.DrawingType = DRAWING_MARKER; Tool.MarkerType = MARKER_X; Tool.Color = Color2.GetColor(); Tool.MarkerSize = 6; Tool.LineWidth = 3; Tool.BeginIndex = sc.Index; Tool.BeginValue = sc.Low[sc.Index]; Tool.AddAsUserDrawnDrawing = 1; sc.UseTool(Tool); r_LineNumber2 = Tool.LineNumber;//Remember line number which has been automatically set } |