Skip to content

Commit

Permalink
+ tab widget for simulation parameter refactored + wrong orig paramet…
Browse files Browse the repository at this point in the history
…ers corrected
  • Loading branch information
chrxh committed Aug 24, 2024
1 parent 9f85da3 commit 3790482
Show file tree
Hide file tree
Showing 4 changed files with 1,908 additions and 1,870 deletions.
20 changes: 10 additions & 10 deletions source/Gui/RadiationSourcesWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,34 @@ void _RadiationSourcesWindow::processIntern()
{
auto parameters = _simController->getSimulationParameters();

std::optional<bool> scheduleAddTab;
std::optional<int> scheduleDelTabAtIndex;
std::optional<bool> scheduleAppendTab;
std::optional<int> scheduleDeleteTabAtIndex;

if (ImGui::BeginTabBar("##ParticleSources", ImGuiTabBarFlags_AutoSelectNewTabs | ImGuiTabBarFlags_FittingPolicyResizeDown)) {

if (parameters.numRadiationSources < MAX_RADIATION_SOURCES) {

//add source
if (ImGui::TabItemButton("+", ImGuiTabItemFlags_Trailing | ImGuiTabItemFlags_NoTooltip)) {
scheduleAddTab = true;
scheduleAppendTab = true;
}
AlienImGui::Tooltip("Add source");
}

for (int tab = 0; tab < parameters.numRadiationSources; ++tab) {
if (!processTab(tab)) {
scheduleDelTabAtIndex = tab;
scheduleDeleteTabAtIndex = tab;
}
}

ImGui::EndTabBar();
}

if (scheduleAddTab.has_value()) {
processAppendTab();
if (scheduleAppendTab.has_value()) {
onAppendTab();
}
if (scheduleDelTabAtIndex.has_value()) {
processDelTab(scheduleDelTabAtIndex.value());
if (scheduleDeleteTabAtIndex.has_value()) {
onDeleteTab(scheduleDeleteTabAtIndex.value());
}
}

Expand Down Expand Up @@ -171,7 +171,7 @@ bool _RadiationSourcesWindow::processTab(int index)
return isOpen;
}

void _RadiationSourcesWindow::processAppendTab()
void _RadiationSourcesWindow::onAppendTab()
{
auto parameters = _simController->getSimulationParameters();
auto origParameters = _simController->getOriginalSimulationParameters();
Expand All @@ -186,7 +186,7 @@ void _RadiationSourcesWindow::processAppendTab()
_simController->setOriginalSimulationParameters(origParameters);
}

void _RadiationSourcesWindow::processDelTab(int index)
void _RadiationSourcesWindow::onDeleteTab(int index)
{
auto parameters = _simController->getSimulationParameters();
auto origParameters = _simController->getOriginalSimulationParameters();
Expand Down
6 changes: 3 additions & 3 deletions source/Gui/RadiationSourcesWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class _RadiationSourcesWindow : public _AlienWindow
private:
void processIntern() override;

bool processTab(int index); //return false if tab is closed
void processAppendTab();
void processDelTab(int index);
bool processTab(int index); //return false if tab should be closed
void onAppendTab();
void onDeleteTab(int index);

RadiationSource createParticleSource() const;

Expand Down
Loading

0 comments on commit 3790482

Please sign in to comment.