Skip to content

Commit 96c9bed

Browse files
andyclaude
andcommitted
Spectrum panel: a short dock shows 'Not enough room for the spectrum' with an Open in window button instead of a squashed plot; tighter control labels (#214)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y1pWhDKvhakdnjg3taYGxM
1 parent 11c6b52 commit 96c9bed

2 files changed

Lines changed: 34 additions & 8 deletions

File tree

‎src/apps/builder/NModePanel.C‎

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ void NModePanel::createSpectrumPane()
369369
const int gap = 6;
370370

371371
row->Add(new wxStaticText(pane, wxID_ANY,
372-
wxString::FromUTF8("Width (cm\xE2\x81\xBB\xC2\xB9):")),
372+
wxString::FromUTF8("Width:")),
373373
0, wxALIGN_CENTER_VERTICAL | wxLEFT, gap);
374374
p_fwhmText = new wxTextCtrl(pane, wxID_ANY,
375375
wxString::Format("%g", fwhm), wxDefaultPosition,
376-
wxSize(56, -1), wxTE_PROCESS_ENTER);
376+
wxSize(48, -1), wxTE_PROCESS_ENTER);
377377
p_fwhmText->SetToolTip(wxString::FromUTF8(
378378
"Full width at half maximum of each band, in cm\xE2\x81\xBB\xC2\xB9 "
379379
"(0 to 200).\nCondensed-phase bands are typically 5 to 30 wide.\n"
@@ -382,26 +382,26 @@ void NModePanel::createSpectrumPane()
382382
"gas-phase spectrum."));
383383
row->Add(p_fwhmText, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 3);
384384

385-
row->Add(new wxStaticText(pane, wxID_ANY, "Frequency scale:"),
385+
row->Add(new wxStaticText(pane, wxID_ANY, "Freq. scale:"),
386386
0, wxALIGN_CENTER_VERTICAL | wxLEFT, gap * 2);
387387
p_scaleText = new wxTextCtrl(pane, wxID_ANY,
388388
wxString::Format("%g", scale), wxDefaultPosition,
389-
wxSize(56, -1), wxTE_PROCESS_ENTER);
389+
wxSize(48, -1), wxTE_PROCESS_ENTER);
390390
p_scaleText->SetToolTip(wxString::FromUTF8(
391391
"Multiplies every frequency. Harmonic frequencies from most "
392392
"methods are 3 to 5 % too high; a typical factor is 0.96."));
393393
row->Add(p_scaleText, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 3);
394394

395395
wxCheckBox *left = new wxCheckBox(pane, wxID_ANY,
396-
"High wavenumber left");
396+
"High on left");
397397
left->SetValue(reversed);
398398
row->Add(left, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, gap * 2);
399399

400400
wxCheckBox *stk = new wxCheckBox(pane, wxID_ANY, "Sticks");
401401
stk->SetValue(sticks);
402402
row->Add(stk, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, gap * 2);
403403

404-
wxButton *reset = new wxButton(pane, wxID_ANY, "Reset zoom");
404+
wxButton *reset = new wxButton(pane, wxID_ANY, "Reset");
405405
reset->SetToolTip("Show the whole spectrum (or double-click the plot, "
406406
"or press Home).\nClick a peak to show its mode. Drag "
407407
"to zoom to a band, mouse wheel to zoom, right-drag "
@@ -413,6 +413,30 @@ void NModePanel::createSpectrumPane()
413413
row->Add(popout, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, gap);
414414
col->Add(row, 0, wxEXPAND | wxTOP | wxBOTTOM, 3);
415415

416+
// The dock can give this panel less height than a plot is readable
417+
// in; then this stands in for the whole plot rather than a squashed one.
418+
wxBoxSizer *noRoom = new wxBoxSizer(wxHORIZONTAL);
419+
noRoom->AddStretchSpacer(1);
420+
noRoom->Add(new wxStaticText(pane, wxID_ANY,
421+
"Not enough room for the spectrum"),
422+
0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 8);
423+
wxButton *noRoomButton = new wxButton(pane, wxID_ANY, "Open in window");
424+
noRoom->Add(noRoomButton, 0, wxALIGN_CENTER_VERTICAL);
425+
noRoom->AddStretchSpacer(1);
426+
col->Add(noRoom, 1, wxEXPAND);
427+
col->Show(noRoom, false);
428+
noRoomButton->Bind(wxEVT_BUTTON,
429+
[this](wxCommandEvent&) { openSpectrumWindow(); });
430+
pane->Bind(wxEVT_SIZE, [pane, col, row, noRoom, this](wxSizeEvent& e) {
431+
const bool tight = e.GetSize().y < 190;
432+
if (col->IsShown(noRoom) != tight) {
433+
col->Show(p_spectrum, !tight);
434+
col->Show(row, !tight);
435+
col->Show(noRoom, tight);
436+
}
437+
e.Skip();
438+
});
439+
416440
pane->SetSizer(col);
417441
p_gridPlotSizer->Add(pane, 1, wxGROW);
418442

‎tests/spectrum/capture.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def run(case, builder, png, timeout, window=False):
155155
if window:
156156
env["ECCE_SPECTRUM_WINDOW"] = "1"
157157
if png:
158-
env["ECCE_EXIT_AFTER_DUMP_DELAY_MS"] = "8000"
158+
env["ECCE_EXIT_AFTER_DUMP_DELAY_MS"] = "14000"
159159
auth = os.path.join(state, "auth.pipe")
160160
fixture.authFile(auth, port=int(settings["ECCE_DATASERVER_PORT"]))
161161
proc = subprocess.Popen(
@@ -169,7 +169,7 @@ def run(case, builder, png, timeout, window=False):
169169
if os.path.exists(out) and os.path.getsize(out) > 0:
170170
# The binary that ran must be the one under test.
171171
if png and not shot:
172-
time.sleep(3)
172+
time.sleep(float(os.environ.get("SPECTRUM_SHOT_WAIT", "3")))
173173
subprocess.run(["import", "-display", display.name,
174174
"-window", "root", png], env=env,
175175
check=False)
@@ -199,6 +199,8 @@ def run(case, builder, png, timeout, window=False):
199199
if "[PANESIZE]" in line and "Vibrational" in line:
200200
print(" " + line)
201201
tail = full[-3000:]
202+
if os.environ.get("SPECTRUM_VERBOSE"):
203+
print(full[-2500:])
202204
apps.stopServices(display)
203205
restorePrefs()
204206

0 commit comments

Comments
 (0)