SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Member Functions | Protected Attributes | List of all members
smtk::view::Badge Class Referenceabstract

A base class for descriptive-phrase badges. More...

#include <Badge.h>

Inheritance diagram for smtk::view::Badge:
[legend]
Collaboration diagram for smtk::view::Badge:
[legend]

Public Member Functions

 smtkTypeMacroBase (Badge)
 
 Badge (const Badge &)=delete
 
Badgeoperator= (const Badge &)=delete
 
virtual bool appliesToPhrase (const DescriptivePhrase *) const
 Returns true if the badge should appear next to the given phrase:
 
virtual std::string tooltip (const DescriptivePhrase *) const
 Return a tool-tip string for the badge that is relevant to this phrase. More...
 
virtual std::string icon (const DescriptivePhrase *phrase, const std::array< float, 4 > &background) const =0
 Returns a string for rendering the badge icon. More...
 
virtual bool action (const DescriptivePhrase *, const BadgeAction &)
 Take an action when the badge is clicked. More...
 
bool isDefault () const
 Return whether this badge be invoked by non-specific user gestures. More...
 
void setIsDefault (bool isDefault)
 Set this badge as a default.
 

Protected Attributes

bool m_isDefault { false }
 Should this badge be invoked by non-specific user gestures when it is applicable?
 

Detailed Description

A base class for descriptive-phrase badges.

A badge is responsible for

A badge may be marked as being a "default." This indicates that user gestures that are not specific to any badge may still apply an badge action; the first applicable badge marked as default should have it action invoked in response to these gestures. An example is how qtReferenceItem uses MembershipBadge: when users click on the title of a phrase (not any badge), it is still desirable for the membership of the phrase to be changed, so the MembershipBadge is marked as default.

Member Function Documentation

◆ action()

virtual bool smtk::view::Badge::action ( const DescriptivePhrase ,
const BadgeAction  
)
inlinevirtual

Take an action when the badge is clicked.

Return true if the action is supported (and was taken) by the badge for the given phrase; otherwise return false.

Reimplemented in smtk::extension::qt::MembershipBadge, smtk::extension::paraview::appcomponents::VisibilityBadge, and smtk::extension::qt::TypeAndColorBadge.

◆ icon()

virtual std::string smtk::view::Badge::icon ( const DescriptivePhrase phrase,
const std::array< float, 4 > &  background 
) const
pure virtual

Returns a string for rendering the badge icon.

The string is currently interpreted by qtDescriptivePhraseDelegate::paint() as scalable vector graphics (SVG).

The icon may change depending on (1) the state of the phrase or its parent view, (2) the background color of the phrase.

Implemented in smtk::view::AssociationBadge, smtk::view::ObjectIconBadge, smtk::view::LockedResourceBadge, smtk::extension::qt::MembershipBadge, and smtk::extension::paraview::appcomponents::VisibilityBadge.

◆ isDefault()

bool smtk::view::Badge::isDefault ( ) const
inline

Return whether this badge be invoked by non-specific user gestures.

This should only be called when appliesToPhrase() returns true.

◆ tooltip()

virtual std::string smtk::view::Badge::tooltip ( const DescriptivePhrase ) const
inlinevirtual

Return a tool-tip string for the badge that is relevant to this phrase.

An empty string (the default) indicates that no tooltip should be shown. If a non-empty string is returned, it should describe the meaning of the badge to the user. If the badge changes its SVG based on application state, the tip should be specific to its current state.

For example, a badge that controls visibility of a phrase's subject in a render-window should say either "Click to show <title>" when the phrase's subject is hidden or "Click to hide <title>" when the phrase's subject is visible.

Reimplemented in smtk::view::AssociationBadge, smtk::view::LockedResourceBadge, smtk::view::ObjectIconBadge, and smtk::extension::paraview::appcomponents::VisibilityBadge.


The documentation for this class was generated from the following file: