From 0679cbc3b8ad8eb7179ae705ccc2250efacbc99b Mon Sep 17 00:00:00 2001 From: ccremers Date: Thu, 25 May 2006 20:35:01 +0000 Subject: [PATCH] - Added '--monochrome' switch, to be used in thesis output. There is a hardcoded lightness factor in dotout.c (MONOCHROMEFACTOR) --- src/dotout.c | 26 +++++++++++++++++++++++++- src/switches.c | 17 ++++++++++++++++- src/switches.h | 3 ++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/dotout.c b/src/dotout.c index 8879b02..28dfc32 100644 --- a/src/dotout.c +++ b/src/dotout.c @@ -34,6 +34,7 @@ extern Role I_RRSD; #define RUNCOLORDELTA 0.2 // maximum hue delta between roles (0.2): smaller means role colors of a protocol become more similar. #define RUNCOLORCONTRACT 0.8 // contract from protocol edges: smaller means more distinction between protocols. #define UNTRUSTEDCOLORS 0.4 +#define MONOCHROMEFACTOR 0.7 // Monochrome settings. 0.0: all colors become white. 1.0: all colors remain the same lightness as the color versions. /* * Dot output @@ -270,7 +271,7 @@ hlsValue (double n1, double n2, double hue) //! hls to rgb conversion void -hlsrgb (int *r, int *g, int *b, double h, double l, double s) +hlsrgbreal (int *r, int *g, int *b, double h, double l, double s) { double m1, m2; @@ -305,6 +306,29 @@ hlsrgb (int *r, int *g, int *b, double h, double l, double s) } } +//! hls to rgb conversion +/** + * Secretly takes the monochrome switch into account + */ +void +hlsrgb (int *r, int *g, int *b, double h, double l, double s) +{ + if (switches.monochrome) + { + // No colors: make lighter + s = 0; + h = 0; + l = 1 - ((1 - l) * MONOCHROMEFACTOR); + hlsrgbreal (r, g, b, h, l, s); + } + else + { + // colors + hlsrgbreal (r, g, b, h, l, s); + } +} + + //! print color from h,l,s triplet void printColor (double h, double l, double s) diff --git a/src/switches.c b/src/switches.c index 19c30e9..f2c20c1 100644 --- a/src/switches.c +++ b/src/switches.c @@ -76,7 +76,8 @@ switchesInit (int argc, char **argv) switches.countStates = false; // default off switches.extendNonReads = 0; // default off switches.extendTrivial = 0; // default off - switches.plain = false; // default colors + switches.plain = false; // default colors for terminal + switches.monochrome = false; // default colors for dot // Process the environment variable SCYTHERFLAGS process_environment (); @@ -892,6 +893,20 @@ switcher (const int process, int index, int commandline) } } + if (detect (' ', "monochrome", 0)) + { + if (!process) + { + /* discourage: hide + */ + } + else + { + switches.monochrome = true; + return index; + } + } + if (detect (' ', "intruder-actions", 1)) { if (!process) diff --git a/src/switches.h b/src/switches.h index 8d0738f..cf670d8 100644 --- a/src/switches.h +++ b/src/switches.h @@ -56,7 +56,8 @@ struct switchdata int countStates; //!< Count states int extendNonReads; //!< Show further events in arachne xml output. int extendTrivial; //!< Show further events in arachne xml output, based on knowledge underapproximation. (Includes at least the events of the nonreads extension) - int plain; //!< Disable color output + int plain; //!< Disable color output on terminal + int monochrome; //!< Disable colors in dot output }; extern struct switchdata switches; //!< pointer to switchdata structure