supergaugecommon.pas 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688
  1. // SPDX-License-Identifier: LGPL-3.0-linking-exception
  2. {
  3. Part of BGRA Controls. Made by third party.
  4. For detailed information see readme.txt
  5. Site: https://sourceforge.net/p/bgra-controls/
  6. Wiki: http://wiki.lazarus.freepascal.org/BGRAControls
  7. Forum: http://forum.lazarus.freepascal.org/index.php/board,46.0.html
  8. }
  9. {******************************* CONTRIBUTOR(S) ******************************
  10. - Edivando S. Santos Brasil | [email protected]
  11. (Compatibility with delphi VCL 11/2018)
  12. - Sandy Ganz | [email protected]
  13. Evolved from DTAnalogCommon, specific for New Gauge Work
  14. Massive overhaul, fixes and features, begat Super Gauge
  15. Needed to split off as changes broke compatibility badly
  16. ***************************** END CONTRIBUTOR(S) *****************************}
  17. unit SuperGaugeCommon;
  18. {$I bgracontrols.inc}
  19. interface
  20. uses
  21. Classes, SysUtils, {$IFDEF FPC}LResources,{$ELSE}Types, {$ENDIF} Forms, Controls, Graphics, Dialogs,
  22. BGRABitmap, BGRABitmapTypes, BGRAGradients, BCTypes;
  23. type
  24. TSGFillStyle = (fsNone, fsGradient, fsFlat, fsPhong); // Add more if needed here
  25. TSGPointerStyle = (psLine, psLineExt, psArc , psTriangle {, psTriangleLine, psTriangleLineExt}); // Todo : Add others at some point
  26. TSGLEDStyle = (lsNone, lsFlat, lsShaded);
  27. TSGLEDShape = (lshRound, lshSquare, lshTriangle, lshDownTriangle);
  28. TSGPointerCapPosition = (cpUnder, cpOver);
  29. TSGCapStyle = (csNone, csFlat, csShaded, csPhong);
  30. TSGTickArc = (taNone, taOuter, taInner, taBoth); // Arc above or below ticks, inner/both is automatic on inner, main if exist, minor othewise
  31. TSGRangeCheckType = (rcNone, rcGaugeOutOfRange, rcBetween, rcBothInclusive, rcStartInclusive,
  32. rcEndInclusive, rcBothBetweenOutside, rcBothInclusiveOutside,
  33. rcGreaterStart, rcLessEnd); // added for range check led, see code for details
  34. TSGMarkerStyle = (msCenter, msLeft, msRight);
  35. { TSGOrigin }
  36. TSGOrigin = packed record
  37. CenterPoint: TPoint;
  38. Radius: integer;
  39. end;
  40. { TSGPointerCapSettings }
  41. TSGPointerCapSettings = class(TPersistent)
  42. private
  43. FEdgeColor: TColor;
  44. FEdgeThickness: integer;
  45. FFillColor: TColor;
  46. FOnChange: TNotifyEvent;
  47. FRadius: integer;
  48. FCurveExponent: single;
  49. FCapStyle: TSGCapStyle;
  50. FCapPosition: TSGPointerCapPosition;
  51. FDirty: boolean;
  52. procedure SetEdgeColor(AValue: TColor);
  53. procedure SetEdgeThickness(AValue: integer);
  54. procedure SetFillColor(AValue: TColor);
  55. procedure SetOnChange(AValue: TNotifyEvent);
  56. procedure SetRadius(AValue: integer);
  57. procedure SetLightIntensity(const AValue: integer);
  58. function GetLightIntensity: integer;
  59. procedure SetCurveExponent(const AValue: single);
  60. procedure SetCapStyle(const AValue: TSGCapStyle);
  61. procedure SetPointerCapPos(const AValue: TSGPointerCapPosition);
  62. procedure DirtyOnChange;
  63. protected
  64. public
  65. FPhong: TPhongShading;
  66. property Dirty: boolean read FDirty write FDirty;
  67. constructor Create;
  68. destructor Destroy; override;
  69. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  70. published
  71. property EdgeColor: TColor read FEdgeColor write SetEdgeColor default clGray;
  72. property FillColor: TColor read FFillColor write SetFillColor default clBlack;
  73. property Radius: integer read FRadius write SetRadius default 30;
  74. property EdgeThickness: integer read FEdgeThickness write SetEdgeThickness default 2;
  75. property LightIntensity: integer read GetLightIntensity write SetLightIntensity default 300;
  76. property CurveExponent: single read FCurveExponent write SetCurveExponent default 0.05;
  77. property CapStyle: TSGCapStyle read FCapStyle write SetCapStyle default csPhong;
  78. property CapPosition: TSGPointerCapPosition read FCapPosition write SetPointerCapPos default cpUnder;
  79. end;
  80. { TSGPointerSettings }
  81. TSGPointerSettings = class(TPersistent)
  82. private
  83. FColor: TColor;
  84. FLength: integer;
  85. FExtensionLength: integer;
  86. FOnChange: TNotifyEvent;
  87. FThickness: integer;
  88. FStyle: TSGPointerStyle;
  89. FDirty: boolean;
  90. procedure SetColor(AValue: TColor);
  91. procedure SetLength(AValue: integer);
  92. procedure SetOnChange(AValue: TNotifyEvent);
  93. procedure SetThickness(AValue: integer);
  94. procedure SetStyle(AValue: TSGPointerStyle);
  95. procedure SetExtensionLength(AValue: integer);
  96. procedure DirtyOnChange;
  97. protected
  98. public
  99. constructor Create;
  100. destructor Destroy; override;
  101. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  102. property Dirty: boolean read FDirty write FDirty;
  103. published
  104. property Color: TColor read FColor write SetColor;
  105. property Length: integer read FLength write SetLength default 160;
  106. property ExtensionLength: integer read FExtensionLength write SetExtensionLength default 20;
  107. property Thickness: integer read FThickness write SetThickness default 5;
  108. property Style: TSGPointerStyle read FStyle write SetStyle default psLineExt;
  109. end;
  110. { TSGScaleSettings }
  111. TSGScaleSettings = class(TPersistent)
  112. private
  113. FEnableScaleText: boolean;
  114. FStart: integer;
  115. FStep: integer;
  116. FMaximum: integer;
  117. FMinimum: integer;
  118. FTextFont: string;
  119. FTextRadius: integer;
  120. FTextSize: integer;
  121. FTextStyle: TFontStyles;
  122. FTickColor: TColor;
  123. FEnableMainTicks: boolean;
  124. FEnableSubTicks: boolean;
  125. FReverseScale: boolean;
  126. FThicknessMainTick: integer;
  127. FThicknessSubTick: integer;
  128. FLengthMainTick: integer;
  129. FLengthSubTick: integer;
  130. FMainTickCount: integer;
  131. FOnChange: TNotifyEvent;
  132. FSubTickCount: integer;
  133. FTextColor: TColor;
  134. FScaleRadius: integer;
  135. FTickArcStyle: TSGTickArc;
  136. FDirty: boolean;
  137. procedure SetEnableScaleText(AValue: boolean);
  138. procedure SetStart(AValue: integer);
  139. procedure SetStep(AValue: integer);
  140. procedure SetMaximum(AValue: integer);
  141. procedure SetMinimum(AValue: integer);
  142. procedure SetTextFont(AValue: string);
  143. procedure SetTextRadius(AValue: integer);
  144. procedure SetTextSize(AValue: integer);
  145. procedure SetTextStyle(AValue: TFontStyles);
  146. procedure SetTickColor(AValue: TColor);
  147. procedure SetEnableMainTicks(AValue: boolean);
  148. procedure SetEnableSubTicks(AValue: boolean);
  149. procedure SetReverseScale(AValue: boolean);
  150. procedure SetLengthMainTick(AValue: integer);
  151. procedure SetLengthSubTick(AValue: integer);
  152. procedure SetMainTickCount(AValue: integer);
  153. procedure SetOnChange(AValue: TNotifyEvent);
  154. procedure SetSubTickCount(AValue: integer);
  155. procedure SetTextColor(AValue: TColor);
  156. procedure SetThicknessMainTick(AValue: integer);
  157. procedure SetThicknessSubTick(AValue: integer);
  158. procedure SetTickArcStyle(AValue: TSGTickArc);
  159. procedure SetScaleRadius(AValue: integer);
  160. procedure DirtyOnChange;
  161. protected
  162. public
  163. constructor Create;
  164. destructor Destroy; override;
  165. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  166. property Dirty: boolean read FDirty write FDirty;
  167. published
  168. property TickColor: TColor read FTickColor write SetTickColor;
  169. property TextColor: TColor read FTextColor write SetTextColor;
  170. property TextSize: integer read FTextSize write SetTextSize default 20;
  171. property TextStyle: TFontStyles read FTextStyle write SetTextStyle;
  172. property TextFont: string read FTextFont write SetTextFont;
  173. property EnableMainTicks: boolean read FEnableMainTicks write SetEnableMainTicks;
  174. property EnableSubTicks: boolean read FEnableSubTicks write SetEnableSubTicks;
  175. property EnableScaleText: boolean read FEnableScaleText write SetEnableScaleText;
  176. property ReverseScale: boolean read FReverseScale write SetReverseScale default False;
  177. property Start: integer read FStart write SetStart default 0;
  178. property Step: integer read FStep write SetStep default 1;
  179. property MainTickCount: integer read FMainTickCount write SetMainTickCount;
  180. property SubTickCount: integer read FSubTickCount write SetSubTickCount;
  181. property LengthMainTick: integer read FLengthMainTick write SetLengthMainTick;
  182. property LengthSubTick: integer read FLengthSubTick write SetLengthSubTick;
  183. property ThicknessMainTick: integer read FThicknessMainTick write SetThicknessMainTick;
  184. property ThicknessSubTick: integer read FThicknessSubTick write SetThicknessSubTick;
  185. property TextRadius: integer read FTextRadius write SetTextRadius default 120;
  186. property ScaleRadius: integer read FScaleRadius write SetScaleRadius;
  187. property TickArcStyle : TSGTickArc read FTickArcStyle write SetTickArcStyle default taOuter;
  188. end;
  189. { TSGBandSettings }
  190. TSGBandSettings = class(TPersistent)
  191. private
  192. FEnabled: boolean;
  193. FStartValue: single;
  194. FEndValue: single;
  195. FEnableText: boolean;
  196. FText: TCaption;
  197. FTextFont: string;
  198. FTextStyle: TFontStyles;
  199. FTextRadius: integer;
  200. FTextSize: integer;
  201. FTextColor: TColor;
  202. FOnChange: TNotifyEvent;
  203. FBandThickness: integer;
  204. FBandRadius: integer; // defines the outer Radius length in pixels, likely center of width/thickness
  205. FBandColor: TColor;
  206. FDirty: boolean;
  207. procedure SetEnabled(AValue: boolean);
  208. procedure SetStartValue(AValue: single);
  209. procedure SetEndValue(AValue: single);
  210. procedure SetEnableText(AValue: boolean);
  211. procedure SetText(AValue: TCaption);
  212. procedure SetTextSize(AValue: integer);
  213. procedure SetTextFont(AValue: string);
  214. procedure SetTextStyle(AValue: TFontStyles);
  215. procedure SetTextRadius(AValue: integer);
  216. procedure SetTextColor(AValue: TColor);
  217. procedure SetOnChange(AValue: TNotifyEvent);
  218. procedure SetBandThickness(AValue: integer);
  219. procedure SetBandRadius(AValue: integer);
  220. procedure SetBandColor(AValue: TColor);
  221. procedure DirtyOnChange;
  222. protected
  223. public
  224. constructor Create;
  225. destructor Destroy; override;
  226. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  227. property Dirty: boolean read FDirty write FDirty;
  228. published
  229. property Enabled: boolean read FEnabled write SetEnabled default False;
  230. property StartValue: single read FStartValue write SetStartValue default 0.0;
  231. property EndValue: single read FEndValue write SetEndValue default 100.0;
  232. property EnableText: boolean read FEnableText write SetEnableText;
  233. property Text: TCaption read FText write SetText;
  234. property TextSize: integer read FTextSize write SetTextSize default 20;
  235. property TextFont: string read FTextFont write SetTextFont;
  236. property TextStyle: TFontStyles read FTextStyle write SetTextStyle;
  237. property TextRadius: integer read FTextRadius write SetTextRadius;
  238. property TextColor: TColor read FTextColor write SetTextColor;
  239. property Thickness: integer read FBandThickness write SetBandThickness;
  240. property BandRadius: integer read FBandRadius write SetBandRadius;
  241. Property BandColor: TColor read FBandColor write SetBandColor;
  242. end;
  243. { TSGFaceSettings }
  244. TSGFaceSettings = class(TPersistent)
  245. private
  246. FInnerColor: TColor;
  247. FOuterColor: TColor;
  248. FFillStyle: TSGFillStyle;
  249. FPicture: TPicture;
  250. FPictureEnabled: boolean;
  251. FPictureOffsetX, FPictureOffsetY: integer;
  252. FCurveExponent: single;
  253. FOnChange: TNotifyEvent;
  254. FDirty: boolean;
  255. procedure SetInnerColor(AValue: TColor);
  256. procedure SetOuterColor(AValue: TColor);
  257. procedure SetFillStyle(AValue: TSGFillStyle);
  258. procedure SetPicture(AValue: TPicture);
  259. procedure SetPictureEnabled(AValue: boolean);
  260. procedure SetPictureOffsetX(AValue: integer);
  261. procedure SetPictureOffsetY(AValue: integer);
  262. procedure SetLightIntensity(const AValue: integer);
  263. function GetLightIntensity: integer;
  264. procedure SetCurveExponent(const AValue: single);
  265. procedure SetOnChange(AValue: TNotifyEvent);
  266. procedure DirtyOnChange;
  267. protected
  268. public
  269. FPhong: TPhongShading;
  270. constructor Create;
  271. destructor Destroy; override;
  272. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  273. property Dirty: boolean read FDirty write FDirty;
  274. published
  275. property FillStyle: TSGFillStyle read FFillStyle write SetFillStyle;
  276. property InnerColor: TColor read FInnerColor write SetInnerColor;
  277. property OuterColor: TColor read FOuterColor write SetOuterColor;
  278. property Picture: TPicture read FPicture write SetPicture;
  279. property PictureEnabled: boolean read FPictureEnabled write SetPictureEnabled;
  280. property PictureOffsetX: integer read FPictureOffsetX write SetPictureOffsetX default 0;
  281. property PictureOffsetY: integer read FPictureOffsetY write SetPictureOffsetY default 0;
  282. property LightIntensity: integer read GetLightIntensity write SetLightIntensity default 300;
  283. property CurveExponent: single read FCurveExponent write SetCurveExponent default 0.05;
  284. end;
  285. { TSGFrameSettings }
  286. TSGFrameSettings = class(TPersistent)
  287. private
  288. FFrameColor: TColor;
  289. FBorderColor: TColor;
  290. FBorderRadius: integer;
  291. FOnChange: TNotifyEvent;
  292. FDirty: boolean;
  293. procedure SetBorderRadius(AValue: integer);
  294. procedure SetFrameColor(AValue: TColor);
  295. procedure SetBorderColor(AValue: TColor);
  296. procedure SetOnChange(AValue: TNotifyEvent);
  297. procedure DirtyOnChange;
  298. protected
  299. public
  300. constructor Create;
  301. destructor Destroy; override;
  302. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  303. property Dirty: boolean read FDirty write FDirty;
  304. published
  305. property BorderRadius: integer read FBorderRadius write SetBorderRadius;
  306. property FrameColor: TColor read FFrameColor write SetFrameColor;
  307. property BorderColor: TColor read FBorderColor write SetBorderColor;
  308. end;
  309. { TSGLEDSettings }
  310. TSGLEDSettings = class(TPersistent)
  311. private
  312. FActiveColor: TColor;
  313. FInactiveColor: TColor;
  314. FBorderColor: TColor;
  315. FSize: integer;
  316. FOffsetX, FOffsetY: integer;
  317. FStyle: TSGLEDStyle;
  318. FShape: TSGLEDShape;
  319. FOnChange: TNotifyEvent;
  320. FActive: boolean;
  321. FDirty: boolean;
  322. procedure SetActive(AValue: boolean);
  323. procedure SetActiveNoDoChange(AValue: boolean);
  324. procedure SetActiveColor(AValue: TColor);
  325. procedure SetInactiveColor(AValue: TColor);
  326. procedure SetBorderColor(AValue: TColor);
  327. procedure SetSize(AValue: integer);
  328. procedure SetOffsetX(AValue: integer);
  329. procedure SetOffsetY(AValue: integer);
  330. procedure SetStyle(AValue: TSGLEDStyle);
  331. procedure SetShape(AValue: TSGLEDShape);
  332. procedure SetOnChange(AValue: TNotifyEvent);
  333. procedure DirtyOnChange;
  334. protected
  335. public
  336. constructor Create;
  337. destructor Destroy; override;
  338. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  339. property Dirty: boolean read FDirty write FDirty;
  340. published
  341. property ActiveColor: TColor read FActiveColor write SetActiveColor;
  342. property InactiveColor: TColor read FInactiveColor write SetInactiveColor;
  343. property BorderColor: TColor read FBorderColor write SetBorderColor;
  344. property Size: integer read FSize write SetSize default 10;
  345. property OffsetX: integer read FOffsetX write SetOffsetX default 0;
  346. property OffsetY: integer read FOffsetY write SetOffsetY default 50;
  347. property Style: TSGLEDStyle read FStyle write SetStyle default lsShaded;
  348. property Shape: TSGLEDShape read FShape write SetShape default lshRound;
  349. property Active: boolean read FActive write SetActive;
  350. property ActiveNoDoChange: boolean read FActive write SetActiveNoDoChange;
  351. end;
  352. { TSGRangeCheckLEDSettings }
  353. TSGRangeCheckLEDSettings = class(TSGLEDSettings)
  354. private
  355. FRangeStartValue : single;
  356. FRangeEndValue : single;
  357. FRangeType: TSGRangeCheckType;
  358. procedure SetRangeStartValue(AValue: single);
  359. procedure SetRangeEndValue(AValue: single);
  360. procedure SetRangeType(AValue: TSGRangeCheckType);
  361. protected
  362. public
  363. constructor Create;
  364. destructor Destroy; override;
  365. published
  366. property RangeStartValue: single read FRangeStartValue write SetRangeStartValue default 0;
  367. property RangeEndValue: single read FRangeEndValue write SetRangeEndValue default 100;
  368. property RangeType: TSGRangeCheckType read FRangeType write SetRangeType;
  369. property ActiveColor;
  370. property InactiveColor;
  371. property BorderColor;
  372. property Size;
  373. property OffsetX; // origin at center based offset
  374. property OffsetY;
  375. property Style;
  376. end;
  377. { TSGTextSettings }
  378. TSGTextSettings = class(TPersistent)
  379. private
  380. FEnabled: boolean;
  381. FFontEx: TBCFont;
  382. FText : TCaption;
  383. FOffsetX, FOffsetY: integer;
  384. FOnChange: TNotifyEvent;
  385. FDirty: boolean;
  386. procedure SetEnabled(AValue: boolean);
  387. procedure SetOffsetX(AValue: integer);
  388. procedure SetOffsetY(AValue: integer);
  389. procedure SetOnChange(AValue: TNotifyEvent);
  390. procedure DirtyOnChange;
  391. procedure SetText(AValue: TCaption);
  392. procedure SetFontEx(AValue: TBCFont);
  393. protected
  394. public
  395. constructor Create;
  396. destructor Destroy; override;
  397. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  398. property Dirty: boolean read FDirty write FDirty;
  399. published
  400. property Enabled: boolean read FEnabled write SetEnabled default False;
  401. property FontEx: TBCFont read FFontEx write SetFontEx;
  402. property Text: TCaption read FText write SetText;
  403. property OffsetX: integer read FOffsetX write SetOffsetX;
  404. property OffsetY: integer read FOffsetY write SetOffsetY;
  405. end;
  406. { TSGMarkerSettings }
  407. // Marker can be left or right or centered. The flat side should
  408. // be aligned with the markers value or in the case of centered, will
  409. // be the center of the marker. Like - \| - Left, |/ - Right, \/ - Centered
  410. TSGMarkerSettings = class(TPersistent)
  411. private
  412. FValue: single; // this is the internal gauge value not user value
  413. FEnabled: boolean;
  414. FColor: TColor;
  415. FHeight: integer;
  416. FRadius: integer;
  417. FWidth: integer;
  418. FStyle: TSGMarkerStyle;
  419. FOnChange: TNotifyEvent;
  420. FDirty: boolean;
  421. procedure SetValue(AValue: single);
  422. procedure SetEnabled(AValue: boolean);
  423. procedure SetColor(AValue: TColor);
  424. procedure SetHeight(AValue: integer);
  425. procedure SetRadius(AValue: integer);
  426. procedure SetWidth(AValue: integer);
  427. procedure SetOnChange(AValue: TNotifyEvent);
  428. procedure SetStyle(AValue: TSGMarkerStyle);
  429. procedure DirtyOnChange;
  430. protected
  431. public
  432. constructor Create;
  433. destructor Destroy; override;
  434. property OnChange: TNotifyEvent read FOnChange write SetOnChange;
  435. property Dirty: boolean read FDirty write FDirty;
  436. published
  437. property Value: single read FValue write SetValue default 0.0;
  438. property Enabled: boolean read FEnabled write SetEnabled default False;
  439. property Color: TColor read FColor write SetColor;
  440. property Height: integer read FHeight write SetHeight;
  441. property Radius: integer read FRadius write SetRadius;
  442. property Width: integer read FWidth write SetWidth;
  443. property Style: TSGMarkerStyle read FStyle write SetStyle default msCenter;
  444. end;
  445. function Initializebitmap(var Bitmap: TBGRABitmap; Width, Height: integer): TSGOrigin;
  446. implementation
  447. function Initializebitmap(var Bitmap: TBGRABitmap; Width, Height: integer): TSGOrigin;
  448. begin
  449. Bitmap.SetSize(Width, Height);
  450. // Clear bitmap to transparent
  451. BitMap.Fill(BGRA(0, 0, 0, 0));
  452. // Get origin information
  453. Result.CenterPoint.x := Width div 2;
  454. Result.CenterPoint.y := Height div 2;
  455. // Take the smallest so radius will always fit
  456. if Result.CenterPoint.x < Result.CenterPoint.y then
  457. Result.Radius := Result.CenterPoint.x
  458. else
  459. Result.Radius := Result.CenterPoint.y;
  460. end;
  461. { TSGPointerCapSettings }
  462. procedure TSGPointerCapSettings.SetCapStyle(const AValue: TSGCapStyle);
  463. begin
  464. if FCapStyle = AValue then
  465. Exit;
  466. FCapStyle := AValue;
  467. DirtyOnChange;
  468. end;
  469. procedure TSGPointerCapSettings.SetPointerCapPos(const AValue: TSGPointerCapPosition);
  470. begin
  471. if FCapPosition = AValue then
  472. Exit;
  473. FCapPosition := AValue;
  474. DirtyOnChange;
  475. end;
  476. procedure TSGPointerCapSettings.SetLightIntensity(const AValue: integer);
  477. begin
  478. if AValue = FPhong.LightSourceIntensity then
  479. Exit;
  480. FPhong.LightSourceIntensity := AValue;
  481. DirtyOnChange;
  482. end;
  483. function TSGPointerCapSettings.GetLightIntensity: integer;
  484. begin
  485. Result := round(FPhong.LightSourceIntensity);
  486. end;
  487. procedure TSGPointerCapSettings.SetCurveExponent(const AValue: single);
  488. begin
  489. if FCurveExponent = AValue then
  490. Exit;
  491. FCurveExponent := AValue;
  492. DirtyOnChange;
  493. end;
  494. procedure TSGPointerCapSettings.SetEdgeColor(AValue: TColor);
  495. begin
  496. if FEdgeColor = AValue then
  497. Exit;
  498. FEdgeColor := AValue;
  499. DirtyOnChange;
  500. end;
  501. procedure TSGPointerCapSettings.SetEdgeThickness(AValue: integer);
  502. begin
  503. if (FEdgeThickness = AValue) or (AValue < 0) then
  504. Exit;
  505. FEdgeThickness := AValue;
  506. DirtyOnChange;
  507. end;
  508. procedure TSGPointerCapSettings.SetFillColor(AValue: TColor);
  509. begin
  510. if FFillColor = AValue then
  511. Exit;
  512. FFillColor := AValue;
  513. DirtyOnChange;
  514. end;
  515. procedure TSGPointerCapSettings.SetOnChange(AValue: TNotifyEvent);
  516. begin
  517. FOnChange := AValue;
  518. // no dirty needed possibly, call directly
  519. if Assigned(FOnChange) then
  520. FOnChange(Self);
  521. end;
  522. procedure TSGPointerCapSettings.SetRadius(AValue: integer);
  523. begin
  524. if FRadius = AValue then
  525. Exit;
  526. FRadius := AValue;
  527. DirtyOnChange;
  528. end;
  529. constructor TSGPointerCapSettings.Create;
  530. begin
  531. // create a phong shader, will need to delete on clean up
  532. FPhong := TPhongShading.Create;
  533. FPhong.LightPositionZ := 100;
  534. FPhong.LightSourceIntensity := 300;
  535. FPhong.NegativeDiffusionFactor := 0.8;
  536. FPhong.AmbientFactor := 0.5;
  537. FPhong.DiffusionFactor := 0.6;
  538. FCurveExponent := 0.05;
  539. FCapStyle := csPhong;
  540. FCapPosition := cpUnder;
  541. FEdgeColor := clGray;
  542. FFillColor := clBlack;
  543. FRadius := 20;
  544. FEdgeThickness := 2;
  545. FDirty := True;
  546. end;
  547. destructor TSGPointerCapSettings.Destroy;
  548. begin
  549. FPhong.Free;
  550. inherited Destroy;
  551. end;
  552. procedure TSGPointerCapSettings.DirtyOnChange;
  553. begin
  554. FDirty := True; // if we get here some props must have changed, mark dirty
  555. if Assigned(FOnChange) then
  556. FOnChange(Self);
  557. end;
  558. { TSGPointerSettings }
  559. procedure TSGPointerSettings.SetColor(AValue: TColor);
  560. begin
  561. if FColor = AValue then
  562. Exit;
  563. FColor := AValue;
  564. DirtyOnChange;
  565. end;
  566. procedure TSGPointerSettings.SetLength(AValue: integer);
  567. begin
  568. if FLength = AValue then
  569. Exit;
  570. FLength := AValue;
  571. DirtyOnChange;
  572. end;
  573. procedure TSGPointerSettings.SetOnChange(AValue: TNotifyEvent);
  574. begin
  575. FOnChange := AValue;
  576. if Assigned(FOnChange) then
  577. FOnChange(Self);
  578. end;
  579. procedure TSGPointerSettings.SetThickness(AValue: integer);
  580. begin
  581. if FThickness = AValue then
  582. Exit;
  583. FThickness := AValue;
  584. DirtyOnChange;
  585. end;
  586. procedure TSGPointerSettings.SetStyle(AValue: TSGPointerStyle);
  587. begin
  588. if FStyle = AValue then
  589. Exit;
  590. FStyle := AValue;
  591. DirtyOnChange;
  592. end;
  593. procedure TSGPointerSettings.SetExtensionLength(AValue: integer);
  594. begin
  595. if FExtensionLength = AValue then
  596. Exit;
  597. FExtensionLength := AValue;
  598. DirtyOnChange;
  599. end;
  600. constructor TSGPointerSettings.Create;
  601. begin
  602. FColor := BGRA(255, 127, 63); // Orange pointer
  603. FLength := 160;
  604. FThickness := 5;
  605. FExtensionLength := 20;
  606. FStyle := psLineExt;
  607. FDirty := True;
  608. end;
  609. procedure TSGPointerSettings.DirtyOnChange;
  610. begin
  611. FDirty := True; // if we get here a prop must have changed, mark dirty
  612. if Assigned(FOnChange) then
  613. FOnChange(Self);
  614. end;
  615. destructor TSGPointerSettings.Destroy;
  616. begin
  617. inherited Destroy;
  618. end;
  619. { TSGScaleSettings }
  620. constructor TSGScaleSettings.Create;
  621. begin
  622. FTickColor := BGRA(223, 196, 125); // Tan
  623. FTextColor := BGRA(140, 208, 211); // Light Blue
  624. FTextFont := 'Calibri';
  625. FTextSize := 20;
  626. FTextRadius := 120;
  627. FEnableMainTicks := True;
  628. FEnableSubTicks := True;
  629. FEnableScaleText := True;
  630. FReverseScale := False;
  631. FMainTickCount := 10;
  632. FSubTickCount := 5;
  633. FStart := 0;
  634. FStep := 1;
  635. FLengthMainTick := 15;
  636. FLengthSubTick := 8;
  637. FThicknessMainTick := 3;
  638. FThicknessSubTick := 1;
  639. FTickArcStyle := taOuter;
  640. FScaleRadius := 155;
  641. FDirty := True;
  642. end;
  643. destructor TSGScaleSettings.Destroy;
  644. begin
  645. inherited Destroy;
  646. end;
  647. procedure TSGScaleSettings.SetTextFont(AValue: string);
  648. begin
  649. if FTextFont = AValue then
  650. Exit;
  651. FTextFont := AValue;
  652. DirtyOnChange;
  653. end;
  654. procedure TSGScaleSettings.SetEnableScaleText(AValue: boolean);
  655. begin
  656. if FEnableScaleText = AValue then
  657. Exit;
  658. FEnableScaleText := AValue;
  659. DirtyOnChange;
  660. end;
  661. procedure TSGScaleSettings.SetReverseScale(AValue: boolean);
  662. begin
  663. if FReverseScale = AValue then
  664. Exit;
  665. FReverseScale := AValue;
  666. DirtyOnChange;
  667. end;
  668. procedure TSGScaleSettings.SetScaleRadius(AValue: integer);
  669. begin
  670. if (FScaleRadius = AValue) or (AValue < 1) then
  671. Exit;
  672. FScaleRadius := AValue;
  673. DirtyOnChange;
  674. end;
  675. procedure TSGScaleSettings.SetMaximum(AValue: integer);
  676. begin
  677. if (FMaximum = AValue) or (AValue <= FMinimum) then
  678. Exit;
  679. FMaximum := AValue;
  680. DirtyOnChange;
  681. end;
  682. procedure TSGScaleSettings.SetStart(AValue: integer);
  683. begin
  684. if (FStart = AValue)then
  685. Exit;
  686. FStart := AValue;
  687. DirtyOnChange;
  688. end;
  689. procedure TSGScaleSettings.SetStep(AValue: integer);
  690. begin
  691. if (FStep = AValue)then
  692. Exit;
  693. FStep := AValue;
  694. DirtyOnChange;
  695. end;
  696. procedure TSGScaleSettings.SetMinimum(AValue: integer);
  697. begin
  698. if (FMinimum = AValue) then
  699. Exit;
  700. FMinimum := AValue;
  701. DirtyOnChange;
  702. end;
  703. procedure TSGScaleSettings.SetTextRadius(AValue: integer);
  704. begin
  705. if (FTextRadius = AValue) or (AValue < 1) then
  706. Exit;
  707. FTextRadius := AValue;
  708. DirtyOnChange;
  709. end;
  710. procedure TSGScaleSettings.SetTextSize(AValue: integer);
  711. begin
  712. if (FTextSize = AValue) or (AValue < 1) then
  713. Exit;
  714. FTextSize := AValue;
  715. DirtyOnChange;
  716. end;
  717. procedure TSGScaleSettings.SetTickColor(AValue: TColor);
  718. begin
  719. if FTickColor = AValue then
  720. Exit;
  721. FTickColor := AValue;
  722. DirtyOnChange;
  723. end;
  724. procedure TSGScaleSettings.SetTickArcStyle(AValue: TSGTickArc);
  725. begin
  726. if FTickArcStyle = AValue then
  727. exit;
  728. FTickArcStyle := AValue;
  729. DirtyOnChange;
  730. end;
  731. procedure TSGScaleSettings.SetEnableMainTicks(AValue: boolean);
  732. begin
  733. if FEnableMainTicks = AValue then
  734. Exit;
  735. FEnableMainTicks := AValue;
  736. DirtyOnChange;
  737. end;
  738. procedure TSGScaleSettings.SetEnableSubTicks(AValue: boolean);
  739. begin
  740. if FEnableSubTicks = AValue then
  741. Exit;
  742. FEnableSubTicks := AValue;
  743. DirtyOnChange;
  744. end;
  745. procedure TSGScaleSettings.SetLengthMainTick(AValue: integer);
  746. begin
  747. if (FLengthMainTick = AValue) or (AValue < 1) then
  748. Exit;
  749. FLengthMainTick := AValue;
  750. DirtyOnChange;
  751. end;
  752. procedure TSGScaleSettings.SetLengthSubTick(AValue: integer);
  753. begin
  754. if (FLengthSubTick = AValue) or (AValue < 1) then
  755. Exit;
  756. FLengthSubTick := AValue;
  757. DirtyOnChange;
  758. end;
  759. procedure TSGScaleSettings.SetMainTickCount(AValue: integer);
  760. begin
  761. if (FMainTickCount = AValue) or (AValue < 1) then
  762. Exit;
  763. FMainTickCount := AValue;
  764. DirtyOnChange;
  765. end;
  766. procedure TSGScaleSettings.SetOnChange(AValue: TNotifyEvent);
  767. begin
  768. FOnChange := AValue;
  769. if Assigned(FOnChange) then
  770. FOnChange(Self);
  771. end;
  772. procedure TSGScaleSettings.SetSubTickCount(AValue: integer);
  773. begin
  774. if (FSubTickCount = AValue) or (AValue < 1) then
  775. Exit;
  776. FSubTickCount := AValue;
  777. DirtyOnChange;
  778. end;
  779. procedure TSGScaleSettings.SetTextColor(AValue: TColor);
  780. begin
  781. if FTextColor = AValue then
  782. Exit;
  783. FTextColor := AValue;
  784. DirtyOnChange;
  785. end;
  786. procedure TSGScaleSettings.SetTextStyle(AValue: TFontStyles);
  787. begin
  788. if FTextStyle = AValue then
  789. Exit;
  790. FTextStyle := AValue;
  791. DirtyOnChange;
  792. end;
  793. procedure TSGScaleSettings.SetThicknessMainTick(AValue: integer);
  794. begin
  795. if (FThicknessMainTick = AValue) or (AValue < 1) then
  796. Exit;
  797. FThicknessMainTick := AValue;
  798. DirtyOnChange;
  799. end;
  800. procedure TSGScaleSettings.SetThicknessSubTick(AValue: integer);
  801. begin
  802. if (FThicknessSubTick = AValue) or (AValue < 1) then
  803. Exit;
  804. FThicknessSubTick := AValue;
  805. DirtyOnChange;
  806. end;
  807. procedure TSGScaleSettings.DirtyOnChange;
  808. begin
  809. FDirty := True; // if we get here a prop must have changed, mark dirty
  810. if Assigned(FOnChange) then
  811. FOnChange(Self);
  812. end;
  813. { TSGBandSettings}
  814. constructor TSGBandSettings.Create;
  815. begin
  816. FEnabled := False;
  817. FEnableText := False;
  818. FText := '';
  819. FTextColor := clBlack;
  820. FTextFont := 'default';
  821. FTextStyle := [];
  822. FTextSize := 20;
  823. FTextRadius := 100;
  824. FStartValue := 0;
  825. FEndValue := 20;
  826. FBandRadius := 100;
  827. FBandColor := clGreen;
  828. FBandThickness := 40;
  829. FStartValue := 0;
  830. FEndValue := 100;
  831. FDirty := True;
  832. end;
  833. destructor TSGBandSettings.Destroy;
  834. begin
  835. inherited Destroy;
  836. end;
  837. procedure TSGBandSettings.SetEnabled(AValue: boolean);
  838. begin
  839. if FEnabled = AValue then
  840. Exit;
  841. FEnabled := AValue;
  842. DirtyOnChange;
  843. end;
  844. procedure TSGBandSettings.SetTextFont(AValue: string);
  845. begin
  846. if FTextFont = AValue then
  847. Exit;
  848. FTextFont := AValue;
  849. DirtyOnChange;
  850. end;
  851. procedure TSGBandSettings.SetTextStyle(AValue: TFontStyles);
  852. begin
  853. if FTextStyle = AValue then
  854. Exit;
  855. FTextStyle := AValue;
  856. DirtyOnChange;
  857. end;
  858. procedure TSGBandSettings.SetEnableText(AValue: boolean);
  859. begin
  860. if FEnableText = AValue then
  861. Exit;
  862. FEnableText := AValue;
  863. DirtyOnChange;
  864. end;
  865. procedure TSGBandSettings.SetText(AValue: TCaption);
  866. begin
  867. if FText = AValue then
  868. Exit;
  869. FText := AValue;
  870. DirtyOnChange;
  871. end;
  872. procedure TSGBandSettings.SetTextRadius(AValue: integer);
  873. begin
  874. if (FTextRadius = AValue) or (AValue < 1) then
  875. Exit;
  876. FTextRadius := AValue;
  877. DirtyOnChange;
  878. end;
  879. procedure TSGBandSettings.SetBandRadius(AValue: integer);
  880. begin
  881. if (FBandRadius = AValue) or (AValue < 1) then
  882. Exit;
  883. FBandRadius := AValue;
  884. DirtyOnChange;
  885. end;
  886. procedure TSGBandSettings.SetStartValue(AValue: single);
  887. begin
  888. if (FStartValue = AValue) or (AValue >= FEndValue) then
  889. Exit;
  890. FStartValue := AValue;
  891. DirtyOnChange;
  892. end;
  893. procedure TSGBandSettings.SetEndValue(AValue: single);
  894. begin
  895. if (FEndValue = AValue) or (AValue <= FStartValue) then
  896. Exit;
  897. FEndValue := AValue;
  898. DirtyOnChange;
  899. end;
  900. procedure TSGBandSettings.SetTextSize(AValue: integer);
  901. begin
  902. if (FTextSize = AValue) or (AValue < 1) then
  903. Exit;
  904. FTextSize := AValue;
  905. DirtyOnChange;
  906. end;
  907. procedure TSGBandSettings.SetOnChange(AValue: TNotifyEvent);
  908. begin
  909. FOnChange := AValue;
  910. if Assigned(FOnChange) then
  911. FOnChange(Self);
  912. end;
  913. procedure TSGBandSettings.SetTextColor(AValue: TColor);
  914. begin
  915. if FTextColor = AValue then
  916. Exit;
  917. FTextColor := AValue;
  918. DirtyOnChange;
  919. end;
  920. procedure TSGBandSettings.SetBandColor(AValue: TColor);
  921. begin
  922. if FBandColor = AValue then
  923. Exit;
  924. FBandColor := AValue;
  925. DirtyOnChange;
  926. end;
  927. procedure TSGBandSettings.SetBandThickness(AValue: integer);
  928. begin
  929. if (FBandThickness = AValue) or (AValue < 1) then
  930. Exit;
  931. FBandThickness := AValue;
  932. DirtyOnChange;
  933. end;
  934. procedure TSGBandSettings.DirtyOnChange;
  935. begin
  936. FDirty := True;
  937. if Assigned(FOnChange) then
  938. FOnChange(Self);
  939. end;
  940. { TSGFaceSettings }
  941. constructor TSGFaceSettings.Create;
  942. begin
  943. // create a Phong shader, will need to delete on clean up
  944. FPhong := TPhongShading.Create;
  945. FPhong.LightPositionZ := 100;
  946. FPhong.LightSourceIntensity := 300;
  947. FPhong.NegativeDiffusionFactor := 0.8;
  948. FPhong.AmbientFactor := 0.5;
  949. FPhong.DiffusionFactor := 0.6;
  950. FCurveExponent := 0.05;
  951. FOuterColor := clBlack;
  952. FInnerColor := clGray;
  953. FFillStyle := fsGradient;
  954. FPicture := TPicture.Create;
  955. FPictureEnabled := FALSE;
  956. FPictureOffsetX := 0;
  957. FPictureOffsetY := 0;
  958. FDirty := True;
  959. end;
  960. destructor TSGFaceSettings.Destroy;
  961. begin
  962. FPhong.Free;
  963. FPicture.Free;
  964. inherited Destroy;
  965. end;
  966. procedure TSGFaceSettings.SetInnerColor(AValue: TColor);
  967. begin
  968. if FInnerColor = AValue then
  969. Exit;
  970. FInnerColor := AValue;
  971. DirtyOnChange;
  972. end;
  973. procedure TSGFaceSettings.SetOuterColor(AValue: TColor);
  974. begin
  975. if FOuterColor = AValue then
  976. Exit;
  977. FOuterColor := AValue;
  978. DirtyOnChange;
  979. end;
  980. procedure TSGFaceSettings.SetFillStyle(AValue: TSGFillStyle);
  981. begin
  982. if FFillStyle = AValue then
  983. Exit;
  984. FFillStyle := AValue;
  985. DirtyOnChange;
  986. end;
  987. procedure TSGFaceSettings.SetPicture(AValue: TPicture);
  988. begin
  989. if FPicture = AValue then
  990. Exit;
  991. FPicture := AValue;
  992. DirtyOnChange;
  993. end;
  994. procedure TSGFaceSettings.SetPictureEnabled(AValue: boolean);
  995. begin
  996. if FPictureEnabled = AValue then
  997. Exit;
  998. FPictureEnabled := AValue;
  999. DirtyOnChange;
  1000. end;
  1001. procedure TSGFaceSettings.SetPictureOffsetX(AValue: integer);
  1002. begin
  1003. if FPictureOffsetX = AValue then
  1004. Exit;
  1005. FPictureOffsetX := AValue;
  1006. DirtyOnChange;
  1007. end;
  1008. procedure TSGFaceSettings.SetPictureOffsetY(AValue: integer);
  1009. begin
  1010. if FPictureOffsetY = AValue then
  1011. Exit;
  1012. FPictureOffsetY := AValue;
  1013. DirtyOnChange;
  1014. end;
  1015. procedure TSGFaceSettings.SetLightIntensity(const AValue: integer);
  1016. begin
  1017. if AValue = FPhong.LightSourceIntensity then
  1018. Exit;
  1019. FPhong.LightSourceIntensity := AValue;
  1020. DirtyOnChange;
  1021. end;
  1022. function TSGFaceSettings.GetLightIntensity: integer;
  1023. begin
  1024. Result := round(FPhong.LightSourceIntensity);
  1025. end;
  1026. procedure TSGFaceSettings.SetCurveExponent(const AValue: single);
  1027. begin
  1028. if FCurveExponent = AValue then
  1029. Exit;
  1030. FCurveExponent := AValue;
  1031. DirtyOnChange;
  1032. end;
  1033. procedure TSGFaceSettings.SetOnChange(AValue: TNotifyEvent);
  1034. begin
  1035. FOnChange := AValue;
  1036. if Assigned(FOnChange) then
  1037. FOnChange(Self);
  1038. end;
  1039. procedure TSGFaceSettings.DirtyOnChange;
  1040. begin
  1041. FDirty := True; // if we get here a prop must have changed, mark dirty
  1042. if Assigned(FOnChange) then
  1043. FOnChange(Self);
  1044. end;
  1045. { TSGFrameSettings }
  1046. constructor TSGFrameSettings.Create;
  1047. begin
  1048. FFrameColor := clBlack;
  1049. FBorderColor := clGray;
  1050. FBorderRadius := 2;
  1051. FDirty := True;
  1052. end;
  1053. destructor TSGFrameSettings.Destroy;
  1054. begin
  1055. inherited Destroy;
  1056. end;
  1057. procedure TSGFrameSettings.SetBorderRadius(AValue: integer);
  1058. begin
  1059. if (FBorderRadius = AValue) or (AValue < 0) then
  1060. Exit;
  1061. FBorderRadius := AValue;
  1062. DirtyOnChange;
  1063. end;
  1064. procedure TSGFrameSettings.SetFrameColor(AValue: TColor);
  1065. begin
  1066. if FFrameColor = AValue then
  1067. Exit;
  1068. FFrameColor := AValue;
  1069. DirtyOnChange;
  1070. end;
  1071. procedure TSGFrameSettings.SetBorderColor(AValue: TColor);
  1072. begin
  1073. if FBorderColor = AValue then
  1074. Exit;
  1075. FBorderColor := AValue;
  1076. DirtyOnChange;
  1077. end;
  1078. procedure TSGFrameSettings.SetOnChange(AValue: TNotifyEvent);
  1079. begin
  1080. FOnChange := AValue;
  1081. if Assigned(FOnChange) then
  1082. FOnChange(Self);
  1083. end;
  1084. procedure TSGFrameSettings.DirtyOnChange;
  1085. begin
  1086. FDirty := True; // if we get here a prop must have changed, mark dirty
  1087. if Assigned(FOnChange) then
  1088. FOnChange(Self);
  1089. end;
  1090. { TSGLEDSettings }
  1091. constructor TSGLEDSettings.Create;
  1092. begin
  1093. FActiveColor := clRed;
  1094. FInActiveColor := clBlack;
  1095. FBorderColor := clGray;
  1096. FSize := 10;
  1097. FOffsetX := 0;
  1098. FOffsetY := 50;
  1099. FStyle := lsShaded;
  1100. FDirty := True;
  1101. end;
  1102. destructor TSGLEDSettings.Destroy;
  1103. begin
  1104. inherited Destroy;
  1105. end;
  1106. procedure TSGLEDSettings.SetActive(AValue: boolean);
  1107. begin
  1108. if FActive = AValue then
  1109. Exit;
  1110. FActive := AValue;
  1111. DirtyOnChange;
  1112. end;
  1113. // HACK, need to have a way to NOT dirty on change
  1114. procedure TSGLEDSettings.SetActiveNoDoChange(AValue: boolean);
  1115. begin
  1116. if FActive = AValue then
  1117. Exit;
  1118. FActive := AValue;
  1119. end;
  1120. procedure TSGLEDSettings.SetActiveColor(AValue: TColor);
  1121. begin
  1122. if FActiveColor = AValue then
  1123. Exit;
  1124. FActiveColor := AValue;
  1125. DirtyOnChange;
  1126. end;
  1127. procedure TSGLEDSettings.SetInactiveColor(AValue: TColor);
  1128. begin
  1129. if FInactiveColor = AValue then
  1130. Exit;
  1131. FInActiveColor := AValue;
  1132. DirtyOnChange;
  1133. end;
  1134. procedure TSGLEDSettings.SetBorderColor(AValue: TColor);
  1135. begin
  1136. if FBorderColor = AValue then
  1137. Exit;
  1138. FBorderColor := AValue;
  1139. DirtyOnChange;
  1140. end;
  1141. procedure TSGLEDSettings.SetSize(AValue: integer);
  1142. begin
  1143. if FSize = AValue then
  1144. Exit;
  1145. FSize := AValue;
  1146. DirtyOnChange;
  1147. end;
  1148. procedure TSGLEDSettings.SetOffsetX(AValue: integer);
  1149. begin
  1150. if FOffsetX = AValue then
  1151. Exit;
  1152. FOffsetX := AValue;
  1153. DirtyOnChange;
  1154. end;
  1155. procedure TSGLEDSettings.SetOffsetY(AValue: integer);
  1156. begin
  1157. if FOffsetY = AValue then
  1158. Exit;
  1159. FOffsetY := AValue;
  1160. DirtyOnChange;
  1161. end;
  1162. procedure TSGLEDSettings.SetStyle(AValue: TSGLEDStyle);
  1163. begin
  1164. if FStyle = AValue then
  1165. Exit;
  1166. FStyle := AValue;
  1167. DirtyOnChange;
  1168. end;
  1169. procedure TSGLEDSettings.SetShape(AValue: TSGLEDShape);
  1170. begin
  1171. if FShape = AValue then
  1172. Exit;
  1173. FShape := AValue;
  1174. DirtyOnChange;
  1175. end;
  1176. procedure TSGLEDSettings.SetOnChange(AValue: TNotifyEvent);
  1177. begin
  1178. FOnChange := AValue;
  1179. // this will not dirty it, may need to not sure
  1180. if Assigned(FOnChange) then
  1181. FOnChange(Self);
  1182. end;
  1183. procedure TSGLEDSettings.DirtyOnChange;
  1184. begin
  1185. FDirty := True; // if we get here a prop must have changed, mark dirty
  1186. if Assigned(FOnChange) then
  1187. FOnChange(Self);
  1188. end;
  1189. { TSGRangeCheckLEDSettings }
  1190. constructor TSGRangeCheckLEDSettings.Create;
  1191. begin
  1192. inherited Create;
  1193. FRangeStartValue := 0;
  1194. FRangeEndValue := 100;
  1195. FRangeType := rcNone;
  1196. FOffsetX := 90;
  1197. FOffsetY := 120;
  1198. end;
  1199. destructor TSGRangeCheckLEDSettings.Destroy;
  1200. begin
  1201. inherited Destroy;
  1202. end;
  1203. procedure TSGRangeCheckLEDSettings.SetRangeStartValue(AValue: single);
  1204. begin
  1205. if (FRangeStartValue = AValue) or (AValue > FRangeEndValue) then
  1206. Exit;
  1207. FRangeStartValue := AValue;
  1208. DirtyOnChange;
  1209. end;
  1210. procedure TSGRangeCheckLEDSettings.SetRangeEndValue(AValue: single);
  1211. begin
  1212. if (FRangeEndValue = AValue) or (AValue < FRangeStartValue) then
  1213. Exit;
  1214. FRangeEndValue := AValue;
  1215. DirtyOnChange;
  1216. end;
  1217. procedure TSGRangeCheckLEDSettings.SetRangeType(AValue: TSGRangeCheckType);
  1218. begin
  1219. if FRangeType = AValue then
  1220. Exit;
  1221. FRangeType := AValue;
  1222. DirtyOnChange;
  1223. end;
  1224. { TSGTextSettings }
  1225. constructor TSGTextSettings.Create;
  1226. begin
  1227. FText := 'Gauge';
  1228. OffsetX := 0;
  1229. OffsetY := 50; // default should be clear of default cap radius when it's drawn
  1230. FDirty := True;
  1231. // create font, must free in dtor
  1232. FFontEx := TBCFont.Create(nil);
  1233. FFontEx.Color := clWhite;
  1234. FFontEx.Style := [fsBold];
  1235. FFontEx.Height := 24;
  1236. end;
  1237. destructor TSGTextSettings.Destroy;
  1238. begin
  1239. FFontEx.Free;
  1240. inherited Destroy;
  1241. end;
  1242. procedure TSGTextSettings.SetEnabled(AValue: boolean);
  1243. begin
  1244. if FEnabled = AValue then
  1245. Exit;
  1246. FEnabled := AValue;
  1247. DirtyOnChange;
  1248. end;
  1249. procedure TSGTextSettings.SetText(AValue: TCaption);
  1250. begin
  1251. if FText = AValue then
  1252. Exit;
  1253. FText := AValue;
  1254. DirtyOnChange;
  1255. end;
  1256. procedure TSGTextSettings.SetOffsetX(AValue: integer);
  1257. begin
  1258. if FOffsetX = AValue then
  1259. Exit;
  1260. FOffsetX := AValue;
  1261. DirtyOnChange;
  1262. end;
  1263. procedure TSGTextSettings.SetOffsetY(AValue: integer);
  1264. begin
  1265. if FOffsetY = AValue then
  1266. Exit;
  1267. FOffsetY := AValue;
  1268. DirtyOnChange;
  1269. end;
  1270. procedure TSGTextSettings.SetOnChange(AValue: TNotifyEvent);
  1271. begin
  1272. FOnChange := AValue;
  1273. // this will not dirty it, may need to not sure
  1274. if Assigned(FOnChange) then
  1275. FOnChange(Self);
  1276. end;
  1277. procedure TSGTextSettings.DirtyOnChange;
  1278. begin
  1279. FDirty := True;
  1280. if Assigned(FOnChange) then
  1281. FOnChange(Self);
  1282. end;
  1283. procedure TSGTextSettings.SetFontEx(AValue: TBCFont);
  1284. begin
  1285. FFontEx.Assign(AValue);
  1286. FDirty := True;
  1287. DirtyOnChange;
  1288. end;
  1289. {TSGMarkerSettings}
  1290. constructor TSGMarkerSettings.Create;
  1291. begin
  1292. FEnabled := False;
  1293. FColor := clLime;
  1294. FHeight := 20;
  1295. FWidth := 10;
  1296. FRadius := 165;
  1297. FStyle := msCenter;
  1298. FDirty := True;
  1299. FValue := 0.0;
  1300. end;
  1301. destructor TSGMarkerSettings.Destroy;
  1302. begin
  1303. inherited Destroy;
  1304. end;
  1305. procedure TSGMarkerSettings.SetValue(AValue: single);
  1306. begin
  1307. if FValue = AValue then
  1308. Exit;
  1309. FValue := AValue;
  1310. DirtyOnChange;
  1311. end;
  1312. procedure TSGMarkerSettings.SetEnabled(AValue: boolean);
  1313. begin
  1314. if FEnabled = AValue then
  1315. Exit;
  1316. FEnabled := AValue;
  1317. DirtyOnChange;
  1318. end;
  1319. procedure TSGMarkerSettings.SetColor(AValue: TColor);
  1320. begin
  1321. if FColor = AValue then
  1322. Exit;
  1323. FColor := AValue;
  1324. DirtyOnChange;
  1325. end;
  1326. procedure TSGMarkerSettings.SetHeight(AValue: integer);
  1327. begin
  1328. if FHeight = AValue then
  1329. Exit;
  1330. FHeight := AValue;
  1331. DirtyOnChange;
  1332. end;
  1333. procedure TSGMarkerSettings.SetRadius(AValue: integer);
  1334. begin
  1335. if FRadius = AValue then
  1336. Exit;
  1337. FRadius := AValue;
  1338. DirtyOnChange;
  1339. end;
  1340. procedure TSGMarkerSettings.SetWidth(AValue: integer);
  1341. begin
  1342. if FWidth = AValue then
  1343. Exit;
  1344. FWidth := AValue;
  1345. DirtyOnChange;
  1346. end;
  1347. procedure TSGMarkerSettings.SetOnChange(AValue: TNotifyEvent);
  1348. begin
  1349. FOnChange := AValue;
  1350. // no dirty needed possibly, call directly
  1351. if Assigned(FOnChange) then
  1352. FOnChange(Self);
  1353. end;
  1354. procedure TSGMarkerSettings.SetStyle(AValue: TSGMarkerStyle);
  1355. begin
  1356. if FStyle = AValue then
  1357. Exit;
  1358. FStyle := AValue;
  1359. DirtyOnChange;
  1360. end;
  1361. procedure TSGMarkerSettings.DirtyOnChange;
  1362. begin
  1363. FDirty := True; // if we get here some props must have changed, mark dirty
  1364. if Assigned(FOnChange) then
  1365. FOnChange(Self);
  1366. end;
  1367. end.