/
simulationexperimentviewwidget.cpp
793 lines (552 loc) · 31.6 KB
/
simulationexperimentviewwidget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
/*******************************************************************************
Copyright (C) The University of Auckland
OpenCOR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenCOR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
//==============================================================================
// Simulation Experiment view widget
//==============================================================================
#include "collapsiblewidget.h"
#include "filemanager.h"
#include "simulation.h"
#include "simulationexperimentviewcontentswidget.h"
#include "simulationexperimentviewinformationgraphpanelandgraphswidget.h"
#include "simulationexperimentviewinformationparameterswidget.h"
#include "simulationexperimentviewinformationsimulationwidget.h"
#include "simulationexperimentviewinformationsolverswidget.h"
#include "simulationexperimentviewinformationwidget.h"
#include "simulationexperimentviewplugin.h"
#include "simulationexperimentviewsimulationwidget.h"
#include "simulationexperimentviewwidget.h"
//==============================================================================
#include <QApplication>
#include <QDesktopWidget>
#include <QHeaderView>
#include <QLayout>
#include <QSettings>
#include <QTimer>
//==============================================================================
namespace OpenCOR {
namespace SimulationExperimentView {
//==============================================================================
SimulationExperimentViewWidget::SimulationExperimentViewWidget(SimulationExperimentViewPlugin *pPlugin,
const Plugins &pCellmlEditingViewPlugins,
const Plugins &pCellmlSimulationViewPlugins,
QWidget *pParent) :
ViewWidget(pParent),
mPlugin(pPlugin),
mCellmlEditingViewPlugins(pCellmlEditingViewPlugins),
mCellmlSimulationViewPlugins(pCellmlSimulationViewPlugins),
mSimulationWidgetSizes(QIntList()),
mContentsWidgetSizes(QIntList()),
mCollapsibleWidgetCollapsed(QBoolList()),
mGraphPanelGraphsMode(SimulationExperimentViewInformationGraphPanelAndGraphsWidget::Graphs),
mSimulationColumnWidths(QIntList()),
mSolversColumnWidths(QIntList()),
mGraphPanelColumnWidths(QIntList()),
mGraphsColumnWidths(QIntList()),
mParametersColumnWidths(QIntList()),
mGraphPanelSectionsExpanded(QMap<int, bool>()),
mSimulationWidget(0),
mSimulationWidgets(QMap<QString, SimulationExperimentViewSimulationWidget *>()),
mFileNames(QStringList()),
mSimulationResultsSizes(QMap<QString, qulonglong>()),
mSimulationCheckResults(QStringList())
{
}
//==============================================================================
static const auto SettingsSizes = QStringLiteral("Sizes");
static const auto SettingsContentsSizes = QStringLiteral("ContentsSizes");
static const auto SettingsCollapsed = QStringLiteral("Collapsed");
static const auto SettingsGraphPanelGraphsMode = QStringLiteral("GraphPanelGraphsMode");
static const auto SettingsSimulationColumnWidths = QStringLiteral("SimulationColumnWidths");
static const auto SettingsSolversColumnWidths = QStringLiteral("SolversColumnWidths");
static const auto SettingsGraphPanelColumnWidths = QStringLiteral("GraphPanelColumnWidths");
static const auto SettingsGraphsColumnWidths = QStringLiteral("GraphsColumnWidths");
static const auto SettingsParametersColumnWidths = QStringLiteral("ParametersColumnWidths");
//==============================================================================
void SimulationExperimentViewWidget::loadSettings(QSettings *pSettings)
{
// Retrieve the sizes of our simulation widget and of its contents widget
static const QVariantList defaultContentsSizes = QVariantList() << 0.25*qApp->desktop()->screenGeometry().width()
<< 0.75*qApp->desktop()->screenGeometry().width();
mSimulationWidgetSizes = qVariantListToIntList(pSettings->value(SettingsSizes).toList());
mContentsWidgetSizes = qVariantListToIntList(pSettings->value(SettingsContentsSizes, defaultContentsSizes).toList());
// Retrieve the collapsed states of our collapsible widget
static const QVariantList defaultCollapsed = QVariantList() << false << false << false;
mCollapsibleWidgetCollapsed = qVariantListToBoolList(pSettings->value(SettingsCollapsed, defaultCollapsed).toList());
// Retrieve our graph panel /graphs mode
mGraphPanelGraphsMode = SimulationExperimentViewInformationGraphPanelAndGraphsWidget::Mode(pSettings->value(SettingsGraphPanelGraphsMode, SimulationExperimentViewInformationGraphPanelAndGraphsWidget::Graphs).toInt());
// Retrieve the columns' width of our various property editors
static const QVariantList defaultThreeColumnWidths = QVariantList() << 100 << 100 << 100;
static const QVariantList defaultTwoColumnWidths = QVariantList() << 100 << 100;
mSimulationColumnWidths = qVariantListToIntList(pSettings->value(SettingsSimulationColumnWidths, defaultThreeColumnWidths).toList());
mSolversColumnWidths = qVariantListToIntList(pSettings->value(SettingsSolversColumnWidths, defaultThreeColumnWidths).toList());
mGraphPanelColumnWidths = qVariantListToIntList(pSettings->value(SettingsGraphPanelColumnWidths, defaultTwoColumnWidths).toList());
mGraphsColumnWidths = qVariantListToIntList(pSettings->value(SettingsGraphsColumnWidths, defaultTwoColumnWidths).toList());
mParametersColumnWidths = qVariantListToIntList(pSettings->value(SettingsParametersColumnWidths, defaultThreeColumnWidths).toList());
}
//==============================================================================
void SimulationExperimentViewWidget::saveSettings(QSettings *pSettings) const
{
// Keep track of the sizes of our simulation widget and those of its
// contents widget
pSettings->setValue(SettingsSizes, qIntListToVariantList(mSimulationWidgetSizes));
pSettings->setValue(SettingsContentsSizes, qIntListToVariantList(mContentsWidgetSizes));
// Keep track of the collapsed states of our collapsible widget
pSettings->setValue(SettingsCollapsed, qBoolListToVariantList(mCollapsibleWidgetCollapsed));
// Keep track of our graph panel /graphs mode
pSettings->setValue(SettingsGraphPanelGraphsMode, mGraphPanelGraphsMode);
// Keep track of the columns' width of our various property editors
pSettings->setValue(SettingsSimulationColumnWidths, qIntListToVariantList(mSimulationColumnWidths));
pSettings->setValue(SettingsSolversColumnWidths, qIntListToVariantList(mSolversColumnWidths));
pSettings->setValue(SettingsGraphPanelColumnWidths, qIntListToVariantList(mGraphPanelColumnWidths));
pSettings->setValue(SettingsGraphsColumnWidths, qIntListToVariantList(mGraphsColumnWidths));
pSettings->setValue(SettingsParametersColumnWidths, qIntListToVariantList(mParametersColumnWidths));
}
//==============================================================================
void SimulationExperimentViewWidget::retranslateUi()
{
// Retranslate our simulation widgets
foreach (SimulationExperimentViewSimulationWidget *simulationWidget, mSimulationWidgets)
simulationWidget->retranslateUi();
}
//==============================================================================
void SimulationExperimentViewWidget::initialize(const QString &pFileName)
{
// Retrieve the simulation widget associated with the given file, if any
mSimulationWidget = mSimulationWidgets.value(pFileName);
if (!mSimulationWidget) {
// No simulation widget exists for the given file, so create one
mSimulationWidget = new SimulationExperimentViewSimulationWidget(mPlugin, this, pFileName, this);
// Keep track of our editing widget
mSimulationWidgets.insert(pFileName, mSimulationWidget);
// Initialise our simulation widget
mSimulationWidget->initialize();
// Keep track of various things related to our simulation widget and its
// children
connect(mSimulationWidget, SIGNAL(splitterMoved(const QIntList &)),
this, SLOT(simulationWidgetSplitterMoved(const QIntList &)));
SimulationExperimentViewContentsWidget *contentsWidget = mSimulationWidget->contentsWidget();
connect(contentsWidget, SIGNAL(splitterMoved(const QIntList &)),
this, SLOT(contentsWidgetSplitterMoved(const QIntList &)));
SimulationExperimentViewInformationWidget *informationWidget = contentsWidget->informationWidget();
connect(informationWidget->collapsibleWidget(), SIGNAL(collapsed(const int &, const bool &)),
this, SLOT(collapsibleWidgetCollapsed(const int &, const bool &)));
connect(informationWidget->graphPanelAndGraphsWidget(), SIGNAL(graphPanelGraphsModeChanged(const OpenCOR::SimulationExperimentView::SimulationExperimentViewInformationGraphPanelAndGraphsWidget::Mode &)),
this, SLOT(graphPanelGraphsModeChanged(const OpenCOR::SimulationExperimentView::SimulationExperimentViewInformationGraphPanelAndGraphsWidget::Mode &)));
connect(informationWidget->simulationWidget()->header(), SIGNAL(sectionResized(int, int, int)),
this, SLOT(simulationHeaderSectionResized(const int &, const int &, const int &)));
connect(informationWidget->solversWidget()->header(), SIGNAL(sectionResized(int, int, int)),
this, SLOT(solversHeaderSectionResized(const int &, const int &, const int &)));
connect(informationWidget->graphPanelAndGraphsWidget(), SIGNAL(graphPanelHeaderSectionResized(int, int, int)),
this, SLOT(graphPanelHeaderSectionResized(const int &, const int &, const int &)));
connect(informationWidget->graphPanelAndGraphsWidget(), SIGNAL(graphsHeaderSectionResized(int, int, int)),
this, SLOT(graphsHeaderSectionResized(const int &, const int &, const int &)));
connect(informationWidget->parametersWidget()->header(), SIGNAL(sectionResized(int, int, int)),
this, SLOT(parametersHeaderSectionResized(const int &, const int &, const int &)));
connect(informationWidget->graphPanelAndGraphsWidget(), SIGNAL(graphPanelSectionExpanded(const int &, const bool &)),
this, SLOT(graphPanelSectionExpanded(const int &, const bool &)));
// Check when a graph has been toggled
connect(mSimulationWidget, SIGNAL(graphToggled(OpenCOR::GraphPanelWidget::GraphPanelPlotGraph *)),
this, SLOT(graphToggled(OpenCOR::GraphPanelWidget::GraphPanelPlotGraph *)));
// Check when some graph plot settings or graphs settings have been
// requested
connect(mSimulationWidget, SIGNAL(graphPanelSettingsRequested()),
this, SLOT(graphPanelSettingsRequested()));
connect(mSimulationWidget, SIGNAL(graphsSettingsRequested()),
this, SLOT(graphsSettingsRequested()));
// Check when the legend has been toggled
connect(mSimulationWidget, SIGNAL(legendToggled()),
this, SLOT(legendToggled()));
// Check when the X/Y logarithmic axis has been toggled
connect(mSimulationWidget, SIGNAL(logarithmicXAxisToggled()),
this, SLOT(logarithmicXAxisToggled()));
connect(mSimulationWidget, SIGNAL(logarithmicYAxisToggled()),
this, SLOT(logarithmicYAxisToggled()));
} else {
// We already have a simulation widget, so just make sure that its GUI
// is up to date
mSimulationWidget->updateGui();
}
// Update some of our simulation's contents' information GUI
updateContentsInformationGui(mSimulationWidget);
// Set our focus proxy to our 'new' simulation widget and make sure that the
// latter immediately gets the focus
setFocusProxy(mSimulationWidget);
mSimulationWidget->setFocus();
}
//==============================================================================
void SimulationExperimentViewWidget::finalize(const QString &pFileName)
{
// Remove the simulation widget, should there be one for the given file
SimulationExperimentViewSimulationWidget *simulationWidget = mSimulationWidgets.value(pFileName);
if (simulationWidget) {
// Finalise our simulation widget
simulationWidget->finalize();
// Now, we can delete it and remove it from our list
delete simulationWidget;
mSimulationWidgets.remove(pFileName);
// Next, we reset our memory of the simulation widget, if needed
if (simulationWidget == mSimulationWidget)
mSimulationWidget = 0;
}
}
//==============================================================================
QIcon SimulationExperimentViewWidget::fileTabIcon(const QString &pFileName) const
{
// Return, if possible, the tab icon for the given file
SimulationExperimentViewSimulationWidget *simulationWidget = mSimulationWidgets.value(pFileName);
if (simulationWidget) {
return simulationWidget->fileTabIcon();
} else {
static const QIcon NoIcon = QIcon();
return NoIcon;
}
}
//==============================================================================
bool SimulationExperimentViewWidget::saveFile(const QString &pOldFileName,
const QString &pNewFileName)
{
// Save the given file, if possible
SimulationExperimentViewSimulationWidget *simulationWidget = mSimulationWidgets.value(pOldFileName);
if (simulationWidget)
return simulationWidget->save(pNewFileName);
else
return false;
}
//==============================================================================
void SimulationExperimentViewWidget::fileOpened(const QString &pFileName)
{
// Track the given file name
mFileNames << pFileName;
// Make sure that the GUI of our simulation widgets is up to date
foreach (SimulationExperimentViewSimulationWidget *simulationWidget, mSimulationWidgets)
simulationWidget->updateGui(true);
}
//==============================================================================
void SimulationExperimentViewWidget::filePermissionsChanged(const QString &pFileName)
{
// Let the simulation widget, if any, associated with the given file name
// know that a file has been un/locked
SimulationExperimentViewSimulationWidget *simulationWidget = mSimulationWidgets.value(pFileName);
if (simulationWidget)
simulationWidget->filePermissionsChanged();
}
//==============================================================================
void SimulationExperimentViewWidget::fileModified(const QString &pFileName)
{
// Let the simulation widget, if any, associated with the given file name
// know that a file has been modified
SimulationExperimentViewSimulationWidget *simulationWidget = mSimulationWidgets.value(pFileName);
if (simulationWidget)
simulationWidget->fileModified();
}
//==============================================================================
void SimulationExperimentViewWidget::fileReloaded(const QString &pFileName)
{
// Let the simulation widget, if any, associated with the given file name
// know that a file has been reloaded
SimulationExperimentViewSimulationWidget *simulationWidget = mSimulationWidgets.value(pFileName);
if (simulationWidget) {
simulationWidget->fileReloaded();
// Make sure that our simulation's contents' information GUI is up to
// date
// Note: this is, at least, necessary for our paramaters widget since we
// repopulate it, meaning that its columns' width will be reset...
updateContentsInformationGui(simulationWidget);
// Make sure that the GUI of our simulation widgets is up to date
foreach (SimulationExperimentViewSimulationWidget *simulationWidget, mSimulationWidgets)
simulationWidget->updateGui(true);
}
}
//==============================================================================
void SimulationExperimentViewWidget::fileRenamed(const QString &pOldFileName,
const QString &pNewFileName)
{
// Stop tracking the old given file name and track the given new one instead
mFileNames.removeOne(pOldFileName);
mFileNames << pNewFileName;
// The given file has been renamed, so update our simulation widgets mapping
SimulationExperimentViewSimulationWidget *simulationWidget = mSimulationWidgets.value(pOldFileName);
if (simulationWidget) {
simulationWidget->setFileName(pNewFileName);
mSimulationWidgets.insert(pNewFileName, simulationWidget);
mSimulationWidgets.remove(pOldFileName);
}
// Let our simulation widgets know that a file has been renamed
foreach (SimulationExperimentViewSimulationWidget *simulationWidget, mSimulationWidgets)
simulationWidget->fileRenamed(pOldFileName, pNewFileName);
}
//==============================================================================
void SimulationExperimentViewWidget::fileClosed(const QString &pFileName)
{
// Stop tracking the given file name
mFileNames.removeOne(pFileName);
// Make sure that the GUI of our simulation widgets is up to date
foreach (SimulationExperimentViewSimulationWidget *simulationWidget, mSimulationWidgets)
simulationWidget->updateGui(true);
}
//==============================================================================
QStringList SimulationExperimentViewWidget::fileNames() const
{
// Return our file names
return mFileNames;
}
//==============================================================================
Plugins SimulationExperimentViewWidget::cellmlEditingViewPlugins() const
{
// Return our CellML editing view plugins
return mCellmlEditingViewPlugins;
}
//==============================================================================
Plugins SimulationExperimentViewWidget::cellmlSimulationViewPlugins() const
{
// Return our CellML simulation view plugins
return mCellmlSimulationViewPlugins;
}
//==============================================================================
SimulationExperimentViewSimulationWidget * SimulationExperimentViewWidget::simulationWidget(const QString &pFileName) const
{
// Return the requested simulation widget
return mSimulationWidgets.value(pFileName);
}
//==============================================================================
SimulationSupport::Simulation * SimulationExperimentViewWidget::simulation(const QString &pFileName) const
{
// Return the simulation for the given file name
SimulationExperimentViewSimulationWidget *simulationWidget = mSimulationWidgets.value(pFileName);
if (simulationWidget)
return simulationWidget->simulation();
else
return 0;
}
//==============================================================================
CellMLSupport::CellmlFileRuntime * SimulationExperimentViewWidget::runtime(const QString &pFileName) const
{
// Return the runtime for the given file name
SimulationExperimentViewSimulationWidget *simulationWidget = mSimulationWidgets.value(pFileName);
if (simulationWidget)
return simulationWidget->simulation()->runtime();
else
return 0;
}
//==============================================================================
QWidget * SimulationExperimentViewWidget::widget(const QString &pFileName)
{
// Return the requested (simulation) widget
return simulationWidget(pFileName);
}
//==============================================================================
qulonglong SimulationExperimentViewWidget::simulationResultsSize(const QString &pFileName) const
{
// Return the results size for the given file name
return mSimulationResultsSizes.value(pFileName);
}
//==============================================================================
void SimulationExperimentViewWidget::checkSimulationResults(const QString &pFileName,
const bool &pClearGraphs)
{
// Make sure that we can still check results (i.e. we are not closing down
// with some simulations still running)
SimulationExperimentViewSimulationWidget *simulationWidget = mSimulationWidgets.value(pFileName);
if (!simulationWidget)
return;
// Update all of our simulation widgets' results, but only if needed
// Note: to update only the given simulation widget's results is not enough
// since another simulation widget may have graphs that refer to the
// given simulation widget...
SimulationSupport::Simulation *simulation = simulationWidget->simulation();
qulonglong simulationResultsSize = simulation->results()->size();
if ( pClearGraphs
|| (simulationResultsSize != mSimulationResultsSizes.value(pFileName))) {
mSimulationResultsSizes.insert(pFileName, simulationResultsSize);
foreach (SimulationExperimentViewSimulationWidget *currentSimulationWidget, mSimulationWidgets)
currentSimulationWidget->updateSimulationResults(simulationWidget, simulationResultsSize, pClearGraphs);
}
// Ask to recheck our simulation widget's results, but only if its
// simulation is still running
if ( simulation->isRunning()
|| (simulationResultsSize != simulation->results()->size())) {
// Note: we cannot ask QTimer::singleShot() to call
// callCheckSimulationResults() since it expects a simulation
// widget as a parameter, so instead we call a method with no
// arguments that will make use of our list to know which
// simulation should be passed as an argument to
// checkSimulationResults()...
mSimulationCheckResults << pFileName;
QTimer::singleShot(0, this, SLOT(callCheckSimulationResults()));
} else if (!simulation->isRunning() && !simulation->isPaused()) {
// The simulation is over, so stop tracking the result's size and reset
// the simulation progress of the given file
mSimulationResultsSizes.remove(pFileName);
simulationWidget->resetSimulationProgress();
}
}
//==============================================================================
void SimulationExperimentViewWidget::callCheckSimulationResults()
{
// Retrieve the simulation widget for which we want to call checkResults()
// and then call checkResults() for it
QString fileName = mSimulationCheckResults.first();
mSimulationCheckResults.removeFirst();
checkSimulationResults(fileName);
}
//==============================================================================
void SimulationExperimentViewWidget::simulationWidgetSplitterMoved(const QIntList &pSizes)
{
// The splitter of our simulation widget has moved, so keep track of its new
// sizes
mSimulationWidgetSizes = pSizes;
}
//==============================================================================
void SimulationExperimentViewWidget::contentsWidgetSplitterMoved(const QIntList &pSizes)
{
// The splitter of our contents widget has moved, so keep track of its new
// sizes
mContentsWidgetSizes = pSizes;
}
//==============================================================================
void SimulationExperimentViewWidget::collapsibleWidgetCollapsed(const int &pIndex,
const bool &pCollapsed)
{
// One of the widgets in our collapsible widget has been collapsed or
// expanded, so keep track of that fact
mCollapsibleWidgetCollapsed[pIndex] = pCollapsed;
}
//==============================================================================
void SimulationExperimentViewWidget::graphToggled(OpenCOR::GraphPanelWidget::GraphPanelPlotGraph *pGraph)
{
// Toggle the given graph
mSimulationWidget->contentsWidget()->informationWidget()->graphPanelAndGraphsWidget()->toggleGraph(pGraph);
}
//==============================================================================
void SimulationExperimentViewWidget::graphPanelSettingsRequested()
{
// Make sure that our graph panel settings are active and visible
mSimulationWidget->contentsWidget()->informationWidget()->graphPanelAndGraphsWidget()->setMode(SimulationExperimentViewInformationGraphPanelAndGraphsWidget::GraphPanel);
mSimulationWidget->contentsWidget()->informationWidget()->collapsibleWidget()->setCollapsed(2, false);
}
//==============================================================================
void SimulationExperimentViewWidget::graphsSettingsRequested()
{
// Make sure that our graphs settings are active and visible
mSimulationWidget->contentsWidget()->informationWidget()->graphPanelAndGraphsWidget()->setMode(SimulationExperimentViewInformationGraphPanelAndGraphsWidget::Graphs);
mSimulationWidget->contentsWidget()->informationWidget()->collapsibleWidget()->setCollapsed(2, false);
}
//==============================================================================
void SimulationExperimentViewWidget::legendToggled()
{
// Toggle the legend property
mSimulationWidget->contentsWidget()->informationWidget()->graphPanelAndGraphsWidget()->toggleLegend();
}
//==============================================================================
void SimulationExperimentViewWidget::logarithmicXAxisToggled()
{
// Toggle the logarithmic X axis property
mSimulationWidget->contentsWidget()->informationWidget()->graphPanelAndGraphsWidget()->toggleLogarithmicXAxis();
}
//==============================================================================
void SimulationExperimentViewWidget::logarithmicYAxisToggled()
{
// Toggle the logarithmic Y axis property
mSimulationWidget->contentsWidget()->informationWidget()->graphPanelAndGraphsWidget()->toggleLogarithmicYAxis();
}
//==============================================================================
void SimulationExperimentViewWidget::graphPanelGraphsModeChanged(const OpenCOR::SimulationExperimentView::SimulationExperimentViewInformationGraphPanelAndGraphsWidget::Mode &pMode)
{
// Keep track of the new graph panel / graphs mode
mGraphPanelGraphsMode = pMode;
}
//==============================================================================
void SimulationExperimentViewWidget::simulationHeaderSectionResized(const int &pIndex,
const int &pOldSize,
const int &pNewSize)
{
Q_UNUSED(pOldSize);
// Keep track of the new column width
mSimulationColumnWidths[pIndex] = pNewSize;
}
//==============================================================================
void SimulationExperimentViewWidget::solversHeaderSectionResized(const int &pIndex,
const int &pOldSize,
const int &pNewSize)
{
Q_UNUSED(pOldSize);
// Keep track of the new column width
mSolversColumnWidths[pIndex] = pNewSize;
}
//==============================================================================
void SimulationExperimentViewWidget::graphPanelHeaderSectionResized(const int &pIndex,
const int &pOldSize,
const int &pNewSize)
{
Q_UNUSED(pOldSize);
// Keep track of the new column width
mGraphPanelColumnWidths[pIndex] = pNewSize;
}
//==============================================================================
void SimulationExperimentViewWidget::graphsHeaderSectionResized(const int &pIndex,
const int &pOldSize,
const int &pNewSize)
{
Q_UNUSED(pOldSize);
// Keep track of the new column width
mGraphsColumnWidths[pIndex] = pNewSize;
}
//==============================================================================
void SimulationExperimentViewWidget::parametersHeaderSectionResized(const int &pIndex,
const int &pOldSize,
const int &pNewSize)
{
Q_UNUSED(pOldSize);
// Keep track of the new column width
mParametersColumnWidths[pIndex] = pNewSize;
}
//==============================================================================
void SimulationExperimentViewWidget::graphPanelSectionExpanded(const int &pSection,
const bool &pExpanded)
{
// Keep track of the section's expanded state
mGraphPanelSectionsExpanded.insert(pSection, pExpanded);
}
//==============================================================================
void SimulationExperimentViewWidget::updateContentsInformationGui(SimulationExperimentViewSimulationWidget *pSimulationWidget)
{
// Update our simualtion widget's GUI and that of its children
// Note: for column widths, we set the last column width to zero to avoid
// potential issues, should the vertical scrollbar be visible...
pSimulationWidget->setSizes(mSimulationWidgetSizes);
SimulationExperimentViewContentsWidget *contentsWidget = pSimulationWidget->contentsWidget();
contentsWidget->setSizes(mContentsWidgetSizes);
SimulationExperimentViewInformationWidget *informationWidget = contentsWidget->informationWidget();
for (int i = 0, iMax = mCollapsibleWidgetCollapsed.count(); i < iMax; ++i)
informationWidget->collapsibleWidget()->setCollapsed(i, mCollapsibleWidgetCollapsed[i]);
informationWidget->graphPanelAndGraphsWidget()->setMode(mGraphPanelGraphsMode);
for (int i = 0, iMax = mSimulationColumnWidths.count(); i < iMax; ++i)
informationWidget->simulationWidget()->setColumnWidth(i, (i == iMax-1)?0:mSimulationColumnWidths[i]);
for (int i = 0, iMax = mSolversColumnWidths.count(); i < iMax; ++i)
informationWidget->solversWidget()->setColumnWidth(i, (i == iMax-1)?0:mSolversColumnWidths[i]);
for (int i = 0, iMax = mGraphPanelColumnWidths.count(); i < iMax; ++i)
informationWidget->graphPanelAndGraphsWidget()->setGraphPanelColumnWidth(i, (i == iMax-1)?0:mGraphPanelColumnWidths[i]);
for (int i = 0, iMax = mGraphsColumnWidths.count(); i < iMax; ++i)
informationWidget->graphPanelAndGraphsWidget()->setGraphsColumnWidth(i, (i == iMax-1)?0:mGraphsColumnWidths[i]);
for (int i = 0, iMax = mParametersColumnWidths.count(); i < iMax; ++i)
informationWidget->parametersWidget()->setColumnWidth(i, (i == iMax-1)?0:mParametersColumnWidths[i]);
foreach (const int §ion, mGraphPanelSectionsExpanded.keys())
informationWidget->graphPanelAndGraphsWidget()->setGraphPanelSectionExpanded(section, mGraphPanelSectionsExpanded.value(section));
}
//==============================================================================
} // namespace SimulationExperimentView
} // namespace OpenCOR
//==============================================================================
// End of file
//==============================================================================