21#include <wx/dcclient.h>
67 wxWindow* host = wxGetTopLevelParent(
this );
71 double tmp =
m_scale.GetDoubleValue();
82 int size_min = (int) std::min( ( psize.
x * tmp ), ( psize.
y * tmp ) );
86 DisplayErrorMessage( host, wxString::Format(
_(
"This scale results in an image which is too small "
87 "(%.2f mm or %.1f mil)." ),
88 25.4 / 300 * size_min,
89 1000.0 / 300.0 * size_min ) );
93 int size_max = (int) std::max( ( psize.
x * tmp ), ( psize.
y * tmp ) );
98 if( !
IsOK( host, wxString::Format(
_(
"This scale results in an image which is very large "
99 "(%.1f mm or %.2f in). Are you sure?" ),
100 25.4 / 300 * size_max,
101 size_max / 300.0 ) ) )
119 return m_scale.GetDoubleValue();
125 m_scale.ChangeDoubleValue( aScale );
140 wxSize display_size =
m_panelDraw->GetClientSize();
146 double scale_X = (double)display_size.x/img_size_pixels.
x;
147 double scale_Y = (double)display_size.y/img_size_pixels.
y;
149 double display_scale = img_scale * std::min( scale_X, scale_Y );
151 dc.SetUserScale( display_scale, display_scale );
160 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