Commit 87ef2822 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

print_dot: add xlabel to colored states if too many colors in use

Based on a report from Andreas Tollkötter.

* spot/twaalgos/dot.cc (highlight_states_show_num_): New option,
turned on implicitly when more than 8 colors are used.
* tests/core/highlightstate.test: Test it.
* NEWS: Mention it.
* THANKS: Add Andreas.
parent c5abf1b3
......@@ -6,6 +6,14 @@ New in spot 2.6.1.dev (not yet released)
code for the online translator. Its replacement has its own
repository: https://gitlab.lrde.epita.fr/spot/spot-web-app/
Library:
- When states are highlighted with more than 8 colors, print_dot()
will add some extra markers to help distinguishing the colors.
This helps with the fact that colors 8-15 are lighter versions of
colors 0-7, and that higher color numbers cycle into this 16-color
palette.
New in spot 2.6.1 (2018-08-04)
Command-line tools:
......
......@@ -2,6 +2,7 @@ We are grateful to these people for their comments, help, or
suggestions.
Akim Demaille
Andreas Tollkötter
Anton Pirogov
Ayrat Khalimov
Caroline Lemieux
......
......@@ -73,6 +73,7 @@ namespace spot
std::vector<std::string>* sn_ = nullptr;
std::map<unsigned, unsigned>* highlight_edges_ = nullptr;
std::map<unsigned, unsigned>* highlight_states_ = nullptr;
bool highlight_states_show_num_ = false;
std::vector<std::pair<unsigned, unsigned>>* sprod_ = nullptr;
std::vector<unsigned>* orig_ = nullptr;
std::set<unsigned>* incomplete_ = nullptr;
......@@ -552,6 +553,8 @@ namespace spot
}
if (!opt_vertical_)
os_ << " rankdir=LR\n";
if (highlight_states_show_num_)
os_ << " forcelabels=true\n";
if (name_ || opt_show_acc_)
{
os_ << " " << label_pre_;
......@@ -702,6 +705,8 @@ namespace spot
os_ << ",filled";
os_ << "\", color=\"" << palette[iter->second % palette_mod]
<< '"';
if (highlight_states_show_num_)
os_ << ", xlabel=\"[" << iter->second << "]\"";
}
}
if (!inline_state_names_ && (sn_ || sprod_ || opt_state_labels_)
......@@ -846,6 +851,17 @@ namespace spot
aut->get_named_prop<std::map<unsigned, unsigned>>("highlight-edges");
highlight_states_ =
aut->get_named_prop<std::map<unsigned, unsigned>>("highlight-states");
if (highlight_states_)
{
// If we use more than palette_mod/2 colors, we will use
// some extra markers to distinguish colors.
auto e = highlight_states_->end();
highlight_states_show_num_ =
std::find_if(highlight_states_->begin(), e,
[](auto p){
return p.second >= palette_mod / 2;
}) != e;
}
incomplete_ =
aut->get_named_prop<std::set<unsigned>>("incomplete-states");
graph_name_ = aut_->get_named_prop<std::string>("automaton-name");
......
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2016, 2017 Laboratoire de Recherche et Développement
# Copyright (C) 2016, 2017, 2018 Laboratoire de Recherche et Développement
# de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
......@@ -113,3 +113,81 @@ EOF
autfilt aut.hoa --highlight-languages -H1.1 | grep spot.highlight.states >res
diff expected res
cat >input.hoa <<EOF
HOA: v1
name: "Fb & GF((a & Xb) | (!a & X!b))"
States: 5
Start: 0
AP: 2 "b" "a"
acc-name: Rabin 1
Acceptance: 2 Fin(0) & Inf(1)
properties: trans-labels explicit-labels trans-acc complete
properties: deterministic
spot.highlight.states: 0 0 1 1 2 0 3 1 4 1
--BODY--
State: 0
[!0&!1] 0
[0] 1
[!0&1] 2
State: 1
[!1] 3
[1] 4
State: 2
[!0&!1] 0 {0}
[!0&1] 2 {0}
[0&!1] 3
[0&1] 4
State: 3
[!0] 1 {1}
[0&!1] 3
[0&1] 4
State: 4
[0] 1 {1}
[!0&!1] 3
[!0&1] 4
--END--
EOF
cat >input2.hoa <<EOF
HOA: v1
name: "Fb & GF((a & Xb) | (!a & X!b))"
States: 5
Start: 0
AP: 2 "b" "a"
acc-name: Rabin 1
Acceptance: 2 Fin(0) & Inf(1)
properties: trans-labels explicit-labels trans-acc complete
properties: deterministic
spot.highlight.states: 0 0 1 8 2 0 3 8 4 8 /* 8 instead of 1 */
--BODY--
State: 0
[!0&!1] 0
[0] 1
[!0&1] 2
State: 1
[!1] 3
[1] 4
State: 2
[!0&!1] 0 {0}
[!0&1] 2 {0}
[0&!1] 3
[0&1] 4
State: 3
[!0] 1 {1}
[0&!1] 3
[0&1] 4
State: 4
[0] 1 {1}
[!0&!1] 3
[!0&1] 4
--END--
EOF
autfilt --dot input.hoa > output.dot
grep xlabel output.dot && exit 1
grep forcelabels output.dot && exit 1
autfilt --dot input2.hoa > output2.dot
grep xlabel output2.dot
grep forcelabels output2.dot
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment