HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GR_SelectionAdapter.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: GR_SelectionAdapter.h ( GR Library, C++)
7  *
8  * COMMENTS:
9  * A utility class to allow working with GU_Selection and GA_Group
10  * objects more transparently. Much of the drawing code will draw
11  * the user selection (GU_Selection) and cook selection (GA_Group)
12  * the same way and this adapter class provides a common interface
13  * for both so we can share code more easily.
14  */
15 #ifndef GR_SelectionAdapter_h
16 #define GR_SelectionAdapter_h
17 
18 #include "GR_API.h"
19 
20 #include <GU/GU_Selection.h>
21 
22 class OP_Node;
23 class UT_StringArray;
24 class UT_BitArray;
25 
27 {
28 public:
30  myCookGroup(NULL) {}
31 
33  { myUserSelection = selection; }
34  void setCookSelection(const GU_Detail &gdp)
35  {
36  myUserSelection = gdp.cookSelection();
37  }
38  void setCookGroup(const GA_Group *group)
39  { myCookGroup = group; }
40 
41  bool isSet() const { return myUserSelection || myCookGroup; }
42 
43  // Returns whether what we consider to be the selection is potentially
44  // non-empty. The use of the word "potentially" highlights that some
45  // simplifying assumptions are made here and we may return true when
46  // the selection does end up being empty, but if we return false, the
47  // selection will always end up being empty.
48  bool isPotentiallyNonEmpty() const;
49 
51  {
52  if (myUserSelection)
53  return myUserSelection->classType();
54  if (myCookGroup)
55  return myCookGroup->classType();
56  return GA_GROUP_INVALID;
57  }
58 
59  const GA_PointGroup *points(const GU_Detail &gd) const;
60  const GA_PrimitiveGroup *primitives(const GU_Detail &gd) const;
61  const GA_VertexGroup *vertices(const GU_Detail &gd) const;
62  const GA_EdgeGroup *edges(const GU_Detail &gd) const;
63  const GA_BreakpointGroup *breakpoints(const GU_Detail &gd) const;
64 
65 private:
66  GU_SelectionHandle myUserSelection;
67  const GA_Group *myCookGroup;
68 };
69 
70 
71 #endif
GT_API const UT_StringHolder selection
GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glad.h:2676
void setCookGroup(const GA_Group *group)
GU_SelectionHandle cookSelection() const
Returns the current cook selection;.
GA_GroupType classType() const
#define GR_API
Definition: GR_API.h:10
UT_SharedPtr< GU_Selection > GU_SelectionHandle
GA_GroupType
An ordinal enum for the different types of groups in GA.
Definition: GA_Types.h:160
void setCookSelection(const GU_Detail &gdp)
void setUserSelection(GU_SelectionHandle selection)