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{
35public:
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
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 {
67 }
68
69 // Set the m_outputSize value from the m_originalSizePixels and the selected unit
71
75 int GetOutputDPI();
76
77private:
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{
87public:
88 BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent );
90
91 // overload KIWAY_PLAYER virtual
92 bool OpenProjectFiles( const std::vector<wxString>& aFilenames, int aCtl = 0 ) override;
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 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
114
118 void exportPcbnewFormat();
119
124
128 void OnExportLogo();
129
130 void Binarize( double aThreshold ); // aThreshold = 0.0 (black level) to 1.0 (white level)
131 void OnNegativeClicked( wxCommandEvent& event ) override;
132 void OnThresholdChange( wxScrollEvent& event ) override;
133
134 void OnSizeChangeX( wxCommandEvent& event ) override;
135 void OnSizeChangeY( wxCommandEvent& event ) override;
136 void OnSizeUnitChange( wxCommandEvent& event ) override;
137
138 void ToggleAspectRatioLock( wxCommandEvent& event ) override;
139
140
147 void ExportToBuffer( std::string& aOutput, OUTPUT_FMT_ID aFormat );
148
149 void updateImageInfo();
150 void OnFormatChange( wxCommandEvent& event ) override;
151 void exportBitmap( OUTPUT_FMT_ID aFormat );
152
153 void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
154 void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
155
156 wxWindow* GetToolCanvas() const override;
157
158private:
163 wxImage m_NB_Image;
164 wxBitmap m_BN_Bitmap;
173};
174#endif// BITMOP2CMP_GUI_H_
OUTPUT_FMT_ID
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:101
Class BM2CMP_FRAME_BASE.
void OnSizeChangeX(wxCommandEvent &event) override
void OnExportLogo()
Generate a file suitable to be copied into a drawing sheet (.kicad_wks) file.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void exportEeschemaFormat()
Generate a schematic library which contains one component: the logo.
bool m_AspectRatioLocked
wxImage m_Pict_Image
void exportPostScriptFormat()
Generate a postscript file.
void OnPaintBW(wxPaintEvent &event) override
wxString FormatOutputSize(double aSize)
double m_AspectRatio
IMAGE_SIZE m_outputSizeY
wxBitmap m_Greyscale_Bitmap
void OnThresholdChange(wxScrollEvent &event) override
void NegateGreyscaleImage()
void OnExportToFile(wxCommandEvent &event) override
IMAGE_SIZE m_outputSizeX
void OnLoadFile(wxCommandEvent &event) override
bool OpenProjectFiles(const std::vector< wxString > &aFilenames, int aCtl=0) override
Open a project or set of files given by aFileList.
BM2CMP_FRAME(KIWAY *aKiway, wxWindow *aParent)
wxBitmap m_Pict_Bitmap
void OnSizeUnitChange(wxCommandEvent &event) override
void OnNegativeClicked(wxCommandEvent &event) override
bool m_exportToClipboard
void OnPaintInit(wxPaintEvent &event) override
void Binarize(double aThreshold)
wxString m_BitmapFileName
void updateImageInfo()
wxImage m_NB_Image
void ToggleAspectRatioLock(wxCommandEvent &event) override
void OnSizeChangeY(wxCommandEvent &event) override
wxImage m_Greyscale_Image
wxString m_ConvertedFileName
void OnFormatChange(wxCommandEvent &event) override
void ExportToBuffer(std::string &aOutput, OUTPUT_FMT_ID aFormat)
generate a export data of the current bitmap.
wxWindow * GetToolCanvas() const override
Canvas access.
EDA_UNITS getUnitFromSelection()
void OnPaintGreyscale(wxPaintEvent &event) override
void OnExportToClipboard(wxCommandEvent &event) override
void exportPcbnewFormat()
Generate a footprint in S expr format.
void exportBitmap(OUTPUT_FMT_ID aFormat)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
wxBitmap m_BN_Bitmap
void SetUnit(EDA_UNITS aUnit)
double m_outputSize
double GetOutputSize()
EDA_UNITS m_unit
void SetOriginalDPI(int aDPI)
int GetOriginalSizePixels()
int m_originalSizePixels
int GetOutputDPI()
void SetOutputSizeFromInitialImageSize()
void SetOutputSize(double aSize, EDA_UNITS aUnit)
void SetOriginalSizePixels(int aPixels)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:267
EDA_UNITS
Definition: eda_units.h:39