1
1
// ////////////////////////////////////////////////////////////////////////
2
2
//
3
- // Copyright (c) 2013, Image Engine Design Inc. All rights reserved.
3
+ // Copyright (c) 2013-2014 , Image Engine Design Inc. All rights reserved.
4
4
//
5
5
// Redistribution and use in source and binary forms, with or without
6
6
// modification, are permitted provided that the following conditions are
@@ -94,9 +94,9 @@ class SceneCacheReader : public DD::Image::SourceGeo
94
94
// Returns the name of the item at index itemIndex in the SceneView_knob.
95
95
const std::string &itemName ( int itemIndex ) const ;
96
96
// Returns a SceneInterface for the root item.
97
- IECore::ConstSceneInterfacePtr getSceneInterface () const ;
97
+ IECore::ConstSceneInterfacePtr getSceneInterface ();
98
98
// Returns a SceneInterface for the item at path.
99
- IECore::ConstSceneInterfacePtr getSceneInterface ( const std::string &path ) const ;
99
+ IECore::ConstSceneInterfacePtr getSceneInterface ( const std::string &path );
100
100
// @}
101
101
102
102
// ! @name Methods which control the SceneView_knob
@@ -116,19 +116,12 @@ class SceneCacheReader : public DD::Image::SourceGeo
116
116
// / is rebuilt then the selection will be lost. The filterScene() method must
117
117
// / be called immediately afterwards.
118
118
void rebuildSceneView ();
119
- // / This recursive method is called from rebuildSceneView() and traverses the
120
- // / sceneInterface to build a list of item names and a mapping of the tags to
121
- // / the indices in the items.
122
- void buildSceneView ( std::vector< std::string > &list, const IECore::ConstSceneInterfacePtr sceneInterface );
123
119
// / Rebuilds the sceneView to show only items which are already selected or have
124
- // / a names that matches filterText and a tag which matches tagText.
120
+ // / names that matches filterText and a tag which matches tagText.
125
121
// / Passing an empty string to either filterText or tagText will disable the
126
122
// / filtering of the names and tags respectively. This should be called
127
123
// / immediately after any call to rebuildSceneView().
128
- void filterScene ( const std::string &filterText, const std::string &tagText );
129
- // / Rebuilds the current geometry selection from the entries that are selected
130
- // / in the SceneView_knob.
131
- void rebuildSelection ();
124
+ void filterScene ( const std::string &filterText, const std::string &tagText, bool keepSelection = true );
132
125
// / Clear any selected geometry from the SceneView_knob.
133
126
void clearSceneViewSelection ();
134
127
// @}
@@ -140,45 +133,28 @@ class SceneCacheReader : public DD::Image::SourceGeo
140
133
void loadPrimitive ( DD::Image::GeometryList &out, const std::string &path );
141
134
// / Get the hash of the file path and root knob.
142
135
DD::Image::Hash sceneHash () const ;
143
- // / Evaluates the file path for the current context and returns the result.
144
- std::string filePath ( ) const ;
136
+ // / Get the hash of the SceneView knob ( the default hash implementation of that knob returns a constant hash...)
137
+ DD::Image::Hash selectionHash ( bool force = false ) const ;
145
138
146
139
Imath::M44d worldTransform ( IECore::ConstSceneInterfacePtr scene, IECore::SceneInterface::Path root, double time );
147
140
148
141
// uses firstOp to return the Op that has the up-to-date private data
149
142
SceneCacheReader *firstReader ();
150
-
151
- // / Returns an InternedString with the name of the geometry tag.
152
- static const IECore::InternedString &geometryTag ();
143
+ const SceneCacheReader *firstReader () const ;
144
+
145
+ class SharedData ;
146
+
147
+ // this function should only be called from the firstReader() object.
148
+ SharedData *sharedData ();
149
+ const SharedData *sharedData () const ;
153
150
154
151
// Knob Members.
155
152
const char *m_filePath; // Holds the raw SceneCache file path.
156
- std::string m_evaluatedFilePath; // Holds the SceneCache file path after any TCL scripts have been evaluated..
157
153
std::string m_root; // Holds the root item in the SceneCache.
158
- std::string m_filterText; // The text to filter the scene with.
159
- std::string m_filterTagText; // The text to filter the tags with. This is set from the Enumeration_knob.
154
+ std::string m_filter; // The text to filter the scene with.
160
155
bool m_worldSpace; // Set to ignore local transforms..
161
156
DD::Image::Matrix4 m_baseParentMatrix; // The global matrix that is applied to the geo.
162
-
163
- // Hashes that are used to both provide an early-out to some methods
164
- // and also contribute towards a hash for the geometry.
165
- DD::Image::Hash m_selectionHash;
166
- DD::Image::Hash m_filterHash;
167
- DD::Image::Hash m_sceneHash;
168
-
169
- // When buildSceneView is called to parse the scene cache and generate a list of entries for the SceneView_knob,
170
- // this map is also populated. It holds a mapping of tag names to the indices of items which have that tag.
171
- // It is used within the filterScene method to quickly filter items with a particular tag.
172
- typedef std::map< std::string, std::vector< unsigned int > > TagMap;
173
- TagMap m_tagMap;
174
-
175
- // When specifying a root we store the path to it's parent item along with the length of it. We do this so that when
176
- // we are building the list of items in the SceneView_knob we can strip this path quickly from the front of the
177
- // name and easily restore it later to load it from the SceneCache. This ensures that the names of the items in the
178
- // SceneView_knob are kept short.
179
- std::string m_pathPrefix;
180
- unsigned int m_pathPrefixLength;
181
-
157
+
182
158
// Pointers to various knobs.
183
159
DD::Image::Knob *m_filePathKnob;
184
160
DD::Image::Knob *m_baseParentMatrixKnob;
@@ -187,19 +163,8 @@ class SceneCacheReader : public DD::Image::SourceGeo
187
163
DD::Image::Knob *m_sceneFilterKnob;
188
164
DD::Image::Knob *m_rootKnob;
189
165
190
- // A flag which is set when all of the knobs have been loaded from the script.
191
- bool m_scriptFinishedLoading;
192
-
193
- // A flag which is used to initialize the internal data structures the first time the node is run.
194
- bool m_isFirstRun;
195
-
196
- // / The SceneView_knob holds a list of all leaf items in the scene. When filtering the SceneView we specify indices into
197
- // / this list. When setting or querying the selected items in the SceneView_knob we need to use indices into the list of
198
- // / filtered (visible) items. This means that we have to keep a look-up table of mappings between indices in the filtered
199
- // / list of items and the index within the complete list of items in the scene.
200
- std::map<int , int > m_itemToFiltered; // Mapping of the index within the full scene list and the filtered scene list.
201
- std::vector<unsigned int > m_filteredToItem; // Mapping from an index in the filtered scene list to the complete scene list.
202
- std::vector< bool > m_itemSelected; // An array of flags which indicate whether an item in the filtered list is selected or not.
166
+ // only the first reader allocates the shared data
167
+ SharedData *m_data;
203
168
};
204
169
205
170
} // namespace IECoreNuke
0 commit comments