Skip to content

Commit

Permalink
Hopefully fix PhysicalUnitsLocalized tests for CI.
Browse files Browse the repository at this point in the history
Also, a few other small changes that got left behind.
  • Loading branch information
wcjohns committed May 21, 2024
1 parent 3a037d8 commit ee8d705
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions InterSpec_resources/app_text/HelpSystem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
<message id="hw-tutorials-link">Tutorials and usage hints</message>
<message id="hw-err-opening-xml">Help Page Not Found</message>
<message id="hw-err-opening-json">Could not open help JSON file at '{1}'.</message>
<message id="hw-search-empty-text">Search</message>
</messages>
9 changes: 7 additions & 2 deletions InterSpec_resources/app_text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ To add a language, you do not need to translate all elements in an XML file, or

At a minimum, you must add a version of `InterSpec.xml` for the new language - preferably translating all elements, but this isn't required. In the InterSpec app, the available languages (Help &rarr; Languages &rarr;) are populated according to which `InterSpec_xx-YY.xml` files are present.

But in addition `InterSpec.xml` to You really should, at a minimum, modify:
But in addition `InterSpec.xml` to you really should, at a minimum, modify:
- `D3SpectrumDisplayDiv.xml`, `CompactFileManager.xml`, `ReferencePhotopeakDisplay.xml`, `PeakModel.xml`, `PeakInfoDisplay.xml`, `EnergyCalTool.xml`, `IsotopeSearchByEnergy.xml`
This will translate the text seem in the application in its basic view, including all the tool-tabs that are open by default.
This will translate the text seen in the application in its basic view, including all the tool-tabs that are open by default, so things will look consistent, until the user opens one of the specialized tools.


***
Expand All @@ -53,4 +53,9 @@ Some potential issues you may run into:
- Unfortunately, if the file is not valid XML, or a un-allowed character entity is used, the error-messaging is not great. When the application is loaded, the file wont be used, but on Windows, no error messages are printed out. On macOS or Linux, if you run the InterSpec executable from the command-line, an error will be printed out to stderr, giving the location of the error in the XML file.


***

A note on performance 20240521:
On an M1 mac, built in release mode, for local server, timing from the time the `InterSpec` class is created, to the ender of its first `render()` call (which I think should capture the added overhead of parsing the language XML, and localizing strings), I compared the pre-internationalization time, to the post-internationalization.
On the first load, of post-internationalized, the worst performance I got was 49 ms, however, was usually ~35 ms. On pre-internationalized, typical was 33ms. On second load (without restarting app), the timings were essentially the same between apps, with it being 10 ms for second load, and 6 ms for subsequent loads.
So all-in-all, internationalization does not cause a performance issue - assuming how I took the timings was valid.
14 changes: 9 additions & 5 deletions src/InterSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,9 @@ InterSpec::InterSpec( WContainerWidget *parent )
m_renderedWidth( 0 ),
m_renderedHeight( 0 ),
m_colorPeaksBasedOnReferenceLines( true ),
m_findingHintPeaks( false )
m_findingHintPeaks( false ),
m_hintQueue{},
m_infoNotificationsMade{}
{
//Initialization of the app (this function) takes about 11ms on my 2.6 GHz
// Intel Core i7, as of (20150316).
Expand Down Expand Up @@ -9691,10 +9693,12 @@ void InterSpec::handleToolTabChanged( int tab )

if( focus && (current_tab == calibtab) )
{
if( InterSpecUser::preferenceValue<bool>( "ShowTooltips", this ) )
passMessage( "You can also recalibrate graphically by right-clicking and "
"dragging the spectrum to where you want",
WarningWidget::WarningMsgInfo );
if( !m_infoNotificationsMade.count("recal-tab")
&& InterSpecUser::preferenceValue<bool>( "ShowTooltips", this ) )
{
m_infoNotificationsMade.insert( "recal-tab" );
passMessage( WString::tr("info-recal-tab-selected"), WarningWidget::WarningMsgInfo );
}
}//if( tab == calibtab )

m_currentToolsTab = current_tab;
Expand Down
4 changes: 2 additions & 2 deletions src/PhysicalUnits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ namespace PhysicalUnits
#define METRIC_PREFIX_UNITS "m|M|k|g|G|t|T|u|" MU_CHARACTER_1 "|" MU_CHARACTER_2 "|p|n|f|milli|micro|pico|nano|femto|kilo|mega|giga|terra"

#define PLUS_MINUS_REGEX "(\\xC2?\\xB1|\\+\\-\\s*|\\-\\+\\s*)"
#define TIME_UNIT_REGEX "(years|year|yr|y|days|day|d|hrs|hours|hour|h|minute|minutes|min|m|second|seconds|sec|s|ms|microseconds|us|nanoseconds|ns)"
#define HALF_LIFE_REGEX "(hl|halflife|halflives|half-life|half-lives|half lives|half life)"
#define TIME_UNIT_REGEX "(years|year|yr|y|days|day|d|hrs|hours|hour|h|minute|minutes|min|m|second|seconds|sec|s|ms|microseconds|us|nanosecond|nanoseconds|ns)"
#define HALF_LIFE_REGEX "(hl|halflife|halflives|half-life|half-lives|half lives|half lifes|half live|halflive|half life)"
#define ACTIVITY_UNIT_REGEX "(bq|becquerel|ci|cu|curie|c)"
#define ABSORBED_DOSE_UNIT_REGEX "(gray|Gy|gy|rad|erg|erg\\/g|erg per gram)"
#define EQUIVALENT_DOSE_UNIT_REGEX "(sievert|Sv|rem|roentgen|r" DIAERESIS_O "entgen)"
Expand Down
2 changes: 1 addition & 1 deletion target/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ add_test( NAME PhysicalUnits
add_executable( test_PhysicalUnitsLocalized test_PhysicalUnitsLocalized.cpp )
target_link_libraries( test_PhysicalUnitsLocalized PRIVATE InterSpecLib )
add_test( NAME test_PhysicalUnitsLocalized
COMMAND $<TARGET_FILE:test_PhysicalUnitsLocalized> ${BOOST_TEST_CL_ARGS}
COMMAND $<TARGET_FILE:test_PhysicalUnitsLocalized> ${BOOST_TEST_CL_ARGS} -- ${DATA_DIR_ARGS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)

Expand Down
5 changes: 5 additions & 0 deletions target/testing/test_PhysicalUnitsLocalized.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ void set_app_text_dir()
const string possible_paths[] = {
SpecUtils::append_path(datadir,".."),
SpecUtils::append_path(datadir,"../.."),
SpecUtils::get_working_path(),
SpecUtils::append_path( SpecUtils::get_working_path(), ".."),
#ifdef _WIN32
"D:\\a\\InterSpec\\",
#endif
".", "../", "../../", "../../../", "/Users/wcjohns/rad_ana/InterSpec/"
};

Expand Down

0 comments on commit ee8d705

Please sign in to comment.