25#include <wx/dcclient.h>
71 wxWindow* host = wxGetTopLevelParent(
this );
79 if( !msg.ToDouble( &tmp ) || tmp < 0.0 )
87 int size_min = (int) std::min( ( psize.
x * tmp ), ( psize.
y * tmp ) );
91 DisplayErrorMessage( host, wxString::Format(
_(
"This scale results in an image which is too small "
92 "(%.2f mm or %.1f mil)." ),
93 25.4 / 300 * size_min,
94 1000.0 / 300.0 * size_min ) );
98 int size_max = (int) std::max( ( psize.
x * tmp ), ( psize.
y * tmp ) );
103 if( !
IsOK( host, wxString::Format(
_(
"This scale results in an image which is very large "
104 "(%.1f mm or %.2f in). Are you sure?" ),
105 25.4 / 300 * size_max,
106 size_max / 300.0 ) ) )
125 wxSize display_size =
m_panelDraw->GetClientSize();
131 double scale_X = (double)display_size.x/img_size_pixels.
x;
132 double scale_Y = (
double)display_size.y/img_size_pixels.
y;
134 double display_scale = img_scale * std::min( scale_X, scale_Y );
136 dc.SetUserScale( display_scale, display_scale );
145 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)
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.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
VECTOR2< int32_t > VECTOR2I