25#include <wx/dcclient.h>
72 if( !msg.ToDouble( &tmp ) || tmp < 0.0 )
74 wxMessageBox(
_(
"Incorrect scale number" ) );
80 int size_min = (int) std::min( ( psize.
x * tmp ), ( psize.
y * tmp ) );
84 wxMessageBox( wxString::Format(
_(
"This scale results in an image which is too small "
85 "(%.2f mm or %.1f mil)." ),
86 25.4 / 300 * size_min, 1000.0 / 300.0 * size_min ) );
90 int size_max = (int) std::max( ( psize.
x * tmp ), ( psize.
y * tmp ) );
95 if( !
IsOK(
this, wxString::Format(
_(
"This scale results in an image which is very large "
96 "(%.1f mm or %.2f in). Are you sure?" ),
97 25.4 / 300 * size_max, size_max / 300.0 ) ) )
116 wxSize display_size =
m_panelDraw->GetClientSize();
122 double scale_X = (double)display_size.
x/img_size_pixels.
x;
123 double scale_Y = (
double)display_size.y/img_size_pixels.
y;
125 double display_scale = img_scale * std::min( scale_X, scale_Y );
127 dc.SetUserScale( display_scale, display_scale );
136 msg.ToDouble( &
scale );
This class handle bitmap images in KiCad.
double GetScalingFactor() const
This scaling factor depends on m_pixelSizeIu and m_scale.
VECTOR2I GetSizePixels() const
void DrawBitmap(wxDC *aDC, const VECTOR2I &aPos, const KIGFX::COLOR4D &aBackgroundColor=KIGFX::COLOR4D::UNSPECIFIED)
void ImportData(BITMAP_BASE *aItem)
Copy aItem image to this object and update m_bitmap.
void ConvertToGreyscale()
void SetScale(double aScale)
Class PANEL_IMAGE_EDITOR_BASE.
wxStaticText * m_stPPI_Value
wxTextCtrl * m_textCtrlScale
void TransferToImage(BITMAP_BASE *aItem)
Function TransferToImage copy edited image to aItem.
bool TransferDataFromWindow() override
BITMAP_BASE * m_workingImage
PANEL_IMAGE_EDITOR(wxWindow *aParent, BITMAP_BASE *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.