SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
11 #ifndef smtk_attribute_Definition_h
12 #define smtk_attribute_Definition_h
14 #include "smtk/CoreExports.h"
18 #include "smtk/attribute/Categories.h"
19 #include "smtk/attribute/ReferenceItemDefinition.h"
20 #include "smtk/attribute/Tag.h"
23 #include "smtk/model/EntityTypeBits.h"
45 class SMTKCORE_EXPORT
Definition :
public smtk::enable_shared_from_this<Definition>
64 auto left = lhs.lock();
67 auto right = rhs.lock();
70 return left->type() < right->type();
74 typedef std::set<WeakDefinitionPtr, WeakDefinitionPtrCompare> WeakDefinitionSet;
80 const std::string& type()
const {
return m_type; }
85 const Tags&
tags()
const {
return m_tags; }
90 const Tag* tag(
const std::string& name)
const;
91 Tag* tag(
const std::string& name);
96 bool addTag(
const Tag& tag);
97 bool removeTag(
const std::string& name);
101 const std::string& displayedTypeName()
const {
return m_label.empty() ? m_type : m_label; }
106 const std::string& label()
const {
return m_label; }
108 void setLabel(
const std::string& newLabel) { m_label = newLabel; }
122 bool includeCategories =
true,
123 bool includeReadAccess =
false,
124 unsigned int readAccessLevel = 0)
const;
126 int version()
const {
return m_version; }
127 void setVersion(
int myVersion) { m_version = myVersion; }
129 bool isAbstract()
const {
return m_isAbstract; }
131 void setIsAbstract(
bool isAbstractValue) { m_isAbstract = isAbstractValue; }
156 m_localCategories = catSet;
169 void filterItemDefinitions(T& values, std::function<
bool(
typename T::value_type)> test);
180 unsigned int advanceLevel(
int mode = 0)
const;
181 void setLocalAdvanceLevel(
int mode,
unsigned int level);
182 void setLocalAdvanceLevel(
unsigned int level);
183 unsigned int localAdvanceLevel(
int mode = 0)
const
185 return (mode == 1 ? m_localAdvanceLevel[1] : m_localAdvanceLevel[0]);
190 void unsetLocalAdvanceLevel(
int mode = 0);
195 return (mode == 1 ? m_hasLocalAdvanceLevelInfo[1] : m_hasLocalAdvanceLevelInfo[0]);
204 void setIsUnique(
bool isUniqueValue);
209 void setIsNodal(
bool isNodalValue) { m_isNodal = isNodalValue; }
215 const double* notApplicableColor()
const;
216 void setNotApplicableColor(
double r,
double g,
double b,
double alpha);
217 void setNotApplicableColor(
const double* color)
219 this->setNotApplicableColor(color[0], color[1], color[2], color[3]);
223 bool isNotApplicableColorSet()
const {
return m_isNotApplicableColorSet; }
228 const double* defaultColor()
const;
229 void setDefaultColor(
double r,
double g,
double b,
double alpha);
230 void setDefaultColor(
const double* color)
232 this->setDefaultColor(color[0], color[1], color[2], color[3]);
236 bool isDefaultColorSet()
const {
return m_isDefaultColorSet; }
270 void clearLocalAssociationRule();
272 bool associatesWithVertex()
const;
273 bool associatesWithEdge()
const;
274 bool associatesWithFace()
const;
275 bool associatesWithVolume()
const;
276 bool associatesWithModel()
const;
277 bool associatesWithGroup()
const;
289 AssociationResultType canBeAssociated(
308 std::size_t numberOfItemDefinitions()
const {
return m_itemDefs.size() + m_baseItemOffset; }
312 const std::vector<smtk::attribute::ItemDefinitionPtr>& localItemDefinitions()
const
322 typename smtk::internal::shared_ptr_type<T>::SharedPointerType addItemDefinition(
323 const std::string& name)
326 typename SharedTypes::SharedPointerType item;
329 if (this->findItemPosition(name) < 0)
331 std::size_t n = m_itemDefs.size();
332 item = SharedTypes::RawPointerType::New(name);
333 this->setItemDefinitionUnitsSystem(item);
334 m_itemDefs.push_back(item);
335 m_itemDefPositions[name] =
static_cast<int>(n);
336 this->updateDerivedDefinitions();
353 int findItemPosition(
const std::string& name)
const;
355 const std::string& detailedDescription()
const {
return m_detailedDescription; }
356 void setDetailedDescription(
const std::string& text) { m_detailedDescription = text; }
358 const std::string& briefDescription()
const {
return m_briefDescription; }
359 void setBriefDescription(
const std::string& text) { m_briefDescription = text; }
370 std::string rootName()
const {
return m_rootName; }
374 void resetItemOffset();
375 std::size_t itemOffset()
const {
return m_baseItemOffset; }
382 std::size_t includeIndex()
const {
return m_includeIndex; }
388 m_exclusionDefs.insert(def);
389 def->m_exclusionDefs.insert(this->shared_from_this());
395 const WeakDefinitionSet exclusions()
const {
return m_exclusionDefs; }
397 std::vector<std::string> excludedTypeNames()
const;
402 bool isUsedAsAPrerequisite()
const;
405 const WeakDefinitionSet prerequisites()
const {
return m_prerequisiteDefs; }
408 std::vector<std::string> prerequisiteTypeNames()
const;
415 bool hasPrerequisites()
const;
430 const std::string& myType,
442 void updateDerivedDefinitions();
448 virtual void applyAdvanceLevels(
449 const unsigned int& readLevelFromParent,
450 const unsigned int& writeLevelFromParent);
463 bool m_hasLocalAdvanceLevelInfo[2];
464 unsigned int m_localAdvanceLevel[2];
465 unsigned int m_advanceLevel[2];
479 bool m_ignoreCategories =
false;
493 static double s_notApplicableBaseColor[4];
494 static double s_defaultBaseColor[4];
496 double m_notApplicableColor[4];
497 double m_defaultColor[4];
512 return m_notApplicableColor;
518 return s_notApplicableBaseColor;
521 inline void Definition::setNotApplicableColor(
double r,
double g,
double b,
double a)
524 m_notApplicableColor[0] = r;
525 m_notApplicableColor[1] = g;
526 m_notApplicableColor[2] = b;
527 m_notApplicableColor[3] = a;
534 return m_defaultColor;
540 return s_defaultBaseColor;
543 inline void Definition::setDefaultColor(
double r,
double g,
double b,
double a)
546 m_defaultColor[0] = r;
547 m_defaultColor[1] = g;
548 m_defaultColor[2] = b;
549 m_defaultColor[3] = a;
555 std::function<
bool(
typename T::value_type)> test)
559 typename T::value_type testItem =
560 smtk::dynamic_pointer_cast<typename T::value_type::element_type>(item);
562 if (testItem && test(testItem))
564 filtered.insert(filtered.end(), testItem);
The main namespace for the Simulation Modeling Tool Kit (SMTK).
Definition: doc.h:33
void setIncludeIndex(std::size_t index)
These methods are use primarily by I/O operations.
Definition: Definition.h:380
Stores the definition of an attribute.
Definition: Definition.h:45
smtk::shared_ptr< smtk::attribute::Definition > DefinitionPtr
Definition: PublicPointerDefs.h:457
bool isUnique() const
Indicates if a persistent object can have multiple attributes of this type associated with it (true m...
Definition: Definition.h:200
bool ignoreCategories() const
Indicates that the Definition's validity (and relevancy) does not depends on the Resource's set of ac...
Definition: Definition.h:423
bool m_isNodal
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:460
Tags m_tags
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:487
const smtk::attribute::Categories & categories() const
Returns the categories (both explicitly assigned and inherited) associated to the Definition.
Definition: Definition.h:137
Definition: Categories.h:146
smtk::weak_ptr< smtk::attribute::Resource > WeakResourcePtr
Definition: PublicPointerDefs.h:615
smtk::attribute::Categories::Set & localCategories()
Returns the categories explicitly assigned to the Definition.
Definition: Definition.h:147
bool hasLocalAdvanceLevelInfo(int mode=0) const
Returns true if the definition is returning its local advance level information.
Definition: Definition.h:193
const double * defaultColor() const
Default Color for attributes created from this definition - If the color has not been set and the def...
Definition: Definition.h:530
bool m_isDefaultColorSet
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:478
Categories::CombinationMode categoryInheritanceMode() const
Determines how the Definition should combine its local category Set with the category constraints bei...
Definition: Definition.h:142
void clearResource()
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:434
std::string m_label
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:459
unsigned int BitFlags
The integer type used to hold bit values describing an entity's type.
Definition: EntityTypeBits.h:25
void unsetDefaultColor()
By unsetting the color it is now inherited from the def's base definition.
Definition: Definition.h:235
void setRootName(const std::string &val)
Sets and returns the root name to be used to construct the name for an attribute.
Definition: Definition.h:369
WeakDefinitionSet m_prerequisiteDefs
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:467
attribute::Categories::Set m_localCategories
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:461
smtk::shared_ptr< const smtk::resource::PersistentObject > ConstPersistentObjectPtr
Definition: PublicPointerDefs.h:294
std::vector< smtk::attribute::ItemDefinitionPtr > m_itemDefs
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:470
const Tags & tags() const
return the smtk::attribute::Tags associated with the Definition
Definition: Definition.h:85
std::map< std::string, int > m_itemDefPositions
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:471
smtk::attribute::WeakResourcePtr m_resource
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:454
Definition: PublicPointerDefs.h:756
std::string m_detailedDescription
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:482
size_t m_prerequisiteUsageCount
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:469
std::string m_briefDescription
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:483
std::size_t m_baseItemOffset
Used by the find method to calculate an item's position.
Definition: Definition.h:485
const double * notApplicableColor() const
Color Specifications Color in the case the attribute does not exist on the model entity If the color ...
Definition: Definition.h:508
void setIgnoreCategories(bool val)
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:424
std::string m_rootName
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:486
bool m_isNotApplicableColorSet
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:477
smtk::shared_ptr< smtk::attribute::Attribute > AttributePtr
Definition: PublicPointerDefs.h:463
void filterItemDefinitions(T &values, std::function< bool(typename T::value_type)> test)
Given a container, filter item definitions in the definition by a lambda function.
Definition: Definition.h:553
std::string m_type
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:458
void resetItemOffset()
This method resets the definition item offset - this is used by the resource when a definition is mod...
Definition: Definition.h:500
smtk::attribute::DefinitionPtr m_baseDefinition
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:457
smtk::shared_ptr< smtk::attribute::ReferenceItemDefinition > ReferenceItemDefinitionPtr
Definition: PublicPointerDefs.h:540
Store information about attribute definitions and instances.
Definition: Resource.h:76
void setCategoryInheritanceMode(Categories::CombinationMode mode)
Determines how the Definition should combine its local category Set with the category constraints bei...
Definition: Definition.h:143
Represent a (possibly composite) value according to a definition.
Definition: Attribute.h:50
void unsetNotApplicableColor()
By unsetting the color it is now inherited from the def's base definition.
Definition: Definition.h:222
Represents the category constraints associated with an Attribute, Attribute Definition,...
Definition: Categories.h:32
Categories::CombinationMode m_combinationMode
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:489
bool m_isUnique
Is Unique indicates if more than one attribute of this type can be assigned to a model entity - this ...
Definition: Definition.h:475
Definition: Definition.h:58
void addExclusion(smtk::attribute::DefinitionPtr def)
Since Exclusion Constraints are symmetric this method will also insert this "definiton" into def.
Definition: Definition.h:386
WeakDefinitionSet m_exclusionDefs
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:466
bool m_isAbstract
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:456
Categories::Set represents a single category constraint used by the Categories class.
Definition: Categories.h:60
bool m_isRequired
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:476
Macros for dealing with shared-pointer classes.
#define smtkTypeMacroBase(...)
Add typedefs to a class for identifcation.
Definition: SharedFromThis.h:131
smtk::shared_ptr< smtk::attribute::ItemDefinition > ItemDefinitionPtr
Definition: PublicPointerDefs.h:480
smtk::attribute::ReferenceItemDefinitionPtr m_acceptsRules
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:480
void setLocalCategories(const smtk::attribute::Categories::Set &catSet)
Sets the local categories.
Definition: Definition.h:154
CombinationMode
Definition: Categories.h:35
AssociationResultType
Return types for canBeAssociated method.
Definition: Definition.h:49
int m_version
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:455
smtk::shared_ptr< const smtk::attribute::ReferenceItemDefinition > ConstReferenceItemDefinitionPtr
Definition: PublicPointerDefs.h:594
attribute::Categories m_categories
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:462
smtk::shared_ptr< smtk::attribute::Resource > ResourcePtr
Definition: PublicPointerDefs.h:611
std::size_t m_includeIndex
Used to keep track of how many definitions are using this one as a prerequisite.
Definition: Definition.h:488
bool isNodal() const
Indicates if the attribute applies to the nodes of the analysis mesh.
Definition: Definition.h:208
smtk::weak_ptr< smtk::attribute::Definition > WeakDefinitionPtr
Definition: PublicPointerDefs.h:461
smtk::shared_ptr< const smtk::attribute::Definition > ConstDefinitionPtr
Definition: PublicPointerDefs.h:459