42#ifndef CA_X11_VIEWER_H
43#define CA_X11_VIEWER_H
58#if !defined(ALEPH_DISABLE_X11_VIEWER) && defined(__has_include)
59# if __has_include(<X11/Xlib.h>)
61# define ALEPH_CA_HAVE_X11 1
81 std::string
title =
"Aleph::CA";
90template <
typename Mapper>
97#if defined(ALEPH_CA_HAVE_X11)
129 if (std::getenv(
"DISPLAY") ==
nullptr)
132 <<
"X11_Frame_Sink: DISPLAY is not set";
140 <<
"X11_Frame_Sink: cannot open X display";
167 return (
static_cast<unsigned long>(c.r) << 16)
168 | (
static_cast<unsigned long>(c.g) << 8)
169 |
static_cast<unsigned long>(c.b);
175 <<
"X11_Frame_Sink: X11 headers are not available";
199#if defined(ALEPH_CA_HAVE_X11)
201 , window_(
other.window_)
208#if defined(ALEPH_CA_HAVE_X11)
209 other.display_ =
nullptr;
210 other.ready_ =
false;
212 other.disabled_ =
true;
218#if defined(ALEPH_CA_HAVE_X11)
228#if defined(ALEPH_CA_HAVE_X11)
240 template <
typename Lattice>
245 static_assert(
Lattice::rank == 2,
"X11_Frame_Sink requires rank-2 frames");
249#if defined(ALEPH_CA_HAVE_X11)
252 if (frame.
size(0) != rows_
or frame.
size(1) != cols_)
261 static_cast<ca_index_t>(c)}));
273 std::this_thread::sleep_for(std::chrono::milliseconds(
opts_.
delay_ms));
280#if defined(ALEPH_CA_HAVE_X11)
287template <
typename Mapper>
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error_if(C)
Throws std::runtime_error if condition holds.
File-format readers and writers for cellular-automata frames.
Lattice that adds boundary-aware access on top of a storage.
typename Storage::coord_type coord_type
static constexpr std::size_t rank
ca_size_t size() const noexcept
state_type at(const coord_type &c) const
Strict access: throws if c is out of range.
void accept(const std::size_t step, const Lattice &frame)
Draw one frame, or no-op when disabled/headless.
~X11_Frame_Sink()
Close the X11 window best-effort.
X11_Frame_Sink(Mapper mapper, X11_Viewer_Options opts={})
Build an X11 viewer sink.
X11_Frame_Sink & operator=(const X11_Frame_Sink &)=delete
void ensure_window(ca_size_t, ca_size_t)
void flush()
Flush pending X11 requests.
X11_Frame_Sink(X11_Frame_Sink &&other) noexcept
Move-construct a viewer, transferring the window handle.
bool active() const noexcept
Return whether the viewer is actively drawing.
X11_Frame_Sink(const X11_Frame_Sink &)=delete
Storage + topology that carries the cell values.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
std::size_t ca_size_t
Unsigned size component used for extents and counts.
Main namespace for Aleph-w library functions.
RGB byte triplet used by PPM exporters.
Options for the live X11 viewer.
bool enabled
disable to force no-op behaviour
unsigned delay_ms
sleep after each drawn frame
unsigned cell_size
pixels per CA cell
std::string title
window title
bool require_display
throw instead of no-op without X11
C++20 concepts for the Cellular Automata module.