##// END OF EJS Templates
Separate the initialization of the properties of the graph of the update of the units of the graph....
Separate the initialization of the properties of the graph of the update of the units of the graph. The initialization of the properties is carried out when adding a variable in the graph, the update of the units is carried out when loading the data of this variable

File last commit:

r1120:a02153d618e2
r1337:3acf26407503
Show More
VisualizationSelectionZoneManager.cpp
51 lines | 1.5 KiB | text/x-c | CppLexer
/ gui / src / Visualization / VisualizationSelectionZoneManager.cpp
#include "Visualization/VisualizationSelectionZoneManager.h"
#include "Visualization/VisualizationSelectionZoneItem.h"
struct VisualizationSelectionZoneManager::VisualizationSelectionZoneManagerPrivate {
QVector<VisualizationSelectionZoneItem *> m_SelectedItems;
};
VisualizationSelectionZoneManager::VisualizationSelectionZoneManager()
: impl{spimpl::make_unique_impl<VisualizationSelectionZoneManagerPrivate>()}
{
}
void VisualizationSelectionZoneManager::select(
const QVector<VisualizationSelectionZoneItem *> &items)
{
clearSelection();
for (auto item : items) {
setSelected(item, true);
}
}
void VisualizationSelectionZoneManager::setSelected(VisualizationSelectionZoneItem *item,
bool value)
{
if (value != item->selected()) {
item->setSelected(value);
item->parentPlot()->replot(QCustomPlot::rpQueuedReplot);
}
if (!value && impl->m_SelectedItems.contains(item)) {
impl->m_SelectedItems.removeAll(item);
}
else if (value) {
impl->m_SelectedItems << item;
}
}
void VisualizationSelectionZoneManager::clearSelection()
{
for (auto item : impl->m_SelectedItems) {
item->setSelected(false);
item->parentPlot()->replot(QCustomPlot::rpQueuedReplot);
}
impl->m_SelectedItems.clear();
}
QVector<VisualizationSelectionZoneItem *> VisualizationSelectionZoneManager::selectedItems() const
{
return impl->m_SelectedItems;
}