Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sandialabs/InterSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohns committed Jul 15, 2024
2 parents b46f8ee + 79f24fc commit 4b7b2ed
Show file tree
Hide file tree
Showing 23 changed files with 798 additions and 320 deletions.
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ set(sources
src/D3SpectrumDisplayDiv.cpp
external_libs/SpecUtils/d3_resources/SpectrumChartD3.js
external_libs/SpecUtils/d3_resources/SpectrumChartD3.css
external_libs/SpecUtils/d3_resources/SpectrumChartD3StandAlone.css
src/D3TimeChart.cpp
src/ZipArchive.cpp
src/MultimediaDisplay.cpp
Expand Down Expand Up @@ -570,10 +569,7 @@ deploy_js_resource("${CMAKE_CURRENT_SOURCE_DIR}/external_libs/SpecUtils/d3_resou

)

set(CSS_RESOURCES_TO_COPY
"SpectrumChartD3.css"
"SpectrumChartD3StandAlone.css"
)
set( CSS_RESOURCES_TO_COPY "SpectrumChartD3.css" )

foreach(_file ${CSS_RESOURCES_TO_COPY})
deploy_css_resource("${CMAKE_CURRENT_SOURCE_DIR}/external_libs/SpecUtils/d3_resources/${_file}"
Expand Down
4 changes: 4 additions & 0 deletions InterSpec/D3SpectrumDisplayDiv.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ class D3SpectrumDisplayDiv : public Wt::WContainerWidget
std::unique_ptr<Wt::JSignal<> > m_legendClosedJS;

std::unique_ptr<Wt::JSignal<bool> > m_sliderDisplayed;
std::unique_ptr<Wt::JSignal<std::string> > m_yAxisTypeChanged;

// Wt Signals
//for all the bellow, the doubles are all the <x,y> coordinated of the action
Expand Down Expand Up @@ -535,6 +536,9 @@ class D3SpectrumDisplayDiv : public Wt::WContainerWidget
/** Called when user shows or closes the slider chart, by using the SVG buttons */
void sliderChartDisplayedCallback( const bool madeVisisble );

/** Called when the user double-clicks on y-axis title, which toggles between linear and log y-axis */
void yAxisTypeChangedCallback( const std::string &type );

/** The javascript variable name used to refer to the SpecrtumChartD3 object.
Currently is `jsRef() + ".chart"`.
*/
Expand Down
17 changes: 16 additions & 1 deletion InterSpec/DetectionLimitSimple.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace Wt
{
class WMenu;
class WText;
class WCheckBox;
class WComboBox;
class WLineEdit;
class WTabWidget;
Expand Down Expand Up @@ -168,6 +169,7 @@ class DetectionLimitSimple : public Wt::WContainerWidget
void handleUserChangedFwhm();

void handleDeconPriorChange();
void handleNoSignalPresentChanged();
void handleDeconContinuumTypeChange();

void updateSpectrumDecorationsAndResultText();
Expand Down Expand Up @@ -227,7 +229,18 @@ class DetectionLimitSimple : public Wt::WContainerWidget

Wt::WLineEdit *m_distance;

enum ConfidenceLevel { OneSigma, TwoSigma, ThreeSigma, FourSigma, FiveSigma, NumConfidenceLevel };
enum ConfidenceLevel
{
NinetyFivePercent, //0.95
NinetyNinePercent, //0.99
OneSigma, //0.682689492137086
TwoSigma, //0.954499736103642
ThreeSigma, //0.997300203936740
FourSigma, //0.999936657516334
FiveSigma, //0.999999426696856
NumConfidenceLevel
};//enum ConfidenceLevel

Wt::WComboBox *m_confidenceLevel;

DetectorDisplay *m_detectorDisplay;
Expand All @@ -254,6 +267,8 @@ class DetectionLimitSimple : public Wt::WContainerWidget
Wt::WPushButton *m_addFwhmBtn;
Wt::WPushButton *m_selectDetectorBtn;

WContainerWidget *m_isBackgroundDiv;
Wt::WCheckBox *m_isBackgroundSpectrum;
Wt::WLabel *m_continuumPriorLabel;
Wt::WComboBox *m_continuumPrior;
Wt::WLabel *m_continuumTypeLabel;
Expand Down
3 changes: 2 additions & 1 deletion InterSpec/HelpSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ namespace HelpSystem
enum class ToolTipPrefOverride
{
AlwaysShow,
RespectPreference
RespectPreference,
InstantAlways
};

enum class ToolTipPosition
Expand Down
9 changes: 9 additions & 0 deletions InterSpec_resources/DetectionLimitSimple.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@
}


.DetectionLimitSimple .BackCbDiv {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
column-gap: 5px;
}

.DeconvMoreInfo {
display: flex;
flex-direction: column;
Expand All @@ -138,3 +146,4 @@
border-collapse: separate;
border-spacing: 5px 5px;
}

2 changes: 1 addition & 1 deletion InterSpec_resources/GridLayoutHelpers.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
justify-self: stretch;
}

.GridJustifyCenter
.GridJustifyCenter, .GridHorCenter
{
justify-self: center;
}
Expand Down
16 changes: 12 additions & 4 deletions InterSpec_resources/app_text/DetectionLimitSimple.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@
<message id="dls-roi-upper-label">ROI Upper:</message>
<message id="dls-num-side-channel-label">Num Side Chan.:</message>
<message id="dls-fwhm-label">FWHM:</message>
<message id="dls-deon-cont-norm-label">Prior:</message>
<message id="dls-cont-norm-unknown">Unknown/Present</message>
<message id="dls-cont-norm-not-present">Not Present</message>
<message id="dls-cont-norm-fixed-by-sides">Cont. from sides</message>
<message id="dls-decon-cont-norm-label">Cont. Norm:</message>
<message id="dls-is-background-spectrum-cb">Background spectrum</message>
<message id="dls-is-background-spectrum-tt">
Checking this option asserts that there is no signal present in this spectrum.
<p>
The peak-region itself will be used to estimate the expected background.
The option to choose side-channels adjacent to the peak-region becomes no-longer relevant, so will be hidden.
</p>
</message>
<message id="dls-cont-norm-unknown">Floating</message>
<message id="dls-cont-norm-not-present">As no signal</message>
<message id="dls-cont-norm-fixed-by-sides">From sides</message>
<message id="dls-roi-changed-no-gamma">Changing the ROI excluded primary gamma - not changing</message>
<message id="dls-suggest-fwhm">Detector FWHM: {1} keV</message>
<message id="dls-rough-est-fwhm">Rough Est. FWHM: {1} keV</message>
Expand Down
6 changes: 3 additions & 3 deletions src/ColorThemeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ ColorThemeWidget::ColorThemeWidget(WContainerWidget *parent)
++row;
cell = table->elementAt(row, 0);
cell->addStyleClass( "CTRowLabel" );
new WLabel("Spectrum Chart Background", cell);
new WLabel("Spectrum Area", cell);
cell = table->elementAt(row, 1);

if( nativeColorSelect )
Expand All @@ -232,7 +232,7 @@ ColorThemeWidget::ColorThemeWidget(WContainerWidget *parent)
++row;
cell = table->elementAt(row, 0);
cell->addStyleClass( "CTRowLabel" );
new WLabel("Spectrum Chart Margins", cell);
new WLabel("Spectrum Chart Bckgrnd", cell);
cell = table->elementAt(row, 1);
cell->addStyleClass( "CTSelect" );
if( nativeColorSelect )
Expand All @@ -244,7 +244,7 @@ ColorThemeWidget::ColorThemeWidget(WContainerWidget *parent)
cell = table->elementAt(row, 2);
cell->addStyleClass( "CTRowDesc" );
new WText("Color for spectrum chart margins", cell);
m_specMarginSameAsBackground = new WCheckBox("Same as background", cell);
m_specMarginSameAsBackground = new WCheckBox("Same as spectrum area", cell);
m_specMarginSameAsBackground->setInline(false);


Expand Down
60 changes: 41 additions & 19 deletions src/D3SpectrumDisplayDiv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,9 @@ D3SpectrumDisplayDiv::D3SpectrumDisplayDiv( WContainerWidget *parent )

// Cancel right-click events for the div, we handle it all in JS
setAttributeValue( "oncontextmenu",
"event.cancelBubble = true; event.returnValue = false; return false;"
);
"event.cancelBubble = true; event.returnValue = false; return false;" );

InterSpec::instance()->useMessageResourceBundle( "D3SpectrumDisplayDiv" );
InterSpec::instance()->useMessageResourceBundle( "D3SpectrumDisplayDiv" );

//For development it may be useful to directly use the original JS/CSS files,
// but normally we should use the resources CMake will copy into
Expand Down Expand Up @@ -434,11 +433,15 @@ void D3SpectrumDisplayDiv::defineJavaScript()
m_legendEnabled = false;
m_legendDisabledSignal.emit();
}) );


m_sliderDisplayed.reset( new Wt::JSignal<bool>(this, "sliderChartDisplayed") );
m_sliderDisplayed->connect( boost::bind( &D3SpectrumDisplayDiv::sliderChartDisplayedCallback, this, boost::placeholders::_1 ) );

m_yAxisTypeChanged.reset( new Wt::JSignal<string>(this, "yAxisTypeChanged") );
m_yAxisTypeChanged->connect( boost::bind( &D3SpectrumDisplayDiv::yAxisTypeChangedCallback, this, boost::placeholders::_1 ) );
}//if( !m_xRangeChangedJS )

m_sliderDisplayed.reset( new Wt::JSignal<bool>(this, "sliderChartDisplayed") );
m_sliderDisplayed->connect( boost::bind( &D3SpectrumDisplayDiv::sliderChartDisplayedCallback, this, boost::placeholders::_1 ) );

for( const string &js : m_pendingJs )
doJavaScript( js );
m_pendingJs.clear();
Expand All @@ -452,9 +455,8 @@ void D3SpectrumDisplayDiv::defineJavaScript()
void D3SpectrumDisplayDiv::initChangeableCssRules()
{
WCssStyleSheet &style = wApp->styleSheet();

m_cssRules["GridColor"] = style.addRule( ".xgrid > .tick, .ygrid > .tick", "stroke: #b3b3b3" );
m_cssRules["MinorGridColor"] = style.addRule( ".minorgrid", "stroke: #e6e6e6" );
m_cssRules["GridColor"] = style.addRule( ":root", "--d3spec-grid-major-color: #b3b3b3;" ); //Not actually needed, as CSS will default to this
m_cssRules["MinorGridColor"] = style.addRule( ":root", "--d3spec-grid-minor-color: #e6e6e6;" ); //Not actually needed, as CSS will default to this
}//void initChangeableCssRules()


Expand Down Expand Up @@ -867,6 +869,9 @@ bool D3SpectrumDisplayDiv::yAxisIsLog() const

void D3SpectrumDisplayDiv::setYAxisLog( bool log )
{
if( m_yAxisIsLog == log )
return;

m_yAxisIsLog = log;
if( isRendered() )
doJavaScript( m_jsgraph + (log ? ".setLogY();" : ".setLinearY();") );
Expand Down Expand Up @@ -1658,14 +1663,9 @@ void D3SpectrumDisplayDiv::setAxisLineColor( const Wt::WColor &color )
if( m_cssRules.count(rulename) )
style.removeRule( m_cssRules[rulename] );

m_cssRules[rulename] = style.addRule( ":root", "--d3spec-axis-color: " + m_axisColor.cssText() );

// Sets axis colors, and ".peakLine, .escapeLineForward, .mouseLine, .secondaryMouseLine"

//ToDo: is setting feature line colors okay like this
rulename = "FeatureLinesColor";
if( m_cssRules.count(rulename) )
style.removeRule( m_cssRules[rulename] );
m_cssRules[rulename] = style.addRule( ".peakLine, .escapeLineForward, .mouseLine, .secondaryMouseLine", "stroke: " + m_axisColor.cssText() );
m_cssRules[rulename] = style.addRule( ":root", "--d3spec-axis-color: " + m_axisColor.cssText() );

//ToDo: figure out how to make grid lines look okay.
//rulename = "GridColor";
Expand Down Expand Up @@ -1701,8 +1701,9 @@ void D3SpectrumDisplayDiv::setChartMarginColor( const Wt::WColor &color )
if( m_cssRules.count(rulename) )
style.removeRule( m_cssRules[rulename] );

m_cssRules[rulename] = style.addRule( ":root", "--d3spec-background-color: " + color.cssText() + ";" );
//Actually this will set the background for the entire chart...
m_cssRules[rulename] = style.addRule( "#" + id() + " > svg", "background: " + color.cssText() );
//m_cssRules[rulename] = style.addRule( "#" + id() + " > svg", "background: " + color.cssText() ); // to set background color for just this chart
}//setChartMarginColor(...)


Expand All @@ -1717,8 +1718,9 @@ void D3SpectrumDisplayDiv::setChartBackgroundColor( const Wt::WColor &color )

if( m_cssRules.count(rulename) )
style.removeRule( m_cssRules[rulename] );

m_cssRules[rulename] = style.addRule( "#chartarea" + id(), "fill: " + c );

m_cssRules[rulename] = style.addRule( ":root", "--d3spec-chart-area-color: " + c + ";" );
//m_cssRules[rulename] = style.addRule( "#chartarea" + id(), "fill: " + c ); //If we wanted to apply this color to only this chart
}

void D3SpectrumDisplayDiv::setDefaultPeakColor( const Wt::WColor &color )
Expand Down Expand Up @@ -2583,6 +2585,26 @@ void D3SpectrumDisplayDiv::sliderChartDisplayedCallback( const bool madeVisisble
}//void sliderChartDisplayedCallback( const bool madeVisisble );


void D3SpectrumDisplayDiv::yAxisTypeChangedCallback( const std::string &type )
{
const bool isLogY = (type == "log");
if( isLogY == m_yAxisIsLog )
return;

m_yAxisIsLog = isLogY;
InterSpec *interspec = InterSpec::instance();
interspec->setLogY( m_yAxisIsLog ); //toggles menu items, but wont put in undo/redo step

UndoRedoManager *undoRedo = UndoRedoManager::instance();
if( undoRedo && undoRedo->canAddUndoRedoNow() )
{
undoRedo->addUndoRedoStep( [isLogY](){ InterSpec::instance()->setLogY(!isLogY); },
[isLogY](){ InterSpec::instance()->setLogY(isLogY); },
"Toggle log-y axis" );
}
}//void yAxisTypeChanged( const std::string &type )


D3SpectrumDisplayDiv::~D3SpectrumDisplayDiv()
{
//doJavaScript( "try{" + m_jsgraph + "=null;}catch(){}" );
Expand Down
Loading

0 comments on commit 4b7b2ed

Please sign in to comment.