1 /*===========================================================================*/
2 /*                                                                           */
3 /* This file is part of the SYMPHONY MILP Solver Framework.                  */
4 /*                                                                           */
5 /* SYMPHONY was jointly developed by Ted Ralphs (ted@lehigh.edu) and         */
6 /* Laci Ladanyi (ladanyi@us.ibm.com).                                        */
7 /*                                                                           */
8 /* (c) Copyright 2000-2019 Ted Ralphs. All Rights Reserved.                  */
9 /*                                                                           */
10 /* This software is licensed under the Eclipse Public License. Please see    */
11 /* accompanying file for terms.                                              */
12 /*                                                                           */
13 /*===========================================================================*/
14 
15 #ifndef _INTERMEDIARY_H
16 #define _INTERMEDIARY_H
17 
18 #include <stdio.h>
19 
20 #include "sym_proto.h"
21 #include "sym_dg_params.h"
22 #include "sym_dg_u.h"
23 
24 #ifndef PIPE_ERROR
25 #define PIPE_ERROR {printf("PIPE_ERROR !!!!!!!!!!!"); }
26 #endif
27 
28 /*===========================================================================*/
29 
30 typedef struct WINDOW_DESCRIPTION{
31    int         canvas_width;
32    int         canvas_height;
33    int         viewable_width;
34    int         viewable_height;
35    int         disp_nodelabels;
36    int         disp_nodeweights;
37    int         disp_edgeweights;
38    char        node_dash[MAX_DASH_PATTERN_LENGTH +1];
39    char        edge_dash[MAX_DASH_PATTERN_LENGTH +1];
40    int         node_radius;
41    int         interactive_mode;
42    int         mouse_tracking;
43    double      scale_factor;
44    char        nodelabel_font[MAX_FONT_LENGTH +1];
45    char        nodeweight_font[MAX_FONT_LENGTH +1];
46    char        edgeweight_font[MAX_FONT_LENGTH +1];
47 }win_desc;
48 
49 /*===========================================================================*/
50 
51 typedef struct DG_NODE{
52    int     node_id;
53    int     posx;
54    int     posy;
55    int     radius;
56    char    deleted;   /* 1/0 */
57    char    label[MAX_LABEL_LENGTH +1]; /*watch out, terminating character
58 				      is a zero!*/
59    char    weight[MAX_WEIGHT_LENGTH +1];
60    char    dash[MAX_DASH_PATTERN_LENGTH +1];
61 }dg_node;
62 
63 /*===========================================================================*/
64 
65 typedef struct DG_EDGE{
66    int     edge_id;
67    int     tail;
68    int     head;
69    char    deleted;
70    char    weight[MAX_WEIGHT_LENGTH +1];
71    char    dash[MAX_DASH_PATTERN_LENGTH +1];
72 }dg_edge;
73 
74 /*===========================================================================*/
75 
76 typedef struct DG_GRAPH{
77    int         nodenum;
78    int         deleted_nodenum;
79    dg_node    *nodes;
80    int         edgenum;
81    int         deleted_edgenum;
82    dg_edge    *edges;
83 }dg_graph;
84 
85 /*===========================================================================*/
86 
87 typedef struct BUF_FIFO{
88    int        *bufid;
89    int         bufspace;
90    int         bufwrite;
91    int         bufread;
92 }buf_fifo;
93 
94 /*===========================================================================*/
95 
96 typedef struct WINDOW{
97    char        name[MAX_NAME_LENGTH +1];
98    unsigned int id;
99    void       *user;
100 
101    int         owner_tid;     /* tid of process that initiated this */
102    buf_fifo    buf;      /* structure to store buffer id's in a FIFO */
103    int         window_displayed;  /* T/F T if window is displayed */
104    int         wait_for_click;  /* 0:don't wait, 1:wait, no report,
105 				   2:wait and report */
106    win_desc    desc;
107    char        title[MAX_TITLE_LENGTH +1];
108    dg_graph    g;
109    int         copy_status; /*0:nothing, 1:waiting to be copied, 2:waiting to
110 			      get a copy. */
111    char        source[MAX_NAME_LENGTH +1]; /* set if copy_status=2 */
112    char        target[MAX_NAME_LENGTH +1]; /* set if copy_status=1 */
113 
114    int         text_length;
115    char       *text;
116 }window;
117 
118 /*===========================================================================*/
119 
120 typedef struct DRAW_GRAPH_PROBLEM{
121    void         *user;
122    int           master;
123    dg_params     par;
124    char          waiting_to_die;
125    unsigned int  next_id;
126    int           window_num;    /* the number of windows */
127    window      **windows;
128 
129    int           message_length;
130    char         *message;
131 }dg_prob;
132 
133 /*===========================================================================*/
134 
135 void INTERMED_ERROR PROTO((char *window_name, int old_msgtag,
136 			   int receiver, int msgtag));
137 int spprint PROTO((FILE *write_to, const char *format, ...));
138 
139 int start_child PROTO((char *cmd, FILE **readpipe, FILE **writepipe));
140 int find_window PROTO((int window_num, window **windows, char *name));
141 void read_node_desc_from_pvm PROTO((dg_node *nod, window *win));
142 void read_edge_desc_from_pvm PROTO((dg_edge *edg, window *win));
143 int find_node PROTO((int node_id, dg_graph *g));
144 int find_edge PROTO((int edge_id, dg_graph *g));
145 void compress_graph PROTO((dg_graph *g));
146 void copy_window_structure PROTO((window *target_win, window *source_win));
147 void display_graph_on_canvas PROTO((window *win, FILE *write_to));
148 void free_window PROTO((int *pwindow_num, window **windows, int i));
149 void copy_win_desc_from_par PROTO((window *win, dg_params *par));
150 void set_window_desc_pvm PROTO((int key, window *win));
151 void wait_for_you_can_die PROTO((dg_prob *dgp, FILE *write_to));
152 window *init_dgwin PROTO((dg_prob *dgp, int sender, char *name, char *title));
153 void add_msg PROTO((window *win, int bufid));
154 int get_next_msg PROTO((window *win));
155 
156 //FILE *fdopen PROTO((int, const char *));
157 
158 #endif
159