-
Notifications
You must be signed in to change notification settings - Fork 157
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
base: develop
Are you sure you want to change the base?
Better zones UI #95
Conversation
Still a WIP. There's a bug during deserialization where opening unopened tabs makes them refresh and reorder. |
These are nice additions. Take your time and let me know when it's ready. |
- c string was copied into std::string with null char since constructor had a count parameter, causing truncation when concatenating with the ID in the imgui label.
…ult names to legacy save files.
@chrxh ready for review |
There was a problem hiding this 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{ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.).
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
.
Fair :)
Good observations. I will fix these.
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! |
Addresses
Name zones
andReorder zone tabs
in #92