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  { }
79 
84 };
85 
87 {
88 public:
90  : myRequireDefaultPrim(false)
91  { }
92 
95 };
96 
98 {
99 public:
101  : myClearHoudiniCustomData(false),
102  myFlattenFileLayers(false),
103  myFlattenSopLayers(false),
106  mySaveFilesFromDisk(false),
107  myEnsureMetricsSet(false),
108  myTrackPrimExistence(false),
109  myMuteLayersBeforeSave(false),
110  myTimeSamplesRange(SYS_FP64_MAX, -SYS_FP64_MAX), // initially "invalid"
112  { }
113 
125 };
126 
128 {
129 public:
130  HUSD_Save();
131  ~HUSD_Save();
132 
133  bool addCombinedTimeSample(const HUSD_AutoReadLock &lock,
134  const HUSD_TimeCode &timecode);
135  bool saveCombined(const UT_StringRef &filepath,
136  bool filepath_is_time_dependent,
137  UT_StringMap<UT_StringHolder> &saved_paths);
138  void clearSaveHistory();
139  bool save(const HUSD_AutoReadLock &lock,
140  const HUSD_TimeCode &timecode,
141  const UT_StringRef &filepath,
142  bool filepath_is_time_dependent,
143  UT_StringMap<UT_StringHolder> &saved_paths);
144 
146  { return mySaveStyle; }
147  void setSaveStyle(HUSD_SaveStyle save_style)
148  { mySaveStyle = save_style; }
149 
150  bool requireDefaultPrim() const
151  { return myDefaultPrimData.myRequireDefaultPrim; }
152  void setRequireDefaultPrim(bool require_default_prim)
153  { myDefaultPrimData.
154  myRequireDefaultPrim = require_default_prim; }
155 
157  { return myDefaultPrimData.myDefaultPrim; }
158  void setDefaultPrim(const UT_StringHolder &defaultprim)
159  { myDefaultPrimData.myDefaultPrim = defaultprim; }
160 
162  { return myFlags.myClearHoudiniCustomData; }
163  void setClearHoudiniCustomData(bool clear_data)
164  { myFlags.myClearHoudiniCustomData = clear_data; }
165 
166  bool flattenFileLayers() const
167  { return myFlags.myFlattenFileLayers; }
168  void setFlattenFileLayers(bool flatten_file_layers)
169  { myFlags.myFlattenFileLayers = flatten_file_layers; }
170 
171  bool flattenSopLayers() const
172  { return myFlags.myFlattenSopLayers; }
173  void setFlattenSopLayers(bool flatten_sop_layers)
174  { myFlags.myFlattenSopLayers = flatten_sop_layers; }
175 
177  { return myFlags.myErrorSavingImplicitPaths; }
179  { myFlags.myErrorSavingImplicitPaths = error; }
180 
182  { return myFlags.myIgnoreSavingImplicitPaths; }
184  { myFlags.myIgnoreSavingImplicitPaths = ignore; }
185 
186  bool saveFilesFromDisk() const
187  { return myFlags.mySaveFilesFromDisk; }
188  void setSaveFilesFromDisk(bool save)
189  { myFlags.mySaveFilesFromDisk = save; }
190 
191  bool ensureMetricsSet() const
192  { return myFlags.myEnsureMetricsSet; }
193  void setEnsureMetricsSet(bool set)
194  { myFlags.myEnsureMetricsSet = set; }
195 
196  bool trackPrimExistence() const
197  { return myFlags.myTrackPrimExistence; }
198  void setTrackPrimExistence(bool track_existence)
199  { myFlags.myTrackPrimExistence = track_existence; }
200 
201  bool muteLayersBeforeSave() const
202  { return myFlags.myMuteLayersBeforeSave; }
203  void setMuteLayersBeforeSave(bool mute_layers)
204  { myFlags.myMuteLayersBeforeSave = mute_layers; }
205 
207  { return myFlags.myTimeSamplesRange; }
209  { myFlags.myTimeSamplesRange = range; }
211  { return myFlags.myTimeSamplesRangePadding; }
213  { myFlags.myTimeSamplesRangePadding = padding; }
214 
216  { return mySaveFilesPattern.get(); }
218  {
219  if (pattern.isstring())
220  mySaveFilesPattern.reset(
221  new UT_PathPattern(pattern));
222  else
223  mySaveFilesPattern.reset();
224  }
225 
227  { return myTimeData.myStartFrame; }
228  void setStartFrame(fpreal64 start_time = -SYS_FP64_MAX)
229  { myTimeData.myStartFrame = start_time; }
230 
232  { return myTimeData.myEndFrame; }
234  { myTimeData.myEndFrame = end_time; }
235 
237  { return myTimeData.myTimeCodesPerSecond; }
239  { myTimeData.myTimeCodesPerSecond = tps; }
240 
242  { return myTimeData.myFramesPerSecond; }
244  { myTimeData.myFramesPerSecond = fps; }
245 
247  { return myProcessorData.myProcessors; }
249  {
250  myProcessorData.myProcessors.clear();
251  for (auto &&processor : aps)
252  {
253  myProcessorData.myProcessors.append({processor});
254  }
255  }
258  { myProcessorData.myProcessors = aps; }
259 
261  { return myProcessorData.myConfigNode; }
263  { myProcessorData.myConfigNode = config_node; }
264 
266  { return myProcessorData.myConfigTime; }
268  { myProcessorData.myConfigTime = t; }
269 
270 private:
271  class husd_SavePrivate;
272 
274  UT_UniquePtr<UT_PathPattern> mySaveFilesPattern;
275  HUSD_SaveStyle mySaveStyle;
276  husd_SaveProcessorData myProcessorData;
277  husd_SaveDefaultPrimData myDefaultPrimData;
278  husd_SaveTimeData myTimeData;
279  husd_SaveConfigFlags myFlags;
280 };
281 
282 #endif
283 
fpreal64 startFrame() const
Definition: HUSD_Save.h:226
fpreal64 myTimeCodesPerSecond
Definition: HUSD_Save.h:67
bool myClearHoudiniCustomData
Definition: HUSD_Save.h:114
GLenum GLint * range
Definition: glcorearb.h:1925
void setDefaultPrim(const UT_StringHolder &defaultprim)
Definition: HUSD_Save.h:158
bool requireDefaultPrim() const
Definition: HUSD_Save.h:150
fpreal64 endFrame() const
Definition: HUSD_Save.h:231
bool errorSavingImplicitPaths() const
Definition: HUSD_Save.h:176
#define HUSD_API
Definition: HUSD_API.h:32
const HUSD_OutputProcessorAndOverridesArray & outputProcessors() const
Definition: HUSD_Save.h:246
void setSaveStyle(HUSD_SaveStyle save_style)
Definition: HUSD_Save.h:147
fpreal64 framesPerSecond() const
Definition: HUSD_Save.h:241
void setSaveFilesPattern(const UT_StringHolder &pattern)
Definition: HUSD_Save.h:217
const UT_StringHolder & defaultPrim() const
Definition: HUSD_Save.h:156
bool ignoreSavingImplicitPaths() const
Definition: HUSD_Save.h:181
#define SYS_FP64_MAX
Definition: SYS_Types.h:221
HUSD_OutputProcessorAndOverrides(HUSD_OutputProcessorPtr processor, const UT_Options &overrides=UT_Options())
Definition: HUSD_Save.h:44
bool ensureMetricsSet() const
Definition: HUSD_Save.h:191
const UT_IntervalD & timeSamplesRange() const
Definition: HUSD_Save.h:206
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:256
fpreal64 myStartFrame
Definition: HUSD_Save.h:65
OP_Node * outputProcessorsConfigNode() const
Definition: HUSD_Save.h:260
void setOutputProcessorsConfigNode(OP_Node *config_node)
Definition: HUSD_Save.h:262
void ignore(T const &) VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6508
void setTimeCodesPerSecond(fpreal64 tps=SYS_FP64_MAX)
Definition: HUSD_Save.h:238
void setFlattenSopLayers(bool flatten_sop_layers)
Definition: HUSD_Save.h:173
fpreal64 timeCodesPerSecond() const
Definition: HUSD_Save.h:236
HUSD_SaveStyle
Definition: HUSD_Save.h:35
bool myIgnoreSavingImplicitPaths
Definition: HUSD_Save.h:118
GLushort pattern
Definition: glad.h:2583
void setRequireDefaultPrim(bool require_default_prim)
Definition: HUSD_Save.h:152
void setTrackPrimExistence(bool track_existence)
Definition: HUSD_Save.h:198
bool myErrorSavingImplicitPaths
Definition: HUSD_Save.h:117
fpreal outputProcessorsTime() const
Definition: HUSD_Save.h:265
GLdouble t
Definition: glad.h:2397
void setEnsureMetricsSet(bool set)
Definition: HUSD_Save.h:193
fpreal64 myFramesPerSecond
Definition: HUSD_Save.h:68
UT_IntervalD myTimeSamplesRange
Definition: HUSD_Save.h:123
bool flattenFileLayers() const
Definition: HUSD_Save.h:166
A map of string to various well defined value types.
Definition: UT_Options.h:84
void setFramesPerSecond(fpreal64 fps=SYS_FP64_MAX)
Definition: HUSD_Save.h:243
const UT_PathPattern * saveFilesPattern() const
Definition: HUSD_Save.h:215
fpreal64 fpreal
Definition: SYS_Types.h:277
OP_Node * myConfigNode
Definition: HUSD_Save.h:81
HUSD_OutputProcessorPtr myProcessor
Definition: HUSD_Save.h:47
bool flattenSopLayers() const
Definition: HUSD_Save.h:171
void setTimeSamplesRange(const UT_IntervalD &range)
Definition: HUSD_Save.h:208
void setErrorSavingImplicitPaths(bool error)
Definition: HUSD_Save.h:178
UT_StringHolder myDefaultPrim
Definition: HUSD_Save.h:93
void setOutputProcessors(const HUSD_OutputProcessorArray &aps)
Definition: HUSD_Save.h:248
fpreal64 timeSamplesRangePadding() const
Definition: HUSD_Save.h:210
void setIgnoreSavingImplicitPaths(bool ignore)
Definition: HUSD_Save.h:183
bool clearHoudiniCustomData() const
Definition: HUSD_Save.h:161
fpreal64 myEndFrame
Definition: HUSD_Save.h:66
HUSD_OutputProcessorAndOverridesArray myProcessors
Definition: HUSD_Save.h:80
bool muteLayersBeforeSave() const
Definition: HUSD_Save.h:201
fpreal64 myTimeSamplesRangePadding
Definition: HUSD_Save.h:124
void setStartFrame(fpreal64 start_time=-SYS_FP64_MAX)
Definition: HUSD_Save.h:228
void setTimeSamplesRangePadding(fpreal64 padding)
Definition: HUSD_Save.h:212
void setEndFrame(fpreal64 end_time=SYS_FP64_MAX)
Definition: HUSD_Save.h:233
bool trackPrimExistence() const
Definition: HUSD_Save.h:196
bool saveFilesFromDisk() const
Definition: HUSD_Save.h:186
void setSaveFilesFromDisk(bool save)
Definition: HUSD_Save.h:188
void setOutputProcessorsTime(fpreal t)
Definition: HUSD_Save.h:267
SYS_FORCE_INLINE bool isstring() const
void setFlattenFileLayers(bool flatten_file_layers)
Definition: HUSD_Save.h:168
void setClearHoudiniCustomData(bool clear_data)
Definition: HUSD_Save.h:163
UT_SharedPtr< HUSD_OutputProcessor > HUSD_OutputProcessorPtr
HUSD_SaveStyle saveStyle() const
Definition: HUSD_Save.h:145
void setMuteLayersBeforeSave(bool mute_layers)
Definition: HUSD_Save.h:203