Skip to content
Snippets Groups Projects
Commit de219014 authored by Fabian Tërnava's avatar Fabian Tërnava
Browse files

refactor variable names and method names to better emphasize their use.

Added method to get the states of the available memories checkboxes.
parent 7c924562
No related branches found
No related tags found
1 merge request!326Allow loading of LTM exports to the Viewer, although the memory servers have not been started
......@@ -150,7 +150,7 @@ namespace armarx::armem::gui
connect(this, &This::connected, this, &This::startPeriodicUpdateTimer);
connect(updateWidget, &armem::gui::PeriodicUpdateWidget::update, this, &This::startQueries);
connect(periodicUpdateTimer, &QTimer::timeout, this, &This::updateAvailableMemories);
connect(periodicUpdateTimer, &QTimer::timeout, this, &This::updateListOfActiveMemories);
connect(periodicUpdateTimer, &QTimer::timeout, this, &This::processQueryResults);
connect(memoryGroup->queryWidget(), &armem::gui::QueryWidget::storeInLTM, this, &This::queryAndStoreInLTM);
......@@ -288,7 +288,7 @@ namespace armarx::armem::gui
{
TIMING_START(MemoryStore);
auto enabledMemories = memoryGroup->queryWidget()->enabledMemories();
auto enabledMemories = memoryGroup->queryWidget()->getEnabledMemories();
for (auto& [name, reader] : memoryReaders)
{
// skip if memory should not be queried
......@@ -321,7 +321,7 @@ namespace armarx::armem::gui
TIMING_START(MemoryStartRecording);
auto enabledMemories = memoryGroup->queryWidget()->enabledMemories();
auto enabledMemories = memoryGroup->queryWidget()->getEnabledMemories();
for (auto& [name, reader] : memoryReaders)
{
// skip if memory should not be queried
......@@ -341,7 +341,7 @@ namespace armarx::armem::gui
TIMING_START(MemoryStopRecording);
auto enabledMemories = memoryGroup->queryWidget()->enabledMemories();
auto enabledMemories = memoryGroup->queryWidget()->getEnabledMemories();
for (auto& [name, reader] : memoryReaders)
{
// skip if memory should not be queried
......@@ -487,7 +487,7 @@ namespace armarx::armem::gui
// Can't use a structured binding here because you can't capture those in a lambda
// according to the C++ standard.
auto enabledMemories = memoryGroup->queryWidget()->enabledMemories();
auto enabledMemories = memoryGroup->queryWidget()->getEnabledMemories();
for (const auto& pair : memoryReaders)
{
// skip if memory should not be queried
......@@ -592,7 +592,7 @@ namespace armarx::armem::gui
}
// Perhaps remove entries
auto enabledMemories = memoryGroup->queryWidget()->enabledMemories();
auto enabledMemories = memoryGroup->queryWidget()->getEnabledMemories();
for (auto it = memoryData.begin(); it != memoryData.end();)
{
// Drop all entries in memoryData which are not in memoryReaders anymore.
......@@ -764,7 +764,7 @@ namespace armarx::armem::gui
void
MemoryViewer::updateAvailableMemories()
MemoryViewer::updateListOfActiveMemories()
{
if (is_connected and mns) // mns must be connected and mns must be available
{
......@@ -773,11 +773,13 @@ namespace armarx::armem::gui
memoryReaders = mns.getAllReaders(true);
memoryWriters = mns.getAllWriters(true);
std::vector<std::string> convVec;
std::transform(memoryReaders.begin(), memoryReaders.end(), std::back_inserter(convVec), [](const auto& p){return p.first;});
std::vector<std::string> activeMemoryNames;
// add all active memories to update list
std::transform(memoryReaders.begin(), memoryReaders.end(), std::back_inserter(activeMemoryNames), [](const auto& p){return p.first;});
TIMING_START(GuiUpdateAvailableMemories);
memoryGroup->queryWidget()->update(convVec);
memoryGroup->queryWidget()->update(activeMemoryNames);
TIMING_END_STREAM(GuiUpdateAvailableMemories, ARMARX_VERBOSE);
}
catch (...)
......@@ -796,14 +798,16 @@ namespace armarx::armem::gui
void
MemoryViewer::updateMemoryTree()
{
std::map<std::string, const armem::wm::Memory*> convMap;
std::map<std::string, const armem::wm::Memory*> memoriesToUpdate;
//auto checkboxStates = memoryGroup->queryWidget()->getAvailableMemoryStates();
for (auto& [name, data] : memoryData)
{
convMap[name] = &data;
memoriesToUpdate[name] = &data;
}
TIMING_START(GuiUpdateMemoryTree)
memoryGroup->tree()->update(convMap);
memoryGroup->tree()->update(memoriesToUpdate);
TIMING_END_STREAM(GuiUpdateMemoryTree, ARMARX_VERBOSE)
if (debugObserver)
......
......@@ -110,7 +110,7 @@ namespace armarx::armem::gui
void processQueryResults();
void updateMemoryTree();
void updateAvailableMemories();
void updateListOfActiveMemories();
signals:
......
......@@ -162,8 +162,35 @@ namespace armarx::armem::gui
return _dropDisabledCheckBox->isChecked();
}
std::map<std::string, QueryWidget::ActiveMemoryState> QueryWidget::getAvailableMemoryStates() const
{
std::scoped_lock l(enabledMemoriesMutex);
std::map<std::string, QueryWidget::ActiveMemoryState> states;
int maxIndex = _availableMemoriesGroupBox->layout()->count();
for (int i = 0; i < maxIndex; ++i)
{
auto w = _availableMemoriesGroupBox->layout()->itemAt(i)->widget();
QCheckBox* box = static_cast<QCheckBox*>(w);
std::string memoryName = box->text().toStdString();
if (box->isEnabled() && box->isChecked())
{
states[memoryName] = ActiveMemoryState::FoundAndChecked;
}
else if (box->isEnabled() && !box->isChecked())
{
states[memoryName] = ActiveMemoryState::FoundAndNotChecked;
}
else
{
states[memoryName] = ActiveMemoryState::NotFound;
}
}
return states;
}
std::vector<std::string> QueryWidget::enabledMemories() const
std::vector<std::string> QueryWidget::getEnabledMemories() const
{
std::scoped_lock l(enabledMemoriesMutex);
......
......@@ -22,6 +22,13 @@ namespace armarx::armem::gui
public:
enum class ActiveMemoryState
{
FoundAndChecked,
FoundAndNotChecked,
NotFound
};
QueryWidget();
armem::query::DataMode dataMode() const;
......@@ -31,7 +38,9 @@ namespace armarx::armem::gui
int queryLinkRecursionDepth() const;
std::vector<std::string> enabledMemories() const;
std::map<std::string, ActiveMemoryState> getAvailableMemoryStates() const;
std::vector<std::string> getEnabledMemories() const;
void update(const std::vector<std::string>& memoryNames);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment