supergaugecommon.pas 46 KB

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