-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGS_ATTBL.CPP
3815 lines (3167 loc) · 140 KB
/
GS_ATTBL.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_ATTBL
Module description: File funzioni di base per la gestione dei blocchi
degli attributi per le entità GEOSIM.
Author: Roberto Poltini
(c) Copyright 1995-2015 by IREN ACQUA GAS S.p.A.
**********************************************************/
/**********************************************************/
/* INCLUDE */
/**********************************************************/
#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 <string.h>
#include <ctype.h>
#include "rxdefs.h"
#include "adslib.h"
#include <dbents.h>
#include <dbapserv.h> // per acdbHostApplicationServices()
#include "..\gs_def.h" // definizioni globali
#include "gs_error.h"
#include "gs_utily.h"
#include "gs_resbf.h"
#include "gs_init.h"
#include "gs_ase.h"
#include "gs_user.h"
#include "gs_class.h"
#include "gs_prjct.h"
#include "gs_netw.h"
#include "gs_area.h"
#include "gs_lisp.h"
#include "gs_graph.h"
#include "gs_attbl.h"
#include "gs_opcod.h"
#include "gs_setv.h"
#include "gs_query.h"
#include "gs_dwg.h" // gestione disegni
#include "gs_filtr.h"
#include "gs_thm.h"
static ads_real LAST_ROT = 0, LAST_SCALE = 1;
#if defined(GSDEBUG) // se versione per debugging
#include <sys/timeb.h> // Solo per debug
#include <time.h> // Solo per debug
double attbl_t1=0, attbl_t2=0, attbl_t3=0, attbl_t4=0, attbl_t5=0, attbl_t6=0, attbl_t7=0, attbl_t8=0;
#endif
/*************************************************************************/
/* GLOBAL VARIABLES */
/*************************************************************************/
//----------------------------------------------------------------------------//
// class C_OVER_ATTR che memorizza un handle di un attributo visibile e
// una lista di handle di attributi che gli si sovrappongono e la lunghezza di questa lista
//----------------------------------------------------------------------------//
class C_OVER_ATTR : public C_STR
{
friend class C_OVER_ATTR_LIST;
public :
ads_name DABlock; // entità blocco padre
long id; // conteggio di handle_list
C_STR_BTREE handle_list; // lista ordinata di handle
C_OVER_ATTR() {}
virtual ~C_OVER_ATTR() {} // chiama ~C_STR
long get_id() { return id; }
};
//----------------------------------------------------------------------------//
// class C_OVER_ATTR_LIST che memorizza lista di handle di attributi visibili e,
// per ognuno, una lista di handle di attributi che gli si sovrappongono
//----------------------------------------------------------------------------//
class C_OVER_ATTR_LIST : public C_LIST
{
public :
C_OVER_ATTR_LIST() {}
~C_OVER_ATTR_LIST() {} // chiama ~C_LIST
int remove_handle(const TCHAR *handle);
};
/*************************************************************************/
/* PRIVATE FUNCTIONS */
/*************************************************************************/
int get_attr_fas_from_block(TCHAR *sample_block_name, C_ATTRIB_FAS_LIST *pFasList);
static int gsc_attribinspoint_2_absolute(ads_point pInsBlock, ads_real BlkRotaz,
ads_real BlkScale, ads_point pt,
ads_point ptConverted);
TCHAR *get_str_param_name(TCHAR *str);
TCHAR *convert_str_parametric(const TCHAR *str, TCHAR *param);
int gsc_set_ins_mode_attrib(AcDbAttribute *pAttrib, short *GenFlag = NULL,
short *HorzAlign = NULL, short *VertAlign = NULL);
int gsc_dbOpenAttribute(ads_name DABlock, const TCHAR *AttribName,
enum AcDb::OpenMode Mode,
AcDbBlockReference **pBlock, AcDbAttribute **pAttrib);
int gsc_RbList2DAStrFmtRbList(C_ATTRIB_LIST *pAttribList, C_RB_LIST &ColValues,
C_RB_LIST &DAStrFmtRbList, int cls = 0, int sub = 0);
int gsc_add_da_block(C_CLASS *p_class, C_RB_LIST &ColValues, C_SELSET &SelSet);
//-----------------------------------------------------------------------//
////////////////// C_CLASS INIZIO ///////////////////////////////
//-----------------------------------------------------------------------//
/*********************************************************/
/*.doc C_CLASS::updfromDA <external> */
/*+
Aggiorna gli attributi di una scheda di un'entità (già esistente) con
eventuali valori di attributi visibili.
Parametri:
C_RB_LIST &ColValues; Lista ((<nome colonna><valore>) ...) di tutti gli
attributi della classe
ads_name entity; Entità grafica
C_SELSET *GlobalSelSet; Gruppo di selezione globale per la scheda corrente
(default = ASE_DSC_NULL)
int *is_torecalc; Flag opzionale: se = GS_GOOD -> viene effettuato
il ricalcolo, se = GS_BAD non viene effettuato
il ricalcolo. Se = NULL va a controllare se
è stato modificato un attributo visibile o se
esiste almeno un attributo visibile (default = NULL).
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int C_CLASS::updfromDA(C_RB_LIST &ColValues, ads_name entity,
C_SELSET *GlobalSelSet, int *is_torecalc)
{
C_ATTRIB_LIST *p_attrib_list = ptr_attrib_list();
C_ATTRIB *p_attrib;
presbuf p;
int to_recalc, Modified = GS_BAD, result = GS_BAD;
C_SELSET SelSet;
C_STRING text, DescrFrom_TAB_REF;
C_RB_LIST VisValuesList;
presbuf value = NULL, p_attr;
TCHAR *attrib_name;
int i = 0;
C_ATTRIB_BLOCK DABlock;
C_SELSET DABlockSet;
C_PROVIDER_TYPE_LIST *pProviderTypeList = ptr_info()->getDBConnection(OLD)->ptr_DataTypeList();
bool UpdateableFromDA;
// se non ha legame diretto con la grafica o non ha legame con tabella
if (!ptr_fas() || !p_attrib_list || p_attrib_list->is_visible() == GS_BAD)
return GS_GOOD;
do
{
if (GlobalSelSet == NULL) // se non è passato come parametro, lo ricavo
{
if (get_SelSet(ColValues, SelSet) == GS_BAD) return GS_BAD;
}
else
if (GlobalSelSet->copy(SelSet) == GS_BAD) return GS_BAD;
// numero di oggetti grafici associati al linkset
if (SelSet.length() <= 0) { GS_ERR_COD = eGSOpNotAble; break; }
if (id.category == CAT_SIMPLEX && id.type == TYPE_TEXT)
{
if ((p_attrib = (C_ATTRIB *) p_attrib_list->getFirstVisibleAttrib()) == NULL)
{ GS_ERR_COD = eGSInvAttribName; break; }
if ((p = ColValues.CdrAssoc(p_attrib->get_name())) == NULL) break;
// leggo valore dal text
if (gsc_getInfoText(entity, &text) == GS_BAD) break;
if ((VisValuesList << acutBuildList(RTLB, RTLB,
RTSTR, p_attrib->get_name(),
RTSTR, text.get_name(),
RTLE,
RTLE, 0)) == NULL) break;
}
else // altrimenti
{
C_ATTRIB_BLOCK DABlock;
C_SELSET DABlockSet;
ads_name ent;
if (SelSet.copy(DABlockSet) != GS_GOOD || DABlockSet.intersectType(DA_BLOCK) != GS_GOOD)
break;
if (DABlockSet.entname(0, ent) == GS_BAD) { result = GS_GOOD; break; }
DABlock.set_ent_name(ent);
if (DABlock.get_values_attrib(VisValuesList) == GS_BAD) break;
}
// ciclo i valori visibili
while ((p = VisValuesList.nth(i++)) != NULL)
{
p = p->rbnext;
attrib_name = p->resval.rstring;
text = p->rbnext->resval.rstring;
if ((p_attrib = (C_ATTRIB *) p_attrib_list->search_name(attrib_name, FALSE)) != NULL)
{ // verifico se esiste l'attributo visibile in ColValues
// (nel caso in cui il blocco DA sia disallineato alla struttura del DB)
if ((p_attr = ColValues.CdrAssoc(attrib_name)) == NULL) continue;
// elimino eventuale prefisso e suffisso
text.removePrefixSuffix(p_attrib->GphPrefix.get_name(), p_attrib->GphSuffix.get_name(), GS_BAD);
// Verifico se ci sono dei valori codificati
UpdateableFromDA = true;
if (GS_CURRENT_WRK_SESSION)
{
// Carico la lista se non era già stata caricata
DescrFrom_TAB_REF.paste(GS_CURRENT_WRK_SESSION->get_pCacheClsAttribValuesList()->get_Value(p_attrib->name, ColValues, text,
GS_CURRENT_WRK_SESSION->get_PrjId(),
id.code, id.sub_code));
C_CACHE_ATTRIB_VALUES *pCacheAttribValues;
// verifico se si tratta di una lista di scelta condizionata
pCacheAttribValues = GS_CURRENT_WRK_SESSION->get_pCacheClsAttribValuesList()->get_pCacheAttribValues(p_attrib->name,
GS_CURRENT_WRK_SESSION->get_PrjId(),
id.code, id.sub_code);
if (pCacheAttribValues)
// se non aggiornabile da blocco DA (flag settato da get_pCacheAttribValues)
if (pCacheAttribValues->get_UpdateableFromDA() != 1)
UpdateableFromDA = false;
else
// verifico se il suo valore è associato ad una lista di scelta
// a 2 colonne
if (DescrFrom_TAB_REF.get_name())
// se valore è cambiato
if (gsc_strcmp(DescrFrom_TAB_REF.get_name(), p->resval.rstring) != 0)
{
Modified = TRUE;
gsc_RbSubst(p, DescrFrom_TAB_REF.get_name());
}
}
if (UpdateableFromDA == true) // se attributo aggiornabile da blocco DA
{
// se il valore è letto da TAB o REF
if (DescrFrom_TAB_REF.get_name())
{
if ((value = pProviderTypeList->DataValueStr2Rb(p_attrib->type,
DescrFrom_TAB_REF.get_name())) == NULL)
break;
}
else
{
// converto valore visibile in resbuf
// converto gli attributi numerici con lo standard (123.456 e NON con le impostazioni di window)
if (gsc_DBIsNumeric(p_attrib->ADOType) == GS_GOOD)
{
if (text.len() == 0)
{
if ((value = acutBuildList(RTNIL, 0)) == NULL)
{ GS_ERR_COD = eGSOutOfMem; break; }
}
else
if ((value = acutBuildList(RTREAL, text.tof(), 0)) == NULL)
{ GS_ERR_COD = eGSOutOfMem; break; }
}
else
if ((value = pProviderTypeList->DataValueStr2Rb(p_attrib->type,
text.get_name())) == NULL)
break;
}
if (gsc_equal(value, p_attr) == GS_BAD)
{ // valore cambiato
Modified = TRUE;
if (gsc_sostitutebuf(value, p_attr) == GS_BAD) break;
}
acutRelRb(value); value = NULL;
}
}
}
if (value) acutRelRb(value);
// se non si sa se devo effettuare il ricalcolo oppure no
if (!is_torecalc)
{ // se è cambiato almeno un attributo visibile ed esiste un attributo
// calcolato (solo valore) oppure da validare
if (Modified == GS_GOOD &&
(p_attrib_list->is_calculated() == GS_GOOD ||
p_attrib_list->is_validated() == GS_GOOD))
to_recalc = GS_GOOD;
}
else to_recalc = *is_torecalc;
if (to_recalc == GS_GOOD) // c'è almeno un attributo calcolato ed
// era cambiato almeno un attributo visibile
if (CalcValidData(ColValues, MODIFY, &SelSet) == GS_BAD) break; // validazione e ricalcolo dati
result = GS_GOOD;
}
while (0);
return result;
}
/*********************************************************/
/*.doc C_CLASS::updtoDA <external> */
/*+
Aggiorna i blocchi degli attributi di una scheda di un'entità.
Parametri:
C_SELSET &SelSet; Gruppo di selezione
C_RB_LIST &ColValues; lista colonna-valore
int ToSAVE_SS; Flag per aggiungere il linkset a GEOsimAppl::SAVE_SS per salvataggio
(default = GS_BAD)
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int C_CLASS::updtoDA(ads_name ent, C_RB_LIST &ColValues, int ToSAVE_SS)
{
C_SELSET SelSet;
SelSet.add(ent);
return updtoDA(SelSet, ColValues, ToSAVE_SS);
}
int C_CLASS::updtoDA(C_SELSET &SelSet, C_RB_LIST &ColValues, int ToSAVE_SS)
{
C_RB_LIST StrList;
C_ATTRIB_LIST *pAttribList = ptr_attrib_list();
C_ATTRIB *pAttrib;
C_ID *p_id = ptr_id();
C_STRING text;
// se non ha legame diretto con la grafica o non ha legame con tabella
if (!ptr_fas() || !pAttribList || pAttribList->is_visible() == GS_BAD)
return GS_GOOD;
// Formatto una lista di resbuf per le etichette
if (gsc_RbList2DAStrFmtRbList(pAttribList, ColValues, StrList, id.code, id.sub_code) == GS_BAD)
return GS_BAD;
if ((p_id->category == CAT_SIMPLEX || p_id->category == CAT_SUBCLASS) && p_id->type == TYPE_TEXT)
{
presbuf pValue;
long i;
ads_name entity;
if ((pAttrib = (C_ATTRIB *) pAttribList->getFirstVisibleAttrib()) == NULL)
{ GS_ERR_COD = eGSInvAttribName; return GS_BAD; }
if ((pValue = StrList.CdrAssoc(pAttrib->get_name())) == NULL)
{ GS_ERR_COD = eGSInvAttribName; return GS_BAD; }
// aggiorno n. aggregate su tutti gli oggetti
i = 0;
while (SelSet.entname(i++, entity) == GS_GOOD)
if (gsc_set_text(entity, pValue->resval.rstring) == GS_BAD) break;
}
else
{
C_ATTRIB_BLOCK DABlock;
if (DABlock.set_values_attrib(SelSet, StrList) == GS_BAD) return GS_BAD;
}
if (ToSAVE_SS == GS_GOOD) // Aggiungo in GEOsimAppl::SAVE_SS per salvataggio
if (gsc_addSS2savess(SelSet) == GS_BAD) return GS_BAD;
return GS_GOOD;
}
/*********************************************************/
/*.doc C_CLASS::SetVisibDA <external> */
/*+
Visualizza o nasconde i blocchi degli attributi di una o più entità.
Parametri:
C_SELSET &SelSet; Gruppo di selezione
int Mode; Modalità di visualizzazione; VISIBLE o INVISIBLE
int CounterToVideo; flag, se = GS_GOOD stampa a video il numero di entità che si
stanno elaborando (default = GS_BAD)
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
-*/
/*********************************************************/
int C_CLASS::SetVisibDA(ads_name ent, int Mode, int CounterToVideo)
{
C_SELSET SelSet;
SelSet.add(ent);
return SetVisibDA(SelSet, Mode);
}
int C_CLASS::SetVisibDA(C_SELSET &SelSet, int Mode, int CounterToVideo)
{
long SelSetLen, key, qty = 0;
ads_name entity;
int ToInsDABlk, ToUpd;
bool NotSaved = false;
C_SELSET PrivateSelSet, entSS;
C_RB_LIST ColValues;
C_SET_VISIB *pActiveSet = NULL;
C_ATTRIB_BLOCK DABlock;
C_DBCONNECTION *pTempConn;
C_STRING TempTableRef;
C_PREPARED_CMD_LIST TempOldCmdList;
C_STRING CompleteName;
get_CompleteName(CompleteName);
// "Applicazione dei criteri di visibilità delle etichette della classe <%s>"
C_STATUSBAR_PROGRESSMETER StatusBarProgressMeter(gsc_msg(1064), CompleteName.get_name());
if (gsc_check_op(opAttInvisib) == GS_BAD) return GS_BAD;
if (!GS_CURRENT_WRK_SESSION) { GS_ERR_COD = eGSNotCurrentSession; return GS_BAD; }
if (GS_CURRENT_WRK_SESSION->isReadyToUpd(&GS_ERR_COD) == GS_BAD) return GS_BAD;
// se si tratta di testo o non ha parte grafica o
// se non ha legame con tabella o non ci sono attributi visibili
if (id.type == TYPE_TEXT || !ptr_fas() || !ptr_info() ||
!ptr_attrib_list() || ptr_attrib_list()->is_visible() == GS_BAD)
return GS_GOOD;
// se non ci sono oggetti nel gruppo di selezione
if ((SelSetLen = SelSet.length()) == 0) return GS_GOOD;
SelSet.copy(PrivateSelSet);
if (Mode == VISIBLE && GEOsimAppl::ACTIVE_VIS_ATTRIB_SET)
// Cerco set di visibilità attivo (se esistente)
pActiveSet = GEOsimAppl::ACTIVE_VIS_ATTRIB_SET->get_VisibSet(this);
// preparo istruzione per l'inserimento di record nella tabella temp
if ((pTempConn = ptr_info()->getDBConnection(TEMP)) == NULL) return GS_BAD;
if (getTempTableRef(TempTableRef) == GS_BAD) return GS_BAD;
// Preparo i comandi di lettura dei dati della classe dal temp/old
if (prepare_data(TempOldCmdList) == GS_BAD) return GS_BAD;
if (CounterToVideo == GS_GOOD)
StatusBarProgressMeter.Init(SelSetLen);
while (PrivateSelSet.entname(0, entity) == GS_GOOD)
{
if (CounterToVideo == GS_GOOD)
StatusBarProgressMeter.Set_Perc((int) ((SelSetLen - PrivateSelSet.length()) * 100 / SelSetLen));
// leggo valore chiave e il gruppo di selezione
if (get_Key_SelSet(entity, &key, entSS) == GS_BAD)
{ PrivateSelSet.subtract_ent(entity); continue; }
// se entità non aggiornabile
if (is_updateableSS(key, entSS) == GS_BAD)
{ PrivateSelSet.subtract_ent(entity); continue; }
ToUpd = TRUE;
// se è un blocco attributi
if (gsc_is_DABlock(entity) == GS_GOOD)
{
// accendi/spegni singola scheda
DABlock.set_ent_name(entity);
if (DABlock.set_vis_attrib(Mode) == GS_BAD)
{ PrivateSelSet.subtract_ent(entity); continue; }
qty++;
PrivateSelSet.subtract_ent(entity);
// Se si deve accendere una scheda ed è attivo un set
if (Mode == VISIBLE && pActiveSet)
{
DABlock.set_ent_name(entity);
DABlock.apply_visib_set(pActiveSet->InvAttribList);
}
}
else // se è un oggetto principale
{
long ItemNum = 0;
ToInsDABlk = (Mode == VISIBLE) ? TRUE : FALSE;
// accendi/spegni tutte le schede
while (entSS.entname(ItemNum++, entity) == GS_GOOD)
{
// se è un blocco attributi
if (gsc_is_DABlock(entity) == GS_GOOD)
{
DABlock.set_ent_name(entity);
if (DABlock.set_vis_attrib(Mode) == GS_GOOD) qty++;
// Se si deve visualizzare una scheda
if (Mode == VISIBLE)
{
ToInsDABlk = FALSE; // C'era già un blocco DA
// Se è attivo un set di visualizzazione
if (pActiveSet)
{
DABlock.set_ent_name(entity);
DABlock.apply_visib_set(pActiveSet->InvAttribList);
}
}
}
PrivateSelSet.subtract_ent(entity);
}
// Se non c'era già un blocco e lo si vuole visualizzare
if (ToInsDABlk &&
(SelSetLen == 1 || GEOsimAppl::GLOBALVARS.get_InsPos() == AUTO))
// se la selezione riguarda una sola entità oppure se la posizione deve
// essere calcolata in modo automatico
if (gsc_add_da_block(entity) == GS_GOOD)
{ qty++; ToUpd = FALSE; }
}
// se non è stato inserito un blocco nuovo (che chiama già la ::upd_data)
if (ToUpd)
if (query_data(key, ColValues, &TempOldCmdList) == GS_BAD ||
upd_data(key, ColValues, ((C_PREPARED_CMD *) TempOldCmdList.get_head()),
&entSS) == GS_BAD)
{
// Aggiungo gli oggetti nel gruppo degli oggetti rifiutati
GEOsimAppl::REFUSED_SS.add(entity);
NotSaved = true;
}
}
if (CounterToVideo == GS_GOOD)
{
StatusBarProgressMeter.End(gsc_msg(1090)); // "Terminato."
if (Mode == INVISIBLE)
acutPrintf(gsc_msg(653), qty); // "\nNascoste %d scheda/e attributi."
else
acutPrintf(gsc_msg(377), qty); // "\nVisualizzate %d scheda/e attributi."
if (NotSaved)
acutPrintf(_T("\n%s"), gsc_msg(84)); // "Alcune entità di GEOsim non saranno salvate"
acutPrintf(GS_LFSTR);
}
return GS_GOOD;
}
//-----------------------------------------------------------------------//
////////////////// C_CLASS FINE ///////////////////////////////
////////////////// C_ATTRIB_BLOCK INIZIO ///////////////////////////////
//-----------------------------------------------------------------------//
/*********************************************************/
/*.doc C_ATTRIB_BLOCK::C_ATTRIB_BLOCK <internal> */
/*+
Questa funzione è il costruttore di C_ATTRIB_BLOCK
-*/
/*********************************************************/
C_ATTRIB_BLOCK::C_ATTRIB_BLOCK()
{
ads_point_clear(insert_point);
wcscpy(layer, DEFAULT_LAYER);
rotation = 0;
scale = 1;
h_text = 1;
wcscpy(style, DEFAULT_TEXTSTYLE);
color.setByLayer();
//vis = 0;
ads_name_clear(ent_name);
}
C_ATTRIB_BLOCK::C_ATTRIB_BLOCK(ads_name ent)
{
ads_point_clear(insert_point);
wcscpy(layer, DEFAULT_LAYER);
rotation = 0;
scale = 1;
h_text = 1;
color.setByLayer();
//vis = 0;
ads_name_set(ent, ent_name);
}
/*********************************************************/
/*.doc C_ATTRIB_BLOCK::~C_ATTRIB_BLOCK <internal> */
/*+
Questa funzione è il distruttore di C_ATTRIB_BLOCK
-*/
/*********************************************************/
C_ATTRIB_BLOCK::~C_ATTRIB_BLOCK()
{
}
/*****************************************************************************/
/*.doc C_ATTRIB_BLOCK::get_insert_point & set_insert_point <internal> */
/*+
Queste funzioni gestiscono il valore del punto di inserimento del blocco.
-*/
/*****************************************************************************/
int C_ATTRIB_BLOCK::get_insert_point(ads_point out)
{
ads_point_set(insert_point, out);
return GS_GOOD;
}
int C_ATTRIB_BLOCK::set_insert_point(ads_point in)
{
ads_point_set(in, insert_point);
return GS_GOOD;
}
/*****************************************************************************/
/*.doc C_ATTRIB_BLOCK::get_layer & set_layer <internal> */
/*+
Queste funzioni gestiscono il valore del piano del blocco.
-*/
/*****************************************************************************/
TCHAR *C_ATTRIB_BLOCK::get_layer()
{
return layer;
}
int C_ATTRIB_BLOCK::set_layer(const TCHAR *in)
{
if (in != NULL && (wcslen(in) < MAX_LEN_LAYERNAME))
gsc_strcpy(layer, in, MAX_LEN_LAYERNAME);
else
return GS_BAD;
return GS_GOOD;
}
/***********************************************************/
/*.doc C_ATTRIB_BLOCK::get_rotation & set_rotation <internal> */
/*+
Queste funzioni gestiscono il valore della rotazione del blocco (in gradi).
-*/
/*********************************************************/
ads_real C_ATTRIB_BLOCK::get_rotation()
{
return rotation;
}
int C_ATTRIB_BLOCK::set_rotation(ads_real in)
{
rotation = in;
return GS_GOOD;
}
/***********************************************************/
/*.doc C_ATTRIB_BLOCK::get_scale & set_scale <internal> */
/*+
Queste funzioni gestiscono il valore della scala del blocco.
-*/
/*********************************************************/
ads_real C_ATTRIB_BLOCK::get_scale()
{
return scale;
}
int C_ATTRIB_BLOCK::set_scale(ads_real in)
{
if (gsc_validscale(in) == GS_BAD) return GS_BAD;
scale = in;
return GS_GOOD;
}
/***********************************************************/
/*.doc C_ATTRIB_BLOCK::get_h_text & set_h_text <internal> */
/*+
Queste funzioni gestiscono il valore dell'altezza testo degli attributi.
-*/
/*********************************************************/
ads_real C_ATTRIB_BLOCK::get_h_text()
{
return h_text;
}
int C_ATTRIB_BLOCK::set_h_text(ads_real in)
{
if (gsc_validhtext(in) == GS_BAD) return GS_BAD;
h_text = in;
return GS_GOOD;
}
/***********************************************************/
/*.doc C_ATTRIB_BLOCK::get_text_style & set_text_style <internal> */
/*+
Queste funzioni gestiscono il valore dello stile testo degli attributi.
-*/
/*********************************************************/
TCHAR *C_ATTRIB_BLOCK::get_text_style()
{
return style;
}
int C_ATTRIB_BLOCK::set_text_style(TCHAR *in)
{
if (gsc_validtextstyle(in) == GS_BAD) return GS_BAD;
gsc_strcpy(style, in, MAX_LEN_TEXTSTYLENAME);
return GS_GOOD;
}
/*****************************************************************************/
/*.doc C_ATTRIB_BLOCK::get_color & set_color <internal> */
/*+
Queste funzioni gestiscono il valore del colore.
-*/
/*****************************************************************************/
void C_ATTRIB_BLOCK::get_color(C_COLOR &out)
{
out = color;
}
int C_ATTRIB_BLOCK::set_color(C_COLOR &in)
{
if (in.getColorMethod() == C_COLOR::None) { GS_ERR_COD = eGSInvalidColor; return GS_BAD; }
color = in;
return GS_GOOD;
}
/*********************************************************/
/*.doc C_ATTRIB_BLOCK::create <internal> */
/*+
Questa funzione crea l'oggetto blocco $T contenente gli attributi visibili.
Parametri:
C_RB_LIST &ColValues; Lista di valori da visualizzre nel blocco DA
es. ((<attr1><valore>)(<attr2><valore>)...)
ads_point InsPoint; Punto di inserimento del blocco DA
ads_real Rot; Rotazione del blocco DA in radianti (0 per default)
presbuf pDAParams; Lista di parametri per la definizione delle
caratteristiche grafiche degli attributi del
blocco DA. Lista così composta:
(40, Height, // altezza testi (1 per default)
51, Oblique, // angolo obliquo testi (0 per default)
7, TextStyle, // stile testo (opzionale)
8, LayerName, // nome del layer (opzionale)
71, GeneratFlag, // flag di generazione testo (opzionale)
72, HorizAlign, // allineamento orizzontale (opzionale)
74, VertAlign, // allineamento verticale (opzionale)
62, Color, // colore testo
0)) == NULL )
I seguenti parametri assumono i valori (vedi manuale di ACAD):
HorizAlign; 0 a sinistra (per default)
1 in centro
2 a destra
3 allineato
4 centrato
5 adattato
VertAlign; 0 linea di base (per default)
1 in basso
2 in centro
3 in alto
Oblique; Angolo obliquo (0 per default)
GeneratFlag; 0 normale (per default)
2 testo rovesciato
3 testo capovolto
Restituisce GS_GOOD in caso di successo altrimenti restituisce GS_BAD.
N.B.: Il punto di inserimento del blocco è in alto a sinistra e gli attributi
sono impilati in modo che l'attributo 1 sia quello più in alto.
-*/
/*********************************************************/
int C_ATTRIB_BLOCK::create(C_RB_LIST &ColValues, ads_point InsPoint,
ads_real Rot, presbuf pDAParams)
{
AcDbBlockTableRecord *pBlockTableRecord;
AcDbObjectId BlockId, AttId, newEntId;
AcDbBlockTable *pBlockTable;
AcGePoint3d pt(InsPoint[X], InsPoint[Y], InsPoint[Z]);
AcDbAttribute *pAttrib;
presbuf p_rb;
int index = 0;
short HorizAlign = 0, VertAlign = 0, GeneratFlag = 0;
int color = DEFAULT_COLOR;
TCHAR *TextStyle = NULL, *LayerName = NULL, *Value;
ads_point Point;
ads_real Height = 1, Oblique = 0, Dist, OffSet;
// altezza testi
if ((p_rb = gsc_rbsearch(40, pDAParams))) Height = p_rb->resval.rreal;
// angolo obliquo testi
if ((p_rb = gsc_rbsearch(51, pDAParams))) Oblique = p_rb->resval.rreal;
// stile testo
if ((p_rb = gsc_rbsearch(7, pDAParams))) TextStyle = p_rb->resval.rstring;
// nome del layer
if ((p_rb = gsc_rbsearch(8, pDAParams))) LayerName = p_rb->resval.rstring;
// flag di generazione testo
if ((p_rb = gsc_rbsearch(71, pDAParams))) GeneratFlag = (short) p_rb->resval.rint;
// flag di allineamento orizzontale
if ((p_rb = gsc_rbsearch(72, pDAParams))) HorizAlign = (short) p_rb->resval.rint;
// flag di allineamento verticale
if ((p_rb = gsc_rbsearch(74, pDAParams))) VertAlign = (short) p_rb->resval.rint;
// colore
if ((p_rb = gsc_rbsearch(62, pDAParams))) color = p_rb->resval.rint;
// Open the block table for read.
if (acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable,
AcDb::kForRead) != Acad::eOk)
return GS_BAD;
if (pBlockTable->getAt(_T("$T"), BlockId) != Acad::eOk)
{ pBlockTable->close(); GS_ERR_COD = eGSInvalidBlock; return GS_BAD; }
if (pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite) != Acad::eOk)
{ pBlockTable->close(); GS_ERR_COD = eGSAdsCommandErr; return GS_BAD; }
pBlockTable->close();
// creazione di una istanza del blocco "$T"
AcDbBlockReference *pBlkRef = new AcDbBlockReference;
pBlkRef->setBlockTableRecord(BlockId);
pBlkRef->setPosition(pt); // punto di inserimento
pBlkRef->setRotation(Rot); // rotazione (in radianti)
pBlkRef->setColorIndex(color); // colore
gsc_setLayer(pBlkRef, (LayerName) ? LayerName : _T("0")); // nome del layer
pBlockTableRecord->appendAcDbEntity(newEntId, pBlkRef);
pBlockTableRecord->close();
// Offset del 60% dell'altezza
OffSet = Height * 0.6;
Dist = Height + OffSet;
// calcolo il punto di inserimento del primo attributo (30% in su)
ads_point_set_from_AcGePoint3d(pt, Point);
acutPolar(Point, Rot + PI / 2, OffSet / 2, Point);
AcGePoint3d_set_from_ads_point(Point, pt);
// ciclo di inserimento degli attributi
while ((p_rb = ColValues.nth(index++)) != NULL)
{
Value = gsc_rb2str(p_rb->rbnext->rbnext);
pAttrib = new AcDbAttribute();
pAttrib->setPosition(pt); // punto di inserimento
gsc_setLayer(pAttrib, _T("0")); // nome layer, "0" in questo caso significa "DABLOCCO"
pAttrib->setTextString((Value) ? Value : GS_EMPTYSTR); // valore
if (Value) free(Value);
pAttrib->setHeight(Height); // altezza testo
pAttrib->setTag(p_rb->rbnext->resval.rstring); // etichetta
pAttrib->setRotation(Rot); // rotazione (in radianti)
pAttrib->setOblique(Oblique); // angolo obliquo testi
pAttrib->setColorIndex(0); // colore BYBLOCK
// stile testo (opzionale)
if (TextStyle) gsc_set_style_attrib(pAttrib, TextStyle);
gsc_set_ins_mode_attrib(pAttrib, &GeneratFlag, &HorizAlign, &VertAlign);
pBlkRef->appendAttribute(AttId, pAttrib);
pAttrib->close();
// calcolo il punto di inserimento del prossimo attributo
ads_point_set_from_AcGePoint3d(pt, Point);
acutPolar(Point, Rot - PI / 2, Dist, Point);
AcGePoint3d_set_from_ads_point(Point, pt);
}
pBlkRef->close();
acdbEntLast(ent_name); // non può fallire se "ads_entmake" non ha fallito
return GS_GOOD;
}
/*********************************************************/
/*.doc C_ATTRIB_BLOCK::insert <external> */
/*+
Inserisce un blocco per gli attributi con coordinate di inserimento
conosciute.
C_RB_LIST &ColValues; Lista di valori da visualizzre nel blocco DA
es. ((<attr1><valore>)(<attr2><valore>)...)
int cls; codice classe
int sub; codice sotto-classe
long Key; Valore chiave
TCHAR *file_ref_block; Path completa file dwg contenente il blocco di riferimento
(default NULL)
TCHAR *ref_block; Nome del blocco di riferimento (default NULL)
int modo; se MANUAL chiede : punto inserimento, scala e rotazione
(per default = MANUAL)
int num_el; n. di aggregazioni (per default = 2 -> 1 oggetto +
1 scheda attributi)
Restituisce GS_GOOD in caso di successo, GS_CAN in caso di annullamento
altrimenti restituisce GS_BAD.
N.B. Il colore di default degli attributi del blocco sono da blocco, il colore del
blocco per ora viene derivato dal colore del layer.
Questo, anche se è una incongruenza, torna utile in fase di stampa in cui lo
spessore del tratto è in funzione del colore e quindi si può cambiare il
colore degli attributi in modo agevole.
-*/
/*********************************************************/
int C_ATTRIB_BLOCK::insert(C_RB_LIST &ColValues, int cls, int sub, long Key,
TCHAR *file_ref_block, TCHAR *ref_block,
int modo, int num_el)
{
ads_point ins_attrib;
C_EED eed;
int result = GS_BAD;
C_LINK Link;
C_RB_LIST Descr;
C_CLASS *pClass;
C_RB_LIST StrList;
if (!GS_CURRENT_WRK_SESSION) { GS_ERR_COD = eGSNotCurrentSession; return GS_BAD; }
if (GS_CURRENT_WRK_SESSION->isReadyToUpd(&GS_ERR_COD) == GS_BAD) return GS_BAD;
if ((pClass = GS_CURRENT_WRK_SESSION->find_class(cls, sub)) == NULL) return GS_BAD;
// Formatto una lista di resbuf per i blocchi DA
if (gsc_RbList2DAStrFmtRbList(pClass->ptr_attrib_list(), ColValues, StrList, cls, sub) == GS_BAD)
return GS_BAD;
if (get_insert_point(ins_attrib) == GS_BAD) return GS_BAD;
if (modo == MANUAL) // chiedo il punto di inserimento del blocco
{
acedInitGet(RSG_NONULL, GS_EMPTYSTR);
// "\nPunto di inserimento della scheda: "
if ((result = acedGetPoint(NULL, gsc_msg(109), ins_attrib)) == RTERROR)
return GS_BAD;
if (result == RTCAN) return GS_CAN;
set_insert_point(ins_attrib);
}
if (get_insert_point(ins_attrib) == GS_BAD) return GS_BAD;
do
{
// Non considero il colore 62, get_color(),
if ((Descr << acutBuildList(8, get_layer(),
40, get_h_text(),
7, get_text_style(),
0)) == GS_BAD)
break;
// inserisco il blocco attributi visibili
if (create(StrList, ins_attrib, 0, Descr.get_head()) == GS_BAD)
break;
// lo collego alla tabella
if (Link.Set(ent_name, cls, sub, Key, INSERT) == GS_BAD) break;
if (modo == MANUAL)
{
if (GEOsimAppl::GLOBALVARS.get_InsXScale() == MANUAL) // impostazione manuale del fattore di scala
{
if ((result = gsc_ddscale_block(ent_name, get_scale(), &LAST_SCALE)) != GS_GOOD)
break;
}
else // scalo il blocco
if ((result = gsc_set_scale(ent_name, get_scale(), get_scale(), 1)) == GS_BAD) break;
if (GEOsimAppl::GLOBALVARS.get_InsRotaz() == MANUAL) // impostazione manuale della rotazione
{
if ((result = gsc_ddrotate_block(ent_name, get_rotation(), &LAST_ROT)) != GS_GOOD)
break;
}
else // ruoto il blocco senza controllo rotazione
if ((result = gsc_set_rotation(ent_name, gsc_grd2rad(get_rotation()),
GS_BAD)) == GS_BAD)
break;
}
else
{
// scalo il blocco
if ((result = gsc_set_scale(ent_name, get_scale(), get_scale(), 1)) == GS_BAD)
break;
// ruoto il blocco senza controllo rotazione
if ((result = gsc_set_rotation(ent_name, gsc_grd2rad(get_rotation()), GS_BAD)) == GS_BAD)
break;
}
// inserisco relazione all'oggetto grafico
eed.cls = cls;
eed.sub = sub;
eed.num_el = num_el;
eed.gs_id = Key;
if (eed.save(ent_name) == GS_BAD) break;
result = GS_BAD;
// se esiste il blocco di riferimento applico le variazioni impostate nel blocco
if (setfas_attrib(file_ref_block, ref_block) == GS_BAD) break;
// Se esiste un set di visibilità lo attivo