You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.5 KiB

  1. /**
  2. * @file kicad_clipboard.h
  3. * @brief
  4. * @author Kristoffer Ödmark
  5. * @version 1.0
  6. * @date 2017-05-03
  7. *
  8. * This program source code file is part of KiCad, a free EDA CAD application.
  9. *
  10. * Copyright (C) 2017-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * as published by the Free Software Foundation; either version 2
  15. * of the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, you may find one here:
  24. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  25. * or you may search the http://www.gnu.org website for the version 2 license,
  26. * or you may write to the Free Software Foundation, Inc.,
  27. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  28. */
  29. #ifndef KICAD_CLIPBOARD_H
  30. #define KICAD_CLIPBOARD_H
  31. #include <kicad_plugin.h>
  32. #include <class_board_item.h>
  33. #include <class_module.h>
  34. #include <pcb_parser.h>
  35. #include <memory.h>
  36. #include <tools/pcbnew_selection.h>
  37. class CLIPBOARD_PARSER : public PCB_PARSER
  38. {
  39. public:
  40. CLIPBOARD_PARSER( LINE_READER* aReader = NULL ): PCB_PARSER( aReader ) {};
  41. MODULE* parseMODULE( wxArrayString* aInitialComments )
  42. {
  43. return PCB_PARSER::parseMODULE( aInitialComments );
  44. }
  45. };
  46. class CLIPBOARD_IO : public PCB_IO
  47. {
  48. public:
  49. /* Saves the entire board to the clipboard formatted using the PCB_IO formatting */
  50. void Save( const wxString& aFileName, BOARD* aBoard,
  51. const PROPERTIES* aProperties = NULL ) override;
  52. /* Writes all the settings of the BOARD* set by setBoard() and then adds all
  53. * the BOARD_ITEM* found in selection formatted by PCB_IO to clipboard as a text
  54. */
  55. void SaveSelection( const PCBNEW_SELECTION& selected, bool isModEdit );
  56. BOARD_ITEM* Parse();
  57. BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties = NULL ) override;
  58. CLIPBOARD_IO();
  59. ~CLIPBOARD_IO();
  60. void SetBoard( BOARD* aBoard );
  61. STRING_FORMATTER* GetFormatter();
  62. private:
  63. void writeHeader( BOARD* aBoard );
  64. STRING_FORMATTER m_formatter;
  65. CLIPBOARD_PARSER* m_parser;
  66. };
  67. #endif /* KICAD_CLIPBOARD_H */