home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume17 / xtexcad1 / part07 < prev    next >
Encoding:
Text File  |  1992-04-20  |  50.2 KB  |  2,181 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!zaphod.mps.ohio-state.edu!mips!msi!dcmartin
  3. From: Fritz Haubensak <hsk@informatik.uni-wuerzburg.de>
  4. Subject: v17i071: TeXcad (X) version 1.2, Part07/10
  5. Message-ID: <1992Apr21.131401.2475@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Nntp-Posting-Host: fascet
  9. Organization: Molecular Simulations, Inc.
  10. References: <csx-17i065-xtexcad-1.2@uunet.UU.NET>
  11. Date: Tue, 21 Apr 1992 13:14:01 GMT
  12. Approved: dcmartin@msi.com
  13. Lines: 2166
  14.  
  15. Submitted-by: Fritz Haubensak <hsk@informatik.uni-wuerzburg.de>
  16. Posting-number: Volume 17, Issue 71
  17. Archive-name: xtexcad-1.2/part07
  18.  
  19. # this is part.07 (part 7 of a multipart archive)
  20. # do not concatenate these parts, unpack them in order with /bin/sh
  21. # file oberfl.c continued
  22. #
  23. if test ! -r _shar_seq_.tmp; then
  24.     echo 'Please unpack part 1 first!'
  25.     exit 1
  26. fi
  27. (read Scheck
  28.  if test "$Scheck" != 7; then
  29.     echo Please unpack part "$Scheck" next!
  30.     exit 1
  31.  else
  32.     exit 0
  33.  fi
  34. ) < _shar_seq_.tmp || exit 1
  35. if test ! -f _shar_wnt_.tmp; then
  36.     echo 'x - still skipping oberfl.c'
  37. else
  38. echo 'x - continuing file oberfl.c'
  39. sed 's/^X//' << 'SHAR_EOF' >> 'oberfl.c' &&
  40. X    XtSetArg(args[n], XtNwidth, 140);
  41. X    n++;
  42. X    XtSetArg(args[n], XtNjustify, XtJustifyCenter);
  43. X    n++;
  44. X    XtSetArg(args[n], XtNshapeStyle, XmuShapeOval);
  45. X    n++;
  46. X    XtSetArg(args[n], XtNstate, False);
  47. X    n++;
  48. X    
  49. X    din = XtCreateManagedWidget("page", toggleWidgetClass, dummy1, args, n);
  50. X    XtAddCallback(din, XtNcallback, full_dina4, NULL);
  51. X
  52. X    n = 0;
  53. X
  54. X    XtSetArg(args[n], XtNlabel, "enable ruler");
  55. X    n++;
  56. X    XtSetArg(args[n], XtNheight, 30);
  57. X    n++;
  58. X    XtSetArg(args[n], XtNwidth, 140);
  59. X    n++;
  60. X    XtSetArg(args[n], XtNjustify, XtJustifyCenter);
  61. X    n++;
  62. X    XtSetArg(args[n], XtNshapeStyle, XmuShapeOval);
  63. X    n++;
  64. X    XtSetArg(args[n], XtNstate, True);
  65. X    n++;
  66. X    
  67. X    rul = XtCreateManagedWidget("lineal", toggleWidgetClass, dummy1, args, n);
  68. X    XtAddCallback(rul, XtNcallback, ruler_switch, NULL);
  69. X
  70. X    n = 0;
  71. X
  72. X    XtSetArg(args[n], XtNlabel, "cross wire");
  73. X    n++;
  74. X    XtSetArg(args[n], XtNheight, 30);
  75. X    n++;
  76. X    XtSetArg(args[n], XtNwidth, 140);
  77. X    n++;
  78. X    XtSetArg(args[n], XtNjustify, XtJustifyCenter);
  79. X    n++;
  80. X    XtSetArg(args[n], XtNshapeStyle, XmuShapeOval);
  81. X    n++;
  82. X    XtSetArg(args[n], XtNstate, False);
  83. X    n++;
  84. X    
  85. X    cross_curs = XtCreateManagedWidget("cross", toggleWidgetClass, dummy1, args, n);
  86. X    XtAddCallback(cross_curs, XtNcallback, cross_switch, NULL);
  87. X
  88. X    n = 0;
  89. X
  90. X    XtSetArg(args[n], XtNlabel, "watch line length");
  91. X    n++;
  92. X    XtSetArg(args[n], XtNheight, 30);
  93. X    n++;
  94. X    XtSetArg(args[n], XtNwidth, 140);
  95. X    n++;
  96. X    XtSetArg(args[n], XtNjustify, XtJustifyCenter);
  97. X    n++;
  98. X    XtSetArg(args[n], XtNshapeStyle, XmuShapeOval);
  99. X    n++;
  100. X    XtSetArg(args[n], XtNstate, False);
  101. X    n++;
  102. X    
  103. X    length_line = XtCreateManagedWidget("llline", toggleWidgetClass, dummy1, args, n);
  104. X    XtAddCallback(length_line, XtNcallback, l_length_switch, NULL);
  105. X    line_length = 0;
  106. X
  107. X    /* add action to translation manager */
  108. X    XtAddActions(actions, XtNumber(actions));
  109. X    XtOverrideTranslations(radio_up, trans_table1);
  110. X    XtOverrideTranslations(raster1, trans_table2);
  111. X    XtOverrideTranslations(snap1, trans_table2);
  112. X    XtOverrideTranslations(slp, trans_table2);
  113. X    XtOverrideTranslations(dias, trans_table2);
  114. X    XtOverrideTranslations(read_number, trans_table);
  115. X
  116. }
  117. /*-----------------------------------------------------------*/
  118. X
  119. void
  120. print_msg(Widget text_widget, char *msg)
  121. {
  122. X    /* prints messages into the welcome and report widget */
  123. X
  124. X    XawTextPosition text_pos;
  125. X    int             result;
  126. X    XawTextBlock    text_block;
  127. X
  128. X
  129. X    /* get current position of Cursor */
  130. X    text_pos = XawTextGetInsertionPoint(text_widget);
  131. X
  132. X
  133. X    /* text_block init. */
  134. X    text_block.firstPos = 0;
  135. X    text_block.length = strlen(msg);
  136. X    text_block.ptr = msg;
  137. X    text_block.format = FMT8BIT;
  138. X
  139. X    XawTextReplace(text_widget, text_pos, text_pos, &text_block);
  140. X
  141. X    /* display text */
  142. X    XawTextDisplay(text_widget);
  143. }
  144. SHAR_EOF
  145. echo 'File oberfl.c is complete' &&
  146. chmod 0644 oberfl.c ||
  147. echo 'restore of oberfl.c failed'
  148. Wc_c="`wc -c < 'oberfl.c'`"
  149. test 37008 -eq "$Wc_c" ||
  150.     echo 'oberfl.c: original size 37008, current size' "$Wc_c"
  151. rm -f _shar_wnt_.tmp
  152. fi
  153. # ============= oberfl.h ==============
  154. if test -f 'oberfl.h' -a X"$1" != X"-c"; then
  155.     echo 'x - skipping oberfl.h (File already exists)'
  156.     rm -f _shar_wnt_.tmp
  157. else
  158. > _shar_wnt_.tmp
  159. echo 'x - extracting oberfl.h (Text)'
  160. sed 's/^X//' << 'SHAR_EOF' > 'oberfl.h' &&
  161. /* xtexcad  V1.2 - graphic editor for LaTeX */
  162. /* 1991 by K.Zitzmann */
  163. /* header-file oberfl.h */
  164. X
  165. X
  166. #ifndef OBERFLH
  167. #define OBERFLH
  168. X
  169. X
  170. X
  171. /* prototypes */
  172. X
  173. X
  174. void popup_init(void);
  175. void paintboard(void);
  176. void textup_init(void);
  177. void print_msg(Widget w, char *msg); /* display message in textwidget */
  178. void radio_init(void);
  179. void command_init(void);
  180. void headline(Widget w, char *txt);
  181. X
  182. X
  183. X
  184. /* constant */
  185. X
  186. X extern const Dimension cmd_btn_width;
  187. X extern const Dimension cmd_btn_height;
  188. X extern const vertical_distance,new_section;
  189. X
  190. X extern const yorigin;
  191. X
  192. X #define xorigin (cmd_btn_width+2*new_section)
  193. X extern const y_A4_max;
  194. X extern const y_A4_min;
  195. X extern const x_A4_max;
  196. X extern const x_A4_min;
  197. X
  198. /* global variables */ 
  199. X
  200. X extern Widget toplevel,canvas,pboard,textup,wtext,input_up,get_up,box_me_up;
  201. X extern Widget line_cmd,box_cmd,circle_cmd,text_cmd,file_cmd;
  202. X extern Widget vector_cmd,zoom_cmd,refresh_cmd,erase_cmd,edit_cmd,options_cmd;
  203. X extern Widget snap1,raster1,radio_up,slp,dias;
  204. X extern Widget txt2,txt3,raster_up,ask_up,sign_up,sign_msg;
  205. X extern Widget coordinates,about,pop_adjust_up,adj_txt2,fileselector,bezier_cmd;
  206. X extern Widget lft,rgt,up,dwn,zentr;
  207. X
  208. X extern Arg args[10]; 
  209. X extern int n,m;
  210. X
  211. X extern Boolean snap, raster; /* radio-button-options */
  212. X extern Boolean zoomed,steigung,durchmesser,refr_auto,dina4;
  213. X extern Boolean ruler,cross;
  214. X
  215. X extern char graph_action,shadow; /* current action : 'L'=line etc. */
  216. X
  217. X extern char filename[100];
  218. X extern char chain[100];
  219. X extern char titlename[200];
  220. X extern char boxinput[256];
  221. X extern char textinput[256];
  222. X extern char txtpos[3];
  223. X extern float xur,yur;
  224. X extern GC gc,copy_gc; /* Graphic Context ID */
  225. X
  226. X extern Pixmap about_map;
  227. X /* Figure Data Base */
  228. X extern struct fig1 {
  229. X    float x,y,h,v;
  230. X    struct fig1 *next;
  231. X    } oval;
  232. X
  233. X extern struct fig2 {
  234. X    float x,y,h,v;
  235. X    struct fig2 *next;
  236. X    int radius;
  237. X    } filledBox,strich,pfeil,disc,kreis;
  238. X
  239. X extern struct fig3 {
  240. X    float x,y,h,v;
  241. X    char *text;
  242. X    char textpos[2];
  243. X    struct fig3 *next;
  244. X    } framedBox;
  245. X
  246. X extern struct fig4 {
  247. X    float x,y,h,v;
  248. X    char *text;
  249. X    char textpos[2];
  250. X    float dashlength;
  251. X    struct fig4 *next;
  252. X    } dashedBox;
  253. X
  254. X extern struct fig5 {
  255. X    float x,y;
  256. X    char *text;
  257. X    char textpos[2]; /* for the makebox-command */
  258. X    struct fig5 *next;
  259. X    } message;
  260. X
  261. X extern struct fig6 {
  262. X     float ax,ay; /* startpoint */
  263. X     float ex,ey; /* endpoint */
  264. X     float sx,sy; /* controlpoint */
  265. X    struct fig6 *next;
  266. X     } bezier;
  267. X
  268. X /* box,oval: first coordinates must be the upper left corner */
  269. X /* circle: x,y determine the middlepoint, h,v are useless after creating object */
  270. X
  271. X extern struct fig2 *disc_start, *disc_curr, *disc_marker;
  272. X extern struct fig2 *kreis_start, *kreis_curr, *kreis_marker;
  273. X extern struct fig2 *filledBox_start, *filledBox_curr, *filledBox_marker;
  274. X extern struct fig1 *oval_start, *oval_curr, *oval_marker;
  275. X extern struct fig2 *strich_start, *strich_curr, *strich_marker;
  276. X extern struct fig2 *pfeil_start, *pfeil_curr, *pfeil_marker;
  277. X extern struct fig3 *framedBox_start, *framedBox_curr, *framedBox_marker;
  278. X extern struct fig4 *dashedBox_start, *dashedBox_curr, *dashedBox_marker;
  279. X extern struct fig5 *message_start, *message_curr, *message_marker;
  280. X extern struct fig6 *bezier_start, *bezier_curr, *bezier_marker;
  281. X
  282. X
  283. X extern int x_zoom_max;
  284. X extern int x_zoom_min;
  285. X extern int y_zoom_max;
  286. X extern int y_zoom_min;
  287. X
  288. X extern int xmotion;
  289. X extern int ymotion;
  290. X
  291. X /* user data */
  292. extern char    aa;
  293. extern char    bb;
  294. extern char    cc;
  295. extern char    dd;
  296. extern char    ee;
  297. extern char    ff;
  298. extern char    gg;
  299. extern char    hh;
  300. extern char    ii;
  301. extern char    jj;
  302. extern char    kk;
  303. extern char    ll;
  304. extern char    mm;
  305. extern char    nn;
  306. extern char    oo;
  307. extern char    pp;
  308. extern char    qq;
  309. extern char    rr;
  310. extern char    ss;
  311. extern char    tt;
  312. extern char    uu;
  313. extern char    vv;
  314. extern char    ww;
  315. extern char    xx;
  316. extern char    yy;
  317. extern char    zz;
  318. extern char     point;
  319. extern char     DUMMY;
  320. extern char    minus;
  321. extern char    ka;
  322. extern char    kb;
  323. extern char    kc;
  324. extern char    kd;
  325. extern char    ke;
  326. extern char    kf;
  327. extern char    kg;
  328. extern char    kh;
  329. extern char    ki;
  330. extern char    kj;
  331. extern char    klein_k;
  332. extern char    kl;
  333. extern char    km;
  334. extern char    kn;
  335. extern char    ko;
  336. extern char    kp;
  337. extern char    kq;
  338. extern char    kr;
  339. extern char    ks;
  340. extern char    kt;
  341. extern char    ku;
  342. extern char    kv;
  343. extern char    kw;
  344. extern char    kx;
  345. extern char    ky;
  346. extern char    kz;
  347. X
  348. #endif
  349. SHAR_EOF
  350. chmod 0644 oberfl.h ||
  351. echo 'restore of oberfl.h failed'
  352. Wc_c="`wc -c < 'oberfl.h'`"
  353. test 4292 -eq "$Wc_c" ||
  354.     echo 'oberfl.h: original size 4292, current size' "$Wc_c"
  355. rm -f _shar_wnt_.tmp
  356. fi
  357. # ============= patchlevel.h ==============
  358. if test -f 'patchlevel.h' -a X"$1" != X"-c"; then
  359.     echo 'x - skipping patchlevel.h (File already exists)'
  360.     rm -f _shar_wnt_.tmp
  361. else
  362. > _shar_wnt_.tmp
  363. echo 'x - extracting patchlevel.h (Text)'
  364. sed 's/^X//' << 'SHAR_EOF' > 'patchlevel.h' &&
  365. /* xtexcad  V1.2 - graphic editor for LaTeX */
  366. /* 1991 by K.Zitzmann */
  367. /* patchlevel.h */
  368. X
  369. #define PATCHLEVEL 0.0
  370. X
  371. SHAR_EOF
  372. chmod 0644 patchlevel.h ||
  373. echo 'restore of patchlevel.h failed'
  374. Wc_c="`wc -c < 'patchlevel.h'`"
  375. test 116 -eq "$Wc_c" ||
  376.     echo 'patchlevel.h: original size 116, current size' "$Wc_c"
  377. rm -f _shar_wnt_.tmp
  378. fi
  379. # ============= pickedit.c ==============
  380. if test -f 'pickedit.c' -a X"$1" != X"-c"; then
  381.     echo 'x - skipping pickedit.c (File already exists)'
  382.     rm -f _shar_wnt_.tmp
  383. else
  384. > _shar_wnt_.tmp
  385. echo 'x - extracting pickedit.c (Text)'
  386. sed 's/^X//' << 'SHAR_EOF' > 'pickedit.c' &&
  387. /* xtexcad  V1.1 - graphic editor for LaTeX */
  388. /* 1991 by K.Zitzmann */
  389. /* pickedit.c */
  390. X
  391. #include "x_stuff.h"
  392. #include "oberfl.h"
  393. #include "ereignis.h"
  394. #include "graphics.h"
  395. #include "pickedit.h"
  396. #include <math.h>
  397. X
  398. X
  399. X
  400. /* this data-structure contains the best matching objects which are */
  401. /* found during a pick-action... */
  402. X
  403. #define sumobj 5
  404. X
  405. int             maxobj = 5;
  406. X
  407. char            kind[sumobj];    /* the object type: 'L'=line, 'V'=vector,
  408. X                 * 'N'=framedBox etc */
  409. int             distance[sumobj];    /* the distance to the selected point
  410. X                     * on the screen */
  411. void           *obj[sumobj];    /* pointer to the current element in kind[] */
  412. int             tip;
  413. X
  414. int             x_pick, y_pick, currIndex;
  415. /* currIndex is THE index which points ALWAYS to the current object */
  416. X
  417. int             points = 10;    /* radius for edit circle */
  418. /* ----------------------------------- */
  419. /*
  420. X * interface to application is : set_pick_stack(x,y) and nextObject()  and
  421. X * currIndex
  422. X */
  423. X
  424. X
  425. void
  426. init_pick()
  427. {
  428. X    int             i;
  429. X    for (i = 0; i <= maxobj; i++)
  430. X    {
  431. X        kind[i] = '-';
  432. X        distance[i] = 9999;
  433. X        obj[i] = NULL;
  434. X    }
  435. X
  436. X    tip = 0;
  437. X    currIndex = 0;
  438. }
  439. X
  440. X
  441. int
  442. nextObject()
  443. {
  444. X    /* returns -1 if there is no object & otherwise the index */
  445. X    /* of the object in the global data-stucture */
  446. X
  447. X    if (kind[tip] == '-')
  448. X        return -1;    /* no object */
  449. X
  450. X    if (tip <= maxobj)
  451. X        tip++;
  452. X    else
  453. X        return -1;
  454. X
  455. X    currIndex = tip - 1;
  456. X
  457. X    return currIndex;
  458. }
  459. X
  460. X
  461. X
  462. void
  463. set_pick_stack(int x, int y)
  464. {
  465. X    /* fills the stack with matching objects */
  466. X    int             d, res;
  467. X    float           h, v;
  468. X    init_pick();
  469. X
  470. X    if (zoomed == True)
  471. X    {
  472. X        h = (float) x;
  473. X        v = (float) y;
  474. X        zoomed2real(&h, &v);
  475. X        x = h;
  476. X        y = v;
  477. X    }
  478. X    /* bezier */
  479. X    if (bezier_start != NULL)
  480. X    {    /* there is min. 1 entry */
  481. X        bezier_marker = bezier_start;
  482. X        res = analyse_bezier(bezier_marker, &d, x, y);
  483. X        if (res == 1)
  484. X            insert_object(bezier_marker, d, ii);
  485. X
  486. X        if (bezier_marker != bezier_curr)
  487. X        {
  488. X            do
  489. X            {
  490. X                bezier_marker = bezier_marker->next;
  491. X                res = analyse_bezier(bezier_marker, &d, x, y);
  492. X                if (res == 1)
  493. X                    insert_object(bezier_marker, d, ii);
  494. X            } while (bezier_marker != bezier_curr);
  495. X        }
  496. X    }
  497. X    /* line */
  498. X    if (strich_start != NULL)
  499. X    {    /* there is min. 1 entry */
  500. X        strich_marker = strich_start;
  501. X        res = analyse_pin(strich_marker, &d, x, y);
  502. X        if (res == 1)
  503. X            insert_object(strich_marker, d, ll);
  504. X
  505. X        if (strich_marker != strich_curr)
  506. X        {
  507. X            do
  508. X            {
  509. X                strich_marker = strich_marker->next;
  510. X                res = analyse_pin(strich_marker, &d, x, y);
  511. X                if (res == 1)
  512. X                    insert_object(strich_marker, d, ll);
  513. X            } while (strich_marker != strich_curr);
  514. X        }
  515. X    }
  516. X    /* vector */
  517. X    if (pfeil_start != NULL)
  518. X    {    /* there is min. 1 entry */
  519. X        pfeil_marker = pfeil_start;
  520. X        res = analyse_pin(pfeil_marker, &d, x, y);
  521. X        if (res == 1)
  522. X            insert_object(pfeil_marker, d, vv);
  523. X
  524. X        if (pfeil_marker != pfeil_curr)
  525. X        {
  526. X            do
  527. X            {
  528. X                pfeil_marker = pfeil_marker->next;
  529. X                res = analyse_pin(pfeil_marker, &d, x, y);
  530. X                if (res == 1)
  531. X                    insert_object(pfeil_marker, d, vv);
  532. X            } while (pfeil_marker != pfeil_curr);
  533. X        }
  534. X    }
  535. X    /* framedBox */
  536. X    if (framedBox_start != NULL)
  537. X    {    /* there is min. 1 entry */
  538. X        framedBox_marker = framedBox_start;
  539. X        res = analyse_nbox(framedBox_marker, &d, x, y);
  540. X        if (res == 1)
  541. X            insert_object(framedBox_marker, d, nn);
  542. X
  543. X        if (framedBox_marker != framedBox_curr)
  544. X        {
  545. X            do
  546. X            {
  547. X                framedBox_marker = framedBox_marker->next;
  548. X                res = analyse_nbox(framedBox_marker, &d, x, y);
  549. X                if (res == 1)
  550. X                    insert_object(framedBox_marker, d, nn);
  551. X            } while (framedBox_marker != framedBox_curr);
  552. X        }
  553. X    }
  554. X    /* dashedBox */
  555. X    if (dashedBox_start != NULL)
  556. X    {    /* there is min. 1 entry */
  557. X        dashedBox_marker = dashedBox_start;
  558. X        res = analyse_dbox(dashedBox_marker, &d, x, y);
  559. X        if (res == 1)
  560. X            insert_object(dashedBox_marker, d, dd);
  561. X
  562. X        if (dashedBox_marker != dashedBox_curr)
  563. X        {
  564. X            do
  565. X            {
  566. X                dashedBox_marker = dashedBox_marker->next;
  567. X                res = analyse_dbox(dashedBox_marker, &d, x, y);
  568. X                if (res == 1)
  569. X                    insert_object(dashedBox_marker, d, dd);
  570. X            } while (dashedBox_marker != dashedBox_curr);
  571. X        }
  572. X    }
  573. X    /* filledBox */
  574. X    if (filledBox_start != NULL)
  575. X    {    /* there is min. 1 entry */
  576. X        filledBox_marker = filledBox_start;
  577. X        res = analyse_fbox(filledBox_marker, &d, x, y);
  578. X        if (res == 1)
  579. X            insert_object(filledBox_marker, d, ff);
  580. X
  581. X
  582. X
  583. X        if (filledBox_marker != filledBox_curr)
  584. X        {
  585. X            do
  586. X            {
  587. X                filledBox_marker = filledBox_marker->next;
  588. X                res = analyse_fbox(filledBox_marker, &d, x, y);
  589. X                if (res == 1)
  590. X                    insert_object(filledBox_marker, d, ff);
  591. X            } while (filledBox_marker != filledBox_curr);
  592. X        }
  593. X    }
  594. X    /* normal circle */
  595. X    if (kreis_start != NULL)
  596. X    {    /* there is min. 1 entry */
  597. X        kreis_marker = kreis_start;
  598. X        res = analyse_ncircle(kreis_marker, &d, x, y);
  599. X        if (res == 1)
  600. X            insert_object(kreis_marker, d, cc);
  601. X
  602. X        if (kreis_marker != kreis_curr)
  603. X        {
  604. X            do
  605. X            {
  606. X                kreis_marker = kreis_marker->next;
  607. X                res = analyse_ncircle(kreis_marker, &d, x, y);
  608. X                if (res == 1)
  609. X                    insert_object(kreis_marker, d, cc);
  610. X            } while (kreis_marker != kreis_curr);
  611. X        }
  612. X    }
  613. X    /* filled circle */
  614. X    if (disc_start != NULL)
  615. X    {    /* there is min. 1 entry */
  616. X        disc_marker = disc_start;
  617. X        res = analyse_fcircle(disc_marker, &d, x, y);
  618. X        if (res == 1)
  619. X            insert_object(disc_marker, d, bb);
  620. X
  621. X        if (disc_marker != disc_curr)
  622. X        {
  623. X            do
  624. X            {
  625. X                disc_marker = disc_marker->next;
  626. X                res = analyse_fcircle(disc_marker, &d, x, y);
  627. X                if (res == 1)
  628. X                    insert_object(disc_marker, d, bb);
  629. X            } while (disc_marker != disc_curr);
  630. X        }
  631. X    }
  632. X    /* oval */
  633. X    if (oval_start != NULL)
  634. X    {    /* there is min. 1 entry */
  635. X        oval_marker = oval_start;
  636. X        res = analyse_ocircle(oval_marker, &d, x, y);
  637. X        if (res == 1)
  638. X            insert_object(oval_marker, d, oo);
  639. X
  640. X        if (oval_marker != oval_curr)
  641. X        {
  642. X            do
  643. X            {
  644. X                oval_marker = oval_marker->next;
  645. X                res = analyse_ocircle(oval_marker, &d, x, y);
  646. X                if (res == 1)
  647. X                    insert_object(oval_marker, d, oo);
  648. X            } while (oval_marker != oval_curr);
  649. X        }
  650. X    }
  651. }
  652. X
  653. X
  654. void
  655. insert_object(void *p, int d, char c)
  656. {
  657. X    int             i, k;
  658. X    /*
  659. X     * operations performed on global data-structure :
  660. X     * 
  661. X     * 
  662. X    /* compute insert-position
  663. X     */
  664. X    for (i = 0; (distance[i] < d) && (i != maxobj); i++);
  665. X
  666. X    if (i == maxobj)
  667. X        return;    /* the distance was too far; there are better objects */
  668. X
  669. X    /* move elements */
  670. X    for (k = (maxobj - 1); k > i; k--)
  671. X    {
  672. X        kind[k] = kind[k - 1];
  673. X        distance[k] = distance[k - 1];
  674. X        obj[k] = obj[k - 1];
  675. X    }
  676. X
  677. X    /* the new entry */
  678. X    kind[i] = c;
  679. X    distance[i] = d;
  680. X    obj[i] = p;
  681. X
  682. X    /* fin */
  683. X
  684. }
  685. X
  686. X
  687. /* function int analyse_xxxxxx() : */
  688. /* returns wether the object is a possible pick(1) or not(0) */
  689. /* p points to the object; d returns the distance to the object */
  690. /* xpos,ypos reference the pick position of the pointer */
  691. X
  692. X
  693. int analyse_bezier(struct fig6 *p, int *d, int xpos, int ypos)
  694. {
  695. X    int cmpdiff=9999;
  696. X    int diff;
  697. X    int x,y;
  698. X    float u;
  699. X    int zone=20;
  700. X    
  701. X    for (u=0; u<=1; u+=0.1)
  702. X    {
  703. X        x=(int)(p->ax*(1-u)*(1-u)+p->sx*(1-u)*2*u+p->ex*u*u);
  704. X            y=(int)(p->ay*(1-u)*(1-u)+p->sy*(1-u)*2*u+p->ey*u*u);
  705. X
  706. X        diff=calc_distance(x,y,xpos,ypos);
  707. X        
  708. X        cmpdiff=(cmpdiff<diff) ? cmpdiff : diff;
  709. X    }
  710. X
  711. X    (*d)= cmpdiff;
  712. X
  713. X    return (cmpdiff<zone) ? 1 : 0;
  714. }
  715. X
  716. X
  717. X
  718. X
  719. int
  720. analyse_pin(struct fig2 * p, int *d, int xpos, int ypos)
  721. {
  722. X    float           d1, d2;
  723. X    float           x1, x2, y1, y2;
  724. X    float           x, y, h, v;
  725. X    float           zone;
  726. X    double          alpha;
  727. X
  728. X
  729. X    /* 1. test : bounding rectangle */
  730. X
  731. X    x = p->x;
  732. X    y = p->y;
  733. X    v = p->v;
  734. X    h = p->h;
  735. X
  736. X    zone = 30.0;
  737. X
  738. X    norm_rectangle(&x, &y, &h, &v);
  739. X    /* now, x,y is the upper left corner of the rectangle */
  740. X
  741. X
  742. X
  743. X    x = x - zone;
  744. X    h = h + zone;
  745. X    y = y - zone;
  746. X    v = v + zone;
  747. X
  748. X
  749. X    if ((xpos < (int) x) || (xpos > (int) h) || (ypos < (int) y) || (ypos > (int) v))
  750. X        return 0;
  751. X
  752. X
  753. X
  754. X
  755. X    /* 2. test : distance */
  756. X
  757. X    x = (p->x);
  758. X    y = (p->y);
  759. X
  760. X    /* %%%%%%%%%%%%%%%%%%%%%  see documentation  %%%%%%%%%%%%%%%%%%%%% */
  761. X
  762. X    /* Vector 1 */
  763. X    x1 = (float) xpos - x;
  764. X    x2 = (float) ypos - y;
  765. X
  766. X    /* compute length of the above vector */
  767. X
  768. X    d1 = (float) sqrt((double) (x1 * x1 + x2 * x2));
  769. X    /* --- */
  770. X
  771. X    /* Vector 2 */
  772. X    y1 = (p->h) - x;
  773. X    y2 = (p->v) - y;
  774. X
  775. X    d2 = (float) sqrt((double) (y1 * y1 + y2 * y2));
  776. X    /* --- */
  777. X
  778. X
  779. X    alpha = (double) ((x1 * y1 + x2 * y2) / (d1 * d2));
  780. X
  781. X    /* acos(x),-1<=x<=1 */
  782. X    if (alpha < -1.0)
  783. X        alpha = -1.0;
  784. X    if (alpha > 1.0)
  785. X        alpha = 1.0;
  786. X
  787. X
  788. X    alpha = acos(alpha);
  789. X
  790. X
  791. X    (*d) = (int) (d1 * (float) sin(alpha));
  792. X
  793. X
  794. X    if ((*d) <= (int) zone)
  795. X        return 1;
  796. X    else
  797. X        return 0;
  798. X
  799. }
  800. X
  801. X
  802. X
  803. int
  804. analyse_nbox(struct fig3 * p, int *d, int xpos, int ypos)
  805. {
  806. X    /* normal box */
  807. X    float           zone;
  808. X    int             x, y, h, v;
  809. X    int             dt, db, dr, dl;
  810. X
  811. X
  812. X
  813. X    zone = 20.0;
  814. X
  815. X    x = (int) ((p->x) - zone);
  816. X    y = (int) ((p->y) - zone);
  817. X    v = (int) ((p->v) + zone);
  818. X    h = (int) ((p->h) + zone);
  819. X
  820. X    /* 1. test : bounding rectangle */
  821. X
  822. X    if ((xpos < x) || (xpos > h) || (ypos < y) || (ypos > v))
  823. X        return 0;
  824. X
  825. X
  826. X    /* 2. test : distance to a boundery */
  827. X
  828. X    dl = abs(xpos - (int) (p->x));
  829. X    dr = abs(xpos - (int) (p->h));
  830. X    dt = abs(ypos - (int) (p->y));
  831. X    db = abs(ypos - (int) (p->v));
  832. X
  833. X    /* compute the minimum of dr,dl,dt,db and store it in d */
  834. X
  835. X    if (dr < dl)
  836. X        dl = dr;    /* minimum in dl */
  837. X    if (db < dt)
  838. X        dt = db;    /* minimum in dt */
  839. X
  840. X    if (dt < dl)
  841. X        (*d) = dt;
  842. X    else
  843. X        (*d) = dl;
  844. X
  845. X
  846. X    if ((*d) <= (int) zone)
  847. X        return 1;
  848. X    else
  849. X        return 0;
  850. X
  851. }
  852. X
  853. X
  854. X
  855. int
  856. analyse_dbox(struct fig4 * p, int *d, int xpos, int ypos)
  857. {
  858. X    /* dashed box */
  859. X    float           zone;
  860. X    int             x, y, h, v;
  861. X    int             dt, db, dr, dl;
  862. X    zone = 20;
  863. X
  864. X    x = (int) ((p->x) - zone);
  865. X    y = (int) ((p->y) - zone);
  866. X    v = (int) ((p->v) + zone);
  867. X    h = (int) ((p->h) + zone);
  868. X
  869. X    /* 1. test : bounding rectangle */
  870. X
  871. X    if ((xpos < x) || (xpos > h) || (ypos < y) || (ypos > v))
  872. X        return 0;
  873. X
  874. X
  875. X    /* 2. test : distance to a boundery */
  876. X
  877. X    dl = abs(xpos - (int) (p->x));
  878. X    dr = abs(xpos - (int) (p->h));
  879. X    dt = abs(ypos - (int) (p->y));
  880. X    db = abs(ypos - (int) (p->v));
  881. X
  882. X    /* compute the minimum of dr,dl,dt,db and store it in d */
  883. X
  884. X    if (dr < dl)
  885. X        dl = dr;    /* minimum in dl */
  886. X    if (db < dt)
  887. X        dt = db;    /* minimum in dt */
  888. X
  889. X    if (dt < dl)
  890. X        (*d) = dt;
  891. X    else
  892. X        (*d) = dl;
  893. X
  894. X
  895. X    if ((*d) <= (int) zone)
  896. X        return 1;
  897. X    else
  898. X        return 0;
  899. X
  900. }
  901. X
  902. X
  903. X
  904. int
  905. analyse_fbox(struct fig2 * p, int *d, int xpos, int ypos)
  906. {
  907. X    /* filled box */
  908. X    int             x, y, h, v;
  909. X    x = (int) (p->x);
  910. X    y = (int) (p->y);
  911. X    v = (int) (p->v);
  912. X    h = (int) (p->h);
  913. X
  914. X    /* test : bounding rectangle */
  915. X
  916. X    if ((xpos < x) || (xpos > h) || (ypos < y) || (ypos > v))
  917. X        return 0;
  918. X
  919. X    (*d) = 0;    /* optimal pick */
  920. X
  921. X    return 1;
  922. X
  923. }
  924. X
  925. X
  926. int
  927. analyse_ncircle(struct fig2 * p, int *d, int xpos, int ypos)
  928. {
  929. X    /* normal circle */
  930. X    float           zone;
  931. X    int             x, y, h, v;
  932. X
  933. X
  934. X    zone = 20.0;
  935. X
  936. X    /* x,y is middlepoint/referencepoint */
  937. X    x = (int) ((p->x) - zone) - (p->radius);
  938. X    y = (int) ((p->y) - zone) - (p->radius);
  939. X    v = (int) ((p->y) + zone) + (p->radius);
  940. X    h = (int) ((p->x) + zone) + (p->radius);
  941. X
  942. X    /* now, x,y,h and v define the boundery-rectangle of the circle */
  943. X
  944. X    /* 1. test : bounding rectangle */
  945. X
  946. X    if ((xpos < x) || (xpos > h) || (ypos < y) || (ypos > v))
  947. X        return 0;
  948. X
  949. X
  950. X    /* 2. test : distance to a boundery (point on the circle-slice) */
  951. X    /*
  952. X     * compute the difference between radius and the length from
  953. X     * (xpos,ypos) to
  954. X     */
  955. X    /* the midlepoint */
  956. X
  957. X    x = xpos - (int) (p->x);
  958. X    y = ypos - (int) (p->y);
  959. X
  960. X    (*d) = abs((p->radius) -
  961. X           (int) sqrt((double) ((float) x * (float) x + (float) y * (float) y)));
  962. X
  963. X    if ((*d) <= (int) zone)
  964. X        return 1;
  965. X    else
  966. X        return 0;
  967. }
  968. X
  969. X
  970. X
  971. int
  972. analyse_ocircle(struct fig1 * p, int *d, int xpos, int ypos)
  973. {
  974. X    /* oval */
  975. X    int             zone;
  976. X    int             x, y, h, v;
  977. X    int             dt, db, dr, dl;
  978. X    zone = 20;
  979. X
  980. X    x = (int) (p->x) - zone;
  981. X    y = (int) (p->y) - zone;
  982. X    v = (int) (p->v) + zone;
  983. X    h = (int) (p->h) + zone;
  984. X
  985. X    /* 1. test : bounding rectangle */
  986. X
  987. X    if ((xpos < x) || (xpos > h) || (ypos < y) || (ypos > v))
  988. X        return 0;
  989. X
  990. X
  991. X    /* 2. test : distance to a boundery */
  992. X
  993. X    dl = abs(xpos - (int) (p->x));
  994. X    dr = abs(xpos - (int) (p->h));
  995. X    dt = abs(ypos - (int) (p->y));
  996. X    db = abs(ypos - (int) (p->v));
  997. X
  998. X
  999. X
  1000. X    /* compute the minimum of dr,dl,dt,db and store it in d */
  1001. X
  1002. X    if (dr < dl)
  1003. X        dl = dr;    /* minimum in dl */
  1004. X    if (db < dt)
  1005. X        dt = db;    /* minimum in dt */
  1006. X
  1007. X    if (dt < dl)
  1008. X        (*d) = dt;
  1009. X    else
  1010. X        (*d) = dl;
  1011. X
  1012. X
  1013. X    if ((*d) <= zone)
  1014. X        return 1;
  1015. X    else
  1016. X        return 0;
  1017. X
  1018. }
  1019. X
  1020. X
  1021. X
  1022. int
  1023. analyse_fcircle(struct fig2 * p, int *d, int xpos, int ypos)
  1024. {
  1025. X    /* filled circle */
  1026. X    int             x, y, h;
  1027. X
  1028. X
  1029. X
  1030. X
  1031. X    /*
  1032. X     * 1. test : the position of the selection point must be inside the
  1033. X     * fille circle
  1034. X     */
  1035. X    /*
  1036. X     * compute the difference between radius and the length from
  1037. X     * (xpos,ypos) to
  1038. X     */
  1039. X    /* the midlepoint */
  1040. X
  1041. X    x = (xpos - (int) (p->x));
  1042. X    y = (ypos - (int) (p->y));
  1043. X
  1044. X    h = (int) sqrt((double) ((float) x * (float) x + (float) y * (float) y));    /* length of this vector */
  1045. X
  1046. X    if (h < (p->radius))
  1047. X        (*d) = 0;    /* the selection point is fully inside the
  1048. X                 * circle */
  1049. X    else
  1050. X        return 0;
  1051. X
  1052. X    return 1;
  1053. }
  1054. X
  1055. X
  1056. X
  1057. void
  1058. set_pick_object(void)
  1059. {
  1060. X    /* Override Translation Manager */
  1061. X    XtTranslations  trans_table;
  1062. X    char            destination[80] = "<Btn1Up>: manage_pick()";
  1063. X    static XtActionsRec actions[80] = {{"manage_pick", manage_pick}};
  1064. X    XtAddActions(actions, XtNumber(actions));
  1065. X    trans_table = XtParseTranslationTable(destination);
  1066. X    XtOverrideTranslations(pboard, trans_table);
  1067. }
  1068. X
  1069. X
  1070. void
  1071. set_copy_object(void)
  1072. {
  1073. X    /* Override Translation Manager */
  1074. X    XtTranslations  trans_table;
  1075. X    char            destination[80] = "<Btn1Down>: manage_copy()";
  1076. X    static XtActionsRec actions[80] = {{"manage_copy", manage_copy}};
  1077. X    XtAddActions(actions, XtNumber(actions));
  1078. X    trans_table = XtParseTranslationTable(destination);
  1079. X    XtOverrideTranslations(pboard, trans_table);
  1080. }
  1081. X
  1082. X
  1083. X
  1084. void
  1085. leave_pick(char *message)
  1086. {
  1087. X    Position        xx, yy, y_rel, x_rel;
  1088. X    n = 0;
  1089. X    XtSetArg(args[n], XtNx, &x_rel);
  1090. X    n++;
  1091. X    XtSetArg(args[n], XtNy, &y_rel);
  1092. X    n++;
  1093. X    XtGetValues(pboard, args, n);
  1094. X    XtTranslateCoords(canvas, x_rel, y_rel, &xx, &yy);
  1095. X    n = 0;
  1096. X    XtSetArg(args[n], XtNx, 175 + xx);
  1097. X    n++;
  1098. X    XtSetArg(args[n], XtNy, 295 + yy);
  1099. X    n++;
  1100. X
  1101. X    XtSetValues(sign_up, args, n);
  1102. X
  1103. X    n = 0;
  1104. X    XtSetArg(args[n], XtNlabel, message);
  1105. X    n++;
  1106. X    XtSetValues(sign_msg, args, n);
  1107. X    XtPopupSpringLoaded(sign_up);
  1108. }
  1109. X
  1110. X
  1111. void
  1112. manage_pick(void)
  1113. {
  1114. X
  1115. X
  1116. X    int             index;
  1117. X    unsigned int    mask;
  1118. X
  1119. X
  1120. X
  1121. X
  1122. X    PointerPosition(&x_pick, &y_pick, &mask);
  1123. X
  1124. X    XtUninstallTranslations(pboard);
  1125. X
  1126. X    set_pick_stack(x_pick, y_pick);    /* pick_stack is filled with matching
  1127. X                     * objects */
  1128. X
  1129. X    index = nextObject();
  1130. X
  1131. X    if (index == -1)
  1132. X    {    /* no objects found */
  1133. X        left();
  1134. X        leave_pick("No valid object found !");
  1135. X        return;
  1136. X    } else
  1137. X        pick_manager();
  1138. }
  1139. X
  1140. X
  1141. X
  1142. X
  1143. X
  1144. void
  1145. pick_manager()
  1146. {
  1147. X    int             btn1 = 256, btn2 = 512, btn3 = 1024;
  1148. X    int             index;
  1149. X    int             x, y, h, v;
  1150. X    unsigned int    mask, mask2;
  1151. X    Display        *disp = XtDisplay(pboard);
  1152. X    Window          win = XtWindow(pboard);
  1153. X    headline(toplevel, "Actions: Button 1 to EDIT ---- Button 2 to MOVE ---- Button 3 for MORE");
  1154. X
  1155. X    while (True)
  1156. X    {
  1157. X
  1158. X        prepare_top_stack_object();
  1159. X
  1160. X        do
  1161. X        {    /* watch for any buttonPress */
  1162. X            PointerPosition(&x, &y, &mask);
  1163. X            if ((x < x_A4_min) || (x > x_A4_max) || (y < y_A4_min) || (y > y_A4_max))
  1164. X            {
  1165. X                left();
  1166. X                prepare_top_stack_object();
  1167. X                return;
  1168. X            }
  1169. X            draw_coords(pboard, (caddr_t) x, (caddr_t) y);
  1170. X
  1171. X        } while (!((mask & btn3) || (mask & btn2) || (mask & btn1)));
  1172. X
  1173. X        do
  1174. X        {
  1175. X            PointerPosition(&h, &v, &mask2);
  1176. X        } while ((mask2 & btn3));
  1177. X
  1178. X
  1179. X        prepare_top_stack_object();
  1180. X
  1181. X        if (mask & btn1)
  1182. X            pick_edit();
  1183. X        else if (mask & btn2)
  1184. X            index = pick_move(x, y);
  1185. X        else
  1186. X        {    /* more */
  1187. X            index = nextObject();
  1188. X
  1189. X            if (index == -1)
  1190. X            {    /* no objects found */
  1191. X                left();
  1192. X                leave_pick("No valid object found !");
  1193. X                return;
  1194. X            }
  1195. X        }
  1196. X
  1197. X    }    /* while */
  1198. }
  1199. X
  1200. X
  1201. X
  1202. int
  1203. pick_move(int startx, int starty)
  1204. {
  1205. X    /* currIndex points to object-reference in global database */
  1206. X
  1207. X    struct fig1    *one;
  1208. X    struct fig2    *two;
  1209. X    struct fig3    *three;
  1210. X    struct fig4    *four;
  1211. X    struct fig6    *six;    
  1212. X    int             x, y, h, v, oldh, oldv;
  1213. X    unsigned int    mask;
  1214. X    Display        *disp = XtDisplay(pboard);
  1215. X    Window          win = XtWindow(pboard);
  1216. X    int             btn1 = 256, btn2 = 512, btn3 = 1024;
  1217. X    float           ax, bx, ay, by, sx, sy;
  1218. X    int             rad;
  1219. X    float           zoomx, zoomy, zoomh, zoomv, zoomsx, zoomsy;
  1220. X    Boolean         redraw;
  1221. X    int             snapx, snapy;
  1222. X
  1223. X
  1224. X    by = -999.0;
  1225. X    oldh = -999;
  1226. X    oldv = oldh;
  1227. X
  1228. X
  1229. X    do
  1230. X    {
  1231. X        PointerPosition(&x, &y, &mask);
  1232. X
  1233. X        draw_coords(pboard, (caddr_t) x, (caddr_t) y);
  1234. X
  1235. X        switch (kind[currIndex])
  1236. X        {
  1237. X        case 'I':
  1238. X            six = (struct fig6 *) obj[currIndex];
  1239. X            h = x - startx;
  1240. X            v = y - starty;
  1241. X            if ((oldh != h) || (oldv != v))
  1242. X            {
  1243. X                oldh = h;
  1244. X                oldv = v;
  1245. X                zoomx = six->ax;
  1246. X                zoomy = six->ay;
  1247. X                zoomh = six->ex;
  1248. X                zoomv = six->ey;
  1249. X                zoomsx = six->sx;
  1250. X                zoomsy = six->sy;
  1251. X                
  1252. X                if (zoomed == True) real2zoomed(&zoomsx, &zoomsy);
  1253. X                
  1254. X                /* delete old line */
  1255. X                if (by == -999.0)
  1256. X                    DrawBezier(zoomx, zoomy, zoomh, zoomv, zoomsx, zoomsy);
  1257. X                else
  1258. X                    DrawBezier(ax, ay, bx, by, sx, sy);
  1259. X                    
  1260. X                if (zoomed == True) 
  1261. X                {
  1262. X                    real2zoomed(&zoomx, &zoomy);
  1263. X                    real2zoomed(&zoomh, &zoomv);
  1264. X                }
  1265. X                ax = zoomx + (float) h;
  1266. X                ay = zoomy + (float) v;
  1267. X                bx = zoomh + (float) h;
  1268. X                by = zoomv + (float) v;
  1269. X                sx = zoomsx + (float) h;
  1270. X                sy = zoomsy + (float) v;
  1271. X
  1272. X                if ((snap == True) && (raster == True))
  1273. X                {
  1274. X                    snapx = (int) ax;
  1275. X                    snapy = (int) ay;
  1276. X                    valid_snap_coords(&snapx, &snapy);
  1277. X                    bx -= (ax - (float) snapx);
  1278. X                    by -= (ay - (float) snapy);
  1279. X                    sx -= (ax - (float) snapx);
  1280. X                    sy -= (ay - (float) snapy);
  1281. X                    ax = (float) snapx;
  1282. X                    ay = (float) snapy;
  1283. X                }
  1284. X                /* draw new line */
  1285. X                
  1286. X                if (zoomed==True)
  1287. X                {
  1288. X                    zoomed2real(&ax,&ay);
  1289. X                    zoomed2real(&bx,&by);
  1290. X                }
  1291. X                
  1292. X                DrawBezier(ax, ay, bx, by, sx, sy);
  1293. X            }
  1294. X            break;
  1295. X
  1296. X        case 'L':
  1297. X            two = (struct fig2 *) obj[currIndex];
  1298. X            h = x - startx;
  1299. X            v = y - starty;
  1300. X            if ((oldh != h) || (oldv != v))
  1301. X            {
  1302. X                oldh = h;
  1303. X                oldv = v;
  1304. X                zoomx = two->x;
  1305. X                zoomy = two->y;
  1306. X                zoomh = two->h;
  1307. X                zoomv = two->v;
  1308. X                if (zoomed == True)
  1309. X                {
  1310. X                    real2zoomed(&zoomx, &zoomy);
  1311. X                    real2zoomed(&zoomh, &zoomv);
  1312. X                }
  1313. X                /* delete old line */
  1314. X                if (by == -999.0)
  1315. X                    XDrawLine(disp, win, gc, (int) zoomx, (int) zoomy,
  1316. X                          (int) zoomh, (int) zoomv);
  1317. X                else
  1318. X                    XDrawLine(disp, win, gc, (int) ax, (int) ay,
  1319. X                          (int) bx, (int) by);
  1320. X                ax = zoomx + (float) h;
  1321. X                ay = zoomy + (float) v;
  1322. X                bx = zoomh + (float) h;
  1323. X                by = zoomv + (float) v;
  1324. X
  1325. X                if ((snap == True) && (raster == True))
  1326. X                {
  1327. X                    snapx = (int) ax;
  1328. X                    snapy = (int) ay;
  1329. X                    valid_snap_coords(&snapx, &snapy);
  1330. X                    bx -= (ax - (float) snapx);
  1331. X                    by -= (ay - (float) snapy);
  1332. X                    ax = (float) snapx;
  1333. X                    ay = (float) snapy;
  1334. X                }
  1335. X                /* draw new line */
  1336. X                XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1337. X            }
  1338. X            break;
  1339. X
  1340. X        case 'V':
  1341. X            h = x - startx;
  1342. X            v = y - starty;
  1343. X            if ((oldh != h) || (oldv != v))
  1344. X            {
  1345. X                oldh = h;
  1346. X                oldv = v;
  1347. X                two = (struct fig2 *) obj[currIndex];
  1348. X                zoomx = two->x;
  1349. X                zoomy = two->y;
  1350. X                zoomh = two->h;
  1351. X                zoomv = two->v;
  1352. X                if (zoomed == True)
  1353. X                {
  1354. X                    real2zoomed(&zoomx, &zoomy);
  1355. X                    real2zoomed(&zoomh, &zoomv);
  1356. X                }
  1357. X                if (by == -999.0)
  1358. X                {
  1359. X                    XDrawLine(disp, win, gc, (int) zoomx, (int) zoomy,
  1360. X                          (int) zoomh, (int) zoomv);
  1361. X                    draw_vector_marker(zoomx, zoomy, zoomh, zoomv);
  1362. X                } else
  1363. X                {
  1364. X                    XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1365. X                    draw_vector_marker(ax, ay, bx, by);
  1366. X                }
  1367. X                ax = zoomx + (float) h;
  1368. X                ay = zoomy + (float) v;
  1369. X                bx = zoomh + (float) h;
  1370. X                by = zoomv + (float) v;
  1371. X
  1372. X                if ((snap == True) && (raster == True))
  1373. X                {
  1374. X                    snapx = (int) ax;
  1375. X                    snapy = (int) ay;
  1376. X                    valid_snap_coords(&snapx, &snapy);
  1377. X                    bx -= (ax - (float) snapx);
  1378. X                    by -= (ay - (float) snapy);
  1379. X                    ax = (float) snapx;
  1380. X                    ay = (float) snapy;
  1381. X                }
  1382. X                XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1383. X                draw_vector_marker(ax, ay, bx, by);
  1384. X            }
  1385. X            break;
  1386. X
  1387. X        case 'N':
  1388. X            h = x - startx;
  1389. X            v = y - starty;
  1390. X            if ((oldh != h) || (oldv != v))
  1391. X            {
  1392. X                oldh = h;
  1393. X                oldv = v;
  1394. X                three = (struct fig3 *) obj[currIndex];
  1395. X                zoomx = three->x;
  1396. X                zoomy = three->y;
  1397. X                zoomh = three->h;
  1398. X                zoomv = three->v;
  1399. X                if (zoomed == True)
  1400. X                {
  1401. X                    real2zoomed(&zoomx, &zoomy);
  1402. X                    real2zoomed(&zoomh, &zoomv);
  1403. X                }
  1404. X                if (by == -999.0)
  1405. X                {
  1406. X                    XDrawRectangle(disp, win, gc, (int) zoomx, (int) zoomy,
  1407. X                         (unsigned int) (zoomh - zoomx),
  1408. X                        (unsigned int) (zoomv - zoomy));
  1409. X                    print_box_text(three->textpos, zoomx, zoomy, zoomh, zoomv, three->text);
  1410. X                } else
  1411. X                {
  1412. X                    XDrawRectangle(disp, win, gc, ax, ay,
  1413. X                           (unsigned int) (bx - ax),
  1414. X                          (unsigned int) (by - ay));
  1415. X                    XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1416. X                    XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1417. X                }
  1418. X                ax = zoomx + (float) h;
  1419. X                ay = zoomy + (float) v;
  1420. X                bx = zoomh + (float) h;
  1421. X                by = zoomv + (float) v;
  1422. X
  1423. X                if ((snap == True) && (raster == True))
  1424. X                {
  1425. X                    snapx = (int) ax;
  1426. X                    snapy = (int) ay;
  1427. X                    valid_snap_coords(&snapx, &snapy);
  1428. X                    bx -= (ax - (float) snapx);
  1429. X                    by -= (ay - (float) snapy);
  1430. X                    ax = (float) snapx;
  1431. X                    ay = (float) snapy;
  1432. X                }
  1433. X                XDrawRectangle(disp, win, gc, ax, ay,
  1434. X                           (unsigned int) (bx - ax),
  1435. X                           (unsigned int) (by - ay));
  1436. X                XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1437. X                XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1438. X            }
  1439. X            break;
  1440. X
  1441. X        case 'D':
  1442. X            h = x - startx;
  1443. X            v = y - starty;
  1444. X            if ((h != oldh) || (v != oldv))
  1445. X            {
  1446. X                oldh = h;
  1447. X                oldv = v;
  1448. X                four = (struct fig4 *) obj[currIndex];
  1449. X                zoomx = four->x;
  1450. X                zoomy = four->y;
  1451. X                zoomh = four->h;
  1452. X                zoomv = four->v;
  1453. X                XSetLineAttributes(disp, gc, 0, LineOnOffDash, CapButt, JoinMiter);
  1454. X                if (zoomed == True)
  1455. X                {
  1456. X                    real2zoomed(&zoomx, &zoomy);
  1457. X                    real2zoomed(&zoomh, &zoomv);
  1458. X                }
  1459. X                if (by == -999.0)
  1460. X                {
  1461. X                    XDrawRectangle(disp, win, gc, (int) zoomx, (int) zoomy,
  1462. X                         (unsigned int) (zoomh - zoomx),
  1463. X                        (unsigned int) (zoomv - zoomy));
  1464. X                    print_box_text(four->textpos, zoomx, zoomy, zoomh, zoomv, four->text);
  1465. X                } else
  1466. X                {
  1467. X                    XDrawRectangle(disp, win, gc, (int) ax, (int) ay,
  1468. X                           (unsigned int) (bx - ax),
  1469. X                          (unsigned int) (by - ay));
  1470. X                    XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1471. X                    XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1472. X                }
  1473. X                ax = zoomx + (float) h;
  1474. X                ay = zoomy + (float) v;
  1475. X                bx = zoomh + (float) h;
  1476. X                by = zoomv + (float) v;
  1477. X
  1478. X                if ((snap == True) && (raster == True))
  1479. X                {
  1480. X                    snapx = (int) ax;
  1481. X                    snapy = (int) ay;
  1482. X                    valid_snap_coords(&snapx, &snapy);
  1483. X                    bx -= (ax - (float) snapx);
  1484. X                    by -= (ay - (float) snapy);
  1485. X                    ax = (float) snapx;
  1486. X                    ay = (float) snapy;
  1487. X                }
  1488. X                XDrawRectangle(disp, win, gc, (int) ax, (int) ay,
  1489. X                           (unsigned int) (bx - ax),
  1490. X                           (unsigned int) (by - ay));
  1491. X                XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1492. X                XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1493. X                XSetLineAttributes(disp, gc, 0, LineSolid, CapButt, JoinMiter);
  1494. X            }
  1495. X            break;
  1496. X
  1497. X        case 'F':
  1498. X            h = x - startx;
  1499. X            v = y - starty;
  1500. X            if ((oldh != h) || (oldv != v))
  1501. X            {
  1502. X                oldh = h;
  1503. X                oldv = v;
  1504. X                two = (struct fig2 *) obj[currIndex];
  1505. X                zoomx = two->x;
  1506. X                zoomy = two->y;
  1507. X                zoomh = two->h;
  1508. X                zoomv = two->v;
  1509. X                if (zoomed == True)
  1510. X                {
  1511. X                    real2zoomed(&zoomx, &zoomy);
  1512. X                    real2zoomed(&zoomh, &zoomv);
  1513. X                }
  1514. X                if (by == -999.0)
  1515. X                {
  1516. X                    XFillRectangle(disp, win, gc, (int) zoomx, (int) zoomy,
  1517. X                         (unsigned int) (zoomh - zoomx),
  1518. X                        (unsigned int) (zoomv - zoomy));
  1519. X                } else
  1520. X                {
  1521. X                    XDrawRectangle(disp, win, gc, (int) ax, (int) ay,
  1522. X                           (unsigned int) (bx - ax),
  1523. X                          (unsigned int) (by - ay));
  1524. X                    XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1525. X                    XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1526. X                }
  1527. X                ax = zoomx + (float) h;
  1528. X                ay = zoomy + (float) v;
  1529. X                bx = zoomh + (float) h;
  1530. X                by = zoomv + (float) v;
  1531. X
  1532. X                if ((snap == True) && (raster == True))
  1533. X                {
  1534. X                    snapx = (int) ax;
  1535. X                    snapy = (int) ay;
  1536. X                    valid_snap_coords(&snapx, &snapy);
  1537. X                    bx -= (ax - (float) snapx);
  1538. X                    by -= (ay - (float) snapy);
  1539. X                    ax = (float) snapx;
  1540. X                    ay = (float) snapy;
  1541. X                }
  1542. X                XDrawRectangle(disp, win, gc, (int) ax, (int) ay,
  1543. X                           (unsigned int) (bx - ax),
  1544. X                           (unsigned int) (by - ay));
  1545. X                XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1546. X                XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1547. X            }
  1548. X            break;
  1549. X
  1550. X        case 'C':
  1551. X            h = x - startx;
  1552. X            v = y - starty;
  1553. X            if ((oldh != h) || (oldv != v))
  1554. X            {
  1555. X                oldh = h;
  1556. X                oldv = v;
  1557. X                two = (struct fig2 *) obj[currIndex];
  1558. X                zoomx = two->x;
  1559. X                zoomy = two->y;
  1560. X                rad = two->radius;
  1561. X                if (zoomed == True)
  1562. X                {
  1563. X                    real2zoomed(&zoomx, &zoomy);
  1564. X                    real2zoomed(&zoomh, &zoomv);
  1565. X                    rad *= 10;
  1566. X                }
  1567. X                if (by == -999.0)
  1568. X                {
  1569. X                    XDrawArc(disp, win, gc, (int) zoomx - rad,
  1570. X                         (int) zoomy - rad,
  1571. X                         (unsigned int) (rad + rad),
  1572. X                         (unsigned int) (rad + rad), 0, 64 * 360);
  1573. X                    by = 0;
  1574. X                } else
  1575. X                {
  1576. X                    XDrawArc(disp, win, gc, (int) (ax - (float) rad),
  1577. X                         (int) (ay - (float) rad),
  1578. X                         (unsigned int) (rad + rad),
  1579. X                         (unsigned int) (rad + rad), 0, 64 * 360);
  1580. X                    XDrawLine(disp, win, gc, ax, ay - rad, ax, ay + rad);
  1581. X                    XDrawLine(disp, win, gc, ax - rad, ay, ax + rad, ay);
  1582. X                }
  1583. X                ax = zoomx + (float) h;
  1584. X                ay = zoomy + (float) v;
  1585. X
  1586. X                if ((snap == True) && (raster == True))
  1587. X                {
  1588. X                    snapx = (int) ax;
  1589. X                    snapy = (int) ay;
  1590. X                    valid_snap_coords(&snapx, &snapy);
  1591. X                    ax = (float) snapx;
  1592. X                    ay = (float) snapy;
  1593. X                }
  1594. X                XDrawArc(disp, win, gc, (int) (ax - (float) rad),
  1595. X                     (int) (ay - (float) rad),
  1596. X                     (unsigned int) (rad + rad),
  1597. X                   (unsigned int) (rad + rad), 0, 64 * 360);
  1598. X                XDrawLine(disp, win, gc, (int) ax, (int) ay - rad, (int) ax, (int) ay + rad);
  1599. X                XDrawLine(disp, win, gc, (int) ax - rad, (int) ay, (int) ax + rad, (int) ay);
  1600. X            }
  1601. X            break;
  1602. X
  1603. X        case 'B':
  1604. X            h = x - startx;
  1605. X            v = y - starty;
  1606. X            if ((oldh != h) || (oldv != v))
  1607. X            {
  1608. X                oldh = h;
  1609. X                oldv = v;
  1610. X                two = (struct fig2 *) obj[currIndex];
  1611. X                zoomx = two->x;
  1612. X                zoomy = two->y;
  1613. X                rad = two->radius;
  1614. X                if (zoomed == True)
  1615. X                {
  1616. X                    real2zoomed(&zoomx, &zoomy);
  1617. X                    real2zoomed(&zoomh, &zoomv);
  1618. X                    rad *= 10;
  1619. X                }
  1620. X                if (by == -999.0)
  1621. X                {
  1622. X                    XFillArc(disp, win, gc, (int) zoomx - rad, (int) zoomy - rad,
  1623. X                         (unsigned int) (rad + rad),
  1624. X                         (unsigned int) (rad + rad), 0, 64 * 360);
  1625. X                    by = 0;
  1626. X                } else
  1627. X                {
  1628. X                    XDrawArc(disp, win, gc, (int) (ax - (float) rad),
  1629. X                         (int) (ay - (float) rad),
  1630. X                         (unsigned int) (rad + rad),
  1631. X                         (unsigned int) (rad + rad), 0, 64 * 360);
  1632. X                    XDrawLine(disp, win, gc, (int) ax, (int) ay - rad, (int) ax, (int) ay + rad);
  1633. X                    XDrawLine(disp, win, gc, (int) ax - rad, (int) ay, (int) ax + rad, (int) ay);
  1634. X                }
  1635. X                ax = zoomx + (float) h;
  1636. X                ay = zoomy + (float) v;
  1637. X
  1638. X                if ((snap == True) && (raster == True))
  1639. X                {
  1640. X                    snapx = (int) ax;
  1641. X                    snapy = (int) ay;
  1642. X                    valid_snap_coords(&snapx, &snapy);
  1643. X                    ax = (float) snapx;
  1644. X                    ay = (float) snapy;
  1645. X                }
  1646. X                XDrawArc(disp, win, gc, (int) (ax - (float) rad),
  1647. X                     (int) (ay - (float) rad),
  1648. X                     (unsigned int) (rad + rad),
  1649. X                   (unsigned int) (rad + rad), 0, 64 * 360);
  1650. X                XDrawLine(disp, win, gc, (int) ax, (int) ay - rad, (int) ax, (int) ay + rad);
  1651. X                XDrawLine(disp, win, gc, (int) ax - rad, (int) ay, (int) ax + rad, (int) ay);
  1652. X            }
  1653. X            break;
  1654. X
  1655. X        case 'O':
  1656. X            h = x - startx;
  1657. X            v = y - starty;
  1658. X            if ((oldh != h) || (oldv != v))
  1659. X            {
  1660. X                oldh = h;
  1661. X                oldv = v;
  1662. X                one = (struct fig1 *) obj[currIndex];
  1663. X                zoomx = one->x;
  1664. X                zoomy = one->y;
  1665. X                zoomh = one->h;
  1666. X                zoomv = one->v;
  1667. X                if (zoomed == True)
  1668. X                {
  1669. X                    real2zoomed(&zoomx, &zoomy);
  1670. X                    real2zoomed(&zoomh, &zoomv);
  1671. X                }
  1672. X                if (by == -999.0)
  1673. X                    DrawOval((int) zoomx, (int) zoomy, (int) zoomh, (int) zoomv);
  1674. X                else
  1675. X                {
  1676. X                    DrawOval((int) ax, (int) ay, (int) bx, (int) by);
  1677. X                    XDrawLine(disp, win, gc, (int) (ax + (bx - ax) / 2), (int) ay, (int) (ax + (bx - ax) / 2), by);
  1678. X                    XDrawLine(disp, win, gc, (int) ax, (int) (ay + (by - ay) / 2), (int) bx, (int) (ay + (by - ay) / 2));
  1679. X                }
  1680. X                ax = zoomx + (float) h;
  1681. X                ay = zoomy + (float) v;
  1682. X                bx = zoomh + (float) h;
  1683. X                by = zoomv + (float) v;
  1684. X
  1685. X                if ((snap == True) && (raster == True))
  1686. X                {
  1687. X                    snapx = (int) ax;
  1688. X                    snapy = (int) ay;
  1689. X                    valid_snap_coords(&snapx, &snapy);
  1690. X                    bx -= (ax - (float) snapx);
  1691. X                    by -= (ay - (float) snapy);
  1692. X                    ax = (float) snapx;
  1693. X                    ay = (float) snapy;
  1694. X                }
  1695. X                DrawOval((int) ax, (int) ay, (int) bx, (int) by);
  1696. X                XDrawLine(disp, win, gc, (int) (ax + (bx - ax) / 2), (int) ay, (int) (ax + (bx - ax) / 2), by);
  1697. X                XDrawLine(disp, win, gc, (int) ax, (int) (ay + (by - ay) / 2), (int) bx, (int) (ay + (by - ay) / 2));
  1698. X            }
  1699. X            break;
  1700. X
  1701. X        default:
  1702. X            break;
  1703. X
  1704. X        }    /* switch */
  1705. X    } while ((mask & btn2));    /* || ( (graph_action=='Y') && (mask & btn1) ) ); */
  1706. X
  1707. X
  1708. X    if ((x < x_A4_min) || (x > x_A4_max) || (y < y_A4_min) || (y > y_A4_max))
  1709. X    {    /* cancel */
  1710. X        if ((refr_auto == True) && (graph_action != 'Y'))
  1711. X            refresh(pboard, '?', (caddr_t)DUMMY);
  1712. X        return -1;
  1713. X    }
  1714. X    /* store the new position of the object */
  1715. X
  1716. X    switch (kind[currIndex])
  1717. X    {
  1718. X    case 'I':
  1719. X        six = (struct fig6 *) obj[currIndex];
  1720. X        if (zoomed == True) zoomed2real(&sx, &sy);
  1721. X        six->ax = ax;
  1722. X        six->ay = ay;
  1723. X        six->ex = bx;
  1724. X        six->ey = by;
  1725. X        six->sx = sx;
  1726. X        six->sy = sy;
  1727. X        break;
  1728. X
  1729. X    case 'L':
  1730. X        two = (struct fig2 *) obj[currIndex];
  1731. X        if (zoomed == True)
  1732. X        {
  1733. X            zoomed2real(&ax, &ay);
  1734. X            zoomed2real(&bx, &by);
  1735. X        }
  1736. X        two->x = ax;
  1737. X        two->y = ay;
  1738. X        two->h = bx;
  1739. X        two->v = by;
  1740. X        break;
  1741. X
  1742. X    case 'V':
  1743. X        two = (struct fig2 *) obj[currIndex];
  1744. X        if (zoomed == True)
  1745. X        {
  1746. X            zoomed2real(&ax, &ay);
  1747. X            zoomed2real(&bx, &by);
  1748. X        }
  1749. X        two->x = ax;
  1750. X        two->y = ay;
  1751. X        two->h = bx;
  1752. X        two->v = by;
  1753. X        break;
  1754. X
  1755. X
  1756. X    case 'N':
  1757. X        three = (struct fig3 *) obj[currIndex];
  1758. X        XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1759. X        XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1760. X        zoomx = ax;
  1761. X        zoomy = ay;
  1762. X        zoomh = bx;
  1763. X        zoomv = by;
  1764. X        if (zoomed == True)
  1765. X        {
  1766. X            zoomed2real(&zoomx, &zoomy);
  1767. X            zoomed2real(&zoomh, &zoomv);
  1768. X        }
  1769. X        three->x = zoomx;
  1770. X        three->y = zoomy;
  1771. X        three->h = zoomh;
  1772. X        three->v = zoomv;
  1773. X        print_box_text(three->textpos, zoomx, zoomy, zoomh, zoomv, three->text);
  1774. X        break;
  1775. X
  1776. X    case 'D':
  1777. X        four = (struct fig4 *) obj[currIndex];
  1778. X        XSetLineAttributes(disp, gc, 0, LineOnOffDash, CapButt, JoinMiter);
  1779. X        XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1780. X        XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1781. X        XSetLineAttributes(disp, gc, 0, LineSolid, CapButt, JoinMiter);
  1782. X        zoomx = ax;
  1783. X        zoomy = ay;
  1784. X        zoomh = bx;
  1785. X        zoomv = by;
  1786. X        if (zoomed == True)
  1787. X        {
  1788. X            zoomed2real(&zoomx, &zoomy);
  1789. X            zoomed2real(&zoomh, &zoomv);
  1790. X        }
  1791. X        four->x = zoomx;
  1792. X        four->y = zoomy;
  1793. X        four->h = zoomh;
  1794. X        four->v = zoomv;
  1795. X        print_box_text(four->textpos, zoomx, zoomy, zoomh, zoomv, four->text);
  1796. X        break;
  1797. X
  1798. X    case 'F':
  1799. X        two = (struct fig2 *) obj[currIndex];
  1800. X        XDrawLine(disp, win, gc, (int) ax, (int) ay, (int) bx, (int) by);
  1801. X        XDrawLine(disp, win, gc, (int) ax, (int) by, (int) bx, (int) ay);
  1802. X        XDrawRectangle(disp, win, gc, (int) ax, (int) ay,
  1803. X                   (unsigned int) (bx - ax),
  1804. X                   (unsigned int) (by - ay));
  1805. X        XFillRectangle(disp, win, gc, (int) ax, (int) ay,
  1806. X                   (unsigned int) (bx - ax),
  1807. X                   (unsigned int) (by - ay));
  1808. X        zoomx = ax;
  1809. X        zoomy = ay;
  1810. X        zoomh = bx;
  1811. X        zoomv = by;
  1812. X        if (zoomed == True)
  1813. X        {
  1814. X            zoomed2real(&zoomx, &zoomy);
  1815. X            zoomed2real(&zoomh, &zoomv);
  1816. X        }
  1817. X        two->x = zoomx;
  1818. X        two->y = zoomy;
  1819. X        two->h = zoomh;
  1820. X        two->v = zoomv;
  1821. X        break;
  1822. X
  1823. X    case 'C':
  1824. X        two = (struct fig2 *) obj[currIndex];
  1825. X        XDrawLine(disp, win, gc, (int) ax - rad, (int) ay, (int) ax + rad, (int) ay);
  1826. X        XDrawLine(disp, win, gc, (int) ax, (int) ay - rad, (int) ax, (int) ay + rad);
  1827. X        zoomx = ax;
  1828. X        zoomy = ay;
  1829. X        if (zoomed == True)
  1830. X        {
  1831. X            zoomed2real(&zoomx, &zoomy);
  1832. X            zoomed2real(&zoomh, &zoomv);
  1833. X        }
  1834. X        two->x = zoomx;
  1835. X        two->y = zoomy;
  1836. X        break;
  1837. X
  1838. X    case 'B':
  1839. X        two = (struct fig2 *) obj[currIndex];
  1840. X        XDrawLine(disp, win, gc, (int) ax - rad, (int) ay, (int) ax + rad, (int) ay);
  1841. X        XDrawLine(disp, win, gc, (int) ax, (int) ay - rad, (int) ax, (int) ay + rad);
  1842. X        XDrawArc(disp, win, gc, (int) ax - rad, (int) ay - rad,
  1843. X             (unsigned int) (rad + rad),
  1844. X             (unsigned int) (rad + rad), 0, 64 * 360);
  1845. X        XFillArc(disp, win, gc, (int) ax - rad, (int) ay - rad,
  1846. X             (unsigned int) (rad + rad),
  1847. X             (unsigned int) (rad + rad), 0, 64 * 360);
  1848. X        zoomx = ax;
  1849. X        zoomy = ay;
  1850. X        if (zoomed == True)
  1851. X        {
  1852. X            zoomed2real(&zoomx, &zoomy);
  1853. X            zoomed2real(&zoomh, &zoomv);
  1854. X        }
  1855. X        two->x = zoomx;
  1856. X        two->y = zoomy;
  1857. X        break;
  1858. X
  1859. X    case 'O':
  1860. X        one = (struct fig1 *) obj[currIndex];
  1861. X        XDrawLine(disp, win, gc, (int) (ax + (bx - ax) / 2), (int) ay,
  1862. X              (int) (ax + (bx - ax) / 2), (int) by);
  1863. X        XDrawLine(disp, win, gc, (int) ax, (int) (ay + (by - ay) / 2),
  1864. X              (int) bx, (int) (ay + (by - ay) / 2));
  1865. X        zoomx = ax;
  1866. X        zoomy = ay;
  1867. X        zoomh = bx;
  1868. X        zoomv = by;
  1869. X        if (zoomed == True)
  1870. X        {
  1871. X            zoomed2real(&zoomx, &zoomy);
  1872. X            zoomed2real(&zoomh, &zoomv);
  1873. X        }
  1874. X        one->x = zoomx;
  1875. X        one->y = zoomy;
  1876. X        one->h = zoomh;
  1877. X        one->v = zoomv;
  1878. X        break;
  1879. X
  1880. X
  1881. X    default:
  1882. X        break;
  1883. X
  1884. X    }    /* switch */
  1885. X
  1886. X
  1887. X
  1888. X
  1889. X    if (refr_auto == True)
  1890. X        refresh(pboard, '?', (caddr_t)DUMMY);
  1891. X
  1892. X    return 0;
  1893. X
  1894. X
  1895. }
  1896. X
  1897. X
  1898. void
  1899. pick_edit()
  1900. {
  1901. X    /* currIndex points to object-reference in global database */
  1902. X    /* button 1 is pressed */
  1903. X
  1904. X    struct fig1    *one;
  1905. X    struct fig2    *two;
  1906. X    struct fig3    *three;
  1907. X    struct fig4    *four;
  1908. X    struct fig6    *six;
  1909. X    int             x, y, dist1, dist2, dist3, dist4, low_val;
  1910. X    unsigned int    mask;
  1911. X    double          vec_x, vec_y, vec_h, vec_v;
  1912. X    int             res1, res2;
  1913. X    float           h_pos, v_pos, x_pos, y_pos;
  1914. X    float           h, v;
  1915. X
  1916. X
  1917. X
  1918. X
  1919. X
  1920. X    PointerPosition(&x, &y, &mask);
  1921. X
  1922. X
  1923. X    if (zoomed == True)
  1924. X    {
  1925. X        h = (float) x;
  1926. X        v = (float) y;
  1927. X        zoomed2real(&h, &v);
  1928. X        x = (int) h;
  1929. X        y = (int) v;
  1930. X    }
  1931. X    switch (kind[currIndex])
  1932. X    {
  1933. X    case 'I':    /* which point ? */
  1934. X        six = (struct fig6 *) obj[currIndex];
  1935. X        dist1 = calc_distance(x, y, (int) six->ax, (int) six->ay);    /* ax,ay */
  1936. X        dist2 = calc_distance(x, y, (int) six->ex, (int) six->ey);    /* ex,ey */
  1937. X        dist3 = calc_distance(x, y, (int) six->sx, (int) six->sy);    /* sx,sy */
  1938. X        if (zoomed == True)
  1939. X        {
  1940. X            dist1 *= 10;
  1941. X            dist2 *= 10;
  1942. X            dist3 *= 10;
  1943. X        }
  1944. X        /* compute minimum */
  1945. X        low_val=(dist1<dist2) ? dist1 : dist2;
  1946. X        low_val=(low_val<dist3) ? low_val : dist3;
  1947. X        if (low_val<=points)
  1948. X        { /* buttonpress was inside of circle */
  1949. X        if (low_val==dist1) edit_bezier_curveA();
  1950. X            else if (low_val==dist2) edit_bezier_curveE();
  1951. X            else edit_bezier_curveS();    
  1952. X
  1953. X            if (refr_auto == True)
  1954. X                refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  1955. X        }    /* if low_val<=points */
  1956. X        break;
  1957. X
  1958. X    case 'L':    /* edit which endpoint ? */
  1959. X        two = (struct fig2 *) obj[currIndex];
  1960. X        vec_x = (double) two->x - (double) x;
  1961. X        vec_y = (double) two->y - (double) y;
  1962. X        vec_h = (double) two->h - (double) x;
  1963. X        vec_v = (double) two->v - (double) y;
  1964. X        res1 = abs((int) sqrt(vec_x * vec_x + vec_y * vec_y));
  1965. X        res2 = abs((int) sqrt(vec_h * vec_h + vec_v * vec_v));
  1966. X        if (zoomed == True)
  1967. X        {
  1968. X            res1 = res1 * 10;
  1969. X            res2 = res2 * 10;
  1970. X        }
  1971. X        if ((res1 <= points) || (res2 <= points))
  1972. X        {
  1973. X            if (res1 < res2)
  1974. X            {
  1975. X                edit_x_line();
  1976. X                if (refr_auto == True)
  1977. X                    refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  1978. X            } else
  1979. X            {
  1980. X                edit_y_line();
  1981. X                if (refr_auto == True)
  1982. X                    refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  1983. X            }
  1984. X        }
  1985. X        break;
  1986. X
  1987. X    case 'V':    /* edit which endpoint ? */
  1988. X        two = (struct fig2 *) obj[currIndex];
  1989. X        vec_x = (double) two->x - (double) x;
  1990. X        vec_y = (double) two->y - (double) y;
  1991. X        vec_h = (double) two->h - (double) x;
  1992. X        vec_v = (double) two->v - (double) y;
  1993. X        res1 = abs((int) sqrt(vec_x * vec_x + vec_y * vec_y));
  1994. X        res2 = abs((int) sqrt(vec_h * vec_h + vec_v * vec_v));
  1995. X        if (zoomed == True)
  1996. X        {
  1997. X            res1 = res1 * 10;
  1998. X            res2 = res2 * 10;
  1999. X        }
  2000. X        if ((res1 <= points) || (res2 <= points))
  2001. X        {
  2002. X            if (res1 < res2)
  2003. X                edit_x_vector();
  2004. X            else
  2005. X                edit_y_vector();
  2006. X        }
  2007. X        break;
  2008. X
  2009. X    case 'N':    /* which point ? */
  2010. X        three = (struct fig3 *) obj[currIndex];
  2011. X        dist1 = calc_distance(x, y, (int) three->x, (int) three->y);    /* upper left */
  2012. X        dist2 = calc_distance(x, y, (int) three->h, (int) three->v);    /* lower right */
  2013. X        dist3 = calc_distance(x, y, (int) three->h, (int) three->y);    /* upper right */
  2014. X        dist4 = calc_distance(x, y, (int) three->x, (int) three->v);    /* lower left */
  2015. X        if (zoomed == True)
  2016. X        {
  2017. X            dist1 *= 10;
  2018. X            dist2 *= 10;
  2019. X            dist3 *= 10;
  2020. X            dist4 *= 10;
  2021. X        }
  2022. X        /* compute minimum */
  2023. X        if (dist1 < dist2)
  2024. X            low_val = dist1;
  2025. X        else
  2026. X            low_val = dist2;
  2027. X        if (dist3 < low_val)
  2028. X            low_val = dist3;
  2029. X        if (dist4 < low_val)
  2030. X            low_val = dist4;
  2031. X        if (low_val <= points)
  2032. X        {
  2033. X            x_pos = three->x;
  2034. X            y_pos = three->y;
  2035. X            h_pos = three->h;
  2036. X            v_pos = three->v;
  2037. X            if (low_val == dist1)
  2038. X            {
  2039. X                three->x = h_pos;
  2040. X                three->y = v_pos;
  2041. X                three->h = x_pos;
  2042. X                three->v = y_pos;
  2043. X                /*
  2044. X                 * now, coordinates are in the correct
  2045. X                 * order...
  2046. X                 */
  2047. X            } else if (low_val == dist3)
  2048. X            {
  2049. X                three->y = v_pos;
  2050. X                three->v = y_pos;
  2051. X            } else if (low_val == dist4)
  2052. X            {
  2053. X                three->x = h_pos;
  2054. X                three->h = x_pos;
  2055. X            }
  2056. X            /* low_val==dist2 is default... */
  2057. X            edit_frame(nn);
  2058. X            if (refr_auto == True)
  2059. X                refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  2060. X        }    /* if low_val<=points */
  2061. X        break;
  2062. X
  2063. X
  2064. X    case 'F':    /* which point ? */
  2065. X        two = (struct fig2 *) obj[currIndex];
  2066. X        dist1 = calc_distance(x, y, (int) two->x, (int) two->y);    /* upper left */
  2067. X        dist2 = calc_distance(x, y, (int) two->h, (int) two->v);    /* lower right */
  2068. X        dist3 = calc_distance(x, y, (int) two->h, (int) two->y);    /* upper right */
  2069. X        dist4 = calc_distance(x, y, (int) two->x, (int) two->v);    /* lower left */
  2070. X        if (zoomed == True)
  2071. X        {
  2072. X            dist1 *= 10;
  2073. X            dist2 *= 10;
  2074. X            dist3 *= 10;
  2075. X            dist4 *= 10;
  2076. X        }
  2077. X        /* compute minimum */
  2078. X        if (dist1 < dist2)
  2079. X            low_val = dist1;
  2080. X        else
  2081. X            low_val = dist2;
  2082. X        if (dist3 < low_val)
  2083. X            low_val = dist3;
  2084. X        if (dist4 < low_val)
  2085. X            low_val = dist4;
  2086. X        if (low_val <= points)
  2087. X        {
  2088. X            x_pos = two->x;
  2089. X            y_pos = two->y;
  2090. X            h_pos = two->h;
  2091. X            v_pos = two->v;
  2092. X            if (low_val == dist1)
  2093. X            {
  2094. X                two->x = h_pos;
  2095. X                two->y = v_pos;
  2096. X                two->h = x_pos;
  2097. X                two->v = y_pos;
  2098. X                /*
  2099. X                 * now, coordinates are in the correct
  2100. X                 * order...
  2101. X                 */
  2102. X            } else if (low_val == dist3)
  2103. X            {
  2104. X                two->y = v_pos;
  2105. X                two->v = y_pos;
  2106. X            } else if (low_val == dist4)
  2107. X            {
  2108. X                two->x = h_pos;
  2109. X                two->h = x_pos;
  2110. X            }
  2111. X            /* low_val==dist2 is default... */
  2112. X            edit_frame(ff);
  2113. X            if (refr_auto == True)
  2114. X                refresh(pboard, '?', (caddr_t)DUMMY);    /* wipe screen */
  2115. X        }    /* if low_val<=points */
  2116. X        break;
  2117. X
  2118. X
  2119. X
  2120. X    case 'D':    /* which point ? */
  2121. X        four = (struct fig4 *) obj[currIndex];
  2122. X        dist1 = calc_distance(x, y, (int) four->x, (int) four->y);    /* upper left */
  2123. X        dist2 = calc_distance(x, y, (int) four->h, (int) four->v);    /* lower right */
  2124. X        dist3 = calc_distance(x, y, (int) four->h, (int) four->y);    /* upper right */
  2125. X        dist4 = calc_distance(x, y, (int) four->x, (int) four->v);    /* lower left */
  2126. X        if (zoomed == True)
  2127. X        {
  2128. X            dist1 *= 10;
  2129. X            dist2 *= 10;
  2130. X            dist3 *= 10;
  2131. X            dist4 *= 10;
  2132. X        }
  2133. X        /* compute minimum */
  2134. X        if (dist1 < dist2)
  2135. X            low_val = dist1;
  2136. X        else
  2137. X            low_val = dist2;
  2138. X        if (dist3 < low_val)
  2139. X            low_val = dist3;
  2140. X        if (dist4 < low_val)
  2141. X            low_val = dist4;
  2142. X        if (low_val <= points)
  2143. X        {
  2144. X            x_pos = four->x;
  2145. X            y_pos = four->y;
  2146. X            h_pos = four->h;
  2147. X            v_pos = four->v;
  2148. X            if (low_val == dist1)
  2149. X            {
  2150. X                four->x = h_pos;
  2151. X                four->y = v_pos;
  2152. X                four->h = x_pos;
  2153. X                four->v = y_pos;
  2154. X                /*
  2155. X                 * now, coordinates are in the correct
  2156. X                 * order...
  2157. X                 */
  2158. X            } else if (low_val == dist3)
  2159. X            {
  2160. X                four->y = v_pos;
  2161. SHAR_EOF
  2162. true || echo 'restore of pickedit.c failed'
  2163. fi
  2164. echo 'End of  part 7'
  2165. echo 'File pickedit.c is continued in part 8'
  2166. echo 8 > _shar_seq_.tmp
  2167. exit 0
  2168. -- 
  2169. --
  2170. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  2171. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  2172. Sunnyvale, California 94086            at&t: 408/522-9236
  2173.