Commit df83a36d authored by Bob Obara's avatar Bob Obara Committed by Kitware Robot

Merge topic 'addingAnalysisView'

abe958e3 Adding support for Analysis
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: John Tourtellott's avatarJohn Tourtellott <john.tourtellott@kitware.com>
Merge-request: !1489
parents b534a8b0 abe958e3
Pipeline #131717 running with stage
#Changes to Attribute Resource
* Added the concept of Parent Analysis. The parent relationship is used to determine the categories associated with an analysis.
* Added the concept of Top Level Analyses - these are analyses that do not have a parent.
* Added the ability to create an attribute definition to represent the analysis structure.
* IO (both JSON and XML) have been changed to support Analysis Parent Relationships.
......@@ -3,3 +3,31 @@ This view has the same syntax as an Attribute View but only allows the user to c
#Changes to Attribute View
* added a new XML attribute "HideAssociations". If set to true the view will not display the association editing widget save screen Real Estate
#New View Type - Analysis
An Analysis View is a specialized view for choosing the types of analyses the user wants to perform. These choices are persistent and can be used by an export operation instead of having the operator ask the user what types of analyses should be performed.
Unlike other views the Analysis View will construct both an Attribute Definition and corresponding Attribute when needed. The Attribute Definition is based on the Analysis Information stored in the Attribute Resource. Any Analysis that is referred to by another will be represented as a Group Item. All other Analyses will be represented as a Void Item.
The View also controls which categories are permitted to be displayed and/or selected. The set is union of all of the selected Analyses' categories.
The following is an example of a Analysis View:
```xml
<View Type="Analysis" Title="Analysis" AnalysisAttributeName="truchasAnalysis"
AnalysisAttributeType="truchasAnalysisDefinition">
</View>
```
* AnalysisAttributeType is the name of the Attribute Definition the view will create to represent the Analysis Structure (if needed)
* AnalysisAttributeName is the name of the Attribute the view will create to represent the Analysis (if needed)
#Changes to Group View
* View no longer displays empty tabs
# Changes to BaseView
* Added the concept of top level categories that represents a set of categories (that can be a subset of those defined in the attribute resource) that can be used to display or filter attribute information.
#Changes to UIManager
* Added the ability to enable/disable category filtering
* Added support for top-level categories
......@@ -14,10 +14,12 @@
#include "smtk/attribute/Attribute.h"
#include "smtk/attribute/Definition.h"
#include "smtk/attribute/GroupItemDefinition.h"
#include "smtk/attribute/RefItem.h"
#include "smtk/attribute/RefItemDefinition.h"
#include "smtk/attribute/ValueItem.h"
#include "smtk/attribute/ValueItemDefinition.h"
#include "smtk/attribute/VoidItemDefinition.h"
#include "smtk/model/Resource.h"
......@@ -1008,3 +1010,106 @@ void Resource::disassociateAllAttributes(const smtk::resource::PersistentObjectP
}
}
}
bool Resource::setAnalysisParent(const std::string& analysisName, const std::string& analysisParent)
{
// First verify that both the analysis and the parent actually are defined
if ((m_analyses.find(analysisName) == m_analyses.end()) ||
(m_analyses.find(analysisParent) == m_analyses.end()))
{
return false;
}
m_analysisParent[analysisName] = analysisParent;
m_analysisChildren[analysisParent].insert(analysisName);
return true;
}
std::string Resource::analysisParent(const std::string& analysisName) const
{
auto it = m_analysisParent.find(analysisName);
if (it == m_analysisParent.end())
{
return "";
}
return it->second;
}
std::set<std::string> Resource::analysisChildren(const std::string& analysisName) const
{
auto it = m_analysisChildren.find(analysisName);
if (it == m_analysisChildren.end())
{
std::set<std::string> empty;
return empty;
}
return it->second;
}
std::set<std::string> Resource::topLevelAnalyses() const
{
std::set<std::string> res;
for (auto const& analysis : m_analyses)
{
if (m_analysisParent.find(analysis.first) == m_analysisParent.end())
{
res.insert(res.end(), analysis.first);
}
}
return res;
}
void Resource::buildAnalysisChildren(GroupItemDefinitionPtr& gitem, const std::string& analysis)
{
auto children = this->analysisChildren(analysis);
if (children.size())
{
auto aitem = gitem->addItemDefinition<GroupItemDefinition>(analysis);
aitem->setIsOptional(true);
for (auto child : children)
{
this->buildAnalysisChildren(aitem, child);
}
}
else
{
auto aitem = gitem->addItemDefinition<VoidItemDefinition>(analysis);
aitem->setIsOptional(true);
}
}
DefinitionPtr Resource::buildAnalysesDefinition(const std::string& type)
{
// First see if the defintion already exists
auto def = this->findDefinition(type);
if (def)
{
return smtk::attribute::DefinitionPtr();
}
// Ok lets build a definition with the following rules:
// 1. All items are optional and each respresents an Analysis
// 2. An Analysis with no children is a void item
// 3. An Analsyis with children is a group item
def = this->createDefinition(type);
auto topAnalyses = this->topLevelAnalyses();
for (auto analysis : topAnalyses)
{
auto children = this->analysisChildren(analysis);
if (children.size())
{
auto aitem = def->addItemDefinition<GroupItemDefinition>(analysis);
aitem->setIsOptional(true);
for (auto child : children)
{
this->buildAnalysisChildren(aitem, child);
}
}
else
{
auto aitem = def->addItemDefinition<VoidItemDefinition>(analysis);
aitem->setIsOptional(true);
}
}
return def;
}
......@@ -143,10 +143,17 @@ public:
smtk::attribute::ConstDefinitionPtr attDef) const;
bool rename(AttributePtr att, const std::string& newName);
// Analysis Methods
bool defineAnalysis(const std::string& analysisName, const std::set<std::string>& categories);
std::size_t numberOfAnalyses() const { return m_analyses.size(); }
std::set<std::string> analysisCategories(const std::string& analysisType) const;
const std::map<std::string, std::set<std::string> >& analyses() const { return m_analyses; }
bool setAnalysisParent(const std::string& analysisName, const std::string& analysisParent);
std::string analysisParent(const std::string& analysisName) const;
std::set<std::string> analysisChildren(const std::string& analysisName) const;
std::set<std::string> topLevelAnalyses() const;
DefinitionPtr buildAnalysesDefinition(const std::string& type);
std::size_t numberOfAdvanceLevels() const { return m_advLevels.size(); }
void addAdvanceLevel(int level, std::string label, const double* l_color = 0);
......@@ -227,6 +234,7 @@ protected:
attribute::DefinitionPtr def, std::vector<smtk::attribute::AttributePtr>& result) const;
bool copyDefinitionImpl(const smtk::attribute::DefinitionPtr sourceDef,
smtk::attribute::ItemDefinition::CopyInfo& info);
void buildAnalysisChildren(GroupItemDefinitionPtr& gitem, const std::string& analysis);
std::map<std::string, smtk::attribute::DefinitionPtr> m_definitions;
std::map<std::string, std::set<smtk::attribute::AttributePtr, Attribute::CompareByName> >
......@@ -239,6 +247,8 @@ protected:
m_derivedDefInfo;
std::set<std::string> m_categories;
std::map<std::string, std::set<std::string> > m_analyses;
std::map<std::string, std::set<std::string> > m_analysisChildren;
std::map<std::string, std::string> m_analysisParent;
std::map<std::string, smtk::view::ViewPtr> m_views;
// Advance levels, <int-level, <string-label, color[4]>
......
......@@ -48,7 +48,21 @@ SMTKCORE_EXPORT void to_json(json& j, const smtk::attribute::ResourcePtr& res)
}
if (res->numberOfAnalyses())
{
j["Analyses"] = res->analyses();
auto analyses = res->analyses();
j["Analyses"] = analyses;
std::map<std::string, std::string> parentInfo;
for (auto analysis : analyses)
{
auto parent = res->analysisParent(analysis.first);
if (parent != "")
{
parentInfo[analysis.first] = parent;
}
}
if (parentInfo.size())
{
j["AnalysesParentInfo"] = parentInfo;
}
}
// Write out the advance levels information
......@@ -202,16 +216,23 @@ SMTKCORE_EXPORT void from_json(const json& j, smtk::attribute::ResourcePtr& res)
// Process Analysis Info
// nlohmman's get function does not support nested map, so iterator is used
try
if (j.find("Analyses") != j.end())
{
json analyses = j.at("Analyses");
for (json::iterator iterAna = analyses.begin(); iterAna != analyses.end(); iterAna++)
{
res->defineAnalysis(iterAna.key(), iterAna.value());
}
}
catch (std::exception& /*e*/)
{
// Do we have parent infomation to deal with?
if (j.find("AnalysesParentInfo") != j.end())
{
json parentInfo = j.at("AnalysesParentInfo");
for (json::iterator iterAna = parentInfo.begin(); iterAna != parentInfo.end(); iterAna++)
{
res->setAnalysisParent(iterAna.key(), iterAna.value());
}
}
}
//Process AdvanceLevel info
......
......@@ -35,11 +35,14 @@ PySharedPtrClass< smtk::attribute::Resource, smtk::resource::Resource > pybind11
.def("advanceLevels", &smtk::attribute::Resource::advanceLevels)
.def("analyses", &smtk::attribute::Resource::analyses)
.def("analysisCategories", &smtk::attribute::Resource::analysisCategories, py::arg("analysisType"))
.def("analysisChildren", &smtk::attribute::Resource::analysisChildren, py::arg("analysisType"))
.def("analysisParent", &smtk::attribute::Resource::analysisParent, py::arg("analysisType"))
.def("associations", &smtk::attribute::Resource::associations)
.def("associate", &smtk::attribute::Resource::associate)
.def("attributes", (std::set<smtk::attribute::AttributePtr> (smtk::attribute::Resource::*)(const smtk::resource::ConstPersistentObjectPtr&) const) &smtk::attribute::Resource::attributes, py::arg("object"))
.def("attributes", (void (smtk::attribute::Resource::*)(std::vector<smtk::attribute::AttributePtr>&) const) &smtk::attribute::Resource::attributes, py::arg("result"))
.def("attributes", [](const smtk::attribute::Resource& sys){ std::vector<smtk::attribute::AttributePtr> result; sys.attributes(result); return result; })
.def("buildAnalysesDefinition", &smtk::attribute::Resource::analysisCategories, py::arg("analysisDefinitionType"))
.def("categories", &smtk::attribute::Resource::categories)
.def("copyAttribute", &smtk::attribute::Resource::copyAttribute, py::arg("att"), py::arg("copyModelAssociations") = false, py::arg("options") = 0)
.def("copyDefinition", &smtk::attribute::Resource::copyDefinition, py::arg("def"), py::arg("options") = 0)
......@@ -80,6 +83,8 @@ PySharedPtrClass< smtk::attribute::Resource, smtk::resource::Resource > pybind11
.def("removeAttribute", &smtk::attribute::Resource::removeAttribute, py::arg("att"))
.def("rename", &smtk::attribute::Resource::rename, py::arg("att"), py::arg("newName"))
.def("setAdvanceLevelColor", &smtk::attribute::Resource::setAdvanceLevelColor, py::arg("level"), py::arg("l_color"))
.def("setAnalysisParent", &smtk::attribute::Resource::setAnalysisParent, py::arg("analysisType"), py::arg("analysisParentType"))
.def("topLevelAnalyses", &smtk::attribute::Resource::topLevelAnalyses)
.def("updateCategories", &smtk::attribute::Resource::updateCategories)
.def("updateDerivedDefinitionIndexOffsets", &smtk::attribute::Resource::updateDerivedDefinitionIndexOffsets, py::arg("def"))
.def("views", &smtk::attribute::Resource::views)
......
......@@ -74,6 +74,7 @@ set(unit_tests
unitAttributeBasics
unitAttributeAssociation
unitAttributeAssociationConstraints
unitAttributeAnalysis
unitComponentItem.cxx
unitDateTimeItem.cxx
unitJsonItemDefinitions.cxx
......
//=========================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/attribute/Attribute.h"
#include "smtk/attribute/Definition.h"
#include "smtk/attribute/FileItem.h"
#include "smtk/attribute/GroupItemDefinition.h"
#include "smtk/attribute/IntItem.h"
#include "smtk/attribute/Resource.h"
#include "smtk/attribute/ResourceItem.h"
#include "smtk/attribute/VoidItemDefinition.h"
#include "smtk/attribute/operators/Read.h"
#include "smtk/attribute/operators/Write.h"
#include "smtk/io/AttributeReader.h"
#include "smtk/io/AttributeWriter.h"
#include "smtk/io/Logger.h"
#include "smtk/common/testing/cxx/helpers.h"
using namespace smtk::attribute;
using namespace smtk::common;
using namespace smtk;
namespace
{
void testLoadedAttributeResource(attribute::ResourcePtr& attRes, const std::string& prefix)
{
smtkTest((attRes->analysisParent("a1") == "a"), prefix << "a1's parent not a");
smtkTest((attRes->analysisParent("b") == ""), prefix << "b has a parent");
}
}
int unitAttributeAnalysis(int, char* [])
{
// ----
// I. Let's create an attribute resource and some analyses
attribute::ResourcePtr attRes = attribute::Resource::create();
std::set<std::string> cats;
cats.insert("foo");
attRes->defineAnalysis("a", cats);
attRes->defineAnalysis("b", cats);
attRes->defineAnalysis("c", cats);
attRes->defineAnalysis("a1", cats);
// Lets try to set the parent to something that doesn't exists
smtkTest(!(attRes->setAnalysisParent("z", "x")), "Succeded in setting z's parent to x");
smtkTest(!(attRes->setAnalysisParent("z", "a")), "Succeded in setting z's parent to a");
smtkTest(!(attRes->setAnalysisParent("a", "x")), "Succeded in setting a's parent to x");
// This should work
smtkTest(attRes->setAnalysisParent("a1", "a"), "Was not able to set a1's parent to a");
// Lets test out the attribute definition building method
// Definition should have 1 group (a), and 2 void (b, c) items. group a should have 1 void item (a1)
auto def = attRes->buildAnalysesDefinition("Analysis");
smtkTest((def != nullptr), "Could not build definition");
smtkTest((def->numberOfItemDefinitions() == 3), "Definition does not have 3 items") int pos =
def->findItemPosition("a");
smtkTest(pos > -1, "Could not find item a");
auto gitem =
std::dynamic_pointer_cast<smtk::attribute::GroupItemDefinition>(def->itemDefinition(pos));
smtkTest((gitem != nullptr), "a is not a group item");
pos = def->findItemPosition("b");
smtkTest(pos > -1, "Could not find item b");
auto vitem =
std::dynamic_pointer_cast<smtk::attribute::VoidItemDefinition>(def->itemDefinition(pos));
smtkTest((vitem != nullptr), "b is not a void item");
pos = def->findItemPosition("c");
smtkTest(pos > -1, "Could not find item c");
vitem = std::dynamic_pointer_cast<smtk::attribute::VoidItemDefinition>(def->itemDefinition(pos));
smtkTest((vitem != nullptr), "c is not a void item");
pos = def->findItemPosition("a1");
smtkTest(pos == -1, "Could find item a1 in Definition");
smtkTest((gitem->numberOfItemDefinitions() == 1), "a's group item does not have 1 item") pos =
gitem->findItemPosition("a1");
smtkTest(pos == 0, "Could not find item a1 in group item a");
vitem =
std::dynamic_pointer_cast<smtk::attribute::VoidItemDefinition>(gitem->itemDefinition(pos));
smtkTest((vitem != nullptr), "a1 is not a void item");
// Should fail if we try to create another with the same type name
def = attRes->buildAnalysesDefinition("Analysis");
smtkTest((def == nullptr), "CWas able to build second definition");
def = nullptr;
vitem = nullptr;
gitem = nullptr;
testLoadedAttributeResource(attRes, "Analysis Test (Original)");
io::AttributeWriter writer;
io::AttributeReader reader;
io::Logger logger;
std::string writeRroot(SMTK_SCRATCH_DIR);
std::string fname = writeRroot + "/unitAttributeAnalysisTest.sbi";
std::string rname = writeRroot + "/unitAttributeAnalysisTest.smtk";
//Test JSON File I/O
attRes->setLocation(rname);
smtk::attribute::Write::Ptr writeOp = smtk::attribute::Write::create();
writeOp->parameters()->associate(attRes);
auto opresult = writeOp->operate();
smtkTest(opresult->findInt("outcome")->value() ==
static_cast<int>(smtk::operation::Operation::Outcome::SUCCEEDED),
"JSON Write operation failed\n"
<< writeOp->log().convertToString());
attRes = nullptr;
smtk::attribute::Read::Ptr readOp = smtk::attribute::Read::create();
readOp->parameters()->findFile("filename")->setValue(rname);
opresult = readOp->operate();
smtkTest(opresult->findInt("outcome")->value() ==
static_cast<int>(smtk::operation::Operation::Outcome::SUCCEEDED),
"JSON Read operation failed\n"
<< writeOp->log().convertToString());
attRes = std::dynamic_pointer_cast<smtk::attribute::Resource>(
opresult->findResource("resource")->objectValue());
//Test the resource created using JSON
testLoadedAttributeResource(attRes, "Analysis Test (JSON)");
//Test XML File I/O
writer.write(attRes, fname, logger);
smtkTest(!logger.hasErrors(), "Error Generated when XML writing file ("
<< fname << "):\n"
<< logger.convertToString());
attRes = attribute::Resource::create();
reader.read(attRes, fname, logger);
smtkTest(!logger.hasErrors(), "Error Generated when XML reading file ("
<< fname << "):\n"
<< logger.convertToString());
//Test the resource created using XML
testLoadedAttributeResource(attRes, "Analysis Test (XML)");
return 0;
}
......@@ -16,6 +16,7 @@ set(QAttrLibSrcs
qtDescriptivePhraseEditor.cxx
qtDescriptivePhraseModel.cxx
qtGroupView.cxx
qtAnalysisView.cxx
qtAssociationView.cxx
qtAttributeView.cxx
qtInstancedView.cxx
......@@ -83,6 +84,7 @@ set(QAttrLibMocHeaders
qtDescriptivePhraseEditor.h
qtDescriptivePhraseModel.h
qtGroupView.h
qtAnalysisView.h
qtAssociationView.h
qtAttributeView.h
qtInstancedView.h
......
//=========================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/extension/qt/qtAnalysisView.h"
#include "smtk/attribute/Attribute.h"
#include "smtk/attribute/GroupItem.h"
#include "smtk/extension/qt/qtAttribute.h"
#include "smtk/extension/qt/qtUIManager.h"
#include "smtk/io/AttributeWriter.h"
#include "smtk/io/Logger.h"
#include "smtk/view/View.h"
#include <QApplication>
#include <QFile>
#include <QFont>
#include <QFrame>
#include <QHBoxLayout>
#include <QLabel>
#include <QScrollArea>
#include <QSize>
#include <QTabWidget>
#include <QVBoxLayout>
#include <QVariant>
#include <algorithm>
using namespace smtk::attribute;
using namespace smtk::extension;
qtBaseView* qtAnalysisView::createViewWidget(const ViewInfo& info)
{
qtAnalysisView* view = new qtAnalysisView(info);
view->buildUI();
return view;
}
qtAnalysisView::qtAnalysisView(const ViewInfo& info)
: qtBaseView(info)
{
}
qtAnalysisView::~qtAnalysisView()
{
}
void qtAnalysisView::createWidget()
{
smtk::view::ViewPtr view = this->getObject();
if (!view)
{
return;
}
this->Widget = new QFrame(this->parentWidget());
//create the layout for the frame area
QVBoxLayout* layout = new QVBoxLayout(this->Widget);
layout->setMargin(0);
this->Widget->setLayout(layout);
auto attRes = this->uiManager()->attResource();
std::string attName, defName;
view->details().attribute("AnalysisAttributeName", attName);
view->details().attribute("AnalysisAttributeType", defName);
// Lets see if we need to create the analysis
// attribute or its definition?
auto attDef = attRes->findDefinition(defName);
if (!attDef)
{
attDef = attRes->buildAnalysesDefinition(defName);
}
m_analysisAttribute = attRes->findAttribute(attName);
if (!m_analysisAttribute)
{
m_analysisAttribute = attRes->createAttribute(attName, attDef);
}
// OK Now lets create a qtAttribute for the Analysis Attribute
// Tell the UI Manager not to filter
this->uiManager()->disableCategoryChecks();
int labelWidth =
this->uiManager()->getWidthOfAttributeMaxLabel(attDef, this->uiManager()->advancedFont());
this->setFixedLabelWidth(labelWidth);
smtk::view::View::Component comp; // Right now not being used
qtAttribute* attInstance = new qtAttribute(m_analysisAttribute, comp, this->widget(), this);
attInstance->createBasicLayout(true);
this->uiManager()->enableCategoryChecks();
layout->addWidget(attInstance->widget());
QObject::connect(attInstance, SIGNAL(modified()), this, SLOT(analysisChanged()));
// OK - lets apply the initial state.
this->analysisChanged();
}
void qtAnalysisView::processAnalysisItem(
smtk::attribute::ConstItemPtr item, std::set<std::string>& cats)
{
// If the item is not active there is nothing to do
if (!item->isEnabled())
{
return;
}
auto attRes = this->uiManager()->attResource();
auto myCats = attRes->analysisCategories(item->name());
cats.insert(myCats.begin(), myCats.end());
auto gitem = std::dynamic_pointer_cast<const GroupItem>(item);
if (gitem == nullptr)
{
return;
}
std::size_t i, n = gitem->numberOfItemsPerGroup();
for (i = 0; i < n; i++)
{
this->processAnalysisItem(gitem->item(i), cats);
}
}
void qtAnalysisView::analysisChanged()
{
// Lets iterate over the items in the analysis attribute and set
// the categories accordingly
std::set<std::string> cats;
std::size_t i, n = m_analysisAttribute->numberOfItems();
for (i = 0; i < n; i++)
{
this->processAnalysisItem(m_analysisAttribute->item(i), cats);
}
this->uiManager()->setToLevelCategories(cats);
}
//=========================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#ifndef __smtk_extension_qtAnalysisView_h
#define __smtk_extension_qtAnalysisView_h
#include "smtk/extension/qt/Exports.h"
#include "smtk/extension/qt/qtBaseView.h"
#include <set>
/**\brief Provides the QT UI for an Analysis View.
*
* An Analysis View is a specialized view for choosing the types of analyses the user wants to
* perform. These choices are persistent and can be used by an export operation instead of having
* the operator ask the user what types of analyses should be performed.
*
* Unlike other views the Analysis View will construct both an Attribute Definition and
* corresponding Attribute when needed. The Attribute Definition is based on the Analysis Information
* stored in the Attribute Resource. Any Analysis that is referred to by another will be represented
* as a Group Item. All other Analyses will be represented as a Void Item.
*
* The View also controls which categories are permitted to be displayed and/or selected. The set
* is union of all of the selected Analyses' categories.
*
* The following is an example of a Analysis View:
* <View Type="Analysis" Title="Analysis" AnalysisAttributeName="truchasAnalysis" AnalysisAttributeType="truchasAnalysisDefinition">
* </View>
*
* AnalysisAttributeType is the name of the Attribute Definition the view will create to represent the
* Analysis Structure (if needed)
*
* AnalysisAttributeName is the name of the Attribute the view will create to represent the
* Analysis (if needed)
*
* \sa qtBaseView
*/
namespace smtk
{
namespace extension
{
class SMTKQTEXT_EXPORT qtAnalysisView : public qtBaseView
{
Q_OBJECT
public:
static qtBaseView* createViewWidget(const ViewInfo& info);
qtAnalysisView(const ViewInfo& info);
virtual ~qtAnalysisView();
public slots:
void analysisChanged();
protected:
void createWidget() override;
void processAnalysisItem(smtk::attribute::ConstItemPtr item, std::set<std::string>& cats);
private:
smtk::attribute::AttributePtr m_analysisAttribute;
}; // class
}; // namespace attribute
}; // namespace smtk
#endif
......@@ -40,14 +40,57 @@ using namespace smtk::extension;
class qtAssociationViewInternals : public Ui::qtAssociationView
{
public:
const QList<smtk::attribute::DefinitionPtr> getCurrentDefs(const QString strCategory) const
QList<smtk::attribute::DefinitionPtr> getCurrentDefs(
smtk::extension::qtUIManager* uiManager) const
{
if (uiManager->categoryEnabled())
{
auto currentCat = uiManager->currentCategory();
if (this->AttDefMap.keys().contains(currentCat.c_str()))
{
return this->AttDefMap[currentCat.c_str()];
}
return this->AllDefs;
}
else if (!uiManager->topLevelCategoriesSet())
{
return this->AllDefs;
}
QList<smtk::attribute::DefinitionPtr> defs;
foreach (DefinitionPtr attDef, this->AllDefs)
{
if (uiManager->passAttributeCategoryCheck(attDef))
{
defs.push_back(attDef);
}
}
return defs;
}
if (this->AttDefMap.keys().contains(strCategory))
bool currentDefsIsEmpty(smtk::extension::qtUIManager* uiManager) const
{
if (uiManager->categoryEnabled())
{
auto currentCat = uiManager->currentCategory();
if (this->AttDefMap.keys().contains(currentCat.c_str()))
{
return (this->AttDefMap[currentCat.c_str()].size() == 0);
}
return (this->AllDefs.size() == 0);
}
else if (!uiManager->topLevelCategoriesSet())
{
return (this->AllDefs.size() == 0);
}
QList<smtk::attribute::DefinitionPtr> defs;