##// END OF EJS Templates
Add comment
Add comment

File last commit:

r301:87af69bdce8a
r408:dd79727b8dcb
Show More
VisualizationZoneWidget.cpp
111 lines | 3.2 KiB | text/x-c | CppLexer
/ gui / src / Visualization / VisualizationZoneWidget.cpp
mv visualization -> Visualization...
r93 #include "Visualization/VisualizationZoneWidget.h"
Alexandre Leroux
Updates visitor interface...
r192 #include "Visualization/IVisualizationWidgetVisitor.h"
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 #include "ui_VisualizationZoneWidget.h"
Add the visualization gui classes
r111 #include "Visualization/VisualizationGraphWidget.h"
Alexandre Leroux
Adds a close button to a zone widget + calls close() method when clicked
r245 #include <SqpApplication.h>
Alexandre Leroux
Adds logs for null visitors
r204 Q_LOGGING_CATEGORY(LOG_VisualizationZoneWidget, "VisualizationZoneWidget")
Alexandre Leroux
Completes the method of creating a zone from a variable
r186 namespace {
Alexandre Leroux
Adds scrollbar to tabs
r284 /// Minimum height for graph added in zones (in pixels)
const auto GRAPH_MINIMUM_HEIGHT = 300;
Alexandre Leroux
Completes the method of creating a zone from a variable
r186 /// Generates a default name for a new graph, according to the number of graphs already displayed in
/// the zone
QString defaultGraphName(const QLayout &layout)
{
auto count = 0;
for (auto i = 0; i < layout.count(); ++i) {
if (dynamic_cast<VisualizationGraphWidget *>(layout.itemAt(i)->widget())) {
count++;
}
}
return QObject::tr("Graph %1").arg(count + 1);
}
} // namespace
Alexandre Leroux
Adds a name for a zone...
r183 VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *parent)
Modify construction of objects to use initializer list...
r89 : QWidget{parent}, ui{new Ui::VisualizationZoneWidget}
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 {
ui->setupUi(this);
Alexandre Leroux
Adds a name for a zone...
r183
ui->zoneNameLabel->setText(name);
Alexandre Leroux
Adds a close button to a zone widget + calls close() method when clicked
r245
// 'Close' options : widget is deleted when closed
setAttribute(Qt::WA_DeleteOnClose);
connect(ui->closeButton, &QToolButton::clicked, this, &VisualizationZoneWidget::close);
ui->closeButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 }
VisualizationZoneWidget::~VisualizationZoneWidget()
{
delete ui;
}
Add the visualization gui classes
r111
void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget)
{
ui->visualizationZoneFrame->layout()->addWidget(graphWidget);
}
Alexandre Leroux
Completes the method of creating a zone from a variable
r186 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable)
Add the visualization gui classes
r111 {
Alexandre Leroux
Completes the method of creating a zone from a variable
r186 auto graphWidget = new VisualizationGraphWidget{
defaultGraphName(*ui->visualizationZoneFrame->layout()), this};
Alexandre Leroux
Adds scrollbar to tabs
r284
// Set graph properties
graphWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
graphWidget->setMinimumHeight(GRAPH_MINIMUM_HEIGHT);
Add the visualization gui classes
r111 this->addGraph(graphWidget);
Alexandre Leroux
Completes the method of creating a zone from a variable
r186 graphWidget->addVariable(variable);
Add the visualization gui classes
r111 return graphWidget;
}
Alexandre Leroux
Updates visitor interface...
r192 void VisualizationZoneWidget::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 graph children
auto layout = ui->visualizationZoneFrame->layout();
for (auto i = 0; i < layout->count(); ++i) {
if (auto item = layout->itemAt(i)) {
Alexandre Leroux
Add comments
r205 // Widgets different from graphs are not visited (no action)
Alexandre Leroux
Implements accept() method of visualization widgets
r193 if (auto visualizationGraphWidget
= dynamic_cast<VisualizationGraphWidget *>(item->widget())) {
visualizationGraphWidget->accept(visitor);
}
}
}
visitor->visitLeave(this);
}
Alexandre Leroux
Adds logs for null visitors
r204 else {
qCCritical(LOG_VisualizationZoneWidget()) << 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 VisualizationZoneWidget::canDrop(const Variable &variable) const
{
// A tab can always accomodate a variable
Q_UNUSED(variable);
return true;
}
Alexandre Leroux
Unplot menu (5): adds contains() method to an IVariableContainer...
r301 bool VisualizationZoneWidget::contains(const Variable &variable) const
{
Q_UNUSED(variable);
return false;
}
Add const and override
r112 QString VisualizationZoneWidget::name() const
Add the visualization gui classes
r111 {
Alexandre Leroux
Adds a name for a zone...
r183 return ui->zoneNameLabel->text();
Add the visualization gui classes
r111 }