Beispiel #1
0
/*************************************************************************
*
* Name:		goen_get_point_info_m7()
*
* Type		
*
* Type		Parameter	IOGF	Description
*    pwr_sGraphPlcNode	*graphbody	Pointer to objecttype data
*    unsigned long	point			Connection point nr
*    unsigned long 	*mask			Mask for drawing inputs/outputs
*    goen_conpoint_type	*info_pointer		Pointer to calculated data
*
* Description:
*	Calculates relativ koordinates for a connectionpoint and investigates
*	the connectionpoint type.
*
**************************************************************************/
int goen_get_point_info_m7( WGre *grectx, pwr_sGraphPlcNode *graphbody, 
			    unsigned long point, unsigned int *mask, 
			    unsigned long node_width, goen_conpoint_type *info_pointer, 
			    vldh_t_node node)
{
    int	inputpoints, outputpoints;
    unsigned long    pointmask;
    unsigned int     *inmask_pointer;
    unsigned int     *outmask_pointer;
    int 		inputs;
    int 		interns;
    int			outputs;
    double		ll_x,ll_y,ur_x,ur_y;


	/* Get number of parameters */
	inputs = graphbody->parameters[PAR_INPUT];
	interns = graphbody->parameters[PAR_INTERN];
	outputs = graphbody->parameters[PAR_OUTPUT];

	inmask_pointer = mask++;
	outmask_pointer = mask;

	/* Check if input in mask (first bit) */
	pointmask = 1;
	inputpoints = 0;
	inputpoints = ((*inmask_pointer & 1 || *inmask_pointer & 2) != 0);
	// inputpoints += ((*inmask_pointer & pointmask) != 0);

	/* Check if output in mask (first bit) */
	pointmask = 1;
	outputpoints = 0;
	outputpoints += ((*outmask_pointer & pointmask) != 0);
	
        flow_MeasureNode( node->hn.node_id, &ll_x, &ll_y, &ur_x, &ur_y);
        f_width = ur_x - ll_x;
 	f_height = ur_y - ll_y;

	f_width -= 2* GOEN_F_LINEWIDTH;
	f_height -= 2* GOEN_F_LINEWIDTH;
	if ( inputpoints > 0)
	  f_width -= f_pinlength;
	if ( outputpoints > 0)
	  f_width -= f_pinlength;

	if (( point == 0) && (inputpoints != 0))
	{
	   info_pointer->x =  - f_width/2.0
		-f_pinlength *( 1 - ( outputpoints == 0 ) * 0.5);
	   info_pointer->y = 0.0;
	   info_pointer->type = CON_LEFT;
	}
	if ((point == 1) || ((point == 0) && (inputpoints == 0)))
	{
	  info_pointer->x =  f_width/2.0
		+ f_pinlength *( 1 - ( inputpoints == 0 ) * 0.5);
	  info_pointer->y = 0.0;
	  info_pointer->type = CON_RIGHT;
	}
	return GOEN__SUCCESS;    
}
Beispiel #2
0
/*************************************************************************
*
* Name:		goen_get_point_info_m1()
*
* Type		
*
* Type		Parameter	IOGF	Description
*    pwr_sGraphPlcNode	*graphbody	Pointer to objecttype data
*    unsigned long	point			Connection point nr
*    unsigned long 	*mask			Mask for drawing inputs/outputs
*    goen_conpoint_type	*info_pointer		Pointer to calculated data
*
* Description:
*	Calculates relativ koordinates for a connectionpoint and investigates
*	the connectionpoint type.
*
**************************************************************************/
int goen_get_point_info_m1( WGre *grectx, pwr_sGraphPlcNode *graphbody, 
			    unsigned long point, unsigned int *mask, 
			    unsigned long node_width, goen_conpoint_type *info_pointer, 
			    vldh_t_node node)
{
    int  i;
    int	inputpoints, outputpoints;
    unsigned long    pointmask;
    unsigned int     *mask_pointer;
    int 		i_innr;
    int 		i_internnr;
    int			i_outnr;
    double		ll_x,ll_y,ur_x,ur_y;


	/* Get number of parameters */
	i_innr = graphbody->parameters[PAR_INPUT];
	i_internnr = graphbody->parameters[PAR_INTERN];
	i_outnr = graphbody->parameters[PAR_OUTPUT];

	/* Count number of inputpoints in mask  */
	mask_pointer = mask;
	pointmask = 1;
	inputpoints = 0;
	for ( i = 0; i < i_innr; i++)  
	{
	  inputpoints += ((*mask_pointer & pointmask) != 0);
	  pointmask <<= 1;
	}
	/* Count number of outputpoints in mask  */
	pointmask = 1;
	outputpoints = 0;
	mask_pointer++;
	for ( i = 0; i < i_outnr; i++)  
	{
	  outputpoints += ((*mask_pointer & pointmask) != 0);
	  pointmask <<= 1;
	}
	
	flow_MeasureNode( node->hn.node_id,
			  &ll_x,&ll_y,&ur_x,&ur_y);

	f_width = ur_x - ll_x - 2* GOEN_F_LINEWIDTH;
	f_height = ur_y - ll_y - 2* GOEN_F_LINEWIDTH;
	if ( inputpoints > 0)
	  f_width -= f_pinlength;
	if ( outputpoints > 0)
	  f_width -= f_pinlength;

	if ( (int)point < inputpoints )
	{
	   /* Connectionpoint is an input */
	   info_pointer->x =  - f_width/2.0
		-f_pinlength *( 1 - ( outputpoints == 0 ) * 0.5);
	   info_pointer->y =  f_height/2.0 - f_header/2 - point * f_repeat;
	   info_pointer->type = CON_LEFT;
	}
	else
	{
	   /* Connectionpoint is an output */
	   info_pointer->x =  f_width/2.0 + f_pinlength
		*( 1 - ( inputpoints == 0 ) * 0.5);
	   info_pointer->y =  f_height/2.0 - f_header/2 -
				 (point - inputpoints) * f_repeat;
	   info_pointer->type = CON_RIGHT;
	}
	return GOEN__SUCCESS;
}
Beispiel #3
0
/*************************************************************************
*
* Name:		int	trace_flow_cb()
*
* Type		int
*
* Type		Parameter	IOGF	Description
*
* Description:
*	Callback from flow.
**************************************************************************/
static int trace_flow_cb( FlowCtx *ctx, flow_tEvent event)
{
  WGre	*gre;
  vldh_t_node	source, dest;
  void		*vobject;
  double	ll_x, ll_y, ur_x, ur_y, width;
  int		subwindow_nr;
  int		sts;

  flow_GetCtxUserData( ctx, (void **)&gre);

  gre->search_rectangle_delete();

  if ( event->any.type == flow_eEventType_CreateCon)
  {
    if ( flow_GetNodeGroup( event->con_create.source_object) == 
		flow_eNodeGroup_Trace)
      return 1;
    flow_GetUserData( event->con_create.source_object, (void **) &source);
    if ( event->con_create.dest_object)
    {
      if ( flow_GetNodeGroup( event->con_create.dest_object) == 
		flow_eNodeGroup_Trace)
        return 1;
      flow_GetUserData( event->con_create.dest_object, (void **) &dest);
    }
    else
      dest = 0;
    (gre->gre_con_created) (gre, 
		event->con_create.x, event->con_create.y, 
		source, event->con_create.source_conpoint,
		dest, event->con_create.dest_conpoint, 0, &sts);	
  }
  switch ( event->event)
  {
    case flow_eEvent_Init:
      break;
    case flow_eEvent_MB2DoubleClick:
      switch ( event->object.object_type)
      {
        case flow_eObjectType_Node:
	  if ( flow_GetNodeGroup( event->object.object) == 
		flow_eNodeGroup_Trace)
	  {
	    flow_DeleteNodeCons( event->object.object);
	    flow_DeleteNode( event->object.object);
	  }
          break;
        default:
          ;
      }
      break;
    case flow_eEvent_MB1PressCtrl:
    {
      vldh_t_node	vnode;
      vldh_t_con	vcon;
      double		pos_x, pos_y;
      double		*x_arr, *y_arr;
      int		i, num;

      /* Object moved */
      switch ( event->object.object_type)
      {
        case flow_eObjectType_Node:
	  if ( flow_GetNodeGroup( event->object.object) == 
		flow_eNodeGroup_Trace)
	    break;
          flow_GetUserData( event->object.object, (void **) &vnode);
	  flow_GetNodePosition( event->object.object, &pos_x, &pos_y);
	  vnode->ln.x = pos_x;
	  vnode->ln.y = pos_y;
	  vldh_nodemodified( vnode);

	  (gre->gre_node_moved) (gre);
          break;
        case flow_eObjectType_Con:
	  if ( flow_GetConGroup( event->object.object) == 
		flow_eConGroup_Trace)
	    break;
          flow_GetUserData( event->object.object, (void **) &vcon);
	  flow_GetConPosition( event->object.object, &x_arr, &y_arr, &num);
	  for ( i = 0; i < num; i++)
	  {
	    vcon->lc.point[i].x = x_arr[i];
	    vcon->lc.point[i].y = y_arr[i];
	  }
	  vcon->lc.point_count = num;
	  vldh_conmodified( vcon);
          break;
        default:
          ;
      }
      break;
    }
    case flow_eEvent_MB1DoubleClick:
      /* Open attribute editor */
      switch ( event->object.object_type)
      {
        case flow_eObjectType_Node:
	  if ( flow_GetNodeGroup( event->object.object) == 
		flow_eNodeGroup_Trace)
	    break;
          gre->popupmenu_mode = GRE_POPUPMENUMODE_OBJECT;
          flow_GetUserData( event->object.object, &vobject);
	  (gre->gre_attribute) (gre, (vldh_t_node) vobject);
          break;
        default:
          ;
      }
      break;
    case flow_eEvent_MB1DoubleClickShift:
      /* Open subwindow */
      switch ( event->object.object_type)
      {
        case flow_eObjectType_Node:
	  if ( flow_GetNodeGroup( event->object.object) == 
		flow_eNodeGroup_Trace)
	    break;
	  gre->popupmenu_mode = GRE_POPUPMENUMODE_OBJECT;
	  flow_MeasureNode( event->object.object, &ll_x,&ll_y,&ur_x,&ur_y);
          width = ur_x - ll_x;
	  if ( event->object.x > ( ll_x + width / 2 ))	
	    subwindow_nr = 1;
	  else				
	    subwindow_nr = 2;
          flow_GetUserData( event->object.object, &vobject);
	  (gre->gre_subwindow) ( gre, (vldh_t_node)vobject, subwindow_nr);
          break;
        default:
          ;
      }
      break;
    case flow_eEvent_MB3Press:
    {
      /* Popup menu */
      int		x_pix, y_pix;
      vldh_t_node	current_node;
      flow_tObject	*select_list;
      int		select_cnt;

      if ( event->object.object_type != flow_eObjectType_Node)
        break;
      if ( flow_GetNodeGroup( event->object.object) == flow_eNodeGroup_Trace)
        break;

      flow_PositionToPixel( gre->flow_ctx, event->object.x,
			event->object.y, &x_pix, &y_pix); 
	  
      gre->get_popup_position( &x_pix, &y_pix);

      current_node = 0;

      /* If there is no selected object, select current object */
      if ( gre->popupmenu_mode == GRE_POPUPMENUMODE_OBJECT)
      {
        flow_GetSelectList( ctx, &select_list, &select_cnt);
        if ( !select_cnt)
        {
          if ( event->object.object_type == flow_eObjectType_Node)
            /* Get the current object */
            flow_GetUserData( event->object.object, (void **)&current_node);
        }	
      }

      (gre->gre_popupmenu) (gre, x_pix, y_pix, 
			gre->popupmenu_mode, current_node);
      break;
    }
    case flow_eEvent_MB1ClickCtrl:
    {
      char			help_title[32];
      vldh_t_node		node;
      vldh_t_con		con;
      int			size, sts;

      if ( event->object.object_type == flow_eObjectType_Node)
      {
	if ( flow_GetNodeGroup( event->object.object) == 
		flow_eNodeGroup_Trace)
	  break;
        flow_GetUserData( event->object.object, (void **)&node);
	sts = ldh_ObjidToName(
		(node->hn.wind)->hw.ldhses,
	         cdh_ClassIdToObjid( node->ln.cid), ldh_eName_Object,
		 help_title, sizeof( help_title), &size);
	WFoe::error_msg(sts);
	if ( EVEN(sts)) return 1;
	(gre->gre_help) ( gre, help_title);
      }
      if ( event->object.object_type == flow_eObjectType_Con)
      {
	if ( flow_GetConGroup( event->object.object) == 
		flow_eConGroup_Trace)
	  break;
        flow_GetUserData( event->object.object, (void **)&con);
	sts = ldh_ObjidToName( 
			(gre->wind)->hw.ldhses, 
	         	cdh_ClassIdToObjid( con->lc.cid), ldh_eName_Object,
		        help_title, sizeof( help_title), &size);
	WFoe::error_msg(sts);
	if ( EVEN(sts)) return 1;
	(gre->gre_help) ( gre, help_title);
      }
      break;
    }
    case flow_eEvent_MB1DoubleClickShiftCtrl:
    {
      trace_changevalue( gre, event->object.object);
      break;
    }
    default:
      ;
  }
  return 1;
}
Beispiel #4
0
/*************************************************************************
*
* Name:		goen_get_point_info_m15()
*
* Type		
*
* Type		Parameter	IOGF	Description
*    pwr_sGraphPlcNode	*graphbody	Pointer to objecttype data
*    unsigned long	point			Connection point nr
*    unsigned long 	*mask			Mask for drawing inputs/outputs
*    goen_conpoint_type	*info_pointer		Pointer to calculated data
*
* Description:
*	Calculates relativ koordinates for a connectionpoint and investigates
*	the connectionpoint type.
*
**************************************************************************/
int goen_get_point_info_m15( WGre *grectx, pwr_sGraphPlcNode *graphbody, 
			    unsigned long point, unsigned int *mask, 
			    unsigned long node_width, goen_conpoint_type *info_pointer, 
			    vldh_t_node node)
{
    	int	inputpoints, outputpoints;
    	unsigned long    pointmask;
	unsigned int    *inmask_pointer;
	unsigned int    *outmask_pointer;
        double		ll_x,ll_y,ur_x,ur_y;
	int		first_input, second_input;


	inmask_pointer = mask++;
	outmask_pointer = mask;

	/* Check if first input in mask (first bit) */
	pointmask = 1;
	first_input =  ((*inmask_pointer & pointmask) != 0);
	pointmask = 2;
	second_input = ((*inmask_pointer & pointmask) != 0);
	inputpoints = first_input + second_input;

	/* Check if output in mask (first bit) */
	pointmask = 1;
	outputpoints = 0;
	outputpoints += ((*outmask_pointer & pointmask) != 0);
	
        flow_MeasureNode( node->hn.node_id, &ll_x, &ll_y, &ur_x, &ur_y);
        f_width = ur_x - ll_x;
 	f_height = ur_y - ll_y;
	f_width -= 2* GOEN_F_LINEWIDTH;
	f_width -= f_pinlength * (( inputpoints != 0 ) + ( outputpoints != 0 ));
	f_height -= 2* GOEN_F_LINEWIDTH;

	if (( point == 0) && first_input)
	{
	   info_pointer->x =  - f_width/2.0
		-f_pinlength *( 1 - ( outputpoints == 0 ) * 0.5);
	   info_pointer->y = GOEN_F_GRID/2;
	   info_pointer->type = CON_LEFT;
	}
	if ((( point == 0) && ( !first_input && second_input)) ||
	    (( point == 1) && ( inputpoints == 2)))
	{
	   info_pointer->x =  - f_width/2.0
		-f_pinlength *( 1 - ( outputpoints == 0 ) * 0.5);
	   info_pointer->y = - GOEN_F_GRID/2;
	   info_pointer->type = CON_LEFT;
	}
	if (((point == 2) && (inputpoints == 2)) || 
	   ((point == 1) && (inputpoints == 1)) ||
	   ((point == 0) && (inputpoints == 0)))
	{
	  info_pointer->x =  f_width/2.0
		+ f_pinlength *( 1 - ( inputpoints == 0 ) * 0.5);
	  info_pointer->y = GOEN_F_GRID / 2;
	  info_pointer->type = CON_RIGHT;
	}
	return GOEN__SUCCESS;    
}
Beispiel #5
0
/*************************************************************************
*
* Name:		goen_get_point_info_m14()
*
* Type		
*
* Type		Parameter	IOGF	Description
*    pwr_sGraphPlcNode	*graphbody	Pointer to objecttype data
*    unsigned long	point			Connection point nr
*    unsigned long 	*mask			Mask for drawing inputs/outputs
*    goen_conpoint_type	*info_pointer		Pointer to calculated data
*
* Description:
*	Calculates relativ koordinates for a connectionpoint and investigates
*	the connectionpoint type.
*
**************************************************************************/
int goen_get_point_info_m14( WGre *grectx, pwr_sGraphPlcNode *graphbody, 
			    unsigned long point, unsigned int *mask, 
			    unsigned long node_width, goen_conpoint_type *info_pointer, 
			    vldh_t_node node)
{
    int  i;
    int	inputpoints, outputpoints;
    unsigned long    inpointmask;
    unsigned long    outpointmask;
    int			sts;
    double		ll_x,ll_y,ur_x,ur_y;
    int			rows;
    ldh_sParDef 	*bodydef;

    	/* Get the runtime paramters for this class */
	sts = ldh_GetObjectBodyDef( (node->hn.wind)->hw.ldhses, 
			node->ln.cid, "RtBody", 1, 
			&bodydef, &rows);
	if ( EVEN(sts) ) return sts;

	/* Count number of inputpoints and outputpoints in mask  */
	inpointmask = 1;
	outpointmask = 1;
	inputpoints = 0;
	outputpoints = 0;
	for ( i = 0; i < rows; i++)  
	{
          if ( bodydef[i].ParClass == pwr_eClass_Input)
	  {
	    inputpoints += ((*mask & inpointmask) != 0);
	    inpointmask <<= 1;
	  }
          if ( bodydef[i].ParClass == pwr_eClass_Output)
	  {
	    outputpoints += ((*(mask+1) & outpointmask) != 0);
	    outpointmask <<= 1;
	  }
	}

        flow_MeasureNode( node->hn.node_id, &ll_x, &ll_y, &ur_x, &ur_y);
        f_width = ur_x - ll_x;
 	f_height = ur_y - ll_y;

	f_width -= 2* GOEN_F_LINEWIDTH;
	f_height -= 2* GOEN_F_LINEWIDTH;
	if ( inputpoints > 0)
	  f_width -= f_pinlength;
	if ( outputpoints > 0)
	  f_width -= f_pinlength;

	if ( (int)point < inputpoints )
	{
	   /* Connectionpoint is an input */
	   info_pointer->x =  - f_width/2.0
		-f_pinlength *( 1 - ( outputpoints == 0 ) * 0.5);
	   info_pointer->y =  f_height/2.0 - (point + 1.5) * f_repeat;
	   info_pointer->type = CON_LEFT;
	}
	else
	{
	   /* Connectionpoint is an output */
	   info_pointer->x =  f_width/2.0 + f_pinlength
		*( 1 - ( inputpoints == 0 ) * 0.5);
	   info_pointer->y =  f_height/2.0 - 
		(point + 1.5 - inputpoints) * f_repeat;
	   info_pointer->type = CON_RIGHT;
	}
	free( (char *)bodydef);
	return GOEN__SUCCESS;
}