add new states by the doc interface

This commit is contained in:
Alexey Fedoseev
2024-04-22 21:50:47 +03:00
parent d5ba4ae523
commit 05f4a074fb
2 changed files with 21 additions and 3 deletions

View File

@@ -1188,6 +1188,20 @@ StateMachine* Document::new_state_machine(const ID& _id, const String& sm_name,
return sm;
}
State* Document::new_state(ElementCollection* _parent, const String& state_name, const Rect& r, const Color& _color)
{
State* state = new State(_parent, generate_vertex_id(_parent), state_name, r, _color);
_parent->add_element(state);
return state;
}
State* Document::new_state(ElementCollection* _parent, const ID& state_id, const String& state_name, const Rect& r, const Color& _color)
{
State* state = new State(_parent, state_id, state_name, r, _color);
_parent->add_element(state);
return state;
}
void Document::check_cyberiada_error(int res, const String& msg) const
{
switch (res) {

View File

@@ -537,9 +537,13 @@ namespace Cyberiada {
Document();
void reset();
StateMachine* new_state_machine(const String& sm_nam, 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());
State* new_state(ElementCollection* parent, const String& state_name,
const Rect& r = Rect(), const Color& color = Color());
State* new_state(ElementCollection* parent, const ID& id, const String& state_name,
const Rect& r = Rect(), const Color& color = Color());
void load(const String& path, DocumentFormat f = formatDetect);
void save(const String& path, DocumentFormat f = formatCyberiada10) const;
@@ -557,7 +561,7 @@ namespace Cyberiada {
void check_cyberiada_error(int res, const String& msg = "") const;
void update_metainfo_element();
ID generate_sm_id() const;
ID generate_vertex_id(const Element* element) const;
ID generate_vertex_id(const Element* parent) const;
ID generate_transition_id(const String& source_id, const String& target_id) const;
void import_nodes_recursively(ElementCollection* collection, CyberiadaNode* nodes);
void import_edges(ElementCollection* collection, CyberiadaEdge* edges);