Horizon
core_symbol.hpp
1 #pragma once
2 #include "core.hpp"
3 #include "pool/symbol.hpp"
4 #include <deque>
5 #include <iostream>
6 #include <memory>
7 #include "document/idocument_symbol.hpp"
8 
9 namespace horizon {
10 class CoreSymbol : public Core, public IDocumentSymbol {
11 public:
12  CoreSymbol(const std::string &filename, IPool &pool);
13  bool has_object_type(ObjectType ty) const override;
14  Symbol &get_symbol() override;
15 
16  Junction *get_junction(const UUID &uu) override;
17  Line *get_line(const UUID &uu) override;
18  SymbolPin &get_symbol_pin(const UUID &uu) override;
19  Arc *get_arc(const UUID &uu) override;
20 
21  Junction *insert_junction(const UUID &uu) override;
22  void delete_junction(const UUID &uu) override;
23  Line *insert_line(const UUID &uu) override;
24  void delete_line(const UUID &uu) override;
25  Arc *insert_arc(const UUID &uu) override;
26  void delete_arc(const UUID &uu) override;
27 
28  SymbolPin &insert_symbol_pin(const UUID &uu) override;
29  void delete_symbol_pin(const UUID &uu) override;
30 
31  class LayerProvider &get_layer_provider() override;
32 
33  std::vector<Line *> get_lines() override;
34  std::vector<Arc *> get_arcs() override;
35 
36  bool set_property(ObjectType type, const UUID &uu, ObjectProperty::ID property,
37  const class PropertyValue &value) override;
38  bool get_property(ObjectType type, const UUID &uu, ObjectProperty::ID property,
39  class PropertyValue &value) override;
40  bool get_property_meta(ObjectType type, const UUID &uu, ObjectProperty::ID property,
41  class PropertyMeta &meta) override;
42 
43  std::string get_display_name(ObjectType type, const UUID &uu) override;
44 
45  const Symbol &get_canvas_data();
46  std::pair<Coordi, Coordi> get_bbox() override;
47 
48  void reload_pool() override;
49 
50  void set_pin_display_mode(Symbol::PinDisplayMode mode);
51 
52  const std::string &get_filename() const override;
53 
54  ObjectType get_object_type() const override
55  {
56  return ObjectType::SYMBOL;
57  }
58 
59  class Rules *get_rules() override;
60 
61  const FileVersion &get_version() const override
62  {
63  return sym.version;
64  }
65 
66 
67 private:
68  std::map<UUID, Text> *get_text_map() override;
69  std::map<UUID, Polygon> *get_polygon_map() override;
70 
71  Symbol sym;
72  std::string m_filename;
73  Symbol::PinDisplayMode pin_display_mode = Symbol::PinDisplayMode::PRIMARY;
74 
75  SymbolRules rules;
76 
77  class HistoryItem : public Core::HistoryItem {
78  public:
79  HistoryItem(const Symbol &s, const std::string &cm) : Core::HistoryItem(cm), sym(s)
80  {
81  }
82  Symbol sym;
83  };
84  void rebuild_internal(bool from_undo, const std::string &comment) override;
85  void history_push(const std::string &comment) override;
86  void history_load(unsigned int i) override;
87  void save(const std::string &suffix) override;
88  void delete_autosave() override;
89 };
90 } // namespace horizon
Graphical arc.
Definition: arc.hpp:20
Definition: core_symbol.hpp:10
Definition: core.hpp:202
Where Tools and and documents meet.
Definition: core.hpp:42
Definition: file_version.hpp:9
Definition: idocument_symbol.hpp:5
Definition: ipool.hpp:14
A Junction is a point in 2D-Space.
Definition: junction.hpp:20
Definition: layer_provider.hpp:7
Graphical line.
Definition: line.hpp:19
Definition: core_properties.hpp:90
Definition: core_properties.hpp:7
Definition: rules.hpp:51
Definition: symbol.hpp:20
Definition: symbol_rules.hpp:10
Definition: symbol.hpp:72
PinDisplayMode
fills in information from the referenced unit
Definition: symbol.hpp:86
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16