KiCad PCB EDA Suite
bitmap2cmp_gui.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KICAD, a free EDA CAD application.
3  *
4  * Copyright (C) 2019-2021 Kicad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 #ifndef BITMOP2CMP_GUI_H_
24 #define BITMOP2CMP_GUI_H_
25 
26 #include "bitmap2component.h"
27 
28 #include "bitmap2cmp_gui_base.h"
29 #include <eda_units.h>
30 #include <potracelib.h>
31 
32 
34 {
35 public:
36  IMAGE_SIZE();
37 
38  // Set the unit used for m_outputSize, and convert the old m_outputSize value
39  // to the value in new unit
40  void SetUnit( EDA_UNITS aUnit );
41 
42  // Accessors:
43  void SetOriginalDPI( int aDPI )
44  {
45  m_originalDPI = aDPI;
46  }
47 
48  void SetOriginalSizePixels( int aPixels )
49  {
50  m_originalSizePixels = aPixels;
51  }
52 
53  double GetOutputSize()
54  {
55  return m_outputSize;
56  }
57 
58  void SetOutputSize( double aSize, EDA_UNITS aUnit )
59  {
60  m_unit = aUnit;
61  m_outputSize = aSize;
62  }
63 
65  {
66  return m_originalSizePixels;
67  }
68 
69  // Set the m_outputSize value from the m_originalSizePixels and the selected unit
71 
75  int GetOutputDPI();
76 
77 private:
78  EDA_UNITS m_unit; // The units for m_outputSize (mm, inch, dpi)
79  double m_outputSize; // The size in m_unit of the output image, depending on
80  // the user settings. Set to the initial image size
81  int m_originalDPI; // The image DPI if specified in file, or 0 if unknown
82  int m_originalSizePixels; // The original image size read from file, in pixels
83 };
84 
86 {
87 public:
88  BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent );
89  ~BM2CMP_FRAME();
90 
91  // overload KIWAY_PLAYER virtual
92  bool OpenProjectFiles( const std::vector<wxString>& aFilenames, int aCtl = 0 ) override;
93 
94 private:
95  // Event handlers
96  void OnPaintInit( wxPaintEvent& event ) override;
97  void OnPaintGreyscale( wxPaintEvent& event ) override;
98  void OnPaintBW( wxPaintEvent& event ) override;
99  void OnLoadFile( wxCommandEvent& event ) override;
100  void OnExportToFile( wxCommandEvent& event ) override;
101  void OnExportToClipboard( wxCommandEvent& event ) override;
102 
105 
106  // return a string giving the output size, according to the selected unit
107  wxString FormatOutputSize( double aSize );
108 
113  void exportEeschemaFormat();
114 
118  void exportPcbnewFormat();
119 
123  void exportPostScriptFormat();
124 
129  void OnExportLogo();
130 
131  void Binarize( double aThreshold ); // aThreshold = 0.0 (black level) to 1.0 (white level)
132  void OnNegativeClicked( wxCommandEvent& event ) override;
133  void OnThresholdChange( wxScrollEvent& event ) override;
134 
135  void OnSizeChangeX( wxCommandEvent& event ) override;
136  void OnSizeChangeY( wxCommandEvent& event ) override;
137  void OnSizeUnitChange( wxCommandEvent& event ) override;
138 
139  void ToggleAspectRatioLock( wxCommandEvent& event ) override;
140 
141 
142  void NegateGreyscaleImage();
148  void ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat );
149 
150  void updateImageInfo();
151  void OnFormatChange( wxCommandEvent& event ) override;
152  void exportBitmap( OUTPUT_FMT_ID aFormat );
153 
154  void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
155  void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
156 
157  wxWindow* GetToolCanvas() const override;
158 
159 private:
160  wxImage m_Pict_Image;
161  wxBitmap m_Pict_Bitmap;
164  wxImage m_NB_Image;
165  wxBitmap m_BN_Bitmap;
174 };
175 #endif// BITMOP2CMP_GUI_H_
wxBitmap m_Greyscale_Bitmap
EDA_UNITS m_unit
wxImage m_Greyscale_Image
void OnExportToFile(wxCommandEvent &event) override
void exportPcbnewFormat()
Generate a footprint in S expr format.
wxBitmap m_BN_Bitmap
void OnPaintInit(wxPaintEvent &event) override
void SetOriginalSizePixels(int aPixels)
Class BM2CMP_FRAME_BASE.
void OnExportLogo()
Generate a file suitable to be copied into a page layout description file (.kicad_wks file.
void SetUnit(EDA_UNITS aUnit)
void OnPaintGreyscale(wxPaintEvent &event) override
bool m_exportToClipboard
bool m_AspectRatioLocked
int GetOriginalSizePixels()
int GetOutputDPI()
IMAGE_SIZE m_outputSizeY
wxString m_ConvertedFileName
double GetOutputSize()
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void SetOutputSize(double aSize, EDA_UNITS aUnit)
void OnExportToClipboard(wxCommandEvent &event) override
void OnPaintBW(wxPaintEvent &event) override
void SetOriginalDPI(int aDPI)
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
int m_originalSizePixels
void OnFormatChange(wxCommandEvent &event) override
void OnThresholdChange(wxScrollEvent &event) override
void OnLoadFile(wxCommandEvent &event) override
void exportEeschemaFormat()
Generate a schematic library which contains one component: the logo.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
wxString FormatOutputSize(double aSize)
void OnSizeUnitChange(wxCommandEvent &event) override
void OnSizeChangeY(wxCommandEvent &event) override
EDA_UNITS getUnitFromSelection()
BM2CMP_FRAME(KIWAY *aKiway, wxWindow *aParent)
IMAGE_SIZE m_outputSizeX
void OnSizeChangeX(wxCommandEvent &event) override
void ToggleAspectRatioLock(wxCommandEvent &event) override
wxImage m_Pict_Image
EDA_UNITS
Definition: eda_units.h:38
void NegateGreyscaleImage()
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
wxString m_BitmapFileName
void Binarize(double aThreshold)
void SetOutputSizeFromInitialImageSize()
void exportBitmap(OUTPUT_FMT_ID aFormat)
bool OpenProjectFiles(const std::vector< wxString > &aFilenames, int aCtl=0) override
Open a project or set of files given by aFileList.
double m_AspectRatio
wxWindow * GetToolCanvas() const override
Canvas access.
wxBitmap m_Pict_Bitmap
OUTPUT_FMT_ID
wxImage m_NB_Image
double m_outputSize
void ExportToBuffer(std::string &aOutput, OUTPUT_FMT_ID aFormat)
generate a export data of the current bitmap.
void updateImageInfo()
void exportPostScriptFormat()
Generate a postscript file.
void OnNegativeClicked(wxCommandEvent &event) override