HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_SelectionSet.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GU_SelectionSet.h ( GU Library, C++)
7  */
8 
9 #ifndef __GU_SelectionSet__
10 #define __GU_SelectionSet__
11 
12 #include "GU_API.h"
13 
14 #include <GA/GA_Types.h>
15 #include <UT/UT_NonCopyable.h>
16 #include <UT/UT_SharedPtr.h>
17 
18 class UT_JSONParser;
19 class UT_JSONWriter;
20 
23 
26 
27 /// A static set of unique selection types. Once created, the set remains
28 /// immutable. The class also stores the current active selection type for the
29 /// set. By default, the first group type by group type order will be set as
30 /// the active selection.
32 {
33 public:
34  /// Construct a new selection set. The mask should contain at least
35  /// one valid group type for selection. If the mask is invalid and doesn't
36  /// contain a valid selection group type, a point selection will be
37  /// chosen by default.
39 
40  /// Create a new selection set from a subset of an existing one.
42  const GU_SelectionSet &selection_set);
43 
44  /// Returns \c true if the set contains the requested selection
45  /// type.
46  bool hasType(GA_GroupType sel_type) const;
47 
48  /// Returns the entire group mask of selection types. This is the same
49  /// value that was passed into the constructor.
50  GA_GroupMaskType typeMask() const;
51 
52  /// Returns the selection handle of the given selection type. If the
53  /// set does not contain the given selection type, an empty
54  /// selection handle is returned.
56 
57  /// Returns the active selection type for this selection set. This
58  /// is the selection type that the GUI should consider first for display
59  /// and manipulation.
60  GA_GroupType activeSelectionType() const;
61 
62  /// Returns the selection handle of the currently active selection type.
63  GU_SelectionHandle activeSelection() const;
64 
65  /// Sets the active selection type for this selection set. If the wanted
66  /// selection type is not available, this function returns \c false, and
67  /// the active selection type remains unchanged.
68  bool setActiveSelectionType(GA_GroupType sel_type);
69 
70  /// Save the selection set to a json stream.
71  bool save(UT_JSONWriter &w) const;
72 
73  /// Load the selection set from a json stream. Will recycle existing
74  /// selection objects, if possible, or create new ones if needed.
75  bool load(UT_JSONParser &p);
76 
77 private:
78  GU_SelectionHandle mySelections[GA_GROUP_N];
79  GA_GroupType myActiveSelection;
80 };
81 
82 #endif // __GU_SelectionSet__
GT_API const UT_StringHolder selection
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:87
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
UT_SharedPtr< GU_SelectionSet > GU_SelectionSetHandle
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
#define GU_API
Definition: GU_API.h:14
UT_SharedPtr< GU_Selection > GU_SelectionHandle
GA_GroupType
An ordinal enum for the different types of groups in GA.
Definition: GA_Types.h:160
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
GA_GroupMaskType
Definition: GA_Types.h:174