KiCad PCB EDA Suite
Loading...
Searching...
No Matches
bitmap2cmp_panel.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 The 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 BITMAP2CMP_PANEL_H
24#define BITMAP2CMP_PANEL_H
25
27#include <eda_units.h>
28
29
32
33
35{
36public:
37 IMAGE_SIZE();
38
39 // Set the unit used for m_outputSize, and convert the old m_outputSize value
40 // to the value in new unit
41 void SetUnit( EDA_UNITS aUnit );
42
43 void SetOriginalDPI( int aDPI ) { m_originalDPI = aDPI; }
44
45 void SetOriginalSizePixels( int aPixels ) { m_originalSizePixels = aPixels; }
47
48 double GetOutputSize() { return m_outputSize; }
49 void SetOutputSize( double aSize, EDA_UNITS aUnit ) { m_outputSize = aSize; m_unit = aUnit; }
50
51 // Set the m_outputSize value from the m_originalSizePixels and the selected unit
53
57 int GetOutputDPI();
58
59private:
60 EDA_UNITS m_unit; // The units for m_outputSize (mm, inch, dpi)
61 double m_outputSize; // The size in m_unit of the output image, depending on
62 // the user settings. Set to the initial image size
63 int m_originalDPI; // The image DPI if specified in file, or 0 if unknown
64 int m_originalSizePixels; // The original image size read from file, in pixels
65};
66
67
69{
70public:
73
74 bool OpenProjectFiles( const std::vector<wxString>& aFilenames, int aCtl = 0 );
75
76 void OnLoadFile( wxCommandEvent& event ) override;
77
80
81 wxWindow* GetCurrentPage();
82
85 void SetOutputSize( const IMAGE_SIZE& aSizeX, const IMAGE_SIZE& aSizeY );
86
92 void ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat );
93
94private:
95 // Event handlers
96 void OnPaintInit( wxPaintEvent& event ) override;
97 void OnPaintGreyscale( wxPaintEvent& event ) override;
98 void OnPaintBW( wxPaintEvent& event ) override;
99 void OnExportToFile( wxCommandEvent& event ) override;
100 void OnExportToClipboard( wxCommandEvent& event ) override;
101 void OnFormatChange( wxCommandEvent& event ) override;
102 void OnNegativeClicked( wxCommandEvent& event ) override;
103 void OnThresholdChange( wxScrollEvent& event ) override;
104 void OnSizeChangeX( wxCommandEvent& event ) override;
105 void OnSizeChangeY( wxCommandEvent& event ) override;
106 void OnSizeUnitChange( wxCommandEvent& event ) override;
107 void ToggleAspectRatioLock( wxCommandEvent& event ) override;
108
110
113
114 // return a string giving the output size, according to the selected unit
115 wxString formatOutputSize( double aSize );
116
117 void binarize( double aThreshold ); // aThreshold = 0.0 (black level) to 1.0 (white level)
118
120
121 void updateImageInfo();
122
123private:
125
130 wxImage m_NB_Image;
131 wxBitmap m_BN_Bitmap;
136};
137#endif// BITMAP2CMP_PANEL
OUTPUT_FMT_ID
Class BITMAP2CMP_PANEL_BASE.
void OnPaintGreyscale(wxPaintEvent &event) override
void binarize(double aThreshold)
void SetOutputSize(const IMAGE_SIZE &aSizeX, const IMAGE_SIZE &aSizeY)
void OnSizeUnitChange(wxCommandEvent &event) override
void OnSizeChangeX(wxCommandEvent &event) override
void OnPaintInit(wxPaintEvent &event) override
void OnExportToClipboard(wxCommandEvent &event) override
void LoadSettings(BITMAP2CMP_SETTINGS *aCfg)
IMAGE_SIZE m_outputSizeX
IMAGE_SIZE GetOutputSizeX() const
void ToggleAspectRatioLock(wxCommandEvent &event) override
bool OpenProjectFiles(const std::vector< wxString > &aFilenames, int aCtl=0)
wxWindow * GetCurrentPage()
void OnExportToFile(wxCommandEvent &event) override
void SaveSettings(BITMAP2CMP_SETTINGS *aCfg)
wxString formatOutputSize(double aSize)
IMAGE_SIZE GetOutputSizeY() const
void OnThresholdChange(wxScrollEvent &event) override
void ExportToBuffer(std::string &aOutput, OUTPUT_FMT_ID aFormat)
generate a export data of the current bitmap.
BITMAP2CMP_FRAME * m_parentFrame
void OnFormatChange(wxCommandEvent &event) override
void OnLoadFile(wxCommandEvent &event) override
wxBitmap m_Greyscale_Bitmap
EDA_UNITS getUnitFromSelection()
void OnNegativeClicked(wxCommandEvent &event) override
void OnPaintBW(wxPaintEvent &event) override
IMAGE_SIZE m_outputSizeY
OUTPUT_FMT_ID getOutputFormat()
void OnSizeChangeY(wxCommandEvent &event) override
void SetUnit(EDA_UNITS aUnit)
double m_outputSize
double GetOutputSize()
EDA_UNITS m_unit
void SetOriginalDPI(int aDPI)
int GetOriginalSizePixels()
int m_originalSizePixels
void SetOutputSizeFromInitialImageSize()
void SetOutputSize(double aSize, EDA_UNITS aUnit)
void SetOriginalSizePixels(int aPixels)
EDA_UNITS
Definition: eda_units.h:46