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;
54  resolverstrings) override;
55  bool getVariantSelectionFallbacks(
57  fallbacks);
58 
59  void opChanged(OP_EventType reason,
60  void *data = 0) override;
61  void onCreated() override;
62  int isSubNetwork(bool includemanagementops)
63  const override;
64  OP_Node *getDisplayNodePtr() override;
65  void childFlagChange(OP_Node *nodeptr) override;
66  LOP_Node *getViewerLop() override;
67 
69  { return myOverrides; }
70  HUSD_OverridesPtr editableOverrides();
71  void resetOverrides();
72 
74  { return myPostLayers; }
75  HUSD_PostLayersPtr editablePostLayers();
76  void resetPostLayers();
77 
79  { return myExpansionState; }
81  { return myExpansionState; }
82 
83  const HUSD_LoadMasks &loadMasks() const
84  { return myLoadMasks; }
85  void setLoadMasks(const HUSD_LoadMasks &load_masks);
86 
87  bool setStateFromDataBlock(
88  const UT_StringRef &blockname,
89  const char *blocktype = nullptr);
90  bool saveExpansionState(
91  const UT_StringHolder &expansionname,
92  const HUSD_ExpansionState &expansion);
93  bool saveOverrides(
94  const UT_StringHolder &overridesname,
95  const HUSD_Overrides &overrides);
96  bool savePostLayers(
97  const UT_StringHolder &postlayersname,
98  const HUSD_PostLayers &postlayers);
99  bool saveLoadMasks(
100  const UT_StringHolder &load_masks_name,
101  const HUSD_LoadMasks &load_masks);
102 
103  const HUSD_PathSet &selection() const
104  { return mySelection; }
106  { return mySelectionCurrentPrim; }
108  { return mySelectionWithInstanceIds; }
109  // Return true if the selection is actually changed by this call.
110  // If not, we do not send the OP_DATA_USERSELECTION_CHANGED event.
111  bool modifySelection(const HUSD_PathSet &paths,
112  const HUSD_InstanceSelection &
113  paths_with_instance_ids,
114  const UT_StringHolder *currentprim =
115  nullptr,
116  GU_SelectionRule rule =
119  { return mySelectionVersionId; }
120 
121  const LOP_SelectionRuleMap &selectionRules() const;
122  void clearSelectionRules();
123  void removeSelectionRule(
124  const UT_StringHolder &name);
125  void addSelectionRule(
126  const UT_StringHolder &name,
127  const LOP_SelectionRule &collection);
128 
129  void saveSelectionRules(std::ostream &os) const;
130  bool loadSelectionRules(UT_IStream &is);
131 
132  void getPinnedPrimitives(
133  UT_String &pinnedprims) const;
134  void setPinnedPrimitives(
135  const UT_StringRef &pinnedprims);
136 
137  // Key strings we use during snapshot network serialisation
141 
142  // When we take a render gallery snapshot, we also save the state of the
143  // LOP network. This method encapsulates saving this data.
144  void saveNetworkForSnapshot(std::ostream &os);
145 
146  UT_StringHolder getRenderGallerySource() const;
147  bool saveRenderGalleryToDisk();
148 
149  static UT_StringHolder makeValidSelectionRuleName(
150  const UT_StringHolder &name);
151 
152 protected:
153  LOP_Network(OP_Network *parent, const char *name,
154  OP_Operator *entry);
155  ~LOP_Network() override;
156 
157  void clearAndDestroy() override;
158 
159  OP_ERROR cookMyLop(OP_Context &context) override;
160 
161  OP_ERROR save(std::ostream &os, const OP_SaveFlags &flags,
162  const char *pathPrefix,
163  const UT_String &name_override =
164  UT_String()) override;
165  bool load(UT_IStream &is, const char *extension,
166  const char *path=0) override;
167  void loadFinished() override;
168 
169 private:
170  static void forceRecookAllChildren(LOP_Node *root, bool firstcall);
171 
172  HUSD_ExpansionState myExpansionState;
173  HUSD_LoadMasks myLoadMasks;
174  HUSD_PostLayersPtr myPostLayers;
175  HUSD_OverridesPtr myOverrides;
176  HUSD_PathSet mySelection;
177  UT_StringHolder mySelectionCurrentPrim;
178  HUSD_InstanceSelection mySelectionWithInstanceIds;
179  LOP_SelectionRuleMap mySelectionRuleMap;
180  int mySelectionVersionId;
181  UT_StringHolder myCachedResolverContextAssetPath;
182  UT_StringMap<UT_StringHolder> myCachedResolverContextStrings;
183  UT_StringMap<UT_StringArray> myVariantSelectionFallbacks;
184 };
185 
186 #endif
GLbitfield flags
Definition: glcorearb.h:1596
virtual bool getResolverContextAssetPath(UT_String &assetpath)
const HUSD_InstanceSelection & selectionWithInstanceIds() const
Definition: LOP_Network.h:107
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:78
static const char * theChildTableName
Definition: LOP_Network.h:45
void saveOverrides(std::ostream &os)
const HUSD_PathSet & selection() const
Definition: LOP_Network.h:103
int getSelectionVersionId() const
Definition: LOP_Network.h:118
HUSD_ConstOverridesPtr overrides() const
Definition: LOP_Network.h:68
const HUSD_LoadMasks & loadMasks() const
Definition: LOP_Network.h:83
GU_SelectionRule
Definition: GU_SelectType.h:40
virtual bool getResolverContextStrings(UT_StringMap< UT_StringHolder > &resolverstrings)
virtual void loadFinished()
#define LOP_API
Definition: LOP_API.h:10
GLuint const GLchar * name
Definition: glcorearb.h:786
static const UT_StringHolder EXTRA_DATA_FORMAT
Definition: LOP_Network.h:138
OP_Node * getDisplayNodePtr() override
virtual OP_ERROR cookMyLop(OP_Context &context)=0
void clearAndDestroy() override
void opChanged(OP_EventType reason, void *data=0) override
static const UT_StringHolder LAST_PICKED_NODE
Definition: LOP_Network.h:139
static const UT_StringHolder PICKED_NODES
Definition: LOP_Network.h:140
HUSD_ExpansionState & editableExpansionState()
Definition: LOP_Network.h:80
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:73
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:105
Definition: format.h:895