00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "../../../include/Grafico2D/FinestraOpzioni2D/DlgOpzioni.h"
00010
00011
00012
00013
00014
00016 #include "../../../icons/DlgOpzioni_XPM.xpm"
00018
00019
00020
00021
00022
00023
00024
00025
00027 BEGIN_EVENT_TABLE(DlgOpzioni,wxDialog)
00030
00031 EVT_CLOSE(DlgOpzioni::DlgOpzioniClose)
00032 EVT_BUTTON(ID_BTNOK,DlgOpzioni::BtnOkClick1)
00033 EVT_BUTTON(ID_BTNANNULLA,DlgOpzioni::BtnAnnullaClick)
00034 EVT_BUTTON(ID_BTNMODIFICA,DlgOpzioni::BtnModificaClick)
00035 EVT_BUTTON(ID_BTNINSERISCI,DlgOpzioni::BtnInserisciClick)
00036 EVT_BUTTON(ID_BTNCLRGRAFICO,DlgOpzioni::BtnClrGraficoClick)
00037 EVT_LISTBOX(ID_LSTFUNZIONI,DlgOpzioni::LstFunzioniEnter)
00038 EVT_BUTTON(ID_BTNRIMUOVI,DlgOpzioni::BtnRimuoviClick)
00039 EVT_BUTTON(ID_BTNCLRSFONDO,DlgOpzioni::BtnClrSfondoClick)
00040 END_EVENT_TABLE()
00042
00043
00044
00045 DlgOpzioni::DlgOpzioni( wxWindow *parent,OpzGrafico* opzioni, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
00046 : wxDialog( parent, id, title, position, size, style)
00047 {
00048 wxString str;
00049
00050 OpzioniPadre=opzioni;
00051 Padre=(wxPanel*)parent;
00052
00053 CreateGUIControls();
00054 AggiornaList();
00055
00056 str.Printf(_T("%f"),OpzioniPadre->xmin);
00057 this->EdtXMin->WriteText(str);
00058 str.Printf(_T("%f"),OpzioniPadre->xmax);
00059 this->EdtXMax->WriteText(str);
00060 str.Printf(_T("%f"),OpzioniPadre->ymin);
00061 this->EdtYMin->WriteText(str);
00062 str.Printf(_T("%f"),OpzioniPadre->ymax);
00063 this->EdtYMax->WriteText(str);
00064
00065 this->ChkXVis->SetValue(OpzioniPadre->xaxis);
00066 this->ChkYVis->SetValue(OpzioniPadre->yaxis);
00067 str.Printf(_T("%d"),OpzioniPadre->nstepsx);
00068 this->EdtNTacX->WriteText(str);
00069 str.Printf(_T("%d"),OpzioniPadre->nstepsy);
00070 this->EdtNTacY->WriteText(str);
00071 str.Printf(_T("%d"),OpzioniPadre->height);
00072 this->EdtAltezza->WriteText(str);
00073 str.Printf(_T("%d"),OpzioniPadre->width);
00074 this->EdtLarghezza->WriteText(str);
00075 this->ChkVisTaccheX->SetValue(OpzioniPadre->showstepsx);
00076 this->ChkVisTaccheY->SetValue(OpzioniPadre->showstepsy);
00077 }
00078
00079 DlgOpzioni::~DlgOpzioni()
00080 {}
00081
00082 void DlgOpzioni::CreateGUIControls(void)
00083 {
00084
00085
00086
00087
00089
00090 WxNotebook1 = new wxNotebook(this, ID_WXNOTEBOOK1, wxPoint(1,8),wxSize(443,421) );
00091
00092 WxNoteBookPage1 = new wxPanel(WxNotebook1, ID_WXNOTEBOOKPAGE1,wxPoint(4,24));
00093 WxNotebook1->AddPage(WxNoteBookPage1,_("Proprietà Generali"));
00094
00095 LblClrSfondo = new wxTextCtrl(WxNoteBookPage1, ID_LBLCLRSFONDO ,_T("") ,wxPoint(97,265),wxSize(30,21) , wxSIMPLE_BORDER| wxTE_READONLY);
00096 LblClrSfondo->SetBackgroundColour(wxColour(*wxWHITE));
00097
00098 BtnClrSfondo = new wxButton(WxNoteBookPage1, ID_BTNCLRSFONDO, _("Modifica") , wxPoint(127,265));
00099
00100 WxYBox = new wxStaticBox(WxNoteBookPage1, ID_WXYBOX,_("Asse Y"),wxPoint(210,5),wxSize(204,252) );
00101
00102 ChkYGrid = new wxCheckBox(WxNoteBookPage1, ID_CHKYGRID, _("Griglia Y") , wxPoint(235,99) );
00103
00104 ChkYVis = new wxCheckBox(WxNoteBookPage1, ID_CHKYVIS, _("Visualizza Asse Ordinate") , wxPoint(234,129));
00105
00106 WxStaticText2 = new wxStaticText(WxNoteBookPage1, ID_WXSTATICTEXT2 ,_("Numero Celle") ,wxPoint(236,194) );
00107
00108 LblYMin = new wxStaticText(WxNoteBookPage1, ID_WXSTATICTEXT8 ,_("Y Min") ,wxPoint(235,31));
00109
00110 LblYMax = new wxStaticText(WxNoteBookPage1, ID_WXSTATICTEXT9 ,_("Y Max") ,wxPoint(235,66));
00111
00112 EdtYMin = new wxTextCtrl(WxNoteBookPage1, ID_EDTYMIN, _("") , wxPoint(283,31),wxSize(97,21) );
00113 EdtYMin->SetMaxLength(0);
00114
00115 EdtYMax = new wxTextCtrl(WxNoteBookPage1, ID_EDTYMAX, _("") , wxPoint(283,62),wxSize(97,21) );
00116 EdtYMax->SetMaxLength(0);
00117
00118
00119 EdtNTacY = new wxTextCtrl(WxNoteBookPage1, ID_EDTNTACY, _("") , wxPoint(235,217),wxSize(37,21) );
00120 EdtNTacY->SetMaxLength(0);
00121
00122 WxStaticText5 = new wxStaticText(WxNoteBookPage1, ID_WXSTATICTEXT5 ,_("ColoreSfondo") ,wxPoint(4,268) );
00123
00124 WxStaticText6 = new wxStaticText(WxNoteBookPage1, ID_WXSTATICTEXT6 ,_("Larghezza Grafico") ,wxPoint(4,306));
00125
00126 WxStaticText7 = new wxStaticText(WxNoteBookPage1, ID_WXSTATICTEXT7 ,_("Altezza Grafico") ,wxPoint(4,337));
00127
00128 EdtAltezza = new wxTextCtrl(WxNoteBookPage1, ID_WXEDIT2, _("") , wxPoint(128,332) );
00129 EdtAltezza->SetMaxLength(0);
00130
00131 EdtLarghezza = new wxTextCtrl(WxNoteBookPage1, ID_EDTLARGHEZZA, _("") , wxPoint(128,305));
00132 EdtLarghezza->SetMaxLength(0);
00133
00134 WxStaticBox1 = new wxStaticBox(WxNoteBookPage1, ID_WXSTATICBOX1,_("Asse Y"),wxPoint(1,5),wxSize(204,252) );
00135
00136 LblXTacche = new wxStaticText(WxNoteBookPage1, ID_LBLXTACCHE ,_("Numero Celle") ,wxPoint(8,193) );
00137
00138 ChkXGrid = new wxCheckBox(WxNoteBookPage1, ID_CHKXGRID, _("Griglia X") , wxPoint(8,98) );
00139
00140 ChkXVis = new wxCheckBox(WxNoteBookPage1, ID_CHKXVIS, _("Visualizza Asse Ascissa") , wxPoint(8,127));
00141
00142 LblXMax = new wxStaticText(WxNoteBookPage1, ID_LBLXMAX ,_("X Max") ,wxPoint(9,66));
00143
00144 EdtXMax = new wxTextCtrl(WxNoteBookPage1, ID_EDTXMAX, _("") , wxPoint(70,62),wxSize(97,21) );
00145 EdtXMax->SetMaxLength(0);
00146
00147 EdtXMin = new wxTextCtrl(WxNoteBookPage1, ID_EDTXMIN, _("") , wxPoint(70,29),wxSize(97,21) );
00148 EdtXMin->SetMaxLength(0);
00149
00150 LblXMin = new wxStaticText(WxNoteBookPage1, ID_LBLXMIN ,_("X Min") ,wxPoint(9,29) );
00151
00152 EdtNTacX = new wxTextCtrl(WxNoteBookPage1, ID_EDTNTACX, _("") , wxPoint(8,216),wxSize(37,21) );
00153 EdtNTacX->SetMaxLength(0);
00154
00155 ChkVisTaccheY = new wxCheckBox(WxNoteBookPage1, ID_CHKVISTACCHEY, _("Visualizza Tacche Asse Y") , wxPoint(234,161));
00156
00157 ChkVisTaccheX = new wxCheckBox(WxNoteBookPage1, ID_CHKVISTACCHEX, _("Visualizza Tacche Asse X") , wxPoint(8,158));
00158
00159 WxNoteBookPage2 = new wxPanel(WxNotebook1, ID_WXNOTEBOOKPAGE2,wxPoint(4,24),wxSize(435,393) );
00160 WxNotebook1->AddPage(WxNoteBookPage2,_("Funzioni"));
00161
00162 LblFunzione = new wxStaticText(WxNoteBookPage2, ID_LBLFUNZIONE ,_("Funzioni") ,wxPoint(13,5));
00163
00164 BtnRimuovi = new wxButton(WxNoteBookPage2, ID_BTNRIMUOVI, _("Rimuovi Funzioni Selezionate") , wxPoint(222,239));
00165
00166 LstFunzioni = new wxCheckListBox(WxNoteBookPage2, ID_LSTFUNZIONI ,wxPoint(12,22),wxSize(379,212),0,NULL,wxLB_SINGLE);
00167
00168 WxStaticBox2 = new wxStaticBox(WxNoteBookPage2, ID_WXSTATICBOX2,_("Nuova Funzione"),wxPoint(10,268),wxSize(450,125));
00169
00170 EdtNuovaFx = new wxTextCtrl(WxNoteBookPage2, ID_EDTNUOVAFX, _("") , wxPoint(102,291),wxSize(315,21) );
00171 EdtNuovaFx->SetMaxLength(0);
00172
00173 WxStaticText9 = new wxStaticText(WxNoteBookPage2, ID_WXSTATICTEXT9 ,_("Descrizione") ,wxPoint(17,294));
00174
00175 LblClrGrafico = new wxTextCtrl(WxNoteBookPage2, ID_LBLCLRGRAFICO ,_(" ") ,wxPoint(104,316),wxSize(30,21) ,wxSIMPLE_BORDER|wxTE_READONLY );
00176 LblClrGrafico->SetBackgroundColour(*wxRED);
00177
00178 BtnClrGrafico = new wxButton(WxNoteBookPage2, ID_BTNCLRGRAFICO, _("Cambia Colore") , wxPoint(134,316));
00179
00180 WxStaticText1 = new wxStaticText(WxNoteBookPage2, ID_WXSTATICTEXT1 ,_("Colore") ,wxPoint(17,321) );
00181
00182 WxStaticText8 = new wxStaticText(WxNoteBookPage2, ID_WXSTATICTEXT8 ,_("Spessore disegno") ,wxPoint(18,355));
00183
00184 wxArrayString arrayStringFor_CmbSpessore;
00185 arrayStringFor_CmbSpessore.Add(_("1"));
00186 arrayStringFor_CmbSpessore.Add(_("2"));
00187 arrayStringFor_CmbSpessore.Add(_("3"));
00188 arrayStringFor_CmbSpessore.Add(_("4"));
00189 arrayStringFor_CmbSpessore.Add(_("5"));
00190 CmbSpessore = new wxComboBox(WxNoteBookPage2, ID_CMBSPESSORE ,_("1") ,wxPoint(139,355),wxSize(49,17) ,arrayStringFor_CmbSpessore );
00191
00192 BtnInserisci = new wxButton(WxNoteBookPage2, ID_BTNINSERISCI, _("Aggiungi") , wxPoint(245,350));
00193
00194 BtnModifica = new wxButton(WxNoteBookPage2, ID_BTNMODIFICA, _("Modifica") , wxPoint(330,350));
00195
00196 BtnAnnulla = new wxButton(this, ID_BTNANNULLA, _("Annulla") , wxPoint(82,440));
00197
00198 BtnOk = new wxButton(this, ID_BTNOK, _("Ok") , wxPoint(8,440));
00199
00200 ClrDlgGrafico = new wxColourDialog(this);
00201
00202 this->SetSize(8,8,457,512);
00203 this->SetTitle(_("Opzioni Grafico 2D"));
00204 this->Center();
00205 wxIcon DlgOpzioni_ICON (DlgOpzioni_XPM);
00206 this->SetIcon(DlgOpzioni_XPM);
00207
00209
00210
00211
00212
00213 LblClrSfondo->SetBackgroundColour(OpzioniPadre->bgcolor);
00214
00215
00216
00217 ChkXGrid->SetValue(OpzioniPadre->xgrid);
00218
00219 ChkYGrid->SetValue(OpzioniPadre->ygrid);
00220 BtnModifica->Enable(0);
00221
00222 }
00223
00224 void DlgOpzioni::DlgOpzioniClose(wxCloseEvent& event)
00225 {
00226
00227
00228 Destroy();
00229 }
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 void DlgOpzioni::BtnClrGraficoClick(wxCommandEvent& event)
00243 {
00244
00245
00246
00247
00248 if(ClrDlgGrafico->ShowModal()==wxID_OK)
00249 {
00250 LblClrGrafico->SetBackgroundColour(ClrDlgGrafico->GetColourData().GetColour());
00251
00252
00253
00254
00255
00256 LblClrGrafico->Refresh();
00257 }
00258
00259 event.Skip();
00260 }
00261
00262
00263
00264
00265
00266 void DlgOpzioni::BtnClrSfondoClick(wxCommandEvent& event)
00267 {
00268
00269
00270 if(ClrDlgGrafico->ShowModal()==wxID_OK)
00271 {
00272 LblClrSfondo->SetBackgroundColour(ClrDlgGrafico->GetColourData().GetColour());
00273 LblClrSfondo->Refresh();
00274
00275 }
00276 event.Skip();
00277 }
00278
00279
00280
00281
00282 void DlgOpzioni::BtnOkClick1(wxCommandEvent& event)
00283 {
00284 int i;
00285 color colore;
00286 wxColour wcolore;
00287
00288 if((atoi(EdtNTacX->GetValue().ToAscii())>0)&&(atoi(EdtNTacY->GetValue().ToAscii())>0)&&(atof(EdtXMin->GetValue().ToAscii())<(atof(EdtXMax->GetValue().ToAscii())))&&(atof(EdtYMin->GetValue().ToAscii())<atof(EdtYMax->GetValue().ToAscii()))&&(atoi(EdtLarghezza->GetValue().ToAscii()))&&(atoi(EdtAltezza->GetValue().ToAscii())))
00289 {
00290 OpzioniPadre->xgrid=ChkXGrid->GetValue();
00291 OpzioniPadre->ygrid=ChkYGrid->GetValue();
00292 OpzioniPadre->xaxis=ChkXVis->GetValue();
00293 OpzioniPadre->yaxis=ChkYVis->GetValue();
00294 OpzioniPadre->nstepsx=atoi(EdtNTacX->GetValue().ToAscii());
00295 OpzioniPadre->nstepsy=atoi(EdtNTacY->GetValue().ToAscii());
00296 OpzioniPadre->showstepsx=ChkVisTaccheX->GetValue();
00297 OpzioniPadre->showstepsy=ChkVisTaccheY->GetValue();
00298
00299 for (i=1;i<=OpzioniPadre->functions.nelements;i++)
00300 {
00301 colore=OpzioniPadre->functions.ExtractColor(i);
00302 wcolore.Set(colore.red,colore.green,colore.blue);
00303
00304 if(this->LstFunzioni->IsChecked(i-1))
00305
00306 OpzioniPadre->functions.ModifyNode(i,wcolore,OpzioniPadre->functions.ExtractFunction(i),OpzioniPadre->functions.ExtractStructure(i),1,OpzioniPadre->functions.ExtractWidth(i));
00307 else
00308 OpzioniPadre->functions.ModifyNode(i,wcolore,OpzioniPadre->functions.ExtractFunction(i),OpzioniPadre->functions.ExtractStructure(i),0,OpzioniPadre->functions.ExtractWidth(i));
00309
00310
00311 }
00312
00313 OpzioniPadre->bgcolor= LblClrSfondo->GetBackgroundColour();
00314
00315
00316 OpzioniPadre->xmin=atof(this->EdtXMin->GetValue().ToAscii());
00317 OpzioniPadre->xmax=atof(this->EdtXMax->GetValue().ToAscii());
00318
00319 OpzioniPadre->ymin=atof(this->EdtYMin->GetValue().ToAscii());
00320 OpzioniPadre->ymax=atof(this->EdtYMax->GetValue().ToAscii());
00321 OpzioniPadre->width=atoi(this->EdtLarghezza->GetValue().ToAscii());
00322 OpzioniPadre->height=atoi(this->EdtAltezza->GetValue().ToAscii());
00323 Padre->Refresh();
00324 this->Destroy();
00325 }
00326 else
00327 {
00328 wxMessageDialog messaggio(this,_T("Inserire correttamente i valori"),_T("Matocad"),wxICON_HAND);
00329 messaggio.ShowModal();
00330 }
00331
00332
00333
00334 event.Skip();
00335 }
00336
00337 void DlgOpzioni::AggiornaList()
00338 {
00339 int i;
00340
00341 LstFunzioni->Clear();
00342 for (i=1;i<=OpzioniPadre->functions.nelements;i++)
00343 {
00344 LstFunzioni->AppendString(wxString(OpzioniPadre->functions.ExtractFunction(i),wxConvUTF8));
00345 if(OpzioniPadre->functions.ExtractDrawFlag(i)==1)
00346 LstFunzioni->Check(i-1,1);
00347 }
00348
00349 }
00350
00351
00352
00353
00354 void DlgOpzioni::BtnInserisciClick(wxCommandEvent& event)
00355 {
00356
00357 rif* pointstructure;
00358 TParserScomponi compila;
00359 char funzione[255];
00360
00361
00362 strcpy(funzione,EdtNuovaFx->GetValue().ToAscii());
00363 pointstructure=compila.Traduci_funzione(funzione);
00364
00365 if(strcmp(funzione,"err")!=0)
00366 {
00367
00368 OpzioniPadre->functions.NewNode( LblClrGrafico->GetBackgroundColour(),funzione,pointstructure,0,atoi(CmbSpessore->GetValue().ToAscii()));
00369 AggiornaList();
00370 }
00371 else
00372 {
00373 wxMessageDialog messaggio(this,_T("Errori di sintassi nella funzione, reinserirla correttamente"),_T("Matocad"),wxICON_HAND);
00374 messaggio.ShowModal();
00375 }
00376
00377 event.Skip();
00378
00379 }
00380
00381
00382
00383
00384
00385 void DlgOpzioni::BtnRimuoviClick(wxCommandEvent& event)
00386 {
00387
00388
00389 int i=1;
00390 int nelements=OpzioniPadre->functions.nelements;
00391
00392
00393
00394 for (i=nelements;i>=1;i--)
00395 {
00396 if(LstFunzioni->IsChecked(i-1))
00397 {
00398 OpzioniPadre->functions.RemoveNode(i);
00399
00400 }
00401 }
00402 AggiornaList();
00403 event.Skip();
00404 }
00405
00406
00407
00408
00409
00410 void DlgOpzioni::BtnModificaClick(wxCommandEvent& event)
00411 {
00412
00413
00414 rif* pointstructure;
00415 TParserScomponi compila;
00416 char funzione[255];
00417 int posizionefunzione=LstFunzioni->GetSelection()+1;
00418
00419
00420
00421
00422 strcpy(funzione,this->EdtNuovaFx->GetLineText(0).ToAscii());
00423 pointstructure=compila.Traduci_funzione(funzione);
00424
00425 if(strcmp(funzione,"err")!=0)
00426 {
00427
00428 BtnModifica->Enable(0);
00429
00430
00431 OpzioniPadre->functions.ModifyNode(posizionefunzione, LblClrGrafico->GetBackgroundColour(),funzione,pointstructure,OpzioniPadre->functions.ExtractDrawFlag(posizionefunzione),atoi(CmbSpessore->GetValue().ToAscii()));
00432 AggiornaList();
00433 }
00434 else
00435 {
00436 wxMessageDialog messaggio(this,_T("Errori di sintassi nella funzione, reinserirla correttamente"),_T("Matocad"),wxICON_HAND);
00437 messaggio.ShowModal();
00438
00439
00440 }
00441 event.Skip();
00442
00443 }
00444
00445
00446
00447
00448
00449
00450
00451
00452 void DlgOpzioni::LstFunzioniEnter(wxCommandEvent& event)
00453 { wxColour wcolore;
00454 color colore;
00455 if(LstFunzioni->GetSelection()<0)
00456 {
00457 BtnModifica->Enable(0);
00458 }
00459 else
00460 { int posfunzione=LstFunzioni->GetSelection()+1;
00461 wxString str;
00462 BtnModifica->Enable(1);
00463 str.Printf(_T("%d"),OpzioniPadre->functions.ExtractWidth(posfunzione));
00464 colore=OpzioniPadre->functions.ExtractColor(posfunzione);
00465 wcolore.Set(colore.red,colore.green,colore.blue);
00466 this->LblClrGrafico->SetBackgroundColour(wcolore);
00467 this->LblClrGrafico->Refresh();
00468 this->CmbSpessore->SetValue(str);
00469 this->CmbSpessore->Refresh();
00470 event.GetSelection();
00471
00472 this->EdtNuovaFx->Clear();
00473 this->EdtNuovaFx->SetValue(LstFunzioni->GetString(posfunzione-1));
00474 }
00475 event.Skip();
00476 }
00477
00478
00479
00480
00481 void DlgOpzioni::BtnAnnullaClick(wxCommandEvent& event)
00482 {
00483
00484 this->Destroy();
00485 event.Skip();
00486 }