| 1 |
C Copyright(C) 1999-2020 National Technology & Engineering Solutions |
| 2 |
C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 3 |
C NTESS, the U.S. Government retains certain rights in this software. |
| 4 |
C |
| 5 |
C See packages/seacas/LICENSE for details |
| 6 |
|
| 7 |
C======================================================================= |
| 8 |
SUBROUTINE PICKN2 (PROMPT, NUMNPF, XN, YN, MIDDEF, NDRES, *) |
| 9 |
C======================================================================= |
| 10 |
|
| 11 |
C --*** PICKN2 *** (MESH) Pick a node from window |
| 12 |
C -- written by Ray J. Meyers 21 June, 1990 |
| 13 |
C -- |
| 14 |
C --PICKN2 puts a cursor on the screen, finds the associated world |
| 15 |
C -- coordinates and then locates and returns the node closest |
| 16 |
C -- to those coordinates. |
| 17 |
C -- |
| 18 |
C --Parameters: |
| 19 |
C -- PROMPT - IN - the point requested |
| 20 |
C -- NUMNPF - IN - the number of nodes |
| 21 |
C -- XN - IN - the x coordinates of the nodes |
| 22 |
C -- yN - IN - the y coordinates of the nodes |
| 23 |
C -- MIDDEF - IN - true if the middle of the displayed mesh is to be the |
| 24 |
C -- starting position, else use the last selected position |
| 25 |
C -- NDRES - OUT - the node id selected |
| 26 |
C -- * - return statement if error picking point |
| 27 |
C -- |
| 28 |
C --Common Variables: |
| 29 |
C -- Sets DXLAST, DYLAST of /PICK/ |
| 30 |
C -- Uses /PICK/ |
| 31 |
|
| 32 |
DIMENSION XN(*), YN(*) |
| 33 |
PARAMETER (KLFT=1, KRGT=2, KBOT=3, KTOP=4, KNEA=5, KFAR=6) |
| 34 |
|
| 35 |
include 'pick.blk' |
| 36 |
|
| 37 |
CHARACTER*(*) PROMPT |
| 38 |
LOGICAL MIDDEF |
| 39 |
|
| 40 |
CHARACTER*80 XPRMPT |
| 41 |
CHARACTER CH |
| 42 |
|
| 43 |
IF (.NOT. INITP) THEN |
| 44 |
CALL PRTERR ('CMDERR', 'No mesh is displayed') |
| 45 |
GOTO 100 |
| 46 |
END IF |
| 47 |
|
| 48 |
C --Put up the cursor at the default location and wait for the user |
| 49 |
C --to select a point |
| 50 |
|
| 51 |
IF (PROMPT .NE. ' ') THEN |
| 52 |
XPRMPT = 'Pick ' // PROMPT // '...' |
| 53 |
ELSE |
| 54 |
XPRMPT = ' ' |
| 55 |
END IF |
| 56 |
|
| 57 |
IF (MIDDEF) THEN |
| 58 |
DXRES = DXMID |
| 59 |
DYRES = DYMID |
| 60 |
ELSE |
| 61 |
DXRES = DXLAST |
| 62 |
DYRES = DYLAST |
| 63 |
END IF |
| 64 |
CALL GRIKEY (XPRMPT, DXRES, DYRES, CH, *100) |
| 65 |
|
| 66 |
C --Save the selected position |
| 67 |
|
| 68 |
DXLAST = DXRES |
| 69 |
DYLAST = DYRES |
| 70 |
|
| 71 |
C --Translate the point from device coordinates into mesh coordinates |
| 72 |
|
| 73 |
XRES = PKMESH(KLFT) + (DXRES - DMESH(KLFT)) * DVRAT |
| 74 |
YRES = PKMESH(KBOT) + (DYRES - DMESH(KBOT)) * DVRAT |
| 75 |
|
| 76 |
C -- FIND THE NEAREST NODE |
| 77 |
|
| 78 |
DISMIN = 10E+30 |
| 79 |
DO 10 I = 1, NUMNPF |
| 80 |
X = XRES - XN(I) |
| 81 |
Y = YRES - YN(I) |
| 82 |
DIS = X*X + Y*Y |
| 83 |
IF(DIS .LT. DISMIN) THEN |
| 84 |
DISMIN = DIS |
| 85 |
NDRES = I |
| 86 |
END IF |
| 87 |
10 CONTINUE |
| 88 |
|
| 89 |
RETURN |
| 90 |
|
| 91 |
100 CONTINUE |
| 92 |
RETURN 1 |
| 93 |
END |