-
Notifications
You must be signed in to change notification settings - Fork 141
/
opennurbs_compstat.cpp
954 lines (809 loc) · 23.1 KB
/
opennurbs_compstat.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
//
// Copyright (c) 1993-2022 Robert McNeel & Associates. All rights reserved.
// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
// McNeel & Associates.
//
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
// MERCHANTABILITY ARE HEREBY DISCLAIMED.
//
// For complete openNURBS copyright information see <http://www.opennurbs.org>.
//
////////////////////////////////////////////////////////////////
#include "opennurbs.h"
#if !defined(ON_COMPILING_OPENNURBS)
// This check is included in all opennurbs source .c and .cpp files to insure
// ON_COMPILING_OPENNURBS is defined when opennurbs source is compiled.
// When opennurbs source is being compiled, ON_COMPILING_OPENNURBS is defined
// and the opennurbs .h files alter what is declared and how it is declared.
#error ON_COMPILING_OPENNURBS must be defined when compiling opennurbs
#endif
//////////////////////////////////////////////////////////////////////////
//
// ON_ComponentStatus bits
//
#define SELECTED_BIT (0x01U)
#define SELECTED_PERSISTENT_BIT (0x02U)
#define SELECTED_MASK (SELECTED_BIT | SELECTED_PERSISTENT_BIT)
#define HIGHLIGHTED_BIT (0x04U)
#define LOCKED_BIT (0x08U)
#define HIDDEN_BIT (0x10U)
// A mark is a tool used in a wide variety of ways by calculations.
// Its value is unpredictable outside the scope of a specific code block.
// High quality calculations will save and restore mark state,
// but this is not always the case.
// This state is not saved in archives.
#define RUNTIME_MARK_BIT (0x20U)
#define DELETED_BIT (0x40U)
#define DAMAGED_BIT (0x80U)
// Do NOT include RUNTIME_MARK_BIT in ALL_MASK
#define ALL_MASK (SELECTED_MASK|HIGHLIGHTED_BIT|LOCKED_BIT|HIDDEN_BIT|DELETED_BIT|DAMAGED_BIT)
ON_ComponentState ON_ComponentStateFromUnsigned(
unsigned int state_as_unsigned
)
{
switch (state_as_unsigned)
{
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::Unset);
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::Clear);
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::NotSelected);
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::Selected);
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::SelectedPersistent);
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::NotHighlighted);
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::Highlighted);
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::NotHidden);
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::Hidden);
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::NotLocked);
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::Locked);
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::NotDamaged);
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::Damaged);
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::NotDeleted);
ON_ENUM_FROM_UNSIGNED_CASE(ON_ComponentState::Deleted);
}
return ON_ComponentState::Unset;
}
//enum STATE_FILTER : unsigned int
//{
// selected = 0,
// highlighted = 1,
// hidden = 2,
// locked = 4,
// damaged = 8
//};
ON_ComponentStatus::ON_ComponentStatus(
ON_ComponentState state
)
{
switch ( state)
{
case ON_ComponentState::Selected:
m_status_flags = SELECTED_BIT;
break;
case ON_ComponentState::SelectedPersistent:
m_status_flags = SELECTED_BIT | SELECTED_PERSISTENT_BIT;
break;
case ON_ComponentState::Highlighted:
m_status_flags = HIGHLIGHTED_BIT;
break;
case ON_ComponentState::Hidden:
m_status_flags = HIDDEN_BIT;
break;
case ON_ComponentState::Locked:
m_status_flags = LOCKED_BIT;
break;
case ON_ComponentState::RuntimeMarkSet:
m_status_flags = RUNTIME_MARK_BIT;
break;
case ON_ComponentState::Deleted:
m_status_flags = DELETED_BIT;
break;
case ON_ComponentState::Damaged:
m_status_flags = DAMAGED_BIT;
break;
default:
m_status_flags = 0U;
break;
}
}
bool ON_ComponentStatus::operator==(ON_ComponentStatus b)
{
return (m_status_flags&ALL_MASK) == (b.m_status_flags&ALL_MASK);
}
bool ON_ComponentStatus::operator!=(ON_ComponentStatus b)
{
return (m_status_flags&ALL_MASK) != (b.m_status_flags&ALL_MASK);
}
const ON_ComponentStatus ON_ComponentStatus::LogicalAnd(ON_ComponentStatus lhs, ON_ComponentStatus rhs)
{
ON_ComponentStatus x;
x.m_status_flags = (lhs.m_status_flags & rhs.m_status_flags);
return x;
}
const ON_ComponentStatus ON_ComponentStatus::LogicalOr(ON_ComponentStatus lhs, ON_ComponentStatus rhs)
{
ON_ComponentStatus x;
x.m_status_flags = (lhs.m_status_flags | rhs.m_status_flags);
return x;
}
bool ON_ComponentStatus::StatusCheck(
ON_ComponentStatus candidate,
ON_ComponentStatus status_pass,
ON_ComponentStatus status_fail
)
{
if (0 != ON_ComponentStatus::LogicalAnd(candidate, status_pass).m_status_flags)
return true;
if (0 != ON_ComponentStatus::LogicalAnd(candidate, status_fail).m_status_flags)
return false;
if (0 == status_fail.m_status_flags)
return true;
if (0 != status_pass.m_status_flags)
return false;
return true;
}
bool ON_ComponentStatus::IsClear() const
{
return (0 == (m_status_flags&ALL_MASK));
}
bool ON_ComponentStatus::IsNotClear() const
{
return (0 != (m_status_flags&ALL_MASK));
}
unsigned int ON_ComponentStatus::SetStatus(
ON_ComponentStatus status_to_copy
)
{
unsigned char s1 = (status_to_copy.m_status_flags&ALL_MASK);
if ( 0 == (SELECTED_BIT & s1) )
s1 &= ~SELECTED_PERSISTENT_BIT;
if (s1 != (m_status_flags&ALL_MASK))
{
const unsigned char mark = (m_status_flags&RUNTIME_MARK_BIT);
m_status_flags = (s1|mark);
return 1;
}
return 0;
}
unsigned int ON_ComponentStatus::SetStates(
ON_ComponentStatus states_to_set
)
{
unsigned char s1 = (m_status_flags&ALL_MASK);
unsigned char mask = (ALL_MASK & states_to_set.m_status_flags);
if (0 == (SELECTED_BIT & mask))
{
// no changes to s1's selected status
mask &= ~SELECTED_PERSISTENT_BIT;
}
else
{
// states_to_set specifies setting selected or selected_persistent.
//
// Clear the persistent bit on s1.
// If s1's SELECTED_PERSISTENT_BIT it is supposed to remain set,
// then mask's SELECTED_PERSISTENT_BIT is set and the
// s1 bit will get set by the s1 |= mask line below.
s1 &= ~SELECTED_PERSISTENT_BIT;
}
s1 |= mask;
if (s1 != (m_status_flags&ALL_MASK))
{
const unsigned char mark = (m_status_flags&RUNTIME_MARK_BIT);
m_status_flags = (s1|mark);
return 1;
}
return 0;
}
unsigned int ON_ComponentStatus::ClearStates(
ON_ComponentStatus states_to_clear
)
{
unsigned char s1 = (m_status_flags&ALL_MASK);
unsigned char mask = ~(ALL_MASK & states_to_clear.m_status_flags);
switch (SELECTED_MASK & mask)
{
case 0:
// states_to_clear.IsSelectedPersistent() is true.
// This means all selection states must be cleared from s1.
// We are in this case because 0 = (SELECTED_MASK & mask)
// so the s1 &= mask line below will remove any set selection
// states from s1.
break;
case SELECTED_PERSISTENT_BIT:
// states_to_clear.IsSelected() is true.
// states_to_clear.IsSelectedPersistent() is false.
// That is SELECTED_BIT = (SELECTED_MASK & states_to_clear.m_status_flags)
// If s1 is selected persistent, it must stay selected.
// If s1 is selected but not persistent, its selection state must be cleared.
if (SELECTED_MASK == (SELECTED_MASK & s1))
{
// s1 is selected persistent and must stay that way
mask |= SELECTED_MASK;
}
else
{
// s1 is not selected persistent and must end up not selected.
mask &= ~SELECTED_MASK;
}
break;
default:
// states_to_clear.IsSelected() is false.
// No changes to s1's selection state.
mask |= SELECTED_MASK;
}
s1 &= mask;
if (s1 != (m_status_flags & ALL_MASK))
{
// 29 Dec 2022, Mikko, RH-71974:
// This is wrong, selected and highlighted are separate states. A thing can be not selected but
// still highlighted.
/*
// If input was selected and highlighted,
// and output is not selected,
// and hightlight and not explictily cleared,
// then preserve highlight sync by auto-clearing highlight.
if ( 0 == (SELECTED_MASK & s1)
&& 0 != (SELECTED_MASK & m_status_flags)
&& 0 != (HIGHLIGHTED_BIT & m_status_flags)
&& 0 != (HIGHLIGHTED_BIT & s1)
)
{
// Input was selected and hightlighted,
// output is not selected.
// Clear highlight automatically.
s1 &= ~HIGHLIGHTED_BIT;
}
*/
// preserve value of runtime mark bit on m_status_flags
const unsigned char mark = (m_status_flags&RUNTIME_MARK_BIT);
// change m_status_flags to new value
m_status_flags = (s1|mark);
return 1;
}
return 0;
}
ON_ComponentState ON_ComponentStatus::SelectedState() const
{
switch ((m_status_flags & SELECTED_MASK))
{
case 0U:
return ON_ComponentState::NotSelected;
case SELECTED_BIT:
return ON_ComponentState::Selected;
case (SELECTED_BIT|SELECTED_PERSISTENT_BIT):
return ON_ComponentState::SelectedPersistent;
}
// error
return ON_ComponentState::NotSelected;
}
unsigned int ON_ComponentStatus::SetSelectedState(
bool bSelectedState,
bool bPersistent,
bool bSynchronizeHighlight
)
{
if (bSelectedState)
{
return
bPersistent
? SetSelectedState(ON_ComponentState::SelectedPersistent, bSynchronizeHighlight)
: SetSelectedState(ON_ComponentState::Selected, bSynchronizeHighlight)
;
}
return SetSelectedState(ON_ComponentState::NotSelected, bSynchronizeHighlight);
}
unsigned int ON_ComponentStatus::SetSelectedState(
ON_ComponentState selected_state,
bool bSynchronizeHighlight
)
{
bool bChanged = false;
switch (selected_state)
{
case ON_ComponentState::NotSelected:
if ( 0 != ClearStates(ON_ComponentStatus::Selected) )
bChanged = true;
if ( bSynchronizeHighlight && 0 != ClearStates(ON_ComponentStatus::Highlighted) )
bChanged = true;
break;
case ON_ComponentState::Selected:
if ( 0 != SetStates(ON_ComponentStatus::Selected) )
bChanged = true;
if ( bSynchronizeHighlight && 0 != SetStates(ON_ComponentStatus::Highlighted) )
bChanged = true;
break;
case ON_ComponentState::SelectedPersistent:
if ( 0 != SetStates(ON_ComponentStatus::SelectedPersistent) )
bChanged = true;
if ( bSynchronizeHighlight && 0 != SetStates(ON_ComponentStatus::Highlighted) )
bChanged = true;
break;
default:
break;
}
return bChanged ? 1U : 0U;
}
bool ON_ComponentStatus::IsSelected() const
{
return 0 != (m_status_flags & SELECTED_BIT);
}
bool ON_ComponentStatus::IsSelectedPersistent() const
{
return ( (SELECTED_BIT | SELECTED_PERSISTENT_BIT) == (m_status_flags & SELECTED_MASK) );
}
unsigned int ON_ComponentStatus::SetHighlightedState(
bool bIsHighlighted
)
{
return bIsHighlighted ? SetStates(ON_ComponentStatus::Highlighted) : ClearStates(ON_ComponentStatus::Highlighted);
}
bool ON_ComponentStatus::IsHighlighted() const
{
return 0 != (m_status_flags & HIGHLIGHTED_BIT);
}
bool ON_ComponentStatus::RuntimeMark() const
{
return ( 0 != (m_status_flags & RUNTIME_MARK_BIT) );
}
bool ON_ComponentStatus::IsMarked(
ON__UINT8 mark_bits
) const
{
return (0 == mark_bits) ? (0 != (m_status_flags & RUNTIME_MARK_BIT)) : (mark_bits == m_mark_bits);
}
bool ON_ComponentStatus::SetRuntimeMark(
bool bRuntimeMark
)
{
return bRuntimeMark ? SetRuntimeMark() : ClearRuntimeMark();
}
bool ON_ComponentStatus::SetRuntimeMark()
{
const unsigned char c = (m_status_flags | RUNTIME_MARK_BIT);
if (c != m_status_flags)
{
m_status_flags = c;
return true;
}
return false;
}
bool ON_ComponentStatus::ClearRuntimeMark()
{
const unsigned char c = (m_status_flags & ~RUNTIME_MARK_BIT);
if (c != m_status_flags)
{
m_status_flags = c;
return true;
}
return false;
}
ON__UINT8 ON_ComponentStatus::MarkBits() const
{
return m_mark_bits;
}
ON__UINT8 ON_ComponentStatus::SetMarkBits(ON__UINT8 bits)
{
const ON__UINT8 rc = m_mark_bits;
m_mark_bits = bits;
return rc;
}
unsigned int ON_ComponentStatus::SetHiddenState(
bool bIsHidden
)
{
return bIsHidden ? SetStates(ON_ComponentStatus::Hidden) : ClearStates(ON_ComponentStatus::Hidden);
}
bool ON_ComponentStatus::IsHidden() const
{
return 0 != (m_status_flags & HIDDEN_BIT);
}
unsigned int ON_ComponentStatus::SetLockedState(
bool bIsLocked
)
{
return bIsLocked ? SetStates(ON_ComponentStatus::Locked) : ClearStates(ON_ComponentStatus::Locked);
}
bool ON_ComponentStatus::IsLocked() const
{
return 0 != (m_status_flags & LOCKED_BIT);
}
unsigned int ON_ComponentStatus::SetDeletedState(
bool bIsDeleted
)
{
return bIsDeleted ? SetStates(ON_ComponentStatus::Deleted) : ClearStates(ON_ComponentStatus::Deleted);
}
bool ON_ComponentStatus::IsDeleted() const
{
return 0 != (m_status_flags & DELETED_BIT);
}
unsigned int ON_ComponentStatus::SetDamagedState(
bool bIsDamaged
)
{
return bIsDamaged ? SetStates(ON_ComponentStatus::Damaged) : ClearStates(ON_ComponentStatus::Damaged);
}
bool ON_ComponentStatus::IsDamaged() const
{
return 0 != (m_status_flags & DAMAGED_BIT);
}
bool ON_ComponentStatus::operator==(const ON_ComponentStatus& other) const
{
return m_status_flags == other.m_status_flags;
}
bool ON_ComponentStatus::operator!=(const ON_ComponentStatus& other) const
{
return m_status_flags != other.m_status_flags;
}
bool ON_ComponentStatus::AllEqualStates(
ON_ComponentStatus states_filter,
ON_ComponentStatus comparand
) const
{
unsigned char mask = (states_filter.m_status_flags & ALL_MASK);
mask &= ~SELECTED_PERSISTENT_BIT;
if (0 == mask)
return false;
unsigned char s1 = mask & m_status_flags;
unsigned char s2 = mask & comparand.m_status_flags;
return (s1 == s2);
}
bool ON_ComponentStatus::SomeEqualStates(
ON_ComponentStatus states_filter,
ON_ComponentStatus comparand
) const
{
unsigned char mask = (states_filter.m_status_flags & ALL_MASK);
mask &= ~SELECTED_PERSISTENT_BIT;
if (0 == mask)
return false;
unsigned char s1 = mask & m_status_flags;
unsigned char s2 = mask & comparand.m_status_flags;
if (0 != (s1&s2))
return true; // some set states are equal
s1 = mask & ~s1;
s2 = mask & ~s2;
if (0 != (s1&s2))
return true; // some clear states are equal
return false;
}
bool ON_ComponentStatus::NoEqualStates(
ON_ComponentStatus states_filter,
ON_ComponentStatus comparand
) const
{
unsigned char mask = (states_filter.m_status_flags & ALL_MASK);
mask &= ~SELECTED_PERSISTENT_BIT;
if (0 == mask)
return false;
unsigned char s1 = mask & m_status_flags;
unsigned char s2 = mask & comparand.m_status_flags;
return (mask == (s1 ^ s2));
}
ON_AggregateComponentStatus::ON_AggregateComponentStatus(const ON_AggregateComponentStatusEx& src)
{
memcpy(this, &src, sizeof(*this));
}
ON_AggregateComponentStatus& ON_AggregateComponentStatus::operator=(const ON_AggregateComponentStatusEx& src)
{
memcpy(this, &src, sizeof(*this));
return *this;
}
ON_AggregateComponentStatusEx::ON_AggregateComponentStatusEx(const ON_AggregateComponentStatus& src)
: ON_AggregateComponentStatus(src)
{
Internal_ChangeStatusSerialNumber();
}
ON_AggregateComponentStatusEx& ON_AggregateComponentStatusEx::operator=(const ON_AggregateComponentStatus& src)
{
ON_AggregateComponentStatus::operator=(src);
Internal_ChangeStatusSerialNumber();
return *this;
}
ON__UINT64 ON_AggregateComponentStatusEx::ComponentStatusSerialNumber() const
{
return m_component_status_serial_number;
}
void ON_AggregateComponentStatusEx::Internal_ChangeStatusSerialNumber()
{
m_component_status_serial_number = ON_NextContentSerialNumber();
}
bool ON_AggregateComponentStatus::ClearAllStates()
{
if (m_current <= 1)
{
unsigned char c = m_current;
unsigned int n = m_component_count;
*this = ON_AggregateComponentStatus::Empty;
m_current = c;
n = m_component_count;
return true;
}
return false;
}
bool ON_AggregateComponentStatusEx::ClearAllStates()
{
Internal_ChangeStatusSerialNumber();
return ON_AggregateComponentStatus::ClearAllStates();
}
bool ON_AggregateComponentStatus::ClearAggregateStatus(
ON_ComponentStatus states_to_clear
)
{
if (states_to_clear.m_status_flags == ON_ComponentStatus::AllSet.m_status_flags || 0 == m_component_count)
return ClearAllStates();
if (1 == m_current)
{
m_aggregate_status.ClearStates(states_to_clear);
const unsigned char s1 = m_aggregate_status.m_status_flags;
if (0 == (SELECTED_BIT & s1))
{
m_selected_count = 0;
m_selected_persistent_count = 0;
}
else if (0 == (SELECTED_PERSISTENT_BIT & s1))
{
m_selected_count -= m_selected_persistent_count;
m_selected_persistent_count = 0;
}
if (0 == (HIGHLIGHTED_BIT & s1))
m_highlighted_count = 0;
if (0 == (LOCKED_BIT & s1))
m_locked_count = 0;
if (0 == (HIDDEN_BIT & s1))
m_hidden_count = 0;
if (0 == (DAMAGED_BIT & s1))
m_damaged_count = 0;
return true;
}
return false;
}
bool ON_AggregateComponentStatusEx::ClearAggregateStatus(
ON_ComponentStatus states_to_clear
)
{
Internal_ChangeStatusSerialNumber();
return ON_AggregateComponentStatus::ClearAggregateStatus(states_to_clear);
}
bool ON_AggregateComponentStatus::IsEmpty() const
{
return (0 == m_current);
}
bool ON_AggregateComponentStatusEx::IsEmpty() const
{
return ON_AggregateComponentStatus::IsEmpty();
}
bool ON_AggregateComponentStatus::IsCurrent() const
{
return (1 == m_current);
}
bool ON_AggregateComponentStatusEx::IsCurrent() const
{
return ON_AggregateComponentStatus::IsCurrent();
}
void ON_AggregateComponentStatus::MarkAsNotCurrent()
{
if (2 != m_current)
{
*this = ON_AggregateComponentStatus::Empty;
m_current = 2;
}
}
void ON_AggregateComponentStatusEx::MarkAsNotCurrent()
{
Internal_ChangeStatusSerialNumber();
return ON_AggregateComponentStatus::MarkAsNotCurrent();
}
ON_ComponentStatus ON_AggregateComponentStatus::AggregateStatus() const
{
return m_aggregate_status;
}
ON_ComponentStatus ON_AggregateComponentStatusEx::AggregateStatus() const
{
return ON_AggregateComponentStatus::AggregateStatus();
}
unsigned int ON_AggregateComponentStatus::ComponentCount() const
{
return m_component_count;
}
unsigned int ON_AggregateComponentStatusEx::ComponentCount() const
{
return ON_AggregateComponentStatus::ComponentCount();
}
unsigned int ON_AggregateComponentStatus::SelectedCount() const
{
return m_selected_count;
}
unsigned int ON_AggregateComponentStatusEx::SelectedCount() const
{
return ON_AggregateComponentStatus::SelectedCount();
}
unsigned int ON_AggregateComponentStatus::SelectedPersistentCount() const
{
return m_selected_persistent_count;
}
unsigned int ON_AggregateComponentStatusEx::SelectedPersistentCount() const
{
return ON_AggregateComponentStatus::SelectedPersistentCount();
}
unsigned int ON_AggregateComponentStatus::HighlightedCount() const
{
return m_highlighted_count;
}
unsigned int ON_AggregateComponentStatusEx::HighlightedCount() const
{
return ON_AggregateComponentStatus::HighlightedCount();
}
unsigned int ON_AggregateComponentStatus::HiddenCount() const
{
return m_hidden_count;
}
unsigned int ON_AggregateComponentStatusEx::HiddenCount() const
{
return ON_AggregateComponentStatus::HiddenCount();
}
unsigned int ON_AggregateComponentStatus::LockedCount() const
{
return m_locked_count;
}
unsigned int ON_AggregateComponentStatusEx::LockedCount() const
{
return ON_AggregateComponentStatus::LockedCount();
}
unsigned int ON_AggregateComponentStatus::DamagedCount() const
{
return m_damaged_count;
}
unsigned int ON_AggregateComponentStatusEx::DamagedCount() const
{
return ON_AggregateComponentStatus::DamagedCount();
}
bool ON_AggregateComponentStatus::Add(
const ON_AggregateComponentStatus& aggregate_status
)
{
if (0 == m_current )
{
*this = aggregate_status;
return m_current <= 1;
}
if ( m_current >= 2 )
return false;
if ( 0 == aggregate_status.m_current )
return true;
if ( aggregate_status.m_current >= 2 )
{
MarkAsNotCurrent();
return false;
}
m_component_count += aggregate_status.m_component_count;
const unsigned char s1 = aggregate_status.m_aggregate_status.m_status_flags;
if ( 0 == s1 )
return true;
if (0 != (SELECTED_BIT & s1))
{
m_selected_count += aggregate_status.m_selected_count;
m_selected_persistent_count += aggregate_status.m_selected_persistent_count;
}
if ( 0 != (HIGHLIGHTED_BIT & s1) )
m_highlighted_count += aggregate_status.m_highlighted_count;
if ( 0 != (LOCKED_BIT & s1) )
m_locked_count += aggregate_status.m_locked_count;
if ( 0 != (HIDDEN_BIT & s1) )
m_hidden_count += aggregate_status.m_hidden_count;
if ( 0 != (DAMAGED_BIT & s1) )
m_damaged_count += aggregate_status.m_damaged_count;
m_aggregate_status.m_status_flags |= s1;
return true;
}
bool ON_AggregateComponentStatusEx::Add(
const ON_AggregateComponentStatus& aggregate_status
)
{
Internal_ChangeStatusSerialNumber();
return ON_AggregateComponentStatus::Add(aggregate_status);
}
bool ON_AggregateComponentStatus::Add(
ON_ComponentStatus component_status
)
{
if ( 0 == m_current )
m_current = 1;
else if ( 1 != m_current )
return false;
m_component_count++;
const unsigned char s1 = component_status.m_status_flags;
if ( 0 == s1 )
return true;
if (0 != (SELECTED_BIT & s1))
{
m_selected_count++;
if (0 != (SELECTED_PERSISTENT_BIT & s1))
m_selected_persistent_count++;
}
if ( 0 != (HIGHLIGHTED_BIT & s1) )
m_highlighted_count++;
if ( 0 != (LOCKED_BIT & s1) )
m_locked_count++;
if ( 0 != (HIDDEN_BIT & s1) )
m_hidden_count++;
if ( 0 != (DAMAGED_BIT & s1) )
m_damaged_count++;
m_aggregate_status.m_status_flags |= s1;
return true;
}
bool ON_AggregateComponentStatusEx::Add(
ON_ComponentStatus component_status
)
{
Internal_ChangeStatusSerialNumber();
return ON_AggregateComponentStatus::Add(component_status);
}
/////////////////////////////////////////////////////////////////
//
// ON_Object component status virtual interface
//
//
unsigned int ON_Object::ClearAllComponentStates() const
{
return ClearComponentStates(ON_ComponentStatus::AllSet);
}
// virtual
unsigned int ON_Object::ClearComponentStates(
ON_ComponentStatus states_to_clear
) const
{
return 0U;
}
//virtual
unsigned int ON_Object::GetComponentsWithSetStates(
ON_ComponentStatus states_filter,
bool bAllEqualStates,
ON_SimpleArray< ON_COMPONENT_INDEX >& components
) const
{
components.SetCount(0);
return 0U;
}
// virtual
unsigned int ON_Object::SetComponentStates(
ON_COMPONENT_INDEX component_index,
ON_ComponentStatus states_to_set
) const
{
return 0U;
}
// virtual
unsigned int ON_Object::ClearComponentStates(
ON_COMPONENT_INDEX component_index,
ON_ComponentStatus states_to_clear
) const
{
return 0U;
}
// virtual
unsigned int ON_Object::SetComponentStatus(
ON_COMPONENT_INDEX component_index,
ON_ComponentStatus status_to_copy
) const
{
return 0U;
}
// virtual
ON_AggregateComponentStatus ON_Object::AggregateComponentStatus() const
{
return ON_AggregateComponentStatus::Empty;
}
// virtual
void ON_Object::MarkAggregateComponentStatusAsNotCurrent() const
{
return;
}
// virtual
bool ON_Object::DeleteComponents(
const ON_COMPONENT_INDEX* ci_list,
size_t ci_count
)
{
return false;
}