MCPcopy Create free account
hub / github.com/chrxh/alien / updateImageFromSimulation

Method updateImageFromSimulation

source/Gui/SimulationView.cpp:282–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282void SimulationView::updateImageFromSimulation()
283{
284 auto worldRect = Viewport::get().getVisibleWorldRect();
285 auto viewSize = Viewport::get().getViewSize();
286 auto zoomFactor = Viewport::get().getZoomFactor();
287
288 if (zoomFactor >= ZoomFactorForOverlay) {
289 auto overlay = _simulationFacade->tryDrawVectorGraphicsAndReturnOverlay(
290 worldRect.topLeft, worldRect.bottomRight, {viewSize.x, viewSize.y}, zoomFactor);
291 if (overlay) {
292 std::sort(overlay->elements.begin(), overlay->elements.end(), [](OverlayElementDescription const& left, OverlayElementDescription const& right) {
293 return left.id < right.id;
294 });
295 _overlay = overlay;
296 }
297 } else {
298 _simulationFacade->tryDrawVectorGraphics(
299 worldRect.topLeft, worldRect.bottomRight, {viewSize.x, viewSize.y}, zoomFactor);
300 _overlay = std::nullopt;
301 }
302
303 //draw overlay
304 if (_overlay) {
305 ImDrawList* drawList = ImGui::GetBackgroundDrawList();
306 auto parameters = _simulationFacade->getSimulationParameters();
307 auto timestep = _simulationFacade->getCurrentTimestep();
308 for (auto const& overlayElement : _overlay->elements) {
309 if (_cellDetailOverlayActive && overlayElement.cell) {
310 {
311 auto fontSizeUnit = std::min(40.0f, Viewport::get().getZoomFactor()) / 2;
312 auto viewPos = Viewport::get().mapWorldToViewPosition({overlayElement.pos.x, overlayElement.pos.y + 0.3f}, parameters.borderlessRendering);
313 if (overlayElement.cellType != CellFunction_None) {
314 auto text = Const::CellFunctionToStringMap.at(overlayElement.cellType);
315 if (overlayElement.executionOrderNumber == toInt((timestep - 1) % parameters.cellNumExecutionOrderNumbers)) {
316 drawList->AddCircleFilled(
317 {viewPos.x - 2.0f * fontSizeUnit, viewPos.y + 0.5f * fontSizeUnit}, fontSizeUnit / 5, ImColor::HSV(0.0f, 1.0f, 0.7f, 1.0f));
318 }
319 drawList->AddText(
320 StyleRepository::get().getMediumFont(),
321 fontSizeUnit,
322 {viewPos.x - 1.7f * fontSizeUnit, viewPos.y},
323 Const::CellFunctionOverlayShadowColor,
324 text.c_str());
325 drawList->AddText(
326 StyleRepository::get().getMediumFont(),
327 fontSizeUnit,
328 {viewPos.x - 1.7f * fontSizeUnit + 1, viewPos.y + 1},
329 Const::CellFunctionOverlayColor,
330 text.c_str());
331 }
332 }
333 {
334 auto viewPos =
335 Viewport::get().mapWorldToViewPosition({overlayElement.pos.x - 0.12f, overlayElement.pos.y - 0.25f}, parameters.borderlessRendering);
336 auto fontSize = Viewport::get().getZoomFactor() / 2;
337 drawList->AddText(
338 StyleRepository::get().getLargeFont(),
339 fontSize,

Callers

nothing calls this directly

Calls 15

toIntFunction · 0.85
to_stringFunction · 0.85
getVisibleWorldRectMethod · 0.80
getViewSizeMethod · 0.80
getZoomFactorMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
getMediumFontMethod · 0.80
getLargeFontMethod · 0.80
isVisibleMethod · 0.80

Tested by

no test coverage detected