00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "a2dprec.h"
00014
00015 #ifdef __BORLANDC__
00016 #pragma hdrstop
00017 #endif
00018
00019 #ifndef WX_PRECOMP
00020 #include "wx/wx.h"
00021 #endif
00022
00023 #include "wx/editor/transdlg.h"
00024 #include "wx/canvas/canmod.h"
00025
00026 #define ID_x 10002
00027 #define ID_y 10003
00028 #define ID_scalex 10006
00029 #define ID_scaley 10004
00030 #define ID_TEXTCTRL3 10013
00031 #define ID_vertical 10010
00032 #define ID_horizontal 10009
00033 #define ID_rotateangle 10014
00034 #define ID_clockwise 10011
00035 #define ID_counterclockwise 10012
00036 #define ID_hide 10015
00037 #define ID_apply 10016
00038
00039
00040
00041
00042
00043 IMPLEMENT_DYNAMIC_CLASS( a2dTransDlg, wxDialog )
00044
00045
00046
00047
00048 BEGIN_EVENT_TABLE( a2dTransDlg, wxDialog )
00049 EVT_BUTTON( ID_hide, a2dTransDlg::OnHideClick )
00050 EVT_BUTTON( ID_apply, a2dTransDlg::OnApplyClick )
00051 END_EVENT_TABLE()
00052
00053
00054
00055
00056
00057 a2dTransDlg::a2dTransDlg()
00058 {
00059 Init();
00060 }
00061
00062 a2dTransDlg::a2dTransDlg( wxWindow* parent, bool modal, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00063 {
00064 m_modal = modal;
00065 Init();
00066 Create(parent, id, caption, pos, size, style);
00067 }
00068
00069
00070
00071
00072
00073 bool a2dTransDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00074 {
00075 SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
00076 wxDialog::Create( parent, id, caption, pos, size, style );
00077
00078 CreateControls();
00079 if (GetSizer())
00080 {
00081 GetSizer()->SetSizeHints(this);
00082 }
00083 Centre();
00084 return true;
00085 }
00086
00087
00088
00089
00090
00091 a2dTransDlg::~a2dTransDlg()
00092 {
00093 }
00094
00095
00096
00097
00098
00099 void a2dTransDlg::Init()
00100 {
00101 m_x = NULL;
00102 m_y = NULL;
00103 m_scalex = NULL;
00104 m_scaley = NULL;
00105 m_vertical = NULL;
00106 m_horizontal = NULL;
00107 m_rotateangle = NULL;
00108 m_clockwise = NULL;
00109 m_counterclockwise = NULL;
00110 m_hide = NULL;
00111 m_apply = NULL;
00112 }
00113
00114 void a2dTransDlg::CreateControls()
00115 {
00116 a2dTransDlg* itemDialog1 = this;
00117
00118 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
00119 itemDialog1->SetSizer(itemBoxSizer2);
00120
00121 wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Move (x,y)"));
00122 wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL);
00123 itemBoxSizer2->Add(itemStaticBoxSizer3, 0, wxALIGN_LEFT|wxALL, 2);
00124
00125 m_x = new wxTextCtrl( itemDialog1, ID_x, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
00126 m_x->SetHelpText(_("Move by x"));
00127 if (a2dTransDlg::ShowToolTips())
00128 m_x->SetToolTip(_("Move by x"));
00129 m_x->SetName(_T("x"));
00130 itemStaticBoxSizer3->Add(m_x, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2);
00131
00132 m_y = new wxTextCtrl( itemDialog1, ID_y, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
00133 m_y->SetHelpText(_("Move by y"));
00134 if (a2dTransDlg::ShowToolTips())
00135 m_y->SetToolTip(_("Move by y"));
00136 m_y->SetName(_T("y"));
00137 itemStaticBoxSizer3->Add(m_y, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2);
00138
00139 wxStaticBox* itemStaticBoxSizer6Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Scale (x,y)"));
00140 wxStaticBoxSizer* itemStaticBoxSizer6 = new wxStaticBoxSizer(itemStaticBoxSizer6Static, wxVERTICAL);
00141 itemBoxSizer2->Add(itemStaticBoxSizer6, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
00142
00143 m_scalex = new wxTextCtrl( itemDialog1, ID_scalex, _("1"), wxDefaultPosition, wxDefaultSize, 0 );
00144 m_scalex->SetHelpText(_("Scale in x with this value"));
00145 if (a2dTransDlg::ShowToolTips())
00146 m_scalex->SetToolTip(_("Scale in x with this value"));
00147 m_scalex->SetName(_T("scalex"));
00148 itemStaticBoxSizer6->Add(m_scalex, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2);
00149
00150 m_scaley = new wxTextCtrl( itemDialog1, ID_scaley, _("1"), wxDefaultPosition, wxDefaultSize, 0 );
00151 m_scaley->SetHelpText(_("Scale in y with this value"));
00152 if (a2dTransDlg::ShowToolTips())
00153 m_scaley->SetToolTip(_("Scale in y with this value"));
00154 m_scaley->SetName(_T("scaley"));
00155 itemStaticBoxSizer6->Add(m_scaley, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2);
00156
00157 wxStaticBox* itemStaticBoxSizer9Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Mirror"));
00158 wxStaticBoxSizer* itemStaticBoxSizer9 = new wxStaticBoxSizer(itemStaticBoxSizer9Static, wxVERTICAL);
00159 itemBoxSizer2->Add(itemStaticBoxSizer9, 0, wxALIGN_LEFT|wxALL, 2);
00160
00161 m_vertical = new wxCheckBox( itemDialog1, ID_vertical, _("Vertical"), wxDefaultPosition, wxDefaultSize, 0 );
00162 m_vertical->SetValue(false);
00163 m_vertical->SetHelpText(_("Mirror on vertical axis"));
00164 if (a2dTransDlg::ShowToolTips())
00165 m_vertical->SetToolTip(_("Mirror on vertical axis"));
00166 m_vertical->SetName(_T("vertical"));
00167 itemStaticBoxSizer9->Add(m_vertical, 0, wxALIGN_LEFT|wxALL, 2);
00168
00169 m_horizontal = new wxCheckBox( itemDialog1, ID_horizontal, _("Horizontal"), wxDefaultPosition, wxDefaultSize, 0 );
00170 m_horizontal->SetValue(false);
00171 m_horizontal->SetHelpText(_("Mirror the object on horizontal"));
00172 if (a2dTransDlg::ShowToolTips())
00173 m_horizontal->SetToolTip(_("Mirror the object on horizontal"));
00174 m_horizontal->SetName(_T("horizontal"));
00175 itemStaticBoxSizer9->Add(m_horizontal, 0, wxALIGN_LEFT|wxALL, 2);
00176
00177 wxStaticBox* itemStaticBoxSizer12Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Rotate"));
00178 wxStaticBoxSizer* itemStaticBoxSizer12 = new wxStaticBoxSizer(itemStaticBoxSizer12Static, wxVERTICAL);
00179 itemBoxSizer2->Add(itemStaticBoxSizer12, 0, wxALIGN_LEFT|wxALL, 2);
00180
00181 m_rotateangle = new wxTextCtrl( itemDialog1, ID_rotateangle, _("0"), wxDefaultPosition, wxDefaultSize, 0 );
00182 m_rotateangle->SetHelpText(_("Rotate object by this angle"));
00183 if (a2dTransDlg::ShowToolTips())
00184 m_rotateangle->SetToolTip(_("Rotate object by this angle"));
00185 m_rotateangle->SetName(_T("rotateangle"));
00186 itemStaticBoxSizer12->Add(m_rotateangle, 0, wxALIGN_LEFT|wxALL, 2);
00187
00188 m_clockwise = new wxRadioButton( itemDialog1, ID_clockwise, _("Clockwise"), wxDefaultPosition, wxDefaultSize, 0 );
00189 m_clockwise->SetValue(true);
00190 m_clockwise->SetHelpText(_("Rotate clockwise"));
00191 if (a2dTransDlg::ShowToolTips())
00192 m_clockwise->SetToolTip(_("Rotate clockwise"));
00193 m_clockwise->SetName(_T("clockwise"));
00194 itemStaticBoxSizer12->Add(m_clockwise, 0, wxALIGN_LEFT|wxALL, 2);
00195
00196 m_counterclockwise = new wxRadioButton( itemDialog1, ID_counterclockwise, _("Counter clockwise"), wxDefaultPosition, wxDefaultSize, 0 );
00197 m_counterclockwise->SetValue(false);
00198 m_counterclockwise->SetHelpText(_("Rotate clockwise"));
00199 if (a2dTransDlg::ShowToolTips())
00200 m_counterclockwise->SetToolTip(_("Rotate clockwise"));
00201 m_counterclockwise->SetName(_T("counterclockwise"));
00202 itemStaticBoxSizer12->Add(m_counterclockwise, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 2);
00203
00204 wxBoxSizer* itemBoxSizer16 = new wxBoxSizer(wxHORIZONTAL);
00205 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
00206
00207 if ( !m_modal )
00208 {
00209 m_hide = new wxButton( itemDialog1, ID_hide, _("Hide"), wxDefaultPosition, wxSize(50, -1), 0 );
00210 m_hide->SetHelpText(_("Hide this dialog"));
00211 if (a2dTransDlg::ShowToolTips())
00212 m_hide->SetToolTip(_("Hide this dialog"));
00213 m_hide->SetName(_T("hide"));
00214 itemBoxSizer16->Add(m_hide, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
00215
00216 m_apply = new wxButton( itemDialog1, ID_apply, _("Apply"), wxDefaultPosition, wxSize(50, -1), 0 );
00217 m_apply->SetHelpText(_("Apply transform"));
00218 if (a2dTransDlg::ShowToolTips())
00219 m_apply->SetToolTip(_("Apply transform"));
00220 m_apply->SetName(_T("apply"));
00221 itemBoxSizer16->Add(m_apply, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
00222 }
00223 else
00224 {
00225 m_hide = new wxButton( itemDialog1, ID_hide, _("Cancel"), wxDefaultPosition, wxSize(50, -1), 0 );
00226 m_hide->SetHelpText(_("Cancel this action"));
00227 if (a2dTransDlg::ShowToolTips())
00228 m_hide->SetToolTip(_("Cancel this dialog"));
00229 m_hide->SetName(_T("hide"));
00230
00231 itemBoxSizer16->Add(m_hide, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
00232 m_apply = new wxButton( itemDialog1, ID_apply, _("Oke"), wxDefaultPosition, wxSize(50, -1), 0 );
00233 m_apply->SetHelpText(_("Apply transform"));
00234 if (a2dTransDlg::ShowToolTips())
00235 m_apply->SetToolTip(_("Apply transform"));
00236 m_apply->SetName(_T("apply"));
00237 itemBoxSizer16->Add(m_apply, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
00238 }
00239 }
00240
00241
00242
00243
00244 bool a2dTransDlg::ShowToolTips()
00245 {
00246 return true;
00247 }
00248
00249
00250
00251
00252 void a2dTransDlg::OnHideClick( wxCommandEvent& event )
00253 {
00254 if ( m_modal )
00255 {
00256 EndModal(wxID_CANCEL );
00257 }
00258 else
00259 Show( false );
00260 }
00261
00262
00263
00264
00265 void a2dTransDlg::OnApplyClick( wxCommandEvent& event )
00266 {
00267 m_lworld = a2dIDENTITY_MATRIX;
00268 m_lworld.Mirror( m_vertical->GetValue(), m_horizontal->GetValue() );
00269
00270 double x = 0;
00271 m_x->GetValue().ToDouble( &x );
00272 double y = 0;
00273 m_y->GetValue().ToDouble( &y );
00274 m_lworld.Translate(x,y);
00275
00276 double rotate = 0;
00277 m_rotateangle->GetValue().ToDouble( &rotate );
00278 if ( m_clockwise->GetValue() )
00279 rotate = -rotate;
00280 m_lworld = m_lworld.Rotate( rotate, 0, 0 );
00281
00282 double scalex = 1;
00283 m_scalex->GetValue().ToDouble( &scalex );
00284 double scaley = 1;
00285 m_scaley->GetValue().ToDouble( &scaley );
00286 m_lworld.Scale( scalex, scaley, x, y );
00287
00288 if ( m_modal )
00289 {
00290 EndModal(wxID_OK);
00291 }
00292 else
00293 {
00294 a2dCommand_TransformMask* com = new a2dCommand_TransformMask( m_lworld );
00295 a2dGetCmdh()->Submit( com );
00296 }
00297 }
00298