Skip to content

Commit

Permalink
+ calculation of peak savepoints fixed
Browse files Browse the repository at this point in the history
+ compile error fixed
  • Loading branch information
chrxh committed Nov 4, 2024
1 parent 2bf93b5 commit bdb94db
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 23 deletions.
2 changes: 1 addition & 1 deletion source/EngineGpuKernels/EditKernelsLauncher.cu
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void _EditKernelsLauncher::updateSelection(GpuSettings const& gpuSettings, Simul
void _EditKernelsLauncher::getSelectionShallowData(GpuSettings const& gpuSettings, SimulationData const& data, SelectionResult const& selectionResult)
{
KERNEL_CALL_1_1(cudaResetSelectionResult, selectionResult);
setValueToDevice(_cudaMinCellPosYAndIndex, 0xffffffffffffffff);
setValueToDevice(_cudaMinCellPosYAndIndex, 0xffffffffffffffffull);
KERNEL_CALL(cudaCalcCellWithMinimalPosY, data, _cudaMinCellPosYAndIndex);
cudaDeviceSynchronize();
auto refCellIndex = static_cast<int>(copyToHost(_cudaMinCellPosYAndIndex) & 0xffffffff);
Expand Down
30 changes: 15 additions & 15 deletions source/Gui/AutosaveWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void AutosaveWindow::processToolbar()
AlienImGui::Tooltip("Create save point");

ImGui::SameLine();
ImGui::BeginDisabled(!static_cast<bool>(_selectedEntry) || _selectedEntry->state != SavepointState_Persisted);
ImGui::BeginDisabled(!static_cast<bool>(_selectedEntry) || (_selectedEntry->state != SavepointState_Persisted && !_selectedEntry->requestId.empty()));
if (AlienImGui::ToolbarButton(ICON_FA_MINUS)) {
onDeleteSavepoint(_selectedEntry);
}
Expand Down Expand Up @@ -166,6 +166,12 @@ void AutosaveWindow::processTable()

// project name
ImGui::TableNextColumn();
if (entry->state == SavepointState_InQueue) {
AlienImGui::Text("In queue");
}
if (entry->state == SavepointState_InProgress) {
AlienImGui::Text("In progress");
}
if (entry->state == SavepointState_Persisted) {
auto triggerLoadSavepoint = AlienImGui::ActionButton(AlienImGui::ActionButtonParameters().buttonText(ICON_FA_DOWNLOAD));
AlienImGui::Tooltip("Load savepoint", false);
Expand All @@ -176,6 +182,9 @@ void AutosaveWindow::processTable()
ImGui::SameLine();
AlienImGui::Text(entry->name);
}
if (entry->state == SavepointState_Error) {
AlienImGui::Text("Error");
}

ImGui::SameLine();
auto selected = _selectedEntry == entry;
Expand All @@ -189,18 +198,9 @@ void AutosaveWindow::processTable()

// timestamp
ImGui::TableNextColumn();
if (entry->state == SavepointState_InQueue) {
AlienImGui::Text("In queue");
}
if (entry->state == SavepointState_InProgress) {
AlienImGui::Text("In progress");
}
if (entry->state == SavepointState_Persisted) {
AlienImGui::Text(entry->timestamp);
}
if (entry->state == SavepointState_Error) {
AlienImGui::Text("Error");
}

// timestep
ImGui::TableNextColumn();
Expand Down Expand Up @@ -247,8 +247,8 @@ void AutosaveWindow::processSettings()
_lastAutosaveTimepoint = std::chrono::steady_clock::now();
}
}
if (AlienImGui::Combo(
AlienImGui::ComboParameters()
if (AlienImGui::Switcher(
AlienImGui::SwitcherParameters()
.name("Catch peaks")
.textWidth(RightColumnWidth)
.defaultValue(_origCatchPeaks)
Expand All @@ -266,8 +266,8 @@ void AutosaveWindow::processSettings()
_directory)) {
updateSavepointTableFromFile();
}
AlienImGui::Combo(
AlienImGui::ComboParameters()
AlienImGui::Switcher(
AlienImGui::SwitcherParameters()
.name("Mode")
.values({"Circular save files", "Unlimited save files"})
.textWidth(RightColumnWidth)
Expand Down Expand Up @@ -444,7 +444,7 @@ void AutosaveWindow::updateSavepoint(int row)
newEntry->filename = data.filename;
newEntry->peak = StringHelper::format(toFloat(sumColorVector(data.rawStatisticsData.timeline.timestep.genomeComplexityVariance)), 2);
newEntry->peakType = "genome complexity variance";
_peakDeserializedSimulation->setDeserializedSimulation(DeserializedSimulation());
_peakDeserializedSimulation->reset();
}
}
if (requestState.value() == PersisterRequestState::Error) {
Expand Down
25 changes: 18 additions & 7 deletions source/Gui/OverlayController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace
auto constexpr ShowDuration = 800;
auto constexpr FadeoutTextDuration = 800;
auto constexpr FadeoutLightningDuration = 1200;
auto constexpr FadeoutProgressAnimationDuration = 1000;
}

void OverlayController::setup(PersisterFacade const& persisterFacade)
Expand Down Expand Up @@ -55,11 +56,20 @@ void OverlayController::setOn(bool value)
void OverlayController::processProgressAnimation()
{
if (_persisterFacade->isBusy()) {
_busyTimepoint = std::chrono::steady_clock::now();
}
if (!_busyTimepoint.has_value()) {
return;
}
auto now = std::chrono::steady_clock::now();
auto millisecSinceBusy = std::chrono::duration_cast<std::chrono::milliseconds>(now - *_busyTimepoint).count();

if (millisecSinceBusy < FadeoutProgressAnimationDuration) {
if (!_progressBarRefTimepoint.has_value()) {
_progressBarRefTimepoint = std::chrono::steady_clock::now();
}
auto now = std::chrono::steady_clock::now();
auto duration = toFloat(std::chrono::duration_cast<std::chrono::milliseconds>(now - *_progressBarRefTimepoint).count());
auto alpha = 1.0f - toFloat(millisecSinceBusy) / FadeoutProgressAnimationDuration;

ImDrawList* drawList = ImGui::GetBackgroundDrawList();

Expand All @@ -73,27 +83,27 @@ void OverlayController::processProgressAnimation()
ImVec2{center.x, center.y + height},
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f * alpha),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f));
drawList->AddRectFilledMultiColor(
ImVec2{center.x, center.y - height * 5},
ImVec2{center.x + width, center.y + height},
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f));
ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f * alpha));
drawList->AddRectFilledMultiColor(
ImVec2{center.x, center.y + height},
ImVec2{center.x + width, center.y + height * 6},
ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f * alpha),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f));
drawList->AddRectFilledMultiColor(
ImVec2{center.x - width, center.y + height},
ImVec2{center.x, center.y + height * 6},
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 1.0f * alpha),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f),
ImColor::HSV(0.66f, 1.0f, 0.1f, 0.0f));
auto N = 8 + toInt(powf(sinf(duration / 500.0f - Const::Pi / 4) + 1, 3.0f) * 5);
Expand All @@ -107,18 +117,19 @@ void OverlayController::processProgressAnimation()
drawList->AddRectFilled(
ImVec2{center.x - width / 2 + toFloat(i) / N * width, std::min(y1, y2)},
ImVec2{center.x - width / 2 + toFloat(i + 1) / N * width - scale(3), std::max(y1, y2)},
ImColor::HSV(0.625f, 0.8f, 0.55f, 0.6f));
ImColor::HSV(0.625f, 0.8f, 0.45f, 0.7f * alpha));
}
drawList->AddText(
StyleRepository::get().getReefMediumFont(),
scale(16.0f),
{center.x - scale(28.0f), center.y - scale(15.0f)},
ImColor::HSV(0, 0, 1, 0.7f),
ImColor::HSV(0, 0, 1, 0.7f * alpha),
"Processing");


} else {
_progressBarRefTimepoint.reset();
_busyTimepoint.reset();
}
}

Expand Down
1 change: 1 addition & 0 deletions source/Gui/OverlayController.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class OverlayController
std::optional<std::chrono::steady_clock::time_point> _progressBarRefTimepoint;
std::optional<std::chrono::steady_clock::time_point> _messageStartTimepoint;
std::optional<std::chrono::steady_clock::time_point> _ticksLaterTimepoint;
std::optional<std::chrono::steady_clock::time_point> _busyTimepoint;
};

inline void printOverlayMessage(std::string const& message, bool withLightning = false)
Expand Down
6 changes: 6 additions & 0 deletions source/PersisterInterface/SharedDeserializedSimulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class _SharedDeserializedSimulation
return _timestamp;
}

void reset()
{
setDeserializedSimulation(DeserializedSimulation());
setLastStatisticsData(RawStatisticsData());
}

bool isEmpty() const
{
std::lock_guard lock(_mutex);
Expand Down

0 comments on commit bdb94db

Please sign in to comment.