SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
SubphraseGenerator.h
1 //=========================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //=========================================================================
10 #ifndef smtk_view_SubphraseGenerator_h
11 #define smtk_view_SubphraseGenerator_h
12 
13 #include "smtk/view/DescriptivePhrase.h"
14 
15 namespace smtk
16 {
17 namespace model
18 {
19 class Group;
20 }
21 
22 namespace view
23 {
24 
48 class SMTKCORE_EXPORT SubphraseGenerator : smtkEnableSharedPtr(SubphraseGenerator)
49 {
50 public:
51  static std::string getType(const smtk::view::ConfigurationPtr& viewSpec);
52  static SubphraseGeneratorPtr create(
53  const std::string& typeName,
54  const smtk::view::ManagerPtr& manager);
55 
59  virtual ~SubphraseGenerator() = default;
60 
61  using Path = std::vector<int>;
62  using PhrasesByPath = std::multimap<Path, DescriptivePhrasePtr>;
63 
68  virtual DescriptivePhrases subphrases(DescriptivePhrase::Ptr src);
69 
72  virtual bool hasChildren(const DescriptivePhrase& src) const;
73 
77  virtual smtk::resource::PersistentObjectSet parentObjects(
78  const smtk::resource::PersistentObjectPtr& obj) const;
79 
81  bool setModel(PhraseModelPtr model);
82 
84  PhraseModelPtr model() const { return m_model.lock(); }
85 
89  virtual DescriptivePhrasePtr createSubPhrase(
91  const DescriptivePhrasePtr& parent,
92  Path& childPath);
93 
104  virtual void subphrasesForCreatedObjects(
106  const DescriptivePhrasePtr& localRoot,
107  PhrasesByPath& resultingPhrases);
108 
119  virtual int directLimit() const;
130  virtual bool setDirectLimit(int val);
131 
136  virtual bool shouldOmitProperty(
137  DescriptivePhrase::Ptr parent,
139  const std::string& pname) const;
140 
145  virtual void setSkipProperties(bool val);
147  virtual bool skipProperties() const;
149 
154  virtual void setSkipAttributes(bool val);
156  virtual bool skipAttributes() const;
158 
160  ManagerPtr manager() const { return m_manager.lock(); }
161  friend Manager;
162 
163 protected:
164  virtual Path indexOfObjectInParent(
166  const smtk::view::DescriptivePhrasePtr& parent,
167  const Path& parentPath);
168 
169  virtual int findResourceLocation(
171  const DescriptivePhrase::Ptr& root) const;
172  virtual bool findSortedLocation(
173  Path& pathOut,
175  DescriptivePhrase::Ptr& phr,
176  const DescriptivePhrase::Ptr& parent) const;
177  virtual bool findSortedLocation(
178  Path& pathOut,
179  smtk::model::EntityPtr entity,
180  DescriptivePhrase::Ptr& phr,
181  const DescriptivePhrase::Ptr& parent) const;
182  virtual bool findSortedLocation(
183  Path& pathOut,
185  DescriptivePhrase::Ptr& phr,
186  const DescriptivePhrase::Ptr& parent) const;
187 
189  bool resourceHasChildren(const smtk::resource::ResourcePtr& rsrc) const;
191  bool modelEntityHasChildren(const smtk::model::EntityPtr& entity) const;
192 
194  void componentsOfResource(
195  DescriptivePhrase::Ptr src,
197  DescriptivePhrases& result);
199  void itemsOfAttribute(
200  DescriptivePhrase::Ptr src,
202  DescriptivePhrases& result);
204  void childrenOfModelEntity(
205  DescriptivePhrase::Ptr src,
206  smtk::model::EntityPtr modelEntity,
207  DescriptivePhrases& result);
208 
214  void freeSubmodelsOfModel(
217  DescriptivePhrase::Ptr src,
218  const smtk::model::Model& mod,
219  DescriptivePhrases& result);
221  void freeGroupsOfModel(
222  DescriptivePhrase::Ptr src,
223  const smtk::model::Model& mod,
224  DescriptivePhrases& result);
226  void freeCellsOfModel(
227  DescriptivePhrase::Ptr src,
228  const smtk::model::Model& mod,
229  DescriptivePhrases& result);
231  void freeAuxiliaryGeometriesOfModel(
232  DescriptivePhrase::Ptr src,
233  const smtk::model::Model& mod,
234  DescriptivePhrases& result);
235 
237  void instancesOfModelEntity(
238  DescriptivePhrase::Ptr src,
239  const smtk::model::EntityRef& ent,
240  DescriptivePhrases& result);
242  /*
243  void attributesOfModelEntity(
244  DescriptivePhrase::Ptr src, const smtk::model::EntityRef& ent, DescriptivePhrases& result);
245  */
246 
247  void cellOfModelUse(
248  DescriptivePhrase::Ptr src,
249  const smtk::model::UseEntity& ent,
250  DescriptivePhrases& result);
251  void boundingShellsOfModelUse(
252  DescriptivePhrase::Ptr src,
253  const smtk::model::UseEntity& ent,
254  DescriptivePhrases& result);
255  void toplevelShellsOfModelUse(
256  DescriptivePhrase::Ptr src,
257  const smtk::model::UseEntity& ent,
258  DescriptivePhrases& result);
259 
260  void usesOfModelCell(
261  DescriptivePhrase::Ptr src,
262  const smtk::model::CellEntity& ent,
263  DescriptivePhrases& result);
264  void inclusionsOfModelCell(
265  DescriptivePhrase::Ptr src,
266  const smtk::model::CellEntity& ent,
267  DescriptivePhrases& result);
268  void boundingCellsOfModelCell(
269  DescriptivePhrase::Ptr src,
270  const smtk::model::CellEntity& ent,
271  DescriptivePhrases& result);
272 
273  void usesOfModelShell(
274  DescriptivePhrase::Ptr src,
275  const smtk::model::ShellEntity& ent,
276  DescriptivePhrases& result);
277 
278  void membersOfModelGroup(
279  DescriptivePhrase::Ptr src,
280  const smtk::model::Group& grp,
281  DescriptivePhrases& result);
282 
283  void childrenOfModelAuxiliaryGeometry(
284  DescriptivePhrase::Ptr src,
286  DescriptivePhrases& result);
287 
288  void prototypeOfModelInstance(
289  DescriptivePhrase::Ptr src,
290  const smtk::model::Instance& ent,
291  DescriptivePhrases& result);
292 
293  template<typename T>
294  void PreparePath(T& result, const T& parentPath, int childIndex);
295 
296  template<typename T>
297  int IndexFromTitle(const std::string& title, const T& phrases);
298 
300 
311  template<typename T>
312  PhraseListContentPtr addComponentPhrases(
313  const T& components,
314  DescriptivePhrase::Ptr parent,
315  DescriptivePhrases& result,
316  int mutability = static_cast<int>(smtk::view::PhraseContent::ContentType::TITLE) |
317  static_cast<int>(smtk::view::PhraseContent::ContentType::COLOR),
318  std::function<bool(const DescriptivePhrase::Ptr&, const DescriptivePhrase::Ptr&)> comparator =
320 
326  template<typename T>
327  void filterModelEntityPhraseCandidates(T& ents);
328 
330  template<typename T>
331  PhraseListContentPtr addModelEntityPhrases(
332  const T& ents,
333  DescriptivePhrase::Ptr parent,
334  int limit,
335  DescriptivePhrases& result,
336  int mutability = static_cast<int>(smtk::view::PhraseContent::ContentType::TITLE) |
337  static_cast<int>(smtk::view::PhraseContent::ContentType::COLOR),
338  std::function<bool(const DescriptivePhrase::Ptr&, const DescriptivePhrase::Ptr&)> comparator =
339  nullptr);
340 
341 #if 0
342 
349  void propertiesOfComponent(
352  DescriptivePhrase::Ptr src, const smtk::model::EntityPtr& ent, DescriptivePhrases& result);
354  void floatPropertiesOfComponent(
355  DescriptivePhrase::Ptr src, const smtk::model::EntityPtr& ent, DescriptivePhrases& result);
357  void stringPropertiesOfComponent(
358  DescriptivePhrase::Ptr src, const smtk::model::EntityPtr& ent, DescriptivePhrases& result);
360  void integerPropertiesOfComponent(
361  DescriptivePhrase::Ptr src, const smtk::model::EntityPtr& ent, DescriptivePhrases& result);
363 
364  void modelsOfModelSession(
365  DescriptivePhrase::Ptr src, const SessionRef& sess, DescriptivePhrases& result);
366 
367  void meshesOfModelModel(DescriptivePhrase::Ptr src, const Model& mod, DescriptivePhrases& result);
368  void meshsetsOfMesh(MeshPhrase::Ptr meshphr, DescriptivePhrases& result);
369  void meshesOfMeshList(MeshListPhrase::Ptr src, DescriptivePhrases& result);
370  void meshsetsOfCollectionByDim(
371  MeshPhrase::Ptr meshphr, smtk::mesh::DimensionType dim, DescriptivePhrases& result);
372 
373  void addEntityProperties(smtk::resource::PropertyType ptype, std::set<std::string>& props,
374  DescriptivePhrase::Ptr parent, DescriptivePhrases& result);
375 
376  template <typename T>
377  void addMeshPhrases(
378  const T& ents, DescriptivePhrase::Ptr parent, int limit, DescriptivePhrases& result);
379 #endif // 0
380 
381  int m_directLimit;
382  bool m_skipAttributes;
383  bool m_skipProperties;
384  WeakPhraseModelPtr m_model;
385  WeakManagerPtr m_manager;
386 };
387 
388 } // namespace view
389 } // namespace smtk
390 
391 #endif
smtk
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
smtk::view::SubphraseGenerator
Generate subphrases to display for a given descriptive phrase.
Definition: SubphraseGenerator.h:48
smtk::view::Manager
A view Manager is responsible for creating new views (eventually) as well as view components such as ...
Definition: Manager.h:43
smtk::model::Model
A entityref subclass that provides methods specific to models.
Definition: Model.h:30
smtk::resource::PersistentObjectArray
std::vector< smtk::resource::PersistentObjectPtr > PersistentObjectArray
Definition: PublicPointerDefs.h:316
smtk::view::SubphraseGenerator::manager
ManagerPtr manager() const
SubphraseGenerators that are managed have a non-null pointer to their manager.
Definition: SubphraseGenerator.h:160
smtk::view::DescriptivePhrases
std::vector< smtk::view::DescriptivePhrasePtr > DescriptivePhrases
Definition: PublicPointerDefs.h:631
smtk::model::EntityPtr
smtk::shared_ptr< smtk::model::Entity > EntityPtr
Definition: PublicPointerDefs.h:430
smtkCreateMacro
#define smtkCreateMacro(...)
Add static create() methods to a class.
Definition: SharedFromThis.h:193
smtkEnableSharedPtr
#define smtkEnableSharedPtr(...)
An abbreviation for enabling shared pointers.
Definition: SharedFromThis.h:234
smtk::model::CellEntity
A entityref subclass with methods specific to cell entities.
Definition: CellEntity.h:30
smtk::view::ManagerPtr
smtk::shared_ptr< smtk::view::Manager > ManagerPtr
Definition: PublicPointerDefs.h:633
smtk::view::PhraseModelPtr
smtk::shared_ptr< smtk::view::PhraseModel > PhraseModelPtr
Definition: PublicPointerDefs.h:637
smtk::model::AuxiliaryGeometry
An EntityRef subclass for representing unmodeled geometry to be included in a scene.
Definition: AuxiliaryGeometry.h:44
smtk::mesh::ComponentPtr
smtk::shared_ptr< smtk::mesh::Component > ComponentPtr
Definition: PublicPointerDefs.h:367
smtk::model::Instance
A entityref subclass that provides methods specific to entity use records.
Definition: Instance.h:23
smtk::attribute::AttributePtr
smtk::shared_ptr< smtk::attribute::Attribute > AttributePtr
Definition: PublicPointerDefs.h:463
smtk::view::WeakPhraseModelPtr
smtk::weak_ptr< smtk::view::PhraseModel > WeakPhraseModelPtr
Definition: PublicPointerDefs.h:639
smtk::view::DescriptivePhrase::compareByTypeThenTitle
static bool compareByTypeThenTitle(const DescriptivePhrasePtr &a, const DescriptivePhrasePtr &b)
Phrase-type-based comparison method for DescriptivePhrases.
Definition: DescriptivePhrase.cxx:371
smtk::view::WeakManagerPtr
smtk::weak_ptr< smtk::view::Manager > WeakManagerPtr
Definition: PublicPointerDefs.h:635
smtk::view::SubphraseGeneratorPtr
smtk::shared_ptr< smtk::view::SubphraseGenerator > SubphraseGeneratorPtr
Definition: PublicPointerDefs.h:645
smtk::view::ConfigurationPtr
smtk::shared_ptr< smtk::view::Configuration > ConfigurationPtr
Definition: PublicPointerDefs.h:649
smtk::view::DescriptivePhrase
A base class for phrases describing an SMTK model.
Definition: DescriptivePhrase.h:76
smtk::model::Group
A entityref subclass that provides methods specific to entity use records.
Definition: Group.h:27
smtk::common::typeName
std::string typeName()
Return the name of a class.
Definition: TypeName.h:287
smtk::resource::PropertyType
PropertyType
Primitive storage types for model properties.
Definition: PropertyType.h:31
smtk::resource::PersistentObjectSet
std::set< smtk::resource::PersistentObjectPtr > PersistentObjectSet
Definition: PublicPointerDefs.h:298
smtk::view::DescriptivePhrasePtr
smtk::shared_ptr< smtk::view::DescriptivePhrase > DescriptivePhrasePtr
Definition: PublicPointerDefs.h:627
smtk::resource::PersistentObjectPtr
smtk::shared_ptr< smtk::resource::PersistentObject > PersistentObjectPtr
Definition: PublicPointerDefs.h:292
smtk::model::UseEntity
A entityref subclass that provides methods specific to entity-use records.
Definition: UseEntity.h:53
smtk::model::ShellEntity
A entityref subclass with methods specific to shell entities.
Definition: ShellEntity.h:33
smtk::view::SubphraseGenerator::model
PhraseModelPtr model() const
Return the phrase model (if any) used to adapt phrases to a user interface.
Definition: SubphraseGenerator.h:84
smtkTypeMacroBase
#define smtkTypeMacroBase(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:151
smtk::view::PhraseListContentPtr
smtk::shared_ptr< smtk::view::PhraseListContent > PhraseListContentPtr
Definition: PublicPointerDefs.h:657
smtk::model::EntityRef
A lightweight entityref pointing to a model entity's resource.
Definition: EntityRef.h:115
smtk::resource::ResourcePtr
smtk::shared_ptr< smtk::resource::Resource > ResourcePtr
Definition: PublicPointerDefs.h:302