32#include <potracelib.h>
35#include <wx/clipbrd.h>
39#include <wx/dcclient.h>
44#define DEFAULT_DPI 300
53 for(
const wxString& unit : {
_(
"mm" ),
_(
"Inch" ),
_(
"DPI" ) } )
196 int imageDPIx =
m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONX );
197 int imageDPIy =
m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONY );
199 if( imageDPIx > 1 && imageDPIy > 1 )
201 if(
m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONUNIT ) == wxIMAGE_RESOLUTION_CM )
203 imageDPIx =
KiROUND( imageDPIx * 2.54 );
204 imageDPIy =
KiROUND( imageDPIy * 2.54 );
225 wxCommandEvent
dummy;
278 text.Printf( wxS(
"%.1f" ), aSize );
280 text.Printf( wxS(
"%.2f" ), aSize );
318 if(
m_UnitSizeX->GetValue().ToDouble( &new_size ) )
347 if(
m_UnitSizeY->GetValue().ToDouble( &new_size ) )
399 wxCommandEvent
dummy;
407 unsigned char threshold = aThreshold * 255;
408 unsigned char alpha_thresh = 0.7 * threshold;
418 if( pixel < threshold && alpha > alpha_thresh )
423 m_NB_Image.SetRGB( x, y, pixel, pixel, pixel );
502 if( wxTheClipboard->Open() )
506 wxTheClipboard->SetData(
new wxTextDataObject( buffer.c_str() ) );
507 wxTheClipboard->Flush();
508 wxTheClipboard->Close();
512 wxMessageBox(
_(
"Unable to export to the Clipboard") );
522 if( !potrace_bitmap )
524 wxMessageBox(
_(
"Error allocating memory for potrace bitmap" ) );
529 for(
int y = 0; y <
m_NB_Image.GetHeight(); y++ )
531 for(
int x = 0; x <
m_NB_Image.GetWidth(); x++ )
533 unsigned char pixel =
m_NB_Image.GetGreen( x, y );
534 BM_PUT( potrace_bitmap, x, y, pixel ? 0 : 1 );
538 wxString layer = wxT(
"F.SilkS" );
544 case 0: layer = wxT(
"F.Cu" );
break;
545 case 1: layer = wxT(
"F.SilkS" );
break;
546 case 2: layer = wxT(
"F.Mask" );
break;
547 case 3: layer = wxT(
"Dwgs.User" );
break;
548 case 4: layer = wxT(
"Cmts.User" );
break;
549 case 5: layer = wxT(
"Eco1.User" );
break;
550 case 6: layer = wxT(
"Eco2.User" );
break;
551 case 7: layer = wxT(
"F.Fab" );
break;
586 if(
m_panel->GetOutputSizeX().GetOriginalSizePixels() != 0 )
588 wxString cap =
_(
"Replace Loaded File?" );
589 wxString msg =
_(
"There is already a file loaded. Do you want to replace it?" );
591 int replace = acceptFileDlg.ShowModal();
593 if( replace == wxID_NO )
597 std::vector<wxString> fNameVec;
598 fNameVec.insert( fNameVec.begin(), filenames.begin(), filenames.end() );
599 m_panel->OpenProjectFiles( fNameVec );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
wxStaticText * m_BPPValue
wxScrolledWindow * m_GreyscalePicturePanel
wxButton * m_buttonExportFile
wxScrolledWindow * m_BNPicturePanel
wxButton * m_buttonExportClipboard
wxSlider * m_sliderThreshold
wxCheckBox * m_aspectRatioCheckbox
wxRadioButton * m_rbPostscript
wxCheckBox * m_checkNegative
wxRadioButton * m_rbFootprint
wxRadioButton * m_rbWorksheet
wxStaticText * m_SizeXValue
wxRadioButton * m_rbSymbol
wxStaticText * m_layerLabel
wxStaticText * m_SizeYValue
wxStaticText * m_InputYValueDPI
BITMAP2CMP_PANEL_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
wxStaticText * m_InputXValueDPI
wxScrolledWindow * m_InitialPicturePanel
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)
wxImage m_Greyscale_Image
void negateGreyscaleImage()
void ToggleAspectRatioLock(wxCommandEvent &event) override
bool OpenProjectFiles(const std::vector< wxString > &aFilenames, int aCtl=0)
wxWindow * GetCurrentPage()
BITMAP2CMP_PANEL(BITMAP2CMP_FRAME *aParent)
void OnExportToFile(wxCommandEvent &event) override
void SaveSettings(BITMAP2CMP_SETTINGS *aCfg)
wxString formatOutputSize(double aSize)
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
OUTPUT_FMT_ID getOutputFormat()
void OnSizeChangeY(wxCommandEvent &event) override
int ConvertBitmap(potrace_bitmap_t *aPotrace_bitmap, OUTPUT_FMT_ID aFormat, int aDpi_X, int aDpi_Y, const wxString &aLayer)
Run the conversion of the bitmap.
BITMAP2CMP_PANEL * m_panel
bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames) override
virtual bool HasMessage() const
Returns true if any messages were reported.
A wrapper for reporting to a wxString object.
const wxString & GetMessages() const
This file is part of the common library.
#define KICAD_MESSAGE_DIALOG
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
std::vector< FAB_LAYER_COLOR > dummy