Horizon
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
horizon::Core Class Referenceabstract

Where Tools and and documents meet. More...

#include <core.hpp>

Inheritance diagram for horizon::Core:
horizon::Document horizon::IDocument horizon::CoreBoard horizon::CoreDecal horizon::CoreFrame horizon::CorePackage horizon::CorePadstack horizon::CoreSchematic horizon::CoreSymbol

Classes

class  HistoryItem
 

Public Types

typedef sigc::signal< void, ToolID > type_signal_tool_changed
 
typedef sigc::signal< void > type_signal_rebuilt
 
typedef sigc::signal< void, bool > type_signal_needs_save
 
typedef sigc::signal< json, ToolID > type_signal_load_tool_settings
 
typedef sigc::signal< void, ToolID, jsontype_signal_save_tool_settings
 
typedef sigc::signal< void, ToolID > type_signal_tool_changed
 
typedef sigc::signal< void > type_signal_rebuilt
 
typedef sigc::signal< void, bool > type_signal_needs_save
 
typedef sigc::signal< json, ToolID > type_signal_load_tool_settings
 
typedef sigc::signal< void, ToolID, jsontype_signal_save_tool_settings
 

Public Member Functions

class Blockget_block () override
 
class Rulesget_rules () override
 
class IPoolget_pool () override
 
virtual ObjectType get_object_type () const =0
 
virtual void rebuild (bool from_undo=false)
 Expands the non-working document. More...
 
ToolResponse tool_begin (ToolID tool_id, const ToolArgs &args, class ImpInterface *imp, bool transient=false)
 
ToolResponse tool_update (const ToolArgs &args)
 
std::pair< bool, bool > tool_can_begin (ToolID tool_id, const std::set< SelectableRef > &selection)
 
void save ()
 
void autosave ()
 
virtual void delete_autosave ()=0
 
void undo ()
 
void redo ()
 
bool can_undo () const
 
bool can_redo () const
 
bool tool_is_active ()
 
virtual bool set_property (ObjectType type, const UUID &uu, ObjectProperty::ID property, const class PropertyValue &value)
 
virtual bool get_property (ObjectType type, const UUID &uu, ObjectProperty::ID property, class PropertyValue &value)
 
virtual bool get_property_meta (ObjectType type, const UUID &uu, ObjectProperty::ID property, class PropertyMeta &meta)
 
void set_property_begin ()
 
void set_property_commit ()
 
bool get_property_transaction () const
 
virtual json get_meta ()
 
virtual void update_rules ()
 
virtual std::pair< Coordi, Coordiget_bbox ()=0
 
std::set< SelectableRef > & get_tool_selection ()
 
std::set< InToolActionID > get_tool_actions () const
 
bool get_needs_save () const
 
void set_needs_save ()
 
virtual const std::string & get_filename () const =0
 
type_signal_tool_changed signal_tool_changed ()
 
type_signal_rebuilt signal_rebuilt ()
 
type_signal_rebuilt signal_save ()
 Gets emitted right before saving. More...
 
type_signal_rebuilt signal_modified ()
 
type_signal_rebuilt signal_can_undo_redo ()
 
type_signal_needs_save signal_needs_save ()
 
type_signal_load_tool_settings signal_load_tool_settings ()
 
type_signal_save_tool_settings signal_save_tool_settings ()
 
virtual void reload_pool ()
 
class Blockget_block () override
 
class Rulesget_rules () override
 
class IPoolget_pool () override
 
virtual ObjectType get_object_type () const =0
 
virtual void rebuild (bool from_undo=false)
 Expands the non-working document. More...
 
ToolResponse tool_begin (ToolID tool_id, const ToolArgs &args, class ImpInterface *imp, bool transient=false)
 
ToolResponse tool_update (const ToolArgs &args)
 
std::pair< bool, bool > tool_can_begin (ToolID tool_id, const std::set< SelectableRef > &selection)
 
void save ()
 
void autosave ()
 
virtual void delete_autosave ()=0
 
void undo ()
 
void redo ()
 
bool can_undo () const
 
bool can_redo () const
 
bool tool_is_active ()
 
virtual bool set_property (ObjectType type, const UUID &uu, ObjectProperty::ID property, const class PropertyValue &value)
 
virtual bool get_property (ObjectType type, const UUID &uu, ObjectProperty::ID property, class PropertyValue &value)
 
virtual bool get_property_meta (ObjectType type, const UUID &uu, ObjectProperty::ID property, class PropertyMeta &meta)
 
void set_property_begin ()
 
void set_property_commit ()
 
bool get_property_transaction () const
 
virtual json get_meta ()
 
virtual void update_rules ()
 
virtual std::pair< Coordi, Coordiget_bbox ()=0
 
std::set< SelectableRef > & get_tool_selection ()
 
std::set< InToolActionID > get_tool_actions () const
 
bool get_needs_save () const
 
void set_needs_save ()
 
virtual const std::string & get_filename () const =0
 
type_signal_tool_changed signal_tool_changed ()
 
type_signal_rebuilt signal_rebuilt ()
 
type_signal_rebuilt signal_save ()
 Gets emitted right before saving. More...
 
type_signal_rebuilt signal_modified ()
 
type_signal_rebuilt signal_can_undo_redo ()
 
type_signal_needs_save signal_needs_save ()
 
type_signal_load_tool_settings signal_load_tool_settings ()
 
type_signal_save_tool_settings signal_save_tool_settings ()
 
virtual void reload_pool ()
 
- Public Member Functions inherited from horizon::Document
class Junctioninsert_junction (const class UUID &uu) override
 
class Junctionget_junction (const UUID &uu) override
 
void delete_junction (const UUID &uu) override
 
class Lineinsert_line (const UUID &uu) override
 
class Lineget_line (const UUID &uu) override
 
void delete_line (const UUID &uu) override
 
class Arcinsert_arc (const UUID &uu) override
 
class Arcget_arc (const UUID &uu) override
 
void delete_arc (const UUID &uu) override
 
class Textinsert_text (const UUID &uu) override
 
class Textget_text (const UUID &uu) override
 
void delete_text (const UUID &uu) override
 
class Polygoninsert_polygon (const UUID &uu) override
 
class Polygonget_polygon (const UUID &uu) override
 
void delete_polygon (const UUID &uu) override
 
class Holeinsert_hole (const UUID &uu) override
 
class Holeget_hole (const UUID &uu) override
 
void delete_hole (const UUID &uu) override
 
class Dimensioninsert_dimension (const UUID &uu) override
 
class Dimensionget_dimension (const UUID &uu) override
 
void delete_dimension (const UUID &uu) override
 
class Keepoutinsert_keepout (const UUID &uu) override
 
class Keepoutget_keepout (const UUID &uu) override
 
void delete_keepout (const UUID &uu) override
 
class Pictureinsert_picture (const UUID &uu) override
 
class Pictureget_picture (const UUID &uu) override
 
void delete_picture (const UUID &uu) override
 
std::vector< Line * > get_lines () override
 
std::vector< Arc * > get_arcs () override
 
std::vector< Keepout * > get_keepouts () override
 
std::string get_display_name (ObjectType type, const UUID &uu) override
 
std::string get_display_name (ObjectType type, const UUID &uu, const UUID &sheet) override
 
class Junctioninsert_junction (const class UUID &uu) override
 
class Junctionget_junction (const UUID &uu) override
 
void delete_junction (const UUID &uu) override
 
class Lineinsert_line (const UUID &uu) override
 
class Lineget_line (const UUID &uu) override
 
void delete_line (const UUID &uu) override
 
class Arcinsert_arc (const UUID &uu) override
 
class Arcget_arc (const UUID &uu) override
 
void delete_arc (const UUID &uu) override
 
class Textinsert_text (const UUID &uu) override
 
class Textget_text (const UUID &uu) override
 
void delete_text (const UUID &uu) override
 
class Polygoninsert_polygon (const UUID &uu) override
 
class Polygonget_polygon (const UUID &uu) override
 
void delete_polygon (const UUID &uu) override
 
class Holeinsert_hole (const UUID &uu) override
 
class Holeget_hole (const UUID &uu) override
 
void delete_hole (const UUID &uu) override
 
class Dimensioninsert_dimension (const UUID &uu) override
 
class Dimensionget_dimension (const UUID &uu) override
 
void delete_dimension (const UUID &uu) override
 
class Keepoutinsert_keepout (const UUID &uu) override
 
class Keepoutget_keepout (const UUID &uu) override
 
void delete_keepout (const UUID &uu) override
 
class Pictureinsert_picture (const UUID &uu) override
 
class Pictureget_picture (const UUID &uu) override
 
void delete_picture (const UUID &uu) override
 
std::vector< Line * > get_lines () override
 
std::vector< Arc * > get_arcs () override
 
std::vector< Keepout * > get_keepouts () override
 
std::string get_display_name (ObjectType type, const UUID &uu) override
 
std::string get_display_name (ObjectType type, const UUID &uu, const UUID &sheet) override
 
- Public Member Functions inherited from horizon::IDocument
virtual bool has_object_type (ObjectType ty) const =0
 
virtual class LayerProviderget_layer_provider ()=0
 
virtual const class FileVersionget_version () const =0
 
virtual bool has_object_type (ObjectType ty) const =0
 
virtual class LayerProviderget_layer_provider ()=0
 
virtual const class FileVersionget_version () const =0
 

Protected Member Functions

 Core (class IPool &pool)
 
void set_needs_save (bool v)
 
virtual void history_push ()=0
 
virtual void history_load (unsigned int i)=0
 
void history_clear ()
 
void history_trim ()
 
void layers_to_meta (class PropertyMeta &meta)
 
void get_placement (const Placement &placement, class PropertyValue &value, ObjectProperty::ID property)
 
void set_placement (Placement &placement, const class PropertyValue &value, ObjectProperty::ID property)
 
virtual void save (const std::string &suffix)=0
 
json get_meta_from_file (const std::string &filename)
 
 Core (class IPool &pool)
 
void set_needs_save (bool v)
 
virtual void history_push ()=0
 
virtual void history_load (unsigned int i)=0
 
void history_clear ()
 
void history_trim ()
 
void layers_to_meta (class PropertyMeta &meta)
 
void get_placement (const Placement &placement, class PropertyValue &value, ObjectProperty::ID property)
 
void set_placement (Placement &placement, const class PropertyValue &value, ObjectProperty::ID property)
 
virtual void save (const std::string &suffix)=0
 
json get_meta_from_file (const std::string &filename)
 
- Protected Member Functions inherited from horizon::Document
virtual std::map< UUID, Junction > * get_junction_map ()
 
virtual std::map< UUID, Line > * get_line_map ()
 
virtual std::map< UUID, Arc > * get_arc_map ()
 
virtual std::map< UUID, Text > * get_text_map ()
 
virtual std::map< UUID, Polygon > * get_polygon_map ()
 
virtual std::map< UUID, Hole > * get_hole_map ()
 
virtual std::map< UUID, Dimension > * get_dimension_map ()
 
virtual std::map< UUID, Keepout > * get_keepout_map ()
 
virtual std::map< UUID, Picture > * get_picture_map ()
 
virtual std::map< UUID, Junction > * get_junction_map ()
 
virtual std::map< UUID, Line > * get_line_map ()
 
virtual std::map< UUID, Arc > * get_arc_map ()
 
virtual std::map< UUID, Text > * get_text_map ()
 
virtual std::map< UUID, Polygon > * get_polygon_map ()
 
virtual std::map< UUID, Hole > * get_hole_map ()
 
virtual std::map< UUID, Dimension > * get_dimension_map ()
 
virtual std::map< UUID, Keepout > * get_keepout_map ()
 
virtual std::map< UUID, Picture > * get_picture_map ()
 

Protected Attributes

class IPoolm_pool
 
std::unique_ptr< ToolBasetool = nullptr
 
type_signal_tool_changed s_signal_tool_changed
 
type_signal_rebuilt s_signal_rebuilt
 
type_signal_rebuilt s_signal_save
 
type_signal_rebuilt s_signal_modified
 
type_signal_rebuilt s_signal_can_undo_redo
 
type_signal_needs_save s_signal_needs_save
 
type_signal_load_tool_settings s_signal_load_tool_settings
 
type_signal_save_tool_settings s_signal_save_tool_settings
 
bool needs_save = false
 
std::deque< std::unique_ptr< HistoryItem > > history
 
int history_current = -1
 
bool property_transaction = false
 

Static Protected Attributes

static const std::string autosave_suffix = ".autosave"
 

Detailed Description

Where Tools and and documents meet.

The Core provides a unified interface for Tools to access the objects common to all documents (whatever is being edited). It also provides the property interface for the property editor.

A Core always stores to copies of the document, one of which is the working copy. Tools always operate on this one. Tools use Core::commit() to commit their changes by replacing the non-working document with the working document. Core::revert() does the opposite thing by replacing the working document with the non-working document, thereby discarding the changes made to the working copy. Usually, calling Core::commit() or Core::revert() is the last thing a Tool does before finishing.

After a Tool has finished its work by returning ToolResponse::end(), the Core will initiate a rebuild. For CoreSchematic, a rebuild will update the Schematic according to its Block.

The Core also handles undo/redo by storing a full copy for each step.

Member Function Documentation

◆ get_meta() [1/2]

json horizon::Core::get_meta ( )
virtual
Returns
the current document's meta information. Meta information contains grid spacing and layer setup.

Reimplemented in horizon::CorePackage, horizon::CoreBoard, horizon::CorePackage, and horizon::CoreBoard.

◆ get_meta() [2/2]

virtual json horizon::Core::get_meta ( )
virtual
Returns
the current document's meta information. Meta information contains grid spacing and layer setup.

Reimplemented in horizon::CorePackage, horizon::CoreBoard, horizon::CorePackage, and horizon::CoreBoard.

◆ rebuild() [1/2]

void horizon::Core::rebuild ( bool  from_undo = false)
virtual

◆ rebuild() [2/2]

virtual void horizon::Core::rebuild ( bool  from_undo = false)
virtual

◆ signal_save() [1/2]

type_signal_rebuilt horizon::Core::signal_save ( )
inline

Gets emitted right before saving.

Gives the Imp an opportunity to write additional information to the document.

◆ signal_save() [2/2]

type_signal_rebuilt horizon::Core::signal_save ( )
inline

Gets emitted right before saving.

Gives the Imp an opportunity to write additional information to the document.


The documentation for this class was generated from the following files: