-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGS_PLOT.CPP
7351 lines (6414 loc) · 255 KB
/
GS_PLOT.CPP
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
/*************************************************************************
Name: gs_plot.cpp
Module description: File funzioni di base per l'impostazione del plottaggio
Author: Caterina Gaeta
**************************************************************************/
/*************************************************************************/
/* INCLUDES */
/*************************************************************************/
#include "stdafx.h" // MFC core and standard components
#define INITGUID
#import "msado15.dll" no_namespace rename ("EOF", "EndOfFile") rename ("EOS", "ADOEOS")
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <fcntl.h>
#include <string.h> /* per strcat() strcmp() */
#include <math.h>
#include "rxdefs.h"
#include "adslib.h"
#include "adsdlg.h" // gestione DCL
#include "..\gs_def.h" // definizioni globali
#include "gs_error.h"
#include "gs_init.h"
#include "gs_list.h" //definizioni per C_STRING
#include "gs_ase.h" // gestione links
#include "gs_class.h"
#include "gs_utily.h"
#include "gs_resbf.h"
#include "gs_prjct.h"
#include "gs_area.h"
#include "gs_graph.h"
#include "gs_plot.h" //definizioni di tipi
#include "d2hMap.h" // doc to help
/*************************************************************************/
/* GLOBAL VARIABLES */
/*************************************************************************/
/* ------------------------VARIABILI PER IL direttorio------------------ */
//variabile da prendere dal valore di GEOsimAppl::WORKDIR
static C_STRING DCL_FILE; //nome e percorso per il file DCL
static C_STRING INIPLOTFILE; //nome e percorso del file per il caricamento dati
/* ------------------------VARIABILI PER LA FINESTRA------------------ */
static ads_point PT1={0,0,0},PT2={0,0,0}; //angoli della sessione selezionata (valori da GSDDPLOT.INI)
/* ------------------------VARIABILI PER LE UNITA' DI MISURA---------- */
static enum UNITS_SYSTEMS {METRIC, ENGLISH};
static enum MEASURE_UNITS {MM=0,CM,M,KM};
static enum EN_MEASURE_UNITS {POLLICI=0,PIEDI,YARDE,MIGLIA}; //Miglia terrestri
static int UNITS_SYSTEM=METRIC; //(valori da GSDDPLOT.INI)
static int MEASURE_UNIT=M; //(valori da GSDDPLOT.INI)
static double PLOT_UNITS=1.0; //(valori da GSDDPLOT.INI)
static double DRAWING_UNITS=1.0; //(valori da GSDDPLOT.INI)
/* ---VARIABILI PER LE DIMENSIONI E IL LAYOUT DELL'AREA DI PLOTTAGGIO -------- */
static int PAPER_FIXED_MARGINS=0; //margine fisso in mm dovuto alla stampante (valori da GSDDPLOT.INI)
static int PAPER_USER_MARGINS=0; //margine tra foglio e disegno in mm =margine tra punto di inizio stampa
//(valori da GSDDPLOT.INI)
static int PAPER_MARGINS=0; //margine utente+margine fisso dovuto alla stampante (calcolato)
static double LARGENESS=0.0; //larghezza in unità disegno della finestra da plottare (calcolato)
static double HEIGHT=0.0; //altezza in unità disegno della finestra da plottare (calcolato)
//dimensioni reali in unità di misura reali - valori calcolati
static double PAPER_LARGENESS=0.0;
static double PAPER_HEIGHT=0.0;
//dimensioni totali disegno in mm compresi i margini - valori calcolati
static double PLOT_LARGENESS=0.0;
static double PLOT_HEIGHT=0.0;
static int PAPER_LIMITS=0; //stampa della cornice con le coordinate sui quattro vertici (valori da GSDDPLOT.INI)
static int LIMIT_TEXT_HEIGHT=0;//altezza testo limiti (valori da GSDDPLOT.INI)
static int PAPER_GRID=0; //stampa dei simboli di griglia (valori da GSDDPLOT.INI)
static double GRID_STEPX=1; //passo della griglia per x nell'unità scelta (valori da GSDDPLOT.INI)
static double GRID_STEPY=1; //passo della griglia per y nell'unità scelta (valori da GSDDPLOT.INI)
enum PLOT_LAYOUTS {BOTTOM_LEFT, TOP_LEFT, BOTTOM_RIGHT, TOP_RIGHT, CENTERED};
static int PLOT_LAYOUT=BOTTOM_LEFT; //posizione disegno rispetto al foglio
/* ---VARIABILI PER GLI EVENTUALI CARTIGLIO E LEGENDA ------------------------ */
static C_STRING CART_NAME; //nome cartiglio con il percorso (valori da GSDDPLOT.INI)
static ads_point CART_POINT; //valore calcolato
static double CART_HEIGHT=0.0; //dimensioni reali del cartiglio in mm (valori da GSDDPLOT.INI)
static double CART_BASE=0.0;
static enum ATTR_TYPES {ATTR_VALUE,ATTR_DATE,ATTR_HOUR,ATTR_SCALE};//tipi di attributi del cartiglio
static short ATTR_TYPE=ATTR_VALUE;
static C_STRING CART_ATTR_VALUE;
static ATTR_LIST USER_ATTR_LIST; //lista attributi cartiglio
static double LEG_HEIGHT=0.0; //dimensioni reali legenda - valori calcolati
static double LEG_BASE=0.0; //calcolata in base alle dim del cart. e della sessione da plottare
static int EXIST_LEGEND=0;
static double LEG_TEXT_HEIGHT=0.0; //altezza testo legenda in mm (valori da GSDDPLOT.INI)
static double LEG_TEXT_INTER_LINE=0.0; //interlinea (valori da GSDDPLOT.INI)
static double LEG_SPACE_BLOCK=0.0; //spazio orizzontale disponibile per un blocco (valori da GSDDPLOT.INI)
static size_t LEG_SPACE_TEXT=0; //spazio orizzontale necessario per ogni scritta in numero di caratteri - valore calcolato
static int LEG_ROWS_NUMBER=0; //numero righe necessarie per tutte le voci della legenda - valore calcolato
static int LEG_AV_ROWS_NUMBER=0; //numero righe disponibili - valore calcolato
static double LEG_BLOCK_SCALE=1.0; //scala per i blocchi (valori da GSDDPLOT.INI)
static int LEG_ENT=1;//raggruppamento nella legenda per entità (=1),raggruppamento nella legenda per blocchi(=0)-valore non variato
static int LEG_MANUAL=0; //legenda automatica o manuale (valori da GSDDPLOT.INI)
static CLASS_LIST EXT_CLASS_LIST; //lista delle classi di entità estratte - calcolato
/* ---VARIABILI PER LA TIPOLOGIA (con/senza cartiglio, posizione, ecc..------- */
static enum PLOT_TYPES {CART_LESS, INT_CART, EXBOTTOM_CART, EXRIGHT_CART, EXBOTTOMLEG_CART, EXRIGHTLEG_CART};
static int PLOT_TYPE=CART_LESS; //tipo di plottata (valori da GSDDPLOT.INI)- se non risulta una legenda e PLOT_TYPE=4 oppure 5
//viene settato =2 oppure 3
//static double L_USER = 0.00; //larghezza foglio se formato utente
//static double H_USER = 0.00; //altezza foglio se formato utente
/* ---VARIABILI PER L' ORIENTAMENTO e LE DIMENSIONI DEL FOGLIO --------------- */
//lista dimensioni dei fogli A4, A3, A2, A1, A0 in mm
static double DIMPAPERS[] = {
l_A4,
h_A4,
l_A3,
h_A3,
l_A2,
h_A2,
l_A1,
h_A1,
l_A0,
h_A0,
0.00,
0.00,
NULL
};
static double UNIT_CONST; //costante di proporzionalità per il calcolo delle misure - calcolato
static enum PAPER_TYPES {A4=0,A3=2,A2=4,A1=6,A0=8, FOGLIO_UTENTE=10};
static int PAPER; //memorizza il tipo di foglio scelto, nel caso di scala ottimizzata
static int HPAPER, VPAPER; //memorizza il tipo di foglio più piccolo utilizzabile - calcolato
static int HUPAPER, VUPAPER; //memorizza il foglio scelto dall'utente a partire dal più piccolo
static enum PAPER_ORIENTATIONS {HORIZONTAL, VERTICAL};
static int PAPER_ORIENTATION=HORIZONTAL; //valori da GSDDPLOT.INI
/* ---VARIABILI PER LA SCELTA DELLA SCALA ----------------------------- */
static enum SCALE_TYPES {UNO_CENTO=1, UNO_DUECENTO, UNO_CINQUECENTO,
UNO_MILLE, UNO_DUEMILA, UNO_CINQUEMILA, OTTIMIZZATA, UTENTE};
static int SCALE_TYPE=UTENTE; //contiene il tipo di scala scelto
static double PLOT_SCALE=1.0; //contiene la costante di proporzionalità per il calcolo delle misure del foglio (valori da GSDDPLOT.INI)
static C_STRING PLOT_ERRORS; //contiene una stringa con l'elenco degli errori nelle impostazioni dell'utente
/*************************************************************************/
/* LOCAL FUNCTIONS FORWARD DECLARATIONS */
/*************************************************************************/
int gsddplot_wizard();
int load_plot_values(const TCHAR *file_name = NULL, double x1=0.0, double y1=0.0, double x2=0.0, double y2=0.0);
int gsc_plot_preview(const TCHAR *file_name, double x1=0.0, double y1=0.0, double x2=0.0, double y2=0.0);
int valid_cart_name(TCHAR *name);
int set_extension(FILE *file);
int set_units(FILE *file);
int set_layout(FILE *file);
int set_cartleg(FILE *file);
int set_type(FILE *file);
int set_orientation(FILE *file);
int set_scale(FILE *file);
int save_plot_values(const TCHAR *file_name = NULL);
int get_real_value(FILE *file,TCHAR *sez,TCHAR *val,double *dbl);
int get_str_value(FILE *file,TCHAR *sez,TCHAR *val,TCHAR *res);
int get_extension(FILE *file);
int get_units(FILE *file);
int get_layout(FILE *file);
int get_cartleg(FILE *file);
int get_type(FILE *file);
int get_orientation(FILE *file);
int get_scale(FILE *file);
int init_values();
int geo_init();
int geo_ext();
int geo_units();
int geo_view();
int geo_scale();
int geo_paper();
int geo_type();
int geo_cart_leg();
int geo_cart_attr();
int geo_userpaper();
int geo_cart_leg_correction();
int geo_layout();
int geo_user_dim_paper(int chk = 0);
int geo_user_scale();
int show_plot();
int find_geowork();
double scale_dim(double d);
int calculate_scale(); //solo per la scala ottimizzata
int calculate_draw_dim();
void skip_extern_class(resbuf *&rb);
int valid_class(resbuf *rb);
int insert_subclass_data(presbuf ent,short prj,short ext_cl_index,short cl_index,
C_STRING *ext_cl_name, C_STRING *cl_name);
int insert_class_data(presbuf ent,short prj,short ext_cl_index,short cl_index,
C_STRING *ext_cl_name, C_STRING *cl_name);
int insert_class(presbuf rt,presbuf ret,short ext_cl_index,short cl_index,
C_STRING *ext_cl_name, C_STRING *cl_name);
int calculate_legend_list();
int calculate_legend();
int calculate_leg_ent_space_text();
int calculate_leg_block_rows_number();
int correct_cart_leg_values();
int build_legend(ads_point leg_pt);
int create_gsddplot_layer(TCHAR *name);
int is_new_layer(TCHAR *name);
int is_point();
void get_area();
void dimen_calculate();
void unit_const_calculate();
int paper_scale_calculate();
int initialize_scale_list(ads_hdlg hdlg);
int initialize_paper_list(ads_hdlg hdlg);
int initialize_type_list(ads_hdlg hdlg);
int initialize_layout_list(ads_hdlg hdlg);
int initialize_user_paper_list(ads_hdlg hdlg);
int create_new_layer(TCHAR *name);
int set_default_layer();
int exist_linetype(TCHAR *name);
int exist_style(TCHAR *name);
static void select_ini_plot_file(ads_callback_packet *cpkt);
static void annulla(ads_callback_packet *cpkt);
static void conferma(ads_callback_packet *cpkt);
static void previous(ads_callback_packet *cpkt);
static void get_view(ads_callback_packet *cpkt);
static void get_user_area(ads_callback_packet *cpkt);
static void get_coordinates(ads_callback_packet *cpkt);
static void change_view(ads_callback_packet *cpkt);
static void EnglishUnitsList(ads_callback_packet *cpkt);
static void MetricUnitsList(ads_callback_packet *cpkt);
static void get_measure_unit(ads_callback_packet *cpkt);
static void get_plot_units(ads_callback_packet *cpkt);
static void get_drawing_units(ads_callback_packet *cpkt);
static void get_paper_orientation(ads_callback_packet *cpkt);
static int set_scale1(ads_callback_packet *cpkt);
static int set_scale2(ads_callback_packet *cpkt);
static int set_scale3(ads_callback_packet *cpkt);
static int set_scale4(ads_callback_packet *cpkt);
static int set_scale5(ads_callback_packet *cpkt);
static int set_scale6(ads_callback_packet *cpkt);
static int set_scale7(ads_callback_packet *cpkt);
static int set_scale8(ads_callback_packet *cpkt);
static int set_paper0(ads_callback_packet *cpkt);
static int set_paper1(ads_callback_packet *cpkt);
static int set_paper2(ads_callback_packet *cpkt);
static int set_paper3(ads_callback_packet *cpkt);
static int set_paper4(ads_callback_packet *cpkt);
static int set_paperUtente(ads_callback_packet *cpkt);
static void get_user_largeness(ads_callback_packet *cpkt);
static void get_user_height(ads_callback_packet *cpkt);
static void get_user_scale(ads_callback_packet *cpkt);
static int set_type1(ads_callback_packet *cpkt);
static int set_type2(ads_callback_packet *cpkt);
static int set_type3(ads_callback_packet *cpkt);
static int set_type4(ads_callback_packet *cpkt);
static int set_type5(ads_callback_packet *cpkt);
static int set_type6(ads_callback_packet *cpkt);
static void get_paper_user_margins(ads_callback_packet *cpkt);
static void get_paper_limits(ads_callback_packet *cpkt);
static void get_limit_text_height(ads_callback_packet *cpkt);
static void get_paper_grid(ads_callback_packet *cpkt);
static void get_user_grid_step_x(ads_callback_packet *cpkt);
static void get_user_grid_step_y(ads_callback_packet *cpkt);
static void browse(ads_callback_packet *cpkt);
static void get_cart_attr(ads_callback_packet *cpkt);
static void get_new_attr(ads_callback_packet *cpkt);
static void del_attr(ads_callback_packet *cpkt);
static void get_mod_attr(ads_callback_packet *cpkt);
static void attr_value_option(ads_callback_packet *cpkt);
static void attr_date_option(ads_callback_packet *cpkt);
static void attr_hour_option(ads_callback_packet *cpkt);
static void attr_scale_option(ads_callback_packet *cpkt);
static void insert_value_attr(ads_callback_packet *cpkt);
static void get_manual_attr(ads_callback_packet *cpkt);
static void get_cart_name(ads_callback_packet *cpkt);
static void get_cart_base_height(ads_callback_packet *cpkt);
static void get_leg_text_height(ads_callback_packet *cpkt);
static void get_leg_text_inter_line(ads_callback_packet *cpkt);
static void get_leg_space_block(ads_callback_packet *cpkt);
static void get_leg_space_text(ads_callback_packet *cpkt);
static void get_leg_rows_number(ads_callback_packet *cpkt);
static void get_leg_av_rows_number(ads_callback_packet *cpkt);
static void get_leg_block_scale(ads_callback_packet *cpkt);
static void get_leg_manual(ads_callback_packet *cpkt);
static void get_leg_ent(ads_callback_packet *cpkt);
static void get_leg_block(ads_callback_packet *cpkt);
static int set_userpaper0(ads_callback_packet *cpkt);
static int set_userpaper1(ads_callback_packet *cpkt);
static int set_userpaper2(ads_callback_packet *cpkt);
static int set_userpaper3(ads_callback_packet *cpkt);
static int set_userpaper4(ads_callback_packet *cpkt);
static int set_userpaper(ads_callback_packet *cpkt);
static void set_layout1(ads_callback_packet *cpkt);
static void set_layout2(ads_callback_packet *cpkt);
static void set_layout3(ads_callback_packet *cpkt);
static void set_layout4(ads_callback_packet *cpkt);
static void set_layout5(ads_callback_packet *cpkt);
static void save_ini_plot_file(ads_callback_packet *cpkt);
int gsc_rtrim_double(double *db);
void InsTextStandardTextStyle(ads_point pt, const TCHAR *HText, const TCHAR *Rot,
const TCHAR *Text);
void InsTextJustifyRightStandardTextStyle(ads_point pt, const TCHAR *HText,
const TCHAR *Rot, const TCHAR *Text);
/* ************************Funzioni*********************************** */
/* ******************************************************************* */
// funzioni della classe geosim_class e delle sottoclassi
/* ******************************************************************* */
//costruttore
geosim_class::geosim_class() {
class_color.setByLayer(); //colore della classe 256=DALAYER=DEFAULT
class_layer = _T("0"); //piano default=layer "0"
class_block = _T("GEOSIM"); //blocco default="GEOSIM"
class_width = 0.0; //larghezza
class_elevation=0.0; //elevazione
class_scale=1.0; //scala
class_rotation=0.0; //rotazione
class_text_height=1.0; //altezza testo
class_thickness=0.0; //spessore
}
//costruttore
CLASS_LIST_ITEM::CLASS_LIST_ITEM() {
ext_class_index=0;
class_index=0;
class_ref=NULL;
}
//costruttore
CLASS_LIST_ITEM::CLASS_LIST_ITEM(short ext,short cl,TCHAR *ext_name,
TCHAR *cl_name,geosim_class *p)
{
ext_class_index=ext;
class_index=cl;
class_ref=p;
ext_class_name.set_name(ext_name);
class_name.set_name(cl_name);
}
//distruttore
CLASS_LIST_ITEM::~CLASS_LIST_ITEM() {
if (class_ref)
delete class_ref;
class_ref=NULL;
}
void geosim_class::write_class_name(ads_point pt, TCHAR* val, C_STRING *name)
{
//controlla se esiste il layer della classe ed in caso negativo lo crea
create_new_layer(this->class_layer.get_name());
//imposta il layer di default quello della classe
gsc_callCmd(_T("_.LAYER"), RTSTR, _T("_S"), RTSTR, this->class_layer.get_name(),
RTSTR, GS_EMPTYSTR, 0);
gsc_callCmd(_T("_.COLOR"), RTSTR, _T("7"), 0);
//inserimento scritta in pt
InsTextStandardTextStyle(pt, val, _T("0"), name->get_name());
//imposta il layer di default 0
set_default_layer();
}
//costruttore
geosim_node::geosim_node(resbuf *rt)
{
presbuf p;
if ((p = gsc_CdrAssoc(_T("COLOR"), rt, FALSE)))
class_color.setResbuf(p);
if ((p = gsc_CdrAssoc(_T("LAYER"), rt, FALSE)))
if (p->restype == RTSTR) class_layer = p->resval.rstring;
if ((p = gsc_CdrAssoc(_T("BLOCK"), rt, FALSE)))
if (p->restype == RTSTR) class_block = p->resval.rstring;
if ((p = gsc_CdrAssoc(_T("BLOCK_SCALE"), rt, FALSE)))
gsc_rb2Dbl(p, &class_scale);
if ((p = gsc_CdrAssoc(_T("ROTATION"), rt, FALSE)))
gsc_rb2Dbl(p, &class_rotation);
}
void geosim_node::draw_class_block(ads_point pt, TCHAR* scale, double larg)
{
//inserimento blocco (se esiste) in pt con la scala leg_block_scale (stessa per X e Y)
//e la rotazione this->class_rotation
//controlla se esiste il layer della classe ed in caso negativo lo crea
create_new_layer(this->class_layer.get_name());
//imposta il layer di default quello della classe
gsc_callCmd(_T("_.LAYER"), RTSTR, _T("_S"), RTSTR, this->class_layer.get_name(),
RTSTR, GS_EMPTYSTR, 0);
//imposta il colore della classe come default
gsc_set_CurrentColor(this->class_color);
if (this->class_block.get_name())
gsc_callCmd(_T("_.INSERT"), RTSTR, this->class_block.get_name() ,RTPOINT, pt,
RTSTR, scale, RTSTR, GS_EMPTYSTR, RTREAL, this->class_rotation, 0);
//imposta il layer di default 0
set_default_layer();
}
//costruttore
geosim_text::geosim_text(presbuf rt)
{
presbuf p;
if ((p = gsc_CdrAssoc(_T("COLOR"), rt, FALSE)))
class_color.setResbuf(p);
if ((p = gsc_CdrAssoc(_T("TEXT_STYLE"), rt, FALSE)))
if (p->restype == RTSTR) class_text_style = p->resval.rstring;
if ((p = gsc_CdrAssoc(_T("LAYER"), rt, FALSE)))
if (p->restype == RTSTR) class_layer = p->resval.rstring;
if ((p = gsc_CdrAssoc(_T("H_TEXT"), rt, FALSE)))
gsc_rb2Dbl(p, &class_text_height);
}
void geosim_text::write_class_name(ads_point pt, TCHAR* val, C_STRING *name)
{
//controlla se esiste il layer della classe ed in caso negativo lo crea
create_new_layer(this->class_layer.get_name());
//imposta il layer di default quello della classe
gsc_callCmd(_T("_.LAYER"), RTSTR, _T("_S"), RTSTR, this->class_layer.get_name(),
RTSTR, GS_EMPTYSTR, 0);
//imposta il colore della classe come default
gsc_set_CurrentColor(this->class_color);
double FixedHText;
//inserimento scritta in pt - (stile, se valido)
if (gsc_validtextstyle(this->class_text_style.get_name()) &&
exist_style(this->class_text_style.get_name()))
{
// verifico se lo stile di testo ha una altezza fissa
gsc_get_charact_textstyle(this->class_text_style.get_name(), &FixedHText);
if (FixedHText == 0) // non è stata impostata altezza fissa
gsc_callCmd(_T("_.TEXT"), RTSTR, _T("_Style"), RTSTR, this->class_text_style.get_name(),
RTPOINT, pt, RTSTR, val, RTSTR, _T("0"), RTSTR, name->get_name(), 0);
else
gsc_callCmd(_T("_.TEXT"), RTSTR, _T("_Style"), RTSTR, this->class_text_style.get_name(),
RTPOINT, pt, RTSTR, _T("0"), RTSTR, name->get_name(), 0);
}
else
{
resbuf rbTxtStyle;
acedGetVar(_T("TEXTSTYLE"), &rbTxtStyle);
// verifico se lo stile di testo ha una altezza fissa
gsc_get_charact_textstyle(rbTxtStyle.resval.rstring, &FixedHText);
if (FixedHText == 0) // non è stata impostata altezza fissa
gsc_callCmd(_T("_.TEXT"), RTPOINT, pt, RTSTR, val, RTSTR, _T("0"), RTSTR,name->get_name(), 0);
else
gsc_callCmd(_T("_.TEXT"), RTPOINT, pt, RTSTR, _T("0"), RTSTR, name->get_name(), 0);
}
//imposta il layer di default 0
set_default_layer();
}
//costruttore
geosim_pol::geosim_pol(presbuf rt)
{
presbuf p;
if ((p = gsc_CdrAssoc(_T("COLOR"), rt, FALSE)))
class_color.setResbuf(p);
if ((p = gsc_CdrAssoc(_T("LINE_TYPE"), rt, FALSE)))
if (p->restype == RTSTR) class_line_type = p->resval.rstring;
if ((p = gsc_CdrAssoc(_T("LAYER"), rt, FALSE)))
if (p->restype == RTSTR) class_layer = p->resval.rstring;
if ((p = gsc_CdrAssoc(_T("WIDTH"), rt, FALSE)))
gsc_rb2Dbl(p, &class_width);
}
void geosim_pol::draw_class_block(ads_point pt, TCHAR *scale, double larg)
{
create_new_layer(this->class_layer.get_name());
//imposta il layer di default quello della classe
gsc_callCmd(_T("_.LAYER"), RTSTR, _T("_S"), RTSTR, this->class_layer.get_name(),
RTSTR, GS_EMPTYSTR, 0);
// imposta il colore della classe come default
gsc_set_CurrentColor(this->class_color);
//imposta il tipo linea della classe come default, se è valido ed esiste
if ((gsc_validlinetype(this->class_line_type.get_name()))&&
(exist_linetype(this->class_line_type.get_name())))
gsc_callCmd(_T("_.LINETYPE"), RTSTR, _T("_S"),
RTSTR, this->class_line_type.get_name(), RTSTR, GS_EMPTYSTR, 0);
ads_point pt1, pt2;
pt1[0] = pt[0] - larg/2;
pt1[1] = pt[1];
pt1[2] = 0.0;
pt2[0] = pt[0] + larg/2;
pt2[1] = pt[1];
pt2[2] = 0.0;
double s;
ads_distof(scale, -1, &s); //conversione da stringa a double
double l = (this->class_width) * s;
gsc_callCmd(_T("_.PLINE"), RTPOINT, pt1, RTSTR, _T("_W"),
RTREAL, l, RTREAL, l, RTPOINT, pt2, RTSTR, GS_EMPTYSTR, 0);
//imposta il layer di default 0
set_default_layer();
}
//costruttore
geosim_sup::geosim_sup(presbuf rt)
{
presbuf p;
if ((p = gsc_CdrAssoc(_T("COLOR"), rt, FALSE)))
class_color.setResbuf(p);
if ((p = gsc_CdrAssoc(_T("HATCH"), rt, FALSE)))
if (p->restype == RTSTR) class_hatch = p->resval.rstring;
if ((p = gsc_CdrAssoc(_T("LINE_TYPE"), rt, FALSE)))
if (p->restype == RTSTR) class_line_type = p->resval.rstring;
if ((p = gsc_CdrAssoc(_T("LAYER"), rt, FALSE)))
if (p->restype == RTSTR) class_layer = p->resval.rstring;
}
void geosim_sup::draw_class_block(ads_point pt, TCHAR *scale, double larg)
{
create_new_layer(this->class_layer.get_name());
//imposta il layer di default quello della classe
gsc_callCmd(_T("_.LAYER"), RTSTR, _T("_S"), RTSTR, this->class_layer.get_name(),
RTSTR, GS_EMPTYSTR, 0);
// imposta il colore della classe come default
gsc_set_CurrentColor(this->class_color);
//imposta il tipo linea della classe come default, se è valido ed esiste
if (gsc_validlinetype(this->class_line_type.get_name()) &&
exist_linetype(this->class_line_type.get_name()))
gsc_callCmd(_T("_.LINETYPE"), RTSTR, _T("_S"),
RTSTR, this->class_line_type.get_name(), RTSTR, GS_EMPTYSTR, 0);
ads_point pt1,pt2,pt3,pt4;
pt1[0] = pt[0] - larg/2;
pt1[1] = pt[1] - larg/2;
pt1[2] = 0.0;
pt2[0] = pt[0] + larg/2;
pt2[1] = pt1[1];
pt2[2] = 0.0;
pt3[0] = pt2[0];
pt3[1] = pt[1] + larg/2;
pt3[2] = 0.0;
pt4[0] = pt1[0];
pt4[1] = pt3[1];
pt4[2] = 0.0;
double s;
ads_distof(scale, -1, &s); //conversione da stringa a double
double l = (this->class_width) * s;
gsc_callCmd(_T("_.PLINE"), RTPOINT,pt1,RTSTR, _T("_W"),
RTREAL,l,RTREAL,l,RTPOINT,pt2,RTPOINT,pt3,RTPOINT,pt4,RTPOINT,pt1,
RTSTR, GS_EMPTYSTR, 0);
set_default_layer();
}
//costruttore
geosim_spag::geosim_spag(presbuf rt)
{
presbuf p;
if ((p = gsc_CdrAssoc(_T("COLOR"), rt, FALSE)))
class_color.setResbuf(p);
if ((p = gsc_CdrAssoc(_T("LINE_TYPE"), rt, FALSE)))
if (p->restype == RTSTR) class_line_type = p->resval.rstring;
if ((p = gsc_CdrAssoc(_T("LAYER"), rt, FALSE)))
if (p->restype == RTSTR) class_layer = p->resval.rstring;
if ((p = gsc_CdrAssoc(_T("WIDTH"), rt, FALSE)))
gsc_rb2Dbl(p, &class_width);
}
void geosim_spag::draw_class_block(ads_point pt, TCHAR *scale, double larg)
{
create_new_layer(this->class_layer.get_name());
//imposta il layer di default quello della classe
gsc_callCmd(_T("_.LAYER"), RTSTR, _T("_S"), RTSTR, this->class_layer.get_name(),
RTSTR, GS_EMPTYSTR, 0);
// imposta il colore della classe come default
gsc_set_CurrentColor(this->class_color);
//imposta il tipo linea della classe come default, se è valido ed esiste
if ((gsc_validlinetype(this->class_line_type.get_name()))&&exist_linetype(this->class_line_type.get_name()) )
gsc_callCmd(_T("_.LINETYPE"), RTSTR, _T("_S"),
RTSTR, this->class_line_type.get_name(), RTSTR, GS_EMPTYSTR, 0);
ads_point pt1, pt2;
pt1[0] = pt[0] - larg/2;
pt1[1] = pt[1];
pt1[2] = 0.0;
pt2[0] = pt[0]+larg/2;
pt2[1] = pt[1];
pt2[2] = 0.0;
double s;
ads_distof(scale, -1, &s); //conversione da stringa a double
double l = (this->class_width) * s;
gsc_callCmd(_T("_.PLINE"), RTPOINT, pt, RTSTR, _T("_W"),
RTREAL, l, RTREAL, l, RTPOINT, pt2, RTSTR, GS_EMPTYSTR, 0);
//imposta il layer di default 0
set_default_layer();
}
/* ******************************************************************* */
// funzioni della classe attr_list e attr_list_item
/* ******************************************************************* */
//costruttore
ATTR_LIST_ITEM::ATTR_LIST_ITEM()
{
attr_type = ATTR_VALUE;
attr_value.set_name(GS_EMPTYSTR);
}
//costruttore
ATTR_LIST_ITEM::ATTR_LIST_ITEM(short type, TCHAR *value)
{
attr_type = type;
attr_value.set_name(value);
}
/* ******************************************************************* */
// valid_cart_name -- controlla se il nome e percorso del cartiglio è valido
/* ******************************************************************* */
int valid_cart_name(TCHAR *name)
{
if (name == NULL) return GS_BAD;
//controlla se il file name->get_name() esiste
if (gsc_path_exist(name) == GS_GOOD) return GS_GOOD;
return GS_BAD;
}
/* ******************************************************************* */
// set_extension -- memorizza i valori di PT1 e PT2 in GSDDPLOT.INI
/* ******************************************************************* */
int set_extension(FILE *file)
{
TCHAR val[50];
swprintf(val, 50, _T("%f"), PT1[X]);
if (gsc_set_profile(file, _T("Extension"), _T("PT10"), val, 0) == GS_BAD)
{
gsc_close_profile(file);
return GS_BAD;
}
swprintf(val, 50, _T("%f"), PT1[Y]);
if (gsc_set_profile(file, _T("Extension"), _T("PT11"), val, 0) == GS_BAD)
{
gsc_close_profile(file);
return GS_BAD;
}
swprintf(val, 50, _T("%f"), PT2[X]);
if (gsc_set_profile(file, _T("Extension"), _T("PT20"), val, 0) == GS_BAD)
{
gsc_close_profile(file);
return GS_BAD;
}
swprintf(val, 50, _T("%f"), PT2[Y]);
if (gsc_set_profile(file, _T("Extension"), _T("PT21"), val, 0) == GS_BAD)
{
gsc_close_profile(file);
return GS_BAD;
}
return GS_GOOD;
}
/* ******************************************************************* */
// set_units -- memorizza i valori di UNITS_SYSTEM MEASURE_UNIT
// PLOT_UNITS DRAWING_UNITS
// in GSDDPLOT.INI
/* ******************************************************************* */
int set_units(FILE *file)
{
TCHAR val[50];
//conversione da int a stringa - base 10
_itow_s(UNITS_SYSTEM, val, 10);
if (gsc_set_profile(file, _T("Units"), _T("UNITS_SYSTEM"), val, 0) == GS_BAD)
{
gsc_close_profile(file);
return GS_BAD;
}
_itow_s(MEASURE_UNIT, val, 10);
if (gsc_set_profile(file, _T("Units"), _T("MEASURE_UNIT"), val, 0) == GS_BAD)
{
gsc_close_profile(file);
return GS_BAD;
}
swprintf(val, 50, _T("%f"), PLOT_UNITS);
if (gsc_set_profile(file, _T("Units"), _T("PLOT_UNITS"), val, 0) == GS_BAD)
{
gsc_close_profile(file);
return GS_BAD;
}
swprintf(val, 50, _T("%f"), DRAWING_UNITS);
if (gsc_set_profile(file, _T("Units"), _T("DRAWING_UNITS"), val, 0) == GS_BAD)
{
gsc_close_profile(file);
return GS_BAD;
}
return GS_GOOD;
}
/* ******************************************************************* */
// set_layout -- memorizza i valori di PAPER_FIXED_MARGINS PAPER_USER_MARGINS
// PAPER_LIMITS LIMIT_TEXT_HEIGHT
// PAPER_GRID GRID_STEPX e Y
// PLOT_LAYOUT
// in GSDDPLOT.INI
/* ******************************************************************* */
int set_layout(FILE *file)
{
TCHAR val[50];
//conversione da int a stringa - base 10
_itow_s(PAPER_FIXED_MARGINS, val, 10);
if (gsc_set_profile(file, _T("Layout"), _T("PAPER_FIXED_MARGINS"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
_itow_s(PAPER_USER_MARGINS, val, 10);
if (gsc_set_profile(file, _T("Layout"), _T("PAPER_USER_MARGINS"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
_itow_s(PAPER_LIMITS, val, 10);
if (gsc_set_profile(file, _T("Layout"), _T("PAPER_LIMITS"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
_itow_s(LIMIT_TEXT_HEIGHT, val, 10);
if (gsc_set_profile(file, _T("Layout"), _T("LIMIT_TEXT_HEIGHT"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
_itow_s(PAPER_GRID, val, 10);
if (gsc_set_profile(file, _T("Layout"), _T("PAPER_GRID"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
swprintf(val, 50, _T("%f"), GRID_STEPX);
if (gsc_set_profile(file, _T("Layout"), _T("GRID_STEPX"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
swprintf(val, 50, _T("%f"), GRID_STEPY);
if (gsc_set_profile(file, _T("Layout"), _T("GRID_STEPY"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
_itow_s(PLOT_LAYOUT, val, 10);
if (gsc_set_profile(file, _T("Layout"), _T("PLOT_LAYOUT"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
return GS_GOOD;
}
/* ******************************************************************* */
// set_cartleg -- memorizza i valori di CART_NAME CART_HEIGHT CART_BASE
// LEG_TEXT_HEIGHT LEG_TEXT_INTER_LINE
// LEG_SPACE_BLOCK LEG_BLOCK_SCALE LEG_ENT
// LEG_MANUAL
// in GSDDPLOT.INI
/* ******************************************************************* */
int set_cartleg(FILE *file)
{
if (CART_NAME.len() == 0)
{
if (gsc_set_profile(file, _T("CartLeg"), _T("CART_NAME"), GS_EMPTYSTR, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
}
else
if (gsc_set_profile(file, _T("CartLeg"), _T("CART_NAME"), CART_NAME.get_name(), 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
TCHAR val[50];
swprintf(val, 50, _T("%f"), CART_HEIGHT);
if (gsc_set_profile(file, _T("CartLeg"), _T("CART_HEIGHT"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
swprintf(val, 50, _T("%f"), CART_BASE);
if (gsc_set_profile(file, _T("CartLeg"), _T("CART_BASE"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
swprintf(val, 50, _T("%f"), LEG_TEXT_HEIGHT);
if (gsc_set_profile(file, _T("CartLeg"), _T("LEG_TEXT_HEIGHT"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
swprintf(val, 50, _T("%f"), LEG_TEXT_INTER_LINE);
if (gsc_set_profile(file, _T("CartLeg"), _T("LEG_TEXT_INTER_LINE"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
swprintf(val, 50, _T("%f"), LEG_SPACE_BLOCK);
if (gsc_set_profile(file, _T("CartLeg"), _T("LEG_SPACE_BLOCK"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
swprintf(val, 50, _T("%f"), LEG_BLOCK_SCALE);
if (gsc_set_profile(file, _T("CartLeg"), _T("LEG_BLOCK_SCALE"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
_itow_s(LEG_ENT, val, 10);
if (gsc_set_profile(file, _T("CartLeg"), _T("LEG_ENT"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
_itow_s(LEG_MANUAL, val, 10);
if (gsc_set_profile(file, _T("CartLeg"), _T("LEG_MANUAL"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
return GS_GOOD;
}
/* ******************************************************************* */
// set_type -- memorizza il valore di PLOT_TYPE
// in GSDDPLOT.INI
/* ******************************************************************* */
int set_type(FILE *file)
{
TCHAR val[50];
_itow_s(PLOT_TYPE, val, 10);
if (gsc_set_profile(file, _T("Type"), _T("PLOT_TYPE"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
return GS_GOOD;
}
/* ******************************************************************* */
// set_orientation -- memorizza il valore di PAPER_ORIENTATION
// in GSDDPLOT.INI
/* ******************************************************************* */
int set_orientation(FILE *file)
{
TCHAR val[50];
_itow_s(PAPER_ORIENTATION, val, 10);
if (gsc_set_profile(file, _T("Orientation"), _T("PAPER_ORIENTATION"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
return GS_GOOD;
}
/* ******************************************************************* */
// set_scale -- memorizza il valore di PLOT_SCALE e di PAPER
// se la scala è OTTIMIZZATA
// in GSDDPLOT.INI
/* ******************************************************************* */
int set_scale(FILE *file)
{
TCHAR val[50];
_itow_s(SCALE_TYPE, val, 10);
if (gsc_set_profile(file, _T("Scale"), _T("SCALE_TYPE"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
if (SCALE_TYPE == OTTIMIZZATA)
{
_itow_s(PAPER, val, 10);
if (gsc_set_profile(file, _T("Scale"), _T("PAPER"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
}
swprintf(val, 50, _T("%f"), PLOT_SCALE);
if (gsc_set_profile(file, _T("Scale"), _T("PLOT_SCALE"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
swprintf(val, 50, _T("%f"), DIMPAPERS[FOGLIO_UTENTE]);
if (gsc_set_profile(file, _T("Scale"), _T("USERPAPERDIM1"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
swprintf(val, 50, _T("%f"), DIMPAPERS[FOGLIO_UTENTE+1]);
if (gsc_set_profile(file, _T("Scale"), _T("USERPAPERDIM2"), val, 0) == GS_BAD)
{ gsc_close_profile(file); return GS_BAD; }
return GS_GOOD;
}
/* ******************************************************************* */
// save_plot_values -- funzione per registrare
// le variabili globali in GSDDPLOT.INI
/* ******************************************************************* */
int save_plot_values(const TCHAR * file_name)
{
//OCCORRE SETTARE I VALORI NEL FILE GSDDPLOT.INI
FILE *file;
C_STRING path;
if (file_name == NULL)
{
path = GEOsimAppl::CURRUSRDIR; //costruisce path per il file .INI
path += _T("\\");
path += _T("GSDDPLOT.INI"); //aggiunge il nome del file .INI
}
else
path = file_name; //file .INI scelto dall'utente
if ((file = gsc_open_profile(path.get_name(), UPDATEABLE)) == NULL)
return GS_BAD;
if (set_extension(file)==GS_BAD) //valori di PT1 e PT2
{
if (gsc_close_profile(file)==GS_BAD) return GS_BAD;//CHIUSURA FILE
return GS_BAD;
}
if (set_units(file)==GS_BAD) //VARIABILI PER LE UNITA' DI MISURA
{
if (gsc_close_profile(file)==GS_BAD) return GS_BAD; //CHIUSURA FILE
return GS_BAD;
}
if (set_layout(file)==GS_BAD) //VARIABILI PER E IL LAYOUT DELL'AREA DI PLOTTAGGIO
{
if (gsc_close_profile(file)==GS_BAD) return GS_BAD; //CHIUSURA FILE
return GS_BAD;
}
if (set_cartleg(file)==GS_BAD) //VARIABILI PER GLI EVENTUALI CARTIGLIO E LEGENDA
{
if (gsc_close_profile(file)==GS_BAD) return GS_BAD; //CHIUSURA FILE
return GS_BAD;
}