KiCad PCB EDA Suite
DIALOG_IMAGE_EDITOR Class Reference

#include <dialog_image_editor.h>

Inheritance diagram for DIALOG_IMAGE_EDITOR:
DIALOG_IMAGE_EDITOR_BASE

Public Member Functions

 DIALOG_IMAGE_EDITOR (wxWindow *aParent, BITMAP_BASE *aItem)
 
 ~DIALOG_IMAGE_EDITOR ()
 
void TransfertToImage (BITMAP_BASE *aItem)
 Function TransfertToImage copy edited image to aItem. More...
 

Protected Attributes

wxPanel * m_panelDraw
 
wxButton * m_buttonMirrorX
 
wxButton * m_buttonMirrorY
 
wxButton * m_buttonRotate
 
wxButton * m_buttonGrey
 
wxButton * m_buttonHalfSize
 
wxButton * m_buttonUndoLast
 
wxStaticText * m_staticTextScale
 
wxTextCtrl * m_textCtrlScale
 
wxStdDialogButtonSizer * m_sdbSizer1
 
wxButton * m_sdbSizer1OK
 
wxButton * m_sdbSizer1Cancel
 

Private Member Functions

void OnUndoLastChange (wxCommandEvent &event) override
 
void OnGreyScaleConvert (wxCommandEvent &event) override
 
void OnHalfSize (wxCommandEvent &event) override
 
void OnMirrorX_click (wxCommandEvent &event) override
 
void OnMirrorY_click (wxCommandEvent &event) override
 
void OnRotateClick (wxCommandEvent &event) override
 
void OnOK_Button (wxCommandEvent &aEvent) override
 
void OnCancel_Button (wxCommandEvent &aEvent) override
 
void OnRedrawPanel (wxPaintEvent &event) override
 
bool CheckValues ()
 

Private Attributes

BITMAP_BASEm_workingImage
 
BITMAP_BASEm_lastImage
 

Detailed Description

Definition at line 35 of file dialog_image_editor.h.

Constructor & Destructor Documentation

DIALOG_IMAGE_EDITOR::DIALOG_IMAGE_EDITOR ( wxWindow *  aParent,
BITMAP_BASE aItem 
)

Definition at line 37 of file dialog_image_editor.cpp.

References BITMAP_BASE::GetScale(), DIALOG_IMAGE_EDITOR_BASE::m_buttonUndoLast, m_lastImage, DIALOG_IMAGE_EDITOR_BASE::m_textCtrlScale, and m_workingImage.

38  : DIALOG_IMAGE_EDITOR_BASE( aParent )
39 {
40  m_workingImage = new BITMAP_BASE( * aItem );
41  m_lastImage = NULL;
42  m_buttonUndoLast->Enable( false );
43  wxString msg;
44  msg.Printf( wxT( "%f" ), m_workingImage->GetScale() );
45  m_textCtrlScale->SetValue( msg );
46 
47  GetSizer()->SetSizeHints( this );
48  Layout();
49  Fit();
50  SetMinSize( GetBestSize() );
51 
52  Centre();
53  SetFocus();
54 }
BITMAP_BASE * m_workingImage
This class handle bitmap images in KiCad.
double GetScale() const
DIALOG_IMAGE_EDITOR_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Image Editor"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(340, 299), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
DIALOG_IMAGE_EDITOR::~DIALOG_IMAGE_EDITOR ( )
inline

Definition at line 44 of file dialog_image_editor.h.

References m_workingImage.

44 { delete m_workingImage; }
BITMAP_BASE * m_workingImage

Member Function Documentation

bool DIALOG_IMAGE_EDITOR::CheckValues ( )
private

Definition at line 129 of file dialog_image_editor.cpp.

References BITMAP_BASE::GetSizePixels(), DIALOG_IMAGE_EDITOR_BASE::m_textCtrlScale, m_workingImage, MAX_SIZE, and MIN_SIZE.

Referenced by OnOK_Button().

130 {
131  #define MIN_SIZE 16
132  #define MAX_SIZE 6000
133  double tmp;
134  wxString msg = m_textCtrlScale->GetValue();
135 
136  // Test number correctness
137  if( ! msg.ToDouble( &tmp ) )
138  {
139  wxMessageBox( _("Incorrect scale number" ) );
140  return false;
141  }
142 
143  // Test value correctness
144  wxSize psize = m_workingImage->GetSizePixels();
145 
146  if( (psize.x * tmp) < MIN_SIZE || (psize.y * tmp) < MIN_SIZE )
147  {
148  wxMessageBox( _("Scale is too small for this image" ) );
149  return false;
150  }
151 
152  if( (psize.x * tmp) > MAX_SIZE || (psize.y * tmp) > MAX_SIZE )
153  {
154  wxMessageBox( _("Scale is too large for this image" ) );
155  return false;
156  }
157 
158  return true;
159 }
BITMAP_BASE * m_workingImage
#define MIN_SIZE
#define MAX_SIZE
wxSize GetSizePixels() const
Function GetSizePixels.
void DIALOG_IMAGE_EDITOR::OnCancel_Button ( wxCommandEvent &  aEvent)
overrideprivatevirtual

Reimplemented from DIALOG_IMAGE_EDITOR_BASE.

Definition at line 171 of file dialog_image_editor.cpp.

172 {
173  EndModal( wxID_CANCEL );
174 }
void DIALOG_IMAGE_EDITOR::OnGreyScaleConvert ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_IMAGE_EDITOR_BASE.

Definition at line 99 of file dialog_image_editor.cpp.

References BITMAP_BASE::GetImageData(), DIALOG_IMAGE_EDITOR_BASE::m_buttonUndoLast, m_lastImage, DIALOG_IMAGE_EDITOR_BASE::m_panelDraw, m_workingImage, and BITMAP_BASE::RebuildBitmap().

100 {
101  delete m_lastImage;
103  m_buttonUndoLast->Enable( true );
104  wxImage& image = *m_workingImage->GetImageData();
105  image = image.ConvertToGreyscale();
107  m_panelDraw->Refresh();
108 }
BITMAP_BASE * m_workingImage
void RebuildBitmap()
wxImage * GetImageData()
This class handle bitmap images in KiCad.
void DIALOG_IMAGE_EDITOR::OnHalfSize ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_IMAGE_EDITOR_BASE.

Definition at line 111 of file dialog_image_editor.cpp.

References BITMAP_BASE::GetImageData(), BITMAP_BASE::GetSizePixels(), DIALOG_IMAGE_EDITOR_BASE::m_buttonUndoLast, m_lastImage, DIALOG_IMAGE_EDITOR_BASE::m_panelDraw, m_workingImage, and BITMAP_BASE::RebuildBitmap().

112 {
113  delete m_lastImage;
115  m_buttonUndoLast->Enable( true );
116  wxSize psize = m_workingImage->GetSizePixels();
117  wxImage& image = *m_workingImage->GetImageData();
118 
119  image = image.Scale( psize.x/2, psize.y/2, wxIMAGE_QUALITY_HIGH );
121  m_panelDraw->Refresh();
122 }
BITMAP_BASE * m_workingImage
void RebuildBitmap()
wxImage * GetImageData()
This class handle bitmap images in KiCad.
wxSize GetSizePixels() const
Function GetSizePixels.
void DIALOG_IMAGE_EDITOR::OnMirrorX_click ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_IMAGE_EDITOR_BASE.

Definition at line 68 of file dialog_image_editor.cpp.

References DIALOG_IMAGE_EDITOR_BASE::m_buttonUndoLast, m_lastImage, DIALOG_IMAGE_EDITOR_BASE::m_panelDraw, m_workingImage, and BITMAP_BASE::Mirror().

69 {
70  delete m_lastImage;
72  m_buttonUndoLast->Enable( true );
73  m_buttonUndoLast->Enable( true );
74  m_workingImage->Mirror( true );
75  m_panelDraw->Refresh();
76 }
BITMAP_BASE * m_workingImage
void Mirror(bool aVertically)
Function Mirror Mirror image vertically (i.e.
This class handle bitmap images in KiCad.
void DIALOG_IMAGE_EDITOR::OnMirrorY_click ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_IMAGE_EDITOR_BASE.

Definition at line 79 of file dialog_image_editor.cpp.

References DIALOG_IMAGE_EDITOR_BASE::m_buttonUndoLast, m_lastImage, DIALOG_IMAGE_EDITOR_BASE::m_panelDraw, m_workingImage, and BITMAP_BASE::Mirror().

80 {
81  delete m_lastImage;
83  m_buttonUndoLast->Enable( true );
84  m_workingImage->Mirror( false );
85  m_panelDraw->Refresh();
86 }
BITMAP_BASE * m_workingImage
void Mirror(bool aVertically)
Function Mirror Mirror image vertically (i.e.
This class handle bitmap images in KiCad.
void DIALOG_IMAGE_EDITOR::OnOK_Button ( wxCommandEvent &  aEvent)
overrideprivatevirtual

Reimplemented from DIALOG_IMAGE_EDITOR_BASE.

Definition at line 162 of file dialog_image_editor.cpp.

References CheckValues().

163 {
164  if( CheckValues() )
165  EndModal( wxID_OK );
166 
167  return;
168 }
void DIALOG_IMAGE_EDITOR::OnRedrawPanel ( wxPaintEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_IMAGE_EDITOR_BASE.

Definition at line 177 of file dialog_image_editor.cpp.

References BITMAP_BASE::DrawBitmap(), BITMAP_BASE::GetScalingFactor(), DIALOG_IMAGE_EDITOR_BASE::m_panelDraw, m_workingImage, and scale.

178 {
179  wxPaintDC dc( m_panelDraw );
180  wxSize size = m_panelDraw->GetClientSize();
181  dc.SetDeviceOrigin( size.x/2, size.y/2 );
182 
183  double scale = 1.0 / m_workingImage->GetScalingFactor();
184  dc.SetUserScale( scale, scale );
185  m_workingImage->DrawBitmap( NULL, &dc, wxPoint( 0, 0 ) );
186 }
BITMAP_BASE * m_workingImage
const int scale
double GetScalingFactor() const
Function GetScalingFactor.
void DrawBitmap(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPos)
void DIALOG_IMAGE_EDITOR::OnRotateClick ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_IMAGE_EDITOR_BASE.

Definition at line 89 of file dialog_image_editor.cpp.

References DIALOG_IMAGE_EDITOR_BASE::m_buttonUndoLast, m_lastImage, DIALOG_IMAGE_EDITOR_BASE::m_panelDraw, m_workingImage, and BITMAP_BASE::Rotate().

90 {
91  delete m_lastImage;
93  m_buttonUndoLast->Enable( true );
94  m_workingImage->Rotate( false );
95  m_panelDraw->Refresh();
96 }
BITMAP_BASE * m_workingImage
This class handle bitmap images in KiCad.
void Rotate(bool aRotateCCW)
Function Rotate Rotate image CW or CCW.
void DIALOG_IMAGE_EDITOR::OnUndoLastChange ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_IMAGE_EDITOR_BASE.

Definition at line 57 of file dialog_image_editor.cpp.

References DIALOG_IMAGE_EDITOR_BASE::m_buttonUndoLast, m_lastImage, DIALOG_IMAGE_EDITOR_BASE::m_panelDraw, and m_workingImage.

58 {
61  delete tmp;
62  m_buttonUndoLast->Enable( false );
63  m_lastImage = NULL;
64  m_panelDraw->Refresh();
65 }
BITMAP_BASE * m_workingImage
This class handle bitmap images in KiCad.
void DIALOG_IMAGE_EDITOR::TransfertToImage ( BITMAP_BASE aItem)

Function TransfertToImage copy edited image to aItem.

Parameters
aItem= the target

Definition at line 189 of file dialog_image_editor.cpp.

References BITMAP_BASE::ImportData(), DIALOG_IMAGE_EDITOR_BASE::m_textCtrlScale, m_workingImage, scale, and BITMAP_BASE::SetScale().

190 {
191  wxString msg = m_textCtrlScale->GetValue();
192  double scale = 1.0;
193  msg.ToDouble( &scale );
194  m_workingImage->SetScale( scale );
195  aItem->ImportData( m_workingImage );
196 }
BITMAP_BASE * m_workingImage
void SetScale(double aScale)
void ImportData(BITMAP_BASE *aItem)
Function ImportData Copy aItem image to me and update m_bitmap.
const int scale

Member Data Documentation

wxButton* DIALOG_IMAGE_EDITOR_BASE::m_buttonGrey
protectedinherited
wxButton* DIALOG_IMAGE_EDITOR_BASE::m_buttonHalfSize
protectedinherited
wxButton* DIALOG_IMAGE_EDITOR_BASE::m_buttonMirrorX
protectedinherited
wxButton* DIALOG_IMAGE_EDITOR_BASE::m_buttonMirrorY
protectedinherited
wxButton* DIALOG_IMAGE_EDITOR_BASE::m_buttonRotate
protectedinherited
BITMAP_BASE* DIALOG_IMAGE_EDITOR::m_lastImage
private
wxStdDialogButtonSizer* DIALOG_IMAGE_EDITOR_BASE::m_sdbSizer1
protectedinherited
wxButton* DIALOG_IMAGE_EDITOR_BASE::m_sdbSizer1Cancel
protectedinherited
wxButton* DIALOG_IMAGE_EDITOR_BASE::m_sdbSizer1OK
protectedinherited
wxStaticText* DIALOG_IMAGE_EDITOR_BASE::m_staticTextScale
protectedinherited
wxTextCtrl* DIALOG_IMAGE_EDITOR_BASE::m_textCtrlScale
protectedinherited

The documentation for this class was generated from the following files: