Skip to content

Commit 32fd7b1

Browse files
committed
Add Focus Widget values to Session Settings - Fixes #1198
1 parent bdf0cbf commit 32fd7b1

2 files changed

Lines changed: 40 additions & 11 deletions

File tree

OpenBCI_GUI/SessionSettings.pde

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ class SessionSettings {
177177
private int loadMarkerWindow;
178178
private int loadMarkerVertScale;
179179

180+
//Focus Widget
181+
private int loadFocusMetric;
182+
private int loadFocusThreshold;
183+
private int loadFocusWindow;
184+
180185
//Primary JSON objects for saving and loading data
181186
private JSONObject saveSettingsJSONData;
182187
private JSONObject loadSettingsJSONData;
@@ -195,6 +200,7 @@ class SessionSettings {
195200
private final String kJSONKeyEmg = "emg";
196201
private final String kJSONKeyEmgJoystick = "emgJoystick";
197202
private final String kJSONKeyMarker = "marker";
203+
private final String kJSONKeyFocus = "focus";
198204

199205
//used only in this class to count the number of channels being used while saving/loading, this gets updated in updateGlobalChannelCount whenever the number of channels being used changes
200206
int sessionSettingsChannelCount;
@@ -451,6 +457,13 @@ class SessionSettings {
451457
saveMarkerSettings.setInt("markerVertScale", w_marker.getMarkerVertScale().getIndex());
452458
saveSettingsJSONData.setJSONObject(kJSONKeyMarker, saveMarkerSettings);
453459

460+
///////////////////////////////////////////////Setup new JSON object to save Marker Widget Settings
461+
JSONObject saveFocusSettings = new JSONObject();
462+
saveFocusSettings.setInt("focusMetric", w_focus.getFocusMetric().getIndex());
463+
saveFocusSettings.setInt("focusThreshold", w_focus.getFocusThreshold().getIndex());
464+
saveFocusSettings.setInt("focusWindow", w_focus.getFocusWindow().getIndex());
465+
saveSettingsJSONData.setJSONObject(kJSONKeyFocus, saveFocusSettings);
466+
454467
///////////////////////////////////////////////Setup new JSON object to save Widgets Active in respective Containers
455468
JSONObject saveWidgetSettings = new JSONObject();
456469

@@ -608,6 +621,12 @@ class SessionSettings {
608621
loadMarkerWindow = loadMarkerSettings.getInt("markerWindow");
609622
loadMarkerVertScale = loadMarkerSettings.getInt("markerVertScale");
610623

624+
//Get Focus widget settings
625+
JSONObject loadFocusSettings = loadSettingsJSONData.getJSONObject(kJSONKeyFocus);
626+
loadFocusMetric = loadFocusSettings.getInt("focusMetric");
627+
loadFocusThreshold = loadFocusSettings.getInt("focusThreshold");
628+
loadFocusWindow = loadFocusSettings.getInt("focusWindow");
629+
611630
//get the Widget/Container settings
612631
JSONObject loadWidgetSettings = loadSettingsJSONData.getJSONObject(kJSONKeyWidget);
613632
//Apply Layout directly before loading and applying widgets to containers
@@ -814,6 +833,14 @@ class SessionSettings {
814833
w_marker.setMarkerVertScale(loadMarkerVertScale);
815834
w_marker.cp5_widget.getController("markerVertScaleDropdown").getCaptionLabel().setText(w_marker.getMarkerVertScale().getString());
816835

836+
////////////////////////////Apply Focus Widget settings
837+
w_focus.setMetric(loadFocusMetric);
838+
w_focus.cp5_widget.getController("focusMetricDropdown").getCaptionLabel().setText(w_focus.getFocusMetric().getString());
839+
w_focus.setThreshold(loadFocusThreshold);
840+
w_focus.cp5_widget.getController("focusThresholdDropdown").getCaptionLabel().setText(w_focus.getFocusThreshold().getString());
841+
w_focus.setFocusHorizScale(loadFocusWindow);
842+
w_focus.cp5_widget.getController("focusWindowDropdown").getCaptionLabel().setText(w_focus.getFocusWindow().getString());
843+
817844
////////////////////////////////////////////////////////////
818845
// Apply more loaded widget settings above this line //
819846

OpenBCI_GUI/W_Focus.pde

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ class W_Focus extends Widget {
8787
//This is the protocol for setting up dropdowns.
8888
dropdownWidth = 60; //Override the default dropdown width for this widget
8989
addDropdown("focusMetricDropdown", "Metric", focusMetric.getEnumStringsAsList(), focusMetric.getIndex());
90-
addDropdown("focusClassifierDropdown", "Classifier", focusClassifier.getEnumStringsAsList(), focusClassifier.getIndex());
9190
addDropdown("focusThresholdDropdown", "Threshold", focusThreshold.getEnumStringsAsList(), focusThreshold.getIndex());
9291
addDropdown("focusWindowDropdown", "Window", xLimit.getEnumStringsAsList(), xLimit.getIndex());
9392

@@ -174,12 +173,7 @@ class W_Focus extends Widget {
174173
//Custom resize these dropdowns due to longer text strings as options
175174
cp5_widget.get(ScrollableList.class, "focusMetricDropdown").setWidth(METRIC_DROPDOWN_W);
176175
cp5_widget.get(ScrollableList.class, "focusMetricDropdown").setPosition(
177-
x0 + w0 - (dropdownWidth*2) - METRIC_DROPDOWN_W - CLASSIFIER_DROPDOWN_W - (PAD_TWO*4),
178-
navH + y0 + PAD_TWO
179-
);
180-
cp5_widget.get(ScrollableList.class, "focusClassifierDropdown").setWidth(CLASSIFIER_DROPDOWN_W);
181-
cp5_widget.get(ScrollableList.class, "focusClassifierDropdown").setPosition(
182-
x0 + w0 - (dropdownWidth*2) - CLASSIFIER_DROPDOWN_W - (PAD_TWO*3),
176+
x0 + w0 - (dropdownWidth*2) - METRIC_DROPDOWN_W - (PAD_TWO*3),
183177
navH + y0 + PAD_TWO
184178
);
185179
}
@@ -400,6 +394,18 @@ class W_Focus extends Widget {
400394
predictionExceedsThreshold = metricPrediction > focusThreshold.getValue();
401395
}
402396

397+
public FocusMetric getFocusMetric() {
398+
return focusMetric;
399+
}
400+
401+
public FocusThreshold getFocusThreshold() {
402+
return focusThreshold;
403+
}
404+
405+
public FocusXLim getFocusWindow() {
406+
return xLimit;
407+
}
408+
403409
public void clear() {
404410
focusBar.clear();
405411
metricPrediction = 0d;
@@ -417,10 +423,6 @@ public void focusMetricDropdown(int n) {
417423
w_focus.setMetric(n);
418424
}
419425

420-
public void focusClassifierDropdown(int n) {
421-
w_focus.setClassifier(n);
422-
}
423-
424426
public void focusThresholdDropdown(int n) {
425427
w_focus.setThreshold(n);
426428
}

0 commit comments

Comments
 (0)