-
Notifications
You must be signed in to change notification settings - Fork 1
/
DoBlock.c
1440 lines (1251 loc) · 48 KB
/
DoBlock.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "xvt.h"
#include "noddy.h"
#include "nodInc.h"
#include "3dHier.h"
#include "3dCamera.h"
#include "3dMatPat.h"
#include "3dXFDraw.h"
#include "3dGrid.h"
#include "3dDraw.h"
#include "3dFMath.h"
#if (XVTWS != MACWS)
#include <malloc.h>
#endif
#define DEBUG(X)
#define TOLERANCE 0.0001
/* ********************************** */
/* External Globals used in this file */
#if XVT_CC_PROTO
extern LAYER_PROPERTIES ***calcBlockSection(double, double, double, double,
double, double, double, int *, int *);
extern int sortBlockSurfaces (BLOCK_DIAGRAM_DATA *);
extern int drawBlockSurfaces (BLOCK_DIAGRAM_DATA *);
extern int drawDirectionIndicator (WINDOW, PNT);
#else
extern LAYER_PROPERTIES ***calcBlockSection();
extern int sortBlockSurfaces ();
extern int drawBlockSurfaces ();
extern int drawDirectionIndicator ();
#endif
extern BLOCK_VIEW_OPTIONS *blockViewOptions;
extern GEOLOGY_OPTIONS geologyOptions;
extern double iscale; /* scaling factor for geology */
extern BOOLEAN parallel;
extern Fixed zoom;
extern COLOR backgroundColor;
#if XVT_CC_PROTO
void qSortPoints(THREED_POINT_INFO __huge *, int, int, int);
#else
void qSortPoints();
#endif
/* ************************* */
/* Globals used in this file */
#if XVT_CC_PROTO
int blockFrame(WINDOW, double, double, double, double, double, double);
int drawBlockDiagram(BLOCK_DIAGRAM_DATA *);
int drawBlockSection(WINDOW, COLOR **, int, int, double,
double, double, double, double, double, double,
double, double, double, double, double, double);
int drawBlockDiagramFrame (Point3d, Point3d, Point3d, int, int, int *, int *, int *);
int draw3dRect (WINDOW, Point3d [4]);
int draw3dLine (WINDOW, Point3d [2]);
int draw3dPoint (WINDOW, Point3d);
int renderBlockDiagram (BLOCK_DIAGRAM_DATA *);
int drawBlockBoreHoles (BLOCK_DIAGRAM_DATA *);
#else
int blockFrame();
int drawBlockDiagram();
int drawBlockSection();
int drawBlockDiagramFrame ();
int draw3dRect ();
int draw3dLine ();
int draw3dPoint ();
int renderBlockDiagram ();
int drawBlockBoreHoles ();
#endif
/***********************************************************************
* *
* void DoBlockDiagram() *
* *
* *
* DoBlockDiagram function displays the block diagram of the present *
* geology in dotmap form for three faces of block and draws *
* frame for block *
* *
* DoBlockDiagram() takes no arguments *
* DoBlockDiagram() returns no value *
* *
************************************************************************/
void DoBlockDiagram(blockDiagram, resolution)
BLOCK_DIAGRAM_DATA *blockDiagram;
int resolution;
{
WINDOW win;
int totalJob = 0, numEvents = (int) countObjects(NULL_WIN);
BLOCK_SURFACE_DATA *surface;
double minX, maxX;
int displayStatusBox = FALSE;
char memLabel[20];
RCT border;
PNT directionPos;
win = blockDiagram->threedData.pixmap;
for (surface = blockDiagram->surfaces; surface; surface = surface->next)
{ /* only display calculation stat window if it is a big one */
if ((!surface->surfaceData) || (blockDiagram->blockData))
{
displayStatusBox = TRUE;
break;
}
}
if (displayStatusBox)
{
strcpy (memLabel, "Block");
if (blockDiagram->blockData)
totalJob = blockDiagram->nz;
else
totalJob = blockDiagram->nz*numEvents + blockDiagram->nx*numEvents
+ blockDiagram->ny*numEvents;
initLongJob (0, totalJob, "Calculating Block Diagram...", memLabel);
}
minX = blockDiagram->minXLoc;
maxX = minX + blockDiagram->nx*blockDiagram->blockSize;
/* Adjust focus to center of block */
if ((blockDiagram->blockData) || (blockDiagram->boreHoles))
blockDiagram->threedData.focus.z += minX;
initBlockDiagram3d(&(blockDiagram->threedData));
/* Put back the focus to where it was */
if ((blockDiagram->blockData) || (blockDiagram->boreHoles))
blockDiagram->threedData.focus.z -= minX;
xvt_dwin_clear (blockDiagram->threedData.pixmap, backgroundColor);
sortBlockSurfaces (blockDiagram);
if (blockDiagram->blockData)
renderBlockDiagram (blockDiagram);
else if (blockDiagram->boreHoles)
drawBlockBoreHoles (blockDiagram);
else
{
drawBlockSurfaces (blockDiagram);
xvt_vobj_get_client_rect (win, &border);
directionPos.h = 35;
directionPos.v = border.bottom - 35;
drawDirectionIndicator (win, directionPos);
}
/* Calculation keeping block in memory
**
** if (blockDiagram->blockData = calcBlockDiagram(blockDiagram->minXLoc,
** blockDiagram->minYLoc, blockDiagram->minZLoc,
** nx, ny, nz, cubeSize))
** {
** updateBlockDiagramPoints (blockDiagram);
** drawBlockDiagram (blockDiagram);
** }
**
*/
if (displayStatusBox)
finishLongJob();
return;
}
/* ********************************************************************* *
initBlockDiagram3d
Setup the 3d libraries for drawing the block diagrams
** ********************************************************************* */
int initBlockDiagram3d(threedData)
THREED_IMAGE_DATA *threedData;
{
setup3dDrawing (threedData);
parallel = TRUE;
zoom = threedData->scale*DEFAULT_BLOCK_SCALING;
/*
if (resolution == BLOCK_PREVIEW)
zoom = 0.022/((maxX-minX)/((double) BLOCK_DIAGRAM_SIZE_X));
else
zoom = 0.03/((maxX-minX)/((double) BLOCK_DIAGRAM_SIZE_X));
*/
return (TRUE);
}
/* ********************************************************************* *
findSurfaceInImage
return the surface that was clicked in
** ********************************************************************* */
BLOCK_SURFACE_DATA *findSurfaceInImage (location, diagram)
PNT location;
BLOCK_DIAGRAM_DATA *diagram;
{
BLOCK_SURFACE_DATA *surface, *chosenSurface = NULL;
Point3d origPoint, transPoint;
Point2d startPoint, endPoint;
double blockXStart, blockXEnd;
RCT surfaceRect;
initBlockDiagram3d(&(diagram->threedData));
sortBlockSurfaces (diagram);
blockXStart = diagram->minXLoc;
blockXEnd = diagram->nx*diagram->blockSize + blockXStart;
for (surface = diagram->surfaces; surface; surface = surface->next)
{
origPoint.z = blockXEnd - (surface->xStart - blockXStart);
origPoint.x = surface->yStart;
origPoint.y = surface->zStart;
ApplyTransform(&origPoint, &transPoint, &xFormViewer);
Project(&transPoint, &startPoint);
origPoint.z = blockXEnd - (surface->xEnd - blockXStart);
origPoint.x = surface->yEnd;
origPoint.y = surface->zEnd;
ApplyTransform(&origPoint, &transPoint, &xFormViewer);
Project(&transPoint, &endPoint);
surfaceRect.left = (short) MIN(startPoint.x,endPoint.x);
surfaceRect.right = (short) MAX(startPoint.x,endPoint.x);
surfaceRect.top = (short) MIN(startPoint.y,endPoint.y);
surfaceRect.bottom = (short) MAX(startPoint.y,endPoint.y);
/* As surfaces are ordered from furthest to closest it is the
** last one with the point in that is closest and therefore probably
** the one a person wants */
if (xvt_rect_has_point(&surfaceRect, location))
{
chosenSurface = surface; /* This Point is in the Surface */
}
}
return (chosenSurface);
}
/************************************************************************
* *
* void DoBlockFrame() *
* *
* *
* DoBlockFrame function draws frame for block *
* *
* DoBlockFrame() takes no arguments *
* DoBlockFrame() returns no value *
* *
************************************************************************/
int blockFrame(win, startX, startY, startZ, endX, endY, endZ)
WINDOW win;
double startX, startY, startZ;
double endX, endY, endZ;
{
DRAW_CTOOLS tools;
xvt_dwin_get_draw_ctools (win, &tools);
tools.pen.width = 0;
tools.pen.pat = PAT_SOLID;
tools.pen.style = P_SOLID;
tools.pen.color = COLOR_BLACK;
xvt_dwin_set_draw_ctools (win, &tools);
xfMoveto3d (endY, endZ, endX, &xFormViewer);
xfLineto3d (startY, endZ, endX, &xFormViewer);
xfLineto3d (startY, endZ, startX, &xFormViewer);
xfMoveto3d (startY, endZ, endX, &xFormViewer);
xfLineto3d (startY, startZ, endX, &xFormViewer);
return (TRUE);
}
/***********************************************************************
* *
* int drawBlockSection() *
* *
* *
* drawBlockSection function displays the block diagram of a *
* specific face
* *
* *
************************************************************************/
int
#if XVT_CC_PROTO
drawBlockSection(WINDOW win, COLOR **blockSection,
int dim1, int dim2, double cubeSize,
double xLocStart, double yLocStart, double zLocStart,
double xLocEnd, double yLocEnd, double zLocEnd,
double xBlkStart, double yBlkStart, double zBlkStart,
double xBlkEnd, double yBlkEnd, double zBlkEnd)
#else
drawBlockSection(win, blockSection, dim1, dim2, cubeSize,
xLocStart, yLocStart, zLocStart,
xLocEnd, yLocEnd, zLocEnd,
xBlkStart, yBlkStart, zBlkStart,
xBlkEnd, yBlkEnd, zBlkEnd)
WINDOW win;
COLOR **blockSection;
int dim1, dim2;
double cubeSize;
double xLocStart, yLocStart, zLocStart;
double xLocEnd, yLocEnd, zLocEnd;
double xBlkStart, yBlkStart, zBlkStart;
double xBlkEnd, yBlkEnd, zBlkEnd;
#endif
{
DRAW_CTOOLS tools;
Point3d Rect3D[4], rect3dPoint;
Point2d rect2dPoint;
PNT drawRect[4];
COLOR *colorPtr, *brushColor;
double xInc, yInc, zInc, halfXInc, halfYInc, halfZInc;
double diffX, diffY, diffZ;
double xOff, yOff, zOff, xLoc, yLoc, zLoc;
Matrix3D *matrixPtr;
register int i, j, point, zIsConstant;
/* Switch the X Drawing direction */
xLocStart = xBlkEnd - xLocStart;
xLocEnd = xBlkEnd - xLocEnd;
xOff = xLocStart;
yOff = yLocStart;
zOff = zLocStart;
diffX = (xLocEnd - xLocStart);
diffY = (yLocEnd - yLocStart);
diffZ = (zLocEnd - zLocStart);
if (fabs(diffZ) < TOLERANCE)
{
zIsConstant = TRUE;
xInc = diffX/((double) dim1);
yInc = diffY/((double) dim2);
zInc = 0.0;
}
else
{
zIsConstant = FALSE;
xInc = diffX/((double) dim1);
yInc = diffY/((double) dim1);
zInc = diffZ/((double) dim2);
}
halfXInc = xInc/2.0;
halfYInc = yInc/2.0;
halfZInc = zInc/2.0;
xvt_dwin_get_draw_ctools (win, &tools);
tools.pen.width = 0;
tools.pen.pat = PAT_HOLLOW;
tools.pen.style = P_SOLID;
tools.pen.color = COLOR_WHITE;
tools.brush.color = COLOR_BLACK;
tools.brush.pat = PAT_SOLID;
xvt_dwin_set_draw_ctools (win, &tools);
brushColor = &(tools.brush.color);
matrixPtr = &xFormViewer;
for (i = 0; i < dim1; i++)
{
colorPtr = blockSection[i];
incrementLongJob (INCREMENT_JOB);
/* the values that only vary with i */
if (zIsConstant)
{
xLoc = i*xInc + xOff;
zLoc = zOff;
Rect3D[0].y = Rect3D[1].y =
Rect3D[2].y = Rect3D[3].y = zLoc;
Rect3D[0].z = xLoc; Rect3D[1].z = xLoc+xInc;
Rect3D[2].z = xLoc+xInc; Rect3D[3].z = xLoc;
}
else
{
xLoc = i*xInc + xOff;
yLoc = i*yInc + yOff;
Rect3D[0].z = xLoc; Rect3D[1].z = xLoc;
Rect3D[2].z = xLoc+xInc; Rect3D[3].z = xLoc+xInc;
Rect3D[0].x = yLoc; Rect3D[1].x = yLoc;
Rect3D[2].x = yLoc+yInc; Rect3D[3].x = yLoc+yInc;
}
for (j = 0; j < dim2; j++)
{
*brushColor = *colorPtr++;
xvt_dwin_set_draw_ctools (win, &tools);
/* the values that only vary with j */
if (zIsConstant)
{
yLoc = j*yInc + yOff;
Rect3D[0].x = yLoc; Rect3D[1].x = yLoc;
Rect3D[2].x = yLoc+yInc; Rect3D[3].x = yLoc+yInc;
}
else
{
zLoc = j*zInc + zOff;
Rect3D[0].y = zLoc; Rect3D[1].y = zLoc+zInc;
Rect3D[2].y = zLoc+zInc; Rect3D[3].y = zLoc;
}
/* this point projection is here as you need
** the full xyz location before projecting */
for (point = 0; point < 4; point++)
{
ApplyTransform(&(Rect3D[point]), &rect3dPoint, matrixPtr);
Project(&rect3dPoint, &rect2dPoint);
drawRect[point].h = (short) rect2dPoint.x;
drawRect[point].v = (short) rect2dPoint.y;
}
xvt_dwin_draw_polygon (win, drawRect, 4);
}
}
/* Draw a black border around the surface we just drew */
tools.pen.width = 1;
tools.pen.pat = PAT_SOLID;
tools.pen.style = P_SOLID;
tools.pen.color = COLOR_BLACK;
xvt_dwin_set_draw_ctools (win, &tools);
if (zIsConstant)
{
xfMoveto3d(yLocEnd, zLocStart, xLocEnd, &xFormViewer);
xfLineto3d(yLocEnd, zLocEnd, xLocStart, &xFormViewer);
xfLineto3d(yLocStart, zLocEnd, xLocStart, &xFormViewer);
xfLineto3d(yLocStart, zLocStart, xLocEnd, &xFormViewer);
}
else
{
xfMoveto3d(yLocEnd, zLocStart, xLocEnd, &xFormViewer);
xfLineto3d(yLocEnd, zLocEnd, xLocEnd, &xFormViewer);
xfLineto3d(yLocStart, zLocEnd, xLocStart, &xFormViewer);
xfLineto3d(yLocStart, zLocStart, xLocStart, &xFormViewer);
}
/* Join back to the start */
xfLineto3d(yLocEnd, zLocStart, xLocEnd, &xFormViewer);
return (TRUE);
}
/***********************************************************************
* *
* int drawBlockSection() *
* *
* *
* drawBlockSection function displays the block diagram of a *
* specific face
* *
* *
************************************************************************/
int
#if XVT_CC_PROTO
drawBlockDiagram(BLOCK_DIAGRAM_DATA *blockDiagram)
#else
drawBlockDiagram(blockDiagram)
BLOCK_DIAGRAM_DATA *blockDiagram;
#endif
{
WINDOW win;
DRAW_CTOOLS tools;
THREED_POINT_INFO __huge *pointPtr;
int numPoints, point, i;
Point3d Rect3D[4];
Point2d Rect2D[4];
PNT drawRect[4];
win = blockDiagram->threedData.pixmap;
xvt_dwin_get_draw_ctools (win, &tools);
tools.pen.width = 0;
tools.pen.pat = PAT_HOLLOW;
tools.pen.style = P_SOLID;
tools.pen.color = COLOR_WHITE;
tools.brush.color = COLOR_BLACK;
tools.brush.pat = PAT_SOLID;
xvt_dwin_set_draw_ctools (win, &tools);
if (pointPtr = blockDiagram->threedData.surface)
{
numPoints = blockDiagram->threedData.surfaceWidth;
qSortPoints (pointPtr, 0, numPoints-2, 2);
for (point = 0; point < numPoints; point+=2, pointPtr+=2)
{
tools.brush.color = pointPtr->color;
xvt_dwin_set_draw_ctools (win, &tools);
Rect3D[0].y = pointPtr[0].point.z + pointPtr[1].point.z;
Rect3D[1].y = pointPtr[0].point.z - pointPtr[1].point.z;
Rect3D[2].y = pointPtr[0].point.z - pointPtr[1].point.z;
Rect3D[3].y = pointPtr[0].point.z + pointPtr[1].point.z;
Rect3D[0].z = pointPtr[0].point.x - pointPtr[1].point.x;
Rect3D[1].z = pointPtr[0].point.x + pointPtr[1].point.x;
Rect3D[2].z = pointPtr[0].point.x + pointPtr[1].point.x;
Rect3D[3].z = pointPtr[0].point.x - pointPtr[1].point.x;
Rect3D[0].x = pointPtr[0].point.y - pointPtr[1].point.y;
Rect3D[1].x = pointPtr[0].point.y - pointPtr[1].point.y;
Rect3D[2].x = pointPtr[0].point.y + pointPtr[1].point.y;
Rect3D[3].x = pointPtr[0].point.y + pointPtr[1].point.y;
for (i = 0; i < 4; i++) /* transform to something drawable */
{
ApplyTransform(&(Rect3D[i]), &(Rect3D[i]), &xFormViewer);
Project(&(Rect3D[i]), &(Rect2D[i]));
drawRect[i].h = (short) Rect2D[i].x;
drawRect[i].v = (short) Rect2D[i].y;
}
xvt_dwin_draw_polygon (win, drawRect, 4);
}
}
return (TRUE);
}
/*
int
#if XVT_CC_PROTO
drawSectionThroughBlock(WINDOW win, LAYER_PROPERTIES ***blockSection,
int dim1, int dim2, double cubeSize,
double xLocStart, double yLocStart, double zLocStart,
double xLocEnd, double yLocEnd, double zLocEnd)
#else
#endif
{
return (TRUE);
}
*/
/* ======================================================================
FUNCTION previewBlockDiagram
DESCRIPTION
update the Preview display of the block Diagram
INPUT
OUTPUT
RETURNED
====================================================================== */
int
#if XVT_CC_PROTO
previewBlockDiagram (BLOCK_DIAGRAM_DATA *blockDiagram)
#else
previewBlockDiagram (blockDiagram)
BLOCK_DIAGRAM_DATA *blockDiagram;
#endif
{
WINDOW win;
THREED_IMAGE_DATA *threedData;
Point3d start;
Point3d end;
double blockSize, minX, maxX;
DRAW_CTOOLS tools;
PNT directionPos;
RCT border;
if (!(threedData = &(blockDiagram->threedData)))
return (FALSE);
win = blockDiagram->threedData.pixmap;
blockSize = blockDiagram->blockSize;
start.x = blockDiagram->minYLoc; end.x = start.x + blockDiagram->ny*blockSize;
start.y = blockDiagram->minZLoc; end.y = start.y + blockDiagram->nz*blockSize;
start.z = /*blockDiagram->minXLoc*/0.0; end.z = start.z + blockDiagram->nx*blockSize;
minX = start.z;
maxX = end.z;
setup3dDrawing (threedData);
parallel = TRUE;
/* zoom = 0.03/((maxX-minX)/((double) BLOCK_DIAGRAM_SIZE_X)); */
zoom = blockDiagram->threedData.scale*DEFAULT_BLOCK_SCALING;
xvt_dwin_clear (threedData->pixmap, backgroundColor);
xvt_dwin_get_draw_ctools (threedData->pixmap, &tools);
tools.pen.width = 0;
tools.pen.pat = PAT_SOLID;
tools.pen.style = P_SOLID;
tools.pen.color = COLOR_LTGRAY;
tools.brush.color = COLOR_BLACK;
tools.brush.pat = PAT_SOLID;
xvt_dwin_set_draw_ctools (threedData->pixmap, &tools);
xfMoveto3d(start.x, start.y, end.z, &xFormViewer);
xfLineto3d(start.x, end.y, end.z, &xFormViewer);
xfLineto3d(start.x, end.y, start.z, &xFormViewer);
xfLineto3d(start.x, start.y, start.z, &xFormViewer);
xfLineto3d(start.x, start.y, end.z, &xFormViewer);
xfMoveto3d(end.x, start.y, end.z, &xFormViewer);
xfLineto3d(end.x, end.y, end.z, &xFormViewer);
xfLineto3d(end.x, end.y, start.z, &xFormViewer);
xfLineto3d(end.x, start.y, start.z, &xFormViewer);
xfLineto3d(end.x, start.y, end.z, &xFormViewer);
xfMoveto3d(start.x, start.y, end.z, &xFormViewer);
xfLineto3d(end.x, start.y, end.z, &xFormViewer);
xfLineto3d(end.x, start.y, start.z, &xFormViewer);
xfLineto3d(start.x, start.y, start.z, &xFormViewer);
xfLineto3d(start.x, start.y, end.z, &xFormViewer);
xfMoveto3d(start.x, end.y, end.z, &xFormViewer);
xfLineto3d(end.x, end.y, end.z, &xFormViewer);
xfLineto3d(end.x, end.y, start.z, &xFormViewer);
xfLineto3d(start.x, end.y, start.z, &xFormViewer);
xfLineto3d(start.x, end.y, end.z, &xFormViewer);
xvt_vobj_get_client_rect (win, &border);
directionPos.h = 35;
directionPos.v = border.bottom - 35;
drawDirectionIndicator (win, directionPos);
return (TRUE);
}
/* ======================================================================
FUNCTION renderBlockDiagram
DESCRIPTION
update the Preview display of the block Diagram
INPUT
OUTPUT
RETURNED
====================================================================== */
int
#if XVT_CC_PROTO
renderBlockDiagram (BLOCK_DIAGRAM_DATA *blockDiagram)
#else
renderBlockDiagram (blockDiagram)
BLOCK_DIAGRAM_DATA *blockDiagram;
#endif
{
#define SHADE_1 1.2 /* 0.9 */
#define SHADE_2 0.8 /* 0.8 */
WINDOW win;
THREED_IMAGE_DATA *threedData;
Point3d start;
Point3d end;
double blockSize, minX, maxX, minY, maxY;
DRAW_CTOOLS tools;
PNT directionPos;
RCT border;
register int x, y, z, nx, ny, nz, xIdx, yIdx, side;
int xInc, yInc, zInc;
int reverseX = FALSE , reverseY = FALSE;
double xPos, yPos, zPos, xLoc, yLoc;
Point3d Rect3D[4];
COLOR ***blockData, currentColor;
CUBE_SIDES drawSideOrder[6];
/* *********************************** */
/* Make sure we have something to draw */
if (!(threedData = &(blockDiagram->threedData)))
return (FALSE);
if (!(blockData = blockDiagram->blockData))
return (FALSE);
/* ********************************* */
/* Someuseful things to have locally */
win = blockDiagram->threedData.pixmap;
blockSize = blockDiagram->blockSize;
nx = blockDiagram->nx;
ny = blockDiagram->ny;
nz = blockDiagram->nz;
start.x = blockDiagram->minYLoc; end.x = start.x + ny*blockSize;
start.y = blockDiagram->minZLoc; end.y = start.y + nz*blockSize;
start.z = blockDiagram->minXLoc; end.z = start.z + nx*blockSize;
minX = blockDiagram->minXLoc;
maxX = blockDiagram->minXLoc + nx*blockSize;
minY = blockDiagram->minYLoc;
maxY = blockDiagram->minYLoc + ny*blockSize;
/* *************************** */
/* Initialise the 3d libraries */
xvt_dwin_clear (threedData->pixmap, backgroundColor);
/* ************************************************** */
/* Setup the brushes and pens we will be drawing with */
xvt_dwin_get_draw_ctools (threedData->pixmap, &tools);
tools.pen.width = 0; /* Draw the back (hidden) lines */
tools.pen.pat = PAT_SOLID;
tools.pen.style = P_SOLID;
tools.pen.color = COLOR_LTGRAY;
xvt_dwin_set_draw_ctools (win, &tools);
drawBlockDiagramFrame (start, end, threedData->camera, FALSE, TRUE,
&xInc, &yInc, &zInc);
/* Setup drawing of diagram so everything is Z-buffered */
drawSideOrder[0] = BOTTOM_SIDE;
if (xInc == 1)
{
reverseX = TRUE;
drawSideOrder[1] = EAST_SIDE;
drawSideOrder[3] = WEST_SIDE;
}
else if (xInc == -1)
{
reverseX = FALSE;
drawSideOrder[1] = WEST_SIDE;
drawSideOrder[3] = EAST_SIDE;
}
if (yInc == 1)
{
reverseY = FALSE;
drawSideOrder[2] = SOUTH_SIDE;
drawSideOrder[4] = NORTH_SIDE;
}
else if (yInc == -1)
{
reverseY = TRUE;
drawSideOrder[2] = NORTH_SIDE;
drawSideOrder[4] = SOUTH_SIDE;
}
drawSideOrder[5] = TOP_SIDE;
/* Setup Brushes and pens for the drawing */
tools.pen.width = 0;
tools.pen.pat = PAT_HOLLOW; /* PAT_NONE; */
tools.pen.style = P_SOLID;
tools.pen.color = COLOR_BLACK;
tools.brush.color = COLOR_BLACK;
tools.brush.pat = PAT_SOLID;
xvt_dwin_set_draw_ctools (threedData->pixmap, &tools);
/* *************** */
/* Initialise Rect */
for (x = 0; x < 4; x++)
{
Rect3D[x].x = Rect3D[x].y = Rect3D[x].z = 0.0;
}
/* ********************* */
/* Draw the actual block */
for (z = 0, zPos = blockDiagram->minZLoc; (z < nz); z++, zPos+=blockSize)
{
incrementLongJob (INCREMENT_JOB);
for (xIdx = 0, xLoc = maxX; (xIdx < nx); xIdx++, xLoc-=blockSize)
{
if (reverseX)
{
x = nx - xIdx - 1;
xPos = minX + (maxX - xLoc) + blockSize;
}
else
{
x = xIdx;
xPos = xLoc;
}
for (yIdx = 0, yLoc = minY; (yIdx < ny); yIdx++, yLoc+=blockSize)
{
if (reverseY)
{
y = ny - yIdx - 1;
yPos = minY + (maxY - yLoc) - blockSize;
}
else
{
y = yIdx;
yPos = yLoc;
}
if ((currentColor = blockData[z][x][y]) != COLOR_INVALID)
{
for (side = 0; side < 6; side++)
{
switch (drawSideOrder[side])
{
case (BOTTOM_SIDE):
if ((z == 0) || (blockData[z-1][x][y] == COLOR_INVALID))
{ /* Reached Bottom or Nothing below */
Rect3D[0].z = xPos;
Rect3D[1].z = xPos;
Rect3D[2].z = xPos - blockSize;
Rect3D[3].z = xPos - blockSize;
Rect3D[0].x = yPos + blockSize;
Rect3D[1].x = yPos;
Rect3D[2].x = yPos;
Rect3D[3].x = yPos + blockSize;
Rect3D[0].y = Rect3D[1].y = Rect3D[2].y = Rect3D[3].y = zPos;
tools.brush.color = currentColor;
xvt_dwin_set_draw_ctools (win, &tools);
draw3dRect (win, Rect3D);
}
break;
case (WEST_SIDE):
if ((x == 0) || (blockData[z][x-1][y] == COLOR_INVALID))
{ /* Reached Left Edge or Nothing left */
Rect3D[0].z = Rect3D[1].z = Rect3D[2].z = Rect3D[3].z = xPos;
Rect3D[0].x = yPos + blockSize;
Rect3D[1].x = yPos;
Rect3D[2].x = yPos;
Rect3D[3].x = yPos + blockSize;
Rect3D[0].y = zPos;
Rect3D[1].y = zPos;
Rect3D[2].y = zPos + blockSize;
Rect3D[3].y = zPos + blockSize;
tools.brush.color = XVT_MAKE_COLOR(XVT_COLOR_GET_RED(currentColor)*SHADE_2,
XVT_COLOR_GET_GREEN(currentColor)*SHADE_2,
XVT_COLOR_GET_BLUE(currentColor)*SHADE_2);
xvt_dwin_set_draw_ctools (win, &tools);
draw3dRect (win, Rect3D);
}
break;
case (EAST_SIDE):
if ((x == nx-1) || (blockData[z][x+1][y] == COLOR_INVALID))
{ /* Reached Right Edge or Nothing right */
Rect3D[0].z = Rect3D[1].z = Rect3D[2].z = Rect3D[3].z = xPos - blockSize;
Rect3D[0].x = yPos + blockSize;
Rect3D[1].x = yPos;
Rect3D[2].x = yPos;
Rect3D[3].x = yPos + blockSize;
Rect3D[0].y = zPos;
Rect3D[1].y = zPos;
Rect3D[2].y = zPos + blockSize;
Rect3D[3].y = zPos + blockSize;
tools.brush.color = XVT_MAKE_COLOR(XVT_COLOR_GET_RED(currentColor)*SHADE_2,
XVT_COLOR_GET_GREEN(currentColor)*SHADE_2,
XVT_COLOR_GET_BLUE(currentColor)*SHADE_2);
xvt_dwin_set_draw_ctools (win, &tools);
draw3dRect (win, Rect3D);
}
break;
case (SOUTH_SIDE):
if ((y == 0) || (blockData[z][x][y-1] == COLOR_INVALID))
{ /* Reached Front or Nothing forward */
Rect3D[0].z = xPos;
Rect3D[1].z = xPos;
Rect3D[2].z = xPos - blockSize;
Rect3D[3].z = xPos - blockSize;
Rect3D[0].x = Rect3D[1].x = Rect3D[2].x = Rect3D[3].x = yPos;
Rect3D[0].y = zPos;
Rect3D[1].y = zPos + blockSize;
Rect3D[2].y = zPos + blockSize;
Rect3D[3].y = zPos;
tools.brush.color = XVT_MAKE_COLOR(XVT_COLOR_GET_RED(currentColor)*SHADE_1,
XVT_COLOR_GET_GREEN(currentColor)*SHADE_1,
XVT_COLOR_GET_BLUE(currentColor)*SHADE_1);
xvt_dwin_set_draw_ctools (win, &tools);
draw3dRect (win, Rect3D);
}
break;
case (NORTH_SIDE):
if ((y == ny-1) || (blockData[z][x][y+1] == COLOR_INVALID))
{ /* Reached Back or Nothing backwards */
Rect3D[0].z = xPos;
Rect3D[1].z = xPos;
Rect3D[2].z = xPos - blockSize;
Rect3D[3].z = xPos - blockSize;
Rect3D[0].x = Rect3D[1].x = Rect3D[2].x = Rect3D[3].x = yPos + blockSize;
Rect3D[0].y = zPos;
Rect3D[1].y = zPos + blockSize;
Rect3D[2].y = zPos + blockSize;
Rect3D[3].y = zPos;
tools.brush.color = XVT_MAKE_COLOR(XVT_COLOR_GET_RED(currentColor)*SHADE_1,
XVT_COLOR_GET_GREEN(currentColor)*SHADE_1,
XVT_COLOR_GET_BLUE(currentColor)*SHADE_1);
xvt_dwin_set_draw_ctools (win, &tools);
draw3dRect (win, Rect3D);
}
break;
case (TOP_SIDE):
if ((z == nz-1) || (blockData[z+1][x][y] == COLOR_INVALID))
{ /* Reached Top or Nothing above */
Rect3D[0].z = xPos;
Rect3D[1].z = xPos;
Rect3D[2].z = xPos - blockSize;
Rect3D[3].z = xPos - blockSize;
Rect3D[0].x = yPos + blockSize;
Rect3D[1].x = yPos;
Rect3D[2].x = yPos;
Rect3D[3].x = yPos + blockSize;
Rect3D[0].y = Rect3D[1].y = Rect3D[2].y = Rect3D[3].y = zPos + blockSize;
tools.brush.color = currentColor;
xvt_dwin_set_draw_ctools (win, &tools);
draw3dRect (win, Rect3D);
}
break;
}
}
}
}
}
}
/* *************************************** */
/* Draw the border and direction indicator */
tools.pen.width = 0;
tools.pen.pat = PAT_SOLID;
tools.pen.style = P_SOLID;
tools.pen.color = COLOR_LTGRAY;
xvt_dwin_set_draw_ctools (win, &tools);
drawBlockDiagramFrame (start, end, threedData->camera, TRUE, FALSE,
(int *) NULL, (int *) NULL, (int *) NULL);
xvt_vobj_get_client_rect (win, &border);
directionPos.h = 35;
directionPos.v = border.bottom - 35;
drawDirectionIndicator (win, directionPos);
return (TRUE);
}
/* ======================================================================
FUNCTION drawBlockBoreHoles
DESCRIPTION
update the Preview display of the block Diagram
INPUT
OUTPUT
RETURNED
====================================================================== */
int
#if XVT_CC_PROTO
drawBlockBoreHoles (BLOCK_DIAGRAM_DATA *blockDiagram)
#else
drawBlockBoreHoles (blockDiagram)
BLOCK_DIAGRAM_DATA *blockDiagram;
#endif
{
WINDOW win;
THREED_IMAGE_DATA *threedData;
LAYER_PROPERTIES *layerProp;
Point3d start, end, line3d[2];
double blockSize, minX, maxX, minY, maxY;
DRAW_CTOOLS tools;
PNT directionPos;
RCT border;
int nx, ny, nz;
double ***boreHoleData;
register int hole, point, numHoles, numPoints;
double ***xyzLoc;
STORY **histoire;
int eventIndex;
int numEvents = countObjects(NULL_WIN);
unsigned int rockType;
/* *********************************** */
/* Make sure we have something to draw */
if (!(threedData = &(blockDiagram->threedData)))
return (FALSE);
if (!(boreHoleData = blockDiagram->boreHoles))
return (FALSE);
/* ********************************* */
/* Someuseful things to have locally */
win = blockDiagram->threedData.pixmap;
blockSize = blockDiagram->blockSize;
nx = blockDiagram->nx;
ny = blockDiagram->ny;