Commit d640e350 authored by Claes Sjofors's avatar Claes Sjofors

Ge dynamics, only one of the min/max attributes need to be set in axis, bar and trend

parent b2db246e
......@@ -9746,13 +9746,32 @@ int GeBar::scan(grow_tObject object)
if (!p)
return 1;
if (max_value_p && min_value_p) {
pwr_tFloat32 maxval = *max_value_p;
pwr_tFloat32 minval = *min_value_p;
if (max_value_p || min_value_p) {
bool update = false;
pwr_tFloat32 maxval;
pwr_tFloat32 minval;
if (max_value_p) {
maxval = *max_value_p;
if (!feqf(maxval, old_max_value))
update = true;
}
if (min_value_p) {
minval = *min_value_p;
if (!feqf(minval, old_min_value))
update = true;
}
if (update) {
double minvald, maxvald;
grow_GetBarRange(object, &minvald, &maxvald);
if (!min_value_p)
minval = minvald;
if (!max_value_p)
maxval = maxvald;
if (!feqf(maxval, old_max_value) || !feqf(minval, old_min_value)) {
if (fabsf(maxval - minval) > FLT_EPSILON) {
grow_SetBarRange(object, double(minval), double(maxval));
grow_SetBarRange(object, minval, maxval);
}
old_min_value = minval;
old_max_value = maxval;
......@@ -10275,24 +10294,64 @@ int GeTrend::scan(grow_tObject object)
if (trend_hold)
return 1;
if (max_value1_p && min_value1_p) {
pwr_tFloat32 maxval = *max_value1_p;
pwr_tFloat32 minval = *min_value1_p;
if (!feqf(maxval, old_max_value1) || !feqf(minval, old_min_value1)) {
if (max_value1_p || min_value1_p) {
bool update = false;
pwr_tFloat32 maxval;
pwr_tFloat32 minval;
if (max_value1_p) {
maxval = *max_value1_p;
if (!feqf(maxval, old_max_value1))
update = true;
}
if (min_value1_p) {
minval = *min_value1_p;
if (!feqf(minval, old_min_value1))
update = true;
}
if (update) {
double minvald, maxvald;
grow_GetTrendRangeY(object, 0, &minvald, &maxvald);
if (!min_value1_p)
minval = minvald;
if (!max_value1_p)
maxval = maxvald;
if (fabsf(maxval - minval) > FLT_EPSILON) {
grow_SetTrendRangeY(object, 0, double(minval), double(maxval));
grow_SetTrendRangeY(object, 0, minval, maxval);
}
old_min_value1 = minval;
old_max_value1 = maxval;
}
}
if (max_value2_p && min_value2_p) {
pwr_tFloat32 maxval = *max_value2_p;
pwr_tFloat32 minval = *min_value2_p;
if (!feqf(maxval, old_max_value2) || !feqf(minval, old_min_value2)) {
if (max_value2_p || min_value2_p) {
bool update = false;
pwr_tFloat32 maxval;
pwr_tFloat32 minval;
if (max_value2_p) {
maxval = *max_value2_p;
if (!feqf(maxval, old_max_value2))
update = true;
}
if (min_value2_p) {
minval = *min_value2_p;
if (!feqf(minval, old_min_value2))
update = true;
}
if (update) {
double minvald, maxvald;
grow_GetTrendRangeY(object, 1, &minvald, &maxvald);
if (!min_value2_p)
minval = minvald;
if (!max_value2_p)
maxval = maxvald;
if (fabsf(maxval - minval) > FLT_EPSILON) {
grow_SetTrendRangeY(object, 1, double(minval), double(maxval));
grow_SetTrendRangeY(object, 1, minval, maxval);
}
old_min_value2 = minval;
old_max_value2 = maxval;
......@@ -13709,6 +13768,11 @@ int GeAxis::connect(grow_tObject object, glow_sTraceData* trace_data, bool now)
int min_found = 0;
int max_found = 0;
int db;
glow_sAxisInfo info;
grow_GetAxisInfo( object, &info);
min_value = info.min_value;
max_value = info.max_value;
imin_value = (int)(min_value + (min_value >= 0 ? 1 : -1) * 0.5);
imax_value = (int)(max_value + (max_value >= 0 ? 1 : -1) * 0.5);
......@@ -15002,9 +15066,11 @@ int GeFillLevel::scan(grow_tObject object)
if (!p)
return 1;
if (max_value_p && min_value_p
&& (!feqf(*max_value_p, max_value) || !feqf(*min_value_p, min_value))) {
if (min_value_p && !feqf(*min_value_p, min_value)) {
min_value = *min_value_p;
first_scan = 1;
}
if (max_value_p && !feqf(*max_value_p, max_value)) {
max_value = *max_value_p;
first_scan = 1;
}
......
......@@ -4693,11 +4693,21 @@ void grow_SetSliderRange(grow_tObject object, double min, double max)
((GrowSlider*)object)->set_range(min, max);
}
void grow_GetBarRange(grow_tObject object, double *min, double *max)
{
((GrowBar*)object)->get_range(min, max);
}
void grow_SetBarRange(grow_tObject object, double min, double max)
{
((GrowBar*)object)->set_range(min, max);
}
void grow_GetTrendRangeY(grow_tObject object, int curve, double *min, double *max)
{
((GrowTrend*)object)->get_range_y(curve, min, max);
}
void grow_SetTrendRangeY(grow_tObject object, int curve, double min, double max)
{
((GrowTrend*)object)->set_range_y(curve, min, max);
......@@ -5209,6 +5219,14 @@ void grow_SetAxisInfo(grow_tObject object, glow_sAxisInfo* info)
((GrowAxisArc*)object)->set_axis_info(info);
}
void grow_GetAxisInfo(grow_tObject object, glow_sAxisInfo* info)
{
if (((GlowArrayElem*)object)->type() == glow_eObjectType_GrowAxis)
((GrowAxis*)object)->get_axis_info(info);
else if (((GlowArrayElem*)object)->type() == glow_eObjectType_GrowAxisArc)
((GrowAxisArc*)object)->get_axis_info(info);
}
void grow_SetTableInfo(grow_tObject object, glow_sTableInfo* info)
{
((GrowTable*)object)->set_table_info(info);
......
......@@ -2311,6 +2311,14 @@ int grow_IsSubGraph(grow_tCtx ctx);
*/
void grow_SetSliderRange(grow_tObject object, double min, double max);
//! Get the range of a bar object.
/*!
\param object Bar object.
\param min Minimum value of range.
\param max Maximum value of range.
*/
void grow_GetBarRange(grow_tObject object, double *min, double *max);
//! Set the range of a bar object.
/*!
\param object Bar object.
......@@ -2326,6 +2334,16 @@ void grow_SetBarRange(grow_tObject object, double min, double max);
*/
void grow_SetTrendFillCurve(grow_tObject object, int fill);
//! Get the range of a trend object.
/*!
\param object Trend object.
\param curve Curve number.
\param min Minimum value of range.
\param max Maximum value of range.
*/
void grow_GetTrendRangeY(
grow_tObject object, int curve, double *min, double *max);
//! Set the range of a trend object.
/*!
\param object Trend object.
......@@ -3059,6 +3077,13 @@ void grow_GetBarInfo(grow_tObject object, glow_sBarInfo* info);
*/
void grow_SetAxisInfo(grow_tObject object, glow_sAxisInfo* info);
//! Get parameters for an axis object.
/*!
\param object Axis object.
\param info Info struct.
*/
void grow_GetAxisInfo(grow_tObject object, glow_sAxisInfo* info);
//! Conversion between different versions of Glow
/*!
\param ctx Grow context.
......
......@@ -952,6 +952,16 @@ void GrowAxis::set_axis_info(glow_sAxisInfo* info)
strcpy(format, info->format);
}
void GrowAxis::get_axis_info(glow_sAxisInfo* info)
{
info->max_value = max_value;
info->min_value = min_value;
info->lines = lines;
info->longquotient = longquotient;
info->valuequotient = valuequotient;
strcpy(info->format, format);
}
void GrowAxis::format_text(char* text, char* fmt, double value)
{
if (streq(fmt, "%1t")) {
......
......@@ -215,6 +215,12 @@ public:
*/
void set_axis_info(glow_sAxisInfo* info);
//! Get parameters for the axis.
/*!
\param info Info struct.
*/
void get_axis_info(glow_sAxisInfo* info);
//! Export the object as a javabean.
/*!
\param t Transform of parent node. Can be zero.
......
......@@ -770,6 +770,16 @@ void GrowAxisArc::set_axis_info(glow_sAxisInfo* info)
strcpy(format, info->format);
}
void GrowAxisArc::get_axis_info(glow_sAxisInfo* info)
{
info->max_value = max_value;
info->min_value = min_value;
info->lines = lines;
info->longquotient = longquotient;
info->valuequotient = valuequotient;
strcpy(info->format, format);
}
void GrowAxisArc::format_text(char* text, char* fmt, double value)
{
if (streq(fmt, "%1t")) {
......
......@@ -215,6 +215,12 @@ public:
*/
void set_axis_info(glow_sAxisInfo* info);
//! Get parameters for the axis.
/*!
\param info Info struct.
*/
void get_axis_info(glow_sAxisInfo* info);
//! Export the object as a javabean.
/*!
\param t Transform of parent node. Can be zero.
......
......@@ -559,6 +559,12 @@ void GrowBar::get_trace_attr(GlowTraceData** attr)
*attr = &trace;
}
void GrowBar::get_range(double *min, double *max)
{
*max = max_value;
*min = min_value;
}
void GrowBar::set_range(double min, double max)
{
max_value = max;
......
......@@ -217,6 +217,13 @@ public:
*/
void align(double x, double y, glow_eAlignDirection direction);
//! Get the range for the bar value
/*!
\param min Min value.
\param max Max value.
*/
void get_range(double *min, double *max);
//! Set the range for the bar value
/*!
\param min Min value.
......
......@@ -949,6 +949,18 @@ void GrowTrend::set_scan_time(double time)
configure_curves();
}
//! Get the range for the specified trend in y direction.
/*!
\param curve Number of curve.
\param min Min value.
\param max Max value.
*/
void GrowTrend::get_range_y(int curve, double *min, double *max)
{
*max = y_max_value[curve];
*min = y_min_value[curve];
}
//! Set the range for the specified trend in y direction.
/*!
\param curve Number of curve.
......
......@@ -167,6 +167,7 @@ public:
*time = scan_time;
}
void get_range_y(int curve, double *min, double *max);
void set_range_y(int curve, double min, double max);
//! Set fill for curves.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment