SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
ComponentPhraseModel.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_ComponentPhraseModel_h
11 #define smtk_view_ComponentPhraseModel_h
12 
13 #include "smtk/view/Configuration.h"
14 #include "smtk/view/DescriptivePhrase.h"
15 #include "smtk/view/PhraseModel.h"
16 
17 #include <functional>
18 #include <map>
19 
20 namespace smtk
21 {
22 namespace view
23 {
33 class SMTKCORE_EXPORT ComponentPhraseModel : public PhraseModel
34 {
35 public:
36  using Observer = std::function<void(DescriptivePhrasePtr, PhraseModelEvent, int, int)>;
38 
39  typedef std::function<
41  SortingCompFunc;
42 
46 
49  ~ComponentPhraseModel() override;
50 
52  DescriptivePhrasePtr root() const override;
53 
62  bool setComponentFilters(const std::multimap<std::string, std::string>& src);
63 
72  void visitComponentFilters(std::function<int(const std::string&, const std::string&)> fn) const;
73 
80  void setSortFunction(const SortingCompFunc& comparator);
81 
82 protected:
83  /*
84  virtual void handleSelectionEvent(const std::string& src, Selection::Ptr seln);
85  virtual void handleResourceEvent(Resource::Ptr rsrc, smtk::resource::Event event);
86  virtual int handleOperationEvent(Operation::Ptr op, Operator::EventType event, Operator::Result res);
87 
88  virtual void handleExpunged(Operation::Ptr op, Operation::Result res, ComponentItemPtr data);
89  virtual void handleModified(Operation::Ptr op, Operation::Result res, ComponentItemPtr data);
90  */
91  void handleResourceEvent(const Resource& rsrc, smtk::resource::EventType event) override;
92  void handleCreated(const smtk::resource::PersistentObjectSet& createdObjects) override;
93 
94  virtual void processResource(const Resource::Ptr& rsrc, bool adding);
95  virtual void populateRoot();
99  DescriptivePhrasePtr createTopPhrase(const smtk::resource::ComponentPtr& comp);
100 
102  std::set<
103  std::weak_ptr<smtk::resource::Resource>,
104  std::owner_less<std::weak_ptr<smtk::resource::Resource>>>
105  m_resources;
106  std::multimap<std::string, std::string> m_componentFilters;
107 
108 private:
109  SortingCompFunc m_comparator = smtk::view::DescriptivePhrase::compareByTypeThenTitle;
110 };
111 } // namespace view
112 } // namespace smtk
113 
114 #endif
smtk
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
smtk::view::Manager
A view Manager is responsible for creating new views (eventually) as well as view components such as ...
Definition: Manager.h:40
smtk::view::PhraseModelEvent
PhraseModelEvent
Events that can be observed on an smtk::view::PhraseModel.
Definition: PhraseModelObserver.h:26
smtk::resource::EventType
EventType
Enumerate events that the resource manager may encounter.
Definition: Observer.h:32
smtk::view::PhraseModel
Hold and maintain a descriptive phrase hierarchy.
Definition: PhraseModel.h:101
smtk::operation::Operation
Operation is a base class for all SMTK operations.
Definition: Operation.h:51
smtkTypeMacro
#define smtkTypeMacro(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:51
smtk::view::Configuration
Configure a view, specifying types and attributes, without specifying a UI library.
Definition: Configuration.h:28
smtk::view::DescriptivePhrase::compareByTypeThenTitle
static bool compareByTypeThenTitle(const DescriptivePhrasePtr &a, const DescriptivePhrasePtr &b)
Phrase-type-based comparison method for DescriptivePhrases.
Definition: DescriptivePhrase.cxx:371
smtkSharedPtrCreateMacro
#define smtkSharedPtrCreateMacro(...)
A convenience macro for declaring shared_from_this and create methods.
Definition: SharedFromThis.h:207
smtkSuperclassMacro
#define smtkSuperclassMacro(...)
Add a typedef to the superclass of this class.
Definition: SharedFromThis.h:87
smtk::resource::Resource
An abstract base class for SMTK resources.
Definition: Resource.h:60
smtk::resource::PersistentObjectSet
std::set< smtk::resource::PersistentObjectPtr > PersistentObjectSet
Definition: PublicPointerDefs.h:291
smtk::view::DescriptivePhrasePtr
smtk::shared_ptr< smtk::view::DescriptivePhrase > DescriptivePhrasePtr
Definition: PublicPointerDefs.h:620
smtk::view::ComponentPhraseModel
Present phrases describing a set of acceptable components held by a single resource.
Definition: ComponentPhraseModel.h:33
smtk::resource::ComponentPtr
smtk::shared_ptr< smtk::resource::Component > ComponentPtr
Definition: PublicPointerDefs.h:297