KiCad PCB EDA Suite
kicad_clipboard.h
Go to the documentation of this file.
1 
30 #ifndef KICAD_CLIPBOARD_H
31 #define KICAD_CLIPBOARD_H
32 
33 #include <kicad_plugin.h>
34 #include <class_board_item.h>
35 #include <class_module.h>
36 #include <pcb_parser.h>
37 #include <memory.h>
38 #include <tools/pcbnew_selection.h>
39 
41 {
42 public:
43  CLIPBOARD_PARSER( LINE_READER* aReader = NULL ): PCB_PARSER( aReader ) {};
44 
45  MODULE* parseMODULE( wxArrayString* aInitialComments )
46  {
47  MODULE* mod = PCB_PARSER::parseMODULE( aInitialComments );
48 
49  //TODO: figure out better way of handling paths
50  mod->SetPath( wxT( "" ) );
51  return mod;
52  }
53 };
54 
55 class CLIPBOARD_IO : public PCB_IO
56 {
57 
58 public:
59  /* Saves the entire board to the clipboard formatted using the PCB_IO formatting */
60  void Save( const wxString& aFileName, BOARD* aBoard,
61  const PROPERTIES* aProperties = NULL ) override;
62  /* Writes all the settings of the BOARD* set by setBoard() and then adds all
63  * the BOARD_ITEM* found in selection formatted by PCB_IO to clipboard as a text
64  */
65  void SaveSelection( const PCBNEW_SELECTION& selected );
66 
67  BOARD_ITEM* Parse();
68 
69  BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties = NULL ) override;
70  CLIPBOARD_IO();
71  ~CLIPBOARD_IO();
72 
73  void SetBoard( BOARD* aBoard );
75 
76 private:
77  void writeHeader( BOARD* aBoard );
78 
81 };
82 
83 
84 #endif /* KICAD_CLIPBOARD_H */
BOARD * Load(const wxString &aFileName, BOARD *aAppendToMe, const PROPERTIES *aProperties=NULL) override
Function Load loads information from some input file format that this PLUGIN implementation knows abo...
BOARD_ITEM * Parse()
STRING_FORMATTER * GetFormatter()
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
Class PCB_IO is a PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Class PCB_PARSER reads a Pcbnew s-expression formatted LINE_READER object and returns the appropriate...
Definition: pcb_parser.h:66
Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
STRING_FORMATTER m_formatter
Class PROPERTIES is a name/value tuple with unique names and optional values.
Definition: properties.h:34
void SetBoard(BOARD *aBoard)
void Save(const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=NULL) override
Function Save will write aBoard to a storage file in a format that this PLUGIN implementation knows a...
MODULE * parseMODULE(wxArrayString *aInitialComments)
CLIPBOARD_PARSER * m_parser
void SaveSelection(const PCBNEW_SELECTION &selected)
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:161
CLIPBOARD_PARSER(LINE_READER *aReader=NULL)
void writeHeader(BOARD *aBoard)
Pcbnew s-expression file format parser definition.
Module description (excepted pads)
MODULE * parseMODULE(wxArrayString *aInitialComments=0)
Function parseMODULE.
Class STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:445
#define mod(a, n)
Definition: greymap.cpp:24