##// END OF EJS Templates
Add merge API and implement it for the DataSeries
Add merge API and implement it for the DataSeries

File last commit:

r205:d787e1653d55
r217:508df86e5db1
Show More
VisualizationTabWidget.cpp
105 lines | 2.7 KiB | text/x-c | CppLexer
/ gui / src / Visualization / VisualizationTabWidget.cpp
mv visualization -> Visualization...
r93 #include "Visualization/VisualizationTabWidget.h"
Alexandre Leroux
Updates visitor interface...
r192 #include "Visualization/IVisualizationWidgetVisitor.h"
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 #include "ui_VisualizationTabWidget.h"
Add the visualization gui classes
r111 #include "Visualization/VisualizationZoneWidget.h"
Alexandre Leroux
Adds logs for null visitors
r204 Q_LOGGING_CATEGORY(LOG_VisualizationTabWidget, "VisualizationTabWidget")
Alexandre Leroux
Completes the method of creating a zone from a variable
r187 namespace {
/// Generates a default name for a new zone, according to the number of zones already displayed in
/// the tab
QString defaultZoneName(const QLayout &layout)
{
auto count = 0;
for (auto i = 0; i < layout.count(); ++i) {
if (dynamic_cast<VisualizationZoneWidget *>(layout.itemAt(i)->widget())) {
count++;
}
}
return QObject::tr("Zone %1").arg(count + 1);
}
} // namespace
Alexandre Leroux
Adds a name for a tab...
r184 struct VisualizationTabWidget::VisualizationTabWidgetPrivate {
explicit VisualizationTabWidgetPrivate(const QString &name) : m_Name{name} {}
Add the visualization gui classes
r111
Alexandre Leroux
Adds a name for a tab...
r184 QString m_Name;
};
VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *parent)
: QWidget{parent},
ui{new Ui::VisualizationTabWidget},
impl{spimpl::make_unique_impl<VisualizationTabWidgetPrivate>(name)}
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 {
ui->setupUi(this);
}
VisualizationTabWidget::~VisualizationTabWidget()
{
delete ui;
}
Add the visualization gui classes
r111
void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget)
{
this->layout()->addWidget(zoneWidget);
}
Alexandre Leroux
Completes the method of creating a zone from a variable
r187 VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable)
Add the visualization gui classes
r111 {
Alexandre Leroux
Completes the method of creating a zone from a variable
r187 auto zoneWidget = new VisualizationZoneWidget{defaultZoneName(*layout()), this};
Add the visualization gui classes
r111 this->addZone(zoneWidget);
Alexandre Leroux
Completes the method of creating a zone from a variable
r187 // Creates a new graph into the zone
zoneWidget->createGraph(variable);
Add the visualization gui classes
r111 return zoneWidget;
}
void VisualizationTabWidget::removeZone(VisualizationZoneWidget *zone)
{
}
Alexandre Leroux
Updates visitor interface...
r192 void VisualizationTabWidget::accept(IVisualizationWidgetVisitor *visitor)
Add the visualization gui classes
r111 {
Alexandre Leroux
Implements accept() method of visualization widgets
r193 if (visitor) {
visitor->visitEnter(this);
// Apply visitor to zone children
for (auto i = 0; i < layout()->count(); ++i) {
if (auto item = layout()->itemAt(i)) {
Alexandre Leroux
Add comments
r205 // Widgets different from zones are not visited (no action)
Alexandre Leroux
Implements accept() method of visualization widgets
r193 if (auto visualizationZoneWidget
= dynamic_cast<VisualizationZoneWidget *>(item->widget())) {
visualizationZoneWidget->accept(visitor);
}
}
}
visitor->visitLeave(this);
}
Alexandre Leroux
Adds logs for null visitors
r204 else {
qCCritical(LOG_VisualizationTabWidget()) << tr("Can't visit widget : the visitor is null");
}
Add the visualization gui classes
r111 }
Alexandre Leroux
Creates a interface that defines a variable container...
r194 bool VisualizationTabWidget::canDrop(const Variable &variable) const
{
// A tab can always accomodate a variable
Q_UNUSED(variable);
return true;
}
Add the visualization gui classes
r111 void VisualizationTabWidget::close()
{
// The main view cannot be directly closed.
return;
}
Add const and override
r112 QString VisualizationTabWidget::name() const
Add the visualization gui classes
r111 {
Alexandre Leroux
Adds a name for a tab...
r184 return impl->m_Name;
Add the visualization gui classes
r111 }