Commit 294272ba authored by Claes Sjofors's avatar Claes Sjofors

Ge new circular bar component BarArc

parent 44936a9b
This diff is collapsed.
......@@ -2137,6 +2137,7 @@ int GeDyn::connect(grow_tObject object, glow_sTraceData* trace_data, bool now)
int inherit_action_type2;
if (grow_GetObjectType(object) == glow_eObjectType_GrowBar
|| grow_GetObjectType(object) == glow_eObjectType_GrowBarArc
|| grow_GetObjectType(object) == glow_eObjectType_GrowTable
|| grow_GetObjectType(object) == glow_eObjectType_GrowWindow
|| grow_GetObjectType(object) == glow_eObjectType_GrowXYCurve
......@@ -2249,6 +2250,7 @@ void GeDyn::export_java(grow_tObject object, std::ofstream& fp, char* var_name)
int inherit_dyn_type2, inherit_action_type2;
if (grow_GetObjectType(object) == glow_eObjectType_GrowBar
|| grow_GetObjectType(object) == glow_eObjectType_GrowBarArc
|| grow_GetObjectType(object) == glow_eObjectType_GrowTable
|| grow_GetObjectType(object) == glow_eObjectType_GrowWindow
|| grow_GetObjectType(object) == glow_eObjectType_GrowXYCurve
......
......@@ -1452,6 +1452,23 @@ int Graph::get_attr_items(grow_tObject object, attr_sItem** itemlist,
*item_cnt = 0;
dyn->get_attributes(object, items, item_cnt);
*client_data = 0;
} else if (grow_GetObjectType(object) == glow_eObjectType_GrowBarArc) {
char transtab[][32] = { "MaxValue", "BarArc.MaxValue", "MinValue",
"BarArc.MinValue", "Angle1", "BarArc.Angle1", "Angle2", "BarArc.Angle2",
"BarWidth", "BarArc.BarWidth", "BarDirection", "BarArc.Direction",
"BarValue", "BarArc.Value", "BarColor", "BarArc.BarColor",
"BarBorderColor", "BarArc.BorderColor", "BarBorderWidth", "BarArc.BorderWidth",
"Dynamic", "Dynamic", "" };
GeDyn* dyn;
grow_GetObjectAttrInfo(object, (char*)transtab, &grow_info, &grow_info_cnt);
grow_GetUserData(object, (void**)&dyn);
*item_cnt = 0;
dyn->get_attributes(object, items, item_cnt);
*client_data = 0;
} else if (grow_GetObjectType(object) == glow_eObjectType_GrowWindow) {
char transtab[][32] = { "FileName", "Window.FileName", "WindowScale",
......@@ -1476,7 +1493,8 @@ int Graph::get_attr_items(grow_tObject object, attr_sItem** itemlist,
"HeaderColumn", "Table.HeaderColumn", "HeaderRowHeight",
"Table.HeaderRowHeight", "HeaderTextSize", "Table.HeaderTextSize",
"HeaderTextBold", "Table.HeaderTextBold", "HeaderTextBold",
"Table.HeaderTextBold", "SelectColor", "Table.SelectColor", "Options",
"Table.HeaderTextBold", "HeaderTextColor", "Table.HeaderTextColor",
"SelectColor", "Table.SelectColor", "Options",
"Table.Options", "VerticalScrollbar", "Table.VerticalScrollbar",
"HorizontalScrollbar", "Table.HorizontalScrollbar", "ScrollbarWidth",
"Table.ScrollbarWidth", "ScrollbarColor", "Table.ScrollbarColor",
......@@ -1887,6 +1905,7 @@ int Graph::graph_attr_recall_cb(
|| grow_GetObjectType(object) == glow_eObjectType_GrowXYCurve
|| grow_GetObjectType(object) == glow_eObjectType_GrowTable
|| grow_GetObjectType(object) == glow_eObjectType_GrowBar
|| grow_GetObjectType(object) == glow_eObjectType_GrowBarArc
|| grow_GetObjectType(object) == glow_eObjectType_GrowPie
|| grow_GetObjectType(object) == glow_eObjectType_GrowBarChart
|| grow_GetObjectType(object) == glow_eObjectType_GrowAxis
......@@ -2527,6 +2546,12 @@ static int graph_grow_cb(GlowCtx* ctx, glow_tEvent event)
graph->create_bar(
&t1, event->create_grow_object.x, event->create_grow_object.y, 0);
graph->journal_store(journal_eAction_CreateObject, t1);
} else if (streq(sub_name, "pwr_bararc")) {
grow_tObject t1;
graph->create_bararc(
&t1, event->create_grow_object.x, event->create_grow_object.y, 0);
graph->journal_store(journal_eAction_CreateObject, t1);
} else if (streq(sub_name, "pwrct_bar")) {
grow_tObject t1;
......@@ -3638,6 +3663,8 @@ static int graph_trace_grow_cb(GlowCtx* ctx, glow_tEvent event)
== glow_eObjectType_GrowTable
|| grow_GetObjectType(event->object.object)
== glow_eObjectType_GrowBar
|| grow_GetObjectType(event->object.object)
== glow_eObjectType_GrowBarArc
|| grow_GetObjectType(event->object.object)
== glow_eObjectType_GrowPie
|| grow_GetObjectType(event->object.object)
......@@ -3674,6 +3701,8 @@ static int graph_trace_grow_cb(GlowCtx* ctx, glow_tEvent event)
== glow_eObjectType_GrowTable
|| grow_GetObjectType(graph->current_mb1_down)
== glow_eObjectType_GrowBar
|| grow_GetObjectType(graph->current_mb1_down)
== glow_eObjectType_GrowBarArc
|| grow_GetObjectType(graph->current_mb1_down)
== glow_eObjectType_GrowPie
|| grow_GetObjectType(graph->current_mb1_down)
......@@ -3833,6 +3862,8 @@ static int graph_trace_grow_cb(GlowCtx* ctx, glow_tEvent event)
== glow_eObjectType_GrowWindow
|| grow_GetObjectType(event->object.object)
== glow_eObjectType_GrowBar
|| grow_GetObjectType(event->object.object)
== glow_eObjectType_GrowBarArc
|| grow_GetObjectType(event->object.object)
== glow_eObjectType_GrowTable
|| grow_GetObjectType(event->object.object)
......@@ -3920,6 +3951,7 @@ static int graph_trace_grow_cb(GlowCtx* ctx, glow_tEvent event)
|| grow_GetObjectType(event->object.object)
== glow_eObjectType_GrowWindow
|| grow_GetObjectType(event->object.object) == glow_eObjectType_GrowBar
|| grow_GetObjectType(event->object.object) == glow_eObjectType_GrowBarArc
|| grow_GetObjectType(event->object.object)
== glow_eObjectType_GrowTable
|| grow_GetObjectType(event->object.object)
......@@ -5507,6 +5539,42 @@ void Graph::create_bar(grow_tObject* object, double x, double y, int colortheme)
grow_Redraw(grow->ctx);
}
void Graph::create_bararc(grow_tObject* object, double x, double y, int colortheme)
{
double width = 5;
double height = 5;
double bar_width = 1;
GeDyn* dyn;
glow_sBarInfo info;
glow_eDrawType backgroundcolor, barcolor, barbordercolor;
if (colortheme) {
backgroundcolor = glow_eCtColor_BarBackgroundColor;
barcolor = glow_eCtColor_BarBarColor;
barbordercolor = glow_eCtColor_BarBarLimitColor;
} else {
backgroundcolor = glow_eDrawType_Color40;
barcolor = glow_eDrawType_Color147;
barbordercolor = glow_eDrawType_Color145;
}
grow_CreateGrowBarArc(grow->ctx, get_next_object_name("O", ""), x, y, x + width,
y + height, 0, 360, bar_width, glow_eDrawType_Line, 1, 1,
backgroundcolor, NULL, object);
dyn = new GeDyn(this);
dyn->dyn_type1 = dyn->total_dyn_type1 = ge_mDynType1_Bar;
dyn->update_elements();
grow_SetUserData(*object, (void*)dyn);
info.bar_drawtype = barcolor;
info.bar_bordercolor = barbordercolor;
info.bar_borderwidth = 1;
info.max_value = 100;
info.min_value = 0;
grow_SetBarArcInfo(*object, &info);
grow_Redraw(grow->ctx);
}
void Graph::create_window(grow_tObject* object, double x, double y)
{
double width = 8;
......
......@@ -1399,6 +1399,15 @@ public:
*/
void create_bar(grow_tObject* object, double x, double y, int colortheme);
//! Create a bararc object.
/*!
\param object Created bar object.
\param x x coordinate for object.
\param y y coordinate for object.
\param colortheme Use colortheme colors.
*/
void create_bararc(grow_tObject* object, double x, double y, int colortheme);
//! Create a window object.
/*!
\param object Created bar object.
......
......@@ -20,6 +20,7 @@ menu Analog
subgraph FastCurve pwr_fastcurve.component 25
subgraph XYCurve pwr_xycurve.component 25
subgraph Bar pwr_bar.component 26
subgraph BarArc pwr_bararc.component 26
subgraph Axis pwr_axis.component 27
subgraph DynamicAxis pwr_dynamicaxis.component 27
subgraph AxisArc pwr_axisarc.component 250
......
......@@ -224,7 +224,8 @@ typedef enum {
glow_eObjectType_GrowAxisArc,
glow_eObjectType_GrowPie,
glow_eObjectType_GrowBarChart,
glow_eObjectType_GrowToolbar
glow_eObjectType_GrowToolbar,
glow_eObjectType_GrowBarArc
} glow_eObjectType;
//! Direction of a connection points, sliders etc
......@@ -1311,6 +1312,7 @@ typedef enum {
glow_eSave_GrowBarChart = 46,
glow_eSave_GrowToolbar = 47,
glow_eSave_CustomColors = 48,
glow_eSave_GrowBarArc = 49,
glow_eSave_End = 99,
glow_eSave_Ctx_zoom_factor_x = 100,
glow_eSave_Ctx_base_zoom_factor = 101,
......@@ -2069,7 +2071,18 @@ typedef enum {
glow_eSave_CustomColors_colors_size = 4800,
glow_eSave_CustomColors_colors = 4801,
glow_eSave_CustomColors_colortheme_lightness = 4802,
glow_eSave_CustomColors_is_default_colortheme = 4803
glow_eSave_CustomColors_is_default_colortheme = 4803,
glow_eSave_GrowBarArc_max_value = 4900,
glow_eSave_GrowBarArc_min_value = 4901,
glow_eSave_GrowBarArc_bar_width = 4902,
glow_eSave_GrowBarArc_bar_value = 4903,
glow_eSave_GrowBarArc_bar_drawtype = 4904,
glow_eSave_GrowBarArc_direction = 4905,
glow_eSave_GrowBarArc_arc_part = 4906,
glow_eSave_GrowBarArc_bar_bordercolor = 4907,
glow_eSave_GrowBarArc_bar_borderwidth = 4908,
glow_eSave_GrowBarArc_userdata_cb = 4909,
glow_eSave_GrowBarArc_bar_direction = 4910
} glow_eSave;
//! Relative or absolute position for an annotation
......
......@@ -48,6 +48,7 @@
#include "glow_growslider.h"
#include "glow_growtext.h"
#include "glow_growbar.h"
#include "glow_growbararc.h"
#include "glow_growslider.h"
#include "glow_growimage.h"
#include "glow_growgroup.h"
......@@ -227,7 +228,7 @@ void GlowArray::copy_from(const GlowArray& array)
n->highlight = 0;
n->hot = 0;
if (n->ctx->userdata_copy_callback)
(n->ctx->userdata_copy_callback)(n, ((GrowBarChart*)array.a[i])->user_data,
(n->ctx->userdata_copy_callback)(n, ((GrowPie*)array.a[i])->user_data,
&n->user_data, glow_eUserdataCbType_Node);
insert(n);
break;
......@@ -313,6 +314,17 @@ void GlowArray::copy_from(const GlowArray& array)
insert(n);
break;
}
case glow_eObjectType_GrowBarArc: {
GrowBarArc* n = new GrowBarArc(*(GrowBarArc*)array.a[i]);
n->highlight = 0;
n->hot = 0;
// Fix, This should be done in the copy constructor !!!
if (n->ctx->userdata_copy_callback)
(n->ctx->userdata_copy_callback)(n, ((GrowBarArc*)array.a[i])->user_data,
&n->user_data, glow_eUserdataCbType_Node);
insert(n);
break;
}
case glow_eObjectType_GrowTrend: {
GrowTrend* n = new GrowTrend(*(GrowTrend*)array.a[i]);
n->highlight = 0;
......@@ -1035,6 +1047,12 @@ void GlowArray::open(GrowCtx* ctx, std::ifstream& fp)
insert(n);
break;
}
case glow_eSave_GrowBarArc: {
GrowBarArc* n = new GrowBarArc(ctx, "");
n->open(fp);
insert(n);
break;
}
case glow_eSave_GrowTrend: {
GrowTrend* n = new GrowTrend(ctx, "", 0, 0, 0, 0, glow_eDrawType_Line, 1,
glow_mDisplayLevel_1, 0, 1, glow_eDrawType_Line, 1);
......
......@@ -49,6 +49,7 @@
#include "glow_growannot.h"
#include "glow_growtext.h"
#include "glow_growbar.h"
#include "glow_growbararc.h"
#include "glow_growxycurve.h"
#include "glow_growtable.h"
#include "glow_growfolder.h"
......@@ -922,6 +923,19 @@ void grow_CreateGrowBar(grow_tCtx ctx, const char* name, double x, double y,
*bar = (grow_tObject)r1;
}
void grow_CreateGrowBarArc(grow_tCtx ctx, const char* name, double x1, double y1,
double x2, double y2, int ang1, int ang2, double width, glow_eDrawType border_draw_type,
int line_width, int border, glow_eDrawType fill_draw_type, void* user_data, grow_tObject* bar)
{
GrowBarArc* r1;
r1 = new GrowBarArc(ctx, name, x1, y1, x2, y2, ang1, ang2, width, border, border_draw_type, line_width,
fill_draw_type, 1);
r1->set_user_data(user_data);
ctx->insert(r1);
ctx->nav_zoom();
*bar = (grow_tObject)r1;
}
void grow_CreateGrowTrend(grow_tCtx ctx, const char* name, double x, double y,
double width, double height, glow_eDrawType draw_type, int line_width,
glow_mDisplayLevel display_level, int fill_rect, int border,
......@@ -1883,6 +1897,106 @@ int grow_GetObjectAttrInfo(
}
break;
}
case glow_eObjectType_GrowBarArc: {
GrowBarArc* op = (GrowBarArc*)object;
char* name;
char* dynamic;
int dynsize;
strcpy(attrinfo[i].name, "Name");
attrinfo[i].value_p = &op->n_name;
attrinfo[i].type = glow_eType_String;
attrinfo[i].no_edit = 0;
attrinfo[i].no_edit = 0;
attrinfo[i].input_validation_cb = grow_name_validation_cb;
attrinfo[i].validation_ctx = (void*)op;
attrinfo[i++].size = sizeof(op->n_name);
if ((name = growapi_translate(transtab, "MaxValue"))) {
strcpy(attrinfo[i].name, name);
attrinfo[i].value_p = &op->max_value;
attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof(op->max_value);
}
if ((name = growapi_translate(transtab, "MinValue"))) {
strcpy(attrinfo[i].name, name);
attrinfo[i].value_p = &op->min_value;
attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof(op->min_value);
}
if ((name = growapi_translate(transtab, "Angle1"))) {
strcpy(attrinfo[i].name, name);
attrinfo[i].value_p = &op->angle1;
attrinfo[i].type = glow_eType_Int;
attrinfo[i++].size = sizeof(op->angle1);
}
if ((name = growapi_translate(transtab, "Angle2"))) {
strcpy(attrinfo[i].name, name);
attrinfo[i].value_p = &op->angle2;
attrinfo[i].type = glow_eType_Int;
attrinfo[i++].size = sizeof(op->angle2);
}
if ((name = growapi_translate(transtab, "BarWidth"))) {
strcpy(attrinfo[i].name, name);
attrinfo[i].value_p = &op->bar_width;
attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof(op->bar_width);
}
if ((name = growapi_translate(transtab, "BarDirection"))) {
strcpy(attrinfo[i].name, name);
attrinfo[i].value_p = &op->bar_direction;
attrinfo[i].type = glow_eType_Boolean;
attrinfo[i++].size = sizeof(op->bar_direction);
}
if ((name = growapi_translate(transtab, "BarValue"))) {
strcpy(attrinfo[i].name, name);
attrinfo[i].value_p = &op->bar_value;
attrinfo[i].type = glow_eType_Double;
attrinfo[i++].size = sizeof(op->bar_value);
}
if ((name = growapi_translate(transtab, "BarColor"))) {
strcpy(attrinfo[i].name, name);
attrinfo[i].value_p = &op->bar_drawtype;
attrinfo[i].type = glow_eType_Color;
attrinfo[i++].size = sizeof(op->bar_drawtype);
}
if ((name = growapi_translate(transtab, "BarBorderColor"))) {
strcpy(attrinfo[i].name, name);
attrinfo[i].value_p = &op->bar_bordercolor;
attrinfo[i].type = glow_eType_Color;
attrinfo[i++].size = sizeof(op->bar_bordercolor);
}
if ((name = growapi_translate(transtab, "BarBorderWidth"))) {
strcpy(attrinfo[i].name, name);
attrinfo[i].value_p = &op->bar_borderwidth;
attrinfo[i].type = glow_eType_Int;
attrinfo[i++].size = sizeof(op->bar_borderwidth);
}
if ((name = growapi_translate(transtab, "Dynamic"))) {
strcpy(attrinfo[i].name, name);
op->get_dynamic(&dynamic, &dynsize);
attrinfo[i].value_p = malloc(1024);
if (dynsize)
strncpy((char*)attrinfo[i].value_p, dynamic, 1024);
else
strcpy((char*)attrinfo[i].value_p, "");
attrinfo[i].type = glow_eType_String;
attrinfo[i].size = 1024;
attrinfo[i].multiline = 1;
attrinfo[i++].info_type = grow_eInfoType_Dynamic;
}
break;
}
case glow_eObjectType_GrowTrend:
case glow_eObjectType_GrowXYCurve: {
GrowTrend* op = (GrowTrend*)object;
......@@ -4576,7 +4690,10 @@ void grow_SetSelectTextFont(grow_tCtx ctx, glow_eFont font)
void grow_SetBarValue(grow_tObject object, double value)
{
((GrowBar*)object)->set_value(value);
if (((GlowArrayElem*)object)->type() == glow_eObjectType_GrowBar)
((GrowBar*)object)->set_value(value);
else if (((GlowArrayElem*)object)->type() == glow_eObjectType_GrowBarArc)
((GrowBarArc*)object)->set_value(value);
}
void grow_AddTrendValue(grow_tObject object, double value, int idx)
......@@ -4695,12 +4812,18 @@ void grow_SetSliderRange(grow_tObject object, double min, double max)
void grow_GetBarRange(grow_tObject object, double *min, double *max)
{
((GrowBar*)object)->get_range(min, max);
if (((GlowArrayElem*)object)->type() == glow_eObjectType_GrowBar)
((GrowBar*)object)->get_range(min, max);
else if (((GlowArrayElem*)object)->type() == glow_eObjectType_GrowBarArc)
((GrowBarArc*)object)->get_range(min, max);
}
void grow_SetBarRange(grow_tObject object, double min, double max)
{
((GrowBar*)object)->set_range(min, max);
if (((GlowArrayElem*)object)->type() == glow_eObjectType_GrowBar)
((GrowBar*)object)->set_range(min, max);
else if (((GlowArrayElem*)object)->type() == glow_eObjectType_GrowBarArc)
((GrowBarArc*)object)->set_range(min, max);
}
void grow_GetTrendRangeY(grow_tObject object, int curve, double *min, double *max)
......@@ -5211,6 +5334,16 @@ void grow_GetBarInfo(grow_tObject object, glow_sBarInfo* info)
((GrowBar*)object)->get_bar_info(info);
}
void grow_SetBarArcInfo(grow_tObject object, glow_sBarInfo* info)
{
((GrowBarArc*)object)->set_bar_info(info);
}
void grow_GetBarArcInfo(grow_tObject object, glow_sBarInfo* info)
{
((GrowBarArc*)object)->get_bar_info(info);
}
void grow_SetAxisInfo(grow_tObject object, glow_sAxisInfo* info)
{
if (((GlowArrayElem*)object)->type() == glow_eObjectType_GrowAxis)
......
......@@ -938,6 +938,30 @@ void grow_CreateGrowBar(grow_tCtx ctx, const char* name, double x, double y,
glow_mDisplayLevel display_level, int fill_rect, int border,
glow_eDrawType fill_draw_type, void* user_data, grow_tObject* bar);
//! Create a bararc object, i.e an object of class GrowArcBar.
/*!
\param ctx Grow context.
\param name Object name (max 31 char).
\param x1 x coordinate for position of lower left corner of the
rectangle.
\param y1 y coordinate for position of lower left corner of the
rectangle.
\param x2 x coordinate for upper right corner.
\param y2 y coordinate for upper right corner.
\param ang1 Start angle of the arc in degrees from the x axis.
\param ang2 Lengh of the arc in degrees from the start angle.
\param width Width of bar.
\param draw_type Border color.
\param line_width Line width of border.
\param border Border is visible.
\param fill_draw_type Fill color.
\param user_data User data.
\param bar Created GrowBarArc object.
*/
void grow_CreateGrowBarArc(grow_tCtx ctx, const char* name, double x1, double y1,
double x2, double y2, int ang1, int ang2, double width, glow_eDrawType border_draw_type, int line_width,
int border, glow_eDrawType fill_draw_type, void* user_data, grow_tObject* bar);
//! Create a trend object, i.e an object of class GrowTrend.
/*!
\param ctx Grow context.
......@@ -3070,6 +3094,21 @@ void grow_SetBarInfo(grow_tObject object, glow_sBarInfo* info);
*/
void grow_GetBarInfo(grow_tObject object, glow_sBarInfo* info);
//! Set parameters for a bararc object.
/*!
\param object BarArc object.
\param info Info struct.
*/
void grow_SetBarArcInfo(grow_tObject object, glow_sBarInfo* info);
//! Get parameters for a bar arc object.
/*!
\param object BarArc object.
\param info Info struct.
*/
void grow_GetBarArcInfo(grow_tObject object, glow_sBarInfo* info);
//! Set parameters for an axis object.
/*!
\param object Axis object.
......
......@@ -61,6 +61,7 @@
#include "glow_growline.h"
#include "glow_growconpoint.h"
#include "glow_growbar.h"
#include "glow_growbararc.h"
#include "glow_growxycurve.h"
#include "glow_exportflow.h"
......@@ -4142,6 +4143,9 @@ int GrowCtx::get_next_object_position(
|| object->type() == glow_eObjectType_GrowGroup
|| object->type() == glow_eObjectType_GrowTrend
|| object->type() == glow_eObjectType_GrowBar
|| object->type() == glow_eObjectType_GrowBarArc
|| object->type() == glow_eObjectType_GrowBarChart
|| object->type() == glow_eObjectType_GrowPie
|| object->type() == glow_eObjectType_GrowText)) {
return 0;
}
......@@ -4168,6 +4172,9 @@ int GrowCtx::get_next_object_position(
|| a[i]->type() == glow_eObjectType_GrowGroup
|| a[i]->type() == glow_eObjectType_GrowTrend
|| a[i]->type() == glow_eObjectType_GrowBar
|| a[i]->type() == glow_eObjectType_GrowBarArc
|| a[i]->type() == glow_eObjectType_GrowBarChart
|| a[i]->type() == glow_eObjectType_GrowPie
|| a[i]->type() == glow_eObjectType_GrowText) {
NextElem n;
......@@ -4490,6 +4497,10 @@ void GrowCtx::read_object(std::ifstream& fp, GlowArrayElem** o)
n = new GrowBar(this, "");
break;
}
case glow_eSave_GrowBarArc: {
n = new GrowBarArc(this, "");
break;
}
case glow_eSave_GrowTrend: {
n = new GrowTrend(this, "");
break;
......
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