コード例 #1
0
ファイル: ge_subgraphs.cpp プロジェクト: Strongc/proview
int	SubGraphs::object_attr()
{
  int	i, j;
  grow_tNodeClass *list;
  grow_tNodeClass *list_p;
  int	list_cnt;
  char	name[80];

  grow_GetNodeClassList( (grow_tCtx) grow_ctx, &list, &list_cnt);
  brow_SetNodraw( brow->ctx);

  list_p = list;
  for ( i = 0; i < list_cnt; i++)
  {

    grow_sAttrInfo	*grow_info, *grow_info_p;
    int			grow_info_cnt;
    int			*extern_p;

    grow_GetObjectAttrInfo( (grow_tObject)*list_p, NULL, &grow_info, &grow_info_cnt);

    grow_info_p = grow_info;
    extern_p = 0;
    for ( j = 0; j < grow_info_cnt; j++)
    {
      if ( strcmp( "Extern", grow_info_p->name) == 0)
      {
        extern_p = (int *)grow_info_p->value_p;
        break;
      }
      grow_info_p++;
    }
    grow_FreeObjectAttrInfo( grow_info);

    grow_GetNodeClassName( *list_p, name);

    new ItemSubGraph( this, name, extern_p, *list_p,
	NULL, flow_eDest_IntoLast);
    list_p++;
  }
    
  brow_ResetNodraw( brow->ctx);
  brow_Redraw( brow->ctx, 0);
  return SUBGRAPHS__SUCCESS;
}
コード例 #2
0
ファイル: ge_graph_object.cpp プロジェクト: siamect/proview
static int graph_object_collect_build( Graph *graph, pwr_sAttrRef *attrref)
{
    pwr_sAttrRef *alist, *ap;
    int *is_attrp, *is_attr;
    int sts;
    char name[120];
    double x1, y1;
    grow_sAttrInfo *grow_info, *grow_info_p;
    int grow_info_cnt;
    int i;
    grow_tObject scantime_button;
    grow_tObject hold_button;
    grow_tObject t1, l1;
    double z_width, z_height, z_descent;
    double name_width = 0;
    double trend_width = 48;
    double trend_height = 1.2;
    double y0 = 2.2;
    double x0 = 2;
    pwr_tTypeId attr_type;
    unsigned int attr_size, attr_offset, attr_dimension;
    GeDyn *dyn;
    char attr_name[120];
    grow_sAttributes grow_attr;
    unsigned long mask;
    int trend_cnt = 0;


    if ( ! graph->get_current_objects_cb)
        return 0;

    sts = (graph->get_current_objects_cb) (graph->parent_ctx, &alist, &is_attr);
    if ( EVEN(sts)) return sts;

    if ( cdh_ObjidIsNull( alist->Objid))
        return 0;

    graph->graph_object_data = 0;
    graph->graph_object_close = 0;

    grow_SetPath( graph->grow->ctx, 1, "pwr_exe:");

    // Set graph attributes

    // Default color theme
    mask = grow_eAttr_color_theme;
    strcpy( grow_attr.color_theme, "$default");
    grow_SetAttributes( graph->grow->ctx, &grow_attr, mask);
    grow_ReadCustomColorFile( graph->grow->ctx, 0);

    grow_SetBackgroundColor( graph->grow->ctx, glow_eDrawType_CustomColor1);

    // Scantime input field
    graph->create_node( NULL, "pwrct_valueinputsmallbg", x0, y0 - 1.3, 4, y0 - 1.3 + 1.2,
                        &scantime_button);

    dyn = new GeDyn( graph);
    grow_SetUserData( scantime_button, (void *)dyn);

    dyn->set_dyn( ge_mDynType1_Value, ge_mDynType2_No, ge_mActionType1_ValueInput, ge_mActionType2_No);
    dyn->update_elements();
    dyn->set_access( (glow_mAccess) 65535);
    dyn->set_attribute( scantime_button, "$local.ScanTime##Float32", 0);
    dyn->set_value_input( "%3.0f", 2, 10000000);

    // Hold button
    graph->create_node( "TrendHold", "pwrct_buttonsmalltoggle", x0 + trend_width/2 - 3./2,
                        y0 - 1.4 , x0 + trend_width/2 + 3./2, y0 - 1.4 + 1.2,
                        &hold_button);
    grow_SetAnnotation( hold_button, 1, "Hold", 4);

    dyn = new GeDyn( graph);
    grow_SetUserData( hold_button, (void *)dyn);

    dyn->set_access( (glow_mAccess) 65535);
    dyn->set_attribute( hold_button, "$local.TrendHold##Boolean", 0);

    //  Zero text
    grow_CreateGrowText( graph->grow->ctx, "", "0",
                         x0 + trend_width - 0.2, y0 - 0.3,
                         glow_eDrawType_TextHelvetica, glow_eDrawType_CustomColor5, 3,
                         glow_eFont_LucidaSans, glow_mDisplayLevel_1,
                         NULL, &t1);

    ap = alist;
    is_attrp = is_attr;
    x1 = x0;
    y1 = y0;
    while( cdh_ObjidIsNotNull( ap->Objid)) {
        if ( *is_attrp) {
            sts = gdh_AttrrefToName( ap, name, sizeof(name), cdh_mNName);
            if ( EVEN(sts)) return sts;

            sts = gdh_GetAttributeCharacteristics( name, &attr_type, &attr_size,
                                                   &attr_offset, &attr_dimension);
            if ( EVEN(sts)) return sts;

            switch ( attr_type) {
            case pwr_eType_Boolean: {
                grow_tObject trend;

                grow_CreateGrowTrend( graph->grow->ctx, "ActualValueTrend",
                                      x1, y1, trend_width, trend_height,
                                      glow_eDrawType_Color37,
                                      0, glow_mDisplayLevel_1, 1, 1,
                                      glow_eDrawType_Color40, NULL,
                                      &trend);
                dyn = new GeDyn( graph);
                dyn->dyn_type1 = ge_mDynType1_Trend;
                dyn->update_dyntype( trend);
                dyn->update_elements();
                grow_SetUserData( trend, (void *)dyn);

                grow_GetObjectAttrInfo( trend, NULL,
                                        &grow_info, &grow_info_cnt);

                strcpy( attr_name, name);
                strcat( attr_name, "##Boolean");
                grow_GetUserData( trend, (void **)&dyn);
                strcpy( ((GeTrend *)dyn->elements)->attribute1, attr_name);
                strcpy( ((GeTrend *)dyn->elements)->timerange_attr, "$local.ScanTime##Float32");
                strcpy( ((GeTrend *)dyn->elements)->hold_attr, "$local.TrendHold##Boolean");
                grow_info_p = grow_info;
                for ( i = 0; i < grow_info_cnt; i++) {
                    if ( strcmp( grow_info_p->name, "NoOfPoints") == 0)
                        *(int *) grow_info_p->value_p = 200;
                    else if ( strcmp( grow_info_p->name, "HorizontalLines") == 0)
                        *(int *) grow_info_p->value_p = 0;
                    else if ( strcmp( grow_info_p->name, "VerticalLines") == 0)
                        *(int *) grow_info_p->value_p = 9;
                    else if ( strcmp( grow_info_p->name, "CurveColor1") == 0)
                        *(int *) grow_info_p->value_p = glow_eDrawType_CustomColor68;
                    else if ( strcmp( grow_info_p->name, "MaxValue1") == 0)
                        *(double *) grow_info_p->value_p = 1.2;
                    else if ( strcmp( grow_info_p->name, "MinValue1") == 0)
                        *(double *) grow_info_p->value_p = -0.1;

                    grow_info_p++;
                }
                grow_FreeObjectAttrInfo( grow_info);

                // This will configure the curves
                grow_SetTrendScanTime( trend, 0.5);

                grow_SetObjectOriginalFillColor( trend, glow_eDrawType_CustomColor66);
                grow_SetObjectOriginalBorderColor( trend, glow_eDrawType_CustomColor67);

                grow_GetTextExtent( graph->grow->ctx, name,
                                    strlen(name), glow_eDrawType_TextHelvetica,
                                    4, glow_eFont_LucidaSans, &z_width, &z_height, &z_descent);

                grow_CreateGrowText( graph->grow->ctx, "", name,
                                     x1 + trend_width + 1, y1 + trend_height/2 + z_height/2,
                                     glow_eDrawType_TextHelvetica, glow_eDrawType_CustomColor5, 4,
                                     glow_eFont_LucidaSans, glow_mDisplayLevel_1,
                                     NULL, &t1);
                if ( z_width > name_width)
                    name_width = z_width;

                trend_cnt++;
                y1 += trend_height;
                break;
            }
            default:
                ;
            }
            if ( trend_cnt >= MAX_TREND_OBJECTS)
                break;
        }

        ap++;
        is_attrp++;
    }
    free( alist);
    free( is_attr);

    // Draw separator lines between name texts
    y1 = y0;
    x1 = x0 + trend_width;
    grow_CreateGrowLine( graph->grow->ctx, "",
                         x0 + trend_width, y1, x0 + trend_width + name_width + 2, y1,
                         glow_eDrawType_CustomColor4, 1, 0, NULL, &l1);

    for ( i = 0; i < trend_cnt; i++) {
        y1 += trend_height;

        grow_CreateGrowLine( graph->grow->ctx, "",
                             x0 + trend_width, y1, x0 + trend_width + name_width + 2, y1,
                             glow_eDrawType_CustomColor4, 1, 0, NULL, &l1);
    }

    // Draw frame
    grow_CreateGrowRect( graph->grow->ctx, "R1", x0 - 1.5, y0 - 2.7,
                         trend_width + name_width + 5.5, 1, glow_eDrawType_CustomColor3,
                         1, 0, glow_mDisplayLevel_1, 1, 0, 0,
                         glow_eDrawType_CustomColor3, NULL, &l1);
    grow_CreateGrowRect( graph->grow->ctx, "R2", x0 - 1.5, y0 + trend_cnt * trend_height + 0.5,
                         trend_width + name_width + 5.5, 5, glow_eDrawType_CustomColor3,
                         1, 0, glow_mDisplayLevel_1, 1, 0, 0,
                         glow_eDrawType_CustomColor3, NULL, &l1);
    grow_CreateGrowRect( graph->grow->ctx, "R3", x0 + trend_width + name_width + 2, y0 - 1.7,
                         2, y0 + trend_cnt * trend_height + 0.9, glow_eDrawType_CustomColor3,
                         1, 0, glow_mDisplayLevel_1, 1, 0, 0,
                         glow_eDrawType_CustomColor3, NULL, &l1);
    grow_CreateGrowRect( graph->grow->ctx, "R4", x0 - 1.5, y0 - 1.7,
                         1, y0 + trend_cnt * trend_height + 0.9, glow_eDrawType_CustomColor3,
                         1, 0, glow_mDisplayLevel_1, 1, 0, 0,
                         glow_eDrawType_CustomColor3, NULL, &l1);

    grow_SetLayout( graph->grow->ctx, x0 - 1, y0 - 2.3, x0 + trend_width +
                    name_width + 3, y0 + trend_cnt * trend_height + 1.5);

    // Set graph attributes
    mask = grow_eAttr_double_buffer_on;
    grow_attr.double_buffer_on = 1;
    grow_SetAttributes( graph->grow->ctx, &grow_attr, mask);

    return 1;
}