25#include <wx/dcclient.h>
77 if( !msg.ToDouble( &tmp ) || tmp < 0.0 )
79 wxMessageBox(
_(
"Incorrect scale number" ) );
85 int size_min = (int) std::min( ( psize.
x * tmp ), ( psize.
y * tmp ) );
89 wxMessageDialog( wxGetTopLevelParent(
this ),
90 wxString::Format(
_(
"This scale results in an image which is too "
91 "small (%.2f mm or %.1f mil)." ),
92 25.4 / 300 * size_min, 1000.0 / 300.0 * size_min ) );
96 int size_max = (int) std::max( ( psize.
x * tmp ), ( psize.
y * tmp ) );
101 if( !
IsOK( wxGetTopLevelParent(
this ),
102 wxString::Format(
_(
"This scale results in an image which is very large "
103 "(%.1f mm or %.2f in). Are you sure?" ),
104 25.4 / 300 * size_max, size_max / 300.0 ) ) )
123 wxSize display_size =
m_panelDraw->GetClientSize();
129 double scale_X = (double)display_size.x/img_size_pixels.
x;
130 double scale_Y = (
double)display_size.y/img_size_pixels.
y;
132 double display_scale = img_scale * std::min( scale_X, scale_Y );
134 dc.SetUserScale( display_scale, display_scale );
143 msg.ToDouble( &
scale );
This class handle bitmap images in KiCad.
void ImportData(BITMAP_BASE &aItem)
Copy aItem image to this object and update m_bitmap.
Class PANEL_IMAGE_EDITOR_BASE.
wxStaticText * m_stPPI_Value
wxTextCtrl * m_textCtrlScale
PANEL_IMAGE_EDITOR(wxWindow *aParent, const BITMAP_BASE &aItem)
bool TransferDataFromWindow() override
std::unique_ptr< BITMAP_BASE > m_workingImage
void TransferToImage(BITMAP_BASE &aItem)
Function TransferToImage copy edited image to aItem.
void OnRedrawPanel(wxPaintEvent &event) override
void OnGreyScaleConvert(wxCommandEvent &event) override
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
This file is part of the common library.
VECTOR2< int32_t > VECTOR2I