pub use self::AlignType::*;
pub use self::ArrowheadType::*;
pub use self::AutoOption::*;
pub use self::BorderLocation2D::*;
pub use self::ContourStyle::*;
pub use self::DashType::*;
pub use self::FillRegionType::*;
pub use self::LabelOption::*;
pub use self::LegendOption::*;
pub use self::MarginSide::*;
pub use self::PaletteType::*;
pub use self::PlotOption::*;
pub use self::Tick::*;
pub use self::TickOption::*;
use crate::util::OneWayOwned;
#[derive(Copy, Clone)]
pub enum PlotOption<T>
{
PointSymbol(char),
PointSize(f64),
Caption(T),
LineWidth(f64),
Color(T),
BorderColor(T),
LineStyle(DashType),
FillAlpha(f64),
FillRegion(FillRegionType),
ArrowType(ArrowheadType),
ArrowSize(f64),
WhiskerBars(f64),
}
impl<'l> OneWayOwned for PlotOption<&'l str>
{
type Output = PlotOption<String>;
fn to_one_way_owned(&self) -> Self::Output
{
match *self
{
PointSymbol(v) => PointSymbol(v),
PointSize(v) => PointSize(v),
Caption(v) => Caption(v.into()),
LineWidth(v) => LineWidth(v),
Color(v) => Color(v.into()),
BorderColor(v) => BorderColor(v.into()),
LineStyle(v) => LineStyle(v),
FillAlpha(v) => FillAlpha(v),
FillRegion(v) => FillRegion(v),
ArrowType(v) => ArrowType(v),
ArrowSize(v) => ArrowSize(v),
WhiskerBars(v) => WhiskerBars(v),
}
}
}
#[derive(Copy, Clone)]
pub enum FillRegionType
{
Above,
Below,
Between,
}
#[derive(Copy, Clone, Debug)]
pub enum AlignType
{
AlignLeft,
AlignRight,
AlignCenter,
AlignTop,
AlignBottom,
}
#[derive(Copy, Clone, Debug)]
pub enum DashType
{
Solid,
SmallDot,
Dot,
Dash,
DotDash,
DotDotDash,
}
impl DashType
{
pub fn to_int(&self) -> i32
{
match *self
{
Solid => 1,
SmallDot => 0,
Dash => 2,
Dot => 3,
DotDash => 4,
DotDotDash => 5,
}
}
}
#[derive(Copy, Clone)]
pub enum ArrowheadType
{
Open,
Closed,
Filled,
NoArrow,
}
#[derive(Copy, Clone)]
pub enum AutoOption<T>
{
Fix(T),
Auto,
}
impl<T> AutoOption<T>
{
pub fn map<U, F: FnOnce(T) -> U>(self, f: F) -> AutoOption<U>
{
match self
{
Fix(v) => Fix(f(v)),
Auto => Auto,
}
}
}
impl<'l> OneWayOwned for AutoOption<&'l str>
{
type Output = AutoOption<String>;
fn to_one_way_owned(&self) -> Self::Output
{
match *self
{
Fix(v) => Fix(v.into()),
Auto => Auto,
}
}
}
#[derive(Copy, Clone)]
pub enum LabelOption<T>
{
TextOffset(f64, f64),
Font(T, f64),
TextColor(T),
Rotate(f64),
TextAlign(AlignType),
MarkerSymbol(char),
MarkerColor(T),
MarkerSize(f64),
}
impl<'l> OneWayOwned for LabelOption<&'l str>
{
type Output = LabelOption<String>;
fn to_one_way_owned(&self) -> Self::Output
{
match *self
{
TextOffset(v1, v2) => TextOffset(v1, v2),
Font(v1, v2) => Font(v1.into(), v2),
TextColor(v) => TextColor(v.into()),
Rotate(v) => Rotate(v),
TextAlign(v) => TextAlign(v),
MarkerSymbol(v) => MarkerSymbol(v),
MarkerColor(v) => MarkerColor(v.into()),
MarkerSize(v) => MarkerSize(v),
}
}
}
#[derive(Copy, Clone)]
pub enum TickOption<T>
{
OnAxis(bool),
Mirror(bool),
Inward(bool),
MinorScale(f64),
MajorScale(f64),
Format(T),
}
impl<'l> OneWayOwned for TickOption<&'l str>
{
type Output = TickOption<String>;
fn to_one_way_owned(&self) -> Self::Output
{
match *self
{
OnAxis(v) => OnAxis(v),
Mirror(v) => Mirror(v),
Inward(v) => Inward(v),
MinorScale(v) => MinorScale(v),
MajorScale(v) => MajorScale(v),
Format(v) => Format(v.into()),
}
}
}
pub enum Tick<T>
{
Major(T, AutoOption<String>),
Minor(T),
}
#[derive(Copy, Clone)]
pub enum BorderLocation2D
{
Bottom = 1,
Left = 2,
Top = 4,
Right = 8,
}
#[derive(Copy, Clone)]
pub enum MarginSide
{
MarginTop(f32),
MarginBottom(f32),
MarginLeft(f32),
MarginRight(f32),
}
#[derive(Copy, Clone)]
pub enum LegendOption<T>
{
Reverse,
Invert,
Horizontal,
Placement(AlignType, AlignType),
Title(T),
MaxRows(u32),
MaxCols(u32),
}
impl<'l> OneWayOwned for LegendOption<&'l str>
{
type Output = LegendOption<String>;
fn to_one_way_owned(&self) -> Self::Output
{
match *self
{
Reverse => Reverse,
Invert => Invert,
Horizontal => Horizontal,
Placement(v1, v2) => Placement(v1, v2),
Title(v) => Title(v.into()),
MaxRows(v) => MaxRows(v),
MaxCols(v) => MaxCols(v),
}
}
}
#[derive(Copy, Clone)]
pub enum ContourStyle
{
Linear,
Cubic(u32),
Spline(u32, u32),
}
#[derive(Copy, Clone)]
pub enum PaletteType
{
Gray(f32),
Formula(i32, i32, i32),
CubeHelix(f32, f32, f32, f32),
}
pub const GRAY: PaletteType = Gray(1.0);
pub const COLOR: PaletteType = Formula(3, 11, 16);
pub const RAINBOW: PaletteType = Formula(33, 13, 10);
pub const HOT: PaletteType = Formula(34, 35, 36);
pub const HELIX: PaletteType = CubeHelix(0.5, -0.8, 2.0, 1.0);
#[derive(Copy, Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
pub struct GnuplotVersion
{
pub major: i32,
pub minor: i32,
}