Commit 03a6683b authored by Claes Sjofors's avatar Claes Sjofors

Ge pie chart and bar chart added

parent 2a24aa12
......@@ -236,6 +236,8 @@ palette NavigatorPalette
class PlcThread
class PostConfig
class RemoteConfig
class ReportConfig
class Report
class SysMonConfig
class StatusServerConfig
class SevHistMonitor
......
This diff is collapsed.
......@@ -162,6 +162,8 @@
ge_eDynPrio_InputFocus,
ge_eDynPrio_DigCommand,
ge_eDynPrio_SetValue,
ge_eDynPrio_Pie,
ge_eDynPrio_BarChart,
// This should always be last
ge_eDynPrio_CloseGraph = 10000
......@@ -199,7 +201,9 @@
ge_mDynType_HostObject = 1 << 26,
ge_mDynType_DigSound = 1 << 27,
ge_mDynType_XY_Curve = 1 << 28,
ge_mDynType_DigCommand = 1 << 29
ge_mDynType_DigCommand = 1 << 29,
ge_mDynType_Pie = 1 << 30,
ge_mDynType_BarChart = 1 << 31
} ge_mDynType;
//! Action types.
......@@ -299,6 +303,8 @@
ge_eSave_DigSound = 33,
ge_eSave_XY_Curve = 34,
ge_eSave_DigCommand = 35,
ge_eSave_Pie = 36,
ge_eSave_BarChart = 37,
ge_eSave_PopupMenu = 50,
ge_eSave_SetDig = 51,
ge_eSave_ResetDig = 52,
......@@ -468,6 +474,32 @@
ge_eSave_DigCommand_command = 3501,
ge_eSave_DigCommand_instance = 3502,
ge_eSave_DigCommand_instance_mask = 3503,
ge_eSave_Pie_attribute1 = 3600,
ge_eSave_Pie_attribute2 = 3601,
ge_eSave_Pie_attribute3 = 3602,
ge_eSave_Pie_attribute4 = 3603,
ge_eSave_Pie_attribute5 = 3604,
ge_eSave_Pie_attribute6 = 3605,
ge_eSave_Pie_attribute7 = 3606,
ge_eSave_Pie_attribute8 = 3607,
ge_eSave_Pie_attribute9 = 3608,
ge_eSave_Pie_attribute10 = 3609,
ge_eSave_Pie_attribute11 = 3610,
ge_eSave_Pie_attribute12 = 3611,
ge_eSave_Pie_fix_range = 3612,
ge_eSave_BarChart_attribute1 = 3700,
ge_eSave_BarChart_attribute2 = 3701,
ge_eSave_BarChart_attribute3 = 3702,
ge_eSave_BarChart_attribute4 = 3703,
ge_eSave_BarChart_attribute5 = 3704,
ge_eSave_BarChart_attribute6 = 3705,
ge_eSave_BarChart_attribute7 = 3706,
ge_eSave_BarChart_attribute8 = 3707,
ge_eSave_BarChart_attribute9 = 3708,
ge_eSave_BarChart_attribute10 = 3709,
ge_eSave_BarChart_attribute11 = 3710,
ge_eSave_BarChart_attribute12 = 3711,
ge_eSave_BarChart_fix_range = 3712,
ge_eSave_PopupMenu_ref_object = 5000,
ge_eSave_SetDig_attribute = 5100,
ge_eSave_SetDig_instance = 5101,
......@@ -2371,6 +2403,95 @@ class GeTable : public GeDynElem {
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
//! Dynamics for a pie object.
#define PIE_MAX_SECTORS 12
class GePie : public GeDynElem {
public:
int sectors;
double min_value;
double max_value;
pwr_tBoolean fix_range;
int size;
graph_eDatabase db;
int attr_type;
pwr_tAName attribute[PIE_MAX_SECTORS];
bool first_scan;
pwr_tFloat32 *p[PIE_MAX_SECTORS];
pwr_tSubid subid[PIE_MAX_SECTORS];
pwr_tFloat32 old_value[PIE_MAX_SECTORS];
GePie( GeDyn *e_dyn) :
GeDynElem(e_dyn, ge_mDynType_Pie, (ge_mActionType) 0, ge_eDynPrio_Pie),
sectors(0), min_value(0), max_value(0), fix_range(0) {
for ( int i = 0; i < PIE_MAX_SECTORS; i++)
strcpy( attribute[i], "");
}
GePie( const GePie& x) :
GeDynElem(x.dyn,x.dyn_type,x.action_type,x.prio),
sectors(x.sectors), min_value(x.min_value), max_value(x.max_value), fix_range(x.fix_range) {
for ( int i = 0; i < PIE_MAX_SECTORS; i++)
strcpy( attribute[i], x.attribute[i]);
}
void get_attributes( attr_sItem *attrinfo, int *item_count);
void save( ofstream& fp);
void open( ifstream& fp);
int connect( grow_tObject object, glow_sTraceData *trace_data);
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, const char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
//! Dynamics for a barchart object.
#define BARCHART_MAX_BARSEGMENTS 12
class GeBarChart : public GeDynElem {
public:
int bars;
int barsegments;
double min_value;
double max_value;
pwr_tBoolean fix_range;
int size;
graph_eDatabase db;
int attr_type;
pwr_tAName attribute[BARCHART_MAX_BARSEGMENTS];
bool first_scan;
pwr_tFloat32 *p[BARCHART_MAX_BARSEGMENTS];
pwr_tSubid subid[BARCHART_MAX_BARSEGMENTS];
pwr_tFloat32 *value;
pwr_tFloat32 *old_value;
GeBarChart( GeDyn *e_dyn) :
GeDynElem(e_dyn, ge_mDynType_BarChart, (ge_mActionType) 0, ge_eDynPrio_BarChart),
bars(0), barsegments(0), min_value(0), max_value(0), fix_range(0), value(0), old_value(0) {
for ( int i = 0; i < BARCHART_MAX_BARSEGMENTS; i++) {
strcpy( attribute[i], "");
p[i] = 0;
}
}
GeBarChart( const GeBarChart& x) :
GeDynElem(x.dyn,x.dyn_type,x.action_type,x.prio),
bars(x.bars),barsegments(x.barsegments), min_value(x.min_value), max_value(x.max_value), fix_range(x.fix_range),
value(0), old_value(0) {
for ( int i = 0; i < BARCHART_MAX_BARSEGMENTS; i++) {
strcpy( attribute[i], x.attribute[i]);
p[i] = 0;
}
}
void get_attributes( attr_sItem *attrinfo, int *item_count);
void save( ofstream& fp);
void open( ifstream& fp);
int connect( grow_tObject object, glow_sTraceData *trace_data);
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, const char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
//! Pulldown menu.
class GePulldownMenu : public GeDynElem {
public:
......
This diff is collapsed.
......@@ -1274,6 +1274,8 @@ class Graph {
*/
void create_axis( grow_tObject *object, double x, double y);
void create_axisarc( grow_tObject *object, double x, double y);
void create_pie( grow_tObject *object, double x, double y);
void create_barchart( grow_tObject *object, double x, double y);
int create_node_floating( double x, double y);
......
......@@ -22,6 +22,8 @@ menu Analog
subgraph Bar pwr_bar.component 26
subgraph Axis pwr_axis.component 27
subgraph AxisArc pwr_axisarc.component 250
subgraph Pie pwr_pie.component 6
subgraph BarChart pwr_barchart.component 25
}
menu Process
{
......
......@@ -213,7 +213,9 @@ typedef enum {
glow_eObjectType_GrowTable,
glow_eObjectType_GrowFolder,
glow_eObjectType_GrowXYCurve,
glow_eObjectType_GrowAxisArc
glow_eObjectType_GrowAxisArc,
glow_eObjectType_GrowPie,
glow_eObjectType_GrowBarChart
} glow_eObjectType;
//! Direction of a connection points, sliders etc
......@@ -1075,6 +1077,8 @@ typedef enum {
glow_eSave_GrowTable = 42,
glow_eSave_GrowXYCurve = 43,
glow_eSave_GrowAxisArc = 44,
glow_eSave_GrowPie = 45,
glow_eSave_GrowBarChart = 46,
glow_eSave_End = 99,
glow_eSave_Ctx_zoom_factor_x = 100,
glow_eSave_Ctx_base_zoom_factor = 101,
......@@ -1753,7 +1757,57 @@ typedef enum {
glow_eSave_GrowAxisArc_format = 4407,
glow_eSave_GrowAxisArc_text_size = 4408,
glow_eSave_GrowAxisArc_text_drawtype = 4409,
glow_eSave_GrowAxisArc_text_color_drawtype = 4410
glow_eSave_GrowAxisArc_text_color_drawtype = 4410,
glow_eSave_GrowPie_arc_part = 4500,
glow_eSave_GrowPie_sectors = 4501,
glow_eSave_GrowPie_min_value = 4502,
glow_eSave_GrowPie_max_value = 4503,
glow_eSave_GrowPie_sector_color1 = 4504,
glow_eSave_GrowPie_sector_color2 = 4505,
glow_eSave_GrowPie_sector_color3 = 4506,
glow_eSave_GrowPie_sector_color4 = 4507,
glow_eSave_GrowPie_sector_color5 = 4508,
glow_eSave_GrowPie_sector_color6 = 4509,
glow_eSave_GrowPie_sector_color7 = 4510,
glow_eSave_GrowPie_sector_color8 = 4511,
glow_eSave_GrowPie_sector_color9 = 4512,
glow_eSave_GrowPie_sector_color10 = 4513,
glow_eSave_GrowPie_sector_color11 = 4514,
glow_eSave_GrowPie_sector_color12 = 4515,
glow_eSave_GrowPie_sector_size1 = 4516,
glow_eSave_GrowPie_sector_size2 = 4517,
glow_eSave_GrowPie_sector_size3 = 4518,
glow_eSave_GrowPie_sector_size4 = 4519,
glow_eSave_GrowPie_sector_size5 = 4520,
glow_eSave_GrowPie_sector_size6 = 4521,
glow_eSave_GrowPie_sector_size7 = 4522,
glow_eSave_GrowPie_sector_size8 = 4523,
glow_eSave_GrowPie_sector_size9 = 4524,
glow_eSave_GrowPie_sector_size10 = 4525,
glow_eSave_GrowPie_sector_size11 = 4526,
glow_eSave_GrowPie_sector_size12 = 4527,
glow_eSave_GrowPie_userdata_cb = 4528,
glow_eSave_GrowBarChart_rect_part = 4600,
glow_eSave_GrowBarChart_bars = 4601,
glow_eSave_GrowBarChart_barsegments = 4602,
glow_eSave_GrowBarChart_min_value = 4603,
glow_eSave_GrowBarChart_max_value = 4604,
glow_eSave_GrowBarChart_bar_color1 = 4605,
glow_eSave_GrowBarChart_bar_color2 = 4606,
glow_eSave_GrowBarChart_bar_color3 = 4607,
glow_eSave_GrowBarChart_bar_color4 = 4608,
glow_eSave_GrowBarChart_bar_color5 = 4609,
glow_eSave_GrowBarChart_bar_color6 = 4610,
glow_eSave_GrowBarChart_bar_color7 = 4611,
glow_eSave_GrowBarChart_bar_color8 = 4612,
glow_eSave_GrowBarChart_bar_color9 = 4613,
glow_eSave_GrowBarChart_bar_color10 = 4614,
glow_eSave_GrowBarChart_bar_color11 = 4615,
glow_eSave_GrowBarChart_bar_color12 = 4616,
glow_eSave_GrowBarChart_vertical_lines = 4617,
glow_eSave_GrowBarChart_horizontal_lines = 4618,
glow_eSave_GrowBarChart_userdata_cb = 4619,
glow_eSave_GrowBarChart_line_color = 4620
} glow_eSave;
//! Relative or absolute position for an annotation
......
......@@ -75,6 +75,8 @@
#include "glow_growgroup.h"
#include "glow_growaxis.h"
#include "glow_growaxisarc.h"
#include "glow_growpie.h"
#include "glow_growbarchart.h"
#include "glow_growconglue.h"
#include "glow_growwindow.h"
#include "glow_growfolder.h"
......@@ -248,6 +250,22 @@ void GlowArray::copy_from( const GlowArray& array)
insert( n);
break;
}
case glow_eObjectType_GrowPie:
{
GrowPie *n = new GrowPie(*(GrowPie *)array.a[i]);
n->highlight = 0;
n->hot = 0;
insert( n);
break;
}
case glow_eObjectType_GrowBarChart:
{
GrowBarChart *n = new GrowBarChart(*(GrowBarChart *)array.a[i]);
n->highlight = 0;
n->hot = 0;
insert( n);
break;
}
case glow_eObjectType_GrowConGlue:
{
GrowConGlue *n = new GrowConGlue(*(GrowConGlue *)array.a[i]);
......@@ -1033,6 +1051,20 @@ void GlowArray::open( GrowCtx *ctx, ifstream& fp)
insert( r);
break;
}
case glow_eSave_GrowPie:
{
GrowPie *r = new GrowPie( ctx, "");
r->open( fp);
insert( r);
break;
}
case glow_eSave_GrowBarChart:
{
GrowBarChart *r = new GrowBarChart( ctx, "");
r->open( fp);
insert( r);
break;
}
case glow_eSave_GrowConGlue:
{
GrowConGlue *r = new GrowConGlue( ctx, "");
......
This diff is collapsed.
......@@ -1236,6 +1236,18 @@ extern "C" {
glow_eDrawType text_drawtype, void *user_data,
grow_tObject *axis);
void grow_CreateGrowPie( grow_tCtx ctx, const char *name,
double x1, double y1, double x2, double y2,
int angle1, int angle2, glow_eDrawType draw_type,
int line_width, int border, int shadow, glow_eDrawType fill_draw_type,
void *user_data, grow_tObject *arc);
void grow_CreateGrowBarChart( grow_tCtx ctx, const char *name,
double x, double y, double width, double height,
glow_eDrawType draw_type, int line_width, int border, int shadow,
glow_eDrawType fill_draw_type,
void *user_data, grow_tObject *barchart);
//! Create a connection glue object, i.e. an object of class GrowConGlue.
/*!
\param ctx Grow context.
......@@ -2955,6 +2967,17 @@ extern "C" {
glow_eDrawType fill_color);
void grow_SetXYCurveData( grow_tObject object, double *y_data, double *x_data, int curve_idx,
int data_points);
void grow_SetPieValues( grow_tObject object, double *values);
void grow_SetPieConf( grow_tObject object, int sector_num, double min_val, double max_val, glow_eDrawType *color);
void grow_GetPieConf( grow_tObject object, int *sector_num, double *min_val, double *max_val);
void grow_SetBarChartValues( grow_tObject object,
float *values1, float *values2, float *values3, float *values4,
float *values5, float *values6, float *values7, float *values8,
float *values9, float *values10, float *values11, float *values12);
void grow_SetBarChartConf( grow_tObject object, int bar_num, int barsegment_num,
double min_val, double max_val, int vert_lines, int horiz_lines,
glow_eDrawType line_color, glow_eDrawType *color);
void grow_GetBarChartConf( grow_tObject object, int *bar_num, int *barsegment_num, double *min_val, double *max_val);
//! Get text size and color for an annotation.
/*!
......
This diff is collapsed.
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef glow_growbarchart_h
#define glow_growbarchart_h
#include "glow_growrect.h"
/*! \file glow_growbarchart.h
\brief Contains the GrowBarChart class. */
/*! \addtogroup Glow */
/*@{*/
#define BARCHART_MAX_BARSEGMENTS 12
#define BARCHART_MAX_BARS 200
//! Class for drawing a barchart object.
/*! A GrowBarChart object is an object that displays a barchart chart.
The GrowBarChart class contains function for drawing the object, and handle events when the
object is clicked on, moved etc.
*/
class GrowBarChart : public GrowRect {
public:
//! Constuctor
/*!
\param glow_ctx The glow context.
\param name Name (max 31 char).
\param x1 x coordinate for first corner.
\param y1 y coordinate for first corner.
\param x2 x coordinate for second corner.
\param y2 y coordinate for second corner.
\param border_d_type Border color.
\param line_w Linewidth of border.
\param t_size Text size.
\param t_drawtype Drawtype for text.
\param nodraw Don't draw the object now.
*/
GrowBarChart( GrowCtx *glow_ctx, const char *name, double x = 0, double y = 0,
double w = 0, double h = 0,
glow_eDrawType border_d_type = glow_eDrawType_Line,
int line_w = 1,
int display_border = 1, int display_shadow = 0,
glow_eDrawType fill_d_type = glow_eDrawType_Line, int nodraw = 0);
//! Destructor
/*! Remove the object from context, and erase it from the screen.
*/
~GrowBarChart();
//! Save the content of the object to file.
/*!
\param fp Ouput file.
\param mode Not used.
*/
void save( ofstream& fp, glow_eSaveMode mode);
//! Read the content of the object from file.
/*!
\param fp Input file.
*/
void open( ifstream& fp);
//! Scan trace
/*! Calls the trace scan callback for the object.
*/
void trace_scan();
//! Init trace
/*! Calls the trace connect callback for the object.
*/
int trace_init();
//! Close trace
/*! Calls the trace disconnect callback for the object.
*/
void trace_close();
//! Erase the object
void erase( GlowWind *w)
{ erase( w, (GlowTransform *)NULL, hot, NULL);};
//! Draw the objects if any part is inside the drawing area.
/*!
\param ll_x Lower left x coordinate of drawing area.
\param ll_y Lower left y coordinate of drawing area.
\param ur_x Upper right x coordinate of drawing area.
\param ur_y Upper right y coordinate of drawing area.
*/
void draw( GlowWind *w, int ll_x, int ll_y, int ur_x, int ur_y);
//! Draw the objects if any part is inside the drawing area, and extends the drawing area.
/*!
\param ll_x Lower left x coordinate of drawing area.
\param ll_y Lower left y coordinate of drawing area.
\param ur_x Upper right x coordinate of drawing area.
\param ur_y Upper right y coordinate of drawing area.
If some part of object is inside the drawing area, and also outside the drawing area,
the drawingarea is extended so it contains the whole objects.
*/
void draw( GlowWind *w, int *ll_x, int *ll_y, int *ur_x, int *ur_y);
//! Set object highlight.
/*!
\param on If 1, set highlight. If 0, reset highlight.
*/
void set_highlight( int on);
//! Get the object type
/*!
\return The type of the object.
*/
glow_eObjectType type() { return glow_eObjectType_GrowBarChart;};
int bars; //!< Number of bars.
int barsegments; //!< Number of bar parts.
double min_value; //!< Range mininum value
double max_value; //!< Range maximum value
int vertical_lines; //!< Number of vertical lines
int horizontal_lines; //!< Number of horizontal lines
glow_eDrawType line_color; //!< Color of vertical and horizontal lines
glow_eDrawType bar_color[BARCHART_MAX_BARSEGMENTS]; //!< Bar color.
float bar_values[BARCHART_MAX_BARSEGMENTS][BARCHART_MAX_BARS]; //!< Bar size
GlowTraceData trace; //!< Obsolete
//! Erase the object.
/*!
\param t Transform of parent node.
\param hot Draw as hot, with larger line width.
\param node Parent node. Can be zero.
*/
void erase( GlowWind *w, GlowTransform *t, int hot, void *node);
//! Draw the object.
/*!
\param t Transform of parent node. Can be zero.
\param highlight Draw with highlight colors.
\param hot Draw as hot, with larger line width.
\param node Parent node. Can be zero.
\param colornode The node that controls the color of the object. Can be zero.
The object is drawn with border, fill and shadow. If t is not zero, the current tranform is
multiplied with the parentnodes transform, to give the appropriate coordinates for the drawing.
*/
void draw( GlowWind *w, GlowTransform *t, int highlight, int hot, void *node, void *colornode);
//! Redraw the area inside the objects border.
void draw();
//! Moves object to alignment line or point.
/*!
\param x x coordinate of alignment point.
\param y y coordinate of alignment point.
\param direction Type of alignment.
*/
void align( double x, double y, glow_eAlignDirection direction);
void set_conf( int bar_num, int barsegment_num, double min_val, double max_val,
int vert_lines, int horiz_lines, glow_eDrawType lcolor, glow_eDrawType *color);
void get_conf( int *bars, int *barsegments, double *min_val, double *max_val);
void set_values( float *values1, float *values2, float *values3, float *values4,
float *values5, float *values6, float *values7, float *values8,
float *values9, float *values10, float *values11, float *values12);
//! Export the object as a javabean.
/*!
\param t Transform of parent node. Can be zero.
\param node Parent node. Can be zero.
\param pass Export pass.
\param shape_cnt Current index in a shape vector.
\param node_cnt Counter used for javabean name. Not used for this kind of object.
\param in_nc Member of a nodeclass. Not used for this kind of object.
\param fp Output file.
The object is transformed to the current zoom factor, and GlowExportJBean is used to generate
java code for the bean.
*/
void export_javabean( GlowTransform *t, void *node,
glow_eExportPass pass, int *shape_cnt, int node_cnt, int in_nc, ofstream &fp);
//! Set configuration values for the barchart.
void set_conf( double max_val, double min_val, int no_of_lines,
int long_quot, int value_quot, double rot, const char *format);
//! Conversion between different versions of Glow
/*!
\param version Version to convert to.
*/
void convert( glow_eConvert version);
};
/*@}*/
#endif
......@@ -67,6 +67,8 @@
#include "glow_growgroup.h"
#include "glow_growaxis.h"
#include "glow_growaxisarc.h"
#include "glow_growpie.h"
#include "glow_growbarchart.h"
#include "glow_growmenu.h"
#include "glow_growfolder.h"
#include "glow_growtable.h"
......@@ -4376,6 +4378,14 @@ void GrowCtx::read_object( ifstream& fp, GlowArrayElem **o)
n = new GrowAxisArc( this, "");
break;
}
case glow_eSave_GrowPie: {
n = new GrowPie( this, "");
break;
}
case glow_eSave_GrowBarChart: {
n = new GrowBarChart( this, "");
break;
}
case glow_eSave_GrowConGlue: {
n = new GrowConGlue( this, "");
break;
......
This diff is collapsed.
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef glow_growpie_h
#define glow_growpie_h
#include "glow_growarc.h"
/*! \file glow_growpie.h
\brief Contains the GrowPie class. */
/*! \addtogroup Glow */
/*@{*/
#define PIE_MAX_SECTORS 12
//! Class for drawing a pie object.
/*! A GrowPie object is an object that displays a pie chart.
The GrowPie class contains function for drawing the object, and handle events when the
object is clicked on, moved etc.
*/
class GrowPie : public GrowArc {
public:
//! Constuctor
/*!
\param glow_ctx The glow context.
\param name Name (max 31 char).
\param x1 x coordinate for first corner.
\param y1 y coordinate for first corner.
\param x2 x coordinate for second corner.
\param y2 y coordinate for second corner.
\param border_d_type Border color.
\param line_w Linewidth of border.
\param t_size Text size.
\param t_drawtype Drawtype for text.
\param nodraw Don't draw the object now.
*/
GrowPie( GrowCtx *glow_ctx, const char *name, double x1 = 0, double y1 = 0,
double x2 = 0, double y2 = 0,
int ang1 = 0, int ang2 = 0,
glow_eDrawType border_d_type = glow_eDrawType_Line,
int line_w = 1,
int display_border = 1, int display_shadow = 0,
glow_eDrawType fill_d_type = glow_eDrawType_Line, int nodraw = 0);
//! Destructor
/*! Remove the object from context, and erase it from the screen.
*/
~GrowPie();
//! Save the content of the object to file.
/*!
\param fp Ouput file.
\param mode Not used.
*/
void save( ofstream& fp, glow_eSaveMode mode);
//! Read the content of the object from file.
/*!
\param fp Input file.
*/
void open( ifstream& fp);
//! Scan trace
/*! Calls the trace scan callback for the object.
*/
void trace_scan();
//! Init trace
/*! Calls the trace connect callback for the object.
*/
int trace_init();
//! Close trace
/*! Calls the trace disconnect callback for the object.
*/
void trace_close();
//! Erase the object
void erase( GlowWind *w)
{ erase( w, (GlowTransform *)NULL, hot, NULL);};
//! Draw the objects if any part is inside the drawing area.
/*!
\param ll_x Lower left x coordinate of drawing area.
\param ll_y Lower left y coordinate of drawing area.
\param ur_x Upper right x coordinate of drawing area.
\param ur_y Upper right y coordinate of drawing area.
*/
void draw( GlowWind *w, int ll_x, int ll_y, int ur_x, int ur_y);
//! Draw the objects if any part is inside the drawing area, and extends the drawing area.
/*!
\param ll_x Lower left x coordinate of drawing area.
\param ll_y Lower left y coordinate of drawing area.
\param ur_x Upper right x coordinate of drawing area.
\param ur_y Upper right y coordinate of drawing area.
If some part of object is inside the drawing area, and also outside the drawing area,
the drawingarea is extended so it contains the whole objects.
*/
void draw( GlowWind *w, int *ll_x, int *ll_y, int *ur_x, int *ur_y);
//! Set object highlight.
/*!
\param on If 1, set highlight. If 0, reset highlight.
*/
void set_highlight( int on);
//! Get the object type
/*!
\return The type of the object.
*/
glow_eObjectType type() { return glow_eObjectType_GrowPie;};
int sectors; //!< Number of sectors.
double min_value; //!< Range mininum value
double max_value; //!< Range maximum value
glow_eDrawType sector_color[PIE_MAX_SECTORS]; //!< Sector color.
double sector_size[PIE_MAX_SECTORS]; //!< Sector size in range 0-1.
GlowTraceData trace; //!< Obsolete
//! Erase the object.
/*!
\param t Transform of parent node.
\param hot Draw as hot, with larger line width.
\param node Parent node. Can be zero.
*/
void erase( GlowWind *w, GlowTransform *t, int hot, void *node);
//! Draw the object.
/*!
\param t Transform of parent node. Can be zero.
\param highlight Draw with highlight colors.
\param hot Draw as hot, with larger line width.
\param node Parent node. Can be zero.
\param colornode The node that controls the color of the object. Can be zero.
The object is drawn with border, fill and shadow. If t is not zero, the current tranform is
multiplied with the parentnodes transform, to give the appropriate coordinates for the drawing.
*/
void draw( GlowWind *w, GlowTransform *t, int highlight, int hot, void *node, void *colornode);
//! Redraw the area inside the objects border.
void draw();
//! Moves object to alignment line or point.
/*!
\param x x coordinate of alignment point.
\param y y coordinate of alignment point.
\param direction Type of alignment.
*/
void align( double x, double y, glow_eAlignDirection direction);
void set_conf( int sectors, double min_val, double max_val, glow_eDrawType *color);
void get_conf( int *sectors, double *min_val, double *max_val);
void set_values( double *values);
//! Export the object as a javabean.
/*!
\param t Transform of parent node. Can be zero.
\param node Parent node. Can be zero.
\param pass Export pass.
\param shape_cnt Current index in a shape vector.
\param node_cnt Counter used for javabean name. Not used for this kind of object.
\param in_nc Member of a nodeclass. Not used for this kind of object.
\param fp Output file.
The object is transformed to the current zoom factor, and GlowExportJBean is used to generate
java code for the bean.
*/
void export_javabean( GlowTransform *t, void *node,
glow_eExportPass pass, int *shape_cnt, int node_cnt, int in_nc, ofstream &fp);
//! Set configuration values for the pie.
void set_conf( double max_val, double min_val, int no_of_lines,
int long_quot, int value_quot, double rot, const char *format);
//! Conversion between different versions of Glow
/*!
\param version Version to convert to.
*/
void convert( glow_eConvert version);
};
/*@}*/
#endif
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