cqlib_core/visualization/state/options.rs
1// This code is part of Cqlib.
2//
3// (C) Copyright China Telecom Quantum Group 2026
4//
5// This code is licensed under the Apache License, Version 2.0. You may
6// obtain a copy of this license in the LICENSE.txt file in the root directory
7// of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8//
9// Any modifications or derivative works of this code must retain this
10// copyright notice, and modified files need to carry a notice indicating
11// that they have been altered from the originals.
12
13//! Public options for quantum-state visualization.
14//!
15//! State plotting APIs accept core QIS state types directly, such as
16//! [`crate::qis::Statevector`] and [`crate::qis::DensityMatrix`].
17
18/// Options shared by state-visualization backends.
19///
20/// Use [`StatePlotOptions::default`] for library defaults, then override only the fields
21/// needed for a specific plot family.
22///
23/// # Examples
24///
25/// ```rust
26/// use cqlib_core::visualization::StatePlotOptions;
27///
28/// let options = StatePlotOptions {
29/// title: Some("State city".to_string()),
30/// reverse_bits: true,
31/// ..StatePlotOptions::default()
32/// };
33/// assert!(options.reverse_bits);
34/// ```
35#[derive(Debug, Clone)]
36pub struct StatePlotOptions {
37 /// Optional chart title.
38 pub title: Option<String>,
39 /// Optional colors used by selected plot families.
40 pub color: Vec<String>,
41 /// Fill opacity for state-city bars.
42 pub alpha: f64,
43 /// Whether to reverse displayed computational-basis bit order.
44 pub reverse_bits: bool,
45 /// Optional figure size in inches-like units, scaled to SVG pixels.
46 pub figsize: Option<(f64, f64)>,
47}
48
49impl Default for StatePlotOptions {
50 fn default() -> Self {
51 Self {
52 title: None,
53 color: Vec::new(),
54 alpha: 1.0,
55 reverse_bits: false,
56 figsize: None,
57 }
58 }
59}