HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_Save.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __HUSD_Save_h__
19 #define __HUSD_Save_h__
20 
21 #include "HUSD_API.h"
22 #include "HUSD_DataHandle.h"
23 #include "HUSD_OutputProcessor.h"
24 #include "HUSD_TimeCode.h"
25 #include <UT/UT_Interval.h>
26 #include <UT/UT_Options.h>
27 #include <UT/UT_PathPattern.h>
28 #include <UT/UT_StringHolder.h>
29 #include <UT/UT_StringMap.h>
30 #include <UT/UT_UniquePtr.h>
31 #include <SYS/SYS_Types.h>
32 
33 class OP_Node;
34 
40 };
41 
43 {
45  const UT_Options &overrides=UT_Options())
46  : myProcessor(processor), myOverrides(overrides) {}
49 };
52 
53 // Some simple structs that just handle lumping bits of save configuration
54 // data together.
56 {
57 public:
63  { }
64 
69 };
70 
72 {
73 public:
75  : myConfigNode(nullptr),
76  myLopNode(nullptr),
77  myConfigTime(0.0),
78  myReplaceHfs(true)
79  { }
80 
86 };
87 
89 {
90 public:
92  : myRequireDefaultPrim(false)
93  { }
94 
97 };
98 
100 {
101 public:
103  : myClearHoudiniCustomData(false),
104  myFlattenFileLayers(false),
105  myFlattenSopLayers(false),
108  mySaveFilesFromDisk(false),
109  myEnsureMetricsSet(false),
110  myTrackPrimExistence(false),
111  myMuteLayersBeforeSave(false),
113  myTimeSamplesRange(SYS_FP64_MAX, -SYS_FP64_MAX), // initially "invalid"
115  { }
116 
129 };
130 
132 {
133 public:
134  HUSD_Save();
135  ~HUSD_Save();
136 
137  bool addCombinedTimeSample(const HUSD_AutoReadLock &lock,
138  const HUSD_TimeCode &timecode);
139  bool saveCombined(const UT_StringRef &filepath,
140  bool filepath_is_time_dependent,
141  UT_StringMap<UT_StringHolder> &saved_paths);
142  void clearSaveHistory();
143  bool save(const HUSD_AutoReadLock &lock,
144  const HUSD_TimeCode &timecode,
145  const UT_StringRef &filepath,
146  bool filepath_is_time_dependent,
147  UT_StringMap<UT_StringHolder> &saved_paths);
148 
150  { return mySaveStyle; }
151  void setSaveStyle(HUSD_SaveStyle save_style)
152  { mySaveStyle = save_style; }
153 
154  bool requireDefaultPrim() const
155  { return myDefaultPrimData.myRequireDefaultPrim; }
156  void setRequireDefaultPrim(bool require_default_prim)
157  { myDefaultPrimData.
158  myRequireDefaultPrim = require_default_prim; }
159 
161  { return myDefaultPrimData.myDefaultPrim; }
162  void setDefaultPrim(const UT_StringHolder &defaultprim)
163  { myDefaultPrimData.myDefaultPrim = defaultprim; }
164 
166  { return myFlags.myClearHoudiniCustomData; }
167  void setClearHoudiniCustomData(bool clear_data)
168  { myFlags.myClearHoudiniCustomData = clear_data; }
169 
170  bool flattenFileLayers() const
171  { return myFlags.myFlattenFileLayers; }
172  void setFlattenFileLayers(bool flatten_file_layers)
173  { myFlags.myFlattenFileLayers = flatten_file_layers; }
174 
175  bool flattenSopLayers() const
176  { return myFlags.myFlattenSopLayers; }
177  void setFlattenSopLayers(bool flatten_sop_layers)
178  { myFlags.myFlattenSopLayers = flatten_sop_layers; }
179 
181  { return myFlags.myErrorSavingImplicitPaths; }
183  { myFlags.myErrorSavingImplicitPaths = error; }
184 
186  { return myFlags.myIgnoreSavingImplicitPaths; }
188  { myFlags.myIgnoreSavingImplicitPaths = ignore; }
189 
190  bool saveFilesFromDisk() const
191  { return myFlags.mySaveFilesFromDisk; }
192  void setSaveFilesFromDisk(bool save)
193  { myFlags.mySaveFilesFromDisk = save; }
194 
195  bool ensureMetricsSet() const
196  { return myFlags.myEnsureMetricsSet; }
198  { myFlags.myEnsureMetricsSet = set; }
199 
200  bool trackPrimExistence() const
201  { return myFlags.myTrackPrimExistence; }
202  void setTrackPrimExistence(bool track_existence)
203  { myFlags.myTrackPrimExistence = track_existence; }
204 
205  bool muteLayersBeforeSave() const
206  { return myFlags.myMuteLayersBeforeSave; }
207  void setMuteLayersBeforeSave(bool mute_layers)
208  { myFlags.myMuteLayersBeforeSave = mute_layers; }
209 
211  { return myFlags.myStripLayersAboveLayerBreaks; }
212  void setStripLayersAboveLayerBreaks(bool strip_layers)
213  { myFlags.myStripLayersAboveLayerBreaks = strip_layers; }
214 
216  { return myFlags.myTimeSamplesRange; }
218  { myFlags.myTimeSamplesRange = range; }
220  { return myFlags.myTimeSamplesRangePadding; }
222  { myFlags.myTimeSamplesRangePadding = padding; }
223 
225  { return mySaveFilesPattern.get(); }
227  {
228  if (pattern.isstring())
229  mySaveFilesPattern.reset(
230  new UT_PathPattern(pattern));
231  else
232  mySaveFilesPattern.reset();
233  }
234 
236  { return myTimeData.myStartFrame; }
237  void setStartFrame(fpreal64 start_time = -SYS_FP64_MAX)
238  { myTimeData.myStartFrame = start_time; }
239 
241  { return myTimeData.myEndFrame; }
243  { myTimeData.myEndFrame = end_time; }
244 
246  { return myTimeData.myTimeCodesPerSecond; }
248  { myTimeData.myTimeCodesPerSecond = tps; }
249 
251  { return myTimeData.myFramesPerSecond; }
253  { myTimeData.myFramesPerSecond = fps; }
254 
256  { return myProcessorData.myProcessors; }
258  {
259  myProcessorData.myProcessors.clear();
260  for (auto &&processor : aps)
261  {
262  myProcessorData.myProcessors.append({processor});
263  }
264  }
267  { myProcessorData.myProcessors = aps; }
268 
270  { return myProcessorData.myConfigNode; }
272  { myProcessorData.myConfigNode = config_node; }
273 
275  { return myProcessorData.myConfigTime; }
277  { myProcessorData.myConfigTime = t; }
278 
280  { return myProcessorData.myReplaceHfs; }
281  void setOutputProcessorsReplaceHfs(bool replacehfs)
282  { myProcessorData.myReplaceHfs = replacehfs; }
283 
284 private:
285  class husd_SavePrivate;
286 
288  UT_UniquePtr<UT_PathPattern> mySaveFilesPattern;
289  HUSD_SaveStyle mySaveStyle;
290  husd_SaveProcessorData myProcessorData;
291  husd_SaveDefaultPrimData myDefaultPrimData;
292  husd_SaveTimeData myTimeData;
293  husd_SaveConfigFlags myFlags;
294 };
295 
296 #endif
297 
fpreal64 startFrame() const
Definition: HUSD_Save.h:235
fpreal64 myTimeCodesPerSecond
Definition: HUSD_Save.h:67
bool myClearHoudiniCustomData
Definition: HUSD_Save.h:117
GLenum GLint * range
Definition: glcorearb.h:1925
void setDefaultPrim(const UT_StringHolder &defaultprim)
Definition: HUSD_Save.h:162
bool requireDefaultPrim() const
Definition: HUSD_Save.h:154
fpreal64 endFrame() const
Definition: HUSD_Save.h:240
bool errorSavingImplicitPaths() const
Definition: HUSD_Save.h:180
#define HUSD_API
Definition: HUSD_API.h:31
const HUSD_OutputProcessorAndOverridesArray & outputProcessors() const
Definition: HUSD_Save.h:255
void setSaveStyle(HUSD_SaveStyle save_style)
Definition: HUSD_Save.h:151
fpreal64 framesPerSecond() const
Definition: HUSD_Save.h:250
void setSaveFilesPattern(const UT_StringHolder &pattern)
Definition: HUSD_Save.h:226
const UT_StringHolder & defaultPrim() const
Definition: HUSD_Save.h:160
bool ignoreSavingImplicitPaths() const
Definition: HUSD_Save.h:185
#define SYS_FP64_MAX
Definition: SYS_Types.h:222
HUSD_OutputProcessorAndOverrides(HUSD_OutputProcessorPtr processor, const UT_Options &overrides=UT_Options())
Definition: HUSD_Save.h:44
bool ensureMetricsSet() const
Definition: HUSD_Save.h:195
const UT_IntervalD & timeSamplesRange() const
Definition: HUSD_Save.h:215
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
< returns > If no error
Definition: snippets.dox:2
double fpreal64
Definition: SYS_Types.h:201
void setOutputProcessors(const HUSD_OutputProcessorAndOverridesArray &aps)
Definition: HUSD_Save.h:265
fpreal64 myStartFrame
Definition: HUSD_Save.h:65
OP_Node * outputProcessorsConfigNode() const
Definition: HUSD_Save.h:269
bool stripLayersAboveLayerBreaks() const
Definition: HUSD_Save.h:210
void setOutputProcessorsConfigNode(OP_Node *config_node)
Definition: HUSD_Save.h:271
void ignore(T const &) VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6508
constexpr auto set(type rhs) -> int
Definition: core.h:610
void setTimeCodesPerSecond(fpreal64 tps=SYS_FP64_MAX)
Definition: HUSD_Save.h:247
void setFlattenSopLayers(bool flatten_sop_layers)
Definition: HUSD_Save.h:177
fpreal64 timeCodesPerSecond() const
Definition: HUSD_Save.h:245
void setStripLayersAboveLayerBreaks(bool strip_layers)
Definition: HUSD_Save.h:212
HUSD_SaveStyle
Definition: HUSD_Save.h:35
bool myIgnoreSavingImplicitPaths
Definition: HUSD_Save.h:121
GLushort pattern
Definition: glad.h:2583
void setRequireDefaultPrim(bool require_default_prim)
Definition: HUSD_Save.h:156
void setTrackPrimExistence(bool track_existence)
Definition: HUSD_Save.h:202
bool myErrorSavingImplicitPaths
Definition: HUSD_Save.h:120
fpreal outputProcessorsTime() const
Definition: HUSD_Save.h:274
GLdouble t
Definition: glad.h:2397
void setEnsureMetricsSet(bool set)
Definition: HUSD_Save.h:197
fpreal64 myFramesPerSecond
Definition: HUSD_Save.h:68
UT_IntervalD myTimeSamplesRange
Definition: HUSD_Save.h:127
bool flattenFileLayers() const
Definition: HUSD_Save.h:170
A map of string to various well defined value types.
Definition: UT_Options.h:87
void setFramesPerSecond(fpreal64 fps=SYS_FP64_MAX)
Definition: HUSD_Save.h:252
const UT_PathPattern * saveFilesPattern() const
Definition: HUSD_Save.h:224
fpreal64 fpreal
Definition: SYS_Types.h:278
OP_Node * myConfigNode
Definition: HUSD_Save.h:82
HUSD_OutputProcessorPtr myProcessor
Definition: HUSD_Save.h:47
bool flattenSopLayers() const
Definition: HUSD_Save.h:175
void setTimeSamplesRange(const UT_IntervalD &range)
Definition: HUSD_Save.h:217
void setErrorSavingImplicitPaths(bool error)
Definition: HUSD_Save.h:182
UT_StringHolder myDefaultPrim
Definition: HUSD_Save.h:95
void setOutputProcessors(const HUSD_OutputProcessorArray &aps)
Definition: HUSD_Save.h:257
fpreal64 timeSamplesRangePadding() const
Definition: HUSD_Save.h:219
void setIgnoreSavingImplicitPaths(bool ignore)
Definition: HUSD_Save.h:187
bool clearHoudiniCustomData() const
Definition: HUSD_Save.h:165
fpreal64 myEndFrame
Definition: HUSD_Save.h:66
HUSD_OutputProcessorAndOverridesArray myProcessors
Definition: HUSD_Save.h:81
bool muteLayersBeforeSave() const
Definition: HUSD_Save.h:205
void setOutputProcessorsReplaceHfs(bool replacehfs)
Definition: HUSD_Save.h:281
fpreal64 myTimeSamplesRangePadding
Definition: HUSD_Save.h:128
void setStartFrame(fpreal64 start_time=-SYS_FP64_MAX)
Definition: HUSD_Save.h:237
void setTimeSamplesRangePadding(fpreal64 padding)
Definition: HUSD_Save.h:221
void setEndFrame(fpreal64 end_time=SYS_FP64_MAX)
Definition: HUSD_Save.h:242
bool trackPrimExistence() const
Definition: HUSD_Save.h:200
bool saveFilesFromDisk() const
Definition: HUSD_Save.h:190
void setSaveFilesFromDisk(bool save)
Definition: HUSD_Save.h:192
void setOutputProcessorsTime(fpreal t)
Definition: HUSD_Save.h:276
SYS_FORCE_INLINE bool isstring() const
bool myStripLayersAboveLayerBreaks
Definition: HUSD_Save.h:126
void setFlattenFileLayers(bool flatten_file_layers)
Definition: HUSD_Save.h:172
void setClearHoudiniCustomData(bool clear_data)
Definition: HUSD_Save.h:167
UT_SharedPtr< HUSD_OutputProcessor > HUSD_OutputProcessorPtr
HUSD_SaveStyle saveStyle() const
Definition: HUSD_Save.h:149
bool outputProcessorsReplaceHfs() const
Definition: HUSD_Save.h:279
void setMuteLayersBeforeSave(bool mute_layers)
Definition: HUSD_Save.h:207