Skip to content

Commit

Permalink
add thermal spoke customisation
Browse files Browse the repository at this point in the history
  • Loading branch information
carrotIndustries committed Feb 10, 2022
1 parent 7e880dc commit c1a568f
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 4 deletions.
1 change: 1 addition & 0 deletions scripts/app_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ versions:
8: add rule multi net matching
9: add rule multi component matching
10: add thermal rules
11: add thermal spoke customisation
schematic:
1: add custom values on symbols
2: add hierarchy
Expand Down
2 changes: 1 addition & 1 deletion src/board/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ BoardColors::BoardColors() : solder_mask({0, .5, 0}), silkscreen({1, 1, 1}), sub
{
}

static const unsigned int app_version = 10;
static const unsigned int app_version = 11;

unsigned int Board::get_app_version()
{
Expand Down
5 changes: 4 additions & 1 deletion src/board/plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ static const LutEnumStr<PlaneSettings::FillStyle> fill_style_lut = {

ThermalSettings::ThermalSettings(const json &j)
: thermal_gap_width(j.value("thermal_gap_width", 0.1_mm)),
thermal_spoke_width(j.value("thermal_spoke_width", 0.2_mm))
thermal_spoke_width(j.value("thermal_spoke_width", 0.2_mm)), n_spokes(j.value("n_spokes", 4)),
angle(j.value("angle", 0))
{
if (j.count("connect_style")) {
connect_style = connect_style_lut.lookup(j.at("connect_style"));
Expand All @@ -41,6 +42,8 @@ void ThermalSettings::serialize(json &j) const
j["connect_style"] = connect_style_lut.lookup_reverse(connect_style);
j["thermal_gap_width"] = thermal_gap_width;
j["thermal_spoke_width"] = thermal_spoke_width;
j["n_spokes"] = n_spokes;
j["angle"] = angle;
}

PlaneSettings::PlaneSettings(const json &j)
Expand Down
2 changes: 2 additions & 0 deletions src/board/plane.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class ThermalSettings {

uint64_t thermal_gap_width = 0.2_mm;
uint64_t thermal_spoke_width = 0.2_mm;
unsigned int n_spokes = 4;
int angle = 0;

void serialize(json &j) const;
};
Expand Down
4 changes: 2 additions & 2 deletions src/board/plane_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,13 +638,13 @@ ClipperLib::Paths Board::get_thermals(Plane *plane, const CanvasPads *cp) const
ClipperLib::Paths antipad;
{

for (int angle = 0; angle < 360; angle += 90) {
for (unsigned int i = 0; i < th.n_spokes; i++) {
ClipperLib::Clipper cl;
cl.AddPaths(pad_exp, ClipperLib::ptSubject, true);

ClipperLib::Path r1 = spoke;
Placement tr;
tr.set_angle_deg(angle);
tr.set_angle((65536 * i) / th.n_spokes + th.angle);
transform_path(r1, tr);
transform_path(r1, it.second.first);
cl.AddPath(r1, ClipperLib::ptClip, true);
Expand Down
26 changes: 26 additions & 0 deletions src/imp/rules/rule_editor_thermals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "pool/part.hpp"
#include "pool/ipool.hpp"
#include "widgets/layer_combo_box.hpp"
#include "widgets/spin_button_angle.hpp"

namespace horizon {

Expand Down Expand Up @@ -208,6 +209,31 @@ void RuleEditorThermals::populate()
widgets_thermal_only.insert(la);
widgets_thermal_only.insert(sp);
}
{
auto sp = Gtk::manage(new Gtk::SpinButton());
sp->set_increments(1, 1);
sp->set_range(1, 8);
sp->set_value(rule2->thermal_settings.n_spokes);
sp->signal_changed().connect([this, sp] {
rule2->thermal_settings.n_spokes = sp->get_value_as_int();
s_signal_updated.emit();
});
auto la = grid_attach_label_and_widget(grid, "Th. spokes", sp, top);
widgets_thermal_only.insert(la);
widgets_thermal_only.insert(sp);
}
{
auto sp = Gtk::manage(new SpinButtonAngle());
sp->set_increments(65536 / 8, 65536 / 8);
sp->set_value(rule2->thermal_settings.angle);
sp->signal_changed().connect([this, sp] {
rule2->thermal_settings.angle = sp->get_value_as_int();
s_signal_updated.emit();
});
auto la = grid_attach_label_and_widget(grid, "Th. spoke angle", sp, top);
widgets_thermal_only.insert(la);
widgets_thermal_only.insert(sp);
}
for (auto &it : widgets_thermal_only) {
it->set_no_show_all();
it->show();
Expand Down
29 changes: 29 additions & 0 deletions src/widgets/plane_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "util/gtk_util.hpp"
#include "spin_button_dim.hpp"
#include "widgets/help_button.hpp"
#include "widgets/spin_button_angle.hpp"
#include "help_texts.hpp"

namespace horizon {
Expand Down Expand Up @@ -146,6 +147,34 @@ PlaneEditor::PlaneEditor(PlaneSettings *sets, int *priority) : Gtk::Grid(), sett
widgets_thermal_only.insert(la);
widgets_thermal_only.insert(sp);
}
{
auto sp = Gtk::manage(new Gtk::SpinButton());
sp->set_increments(1, 1);
sp->set_range(1, 8);
sp->set_value(settings->thermal_settings.n_spokes);
sp->signal_changed().connect([this, sp] {
settings->thermal_settings.n_spokes = sp->get_value_as_int();
s_signal_changed.emit();
});
auto la = grid_attach_label_and_widget(this, "Th. spokes", sp, top);
widgets_from_rules_disable.insert(la);
widgets_from_rules_disable.insert(sp);
widgets_thermal_only.insert(la);
widgets_thermal_only.insert(sp);
}
{
auto sp = Gtk::manage(new SpinButtonAngle());
sp->set_value(settings->thermal_settings.angle);
sp->signal_changed().connect([this, sp] {
settings->thermal_settings.angle = sp->get_value_as_int();
s_signal_changed.emit();
});
auto la = grid_attach_label_and_widget(this, "Th. spoke angle", sp, top);
widgets_from_rules_disable.insert(la);
widgets_from_rules_disable.insert(sp);
widgets_thermal_only.insert(la);
widgets_thermal_only.insert(sp);
}
for (auto &it : widgets_thermal_only) {
it->set_no_show_all();
it->show();
Expand Down

0 comments on commit c1a568f

Please sign in to comment.