Skip to content
Merged
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
2 changes: 1 addition & 1 deletion data/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ $LCD_FG_COLOR: #272863bb;
0 0 0 1px #0006,
inset 0 1px 0 #fff4,
inset 0 -1px 0 #fff2,
0 12px 24px #545e5473;
0 12px 24px #aec3ae73;

color: $LCD_FG_COLOR;
padding-top: 8px;
Expand Down
1 change: 0 additions & 1 deletion data/ui/date_view.blp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2026 Subhadeep Jasu <subhadeep107@proton.me>
using Gtk 4.0;
using Adw 1;

template $PebblesDateView: $PebblesView {
selected_view: bind date_stack.visible-child-name;
Expand Down
105 changes: 58 additions & 47 deletions src/core/graphing_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def set_plot_params_and_plot(self, payload):
'yMax': payload.get_y_max(),
'xScaling': payload.get_x_scaling(),
'yScaling': payload.get_y_scaling(),
'darkMode': payload.get_dark_mode()
'darkMode': payload.get_dark_mode(),
'fidelity': payload.get_fidelity_mode()
}

self.start_plotting()
Expand Down Expand Up @@ -99,64 +100,74 @@ def start_plotting(self):
def _plot(self, path=''):
try:
with self.plot_lock:
steps = [6, 1]
fidelity_mode = self.plot_params['fidelity']
step_size = 1 if fidelity_mode or path != '' else 6
palette = Pebbles.get_palette(self.plot_params['darkMode'])
dpi = self.plot_params['dpi']
width = self.plot_params['width']
height = self.plot_params['height']
plt.tight_layout(pad=4 / dpi)

for step_size in steps:
if self.cancel_event.is_set():
return

fig, ax = self._setup_plot(width, height, dpi, step_size)
x_values = self._generate_plot_x_values(
self.plot_params['xScaling'],
width,
step_size
)

if self.plot_params['yScaling'] == 1:
x_values = x_values[x_values != 0]

t_values = np.linspace(
0, 2*np.pi, width // (step_size ** 2)
)
for pro in self.calculators:
pro['calc'].set_substitute_value('A',
self.plot_params['a'], zero_limit=True)
pro['calc'].set_substitute_value('B',
self.plot_params['b'], zero_limit=True)
pro['calc'].set_substitute_value('C',
self.plot_params['c'], zero_limit=True)
pro['calc'].set_substitute_value('M',
self.plot_params['m'], zero_limit=True)
if pro['eq'].get_radial_coord_mode():
self._plot_radial(ax, pro, palette, (t_values, step_size))
else:
self._plot_cartesian(
ax, pro, palette,
(
x_values,
step_size,
self.plot_params['xScaling'],
self.plot_params['yScaling']
)
if self.cancel_event.is_set():
return

fig, ax = self._setup_plot(width, height, dpi, step_size)
x_values = self._generate_plot_x_values(
self.plot_params['xScaling'],
width,
step_size
)

if self.plot_params['yScaling'] == 1:
x_values = x_values[x_values != 0]

t_values = np.linspace(
0, 2 * np.pi, width // (step_size ** 2)
)
for pro in self.calculators:
pro['calc'].set_substitute_value('A',
self.plot_params['a'], zero_limit=True)
pro['calc'].set_substitute_value('B',
self.plot_params['b'], zero_limit=True)
pro['calc'].set_substitute_value('C',
self.plot_params['c'], zero_limit=True)
pro['calc'].set_substitute_value('M',
self.plot_params['m'], zero_limit=True)
if pro['eq'].get_radial_coord_mode():
self._plot_radial(ax, pro, palette, (t_values, step_size))
else:
self._plot_cartesian(
ax, pro, palette,
(
x_values,
step_size,
self.plot_params['xScaling'],
self.plot_params['yScaling']
)
)

if step_size == 1:
if path == '':
if fidelity_mode:
self._draw_legend(ax)
self._configure_labels(ax)

if path != '':
Utils.fig_save_path = path
Utils.plot_to_image(plt, fig, (width, height), dpi, step_size)
pixbuf_f = Utils.plot_to_pixbuf(plt, fig, (width, height), dpi, step_size)
ax.set_xticklabels([])
ax.set_yticklabels([])
ax.get_legend().remove()
pixbuf_i = Utils.plot_to_pixbuf(plt, fig, (width, height), dpi, step_size)
if self.on_plot_ready:
self.on_plot_ready(pixbuf_i, pixbuf_f, True)
else:
pixbuf = Utils.plot_to_pixbuf(plt, fig, (width, height), dpi, step_size)

ax.set_xticklabels([])
ax.set_yticklabels([])
pixbuf_f = Utils.plot_to_pixbuf(plt, fig, (width, height), dpi, step_size)
if self.on_plot_ready:
self.on_plot_ready(pixbuf, True)
self.on_plot_ready(None, pixbuf_f, True)
else:
self._draw_legend(ax)
self._configure_labels(ax)
Utils.fig_save_path = path
Utils.plot_to_image(plt, fig, (width, height), dpi, step_size)

except RuntimeError:
pass
Expand Down
3 changes: 2 additions & 1 deletion src/models/GraphPayload.Model.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ namespace Pebbles {
public int height { get; set; }
public double dpi { get; set; }
public bool dark_mode { get; set; }
public bool fidelity_mode { get; set; }

public bool contains_equations () {
return equations != null;
return equations != null && equations.length > 0;
}
}
}
11 changes: 2 additions & 9 deletions src/shell/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -708,13 +708,6 @@ namespace Pebbles {
}

private void load_settings () {
// Check if the version is new
if (settings.version != Config.VERSION) {
settings.version = Config.VERSION;

// Show some kind of What's New dialog?
}

if (settings.load_last_session) {
switch (settings.global_angle_unit) {
case DEG:
Expand Down Expand Up @@ -893,8 +886,8 @@ namespace Pebbles {
statistics_view.plot (figure, valid);
}

protected void on_render_ready (Gdk.Pixbuf? figure, bool valid) {
graphing_view.render_graph (figure, valid);
protected void on_render_ready (Gdk.Pixbuf? figure_i, Gdk.Pixbuf? figure_f, bool valid) {
graphing_view.render_graph (figure_i, figure_f, valid);
}

protected void on_memory_change (string context, bool present) {
Expand Down
4 changes: 2 additions & 2 deletions src/shell/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ def _on_graph_export(self, _, path):
self.graph_calc.export(path)


def _graph_ready_cb(self, pixbuf, valid):
self.on_render_ready(pixbuf, valid)
def _graph_ready_cb(self, pixbuf_i, pixbuf_f, valid):
self.on_render_ready(pixbuf_i, pixbuf_f, valid)


def _memory_recall(self, _, context: str):
Expand Down
4 changes: 2 additions & 2 deletions src/shell/views/GraphingView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ namespace Pebbles {
var_m_adjustment = new Gtk.Adjustment (0, -double.MAX, double.MAX, 0.01, 0.1, 0);
}

public void render_graph (Gdk.Pixbuf? pixbuf, bool valid) {
viewport.show_graph (pixbuf, valid);
public void render_graph (Gdk.Pixbuf? pixbuf_i, Gdk.Pixbuf? pixbuf_f, bool valid) {
viewport.show_graph (pixbuf_i, pixbuf_f, valid);
}

public void send_shift_modifier (bool shifted) {
Expand Down
Loading
Loading