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

Method onAddZone

source/Gui/SimulationParametersMainWindow.cpp:482–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480}
481
482void SimulationParametersMainWindow::onAddZone()
483{
484 auto parameters = _simulationFacade->getSimulationParameters();
485 auto origParameters = _simulationFacade->getOriginalSimulationParameters();
486
487 if (!checkNumZones(parameters)) {
488 return;
489 }
490
491 ++_selectedLocationIndex;
492 LocationHelper::adaptLocationIndex(parameters, _selectedLocationIndex, 1);
493 LocationHelper::adaptLocationIndex(origParameters, _selectedLocationIndex, 1);
494
495 auto worldSize = _simulationFacade->getWorldSize();
496
497 SimulationParametersZone zone;
498 StringHelper::copy(zone.name, sizeof(zone.name), LocationHelper::generateZoneName(parameters));
499 zone.locationIndex = _selectedLocationIndex;
500 zone.posX = toFloat(worldSize.x / 2);
501 zone.posY = toFloat(worldSize.y / 2);
502 auto maxRadius = toFloat(std::min(worldSize.x, worldSize.y)) / 2;
503 zone.shapeType = SpotShapeType_Circular;
504 zone.fadeoutRadius = maxRadius / 3;
505 zone.color = _zoneColorPalette.getColor((2 + parameters.numZones) * 8);
506 zone.values = parameters.baseValues;
507
508 setDefaultShapeDataForZone(zone);
509
510 int index = parameters.numZones;
511 parameters.zone[index] = zone;
512 origParameters.zone[index] = zone;
513 ++parameters.numZones;
514 ++origParameters.numZones;
515 _simulationFacade->setSimulationParameters(parameters);
516 _simulationFacade->setOriginalSimulationParameters(origParameters);
517}
518
519void SimulationParametersMainWindow::onAddSource()
520{

Callers

nothing calls this directly

Calls 6

toFloatFunction · 0.85
getWorldSizeMethod · 0.80
getColorMethod · 0.80

Tested by

no test coverage detected