示例#1
0
int trace_start( WFoe *foe)
{
  static 	int gdh_initialized = 0;
  WGre 	*gre = foe->gre;
  int	  	sts;
  double 	f_width, f_height;

  if ( !gre->trace_started) {
    if ( !gdh_initialized) {
      sts = gdh_Init("wb_trace");
      if (EVEN(sts)) {
        foe->message( "Unable to attach to Proview runtime");
        WFoe::error_msg( sts); 
        return sts;
      }
    }

    gre->set_trace_attributes( 0);

    trace_trasetup( foe);

    flow_ResetHighlightAll( gre->flow_ctx);
    flow_SelectClear( gre->flow_ctx);
    sts = flow_TraceInit( gre->flow_ctx, trace_connect_bc, 
		trace_disconnect_bc, NULL);
    if ( EVEN(sts))
      return sts;


    gre->trace_start();

    /* Create node and con classes for trace */
    if ( !gre->trace_analyse_nc) {
      f_width = 4*GOEN_F_GRID;
      f_height = GOEN_F_GRID;
      flow_CreateNodeClass( gre->flow_ctx, "TraceNode", flow_eNodeGroup_Trace, 
		&gre->trace_analyse_nc);
      flow_AddRect( gre->trace_analyse_nc, 0, 0, f_width, f_height, 
		flow_eDrawType_Line, 1, flow_mDisplayLevel_1);
      flow_AddAnnot( gre->trace_analyse_nc, f_width/8, 0.7*f_height, 0,
		flow_eDrawType_TextHelvetica, 4, flow_eAnnotType_OneLine,
		flow_mDisplayLevel_1);
      flow_AddConPoint( gre->trace_analyse_nc, 0, 0.5*f_height, 0, 
		flow_eDirection_Left);
      flow_AddConPoint( gre->trace_analyse_nc, f_width, 0.5*f_height, 1,
		flow_eDirection_Right);

      flow_CreateConClass( gre->flow_ctx, "TraceCon", 
		flow_eConType_Straight, flow_eCorner_Right,
		flow_eDrawType_Line, 1, 0, 0, 0, flow_eConGroup_Trace,
		&gre->trace_con_cc);	  
    }
  }
  return TRA__SUCCESS;
}
示例#2
0
/*************************************************************************
 *
 * Name:		goen_create_contype()
 *
 * Type		int
 *
 * Type		Parameter	IOGF	Description
 * Widget	widget		I	neted widget.
 * unsigned long	conclass	I	connection class.
 * unsigned long	ldhses		I	ldh session.
 * goe_t_colors	*colors		I	array of loaded colors.
 * goe_t_fonts	*fonts		I	array of loaded fonts.
 * goen_t_cursors *cursors	I	array of loaded cursors.
 * unsigned long  *con_type_id	O	created neted connections type id.
 *
 * Description:
 *	Create a neted connection type.
 *	The attributes of the connection is described in grapbody in the 
 *	class object.
 *
 *	Parameters:
 *
 *    unsigned long 	con_type	index for where the connection type
 *					id is stored in the window object.
 *    int		arrows		no, one or two arrows.
 *    float		linewidth	widht of the connection line.
 *    float		dashes		length of dashes.
 *    int 		fillpattern	fillpattern for line.
 *    int		color		color.
 *    int		curvature	drawing method for the connection.
 *    float		corners		radius of corners.
 *
 *	Values:
 *
 *    arrows:
 *	GOEN_ARROW_NONE	0		No arrow
 *	GOEN_ARROW_END	1		One arrow at end of connection
 *	GOEN_ARROW_BOTH	2		Two arrows
 *    fillpattern:
 *	GOEN_UNFILL	0		No fillpattern	
 *	GOEN_FILL1	1		Some fillpattern...
 *    color:
 *	GOE_K_BLACK	0		black
 *	GOE_K_BLUE      1		blue
 *	GOE_K_RED	2		red
 *	GOE_K_GREEN     3		greem
 *    curvature:
 *	GOEN_ROUTECON	0		Routed connection
 *	GOEN_JAGGED	1		Streight line connection
 *	GOEN_RECTILINEAR 2		Rectilinear connectionstyle
 *	GOEN_STRANSDIV 	3		Simultaneus transition divergence
 *	GOEN_STRANSCONV 4		Simultaneus transition convergence
 *	GOEN_STEPDIV 	5		Step divergence
 *	GOEN_STEPCONV 	6		Step convergence
 *
 **************************************************************************/
int goen_create_contype(
			flow_tCtx	        ctx,
			pwr_tClassId	conclass,
			ldh_tSesContext	ldhses,
			flow_tConClass      *con_class
			)
{
  pwr_tClassId			bodyclass;
  pwr_sGraphPlcConnection 	*graphbody;
  int				sts, size;
  char				name[80];
  flow_eDrawType			line_type;
  flow_eConType			con_type;
  int				line_width;
  double				arrow_width = 0;
  double				arrow_length = 0;
  double				round_corner_amount;
  flow_eCorner			corner_type;

  if ( conclass == 0) {
    /* Fix for syref connections */
    flow_CreateConClass(ctx, "RefCon", 
			flow_eConType_Reference, flow_eCorner_Right,
			flow_eDrawType_Line, 2, 0, 0, 0, flow_eConGroup_Common,
			con_class);
    return 1;
  }
  /* Get graphbody for the class */
  sts = ldh_GetClassBody(ldhses, conclass, "GraphPlcCon", 
			 &bodyclass, (char **)&graphbody, &size);
  if( EVEN(sts) ) return sts;

  sts = ldh_ClassIdToName( ldhses, conclass, name, sizeof(name), &size);
  if( EVEN(sts) ) return sts;

  if (graphbody->arrows != 0) {
    con_type = flow_eConType_StraightOneArrow;
    arrow_width = 0.03;
    arrow_length = 0.045;
  }
  else if ( graphbody->curvature == GOEN_ROUTECON ||
	    graphbody->curvature == GOEN_RECTILINEAR)
    con_type = flow_eConType_Routed;
  else if ( graphbody->curvature == GOEN_STRANSDIV)
    con_type = flow_eConType_TransDiv;
  else if ( graphbody->curvature == GOEN_STRANSCONV)
    con_type = flow_eConType_TransConv;
  else if ( graphbody->curvature == GOEN_STEPDIV)
    con_type = flow_eConType_StepDiv;
  else if ( graphbody->curvature == GOEN_STEPCONV)
    con_type = flow_eConType_StepConv;
  else if ( graphbody->curvature == GOEN_JAGGED)
    con_type = flow_eConType_Straight;
  else
    con_type = flow_eConType_Straight;

  line_width = (int)(graphbody->linewidth * 400 + 0.5);
  if ( graphbody->dashes > 0)
    line_type = flow_eDrawType_LineDashed;
  else if ( graphbody->fillpattern > 0)
    line_type = flow_eDrawType_LineGray;
  else
    line_type = flow_eDrawType_Line;
	
  if ( graphbody->corners > 0.0) {
    corner_type = flow_eCorner_Rounded;
    round_corner_amount = 0.025;
  }
  else {
    corner_type = flow_eCorner_Right;
    round_corner_amount = 0;
  }

  flow_CreateConClass(ctx, name,
		      con_type, corner_type, 
		      line_type, line_width, arrow_width, arrow_length, 
		      round_corner_amount, flow_eConGroup_Common,
		      con_class);
  return GOEN__SUCCESS;
}