Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions pdnkit/LayerPanel.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "LayerPanel.h"

#include <QCheckBox>
#include <QDoubleSpinBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QVBoxLayout>
Expand Down Expand Up @@ -71,13 +72,26 @@ void LayerPanel::setLayers(const std::vector<Entry>& layers) {
name->setMinimumWidth(70);
h->addWidget(name);

// Thickness label -- pulled from the LayerPanel Entry. Empty if the
// (setup (stackup ...)) block did not supply a value for this layer.
if (L.thickness_um > 0.0) {
auto* t = new QLabel(QString::number(L.thickness_um, 'f', 1) + " um");
// Thickness spinbox -- pre-loaded from the parsed stackup. Editing
// it propagates a thickness_changed() so MainWindow can override
// board_->stackup.layers[i].thickness in memory. Persisting back
// to the .kicad_pcb file needs an S-expr emitter -- separate work.
auto* t = new QDoubleSpinBox();
t->setRange(0.0, 1000.0);
t->setDecimals(2);
t->setSingleStep(1.0);
t->setSuffix(" um");
t->setValue(L.thickness_um);
t->setMaximumWidth(110);
if (L.thickness_um <= 0.0) {
t->setStyleSheet("color: #888;");
h->addWidget(t);
t->setSpecialValueText("(unset)");
}
connect(t, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, [this, ord](double v) {
emit thickness_changed(ord, v * 1.0e-6);
});
h->addWidget(t);
h->addStretch();

rows_layout_->addWidget(row);
Expand Down
6 changes: 6 additions & 0 deletions pdnkit/LayerPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ class LayerPanel : public QWidget {
signals:
void visibility_changed(int ordinal, bool visible);

// Emitted when the user edits a layer's thickness spinbox. The
// value is in meters (the panel does the um -> m conversion).
// MainWindow listens and writes board_->stackup.layers[i].thickness
// so the next analysis uses the override.
void thickness_changed(int ordinal, double thickness_m);

private:
void clearRows();

Expand Down
16 changes: 16 additions & 0 deletions pdnkit/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) {
dock->setWidget(layers_scroll);
dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
addDockWidget(Qt::RightDockWidgetArea, dock);
connect(layer_panel_, &LayerPanel::thickness_changed,
this, [this](int ord, double thickness_m) {
if (!board_) return;
for (auto& L : board_->stackup.layers) {
if (L.ordinal == ord) {
L.thickness = thickness_m;
break;
}
}
statusBar()->showMessage(
QString("Layer %1 thickness updated to %2 um "
"(in-memory, next analysis will use it)")
.arg(ord)
.arg(thickness_m * 1.0e6, 0, 'f', 1),
6000);
});
connect(layer_panel_, &LayerPanel::visibility_changed,
canvas_, &PcbCanvas::setLayerVisibility);

Expand Down
Loading