This repository has been archived by the owner on May 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathopennurbs_compstat.h
551 lines (463 loc) · 13.7 KB
/
opennurbs_compstat.h
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
/* $NoKeywords: $ */
/*
//
// Copyright (c) 1993-2014 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>.
//
////////////////////////////////////////////////////////////////
*/
//////////////////////////////////////////////////////////////////////////
//
// ON_ComponentState and ON_ComponentStatus
//
#pragma region RH_C_SHARED_ENUM [ON_ComponentState] [Rhino.Geometry.ComponentState] [internal:byte]
///<summary><para>Provides a set of values describing component state.</para>
///<para>This is not a bit field.</para>
///<para>Some of these values are mutually exclusive and should not be combined.</para></summary>
enum class ON_ComponentState : unsigned char
{
///<summary>Not a valid status.</summary>
Unset = 0,
///<summary>This is a default component state.</summary>
Clear = 1,
///<summary>This is a default component state, but not selected.</summary>
NotSelected = 2,
///<summary>This component is selected.</summary>
Selected = 3,
///<summary>This component is selected persistently.</summary>
SelectedPersistent = 4,
///<summary>This is a default component state, but not highlighted.</summary>
NotHighlighted = 5,
///<summary>This component is highlighted.</summary>
Highlighted = 6,
///<summary>This is a default component state, but not hidden.</summary>
NotHidden = 7,
///<summary>This component is hidden.</summary>
Hidden = 8,
///<summary>This is a default component state, but not locked.</summary>
NotLocked = 9,
///<summary>This component is locked.</summary>
Locked = 10,
///<summary>This is a default component state, but not damaged.</summary>
NotDamaged = 11,
///<summary>This component is damaged.</summary>
Damaged = 12,
///<summary>This component is not deleted.</summary>
NotDeleted = 13,
///<summary>This component is deleted.</summary>
Deleted = 14,
///<summary>This runtime mark is clear.</summary>
RuntimeMarkClear = 15,
///<summary>This runtime mark is set.</summary>
RuntimeMarkSet = 16
};
#pragma endregion
ON_DECL
ON_ComponentState ON_ComponentStateFromUnsigned(
unsigned int state_as_unsigned
);
class ON_CLASS ON_ComponentStatus
{
public:
static const ON_ComponentStatus NoneSet;
static const ON_ComponentStatus Selected;
static const ON_ComponentStatus SelectedPersistent;
static const ON_ComponentStatus Highlighted;
static const ON_ComponentStatus Hidden;
static const ON_ComponentStatus Locked;
static const ON_ComponentStatus Deleted;
static const ON_ComponentStatus Damaged;
static const ON_ComponentStatus AllSet;
ON_ComponentStatus() = default;
~ON_ComponentStatus() = default;
ON_ComponentStatus(const ON_ComponentStatus&) = default;
ON_ComponentStatus& operator=(const ON_ComponentStatus&) = default;
/*
Description:
Constructs a status with the specified state set.
*/
ON_ComponentStatus(
ON_ComponentState state
);
bool operator==(ON_ComponentStatus);
bool operator!=(ON_ComponentStatus);
/*
Returns:
True if every setting besides runtime mark is 0 or false.
Ignores the runtime mark state.
Remarks:
The runtime mark setting is ignored by IsClear().
*/
bool IsClear() const;
/*
Description:
Sets *this = status_to_copy and returns 1 if a state setting changed.
Returns:
1 if status changed.
0 if status did not change.
Remarks:
The runtime mark setting cannot be changed using SetStatus().
*/
unsigned int SetStatus(
ON_ComponentStatus status_to_copy
);
/*
Description:
If a state is set in states_to_set, the same state is set in "this".
Parameters:
states_to_set - [in]
Returns:
1 if status changed.
0 if status did not change.
Remarks:
The runtime mark setting cannot be changed using SetStates().
*/
unsigned int SetStates(
ON_ComponentStatus states_to_set
);
/*
Description:
If a state is set in states_to_clear, the same state is cleared in "this".
Parameters:
states_to_clear - [in]
Returns:
1 if status changed.
0 if status did not change.
Remarks:
The runtime mark setting cannot be changed using ClearStates().
*/
unsigned int ClearStates(
ON_ComponentStatus states_to_clear
);
//////////////////////////////////////////////////////////////////////////
//
// RuntimeMark
//
bool RuntimeMark() const;
unsigned int SetRuntimeMark(
bool bRuntimeMark
);
unsigned int SetRuntimeMark();
unsigned int ClearRuntimeMark();
//////////////////////////////////////////////////////////////////////////
//
// Selection
//
/*
Returns:
ON_ComponentState::not_selected,
ON_ComponentState::Selected or
ON_ComponentState::Selected_pesistent.
*/
ON_ComponentState SelectedState() const;
/*
Returns:
1 if status changed.
0 if status did not change.
*/
unsigned int SetSelectedState(
bool bSelectedState,
bool bPersistent,
bool bSynchronizeHighlight
);
unsigned int SetSelectedState(
ON_ComponentState selected_state,
bool bSynchronizeHighlight
);
/*
Returns:
false
The selection state is ON_ComponentState::not_selected.
true
The selection state is ON_ComponentState::Selected
or ON_ComponentState::Selected_pesistent.
*/
bool IsSelected() const;
/*
Returns:
false
The selection state is ON_ComponentState::not_selected.
true
The selection state is ON_ComponentState::Selected_pesistent.
*/
bool IsSelectedPersistent() const;
//////////////////////////////////////////////////////////////////////////
//
// Highlighted
//
/*
Returns:
1 if status changed.
0 if status did not change.
*/
unsigned int SetHighlightedState(
bool bIsHighlighed
);
/*
Returns:
false if not highlighted.
true otherwise.
*/
bool IsHighlighted() const;
//////////////////////////////////////////////////////////////////////////
//
// Hidden
//
/*
Returns:
1 if status changed.
0 if status did not change.
*/
unsigned int SetHiddenState(
bool bIsHidden
);
/*
Returns:
false if not hidden.
true otherwise.
(ON_ComponentStatus::HIDDEN_STATE::not_hidden != HiddenState())
*/
bool IsHidden() const;
//////////////////////////////////////////////////////////////////////////
//
// Locked
//
/*
Returns:
1 if status changed.
0 if status did not change.
*/
unsigned int SetLockedState(
bool bIsLocked
);
/*
Returns:
false if not locked.
true otherwise.
(ON_ComponentStatus::LOCKED_STATE::not_locked != LockedState())
*/
bool IsLocked() const;
//////////////////////////////////////////////////////////////////////////
//
// Deleted
//
/*
Returns:
1 if status changed.
0 if status did not change.
*/
unsigned int SetDeletedState(
bool bIsDeleted
);
/*
Returns:
false if not hidden.
true otherwise.
(ON_ComponentStatus::DELETED_STATE::not_deleted != DeletedState())
*/
bool IsDeleted() const;
//////////////////////////////////////////////////////////////////////////
//
// Damaged
//
/*
Returns:
1 if status changed.
0 if status did not change.
*/
unsigned int SetDamagedState(
bool bIsDamaged
);
/*
Returns:
false if not damaged.
true otherwise.
(ON_ComponentStatus::DAMAGED_STATE::not_damaged != DamagedState())
*/
bool IsDamaged() const;
//////////////////////////////////////////////////////////////////////////
//
// Checking multiple state values efficently
//
bool operator==(const ON_ComponentStatus&) const;
bool operator!=(const ON_ComponentStatus&) const;
/*
Parameters:
states_filter - [in]
If no states are specified, then false is returned.
comparand - [in]
If a state is set in states_filter, the corresponding state
in "this" and comparand will be tested.
Returns:
True if every tested state in "this" and comparand are identical.
Remarks:
For the purposes of this test, ON_ComponentState::Selected
and ON_ComponentState::SelectedPersistent are considered equal.
*/
bool AllEqualStates(
ON_ComponentStatus states_filter,
ON_ComponentStatus comparand
) const;
/*
Parameters:
states_filter - [in]
If no states are specified, then false is returned.
comparand - [in]
If a state is set in states_filter, the corresponding state
in "this" and comparand will be tested.
Returns:
True if at least one tested state in "this" and comparand are identical.
Remarks:
For the purposes of this test, ON_ComponentState::Selected
and ON_ComponentState::SelectedPersistent are considered equal.
*/
bool SomeEqualStates(
ON_ComponentStatus states_filter,
ON_ComponentStatus comparand
) const;
/*
Parameters:
states_filter - [in]
If no states are specified, then false is returned.
comparand - [in]
If a state is set in states_filter, the corresponding state
in "this" and comparand will be tested.
Returns:
True if every tested state in "this" and comparand are different.
Remarks:
For the purposes of this test, ON_ComponentState::Selected
and ON_ComponentState::SelectedPersistent are considered equal.
*/
bool NoEqualStates(
ON_ComponentStatus states_filter,
ON_ComponentStatus comparand
) const;
private:
friend class ON_AggregateComponentStatus;
unsigned char m_status_flags = 0U;
};
//////////////////////////////////////////////////////////////////////////
//
// ON_AggregateComponentStatus
//
//
class ON_CLASS ON_AggregateComponentStatus
{
public:
static const ON_AggregateComponentStatus Empty;
static const ON_AggregateComponentStatus NotCurrent;
ON_AggregateComponentStatus() = default;
~ON_AggregateComponentStatus() = default;
ON_AggregateComponentStatus(const ON_AggregateComponentStatus&) = default;
ON_AggregateComponentStatus& operator=(const ON_AggregateComponentStatus&) = default;
/*
Description:
Sets all states to clear.
Marks status as current.
Does not change compoent count
Returns
true if successful.
false if information is not current and ClearAllStates() failed.
*/
bool ClearAllStates();
/*
Description:
Sets all states specified by states_to_clear to clear.
Does not change current mark.
Does not change compoent count.
Returns
true if successful.
false if information is not current and ClearAggregateStatus() failed.
*/
bool ClearAggregateStatus(
ON_ComponentStatus states_to_clear
);
/*
Description:
Add the status information in component_status to this aggregate status.
Parameters:
component_status - [in]
Returns:
true if successful.
false if information is not current and Add failed.
*/
bool Add(
ON_ComponentStatus component_status
);
/*
Description:
Add the status information in aggregate_status to this aggregate status.
Parameters:
aggregate_status - [in]
Returns:
true if successful.
false if information is not current and Add failed.
*/
bool Add(
const ON_AggregateComponentStatus& aggregate_status
);
/*
Returns:
true if this is empty
false if not empty.
*/
bool IsEmpty() const;
/*
Returns:
true if the information is current (valid, up to date, ...).
false if the information is not current.
Remarks:
If the information is not current, all counts are zero and states are clear.
*/
bool IsCurrent() const;
/*
Description:
Mark the information as not current.
Erases all information.
*/
void MarkAsNotCurrent();
ON_ComponentStatus AggregateStatus() const;
unsigned int ComponentCount() const;
/*
Returns:
Number of compoents that are selected or persistently selected.
*/
unsigned int SelectedCount() const;
/*
Returns:
Number of compoents that are persistently selected.
*/
unsigned int SelectedPersistentCount() const;
unsigned int HighlightedCount() const;
unsigned int HiddenCount() const;
unsigned int LockedCount() const;
unsigned int DamagedCount() const;
private:
// a bitwise or of all component status settings
ON_ComponentStatus m_aggregate_status = ON_ComponentStatus::NoneSet;
private:
unsigned char m_current = 0; // 0 = empty, 1 = current, 2 = dirty
unsigned short m_reserved2 = 0;
private:
// number of components
unsigned int m_component_count = 0;
// number of selected components (includes persistent and non persistent)
unsigned int m_selected_count = 0;
// number of selected components
unsigned int m_selected_persistent_count = 0;
// number of highlighted components
unsigned int m_highlighted_count = 0;
// number of hidden components
unsigned int m_hidden_count = 0;
// number of locked components
unsigned int m_locked_count = 0;
// number of damaged components
unsigned int m_damaged_count = 0;
};