Skip to content

Commit 3e988b3

Browse files
committed
Update version of Electron to use; some minor formatting updates to More NuclideInfo stuff.
1 parent f8c257d commit 3e988b3

File tree

5 files changed

+82
-18
lines changed

5 files changed

+82
-18
lines changed

InterSpec/MoreNuclideInfo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ namespace MoreNuclideInfo
130130
Returned pointer will be nullptr if XML file is missing, or invalid.
131131
*/
132132
static std::shared_ptr<const MoreNucInfoDb> instance();
133+
134+
/** For debug purposes, reset the pointer to the global instance of this class; any shared pointers you
135+
have will remain valid, but the next call to `MoreNucInfoDb::instance()` will return a different
136+
instance.
137+
*/
138+
static void remove_global_instance();
133139

134140
std::map<const SandiaDecay::Nuclide *, NucInfo> m_nuc_infos;
135141
std::map<std::string, NucInfo> m_other_infos;

InterSpec_resources/MoreNuclideInfoDisplay.css

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
.MoreNuclideInfoDisplay a
1313
{
14-
color: blue;
14+
/* color: blue; */
1515
cursor: pointer;
1616
}
1717

@@ -40,6 +40,7 @@
4040
margin-bottom: 10px;
4141
}
4242

43+
4344
.MoreNuclideInfoDisplay .MoreNucInfoSection .MoreNucInfoSubTitle
4445
{
4546
font-weight: 700;
@@ -84,24 +85,24 @@
8485
}
8586

8687
/* Render unordered lists as CSV lines - this is for the associated nuclides list */
87-
.MoreNuclideInfoDisplay ul
88+
.MoreNuclideInfoDisplay ul.MoreNucInfoRelated
8889
{
8990
display: inline;
9091
list-style: none;
9192
padding-inline-start: 0px;
9293
}
9394

94-
.MoreNuclideInfoDisplay ul > li
95+
.MoreNuclideInfoDisplay ul.MoreNucInfoRelated > li
9596
{
9697
display: inline;
9798
}
9899

99-
.MoreNuclideInfoDisplay ul > li:after
100+
.MoreNuclideInfoDisplay ul.MoreNucInfoRelated > li:after
100101
{
101102
content: ", ";
102103
}
103104

104-
.MoreNuclideInfoDisplay ul > li:last-child:after
105+
.MoreNuclideInfoDisplay ul.MoreNucInfoRelated > li:last-child:after
105106
{
106107
content: "";
107108
}
@@ -119,13 +120,36 @@
119120
margin-block-start: 0px;
120121
}
121122

122-
.MoreNuclideInfoDisplay button.with-label.Wt-btn.LightButton
123+
.MoreNuclideInfoDisplay button.with-label.Wt-btn.LightButton,
124+
.MoreNuclideInfoDisplay a
125+
{
126+
color: rgb(18,101,200);
127+
}
128+
129+
.MoreNuclideInfoDisplay button.with-label.Wt-btn.LightButton:hover,
130+
.MoreNuclideInfoDisplay a:hover
123131
{
124-
color: blue;
132+
color: rgb(99, 161, 236);
125133
}
126134

135+
127136
.MoreNuclideInfoDisplay button.DecayBtn
128137
{
129138
margin-top: 5px;
130139
margin-left: 15px;
131-
}
140+
}
141+
142+
143+
/* This is each paragraph within analyst notes; i.e., where there was more than one blank lines
144+
between writing in more_nuclide_info.xml
145+
*/
146+
.MoreNuclideInfoDisplay .MoreNucInfoSection .MoreNucInfoSubSec
147+
{
148+
margin-top: 5px;
149+
margin-bottom: 10px;
150+
}
151+
152+
.MoreNuclideInfoDisplay .MoreNucInfoSection .MoreNucInfoSubSec > ul
153+
{
154+
margin-block-start: 2px;
155+
}

src/MoreNuclideInfo.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,21 @@ namespace MoreNuclideInfo
146146
}//std::shared_ptr<const MoreNucInfoDb> MoreNucInfoDb::instance()
147147

148148

149+
void MoreNucInfoDb::remove_global_instance()
150+
{
151+
std::lock_guard<std::mutex> lock( sm_mutex );
152+
if( sm_db )
153+
{
154+
assert( sm_status == MoreNuclideInfo::InfoStatus::Inited );
155+
sm_db.reset();
156+
sm_status = MoreNuclideInfo::InfoStatus::NotInited;
157+
}else
158+
{
159+
assert( sm_status != MoreNuclideInfo::InfoStatus::Inited );
160+
}
161+
}//void MoreNucInfoDb::remove_global_instance()
162+
163+
149164
MoreNucInfoDb::MoreNucInfoDb()
150165
{
151166
}

src/MoreNuclideInfoDisplay.cpp

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "InterSpec_config.h"
2525

26+
#include <regex>
2627
#include <string>
2728
#include <fstream>
2829
#include <sstream>
@@ -339,9 +340,23 @@ void MoreNuclideInfoDisplay::setNuclide( const SandiaDecay::Nuclide *const nuc,
339340
const auto more_info_db = MoreNucInfoDb::instance();
340341
if( more_info_db )
341342
{
343+
#ifndef NDEBUG
344+
#warning "Reseting MoreNucInfoDb for iterating purposes - remove this!"
345+
cerr << "Reseting MoreNucInfoDb for iterating purposes - remove this!" << endl;
346+
MoreNucInfoDb::remove_global_instance();
347+
#endif
348+
342349
const NucInfo *const more_info = more_info_db->info( nuc );
343350

344-
if( more_info )
351+
if( !more_info )
352+
{
353+
// We need to fill these conditions out, incase we are setting a nuclide that doesnt have
354+
// them, but the previously displayed nuclide did.
355+
tmplt.setCondition( "if-has-more-info", false );
356+
tmplt.setCondition( "if-has-related", false );
357+
tmplt.bindWidget( "related-nucs", nullptr );
358+
tmplt.bindString( "more-info", "", Wt::TextFormat::XHTMLText );
359+
}else
345360
{
346361
tmplt.setCondition( "if-has-related", !more_info->m_associated.empty() );
347362
if( !more_info->m_associated.empty() )
@@ -353,9 +368,9 @@ void MoreNuclideInfoDisplay::setNuclide( const SandiaDecay::Nuclide *const nuc,
353368
for( size_t i = 0; i < more_info->m_associated.size(); ++i )
354369
{
355370
const SandiaDecay::Nuclide *associated = db->nuclide( more_info->m_associated[i] );
371+
WContainerWidget *li = new WContainerWidget( associatedList );
356372
if( associated )
357373
{
358-
WContainerWidget *li = new WContainerWidget( associatedList );
359374
WAnchor *anchor = new WAnchor( li );
360375
anchor->setText( more_info->m_associated[i] );
361376
anchor->clicked().connect( boost::bind( &MoreNuclideInfoDisplay::setNuclide, this, associated, history ) );
@@ -365,8 +380,7 @@ void MoreNuclideInfoDisplay::setNuclide( const SandiaDecay::Nuclide *const nuc,
365380
t->addStyleClass( "HalfLife" );
366381
}else
367382
{
368-
WText *txtw = new WText( more_info->m_associated[i], associatedList );
369-
txtw->setInline( false );
383+
new WText( more_info->m_associated[i], li );
370384
}
371385
}
372386

@@ -380,11 +394,16 @@ void MoreNuclideInfoDisplay::setNuclide( const SandiaDecay::Nuclide *const nuc,
380394
SpecUtils::ireplace_all( notes, "\r", "" );
381395
vector<string> more_info_lines;
382396

397+
// Replace things like &lt;li&gt;Some List Item&lt;/li&gt;
398+
// to <li>Some List Item</li>
399+
std::regex tag_regex( "&lt;([a-zA-Z/ ]{1,4})&gt;" );
400+
notes = std::regex_replace( notes, tag_regex,"<$1>");
401+
383402
boost::algorithm::split( more_info_lines, notes,
384403
boost::algorithm::is_any_of( "\n" ),
385404
boost::algorithm::token_compress_off );
386-
387-
notes = "<p>";
405+
406+
notes = "<div class=\"MoreNucInfoSubSec\">";
388407
for( size_t i = 0; i < more_info_lines.size(); ++i )
389408
{
390409
string line = more_info_lines[i];
@@ -394,7 +413,7 @@ void MoreNuclideInfoDisplay::setNuclide( const SandiaDecay::Nuclide *const nuc,
394413

395414
if( line.empty() )
396415
{
397-
notes += "</p><p>";
416+
notes += "</div><div class=\"MoreNucInfoSubSec\">";
398417

399418
// Skip all the next empty lines
400419
for( ; (i + 1) < more_info_lines.size(); ++i )
@@ -407,7 +426,7 @@ void MoreNuclideInfoDisplay::setNuclide( const SandiaDecay::Nuclide *const nuc,
407426
}//if( line.empty() )
408427
}//for( size_t i = 0; i < more_info_lines.size(); ++i )
409428

410-
notes += "</p>";
429+
notes += "</div>";
411430
tmplt.bindString( "more-info", notes, Wt::TextFormat::XHTMLText );
412431
}//if( more_info )
413432
}//if( more_info_db )
@@ -443,4 +462,4 @@ MoreNuclideInfoWindow::MoreNuclideInfoWindow( const SandiaDecay::Nuclide *const
443462
{
444463
m_display = new MoreNuclideInfoDisplay( nuc, contents() );
445464
addButton( "Close" );
446-
}//MoreNuclideInfoWindow
465+
}//MoreNuclideInfoWindow

target/electron/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"cmake-js": "^6.1.0"
2626
},
2727
"devDependencies": {
28-
"electron": "^23.1.3",
28+
"electron": "^21.4.2",
2929
"electron-packager": "^17.1.1",
3030
"node-addon-api": "^6.0.0"
3131
}

0 commit comments

Comments
 (0)