Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better zones UI #95

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open

Conversation

willjallen
Copy link
Contributor

@willjallen willjallen commented Apr 26, 2024

Addresses Name zones and Reorder zone tabs in #92

  • Add names to zones(spots) with serialization/deserialization
  • Support zone tab reordering
  • Disable closing and reordering Base tab
  • Fix bug where closing one tab will close multiple others

@willjallen willjallen marked this pull request as draft April 26, 2024 11:39
@willjallen
Copy link
Contributor Author

Still a WIP. There's a bug during deserialization where opening unopened tabs makes them refresh and reorder.

@chrxh
Copy link
Owner

chrxh commented Apr 26, 2024

These are nice additions. Take your time and let me know when it's ready.

@willjallen willjallen marked this pull request as ready for review April 29, 2024 05:55
@willjallen willjallen mentioned this pull request Apr 29, 2024
19 tasks
@willjallen
Copy link
Contributor Author

@chrxh ready for review

Copy link
Owner

@chrxh chrxh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks almost fine for me (see comments there). Good work!

I have tested it and a few issues should be addressed before merging:

  • The order of the zones are not preserved after saving and loading a sim.
  • When copying simulation parameters (by pressing the copy button), rearranging the zones and then pasting the parameters, the order of the zones is not restored.
  • Analogous to the counting of the radiation sources (see radiation source window), I would prefer to name the zones from "Zone 1" (and not from Zone 0). Counting from 0 is not so familiar to many people (except for programmers :D)

Some minor stuff (need not necessarily be addressed in this PR, but it would be nice to fix them at some point):

  • The automatic naming scheme can create zone names which are already in use. An example:
    Given: 2 zones named "Zone 0" and "Zone 1"
    Action: delete "Zone 0" and than add a new zone. The new zone will become the name "Zone 1", which is already in use.
  • A reset button for the zone name, as is also available for all other properties.

Do you would like to see your feature in v4.9.2 or in v4.10.0 (this update will still take a few weeks until it will be ready)?
Tomorrow I will be one week off so I can probably not answer until I return.

parameters.spots[i] = parameters.spots[i + 1];
origParameters.spots[i] = origParameters.spots[i + 1];
}
--parameters.numSpots;
--origParameters.numSpots;
_simController->setSimulationParameters(parameters);
_simController->setOriginalSimulationParameters(origParameters);
}else{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose there was a bug before with the counting of tab. Good that you have fixed it!

ImGui::EndTabItem();
}

//delete spot
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please restore this comment.

if (AlienImGui::BeginTreeNode(AlienImGui::TreeNodeParameters().text("General"))) {
if(AlienImGui::InputText(AlienImGui::InputTextParameters().name("Name").textWidth(RightColumnWidth), _spotNameStrings[tab])){
_spotNameStrings[tab] = _spotNameStrings[tab].substr(0, SIM_PARAM_SPOT_NAME_LENGTH - 1); // Leave space for null byte
strncpy(spot.name, _spotNameStrings[tab].c_str(), SIM_PARAM_SPOT_NAME_LENGTH);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resharper tells me that strncpy is marked as deprecated because this function can be unsafe. One should use strncpy_s instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strncpy_s, as well as the other _s variants, have an implementation in MSVC, but not in GCC. Thus, it is not portable and will not compile on the CI build, nor many standard linux distros. See 7421385. There are alternatives to the current method, such as using a library or using memcpy with strlen. I am agnostic to any of these options.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh all right, I didn't know that because I use MSVC on my machine.

@@ -41,7 +41,14 @@ class _SimulationParametersWindow : public _AlienWindow
std::optional<int> _sessionId;
bool _focusBaseTab = false;
std::vector<std::string> _cellFunctionStrings;


std::vector<std::string> _spotNameStrings;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this member really necessary (same for _copiedSpotNameStrings)? Couldn't it be extracted from the name member in SimulationParameterSpot? I ask because I would like to avoid redundant data because then one always has to remember to keep it up to date in the code (e.g. after rearranging zones, pasting parameters, etc.).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will look into this. It was necessary at one point to deal with an imgui bug, but I question if this remains the case.

std::vector<std::string> _copiedSpotNameStrings;
std::vector<std::string> _copiedSpotTabIDs;

int _serialTabID;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to initialize PODs at the point where they are declared. So here it should probably be = 0.

@willjallen
Copy link
Contributor Author

willjallen commented Apr 30, 2024

  • Analogous to the counting of the radiation sources (see radiation source window), I would prefer to name the zones from "Zone 1" (and not from Zone 0). Counting from 0 is not so familiar to many people (except for programmers :D)

Fair :)

Some minor stuff (need not necessarily be addressed in this PR, but it would be nice to fix them at some point):

  • The automatic naming scheme can create zone names which are already in use. An example:
    Given: 2 zones named "Zone 0" and "Zone 1"
    Action: delete "Zone 0" and than add a new zone. The new zone will become the name "Zone 1", which is already in use.
  • A reset button for the zone name, as is also available for all other properties.
  • The order of the zones are not preserved after saving and loading a sim.
  • When copying simulation parameters (by pressing the copy button), rearranging the zones and then pasting the parameters, the order of the zones is not restored.

Good observations. I will fix these.

Do you would like to see your feature in v4.9.2 or in v4.10.0 (this update will still take a few weeks until it will be ready)? Tomorrow I will be one week off so I can probably not answer until I return.

My regular work schedule is highly variable at the moment, but I do not think it will take weeks to make these changes. Enjoy your time off!

@chrxh
Copy link
Owner

chrxh commented Apr 30, 2024

My regular work schedule is highly variable at the moment, but I do not think it will take weeks to make these changes. Enjoy your time off!

Thanks!
The part about the weeks referred to changes that I still want to make and had planned for v4.10. Your changes could then also be included in that version :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants