From d4984ebf532e86ad0becf9423af38b9939bc1d8c Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 8 Jun 2021 12:16:02 +0100 Subject: [PATCH] dev: Enable CircuitLayout labels to be hidden --- src/dev/graph/layout.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/dev/graph/layout.rs b/src/dev/graph/layout.rs index b29ccc5d..507ab743 100644 --- a/src/dev/graph/layout.rs +++ b/src/dev/graph/layout.rs @@ -35,11 +35,20 @@ use crate::plonk::{ /// ``` #[derive(Debug, Default)] pub struct CircuitLayout { + hide_labels: bool, view_width: Option>, view_height: Option>, } impl CircuitLayout { + /// Sets the visibility of region labels. + /// + /// The default is to show labels. + pub fn show_labels(mut self, show: bool) -> Self { + self.hide_labels = !show; + self + } + /// Sets the view width for this layout, as a number of columns. pub fn view_width(mut self, width: Range) -> Self { self.view_width = Some(width); @@ -61,6 +70,8 @@ impl CircuitLayout { use plotters::coord::types::RangedCoordusize; use plotters::prelude::*; + let show_labels = !self.hide_labels; + // Collect the layout details. let mut cs = ConstraintSystem::default(); let config = ConcreteCircuit::configure(&mut cs); @@ -117,10 +128,13 @@ impl CircuitLayout { ShapeStyle::from(&GREEN.mix(0.2)).filled(), ))?; root.draw(&Rectangle::new([top_left, bottom_right], &BLACK))?; - root.draw( - &(EmptyElement::at(top_left) - + Text::new(label, (10, 10), ("sans-serif", 15.0).into_font())), - ) + if show_labels { + root.draw( + &(EmptyElement::at(top_left) + + Text::new(label, (10, 10), ("sans-serif", 15.0).into_font())), + )?; + } + Ok(()) }; let draw_cell = |root: &DrawingArea<_, _>, column, row| {