Support Board
Date/Time: Wed, 27 Nov 2024 00:44:05 +0000
Post From: Subgraph is not updating after a custom menu event
[2023-10-13 02:31:51] |
Mark Lewis - Posts: 25 |
I have pieced together some code so that I select a user drawing (rectangle in this case), right-click and choose my custom menu item. The code triggers a message to the log with the drawing information but I cannot update my subgraph (Subgraph_BalanceZoneTop) to the value retrieved by the code capturing the event. Also, when I add the custom study it puts the subgraph line (Subgraph_BalanceZoneTop ) at 0. How can I fix these two issues? I have searched and searched the custom study examples. Thanks! #include "sierrachart.h" SCDLLName("My Studies") SCSFExport scsf_BalanceZones(SCStudyInterfaceRef sc) { SCString MessageText; SCSubgraphRef Subgraph_BalanceZoneTop = sc.Subgraph[0]; if (sc.SetDefaults) { sc.GraphName = "Balance Zones"; sc.StudyDescription = ""; sc.GraphRegion = 0; Subgraph_BalanceZoneTop.Name = "Balance zone top"; Subgraph_BalanceZoneTop.DrawStyle = DRAWSTYLE_LINE; Subgraph_BalanceZoneTop.PrimaryColor = RGB(127,0,0); // Dark red Subgraph_BalanceZoneTop.DrawZeros = true; return; } int& r_MenuID = sc.GetPersistentInt(1); if (sc.LastCallToFunction) { sc.RemoveACSChartShortcutMenuItem(sc.ChartNumber, r_MenuID); return; } if (sc.UpdateStartIndex == 0) { if (r_MenuID <= 0) { r_MenuID = sc.AddACSChartShortcutMenuItem(sc.ChartNumber, "Balance zones"); } return; } s_UseTool ChartDrawing; if (sc.MenuEventID != 0 && sc.MenuEventID == r_MenuID) { int selectedLineNumber = sc.GetLineNumberOfSelectedUserDrawnDrawing(); sc.GetUserDrawnDrawingByLineNumber(0, selectedLineNumber, ChartDrawing); float BalanceZoneHeight = ChartDrawing.BeginValue - ChartDrawing.EndValue; Subgraph_BalanceZoneTop[sc.Index] = ChartDrawing.BeginValue; SCString BeginDateTimeString = sc.FormatDateTime(ChartDrawing.BeginDateTime); SCString EndDateTimeString = sc.FormatDateTime(ChartDrawing.EndDateTime); SCString Msg; Msg.Format("Drawing was selected: BeginDateTime=%s, EndDateTime=%s, BeginValue=%f, EndValue=%f, Height=%f." , BeginDateTimeString.GetChars(), EndDateTimeString.GetChars(), ChartDrawing.BeginValue, ChartDrawing.EndValue, BalanceZoneHeight); sc.AddMessageToLog(Msg, 1); return; } } Date Time Of Last Edit: 2023-10-13 02:33:35
|