correct the graphml export of comment subjects

This commit is contained in:
Alexey Fedoseev
2024-04-25 10:06:20 +03:00
parent 76e79a0bc0
commit 1a593a5954
2 changed files with 22 additions and 6 deletions

View File

@@ -347,7 +347,7 @@ std::ostream& CommentSubject::dump(std::ostream& os) const
CYB_ASSERT(type == commentSubjectData); CYB_ASSERT(type == commentSubjectData);
type_str = "data"; type_str = "data";
} }
os << "{ id: '" << id << "'"; os << "{id: '" << id << "'";
os << ", type: " << type_str; os << ", type: " << type_str;
if (element) { if (element) {
os << ", to: '" << element->get_id() << "'"; os << ", to: '" << element->get_id() << "'";
@@ -468,6 +468,14 @@ CyberiadaEdge* Comment::subjects_to_edges() const
edge->geometry_polyline = c_polyline(i->get_geometry_polyline()); edge->geometry_polyline = c_polyline(i->get_geometry_polyline());
} }
} }
if (result) {
CyberiadaEdge* e = result;
while (e->next) e = e->next;
e->next = edge;
} else {
result = edge;
}
} }
} }
return result; return result;
@@ -481,7 +489,7 @@ std::ostream& Comment::dump(std::ostream& os) const
os << ", geometry: " << geometry_rect; os << ", geometry: " << geometry_rect;
} }
if (has_subjects()) { if (has_subjects()) {
os << "subjects: {"; os << ", subjects: {";
for (std::list<CommentSubject>::const_iterator i = subjects.begin(); i != subjects.end(); i++) { for (std::list<CommentSubject>::const_iterator i = subjects.begin(); i != subjects.end(); i++) {
os << *i; os << *i;
if(std::next(i) != subjects.end()) { if(std::next(i) != subjects.end()) {
@@ -1223,23 +1231,31 @@ StateMachine* Document::new_state_machine(const ID& _id, const String& sm_name,
return sm; return sm;
} }
State* Document::new_state(ElementCollection* _parent, const String& state_name, const Rect& r, const Color& _color) State* Document::new_state(ElementCollection* _parent, const String& state_name, const Action& a,
const Rect& r, const Color& _color)
{ {
check_parent_element(_parent); check_parent_element(_parent);
check_nonempty_string(state_name); check_nonempty_string(state_name);
State* state = new State(_parent, generate_vertex_id(_parent), state_name, r, _color); State* state = new State(_parent, generate_vertex_id(_parent), state_name, r, _color);
if (!a.is_empty_transition()) {
state->add_action(a);
}
_parent->add_element(state); _parent->add_element(state);
return state; return state;
} }
State* Document::new_state(ElementCollection* _parent, const ID& state_id, const String& state_name, const Rect& r, const Color& _color) State* Document::new_state(ElementCollection* _parent, const ID& state_id, const String& state_name, const Action& a,
const Rect& r, const Color& _color)
{ {
check_parent_element(_parent); check_parent_element(_parent);
check_nonempty_string(state_name); check_nonempty_string(state_name);
check_id_uniqueness(state_id); check_id_uniqueness(state_id);
State* state = new State(_parent, state_id, state_name, r, _color); State* state = new State(_parent, state_id, state_name, r, _color);
if (!a.is_empty_transition()) {
state->add_action(a);
}
_parent->add_element(state); _parent->add_element(state);
return state; return state;
} }

View File

@@ -546,9 +546,9 @@ namespace Cyberiada {
StateMachine* new_state_machine(const String& sm_name, const Rect& r = Rect()); StateMachine* new_state_machine(const String& sm_name, const Rect& r = Rect());
StateMachine* new_state_machine(const ID& id, const String& sm_name, const Rect& r = Rect()); StateMachine* new_state_machine(const ID& id, const String& sm_name, const Rect& r = Rect());
State* new_state(ElementCollection* parent, const String& state_name, State* new_state(ElementCollection* parent, const String& state_name,
const Rect& r = Rect(), const Color& color = Color()); const Action& a = Action(), const Rect& r = Rect(), const Color& color = Color());
State* new_state(ElementCollection* parent, const ID& id, const String& state_name, State* new_state(ElementCollection* parent, const ID& id, const String& state_name,
const Rect& r = Rect(), const Color& color = Color()); const Action& a = Action(), const Rect& r = Rect(), const Color& color = Color());
InitialPseudostate* new_initial(ElementCollection* parent, const Point& p = Point()); InitialPseudostate* new_initial(ElementCollection* parent, const Point& p = Point());
InitialPseudostate* new_initial(ElementCollection* parent, const Name& name, const Point& p = Point()); InitialPseudostate* new_initial(ElementCollection* parent, const Name& name, const Point& p = Point());
InitialPseudostate* new_initial(ElementCollection* parent, const ID& id, const Name& name, const Point& p = Point()); InitialPseudostate* new_initial(ElementCollection* parent, const ID& id, const Name& name, const Point& p = Point());