Skip to content

Commit

Permalink
use the model when setting up the event handlers for more reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon committed Oct 3, 2023
1 parent e5c3431 commit 7b7d945
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,6 @@ private void runAcquisition(boolean speedTest) {
}

private void createEventHandlers() {
final DefaultAcquisitionSettingsDISPIM.Builder asb_ =
model_.acquisitions().settingsBuilder();

// start/stop acquisitions
btnRunAcquisition_.registerListener(e -> {
Expand Down Expand Up @@ -277,28 +275,28 @@ private void createEventHandlers() {
// multiple positions
cbxUseMultiplePositions_.registerListener(e -> {
final boolean isSelected = cbxUseMultiplePositions_.isSelected();
asb_.useMultiplePositions(isSelected);
model_.acquisitions().settingsBuilder().useMultiplePositions(isSelected);
pnlMultiPositions_.setEnabled(isSelected);
});

// time points
cbxUseTimePoints_.registerListener(e -> {
final boolean selected = cbxUseTimePoints_.isSelected();
asb_.useTimePoints(selected);
model_.acquisitions().settingsBuilder().useTimePoints(selected);
pnlTimePoints_.setEnabled(selected);
//updateDurationLabels();
});

// use channels
cbxUseChannels_.registerListener(e -> {
final boolean state = cbxUseChannels_.isSelected();
asb_.useChannels(state);
model_.acquisitions().settingsBuilder().useChannels(state);
pnlChannelTable_.setItemsEnabled(state);
});

cmbAcquisitionModes_.registerListener(e -> {
final int index = cmbAcquisitionModes_.getSelectedIndex();
asb_.acquisitionMode(AcquisitionMode.getByIndex(index));
model_.acquisitions().settingsBuilder().acquisitionMode(AcquisitionMode.getByIndex(index));
//System.out.println("getAcquisitionMode: " + model_.acquisitions().getAcquisitionSettings().getAcquisitionMode());
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ private void setSetupOptionsState(final boolean state) {
}

private void createEventHandlers() {
final DefaultAutofocusSettings.Builder afsb_ = model_
.acquisitions().settingsBuilder().autofocusSettingsBuilder();

// general autofocus settings
cbxShowImages_.registerListener(e -> {
Expand All @@ -206,32 +204,40 @@ private void createEventHandlers() {
});

spnNumImages_.registerListener(e ->
afsb_.numImages(spnNumImages_.getInt()));
model_.acquisitions().settingsBuilder()
.autofocusSettingsBuilder().numImages(spnNumImages_.getInt()));

spnStepSize_.registerListener(e ->
afsb_.stepSize(spnStepSize_.getDouble()));
model_.acquisitions().settingsBuilder()
.autofocusSettingsBuilder().stepSize(spnStepSize_.getDouble()));

spnMinimumR2_.registerListener(e -> {
afsb_.r2(spnMinimumR2_.getDouble());
model_.acquisitions().settingsBuilder()
.autofocusSettingsBuilder().r2(spnMinimumR2_.getDouble());
});

cmbAutofocusMode_.registerListener(e -> {
afsb_.mode(AutofocusMode.fromString(cmbAutofocusMode_.getSelected()));
model_.acquisitions().settingsBuilder().autofocusSettingsBuilder()
.mode(AutofocusMode.fromString(cmbAutofocusMode_.getSelected()));
});

cmbScoringAlgorithm_.registerListener(e -> {
afsb_.scoringAlgorithm(AutofocusType.fromString(cmbScoringAlgorithm_.getSelected()));
model_.acquisitions().settingsBuilder().autofocusSettingsBuilder()
.scoringAlgorithm(AutofocusType.fromString(cmbScoringAlgorithm_.getSelected()));
});

cmbFittingFunction_.registerListener(e -> {
afsb_.fit(AutofocusFitType.fromString(cmbFittingFunction_.getSelected()));
model_.acquisitions().settingsBuilder().autofocusSettingsBuilder()
.fit(AutofocusFitType.fromString(cmbFittingFunction_.getSelected()));
});

// autofocus options during acquisition
cbxAutofocusEveryPass_.registerListener(e -> System.out.println("cbxAutofocusEveryPass_: " + cbxAutofocusEveryPass_.isSelected()));
cbxAutofocusBeforeAcq_.registerListener(e -> System.out.println("cbxAutofocusBeforeAcq_: " + cbxAutofocusBeforeAcq_.isSelected()));

cmbAutofocusChannel_.registerListener(e -> System.out.println("cmbAutofocusChannel_"));
cbxAutofocusEveryPass_.registerListener(e ->
System.out.println("cbxAutofocusEveryPass_: " + cbxAutofocusEveryPass_.isSelected()));
cbxAutofocusBeforeAcq_.registerListener(e ->
System.out.println("cbxAutofocusBeforeAcq_: " + cbxAutofocusBeforeAcq_.isSelected()));
cmbAutofocusChannel_.registerListener(e ->
System.out.println("cmbAutofocusChannel_"));

spnAutofocusEveryX_.registerListener(e -> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ private void createUserInterface() {
}

private void createEventHandlers() {
final DefaultAcquisitionSettingsDISPIM.Builder asb_ =
model_.acquisitions().settingsBuilder();

btnBrowse_.registerListener((EventObject e) -> {
//final String path = fileSelect_.openDialogBox(this, new File(""));
Expand All @@ -108,25 +106,25 @@ private void createEventHandlers() {
directorySelect_
);
if (result != null) {
asb_.saveDirectory(result.toString());
model_.acquisitions().settingsBuilder().saveDirectory(result.toString());
txtSaveDirectory_.setText(result.toString());
}
//System.out.println("getSaveDirectory: " + model_.acquisitions().getAcquisitionSettings().getSaveDirectory());
});

cbxSaveWhileAcquiring_.registerListener(e -> {
asb_.saveImagesDuringAcquisition(cbxSaveWhileAcquiring_.isSelected());
model_.acquisitions().settingsBuilder().saveImagesDuringAcquisition(cbxSaveWhileAcquiring_.isSelected());
//System.out.println("isSavingWhileAcquiring: " + model_.acquisitions().getAcquisitionSettings().isSavingWhileAcquiring());
});

txtSaveFileName_.registerListener(e -> {
asb_.saveNamePrefix(txtSaveFileName_.getText());
model_.acquisitions().settingsBuilder().saveNamePrefix(txtSaveFileName_.getText());
//System.out.println("getSaveNamePrefix: " + model_.acquisitions().getAcquisitionSettings().getSaveNamePrefix());
});

radSaveMode_.registerListener(e -> {
model_.acquisitions().settingsBuilder().saveMode(DataStorage.SaveMode.fromString(radSaveMode_.getSelectedButtonText()));
System.out.println("radSaveMode: " + radSaveMode_.getSelectedButtonText());
asb_.saveMode(DataStorage.SaveMode.fromString(radSaveMode_.getSelectedButtonText()));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,30 @@ private void createUserInterface() {
}

private void createEventHandlers() {
final DefaultScanSettings.Builder scsb = model_.acquisitions()
.settingsBuilder().scanSettingsBuilder();

// Scan Settings
spnScanAcceleration_.registerListener(e ->
scsb.scanAccelerationFactor(spnScanAcceleration_.getDouble()));
model_.acquisitions().settingsBuilder().scanSettingsBuilder()
.scanAccelerationFactor(spnScanAcceleration_.getDouble()));
spnScanOvershootDist_.registerListener(e ->
scsb.scanOvershootDistance(spnScanOvershootDist_.getInt()));
model_.acquisitions().settingsBuilder().scanSettingsBuilder()
.scanOvershootDistance(spnScanOvershootDist_.getInt()));
spnScanRetraceSpeed_.registerListener(e ->
scsb.scanRetraceSpeed(spnScanRetraceSpeed_.getDouble()));
model_.acquisitions().settingsBuilder().scanSettingsBuilder()
.scanRetraceSpeed(spnScanRetraceSpeed_.getDouble()));
spnScanAngleFirstView_.registerListener(e ->
scsb.scanAngleFirstView(spnScanAngleFirstView_.getDouble()));
model_.acquisitions().settingsBuilder().scanSettingsBuilder()
.scanAngleFirstView(spnScanAngleFirstView_.getDouble()));

cbxScanFromCurrentPosition_.registerListener(e ->
scsb.scanFromCurrentPosition(cbxScanFromCurrentPosition_.isSelected()));
model_.acquisitions().settingsBuilder().scanSettingsBuilder()
.scanFromCurrentPosition(cbxScanFromCurrentPosition_.isSelected()));
cbxScanNegativeDirection_.registerListener(e ->
scsb.scanFromNegativeDirection(cbxScanNegativeDirection_.isSelected()));
model_.acquisitions().settingsBuilder().scanSettingsBuilder()
.scanFromNegativeDirection(cbxScanNegativeDirection_.isSelected()));
cbxReturnToOriginalPosition_.registerListener(e ->
scsb.scanReturnToOriginalPosition(cbxReturnToOriginalPosition_.isSelected()));
model_.acquisitions().settingsBuilder().scanSettingsBuilder()
.scanReturnToOriginalPosition(cbxReturnToOriginalPosition_.isSelected()));

// TODO: better method, change scanner methods to double?
final ASIScanner scanner = model_.devices().getDevice("IllumSlice");
Expand Down

0 comments on commit 7b7d945

Please sign in to comment.