This commit is contained in:
2024-11-19 22:03:44 +03:30
parent ee9ea11b6a
commit a345aa52c1
7 changed files with 1003 additions and 43 deletions
+245 -2
View File
@@ -1801,6 +1801,168 @@ class XCSignalObject : public XCBaseObject
//
// Zone Ticks ...
//
// Specify How to Draws Specified Levels ...
struct XTickZoneLevelSpecs
{
//
double percent; // Max Allowed Percent of Tick Zone ...
//
// Label Info ...
color labelColor;
string labelFont;
int labelFontSize;
double labelAngel;
//
// Zone Info ...
bool zoneFill;
int zoneWidth;
color zoneColor;
ENUM_LINE_STYLE zoneStyle;
//
// Constructor ...
XTickZoneLevelSpecs()
{
Default();
}
//
// Tools ...
/**
* Initialize Drawing Specs ...
*
* @param _percent: Double, Max Allowed Percent ...
* @param _labelColor: Color, Specified Label Color ...
* @param _zoneColoe: Color, Specified Zone Color ...
* @param _zoneFill: Boolean, Specified Fill Zone or not ...
* @param _zoneStyle: ENUM_LINE_STYLE member, Specified Zone Style ...
* @param _labelFontSize: Integer, Specified Label Font Size ...
* @param _labelFont: String, Specified Label Font Name ...
* @param _labelAngel: Double, Specified Label Angel ...
*
* @return ( bool )
*/
bool Init(
double _percent,
color _labelColor = clrWhite,
color _zoneColor = clrWhite,
bool _zoneFill = false,
ENUM_LINE_STYLE _zoneStyle = STYLE_DOT,
int _zoneWidth = 1,
int _labelFontSize = 12,
string _labelFont = "Arial",
double _labelAngel = 0 //
)
{
//
bool result = false;
//
Default();
//
result = _percent > 0;
if (!result)
{
return result;
}
//
percent = _percent;
labelColor = _labelColor;
zoneColor = _zoneColor;
zoneFill = _zoneFill;
zoneStyle = _zoneStyle;
//
if (_zoneWidth > 0)
{
zoneWidth = _zoneWidth;
}
//
if (_labelFontSize > 0)
{
labelFontSize = _labelFontSize;
}
//
if (IsSpecifiedValid(_labelFont))
{
labelFont = _labelFont;
}
//
if (_labelAngel >= 0)
{
labelAngel = _labelAngel;
}
//
result = IsValid();
//
return result;
}
/**
* Set Default Properties ...
*/
void Default()
{
//
percent = 0;
//
// Label ...
labelAngel = 0;
labelFontSize = 13;
labelFont = "Arial";
labelColor = clrWhite;
//
// Zone ...
zoneWidth = 1;
zoneFill = false;
zoneColor = clrWhite;
zoneStyle = STYLE_DOT;
}
/**
* Validate ...
*
* @return ( bool )
*/
bool IsValid()
{
//
bool result = false;
//
result =
//
percent > 0 &&
//
// Zone ...
zoneWidth > 0 &&
//
// Label ...
labelFontSize > 0 &&
IsSpecifiedValid(labelFont)
//
;
//
return result;
}
//
};
class XCTickZoneObject : public XCBaseObject
{
//
@@ -2028,6 +2190,7 @@ class XCTicksZoneObject : public XCBaseObject
long chart_id,
int window,
XCTicksZone &zone,
XTickZoneLevelSpecs &specs[],
string prefix = NULL //
)
{
@@ -2057,7 +2220,7 @@ class XCTicksZoneObject : public XCBaseObject
XCTickZone *iZone = zone.GetZone(i);
XCTickZoneObject *iObj;
iObj = new XCTickZoneObject();
result = iObj.Create(
bool isCreated = iObj.Create(
chart_id,
window,
ToString(i) + "_" + name,
@@ -2066,11 +2229,35 @@ class XCTicksZoneObject : public XCBaseObject
iZone,
prefix //
);
if (!result)
if (!isCreated)
{
break;
}
//
XTickZoneLevelSpecs iSpec;
bool hasSpecs = FindSpecs(
iZone,
iSpec,
specs //
);
if (hasSpecs)
{
//
// Label ...
iObj.LabelFont(iSpec.labelFont);
iObj.LabelAngle(iSpec.labelAngel);
iObj.LabelColor(iSpec.labelColor);
iObj.LabelSize(iSpec.labelFontSize);
//
// Zone ...
iObj.ZoneFill(iSpec.zoneFill);
iObj.ZoneColor(iSpec.zoneColor);
iObj.ZoneWidth(iSpec.zoneWidth);
iObj.ZoneStyle(iSpec.zoneStyle);
}
//
mZones.Add(iObj);
}
@@ -2108,11 +2295,67 @@ class XCTicksZoneObject : public XCBaseObject
//
// Actions ...
/**
* Destroy Object ...
*/
void Destroy()
{
mZones.Clear();
}
/**
* Find Specified TickZone Drawing Specs ...
*
* @param zone: XCTickZone instance, reference to Search For it ...
* @param spec: XTickZoneLevelSpecs instance, reference to Result ...
* @param specs: XTickZoneLevelSpecs instance Collection for Search ...
*
* @return ( bool )
*/
bool FindSpecs(
XCTickZone *zone,
XTickZoneLevelSpecs &spec,
XTickZoneLevelSpecs &specs[] //
)
{
//
bool result = false;
//
int count = ArraySize(specs);
result =
zone.IsValid() &&
IsValidSize(count);
if (!result)
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
XTickZoneLevelSpecs iSpecs = specs[i];
//
bool isSpecValidForZone =
!spec.IsValid()
? zone.percent <= iSpecs.percent
: zone.percent <= iSpecs.percent &&
spec.percent > iSpecs.percent;
if (isSpecValidForZone)
{
spec = iSpecs;
}
}
//
result = spec.IsValid();
//
return result;
}
//
private:
//