Skip to content

Commit 8081e16

Browse files
committed
fix #547, mutation trajectories plot is confusing
1 parent 5f697e1 commit 8081e16

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

QtSLiM/QtSLiMGraphView_FrequencyTrajectory.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ void QtSLiMGraphView_FrequencyTrajectory::addedToWindow(void)
7272
addSubpopulationsToMenu(subpopulationButton_, selectedSubpopulationID_);
7373
addMutationTypesToMenu(mutationTypeButton_, selectedMutationTypeIndex_);
7474
}
75+
76+
// We want to display a "recycle to start gathering data at the start of the run" message
77+
justAddedToWindow_ = true;
7578
}
7679

7780
QtSLiMGraphView_FrequencyTrajectory::~QtSLiMGraphView_FrequencyTrajectory()
@@ -96,6 +99,8 @@ void QtSLiMGraphView_FrequencyTrajectory::invalidateCachedData(void)
9699
frequencyHistoryDict_.clear();
97100
frequencyHistoryColdStorageLost_.clear();
98101
frequencyHistoryColdStorageFixed_.clear();
102+
103+
justAddedToWindow_ = true;
99104
}
100105

101106
void QtSLiMGraphView_FrequencyTrajectory::fetchDataForFinishedTick(void)
@@ -243,6 +248,7 @@ void QtSLiMGraphView_FrequencyTrajectory::fetchDataForFinishedTick(void)
243248
//NSLog(@"frequencyHistoryDict has %lld entries, frequencyHistoryColdStorageLost has %lld entries, frequencyHistoryColdStorageFixed has %lld entries", (long long int)[frequencyHistoryDict count], (long long int)[frequencyHistoryColdStorageLost count], (long long int)[frequencyHistoryColdStorageFixed count]);
244249

245250
lastTick_ = community->Tick();
251+
justAddedToWindow_ = false;
246252
}
247253

248254
void QtSLiMGraphView_FrequencyTrajectory::subpopulationPopupChanged(int /* index */)
@@ -288,6 +294,9 @@ void QtSLiMGraphView_FrequencyTrajectory::controllerRecycled(void)
288294
addSubpopulationsToMenu(subpopulationButton_, selectedSubpopulationID_);
289295
addMutationTypesToMenu(mutationTypeButton_, selectedMutationTypeIndex_);
290296

297+
// We do not want to display our "recycle to start gathering at the start" message after a recycle
298+
justAddedToWindow_ = false;
299+
291300
QtSLiMGraphView::controllerRecycled();
292301
}
293302

@@ -347,6 +356,7 @@ QString QtSLiMGraphView_FrequencyTrajectory::disableMessage(void)
347356

348357
if (graphSpecies)
349358
{
359+
// check that we have a valid subpop and muttype
350360
bool hasSubpop = true, hasMuttype = true;
351361

352362
if (!graphSpecies->SubpopulationWithID(selectedSubpopulationID_))
@@ -355,6 +365,12 @@ QString QtSLiMGraphView_FrequencyTrajectory::disableMessage(void)
355365
hasMuttype = addMutationTypesToMenu(mutationTypeButton_, selectedMutationTypeIndex_);
356366
if (!hasSubpop || !hasMuttype)
357367
return "no\ndata";
368+
369+
// check that we have some history recorded
370+
qDebug() << "justAddedToWindow_ ==" << justAddedToWindow_;
371+
372+
if (justAddedToWindow_)
373+
return "initiating data collection;\nrecycle and run to\ncollect data from the\nstart of the simulation";
358374
}
359375

360376
return "";

QtSLiM/QtSLiMGraphView_FrequencyTrajectory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public slots:
6969
std::vector<MutationFrequencyHistory *> frequencyHistoryColdStorageLost_; // vector of MutationFrequencyHistory objects that have been lost
7070
std::vector<MutationFrequencyHistory *> frequencyHistoryColdStorageFixed_; // vector of MutationFrequencyHistory objects that have been fixed
7171
slim_tick_t lastTick_ = 0; // the last tick data was gathered for; used to detect a backward move in time
72+
bool justAddedToWindow_ = true; // true when the plot window has just been created
7273

7374
// pop-up menu buttons
7475
QComboBox *subpopulationButton_ = nullptr;

VERSIONS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ development head (in the master branch):
2222
add infinite loop checking in Eidos; add [logical$ checkInfiniteLoops = T] option to initializeSLiMOptions() to disable checking for infinite loops in Eidos
2323
fix #539, crash reading malformed population file
2424
fix #535, allow transparency in plots: added [float alpha = 1.0] to Plot methods abline(), lines(), points(), and text() (required to be singleton for lines())
25+
fix #547, mutation trajectories plot is confusing in the way it starts collecting data at the time it is opened
2526

2627

2728
version 5.0 (Eidos version 4.0):

0 commit comments

Comments
 (0)