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 (C) 2019-2022 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 // Accessors:
44 void SetOriginalDPI( int aDPI )
45 {
46 m_originalDPI = aDPI;
47 }
48
49 void SetOriginalSizePixels( int aPixels )
50 {
51 m_originalSizePixels = aPixels;
52 }
53
55 {
56 return m_outputSize;
57 }
58
59 void SetOutputSize( double aSize, EDA_UNITS aUnit )
60 {
61 m_unit = aUnit;
62 m_outputSize = aSize;
63 }
64
66 {
68 }
69
70 // Set the m_outputSize value from the m_originalSizePixels and the selected unit
72
76 int GetOutputDPI();
77
78private:
79 EDA_UNITS m_unit; // The units for m_outputSize (mm, inch, dpi)
80 double m_outputSize; // The size in m_unit of the output image, depending on
81 // the user settings. Set to the initial image size
82 int m_originalDPI; // The image DPI if specified in file, or 0 if unknown
83 int m_originalSizePixels; // The original image size read from file, in pixels
84};
85
86
88{
89public:
92
93 bool OpenProjectFiles( const std::vector<wxString>& aFilenames, int aCtl = 0 );
94
95 void OnLoadFile( wxCommandEvent& event ) override;
96
99
100 wxWindow* GetCurrentPage();
101
104 void SetOutputSize( const IMAGE_SIZE& aSizeX, const IMAGE_SIZE& aSizeY );
105
111 void ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat );
112
113private:
114 // Event handlers
115 void OnPaintInit( wxPaintEvent& event ) override;
116 void OnPaintGreyscale( wxPaintEvent& event ) override;
117 void OnPaintBW( wxPaintEvent& event ) override;
118 void OnExportToFile( wxCommandEvent& event ) override;
119 void OnExportToClipboard( wxCommandEvent& event ) override;
120
123
124 // return a string giving the output size, according to the selected unit
125 wxString FormatOutputSize( double aSize );
126
127 void Binarize( double aThreshold ); // aThreshold = 0.0 (black level) to 1.0 (white level)
128 void OnNegativeClicked( wxCommandEvent& event ) override;
129 void OnThresholdChange( wxScrollEvent& event ) override;
130
131 void OnSizeChangeX( wxCommandEvent& event ) override;
132 void OnSizeChangeY( wxCommandEvent& event ) override;
133 void OnSizeUnitChange( wxCommandEvent& event ) override;
134
135 void ToggleAspectRatioLock( wxCommandEvent& event ) override;
136
138
139 void updateImageInfo();
140 void OnFormatChange( wxCommandEvent& event ) override;
141 void exportBitmap( OUTPUT_FMT_ID aFormat );
142
143private:
145
150 wxImage m_NB_Image;
151 wxBitmap m_BN_Bitmap;
156};
157#endif// BITMAP2CMP_PANEL
OUTPUT_FMT_ID
Class BITMAP2CMP_PANEL_BASE.
void OnPaintGreyscale(wxPaintEvent &event) override
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 Binarize(double aThreshold)
void OnExportToClipboard(wxCommandEvent &event) override
void LoadSettings(BITMAP2CMP_SETTINGS *aCfg)
wxString FormatOutputSize(double aSize)
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)
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
void exportBitmap(OUTPUT_FMT_ID aFormat)
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