25#include <wx/dcclient.h>
71 wxWindow* host = wxGetTopLevelParent(
this );
75 double tmp =
m_scale.GetDoubleValue();
86 int size_min = (int) std::min( ( psize.
x * tmp ), ( psize.
y * tmp ) );
90 DisplayErrorMessage( host, wxString::Format(
_(
"This scale results in an image which is too small "
91 "(%.2f mm or %.1f mil)." ),
92 25.4 / 300 * size_min,
93 1000.0 / 300.0 * size_min ) );
97 int size_max = (int) std::max( ( psize.
x * tmp ), ( psize.
y * tmp ) );
102 if( !
IsOK( host, 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,
105 size_max / 300.0 ) ) )
123 return m_scale.GetDoubleValue();
129 m_scale.ChangeDoubleValue( aScale );
144 wxSize display_size =
m_panelDraw->GetClientSize();
150 double scale_X = (double)display_size.x/img_size_pixels.
x;
151 double scale_Y = (double)display_size.y/img_size_pixels.
y;
153 double display_scale = img_scale * std::min( scale_X, scale_Y );
155 dc.SetUserScale( display_scale, display_scale );
164 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.
PANEL_IMAGE_EDITOR_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_stPPI_Value
wxStaticText * m_staticTextScale
wxTextCtrl * m_textCtrlScale
bool TransferDataFromWindow() override
void SetScale(double aScale)
PANEL_IMAGE_EDITOR(UNITS_PROVIDER *aUnitsProvider, wxWindow *aParent, const BITMAP_BASE &aItem)
std::unique_ptr< BITMAP_BASE > m_workingImage
bool TransferDataToWindow() override
void TransferToImage(BITMAP_BASE &aItem)
Copy edited image to aItem.
VECTOR2I GetImageSize() const
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