##// END OF EJS Templates
Completes the method of creating a zone from a variable
Alexandre Leroux -
r201:e28c6678c3bc
parent child
Show More
@@ -23,8 +23,13 public:
23 23 /// Add a zone widget
24 24 void addZone(VisualizationZoneWidget *zoneWidget);
25 25
26 /// Create a zone using a Variable
27 VisualizationZoneWidget *createZone();
26 /**
27 * Creates a zone using a variable. The variable will be displayed in a new graph of the new
28 * zone.
29 * @param variable the variable for which to create the zone
30 * @return the pointer to the created zone
31 */
32 VisualizationZoneWidget *createZone(std::shared_ptr<Variable> variable);
28 33
29 34 /// Remove a zone
30 35 void removeZone(VisualizationZoneWidget *zone);
@@ -3,6 +3,24
3 3
4 4 #include "Visualization/VisualizationZoneWidget.h"
5 5
6 namespace {
7
8 /// Generates a default name for a new zone, according to the number of zones already displayed in
9 /// the tab
10 QString defaultZoneName(const QLayout &layout)
11 {
12 auto count = 0;
13 for (auto i = 0; i < layout.count(); ++i) {
14 if (dynamic_cast<VisualizationZoneWidget *>(layout.itemAt(i)->widget())) {
15 count++;
16 }
17 }
18
19 return QObject::tr("Zone %1").arg(count + 1);
20 }
21
22 } // namespace
23
6 24 struct VisualizationTabWidget::VisualizationTabWidgetPrivate {
7 25 explicit VisualizationTabWidgetPrivate(const QString &name) : m_Name{name} {}
8 26
@@ -27,11 +45,14 void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget)
27 45 this->layout()->addWidget(zoneWidget);
28 46 }
29 47
30 VisualizationZoneWidget *VisualizationTabWidget::createZone()
48 VisualizationZoneWidget *VisualizationTabWidget::createZone(std::shared_ptr<Variable> variable)
31 49 {
32 auto zoneWidget = new VisualizationZoneWidget{this};
50 auto zoneWidget = new VisualizationZoneWidget{defaultZoneName(*layout()), this};
33 51 this->addZone(zoneWidget);
34 52
53 // Creates a new graph into the zone
54 zoneWidget->createGraph(variable);
55
35 56 return zoneWidget;
36 57 }
37 58
General Comments 0
You need to be logged in to leave comments. Login now