Commit 68fcecfa authored by T.J. Corona's avatar T.J. Corona Committed by Kitware Robot

Merge topic 'QEntityItemModel-add-default-colors' into release

390bfb54 FEATURE: Store default color on QEntityItemModel
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Haocheng LIU's avatarHaocheng Liu <haocheng.liu@kitware.com>
Merge-request: !924
parents 1012b19f 390bfb54
......@@ -137,6 +137,7 @@ add_library(smtkQtExt
#we need to add the location of the moc files to the include dir for qtsmtk
target_include_directories(smtkQtExt PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
#set smtkQtExt to publicly link to smtkCore
#set smtkQtExt to publicly link to smtkCore
target_link_libraries(smtkQtExt LINK_PUBLIC
smtkCore
......
......@@ -66,6 +66,7 @@ namespace smtk
{
namespace extension
{
std::map<std::string, QColor> QEntityItemModel::s_defaultColors = {};
/// Private storage for QEntityItemModel.
class QEntityItemModel::Internal
......@@ -127,6 +128,17 @@ QEntityItemModel::~QEntityItemModel()
delete this->P;
}
QColor QEntityItemModel::defaultEntityColor(const std::string& entityType)
{
if (s_defaultColors.find(entityType) == s_defaultColors.end())
{
return QColor();
}
else
{
return s_defaultColors[entityType];
}
}
void QEntityItemModel::clear()
{
if (this->m_root && !this->m_root->subphrases().empty())
......@@ -393,8 +405,23 @@ QVariant QEntityItemModel::data(const QModelIndex& idx, int role) const
FloatList rgba = item->relatedColor();
if (rgba.size() >= 4 && rgba[3] < 0)
{
// assign an invalid color
color = QColor(255, 255, 255, 0);
if (item->relatedEntity().isFace())
{
color = QEntityItemModel::defaultEntityColor("Face");
}
else if (item->relatedEntity().isEdge())
{
color = QEntityItemModel::defaultEntityColor("Edge");
}
else if (item->relatedEntity().isVertex())
{
color = QEntityItemModel::defaultEntityColor("Vertex");
}
else
{
// Assign an invalid color
color = QColor(255, 255, 255, 0);
}
}
else
{
......
......@@ -46,6 +46,13 @@ class SMTKQTEXT_EXPORT QEntityItemModel : public QAbstractItemModel
public:
QEntityItemModel(QObject* parent = 0);
virtual ~QEntityItemModel();
// Set and get default entity color
static void setDefaultEntityColor(const std::string& entityType, const QColor& color)
{
s_defaultColors[entityType] = color;
}
static QColor defaultEntityColor(const std::string& entityType);
void clear();
......@@ -130,6 +137,7 @@ signals:
protected:
smtk::model::DescriptivePhrasePtr m_root;
bool m_deleteOnRemoval; // remove UUIDs from mesh when they are removed from the list?
static std::map<std::string, QColor> s_defaultColors;
class Internal;
Internal* P;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment