Skip to content

Commit 1a62e29

Browse files
committed
Merge branch 'master' of https://github.com/sandialabs/InterSpec
2 parents 90d72f9 + 23f901f commit 1a62e29

19 files changed

+433
-425
lines changed

InterSpec/D3SpectrumDisplayDiv.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,6 @@ class D3SpectrumDisplayDiv : public Wt::WContainerWidget
196196
const float upperx,
197197
const Wt::WColor &color );
198198

199-
200-
//By default SpectrumDisplayDiv has setLayoutSizeAware(true) set, so if the
201-
// widget is being sized by a Wt layout manager, layoutWidth() and
202-
// layoutHeight() will return this widget width and height respectively
203-
int layoutWidth() const;
204-
int layoutHeight() const;
205-
206199
//For the case of auto-ranging x-axis, the below _may_ return 0 when auto
207200
// range is set, but chart hasnt been rendered (although maybe +-DBL_MAX)
208201
double xAxisMinimum() const;
@@ -298,9 +291,6 @@ class D3SpectrumDisplayDiv : public Wt::WContainerWidget
298291

299292
void setForegroundPeaksToClient();
300293

301-
//layoutSizeChanged(...): adjusts display binning if necessary
302-
virtual void layoutSizeChanged ( int width, int height );
303-
304294
virtual void render( Wt::WFlags<Wt::RenderFlag> flags );
305295

306296
/** Flags */
@@ -323,9 +313,6 @@ class D3SpectrumDisplayDiv : public Wt::WContainerWidget
323313
SpectrumDataModel *m_model;
324314
PeakModel *m_peakModel;
325315

326-
int m_layoutWidth;
327-
int m_layoutHeight;
328-
329316
bool m_compactAxis;
330317
bool m_legendEnabled;
331318
bool m_yAxisIsLog;

InterSpec/D3TimeChart.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ class D3TimeChart : public Wt::WContainerWidget
9999
/** When the user drags on the chart to change the time range the spectrum is displayed for. */
100100
Wt::Signal<int/*start sample number*/,int/*end sample number*/,Wt::WFlags<Wt::KeyboardModifier>> &chartDragged();
101101

102-
/** When the chart is resized; gives new width and height of the chart area (e.g., the area inside
103-
the axis lines), in pixels.
104-
*/
105-
Wt::Signal<double/*chart width px*/,double/*chart height px*/> &chartResized();
106-
107102
/** Signal emitted when the displayed x-axis range changes via a user action; e.g., when zooming
108103
into or out of a region of interest.
109104
*/
@@ -138,16 +133,6 @@ class D3TimeChart : public Wt::WContainerWidget
138133
void setY1AxisTitle( const std::string &title );
139134
void setY2AxisTitle( const std::string &title );
140135

141-
142-
//By default SpectrumDisplayDiv has setLayoutSizeAware(true) set, so if the
143-
// widget is being sized by a Wt layout manager, layoutWidth() and
144-
// layoutHeight() will return this widget width and height respectively
145-
int layoutWidth() const;
146-
int layoutHeight() const;
147-
148-
double chartWidthInPixels() const;
149-
double chartHeightInPixels() const;
150-
151136
void setCompactAxis( const bool compact );
152137
bool isAxisCompacted() const;
153138

@@ -182,9 +167,6 @@ class D3TimeChart : public Wt::WContainerWidget
182167
void setDataToClient();
183168
void setHighlightRegionsToClient();
184169

185-
//layoutSizeChanged(...): adjusts display binning if necessary
186-
virtual void layoutSizeChanged ( int width, int height );
187-
188170
/** Shows or hides the user-selectable filters to control what the mouse/touch selects and energy range. */
189171
void showFilters( const bool show );
190172

@@ -255,8 +237,6 @@ class D3TimeChart : public Wt::WContainerWidget
255237
/** The width of the plotting area in pixels. */
256238
double m_chartWidthPx;
257239

258-
/** The height of the plotting area in pixels. */
259-
double m_chartHeightPx;
260240

261241
bool m_compactXAxis;
262242
bool m_showVerticalLines;
@@ -283,20 +263,17 @@ class D3TimeChart : public Wt::WContainerWidget
283263
// Signals to hook C++ code to, to be notified when a user action happens
284264
Wt::Signal<int/*sample number*/,Wt::WFlags<Wt::KeyboardModifier>> m_chartClicked;
285265
Wt::Signal<int/*start sample number*/,int/*end sample number*/,Wt::WFlags<Wt::KeyboardModifier>> m_chartDragged;
286-
Wt::Signal<double/*chart width px*/,double/*chart height px*/> m_chartResized;
287266
Wt::Signal<int/*start sample number*/,int/*end sample number*/,int/*samples per channel*/> m_displayedXRangeChange;
288267
//Wt::Signal<boost::optional<float> /*lower keV*/,boost::optional<float>/*upper keV*/> m_energyRangeFilterChanged;
289268

290269
// Signals called from JS to propogate infromation to the C++
291270
std::unique_ptr<Wt::JSignal<int,int>> m_chartClickedJS;
292271
std::unique_ptr<Wt::JSignal<int,int,int>> m_chartDraggedJS;
293-
std::unique_ptr<Wt::JSignal<double,double>> m_chartResizedJS;
294272
std::unique_ptr<Wt::JSignal<int,int,int>> m_displayedXRangeChangeJS;
295273

296274
// Functions connected to the JSignal's
297275
void chartClickedCallback( int sample_number, int modifier_keys );
298276
void chartDraggedCallback( int first_sample_number, int last_sample_number, int modifier_keys );
299-
void chartResizedCallback( double chart_width_px, double chart_height_px );
300277
void displayedXRangeChangeCallback( int first_sample_number, int last_sample_number, int samples_per_channel );
301278

302279
/** The javascript variable name used to refer to the SpecrtumChartD3 object.

InterSpec/DbFileBrowser.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ class SnapshotBrowser : public Wt::WContainerWidget
6464

6565
int numSnaphots() const;
6666

67+
/** Returns the number of saved states available. */
68+
static size_t num_saved_states( InterSpec *viewer,
69+
std::shared_ptr<DataBaseUtils::DbSession> session,
70+
std::shared_ptr<const SpectraFileHeader> header );
71+
6772
protected:
6873
void selectionChanged();
6974
void startDeleteSelected();

InterSpec/InterSpec.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,6 @@ class InterSpec : public Wt::WContainerWidget
497497

498498
void toggleToolTip( const bool showToolTips );
499499

500-
int paintedWidth() const; //Depreciated
501-
int paintedHeight() const; //Depreciated //XXX Not correct due to all padding and stuff, but close
502-
503500
/** Width of the apps window, in pixels. Will return a value of zero if (not yet) available. */
504501
int renderedWidth() const;
505502
/** Height of the apps window, in pixels. Will return a value of zero if (not yet) available. */
@@ -1192,9 +1189,18 @@ class InterSpec : public Wt::WContainerWidget
11921189
SpecMeasManager *m_fileManager; // The file manager
11931190
Wt::WGridLayout *m_layout;
11941191

1192+
// 20210604: started playing around with using FLEX layout for just the charts - its not there yet,
1193+
// but shows some promise.
1194+
#define USE_FLEX_CHART_LAYOUT 0
1195+
11951196
//Note: m_chartsLayout may be eliminated; may even be able to eliminate
11961197
// m_toolsLayout...
1198+
#if( USE_FLEX_CHART_LAYOUT )
1199+
Wt::WContainerWidget *m_chartsDiv;
1200+
#else
11971201
Wt::WGridLayout *m_chartsLayout;
1202+
#endif
1203+
11981204
Wt::WGridLayout *m_toolsLayout;
11991205
Wt::WContainerWidget *m_menuDiv; // The top menu bar.
12001206

InterSpec/PeakDef.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,9 @@ struct PeakContinuum
224224

225225
//translate_offset_polynomial: if you want the exact same polynomial
226226
// line, but would like it with reference to a different energy,
227-
// use this funtion.
228-
//XXX - Currently only supports constant and linear polynomials.
227+
// use this function.
228+
// TODO: Does NOT support Quadratic, Cubic, or External continuum types
229+
// TODO: Currently untested
229230
static void translate_offset_polynomial( double *new_coefs,
230231
const double *old_coefs,
231232
OffsetType type,

InterSpec/PopupDiv.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,8 @@ class PopupDivMenu : public Wt::WPopupMenu
195195
// if the parent has been deleteed, or this widget reomved from it.
196196
Wt::WMenuItem *parentItem();
197197

198-
//showFromClick() and showFromMouseOver() are convience functions that call
199-
// doShow(bool). They are hopefully temprary to work around an issue where
200-
// if this->popup(parent,Vertical) is called, then this menu will actually be
201-
// hidden (probably related to Wt calling this function in JS as well...).
202-
void showFromClick();
203-
void showFromMouseOver();
204-
205198
//
206-
void doShow( bool clicked );
199+
void showMobile();
207200

208201

209202
void setupDesktopMenuStuff();

InterSpec/SpecMeasManager.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,6 @@ class SpecMeasManager : public Wt::WObject
406406
Wt::WContainerWidget *createButtonBar();
407407
void deleteSpectrumManager();
408408
Wt::WContainerWidget *createTreeViewDiv();
409-
void createInfoHandler();
410-
void refreshAdditionalInfo( bool clearInfo = false );
411409

412410

413411
protected:

InterSpec_resources/D3TimeChart.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,10 @@ D3TimeChart.prototype.handleResize = function () {
447447
// ...
448448
// Make sure to update the C++ code of the changed plotting size.
449449
try {
450-
// console.log("Resized!");
450+
// console.log( "Resized! New size={" + this.chart.clientWidth + "," + this.chart.clientHeight + "}" );
451451
this.state.height = this.chart.clientHeight;
452452
this.state.width = this.chart.clientWidth;
453-
453+
454454
this.reinitializeChart();
455455
} catch (err) {
456456
if (err instanceof ValidationError) {

src/D3SpectrumDisplayDiv.cpp

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ D3SpectrumDisplayDiv::D3SpectrumDisplayDiv( WContainerWidget *parent )
179179
m_renderFlags( 0 ),
180180
m_model( new SpectrumDataModel( this ) ),
181181
m_peakModel( 0 ),
182-
m_layoutWidth( 0 ),
183-
m_layoutHeight( 0 ),
184182
m_compactAxis( false ),
185183
m_legendEnabled( true ),
186184
m_yAxisIsLog( true ),
@@ -208,7 +206,6 @@ D3SpectrumDisplayDiv::D3SpectrumDisplayDiv( WContainerWidget *parent )
208206
m_chartBackgroundColor(),
209207
m_defaultPeakColor( 0, 51, 255, 155 )
210208
{
211-
setLayoutSizeAware( true );
212209
addStyleClass( "SpectrumDisplayDiv" );
213210

214211
// Cancel right-click events for the div, we handle it all in JS
@@ -301,7 +298,21 @@ void D3SpectrumDisplayDiv::defineJavaScript()
301298
options += "}";
302299

303300
setJavaScriptMember( "chart", "new SpectrumChartD3(" + jsRef() + "," + options + ");");
301+
302+
303+
#if( USE_FLEX_CHART_LAYOUT )
304+
doJavaScript( ""
305+
"const resizeObs" + id() + " = new ResizeObserver(entries => {"
306+
"for (let entry of entries) {"
307+
"if( entry.target && (entry.target.id === '" + id() + "') )"
308+
+ m_jsgraph + ".handleResize();"
309+
"}"
310+
"});"
311+
"resizeObs" + id() + ".observe(" + jsRef() + ");"
312+
);
313+
#else
304314
setJavaScriptMember( "wtResize", "function(self, w, h, layout){" + m_jsgraph + ".handleResize();}" );
315+
#endif
305316

306317
#if( RENDER_REFERENCE_PHOTOPEAKS_SERVERSIDE )
307318
updateReferncePhotoPeakLines();
@@ -603,13 +614,6 @@ void D3SpectrumDisplayDiv::setShowRefLineInfoForMouseOver( const bool show )
603614
}//void setShowRefLineInfoForMouseOver( const bool show )
604615

605616

606-
void D3SpectrumDisplayDiv::layoutSizeChanged ( int width, int height )
607-
{
608-
m_layoutWidth = width;
609-
m_layoutHeight = height;
610-
}//void layoutSizeChanged ( int width, int height )
611-
612-
613617
void D3SpectrumDisplayDiv::render( Wt::WFlags<Wt::RenderFlag> flags )
614618
{
615619
const bool renderFull = (flags & Wt::RenderFlag::RenderFull);
@@ -636,18 +640,6 @@ void D3SpectrumDisplayDiv::render( Wt::WFlags<Wt::RenderFlag> flags )
636640
}
637641

638642

639-
int D3SpectrumDisplayDiv::layoutWidth() const
640-
{
641-
return m_layoutWidth;
642-
}//int layoutWidth() const
643-
644-
645-
int D3SpectrumDisplayDiv::layoutHeight() const
646-
{
647-
return m_layoutHeight;
648-
}//int layoutHeight() const
649-
650-
651643
double D3SpectrumDisplayDiv::xAxisMinimum() const
652644
{
653645
return m_xAxisMinimum;
@@ -2049,7 +2041,7 @@ void D3SpectrumDisplayDiv::chartFitRoiDragCallback( double lower_energy, double
20492041
if( ismobile )
20502042
{
20512043
menu->addStyleClass( " Wt-popupmenu Wt-outset" );
2052-
menu->showFromMouseOver();
2044+
menu->showMobile();
20532045
}else
20542046
{
20552047
menu->addStyleClass( " Wt-popupmenu Wt-outset NumPeakSelect" );

0 commit comments

Comments
 (0)