HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LOP_Network.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: LOP Library (C++)
7  *
8  * COMMENTS: LOP manager node for other network types.
9  *
10  */
11 
12 #ifndef __LOP_Network_h__
13 #define __LOP_Network_h__
14 
15 #include "LOP_API.h"
16 #include "LOP_Node.h"
17 #include "LOP_SelectionRule.h"
19 #include <HUSD/HUSD_PostLayers.h>
20 #include <HUSD/HUSD_FindPrims.h>
21 #include <HUSD/HUSD_LoadMasks.h>
22 #include <HUSD/HUSD_Overrides.h>
23 #include <HUSD/HUSD_Utils.h>
24 #include <GU/GU_SelectType.h>
25 #include <UT/UT_StringMap.h>
26 
27 #define LOP_EXPANSION_DATA_BLOCK_TYPE "expansion"
28 #define LOP_OVERRIDES_DATA_BLOCK_TYPE "overrides"
29 #define LOP_LOADMASKS_DATA_BLOCK_TYPE "loadmasks"
30 #define LOP_POSTLAYERS_DATA_BLOCK_TYPE "postlayers"
31 #define LOP_ONLOAD_DATA_BLOCK_PREFIX "__onload__."
32 
34 {
39 };
40 
42 {
43 public:
44  // Standard OP_Network stuff:
45  static const char *theChildTableName;
46  static OP_Node *myConstructor(OP_Network *net, const char *name,
47  OP_Operator *entry);
48  static PRM_Template myTemplateList[];
49 
51  UT_String &assetpath) override;
52  void opChanged(OP_EventType reason,
53  void *data = 0) override;
54  void onCreated() override;
55  int isSubNetwork(bool includemanagementops)
56  const override;
57  OP_Node *getDisplayNodePtr() override;
58  void childFlagChange(OP_Node *nodeptr) override;
59  LOP_Node *getViewerLop() override;
60 
62  { return myOverrides; }
63  HUSD_OverridesPtr editableOverrides();
64  void resetOverrides();
65 
67  { return myPostLayers; }
68  HUSD_PostLayersPtr editablePostLayers();
69  void resetPostLayers();
70 
72  { return myExpansionState; }
74  { return myExpansionState; }
75 
76  const HUSD_LoadMasks &loadMasks() const
77  { return myLoadMasks; }
78  void setLoadMasks(const HUSD_LoadMasks &load_masks);
79 
80  bool setStateFromDataBlock(
81  const UT_StringRef &blockname,
82  const char *blocktype = nullptr);
83  bool saveExpansionState(
84  const UT_StringHolder &expansionname,
85  const HUSD_ExpansionState &expansion);
86  bool saveOverrides(
87  const UT_StringHolder &overridesname,
88  const HUSD_Overrides &overrides);
89  bool savePostLayers(
90  const UT_StringHolder &postlayersname,
91  const HUSD_PostLayers &postlayers);
92  bool saveLoadMasks(
93  const UT_StringHolder &load_masks_name,
94  const HUSD_LoadMasks &load_masks);
95 
96  const HUSD_PathSet &selection() const
97  { return mySelection; }
99  { return mySelectionLayerId; }
101  { return mySelectionCurrentPrim; }
103  { return mySelectionWithInstanceIds; }
104  // Return true if the selection is actually changed by this call.
105  // If not, we do not send the OP_DATA_USERSELECTION_CHANGED event.
106  bool modifySelection(const HUSD_PathSet &paths,
107  const HUSD_InstanceSelection &
108  paths_with_instance_ids,
109  const UT_StringHolder *layerid =
110  nullptr,
111  const UT_StringHolder *currentprim =
112  nullptr,
113  GU_SelectionRule rule =
116  { return mySelectionVersionId; }
117 
118  const LOP_SelectionRuleMap &selectionRules() const;
119  void clearSelectionRules();
120  void removeSelectionRule(
121  const UT_StringHolder &name);
122  void addSelectionRule(
123  const UT_StringHolder &name,
124  const LOP_SelectionRule &collection);
125 
126  void saveSelectionRules(std::ostream &os) const;
127  bool loadSelectionRules(UT_IStream &is);
128 
129  void getPinnedPrimitives(
130  UT_String &pinnedprims) const;
131  void setPinnedPrimitives(
132  const UT_StringRef &pinnedprims);
133 
134  void getRenderGallerySource(
135  UT_String &source) const;
136  void setRenderGallerySource(
137  const UT_StringRef &source);
138 
139  static UT_StringHolder makeValidSelectionRuleName(
140  const UT_StringHolder &name);
141 
142 protected:
143  LOP_Network(OP_Network *parent, const char *name,
144  OP_Operator *entry);
145  ~LOP_Network() override;
146 
147  void clearAndDestroy() override;
148 
149  OP_ERROR cookMyLop(OP_Context &context) override;
150 
151  OP_ERROR save(std::ostream &os, const OP_SaveFlags &flags,
152  const char *pathPrefix,
153  const UT_String &name_override =
154  UT_String()) override;
155  bool load(UT_IStream &is, const char *extension,
156  const char *path=0) override;
157  void loadFinished() override;
158 
159 private:
160  static void forceRecookAllChildren(LOP_Node *root, bool firstcall);
161 
162  HUSD_ExpansionState myExpansionState;
163  HUSD_LoadMasks myLoadMasks;
164  HUSD_PostLayersPtr myPostLayers;
165  HUSD_OverridesPtr myOverrides;
166  HUSD_PathSet mySelection;
167  UT_StringHolder mySelectionLayerId;
168  UT_StringHolder mySelectionCurrentPrim;
169  HUSD_InstanceSelection mySelectionWithInstanceIds;
170  LOP_SelectionRuleMap mySelectionRuleMap;
171  int mySelectionVersionId;
172  UT_StringHolder myCachedResolverContextAssetPath;
173 };
174 
175 #endif
virtual bool getResolverContextAssetPath(UT_String &assetpath)
const HUSD_InstanceSelection & selectionWithInstanceIds() const
Definition: LOP_Network.h:102
void childFlagChange(OP_Node *nodeptr) override
virtual int isSubNetwork(bool includemanagementops) const
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
void onCreated() override
Overriden in VOPs.
UT_ErrorSeverity
Definition: UT_Error.h:25
const HUSD_ExpansionState & expansionState() const
Definition: LOP_Network.h:71
static const char * theChildTableName
Definition: LOP_Network.h:45
void saveOverrides(std::ostream &os)
GLuint const GLchar * name
Definition: glcorearb.h:786
const HUSD_PathSet & selection() const
Definition: LOP_Network.h:96
int getSelectionVersionId() const
Definition: LOP_Network.h:115
HUSD_ConstOverridesPtr overrides() const
Definition: LOP_Network.h:61
const HUSD_LoadMasks & loadMasks() const
Definition: LOP_Network.h:76
GU_SelectionRule
Definition: GU_SelectType.h:40
const UT_StringHolder & selectionLayerId() const
Definition: LOP_Network.h:98
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
virtual void loadFinished()
#define LOP_API
Definition: LOP_API.h:10
GLbitfield flags
Definition: glcorearb.h:1596
OP_Node * getDisplayNodePtr() override
virtual OP_ERROR cookMyLop(OP_Context &context)=0
void clearAndDestroy() override
void opChanged(OP_EventType reason, void *data=0) override
HUSD_ExpansionState & editableExpansionState()
Definition: LOP_Network.h:73
OP_EventType
Definition: OP_Value.h:22
virtual LOP_Node * getViewerLop()
LOP_NetworkCustomData
Definition: LOP_Network.h:33
HUSD_ConstPostLayersPtr postLayers() const
Definition: LOP_Network.h:66
bool load(UT_IStream &is, const char *ext="", const char *path=0) override
virtual OP_ERROR save(std::ostream &os, const OP_SaveFlags &flags, const char *path_prefix="", const UT_String &name_override=UT_String())
OIIO_UTIL_API std::string extension(string_view filepath, bool include_dot=true) noexcept
const UT_StringHolder & selectionCurrentPrim() const
Definition: LOP_Network.h:100
Definition: format.h:895
GLenum const void * paths
Definition: glew.h:13872