10 #include <QPushButton>
12 #include <QMouseEvent>
15 #include <QInputDialog>
26 title_bar->setVisible(
false);
32 :
ads::CDockManager(parent), _name(name), _datamap(datamap)
36 auto CreateFirstWidget = [&]() {
73 QSplitter* splitter = qobject_cast<QSplitter*>(widget);
76 QDomElement splitter_elem = doc.createElement(
"DockSplitter");
77 splitter_elem.setAttribute(
"orientation",
78 (splitter->orientation() == Qt::Horizontal) ?
"|" :
"-");
79 splitter_elem.setAttribute(
"count", QString::number(splitter->count()));
83 for (
int size : splitter->sizes())
87 for (
int size : splitter->sizes())
89 sizes_str += QString::number(
double(
size) /
double(total_size));
92 sizes_str.resize(sizes_str.size() - 1);
93 splitter_elem.setAttribute(
"sizes", sizes_str);
95 for (
int i = 0; i < splitter->count(); ++i)
98 splitter_elem.appendChild(child);
100 return splitter_elem;
107 QDomElement area_elem = doc.createElement(
"DockArea");
114 area_elem.appendChild(plotwidget_elem);
115 area_elem.setAttribute(
"name", dock_widget->toolBar()->label()->text());
126 QDomElement containers_elem = doc.createElement(
"Tab");
132 QDomElement elem = doc.createElement(
"Container");
134 elem.appendChild(child);
135 containers_elem.appendChild(elem);
137 return containers_elem;
142 QString orientation_str = elem.attribute(
"orientation");
143 int splitter_count = elem.attribute(
"count").toInt();
146 if (!orientation_str.startsWith(
"|") && !orientation_str.startsWith(
"-"))
151 Qt::Orientation orientation =
152 orientation_str.startsWith(
"|") ? Qt::Horizontal : Qt::Vertical;
154 std::vector<DockWidget*> widgets(splitter_count);
157 for (
int i = 1; i < splitter_count; i++)
166 for (
int i = 0; i < splitter_count; i++)
169 (orientation == Qt::Horizontal) ? widgets[i]->width() : widgets[i]->height();
172 auto sizes_str = elem.attribute(
"sizes").split(
";");
175 for (
int i = 0; i < splitter_count; i++)
177 sizes.push_back(
static_cast<int>(sizes_str[i].
toDouble() * tot_size));
180 auto splitter = ads::internal::findParent<ads::CDockSplitter*>(widget);
181 splitter->setSizes(sizes);
185 QDomElement child_elem = elem.firstChildElement();
186 while (child_elem.isNull() ==
false)
188 if (child_elem.tagName() ==
"DockArea")
190 auto plot_elem = child_elem.firstChildElement(
"plot");
191 widgets[index]->plotWidget()->xmlLoadState(plot_elem);
192 if (child_elem.hasAttribute(
"name"))
194 QString area_name = child_elem.attribute(
"name");
195 widgets[index]->toolBar()->label()->setText(area_name);
199 else if (child_elem.tagName() ==
"DockSplitter")
208 child_elem = child_elem.nextSiblingElement();
219 for (
auto container_elem = tab_element.firstChildElement(
"Container");
220 !container_elem.isNull(); container_elem = container_elem.nextSiblingElement(
"Cont"
224 auto splitter_elem = container_elem.firstChildElement(
"DockSplitter");
225 if (!splitter_elem.isNull())
258 for (
int index = 0; index <
plotCount(); index++)
266 for (
int index = 0; index <
plotCount(); index++)
274 for (
int index = 0; index <
plotCount(); index++)
282 :
ads::CDockWidget(
"Plot", parent), _datamap(datamap)
284 setFrameShape(QFrame::NoFrame);
286 static int plot_count = 0;
287 QString plot_name = QString(
"_plot_%1_").arg(plot_count++);
295 qobject_cast<QBoxLayout*>(layout())->insertWidget(0,
_toolbar);
313 auto FullscreenAction = [=]() {
321 auto area = parent_docker->
dockArea(i);
333 dockAreaWidget()->closeArea();
335 _plot_widget->deleteLater();
336 _plot_widget = nullptr;
337 this->undoableChange();
340 this->layout()->setMargin(10);