Commit b835884f authored by Claes Sjofors's avatar Claes Sjofors

Safety level enum added to some object, and warning triangle in plcpgm

parent 8b7f9256
......@@ -1059,6 +1059,7 @@ int CnvWblToH::check_typename( char *type_volume, char *type_name)
"pwr_tDataRef",
"pwr_tVoid",
"pwr_tConfigStatusEnum",
"pwr_tSafetyLevelEnum",
""};
for ( name = valid_names[0]; strcmp(name,"") != 0;
......
......@@ -624,6 +624,18 @@ typedef pwr_tMask pwr_tPrivMask;
*/
typedef pwr_tEnum pwr_tConfigStatusEnum;
/*_*
@aref safetylevelenum SafetyLevelEnum
*/
typedef pwr_tEnum pwr_tSafetyLevelEnum;
typedef enum {
pwr_eSafetyLevel_None,
pwr_eSafetyLevel_Low,
pwr_eSafetyLevel_High
} pwr_eSafetyLevel;
/* Operating system. */
/*_*
@aref opsys OpSys
......@@ -1054,6 +1066,7 @@ struct pwr_s_PlantHier {
pwr_tURL CircuitDiagram pwr_dAlignW;
pwr_tURL Photo pwr_dAlignW;
pwr_tConfigStatusEnum ConfigurationStatus pwr_dAlignW;
pwr_tSafetyLevelEnum SafetyLevel pwr_dAlignW;
};
/* Node defining classes. */
......@@ -1123,6 +1136,7 @@ struct pwr_s_LibHier {
struct pwr_s_NodeHier {
pwr_tString80 Description pwr_dAlignLW;
pwr_tConfigStatusEnum ConfigurationStatus pwr_dAlignW;
pwr_tSafetyLevelEnum SafetyLevel pwr_dAlignW;
};
struct pwr_s_RootVolume {
......
......@@ -117,6 +117,19 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$ConfigStatusEnum"
EndBody
EndObject
!/**
! @Summary Safety level.
! Safety level.
! Safety level in the development environment for an hierarchy,
! plcprogram or process graph, set by the designer to indicate
! the level. If a level is set for an object, it is marked with
! a warning trangle.
!*/
Object SafetyLevel $Intern 5
Body SysBody
Attr TypeRef = "pwrs:Type-$SafetyLevelEnum"
EndBody
EndObject
EndObject
Object DevBody $ObjBodyDef 2
Object ScanTime $Intern 1
......
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2015 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.
!
! pwrb_c_redwarning.wb_load -- Defines the class RedWarning.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group Plc,PlcEdit
! @Summary Red warning triangle
! Red warning triangle.
!*/
Object RedWarning $ClassDef 675
Body SysBody
Attr Flags |= pwr_mClassDef_DevOnly
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_DevBodyOnly
EndBody
Object DevBody $ObjBodyDef 2
Object PlcNode $Buffer 1
Body SysBody
Attr Class = pwr_eClass_PlcNode
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
EndObject
Object GraphPlcNode $GraphPlcNode
Body SysBody
Attr object_type = 11
Attr parameters[0] = 0
Attr parameters[1] = 0
Attr parameters[2] = 0
Attr parameters[3] = 0
Attr subwindows = 0
Attr graphmethod = 4
Attr graphindex = 49
Attr default_mask[0] = 0
Attr default_mask[1] = 0
Attr segname_annotation = 0
Attr devbody_annotation = 0
Attr compmethod = 2
Attr compindex = 0
Attr tracemethod = 0
Attr traceindex = 0
Attr objname = "RedWarning"
Attr graphname = "RedWarning"
Attr debugpar = ""
EndBody
EndObject
EndObject
EndSObject
......@@ -212,6 +212,19 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$ConfigStatusEnum"
EndBody
EndObject
!/**
! @Summary Safety level.
! Safety level.
! Safety level in the development environment for an hierarchy,
! plcprogram or process graph, set by the designer to indicate
! the level. If a level is set for an object, it is marked with
! a warning trangle.
!*/
Object SafetyLevel $Attribute 17
Body SysBody
Attr TypeRef = "pwrs:Type-$SafetyLevelEnum"
EndBody
EndObject
EndObject
Object Template XttGraph
Body RtBody
......
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2015 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.
!
! pwrb_c_yellowwarning.wb_load -- Defines the class YellowWarning.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group Plc,PlcEdit
! @Summary Red warning triangle
! Red warning triangle.
!*/
Object YellowWarning $ClassDef 676
Body SysBody
Attr Flags |= pwr_mClassDef_DevOnly
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_DevBodyOnly
EndBody
Object DevBody $ObjBodyDef 2
Object PlcNode $Buffer 1
Body SysBody
Attr Class = pwr_eClass_PlcNode
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
EndObject
Object GraphPlcNode $GraphPlcNode
Body SysBody
Attr object_type = 11
Attr parameters[0] = 0
Attr parameters[1] = 0
Attr parameters[2] = 0
Attr parameters[3] = 0
Attr subwindows = 0
Attr graphmethod = 4
Attr graphindex = 48
Attr default_mask[0] = 0
Attr default_mask[1] = 0
Attr segname_annotation = 0
Attr devbody_annotation = 0
Attr compmethod = 2
Attr compindex = 0
Attr tracemethod = 0
Attr traceindex = 0
Attr objname = "YellowWarning"
Attr graphname = "YellowWarning"
Attr debugpar = ""
EndBody
EndObject
EndObject
EndSObject
......@@ -102,6 +102,19 @@ SObject pwrs:Class
Attr TypeRef = "pwrs:Type-$ConfigStatusEnum"
EndBody
EndObject
!/**
! @Summary Safety level.
! Safety level.
! Safety level in the development environment for an hierarchy,
! plcprogram or process graph, set by the designer to indicate
! the level. If a level is set for an object, it is marked with
! a warning trangle.
!*/
Object SafetyLevel $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$SafetyLevelEnum"
EndBody
EndObject
EndObject
Object NavigatorPosnn $Menu
Object Pointed $Menu
......
......@@ -155,6 +155,19 @@ SObject pwrs:Class
Attr TypeRef = "pwrs:Type-$ConfigStatusEnum"
EndBody
EndObject
!/**
! @Summary Safety level.
! Safety level.
! Safety level in the development environment for an hierarchy,
! plcprogram or process graph, set by the designer to indicate
! the level. If a level is set for an object, it is marked with
! a warning trangle.
!*/
Object SafetyLevel $Attribute 9
Body SysBody
Attr TypeRef = "pwrs:Type-$SafetyLevelEnum"
EndBody
EndObject
EndObject
Object NavigatorPosnn $Menu
Object Pointed $Menu
......
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2015 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.
!
! pwrs_td_safetylevelenum.wb_load -- Defines the enum type SafetyLevel
!
SObject pwrs:Type
!/**
! @Version 1.0
! @Group Types
! Enumeration for safety level.
!*/
Object $SafetyLevelEnum $TypeDef 25
Body SysBody
Attr TypeRef = "pwrs:Type-$Enum"
Attr PgmName = "SafetyLevelEnum"
EndBody
!/**
! None.
!*/
Object None $Value
Body SysBody
Attr PgmName = "None"
Attr Text = "None"
Attr Value = 0
EndBody
EndObject
!/**
! Low.
!*/
Object Low $Value
Body SysBody
Attr PgmName = "Low"
Attr Text = "Low"
Attr Value = 1
EndBody
EndObject
!/**
! High.
!*/
Object High $Value
Body SysBody
Attr PgmName = "High"
Attr Text = "High"
Attr Value = 2
EndBody
EndObject
EndObject
EndSObject
......@@ -811,9 +811,11 @@ palette PlcEditorPalette
class HelpText
class HelpTextL
class Point
class RedWarning
class ShowPlcAttr
class Text
class Title
class YellowWarning
}
menu Grafcet
{
......
......@@ -276,6 +276,13 @@ int goen_create_nodetype_m3(
flow_CreateNodeClass( ctx, name, flow_eNodeGroup_Common,
&nc);
if ( graph_index == 3) {
flow_AddFilledTriangle( nc, f_delta, -f_yoffs, GOEN_F_GRID,
GOEN_F_GRID, flow_eDrawType_LineRed, flow_mDisplayLevel_1);
flow_AddTriangle( nc, f_delta, -f_yoffs, GOEN_F_GRID,
GOEN_F_GRID, flow_eDrawType_Line, line_width, flow_mDisplayLevel_1);
}
if ( ! (frame_width == 0.0 && frame_height == 0.0))
{
/* Draw a rectangle that is 'hot' only on the lines */
......
......@@ -79,7 +79,9 @@ typedef enum {
goen_eGraphIndex_StoDTgeneric = 44,
goen_eGraphIndex_True = 45,
goen_eGraphIndex_False = 46,
goen_eGraphIndex_IOSimulFlag = 47
goen_eGraphIndex_IOSimulFlag = 47,
goen_eGraphIndex_YellowWarning = 48,
goen_eGraphIndex_RedWarning = 49
} goen_eGraphIndex;
static float f_pinlength = GOEN_F_PINLENGTH;
......@@ -144,7 +146,14 @@ int goen_create_nodetype_m4(
sizeof( annot_str)/sizeof(annot_str[0]), sizeof( annot_str[0]));
if ( EVEN(sts)) return sts;
flow_CreateNodeClass( ctx, name, flow_eNodeGroup_Common, &nc);
switch ( graph_index) {
case goen_eGraphIndex_RedWarning:
case goen_eGraphIndex_YellowWarning:
flow_CreateNodeClass( ctx, name, flow_eNodeGroup_Safety, &nc);
break;
default:
flow_CreateNodeClass( ctx, name, flow_eNodeGroup_Common, &nc);
}
switch ( graph_index)
{
......@@ -545,6 +554,24 @@ int goen_create_nodetype_m4(
flow_eDrawType_TextHelvetica, GOEN_F_TEXTSIZE);
break;
}
case goen_eGraphIndex_RedWarning:
case goen_eGraphIndex_YellowWarning:
{
flow_eDrawType draw_type;
f_width = GOEN_F_GRID * 2;
f_height = GOEN_F_GRID * 2;
if ( graph_index == goen_eGraphIndex_RedWarning)
draw_type = flow_eDrawType_LineRed;
else
draw_type = flow_eDrawType_Yellow;
flow_AddFilledTriangle( nc, 0, GOEN_F_GRID/2, f_width, f_height, draw_type, flow_mDisplayLevel_1);
flow_AddTriangle( nc, 0, GOEN_F_GRID/2, f_width, f_height, flow_eDrawType_Line, 1, flow_mDisplayLevel_1);
break;
}
}
*node_class = nc;
return GOEN__SUCCESS;
......
This diff is collapsed.
......@@ -54,10 +54,26 @@
#endif
typedef enum {
wnav_eBrowType_Volume,
wnav_eBrowType_Setup,
wnav_eBrowType_Other
} wnav_eBrowType;
wnav_eBrowType_Volume,
wnav_eBrowType_Setup,
wnav_eBrowType_Other
} wnav_eBrowType;
typedef enum {
wnav_eMultiobject_Normal,
wnav_eMultiobject_RedSquare,
wnav_eMultiobject_YellowSquare,
wnav_eMultiobject_GreenSquare,
wnav_eMultiobject_RedTriangle,
wnav_eMultiobject_RedSquare_RedTriangle,
wnav_eMultiobject_YellowSquare_RedTriangle,
wnav_eMultiobject_GreenSquare_RedTriangle,
wnav_eMultiobject_YellowTriangle,
wnav_eMultiobject_RedSquare_YellowTriangle,
wnav_eMultiobject_YellowSquare_YellowTriangle,
wnav_eMultiobject_GreenSquare_YellowTriangle,
wnav_eMultiobject_
} wnav_eMultiobject;
class WNavBrow {
public:
......@@ -73,10 +89,14 @@ class WNavBrow {
BrowCtx *ctx;
void *userdata;
brow_tNodeClass nc_object;
brow_tNodeClass nc_multiobject;
brow_tNodeClass nc_multiobject[wnav_eMultiobject_];
brow_tNodeClass nc_multiobject_red;
brow_tNodeClass nc_multiobject_yellow;
brow_tNodeClass nc_multiobject_green;
brow_tNodeClass nc_multiobject_warn;
brow_tNodeClass nc_multiobject_red_warn;
brow_tNodeClass nc_multiobject_yellow_warn;
brow_tNodeClass nc_multiobject_green_warn;
brow_tNodeClass nc_attr;
brow_tNodeClass nc_attr_full;
brow_tNodeClass nc_attr_input;
......
......@@ -89,7 +89,8 @@ WItemObject::WItemObject( WNav *wnav, pwr_tObjid item_objid,
char segname[120];
pwr_tObjid child;
pwr_tClassId classid;
pwr_tEnum *config_status;
pwr_tEnum *config_status_p, *safety_level_p;
pwr_tEnum config_status, safety_level;
char *descr;
char descr_str[200];
int size;
......@@ -110,6 +111,7 @@ WItemObject::WItemObject( WNav *wnav, pwr_tObjid item_objid,
segname, sizeof(segname), &size);
// Get ConfigStatus
config_status = 0;
for ( int i = 0; i < 3; i++) {
switch ( i) {
case 0:
......@@ -123,57 +125,117 @@ WItemObject::WItemObject( WNav *wnav, pwr_tObjid item_objid,
break;
}
sts = ldh_GetObjectPar( wnav->ldhses, objid, body, "ConfigurationStatus",
(char **)&config_status, &size);
if ( ODD(sts)) break;
(char **)&config_status_p, &size);
if ( ODD(sts)) {
config_status = *config_status_p;
free((char *) config_status_p);
break;
}
}
if ( EVEN(sts)) {
nc = wnav->brow->nc_multiobject;
// Get SafetyLevel
safety_level = 0;
for ( int i = 0; i < 3; i++) {
switch ( i) {
case 0:
strcpy( body, "DevBody");
break;
case 1:
strcpy( body, "SysBody");
break;
case 2:
strcpy( body, "RtBody");
break;
}
sts = ldh_GetObjectPar( wnav->ldhses, objid, body, "SafetyLevel",
(char **)&safety_level_p, &size);
if ( ODD(sts)) {
safety_level = *safety_level_p;
free( (char *)safety_level_p);
break;
}
}
if ( config_status == 0) {
switch ( safety_level) {
case pwr_eSafetyLevel_None:
nc = wnav->brow->nc_multiobject[wnav_eMultiobject_Normal];
break;
case pwr_eSafetyLevel_Low:
nc = wnav->brow->nc_multiobject[wnav_eMultiobject_YellowTriangle];
break;
case pwr_eSafetyLevel_High:
nc = wnav->brow->nc_multiobject[wnav_eMultiobject_RedTriangle];
break;
}
strcpy( descr_str, "");
}
else {
// Evaluate config status
if ( *config_status == 0) {
nc = wnav->brow->nc_multiobject;
strcpy( descr_str, "");
}
else {
// Get enum text
ldh_sParDef adef;
ldh_sValueDef *vd;
int rows;
sts = ldh_GetAttrDef( wnav->ldhses, classid, body, "ConfigurationStatus", &adef);
if ( EVEN(sts)) return;
sts = ldh_GetEnumValueDef( wnav->ldhses, adef.Par->Param.TypeRef, &vd, &rows);
if ( EVEN(sts)) return;
// Get enum text
ldh_sParDef adef;
ldh_sValueDef *vd;
int rows;
sts = ldh_GetAttrDef( wnav->ldhses, classid, body, "ConfigurationStatus", &adef);
if ( EVEN(sts)) return;
bool found = false;
int i;
for ( i = 0; i < rows; i++) {
if ( vd[i].Value.Value == *config_status) {
found = true;
sts = ldh_GetEnumValueDef( wnav->ldhses, adef.Par->Param.TypeRef, &vd, &rows);
if ( EVEN(sts)) return;
bool found = false;
int i;
for ( i = 0; i < rows; i++) {
if ( vd[i].Value.Value == config_status) {
found = true;
break;
}
}
if ( found) {
if ( config_status < 100) {
switch ( safety_level) {
case pwr_eSafetyLevel_None:
nc = wnav->brow->nc_multiobject[wnav_eMultiobject_RedSquare];
break;
}
case pwr_eSafetyLevel_Low:
nc = wnav->brow->nc_multiobject[wnav_eMultiobject_RedSquare_YellowTriangle];
break;
case pwr_eSafetyLevel_High:
nc = wnav->brow->nc_multiobject[wnav_eMultiobject_RedSquare_RedTriangle];
break;
}
}
if ( found) {
if ( *config_status < 100)
nc = wnav->brow->nc_multiobject_red;
else if ( *config_status < 200)
nc = wnav->brow->nc_multiobject_yellow;
else
nc = wnav->brow->nc_multiobject_green
;
sprintf( descr_str, "<%s> ", vd[i].Value.Text);
else if ( config_status < 200) {
switch ( safety_level) {
case pwr_eSafetyLevel_None:
nc = wnav->brow->nc_multiobject[wnav_eMultiobject_YellowSquare];
break;
case pwr_eSafetyLevel_Low:
nc = wnav->brow->nc_multiobject[wnav_eMultiobject_YellowSquare_YellowTriangle];
break;
case pwr_eSafetyLevel_High:
nc = wnav->brow->nc_multiobject[wnav_eMultiobject_YellowSquare_RedTriangle];
break;
}
}
else {
nc = wnav->brow->nc_multiobject_red;
strcpy( descr_str, "<Unknown status> ");
switch ( safety_level) {
case pwr_eSafetyLevel_None:
nc = wnav->brow->nc_multiobject[wnav_eMultiobject_GreenSquare];
break;
case pwr_eSafetyLevel_Low:
nc = wnav->brow->nc_multiobject[wnav_eMultiobject_GreenSquare_YellowTriangle];
break;
case pwr_eSafetyLevel_High:
nc = wnav->brow->nc_multiobject[wnav_eMultiobject_GreenSquare_RedTriangle];
break;
}
}
free( (char *)vd);
sprintf( descr_str, "<%s> ", vd[i].Value.Text);
}
free((char *) config_status);
else {
nc = wnav->brow->nc_multiobject_red;
strcpy( descr_str, "<Unknown status> ");
}
free( (char *)vd);
}
brow_CreateNode( wnav->brow->ctx, segname, nc, dest, dest_code, (void *) this,
......
......@@ -1045,6 +1045,69 @@ int FlowDrawGtk::nav_rect_erase( FlowCtx *ctx, int x, int y, int width, int heig
return 1;
}
int FlowDrawGtk::triangle( FlowCtx *ctx, int x, int y, int width, int height,
flow_eDrawType gc_type, int idx, int highlight, int dimmed)
{
if ( ctx->nodraw) return 1;
if ( gc_type == flow_eDrawType_LineGray && highlight)
gc_type = flow_eDrawType_Line;
GdkPoint p[4] = {{x,y+height},{x+width/2,y},{x+width,y+height},{x,y+height}};
gdk_draw_polygon( window,
gcs[gc_type+highlight][idx], 0, p, 4);
return 1;
}
int FlowDrawGtk::triangle_erase( FlowCtx *ctx, int x, int y, int width, int height,
int idx)
{
if ( ctx->nodraw) return 1;
GdkPoint p[4] = {{x,y+height},{x+width/2,y},{x+width,y+height},{x,y+height}};
gdk_draw_polygon( window,
gcs[flow_eDrawType_LineErase][idx], 0,
p, 4);
return 1;
}
int FlowDrawGtk::nav_triangle( FlowCtx *ctx, int x, int y, int width, int height,
flow_eDrawType gc_type, int idx, int highlight)
{
if ( ctx->no_nav || ctx->nodraw) return 1;
if ( gc_type == flow_eDrawType_LineGray && highlight)
gc_type = flow_eDrawType_Line;
GdkPoint p[4] = {{x,y+height},{x+width/2,y},{x+width,y+height},{x,y+height}};
gdk_draw_polygon( nav_window,
gcs[gc_type+highlight][idx], 0, p, 4);
return 1;
}
int FlowDrawGtk::nav_fill_triangle( FlowCtx *ctx, int x, int y, int width, int height,
flow_eDrawType gc_type)
{
if ( ctx->no_nav || ctx->nodraw || gc_type != flow_eDrawType_LineRed) return 1;
GdkPoint p[4] = {{x,y+height},{x+width/2,y},{x+width,y+height},{x,y+height}};
gdk_draw_polygon( nav_window,
gcs[gc_type][0], 1, p, 4);
return 1;
}
int FlowDrawGtk::nav_triangle_erase( FlowCtx *ctx, int x, int y, int width, int height,
int idx)
{
if ( ctx->no_nav || ctx->nodraw) return 1;
GdkPoint p[4] = {{x,y+height},{x+width/2,y},{x+width,y+height},{x,y+height}};
gdk_draw_polygon( nav_window,
gcs[flow_eDrawType_LineErase][idx], 0,
p, 4);
return 1;
}
int FlowDrawGtk::arrow( FlowCtx *ctx, int x1, int y1, int x2, int y2,
int x3, int y3,
flow_eDrawType gc_type, int idx, int highlight)
......@@ -1592,6 +1655,23 @@ int FlowDrawGtk::fill_rect( FlowCtx *ctx, int x, int y, int w, int h,
return 1;
}
int FlowDrawGtk::fill_triangle( FlowCtx *ctx, int x, int y, int w, int h,
flow_eDrawType gc_type)
{
if ( ctx->nodraw) return 1;
GdkPoint p[4] = {{x,y+h},{x+w/2,y},{x+w,y+h},{x,y+h}};
if ( gc_type == flow_eDrawType_Green)
gdk_draw_polygon( window, gc_green, 1, p, 4);
else if ( gc_type == flow_eDrawType_Yellow)
gdk_draw_polygon( window, gc_yellow, 1, p, 4);
else if ( gc_type == flow_eDrawType_DarkGray)
gdk_draw_polygon( window, gc_darkgray, 1, p, 4);
else
gdk_draw_polygon( window, gcs[gc_type][0], 1, p, 4);
return 1;
}
int FlowDrawGtk::image( FlowCtx *ctx, int x, int y, int width, int height,
flow_tImImage image, flow_tPixmap pixmap, flow_tPixmap clip_mask)
{
......
......@@ -95,6 +95,16 @@ class FlowDrawGtk : public FlowDraw {
flow_eDrawType gc_type, int idx, int highlight);
int nav_rect_erase( FlowCtx *ctx, int x, int y, int width, int height,
int idx);
int triangle( FlowCtx *ctx, int x, int y, int width, int height,
flow_eDrawType gc_type, int idx, int highlight, int dimmed);
int triangle_erase( FlowCtx *ctx, int x, int y, int width, int height,
int idx);
int nav_triangle( FlowCtx *ctx, int x, int y, int width, int height,
flow_eDrawType gc_type, int idx, int highlight);
int nav_fill_triangle( FlowCtx *ctx, int x, int y, int width, int height,
flow_eDrawType gc_type);
int nav_triangle_erase( FlowCtx *ctx, int x, int y, int width, int height,
int idx);
int arrow( FlowCtx *ctx, int x1, int y1, int x2, int y2,
int x3, int y3,
flow_eDrawType gc_type, int idx, int highlight);
......@@ -139,6 +149,8 @@ class FlowDrawGtk : public FlowDraw {
flow_eDrawType gc_type, int idx, int line, double size);
int fill_rect( FlowCtx *ctx, int x, int y, int width, int height,
flow_eDrawType gc_type);
int fill_triangle( FlowCtx *ctx, int x, int y, int width, int height,
flow_eDrawType gc_type);
int image( FlowCtx *ctx, int x, int y, int width, int height,
flow_tImImage image, flow_tPixmap pixmap, flow_tPixmap clip_mask);
int pixmaps_create( FlowCtx *ctx, flow_sPixmapData *pixmap_data,
......
......@@ -113,7 +113,8 @@ typedef enum {
flow_eObjectType_Radiobutton,
flow_eObjectType_Frame,
flow_eObjectType_Image,
flow_eObjectType_AnnotPixmapButton
flow_eObjectType_AnnotPixmapButton,
flow_eObjectType_Triangle
} flow_eObjectType;
typedef enum {
......@@ -132,7 +133,8 @@ typedef enum {
typedef enum {
flow_eNodeGroup_Common,
flow_eNodeGroup_Document,
flow_eNodeGroup_Trace
flow_eNodeGroup_Trace,
flow_eNodeGroup_Safety
} flow_eNodeGroup;
typedef enum {
......@@ -417,6 +419,7 @@ typedef enum {
flow_eSave_Radiobutton = 17,
flow_eSave_Frame = 18,
flow_eSave_AnnotPixmapButton = 19,
flow_eSave_Triangle = 20,
flow_eSave_End = 99,
flow_eSave_Ctx_zoom_factor = 100,
flow_eSave_Ctx_base_zoom_factor = 101,
......@@ -472,6 +475,7 @@ typedef enum {
flow_eSave_Rect_ll = 502,
flow_eSave_Rect_ur = 503,
flow_eSave_Rect_display_level = 504,
flow_eSave_Rect_fill = 505,
flow_eSave_Line_draw_type = 600,
flow_eSave_Line_line_width = 601,
flow_eSave_Line_p1 = 602,
......@@ -552,7 +556,8 @@ typedef enum {
flow_eSave_Arrow_line_width = 1403,
flow_eSave_Arrow_p_dest = 1404,
flow_eSave_Arrow_p1 = 1405,
flow_eSave_Arrow_p2 = 1406
flow_eSave_Arrow_p2 = 1406,
flow_eSave_Triangle_rect_part = 2000
} flow_eSave;
typedef enum {
......
......@@ -58,6 +58,7 @@
#include "flow_annot.h"
#include "flow_draw.h"
#include "flow_tiptext.h"
#include "flow_triangle.h"
#include "flow_api.h"
int flow_Save( flow_tCtx ctx, char *filename)
......@@ -377,6 +378,25 @@ void flow_AddFilledRect( flow_tNodeClass nc, double x, double y,
((FlowNodeClass *)nc)->insert( rect);
}
void flow_AddTriangle( flow_tNodeClass nc, double x, double y,
double width, double height,
flow_eDrawType draw_type, int line_width, flow_mDisplayLevel display_level)
{
FlowTriangle *triangle = new FlowTriangle( ((FlowNodeClass *)nc)->ctx, x, y,
width, height, draw_type, line_width, 0, display_level);
((FlowNodeClass *)nc)->insert( triangle);
}
void flow_AddFilledTriangle( flow_tNodeClass nc, double x, double y,
double width, double height,
flow_eDrawType draw_type, flow_mDisplayLevel display_level)
{
FlowTriangle *triangle = new FlowTriangle( ((FlowNodeClass *)nc)->ctx, x, y,
width, height, draw_type, 0, 0, display_level, 1);
((FlowNodeClass *)nc)->insert( triangle);
}
void flow_AddLine( flow_tNodeClass nc, double x1, double y1,
double x2, double y2,
flow_eDrawType draw_type, int line_width)
......
......@@ -177,6 +177,12 @@ void flow_AddRect( flow_tNodeClass nc, double x, double y,
void flow_AddFilledRect( flow_tNodeClass nc, double x, double y,
double width, double height,
flow_eDrawType draw_type, flow_mDisplayLevel display_level);
void flow_AddTriangle( flow_tNodeClass nc, double x, double y,
double width, double height,
flow_eDrawType draw_type, int line_width, flow_mDisplayLevel display_level);
void flow_AddFilledTriangle( flow_tNodeClass nc, double x, double y,
double width, double height,
flow_eDrawType draw_type, flow_mDisplayLevel display_level);
void flow_AddLine( flow_tNodeClass nc, double x1, double y1,
double x2, double y2,
flow_eDrawType draw_type, int line_width);
......
......@@ -43,6 +43,7 @@
#include "flow_ctx.h"
#include "flow_point.h"
#include "flow_rect.h"
#include "flow_triangle.h"
#include "flow_node.h"
#include "flow_con.h"
#include "flow_nodeclass.h"
......@@ -181,6 +182,12 @@ void FlowArray::copy_from( const FlowArray& array)
insert( n);
break;
}
case flow_eObjectType_Triangle:
{
FlowTriangle *n = new FlowTriangle(*(FlowTriangle *)array.a[i]);
insert( n);
break;
}
case flow_eObjectType_Text:
{
FlowText *n = new FlowText(*(FlowText *)array.a[i]);
......@@ -753,6 +760,13 @@ void FlowArray::open( void *ctx, ifstream& fp)
insert( n);
break;
}
case flow_eSave_Triangle:
{
FlowTriangle *n = new FlowTriangle( (FlowCtx *) ctx);
n->open( fp);
insert( n);
break;
}
case flow_eSave_Node:
{
FlowNode *n = new FlowNode( (FlowCtx *) ctx, "", 0, 0, 0);
......
......@@ -62,6 +62,7 @@
#include "flow_conpoint.h"
#include "flow_annot.h"
#include "flow_radiobutton.h"
#include "flow_triangle.h"
#include "flow_tiptext.h"
#include "flow_draw.h"
#include "flow_browapi.h"
......@@ -351,6 +352,26 @@ void brow_AddFilledRect( brow_tNodeClass nc, double x, double y,
}
void brow_AddTriangle( brow_tNodeClass nc, double x, double y,
double width, double height,
flow_eDrawType draw_type, int line_width, int fix_line_width)
{
FlowTriangle *rect = new FlowTriangle( ((FlowNodeClass *)nc)->ctx, x, y,
width, height, draw_type, line_width, fix_line_width);
((FlowNodeClass *)nc)->insert( rect);
}
void brow_AddFilledTriangle( brow_tNodeClass nc, double x, double y,
double width, double height,
flow_eDrawType draw_type)
{
FlowTriangle *rect = new FlowTriangle( ((FlowNodeClass *)nc)->ctx, x, y,
width, height, draw_type, 1, 0, flow_mDisplayLevel_1, 1);
((FlowNodeClass *)nc)->insert( rect);
}
void brow_AddFrame( brow_tNodeClass nc, double x, double y,
double width, double height,
flow_eDrawType draw_type, int line_width, int fix_line_width)
......
......@@ -149,6 +149,12 @@ void brow_AddRect( brow_tNodeClass nc, double x, double y,
void brow_AddFilledRect( brow_tNodeClass nc, double x, double y,
double width, double height,
flow_eDrawType draw_type);
void brow_AddTriangle( brow_tNodeClass nc, double x, double y,
double width, double height,
flow_eDrawType draw_type, int line_width, int fix_line_width);
void brow_AddFilledTriangle( brow_tNodeClass nc, double x, double y,
double width, double height,
flow_eDrawType draw_type);
void brow_AddFrame( brow_tNodeClass nc, double x, double y,
double width, double height,
flow_eDrawType draw_type, int line_width, int fix_line_width);
......
......@@ -68,6 +68,16 @@ class FlowDraw {
flow_eDrawType gc_type, int idx, int highlight) {return 1;}
virtual int nav_rect_erase( FlowCtx *ctx, int x, int y, int width, int height,
int idx) {return 1;}
virtual int triangle( FlowCtx *ctx, int x, int y, int width, int height,
flow_eDrawType gc_type, int idx, int highlight, int dimmed) {return 1;}
virtual int triangle_erase( FlowCtx *ctx, int x, int y, int width, int height,
int idx) {return 1;}
virtual int nav_triangle( FlowCtx *ctx, int x, int y, int width, int height,
flow_eDrawType gc_type, int idx, int highlight) {return 1;}
virtual int nav_fill_triangle( FlowCtx *ctx, int x, int y, int width, int height,
flow_eDrawType gc_type) {return 1;}
virtual int nav_triangle_erase( FlowCtx *ctx, int x, int y, int width, int height,
int idx) {return 1;}
virtual int arrow( FlowCtx *ctx, int x1, int y1, int x2, int y2,
int x3, int y3,
flow_eDrawType gc_type, int idx, int highlight) {return 1;}
......@@ -115,6 +125,8 @@ class FlowDraw {
flow_eDrawType gc_type, int idx, int line, double size) {return 1;}
virtual int fill_rect( FlowCtx *ctx, int x, int y, int width, int height,
flow_eDrawType gc_type) {return 1;}
virtual int fill_triangle( FlowCtx *ctx, int x, int y, int width, int height,
flow_eDrawType gc_type) {return 1;}
virtual int image( FlowCtx *ctx, int x, int y, int width, int height,
flow_tImImage image, flow_tPixmap pixmap, flow_tPixmap clip_mask) {return 1;}
virtual int pixmaps_create( FlowCtx *ctx, flow_sPixmapData *pixmap_data,
......
......@@ -503,7 +503,7 @@ void FlowNode::nav_draw( int ll_x, int ll_y, int ur_x, int ur_y)
y_high_pix >= ll_y &&
y_low_pix <= ur_y)
{
if ( x_right_pix - x_left_pix < 10 && y_high_pix - y_low_pix < 10)
if ( x_right_pix - x_left_pix < 10 && y_high_pix - y_low_pix < 10 && nc->group != flow_eNodeGroup_Safety)
ctx->fdraw->nav_rect( ctx, x_left_pix, y_low_pix,
x_right_pix - x_left_pix, y_high_pix - y_low_pix,
flow_eDrawType_Line, 0, highlight);
......
......@@ -132,6 +132,20 @@ int FlowPdf::filled_rect( double x, double y, double width, double height,
return 1;
}
int FlowPdf::triangle( double x, double y, double width, double height, flow_eDrawType type,
double idx, int highlight)
{
topdf->draw_triangle( idx, x - offset_x, offset_y - y - height, width, height);
return 1;
}
int FlowPdf::filled_triangle( double x, double y, double width, double height,
flow_eDrawType type, double idx)
{
topdf->draw_filled_triangle( type, x - offset_x, offset_y - y - height, width, height);
return 1;
}
int FlowPdf::arc( double x, double y, double width, double height, int angle1, int angle2,
flow_eDrawType type, double idx, int highlight)
{
......
......@@ -51,6 +51,8 @@ class FlowPdf : public FlowPrint {
int print_page( double ll_x, double ll_y, double ur_x, double ur_y);
int rect( double x, double y, double width, double height, flow_eDrawType type, double idx, int highlight);
int filled_rect( double x, double y, double width, double height, flow_eDrawType type, double idx);
int triangle( double x, double y, double width, double height, flow_eDrawType type, double idx, int highlight);
int filled_triangle( double x, double y, double width, double height, flow_eDrawType type, double idx);
int arc( double x, double y, double width, double height, int angel1, int angel2,
flow_eDrawType type, double idx, int highlight);
int line( double x1, double y1, double x2, double y2, flow_eDrawType type, double idx, int highlight);
......
......@@ -55,6 +55,8 @@ class FlowPrint {
virtual int print_page( double ll_x, double ll_y, double ur_x, double ur_y) {return 1;}
virtual int rect( double x, double y, double width, double height, flow_eDrawType type, double idx, int highlight) { return 1;}
virtual int filled_rect( double x, double y, double width, double height, flow_eDrawType type, double idx) {return 1;}
virtual int triangle( double x, double y, double width, double height, flow_eDrawType type, double idx, int highlight) { return 1;}
virtual int filled_triangle( double x, double y, double width, double height, flow_eDrawType type, double idx) {return 1;}
virtual int arc( double x, double y, double width, double height, int angle1, int angle2,
flow_eDrawType type, double idx, int highlight) {return 1;}
virtual int line( double x1, double y1, double x2, double y2, flow_eDrawType type, double idx, int highlight) {return 1;}
......
......@@ -198,6 +198,64 @@ int FlowPscript::filled_rect( double x, double y, double width, double height, f
return 1;
}
int FlowPscript::triangle( double x, double y, double width, double height, flow_eDrawType type,
double idx, int highlight)
{
idx = MAX( 0.5, idx);
if ( type == flow_eDrawType_LineGray) {
fprintf( file, "gsave\n");
fprintf( file, "0.5 setgray\n");
}
if ( highlight && show_red) {
fprintf( file, "gsave\n");
fprintf( file, "0 1 1 0 setcmykcolor\n");
}
setlinewidth( idx);
fprintf( file, "newpath\n");
fprintf( file, "%f %f moveto\n", x-offset_x, offset_y-(y+height));
fprintf( file, "%f %f lineto\n", (x+width/2)-offset_x, offset_y-y);
fprintf( file, "%f %f lineto\n", (x+width)-offset_x, offset_y-(y+height));
fprintf( file, "%f %f lineto\n", x-offset_x, offset_y-(y+height));
fprintf( file, "closepath\n");
fprintf( file, "stroke\n");
if ( type == flow_eDrawType_LineGray)
fprintf( file, "grestore\n");
if ( highlight && show_red)
fprintf( file, "grestore\n");
return 1;
}
int FlowPscript::filled_triangle( double x, double y, double width, double height, flow_eDrawType type,
double idx)
{
if ( type == flow_eDrawType_LineRed) {
fprintf( file, "gsave\n");
fprintf( file, "1.0 0.2 0.2 setrgbcolor\n");
}
else if ( type == flow_eDrawType_Yellow) {
fprintf( file, "gsave\n");
fprintf( file, "1.0 1.0 0.0 setrgbcolor\n");
}
setlinewidth( idx);
fprintf( file, "newpath\n");
fprintf( file, "%f %f moveto\n", x-offset_x, offset_y-(y+height));
fprintf( file, "%f %f lineto\n", (x+width/2)-offset_x, offset_y-y);
fprintf( file, "%f %f lineto\n", (x+width)-offset_x, offset_y-(y+height));
fprintf( file, "%f %f lineto\n", x-offset_x, offset_y-(y+height));
fprintf( file, "closepath\n");
fprintf( file, "fill\n");
if ( type == flow_eDrawType_LineRed || type == flow_eDrawType_Yellow)
fprintf( file, "grestore\n");
return 1;
}
int FlowPscript::arc( double x, double y, double width, double height, int angle1, int angle2,
flow_eDrawType type, double idx, int highlight)
{
......
......@@ -49,6 +49,8 @@ class FlowPscript : public FlowPrint {
int print_page( double ll_x, double ll_y, double ur_x, double ur_y);
int rect( double x, double y, double width, double height, flow_eDrawType type, double idx, int highlight);
int filled_rect( double x, double y, double width, double height, flow_eDrawType type, double idx);
int triangle( double x, double y, double width, double height, flow_eDrawType type, double idx, int highlight);
int filled_triangle( double x, double y, double width, double height, flow_eDrawType type, double idx);
int arc( double x, double y, double width, double height, int angle1, int angle2,
flow_eDrawType type, double idx, int highlight);
int line( double x1, double y1, double x2, double y2, flow_eDrawType type, double idx, int highlight);
......
......@@ -96,6 +96,7 @@ void FlowRect::save( ofstream& fp, flow_eSaveMode mode)
fp << int(flow_eSave_Rect_draw_type) << FSPACE << int(draw_type) << endl;
fp << int(flow_eSave_Rect_line_width) << FSPACE << line_width << endl;
fp << int(flow_eSave_Rect_display_level) << FSPACE << int(display_level) << endl;
fp << int(flow_eSave_Rect_fill) << FSPACE << fill << endl;
fp << int(flow_eSave_Rect_ll) << endl;
ll.save( fp, mode);
fp << int(flow_eSave_Rect_ur) << endl;
......@@ -118,6 +119,7 @@ void FlowRect::open( ifstream& fp)
case flow_eSave_Rect_draw_type: fp >> tmp; draw_type = (flow_eDrawType)tmp; break;
case flow_eSave_Rect_line_width: fp >> line_width; break;
case flow_eSave_Rect_display_level: fp >> tmp; display_level = (flow_mDisplayLevel)tmp; break;
case flow_eSave_Rect_fill: fp >> fill; break;
case flow_eSave_Rect_ll: ll.open( fp); break;
case flow_eSave_Rect_ur: ur.open( fp); break;
case flow_eSave_End: end_found = 1; break;
......
......@@ -63,14 +63,14 @@ class FlowRect : public FlowArrayElem {
int event_handler( void *pos, flow_eEvent event, int x, int y, void *node);
void conpoint_select( void *pos, int x, int y, double *distance,
void **cp) {};
void print( void *pos, void *node, int highlight);
void save( ofstream& fp, flow_eSaveMode mode);
void open( ifstream& fp);
void draw( void *pos, int hightlight, int dimmed, int hot, void *node);
void nav_draw( void *pos, int highlight, void *node);
virtual void print( void *pos, void *node, int highlight);
virtual void save( ofstream& fp, flow_eSaveMode mode);
virtual void open( ifstream& fp);
virtual void draw( void *pos, int hightlight, int dimmed, int hot, void *node);
virtual void nav_draw( void *pos, int highlight, void *node);
void draw_inverse( void *pos, int hot, void *node);
void erase( void *pos, int hot, void *node);
void nav_erase( void *pos, void *node);
virtual void erase( void *pos, int hot, void *node);
virtual void nav_erase( void *pos, void *node);
void get_borders( double pos_x, double pos_y, double *x_right,
double *x_left, double *y_high, double *y_low, void *node);
void move( void *pos, double x, double y, int highlight, int dimmed, int hot);
......
......@@ -519,6 +519,53 @@ void CnvToPdf::draw_rect( double lw, double x, double y, double w, double h)
" " << x << " " << y << " " << w << " " << h << " re S" << endl;
}
void CnvToPdf::draw_triangle( double lw, double x, double y, double w, double h)
{
fp[cf] <<
" " << lw << " w" << endl <<
" " << x << " " << y << " m" << endl <<
" " << x+w/2 << " " << y+h << " l" << endl <<
" " << x+w << " " << y << " l" << endl <<
" " << x << " " << y << " l" << endl <<
" S" << endl;
}
void CnvToPdf::draw_filled_triangle( flow_eDrawType color, double x, double y, double w, double h)
{
float r, g, b;
if ( color == flow_eDrawType_LineRed || color == flow_eDrawType_Yellow) {
if ( color == flow_eDrawType_LineRed) {
r = 1;
g = 0.2;
b = 0.2;
}
else if ( color == flow_eDrawType_Yellow) {
r = 1;
g = 1;
b = 0;
}
fp[cf] <<
" /DeviceRGB cs" << endl <<
" " << r << " " << g << " " << b << " sc" << endl;
}
fp[cf] <<
" " << x << " " << y << " m" << endl <<
" " << x+w/2 << " " << y+h << " l" << endl <<
" " << x+w << " " << y << " l" << endl <<
" " << x << " " << y << " l" << endl <<
" f" << endl;
if ( color == flow_eDrawType_LineRed || color == flow_eDrawType_Yellow) {
r = 0;
g = 0;
b = 0;
fp[cf] <<
" " << r << " " << g << " " << b << " sc" << endl;
}
}
void CnvToPdf::draw_arc( double lw, double x, double y, double w, double h,
int angle1, int angle2)
{
......
......@@ -45,6 +45,7 @@ using namespace std;
#include <vector>
#include <string>
#include "pwr.h"
#include "flow.h"
//#include "cnv_style.h"
//#include "cnv_content.h"
......@@ -262,6 +263,8 @@ class CnvToPdf {
void close();
void print_text( char *text, CnvStyle& style, int mode = pdf_mPrintMode_Pos);
void draw_rect( double lw, double x, double y, double w, double h);
void draw_triangle( double lw, double x, double y, double w, double h);
void draw_filled_triangle( flow_eDrawType color, double x, double y, double w, double h);
void draw_arc( double lw, double x, double y, double w, double h,
int angle1, int angle2);
void draw_line( double lw, double x1, double y1, double x2, double y2,
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2015 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.
**/
#include "flow_std.h"
#include <iostream>
#include "flow_triangle.h"
#include "flow_draw.h"
#include "flow_node.h"
void FlowTriangle::save( ofstream& fp, flow_eSaveMode mode)
{
fp << int(flow_eSave_Triangle) << endl;
fp << int(flow_eSave_Triangle_rect_part) << endl;
FlowRect::save( fp, mode);
fp << int(flow_eSave_End) << endl;
}
void FlowTriangle::open( ifstream& fp)
{
int type;
int end_found = 0;
char dummy[40];
for (;;)
{
fp >> type;
switch( type) {
case flow_eSave_Triangle: break;
case flow_eSave_Triangle_rect_part:
FlowRect::open( fp);
break;
case flow_eSave_End: end_found = 1; break;
default:
cout << "FlowTriangle:open syntax error" << endl;
fp.getline( dummy, sizeof(dummy));
}
if ( end_found)
break;
}
}
void FlowTriangle::draw( void *pos, int highlight, int dimmed, int hot, void *node)
{
if ( !(display_level & ctx->display_level))
return;
int idx;
if ( fix_line_width)
{
idx = line_width;
idx += hot;
if ( idx < 0)
{
erase( pos, hot, node);
return;
}
}
else
{
idx = int( ctx->zoom_factor / ctx->base_zoom_factor * line_width - 1);
idx += hot;
}
idx = MAX( 0, idx);
idx = MIN( idx, DRAW_TYPE_SIZE-1);
if ( !fill)
ctx->fdraw->triangle( ctx, ll.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x, ll.z_y +
((FlowPoint *)pos)->z_y - ctx->offset_y,
ur.z_x - ll.z_x, ur.z_y - ll.z_y, draw_type, idx, highlight, dimmed);
else {
flow_eDrawType dtype;
if ( node && ((FlowNode *)node)->fill_color != flow_eDrawType_Inherit)
dtype = ((FlowNode *)node)->fill_color;
else
dtype = draw_type;
ctx->fdraw->fill_triangle( ctx, ll.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x, ll.z_y +
((FlowPoint *)pos)->z_y - ctx->offset_y,
ur.z_x - ll.z_x, ur.z_y - ll.z_y, dtype);
}
}
void FlowTriangle::erase( void *pos, int hot, void *node)
{
if ( !(display_level & ctx->display_level))
return;
int idx;
if ( fix_line_width)
{
idx = line_width;
idx += hot;
if ( idx < 0) return;
}
else
{
idx = int( ctx->zoom_factor / ctx->base_zoom_factor * line_width - 1);
idx += hot;
}
idx = MAX( 0, idx);
idx = MIN( idx, DRAW_TYPE_SIZE-1);
if ( !fill)
ctx->fdraw->triangle_erase( ctx, ll.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x, ll.z_y +
((FlowPoint *)pos)->z_y - ctx->offset_y,
ur.z_x - ll.z_x, ur.z_y - ll.z_y, idx);
else
ctx->fdraw->fill_triangle( ctx, ll.z_x + ((FlowPoint *)pos)->z_x - ctx->offset_x, ll.z_y +
((FlowPoint *)pos)->z_y - ctx->offset_y,
ur.z_x - ll.z_x, ur.z_y - ll.z_y, flow_eDrawType_LineErase);
}
void FlowTriangle::nav_draw( void *pos, int highlight, void *node)
{
if ( !(display_level & ctx->display_level))
return;
int idx;
if ( fix_line_width)
{
idx = line_width;
if ( idx < 0) return;
}
else
{
idx = int( ctx->nav_zoom_factor / ctx->base_zoom_factor * line_width - 1);
}
idx = MAX( 0, idx);
idx = MIN( idx, DRAW_TYPE_SIZE-1);
if ( !fill)
ctx->fdraw->nav_triangle( ctx, ll.nav_z_x + ((FlowPoint *)pos)->nav_z_x -
ctx->nav_offset_x, ll.nav_z_y +
((FlowPoint *)pos)->nav_z_y - ctx->nav_offset_y,
ur.nav_z_x - ll.nav_z_x, ur.nav_z_y - ll.nav_z_y,
draw_type, idx, highlight);
else {
ctx->fdraw->nav_fill_triangle( ctx, ll.nav_z_x + ((FlowPoint *)pos)->nav_z_x -
ctx->nav_offset_x, ll.nav_z_y +
((FlowPoint *)pos)->nav_z_y - ctx->nav_offset_y,
ur.nav_z_x - ll.nav_z_x, ur.nav_z_y - ll.nav_z_y,
draw_type);
}
}
void FlowTriangle::nav_erase( void *pos, void *node)
{
if ( !(display_level & ctx->display_level))
return;
int idx;
if ( fix_line_width)
{
idx = line_width;
if ( idx < 0) return;
}
else
{
idx = int( ctx->nav_zoom_factor / ctx->base_zoom_factor * line_width - 1);
}
idx = MAX( 0, idx);
idx = MIN( idx, DRAW_TYPE_SIZE-1);
if ( !fill)
ctx->fdraw->nav_triangle_erase( ctx, ll.nav_z_x + ((FlowPoint *)pos)->nav_z_x -
ctx->nav_offset_x, ll.nav_z_y +
((FlowPoint *)pos)->nav_z_y - ctx->nav_offset_y,
ur.nav_z_x - ll.nav_z_x, ur.nav_z_y - ll.nav_z_y,
idx);
else
ctx->fdraw->nav_fill_triangle( ctx, ll.nav_z_x + ((FlowPoint *)pos)->nav_z_x -
ctx->nav_offset_x, ll.nav_z_y +
((FlowPoint *)pos)->nav_z_y - ctx->nav_offset_y,
ur.nav_z_x - ll.nav_z_x, ur.nav_z_y - ll.nav_z_y,
flow_eDrawType_LineErase);
}
void FlowTriangle::print( void *pos, void *node, int highlight)
{
if ( !(display_level & ctx->display_level))
return;
if ( fix_line_width && line_width < 0)
return;
if ( draw_type == flow_eDrawType_LineErase)
return;
double idx = ctx->print_zoom_factor / ctx->base_zoom_factor * line_width;
idx = MAX( 0, idx);
idx = MIN( idx, DRAW_TYPE_SIZE-1);
if ( !fill)
ctx->current_print->triangle( ll.print_z_x + ((FlowPoint *)pos)->print_z_x,
ll.print_z_y + ((FlowPoint *)pos)->print_z_y,
ur.print_z_x - ll.print_z_x, ur.print_z_y - ll.print_z_y,
draw_type, idx, highlight);
else
ctx->current_print->filled_triangle( ll.print_z_x + ((FlowPoint *)pos)->print_z_x,
ll.print_z_y + ((FlowPoint *)pos)->print_z_y,
ur.print_z_x - ll.print_z_x, ur.print_z_y - ll.print_z_y,
draw_type, idx);
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2015 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 flow_triangle_h
#define flow_triangle_h
#include <iostream>
#include <fstream>
#include "flow.h"
#include "flow_ctx.h"
#include "flow_point.h"
#include "flow_array_elem.h"
#include "flow_rect.h"
class FlowTriangle : public FlowRect {
public:
FlowTriangle( FlowCtx *flow_ctx, double x = 0, double y = 0, double w = 0,
double h = 0, flow_eDrawType d_type = flow_eDrawType_Line,
int line_w = 1, int fix_line_w = 0,
flow_mDisplayLevel display_lev = flow_mDisplayLevel_1,
int fill_triangle = 0) :
FlowRect(flow_ctx, x, y, w, h, d_type, line_w, fix_line_w, display_lev, fill_triangle) {}
virtual ~FlowTriangle() {}
void save( ofstream& fp, flow_eSaveMode mode);
void open( ifstream& fp);
void draw( void *pos, int hightlight, int dimmed, int hot, void *node);
void nav_draw( void *pos, int highlight, void *node);
void erase( void *pos, int hot, void *node);
void nav_erase( void *pos, void *node);
void print( void *pos, void *node, int highlight);
};
#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