2 #include "canvas/selectables.hpp" 3 #include "canvas/target.hpp" 4 #include "common/layer.hpp" 5 #include "common/object_descr.hpp" 6 #include "common/keepout.hpp" 8 #include "tool_data.hpp" 9 #include "dialogs/dialogs.hpp" 10 #include "nlohmann/json_fwd.hpp" 11 #include "pool/pool.hpp" 12 #include "pool/symbol.hpp" 13 #include <gdk/gdkkeysyms.h> 16 #include <sigc++/sigc++.h> 17 #include "tool_id.hpp" 20 enum class ToolEventType { MOVE, CLICK, CLICK_RELEASE, KEY, LAYER_CHANGE, DATA };
31 std::set<SelectableRef> selection;
32 bool keep_selection =
false;
37 std::unique_ptr<ToolData> data =
nullptr;
48 ToolID next_tool = ToolID::NONE;
49 bool end_tool =
false;
51 bool fast_draw =
false;
98 virtual void load_from_json(
const json &j) = 0;
99 virtual json serialize()
const = 0;
137 void set_transient();
138 virtual ToolID get_tool_id_for_settings()
const 150 virtual void apply_settings()
199 ToolID tool_id = ToolID::NONE;
200 bool is_transient =
false;
232 class Core :
public sigc::trackable {
234 virtual bool has_object_type(ObjectType ty)
239 virtual class Junction *insert_junction(
const UUID &uu,
bool work =
true);
240 virtual class Junction *get_junction(
const UUID &uu,
bool work =
true);
241 virtual void delete_junction(
const UUID &uu,
bool work =
true);
243 virtual class Line *insert_line(
const UUID &uu,
bool work =
true);
244 virtual class Line *get_line(
const UUID &uu,
bool work =
true);
245 virtual void delete_line(
const UUID &uu,
bool work =
true);
247 virtual class Arc *insert_arc(
const UUID &uu,
bool work =
true);
248 virtual class Arc *get_arc(
const UUID &uu,
bool work =
true);
249 virtual void delete_arc(
const UUID &uu,
bool work =
true);
251 virtual class Text *insert_text(
const UUID &uu,
bool work =
true);
252 virtual class Text *get_text(
const UUID &uu,
bool work =
true);
253 virtual void delete_text(
const UUID &uu,
bool work =
true);
255 virtual class Polygon *insert_polygon(
const UUID &uu,
bool work =
true);
256 virtual class Polygon *get_polygon(
const UUID &uu,
bool work =
true);
257 virtual void delete_polygon(
const UUID &uu,
bool work =
true);
259 virtual class Hole *insert_hole(
const UUID &uu,
bool work =
true);
260 virtual class Hole *get_hole(
const UUID &uu,
bool work =
true);
261 virtual void delete_hole(
const UUID &uu,
bool work =
true);
265 virtual void delete_dimension(
const UUID &uu);
267 virtual class Keepout *insert_keepout(
const UUID &uu);
268 virtual class Keepout *get_keepout(
const UUID &uu);
269 virtual void delete_keepout(
const UUID &uu);
271 virtual std::vector<Line *> get_lines(
bool work =
true);
272 virtual std::vector<Arc *> get_arcs(
bool work =
true);
273 virtual std::vector<Keepout *> get_keepouts();
275 virtual class Block *get_block(
bool work =
true)
284 virtual void rebuild(
bool from_undo =
false);
287 std::pair<bool, bool> tool_can_begin(ToolID tool_id,
const std::set<SelectableRef> &selection);
288 bool tool_handles_esc();
289 virtual void commit() = 0;
290 virtual void revert() = 0;
291 virtual void save() = 0;
295 bool can_undo()
const;
296 bool can_redo()
const;
298 inline bool tool_is_active()
300 return tool !=
nullptr;
303 virtual bool set_property(ObjectType type,
const UUID &uu, ObjectProperty::ID property,
305 virtual bool get_property(ObjectType type,
const UUID &uu, ObjectProperty::ID property,
class PropertyValue &value);
306 virtual bool get_property_meta(ObjectType type,
const UUID &uu, ObjectProperty::ID property,
309 virtual std::string get_display_name(ObjectType type,
const UUID &uu);
311 void set_property_begin();
312 void set_property_commit();
313 bool get_property_transaction()
const;
324 virtual json get_meta();
326 virtual class Rules *get_rules()
330 virtual void update_rules()
334 virtual std::pair<Coordi, Coordi> get_bbox() = 0;
339 std::set<SelectableRef> selection;
342 bool get_needs_save()
const;
343 void set_needs_save();
345 typedef sigc::signal<void, ToolID> type_signal_tool_changed;
346 type_signal_tool_changed signal_tool_changed()
348 return s_signal_tool_changed;
350 typedef sigc::signal<void> type_signal_rebuilt;
351 type_signal_rebuilt signal_rebuilt()
353 return s_signal_rebuilt;
362 return s_signal_save;
365 type_signal_rebuilt signal_can_undo_redo()
367 return s_signal_can_undo_redo;
370 typedef sigc::signal<json> type_signal_request_save_meta;
377 return s_signal_request_save_meta;
380 typedef sigc::signal<void, bool> type_signal_needs_save;
381 type_signal_needs_save signal_needs_save()
383 return s_signal_needs_save;
386 typedef sigc::signal<json, ToolID> type_signal_load_tool_settings;
387 type_signal_load_tool_settings signal_load_tool_settings()
389 return s_signal_load_tool_settings;
392 typedef sigc::signal<void, ToolID, json> type_signal_save_tool_settings;
393 type_signal_save_tool_settings signal_save_tool_settings()
395 return s_signal_save_tool_settings;
398 virtual void reload_pool()
403 virtual std::map<UUID, Junction> *get_junction_map(
bool work =
true)
407 virtual std::map<UUID, Line> *get_line_map(
bool work =
true)
411 virtual std::map<UUID, Arc> *get_arc_map(
bool work =
true)
415 virtual std::map<UUID, Text> *get_text_map(
bool work =
true)
419 virtual std::map<UUID, Polygon> *get_polygon_map(
bool work =
true)
423 virtual std::map<UUID, Hole> *get_hole_map(
bool work =
true)
427 virtual std::map<UUID, Dimension> *get_dimension_map()
431 virtual std::map<UUID, Keepout> *get_keepout_map()
436 bool reverted =
false;
437 std::unique_ptr<ToolBase> tool =
nullptr;
438 type_signal_tool_changed s_signal_tool_changed;
439 type_signal_rebuilt s_signal_rebuilt;
440 type_signal_rebuilt s_signal_save;
441 type_signal_rebuilt s_signal_can_undo_redo;
442 type_signal_request_save_meta s_signal_request_save_meta;
443 type_signal_needs_save s_signal_needs_save;
444 type_signal_load_tool_settings s_signal_load_tool_settings;
445 type_signal_save_tool_settings s_signal_save_tool_settings;
446 bool needs_save =
false;
447 void set_needs_save(
bool v);
458 std::deque<std::unique_ptr<HistoryItem>> history;
459 int history_current = -1;
460 virtual void history_push() = 0;
461 virtual void history_load(
unsigned int i) = 0;
462 void history_clear();
464 bool property_transaction =
false;
471 std::unique_ptr<ToolBase> create_tool(ToolID tool_id);
Polygon used in Padstack, Package and Board for specifying filled Regions.
Definition: polygon.hpp:27
a class to store JSON values
Definition: json.hpp:161
type_signal_request_save_meta signal_request_save_meta()
connect to this signal for providing meta information when the document is saved
Definition: core.hpp:375
Graphical line.
Definition: line.hpp:19
Definition: core_properties.hpp:7
Definition: placement.hpp:8
Definition: keepout.hpp:9
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
Tools use this class to actually access the core.
Definition: cores.hpp:13
Used wherever a user-editable text is needed.
Definition: text.hpp:19
Definition: imp_interface.hpp:7
Where Tools and and documents meet.
Definition: core.hpp:232
Definition: dimension.hpp:12
Definition: layer_provider.hpp:7
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:19
type_signal_rebuilt signal_save()
Gets emitted right before saving.
Definition: core.hpp:360
A Junction is a point in 2D-Space.
Definition: junction.hpp:25
Graphical arc.
Definition: arc.hpp:20
A hole with diameter and position, that's it.
Definition: hole.hpp:19