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