Skip to content

Commit

Permalink
Remove using SpectrumDataModel from D3SpectrumDisplayDiv and `Pea…
Browse files Browse the repository at this point in the history
…kModel`.

Use of `SpectrumDataModel` was pretty vestigial and overkill, so removed using the class where a simple `shared_ptr` to a spectrum would suffice.
  • Loading branch information
wcjohns committed May 6, 2024
1 parent 5a31e36 commit 4e040a3
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 133 deletions.
22 changes: 11 additions & 11 deletions InterSpec/D3SpectrumDisplayDiv.h
Expand Up @@ -25,7 +25,6 @@ class SpecMeas;
class PeakModel;
class InterSpec;
struct ColorTheme;
class SpectrumDataModel;
namespace Wt
{
class WCssTextRule;
Expand All @@ -40,10 +39,9 @@ namespace SpecUtils{ enum class SpectrumType : int; }
internal flag, call WWidget::scheduleRender(0), and not load the JS/JSON to
client until D3SpectrumDisplayDiv::render() is called. Same thing with
colors and scale factors.
- Get rid of SpectrumDataModel. Will also require modifying PeakModel.
- The y-axis range is not propogated from the client to server after many
- The y-axis range is not propagated from the client to server after many
operations; this should be fixed. Also, not sure if x-axis range is always
propogated.
propagated.
- showHistogramIntegralsInLegend() is not implemented client side
- setTextInMiddleOfChart() is not implemented client side
- assign unique spectrum ID's in the JSON for each spectrum; convert JS to
Expand Down Expand Up @@ -271,11 +269,6 @@ class D3SpectrumDisplayDiv : public Wt::WContainerWidget
// to include the SpectrumChart header for just this
void setShowPeakLabel( int peakLabel, bool show );
bool showingPeakLabel( int peakLabel ) const;

#if( BUILD_AS_UNIT_TEST_SUITE )
SpectrumDataModel *model(){ return m_model; }
#endif


void setReferncePhotoPeakLines( const ReferenceLineInfo &nuc );
void persistCurrentReferncePhotoPeakLines();
Expand Down Expand Up @@ -320,6 +313,9 @@ class D3SpectrumDisplayDiv : public Wt::WContainerWidget
*/
void initChangeableCssRules();

void doBackgroundLiveTimeNormalization();
void doSecondaryLiveTimeNormalization();

/** Sets the highlight regions to client - currently unimplemented. */
void setHighlightRegionsToClient();

Expand Down Expand Up @@ -350,10 +346,14 @@ class D3SpectrumDisplayDiv : public Wt::WContainerWidget

Wt::WFlags<D3RenderActions> m_renderFlags;

//ToDo: should eliminate use of SpectrumDataModel in this class
SpectrumDataModel *m_model;
PeakModel *m_peakModel;

std::shared_ptr<const SpecUtils::Measurement> m_foreground;
std::shared_ptr<const SpecUtils::Measurement> m_secondary;
std::shared_ptr<const SpecUtils::Measurement> m_background;
float m_secondaryScale;
float m_backgroundScale;

bool m_compactAxis;
bool m_legendEnabled;
bool m_yAxisIsLog;
Expand Down
9 changes: 3 additions & 6 deletions InterSpec/PeakModel.h
Expand Up @@ -39,7 +39,6 @@
#include "InterSpec/PeakDef.h"

class SpecMeas;
class SpectrumDataModel;

namespace SpecUtils{ class Measurement; }

Expand Down Expand Up @@ -91,10 +90,8 @@ class PeakModel: public Wt::WAbstractItemModel
PeakModel( Wt::WObject *parent = 0 );
virtual ~PeakModel();

//Inorder to display continuum area of peaks, you need to set the data model
// XXX - note that with PeakDef refactorization that happened in Dec 2013,
// this requirement/paradyn could be eliminated probably
void setDataModel( SpectrumDataModel *dataModel );
/** Sets the foreground spectrum - necessary for stepped continua. */
void setForeground( std::shared_ptr<const SpecUtils::Measurement> spec );

//setPeakFromSpecMeas(...): when the primary spectrum is changed (either file,
// or the displayed sample numbers), then this function should be called to
Expand Down Expand Up @@ -411,7 +408,7 @@ class PeakModel: public Wt::WAbstractItemModel
void removePeakInternal( std::shared_ptr<const PeakDef> peak );


SpectrumDataModel *m_dataModel;
std::shared_ptr<const SpecUtils::Measurement> m_foreground;

//m_peaks and m_sortedPeaks contain the same peaks, they just differ in how
// they are sorted.
Expand Down
20 changes: 12 additions & 8 deletions InterSpec/SpectrumDataModel.h
Expand Up @@ -42,10 +42,9 @@ namespace SpecUtils{ class Measurement; }

class SpectrumDataModel: public Wt::WAbstractItemModel
{
/********\
| This class is a holding area for data on the graph. It allows for
| accessing, modifying, etc. the data points in order to shift data
| and then draw it.
/**
| This is used to store foreground/background/secondary spectra for use
| within the `SpectrumChart` class.
|
| When using any of the WAbstractItemModel or WModelIndex function calls,
| this class has each column correspond to a piece of data:
Expand All @@ -57,8 +56,7 @@ class SpectrumDataModel: public Wt::WAbstractItemModel
| The given x value for a bin is the center of the bin, not either edge.
| Note that ROOT TH1s use the lower edge as the x value, and this is _not_
| the case.
|
\********/
*/

public:
// Some convenient constants for addressing the columns.
Expand All @@ -78,8 +76,14 @@ class SpectrumDataModel: public Wt::WAbstractItemModel
// If one of the following functions that add or change a histogram would
// encounter a binning inconsistency, it might throw an std::runtime_error

//setDataHistogram(): also sets m_secondSF and m_backgroundSF to
// m_dataLiveTime/m_{Second|Background}LiveTime
/** Sets the foreground data histogram.
Also sets `m_secondSF` and `m_backgroundSF` to
`m_dataLiveTime/m_{Second|Background}LiveTime`
If you are also using a `PeakModel` with the `SpectrumChart`, make sure to also
set the data to it as well, or hook it up to `dataSet()` signal as well.
*/
void setDataHistogram( std::shared_ptr<const SpecUtils::Measurement> hist );

//setSecondDataHistogram(): also sets m_secondSF to m_dataLiveTime/m_secondDataLiveTime
Expand Down

0 comments on commit 4e040a3

Please sign in to comment.