Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
optimizedialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  optimizedialog.cpp
3  --------------------
4  begin : Sun Jul 30 2006
5  copyright : (C) 2006 by Michael Margraf
6  email : michael.margraf@alumni.tu-berlin.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #include <QtGui>
18 #ifdef HAVE_CONFIG_H
19 # include <config.h>
20 #endif
21 
22 #include "optimizedialog.h"
23 #include "opt_sim.h"
24 #include "schematic.h"
25 
26 #include <Q3HBox>
27 #include <QLabel>
28 #include <QLayout>
29 #include <QCheckBox>
30 #include <QLineEdit>
31 #include <QComboBox>
32 #include <Q3ListView>
33 #include <QTabWidget>
34 #include <QValidator>
35 #include <QPushButton>
36 #include <QMessageBox>
37 //Added by qt3to4:
38 #include <Q3GridLayout>
39 #include <Q3VBoxLayout>
40 
41 
43  : QDialog(d_, 0, TRUE, Qt::WDestructiveClose)
44 {
45  Comp = c_;
46  Doc = d_;
47  changed = false;
48  setCaption(tr("Edit Optimization Properties"));
49 
50  Expr.setPattern("[\\w_]+");
51  Validator = new QRegExpValidator(Expr, this);
52  numVal = new QDoubleValidator(this);
53  intVal = new QIntValidator(this);
54 
55  all = new Q3VBoxLayout(this); // to provide the neccessary size
56  QTabWidget *t = new QTabWidget(this);
57  all->addWidget(t);
58 
59  // ...........................................................
60  QWidget *Tab1 = new QWidget(t);
61  Q3GridLayout *gp1 = new Q3GridLayout(Tab1,3,2,3,3);
62 
63  gp1->addWidget(new QLabel(tr("Name:"), Tab1), 0,0);
64  NameEdit = new QLineEdit(Tab1);
65  NameEdit->setValidator(Validator);
66  gp1->addWidget(NameEdit,0,1);
67 
68  gp1->addWidget(new QLabel(tr("Simulation:"), Tab1), 1,0);
69  SimEdit = new QComboBox(Tab1);
70  SimEdit->setEditable(true);
71  gp1->addWidget(SimEdit,1,1);
72 
73  t->addTab(Tab1, tr("General"));
74 
75  // ...........................................................
76  QWidget *Tab4 = new QWidget(t);
77  Q3GridLayout *gp4 = new Q3GridLayout(Tab4,11,2,3,3);
78 
79  gp4->addWidget(new QLabel(tr("Method:"), Tab4), 0,0);
80  MethodCombo = new QComboBox(Tab4);
81  MethodCombo->insertItem("DE/best/1/exp");
82  MethodCombo->insertItem("DE/rand/1/exp");
83  MethodCombo->insertItem("DE/rand-to-best/1/exp");
84  MethodCombo->insertItem("DE/best/2/exp");
85  MethodCombo->insertItem("DE/rand/1/exp");
86  MethodCombo->insertItem("DE/best/1/bin");
87  MethodCombo->insertItem("DE/rand/1/bin");
88  MethodCombo->insertItem("DE/rand-to-best/1/bin");
89  MethodCombo->insertItem("DE/best/2/bin");
90  MethodCombo->insertItem("DE/rand/2/bin");
91  gp4->addWidget(MethodCombo,0,1);
92 
93  gp4->addWidget(new QLabel(tr("Maximum number of iterations:"), Tab4), 1,0);
94  IterEdit = new QLineEdit(Tab4);
95  IterEdit->setValidator(intVal);
96  gp4->addWidget(IterEdit,1,1);
97 
98  gp4->addWidget(new QLabel(tr("Output refresh cycle:"), Tab4), 2,0);
99  RefreshEdit = new QLineEdit(Tab4);
100  RefreshEdit->setValidator(intVal);
101  gp4->addWidget(RefreshEdit,2,1);
102 
103  gp4->addWidget(new QLabel(tr("Number of parents:"), Tab4), 3,0);
104  ParentsEdit = new QLineEdit(Tab4);
105  ParentsEdit->setValidator(intVal);
106  gp4->addWidget(ParentsEdit,3,1);
107 
108  gp4->addWidget(new QLabel(tr("Constant F:"), Tab4), 4,0);
109  ConstEdit = new QLineEdit(Tab4);
110  ConstEdit->setValidator(new QDoubleValidator(0.0,2.0,20,ConstEdit));
111  gp4->addWidget(ConstEdit,4,1);
112 
113  gp4->addWidget(new QLabel(tr("Crossing over factor:"), Tab4), 5,0);
114  CrossEdit = new QLineEdit(Tab4);
115  CrossEdit->setValidator(new QDoubleValidator(0.0,1.0,20,CrossEdit));
116  gp4->addWidget(CrossEdit,5,1);
117 
118  gp4->addWidget(new QLabel(tr("Pseudo random number seed:"), Tab4), 6,0);
119  SeedEdit = new QLineEdit(Tab4);
120  SeedEdit->setValidator(numVal);
121  gp4->addWidget(SeedEdit,6,1);
122 
123  gp4->addWidget(new QLabel(tr("Minimum cost variance:"), Tab4), 7,0);
124  CostVarEdit = new QLineEdit(Tab4);
125  CostVarEdit->setValidator(numVal);
126  gp4->addWidget(CostVarEdit,7,1);
127 
128  gp4->addWidget(new QLabel(tr("Cost objectives:"), Tab4), 8,0);
129  CostObjEdit = new QLineEdit(Tab4);
130  CostObjEdit->setValidator(numVal);
131  gp4->addWidget(CostObjEdit,8,1);
132 
133  gp4->addWidget(new QLabel(tr("Cost constraints:"), Tab4), 9,0);
134  CostConEdit = new QLineEdit(Tab4);
135  CostConEdit->setValidator(numVal);
136  gp4->addWidget(CostConEdit,9,1);
137 
138  t->addTab(Tab4, tr("Algorithm"));
139 
140  // ...........................................................
141  QWidget *Tab2 = new QWidget(t);
142  Q3GridLayout *gp2 = new Q3GridLayout(Tab2,5,3,3,3);
143 
144  VarList = new Q3ListView(Tab2);
145  VarList->addColumn(tr("Name"));
146  VarList->addColumn(tr("active"));
147  VarList->addColumn(tr("initial"));
148  VarList->addColumn(tr("min"));
149  VarList->addColumn(tr("max"));
150  VarList->addColumn(tr("Type"));
151  VarList->setSorting(-1); // no sorting
152  gp2->addMultiCellWidget(VarList,0,0,0,2);
153  connect(VarList, SIGNAL(selectionChanged(Q3ListViewItem*)),
154  SLOT(slotEditVariable(Q3ListViewItem*)));
155 
156  Q3HBox *VarLine = new Q3HBox(Tab2);
157  VarLine->setSpacing(3);
158  gp2->addMultiCellWidget(VarLine, 1,1,0,2);
159 
160  new QLabel(tr("Name:"), VarLine);
161  VarNameEdit = new QLineEdit(VarLine);
162  VarNameEdit->setValidator(Validator);
163  connect(VarNameEdit, SIGNAL(textChanged(const QString&)),
164  SLOT(slotChangeVarName(const QString&)));
165  VarActiveCheck = new QCheckBox(tr("active"), VarLine);
166  VarActiveCheck->setChecked(true);
167  connect(VarActiveCheck, SIGNAL(toggled(bool)),
168  SLOT(slotChangeVarActive(bool)));
169 
170  gp2->addWidget(new QLabel(tr("initial:"), Tab2), 2,0);
171  gp2->addWidget(new QLabel(tr("min:"), Tab2), 2,1);
172  gp2->addWidget(new QLabel(tr("max:"), Tab2), 2,2);
173  VarInitEdit = new QLineEdit(Tab2);
174  VarInitEdit->setValidator(numVal);
175  gp2->addWidget(VarInitEdit,3,0);
176  connect(VarInitEdit, SIGNAL(textChanged(const QString&)),
177  SLOT(slotChangeVarInit(const QString&)));
178  VarMinEdit = new QLineEdit(Tab2);
179  VarMinEdit->setValidator(numVal);
180  gp2->addWidget(VarMinEdit,3,1);
181  connect(VarMinEdit, SIGNAL(textChanged(const QString&)),
182  SLOT(slotChangeVarMin(const QString&)));
183  VarMaxEdit = new QLineEdit(Tab2);
184  VarMaxEdit->setValidator(numVal);
185  gp2->addWidget(VarMaxEdit,3,2);
186  connect(VarMaxEdit, SIGNAL(textChanged(const QString&)),
187  SLOT(slotChangeVarMax(const QString&)));
188 
189  Q3HBox *VarButtons = new Q3HBox(Tab2);
190  VarButtons->setSpacing(3);
191  gp2->addMultiCellWidget(VarButtons, 4,4,0,2);
192 
193  new QLabel(tr("Type:"), VarButtons);
194  VarTypeCombo = new QComboBox(VarButtons);
195  VarTypeCombo->insertItem(tr("linear double"));
196  VarTypeCombo->insertItem(tr("logarithmic double"));
197  VarTypeCombo->insertItem(tr("linear integer"));
198  VarTypeCombo->insertItem(tr("logarithmic integer"));
199  connect(VarTypeCombo, SIGNAL(activated(const QString&)),
200  SLOT(slotChangeVarType(const QString&)));
201 
202  VarButtons->setStretchFactor(new QWidget(VarButtons), 10);
203  QPushButton *AddVar_Butt = new QPushButton(tr("Add"), VarButtons);
204  connect(AddVar_Butt, SIGNAL(clicked()), SLOT(slotAddVariable()));
205  QPushButton *DelVar_Butt = new QPushButton(tr("Delete"), VarButtons);
206  connect(DelVar_Butt, SIGNAL(clicked()), SLOT(slotDeleteVariable()));
207 
208  t->addTab(Tab2, tr("Variables"));
209 
210  // ...........................................................
211  QWidget *Tab3 = new QWidget(t);
212  Q3GridLayout *gp3 = new Q3GridLayout(Tab3,4,3,3,3);
213 
214  GoalList = new Q3ListView(Tab3);
215  GoalList->addColumn(tr("Name"));
216  GoalList->addColumn(tr("Type"));
217  GoalList->addColumn(tr("Value"));
218  GoalList->setSorting(-1); // no sorting
219  gp3->addMultiCellWidget(GoalList,0,0,0,2);
220  connect(GoalList, SIGNAL(selectionChanged(Q3ListViewItem*)),
221  SLOT(slotEditGoal(Q3ListViewItem*)));
222 
223  gp3->addWidget(new QLabel(tr("Name:"), Tab3), 1,0);
224  GoalNameEdit = new QLineEdit(Tab3);
225  GoalNameEdit->setValidator(Validator);
226  gp3->addWidget(GoalNameEdit,1,1);
227  connect(GoalNameEdit, SIGNAL(textChanged(const QString&)),
228  SLOT(slotChangeGoalName(const QString&)));
229 
230  gp3->addWidget(new QLabel(tr("Value:"), Tab3), 2,0);
231  GoalNumEdit = new QLineEdit(Tab3);
232  GoalNumEdit->setValidator(numVal);
233  gp3->addWidget(GoalNumEdit,2,1);
234  connect(GoalNumEdit, SIGNAL(textChanged(const QString&)),
235  SLOT(slotChangeGoalNum(const QString&)));
236 
237  GoalTypeCombo = new QComboBox(Tab3);
238  GoalTypeCombo->insertItem(tr("minimize"));
239  GoalTypeCombo->insertItem(tr("maximize"));
240  GoalTypeCombo->insertItem(tr("less"));
241  GoalTypeCombo->insertItem(tr("greater"));
242  GoalTypeCombo->insertItem(tr("equal"));
243  GoalTypeCombo->insertItem(tr("monitor"));
244  gp3->addWidget(GoalTypeCombo,2,2);
245  connect(GoalTypeCombo, SIGNAL(activated(const QString&)),
246  SLOT(slotChangeGoalType(const QString&)));
247 
248  Q3HBox *GoalButtons = new Q3HBox(Tab3);
249  GoalButtons->setSpacing(3);
250  gp3->addMultiCellWidget(GoalButtons, 3,3,0,2);
251 
252  GoalButtons->setStretchFactor(new QWidget(GoalButtons),5);
253  QPushButton *AddGoal_Butt = new QPushButton(tr("Add"), GoalButtons);
254  connect(AddGoal_Butt, SIGNAL(clicked()), SLOT(slotAddGoal()));
255  QPushButton *DelGoal_Butt = new QPushButton(tr("Delete"), GoalButtons);
256  connect(DelGoal_Butt, SIGNAL(clicked()), SLOT(slotDeleteGoal()));
257 
258  t->addTab(Tab3, tr("Goals"));
259 
260  // ...........................................................
261  // buttons on the bottom of the dialog (independent of the TabWidget)
262  Q3HBox *Butts = new Q3HBox(this);
263  Butts->setSpacing(3);
264  Butts->setMargin(3);
265  all->addWidget(Butts);
266 
267  QPushButton *OkButt = new QPushButton(tr("OK"), Butts);
268  connect(OkButt, SIGNAL(clicked()), SLOT(slotOK()));
269  QPushButton *ApplyButt = new QPushButton(tr("Apply"), Butts);
270  connect(ApplyButt, SIGNAL(clicked()), SLOT(slotApply()));
271  QPushButton *CancelButt = new QPushButton(tr("Cancel"), Butts);
272  connect(CancelButt, SIGNAL(clicked()), SLOT(slotCancel()));
273 
274  OkButt->setFocus();
275 
276  // ...........................................................
277 
278  Component *pc;
279  for(pc=Doc->Components->first(); pc!=0; pc=Doc->Components->next())
280  if(pc != Comp)
281  if(pc->Model[0] == '.' && pc->Model != ".Opt")
282  SimEdit->insertItem(pc->Name);
283 
284  Property *pp;
285  pp = Comp->Props.at(0);
286  if(!pp->Value.isEmpty())
287  SimEdit->setCurrentText(pp->Value);
288 
289  pp = Comp->Props.at(1);
290  if(!pp->Value.isEmpty()) {
291  MethodCombo->setCurrentItem(pp->Value.section('|',0,0).toInt()-1);
292  IterEdit->setText(pp->Value.section('|',1,1));
293  RefreshEdit->setText(pp->Value.section('|',2,2));
294  ParentsEdit->setText(pp->Value.section('|',3,3));
295  ConstEdit->setText(pp->Value.section('|',4,4));
296  CrossEdit->setText(pp->Value.section('|',5,5));
297  SeedEdit->setText(pp->Value.section('|',6,6));
298  CostVarEdit->setText(pp->Value.section('|',7,7));
299  CostObjEdit->setText(pp->Value.section('|',8,8));
300  CostConEdit->setText(pp->Value.section('|',9,9));
301  }
302 
303  NameEdit->setText(Comp->Name);
304 
305  for(pp = Comp->Props.at(2); pp != 0; pp = Comp->Props.next()) {
306  if(pp->Name == "Var") {
307  new Q3ListViewItem(VarList, pp->Value.section('|',0,0),
308  pp->Value.section('|',1,1) == "yes" ? tr("yes") : tr("no"),
309  pp->Value.section('|',2,2),
310  pp->Value.section('|',3,3), pp->Value.section('|',4,4),
311  ((pp->Value.section('|',5,5)=="LIN_DOUBLE")?tr("linear double") :
312  ((pp->Value.section('|',5,5)=="LOG_DOUBLE")?tr("logarithmic double") :
313  ((pp->Value.section('|',5,5)=="LIN_INT")?tr("linear integer") :
314  tr("logarithmic integer")))));
315  }
316  if(pp->Name == "Goal") {
317  new Q3ListViewItem(GoalList, pp->Value.section('|',0,0),
318  ((pp->Value.section('|',1,1) == "MIN") ? tr("minimize") :
319  ((pp->Value.section('|',1,1) == "MAX") ? tr("maximize") :
320  ((pp->Value.section('|',1,1) == "LE") ? tr("less") :
321  ((pp->Value.section('|',1,1) == "GE") ? tr("greater") :
322  ((pp->Value.section('|',1,1) == "EQ") ? tr("equal") :
323  tr("monitor")))))),
324  pp->Value.section('|',2,2));
325  }
326  }
327 
328  resize(300, 250);
329 }
330 
332 {
333  delete all;
334  delete numVal;
335  delete intVal;
336  delete Validator;
337 }
338 
339 // -----------------------------------------------------------
340 void OptimizeDialog::slotEditVariable(Q3ListViewItem *Item)
341 {
342  VarNameEdit->blockSignals(true);
343 
344  if(Item == 0) {
345  VarNameEdit->clear();
346  VarActiveCheck->setChecked(true);
347  VarInitEdit->clear();
348  VarMinEdit->clear();
349  VarMaxEdit->clear();
350  VarTypeCombo->setCurrentItem(0);
351  VarNameEdit->blockSignals(false);
352  return;
353  }
354 
355  VarNameEdit->setText(Item->text(0));
356  VarActiveCheck->setChecked(Item->text(1) == tr("yes"));
357  VarInitEdit->setText(Item->text(2));
358  VarMinEdit->setText(Item->text(3));
359  VarMaxEdit->setText(Item->text(4));
360  VarTypeCombo->setCurrentText(Item->text(5));
361  VarNameEdit->blockSignals(false);
362 }
363 
364 // -----------------------------------------------------------
366 {
367  if(VarNameEdit->text().isEmpty() || VarInitEdit->text().isEmpty() ||
368  VarMinEdit->text().isEmpty() || VarMaxEdit->text().isEmpty()) {
369  QMessageBox::critical(this, tr("Error"),
370  tr("Every text field must be non-empty!"));
371  return;
372  }
373 
374  Q3ListViewItem *item;
375  for(item = VarList->firstChild(); item != 0; item = item->itemBelow())
376  if(item->text(0) == VarNameEdit->text()) {
377  QMessageBox::critical(this, tr("Error"),
378  tr("Variable \"%1\" already in list!").arg(VarNameEdit->text()));
379  return;
380  }
381 
382 
383  new Q3ListViewItem(VarList, VarNameEdit->text(),
384  VarActiveCheck->isChecked() ? tr("yes") : tr("no"),
385  VarInitEdit->text(), VarMinEdit->text(), VarMaxEdit->text(),
386  VarTypeCombo->currentText());
387 
388  slotEditVariable(0); // clear entry fields
389  VarList->clearSelection();
390 }
391 
392 // -----------------------------------------------------------
394 {
395  Q3ListViewItem *next_item = 0;
396 
397  Q3ListViewItem *Item = VarList->selectedItem();
398  if(Item) {
399  next_item = Item->itemBelow();
400  if(next_item == 0) next_item = Item->itemAbove();
401  VarList->takeItem(Item); // remove from ListView
402  delete Item; // delete item
403  }
404 
405  slotEditVariable(next_item);
406 }
407 
408 // -----------------------------------------------------------
410 {
411  Q3ListViewItem *Item = VarList->selectedItem();
412  if(Item == 0) return;
413 
414  Item->setText(1, On ? tr("yes") : tr("no"));
415 }
416 
417 // -----------------------------------------------------------
419 {
420  VarList->clearSelection();
421 }
422 
423 // -----------------------------------------------------------
425 {
426  Q3ListViewItem *Item = VarList->selectedItem();
427  if(Item == 0) return;
428 
429  Item->setText(2, Text);
430 }
431 
432 // -----------------------------------------------------------
434 {
435  Q3ListViewItem *Item = VarList->selectedItem();
436  if(Item == 0) return;
437 
438  Item->setText(3, Text);
439 }
440 
441 // -----------------------------------------------------------
443 {
444  Q3ListViewItem *Item = VarList->selectedItem();
445  if(Item == 0) return;
446 
447  Item->setText(4, Text);
448 }
449 
450 // -----------------------------------------------------------
452 {
453  Q3ListViewItem *Item = VarList->selectedItem();
454  if(Item == 0) return;
455 
456  Item->setText(5, Text);
457 }
458 
459 // -----------------------------------------------------------
460 void OptimizeDialog::slotEditGoal(Q3ListViewItem *Item)
461 {
462  GoalNameEdit->blockSignals(true);
463 
464  if(Item == 0) {
465  GoalNameEdit->clear();
466  GoalTypeCombo->setCurrentItem(0);
467  GoalNumEdit->clear();
468  GoalNameEdit->blockSignals(false);
469  return;
470  }
471 
472  GoalNameEdit->setText(Item->text(0));
473  GoalTypeCombo->setCurrentText(Item->text(1));
474  GoalNumEdit->setText(Item->text(2));
475  GoalNameEdit->blockSignals(false);
476 }
477 
478 // -----------------------------------------------------------
480 {
481  if(GoalNameEdit->text().isEmpty() || GoalNumEdit->text().isEmpty()) {
482  QMessageBox::critical(this, tr("Error"),
483  tr("Every text field must be non-empty!"));
484  return;
485  }
486 
487  Q3ListViewItem *item;
488  for(item = GoalList->firstChild(); item != 0; item = item->itemBelow())
489  if(item->text(0) == GoalNameEdit->text()) {
490  QMessageBox::critical(this, tr("Error"),
491  tr("Goal \"%1\" already in list!").arg(GoalNameEdit->text()));
492  return;
493  }
494 
495 
496  new Q3ListViewItem(GoalList, GoalNameEdit->text(),
497  GoalTypeCombo->currentText(), GoalNumEdit->text());
498 
499  slotEditGoal(0); // clear entry fields
500  GoalList->clearSelection();
501 }
502 
503 // -----------------------------------------------------------
505 {
506  Q3ListViewItem *next_item = 0;
507 
508  Q3ListViewItem *Item = GoalList->selectedItem();
509  if(Item) {
510  next_item = Item->itemBelow();
511  if(next_item == 0) next_item = Item->itemAbove();
512  GoalList->takeItem(Item); // remove from ListView
513  delete Item; // delete item
514  }
515 
516  slotEditGoal(next_item);
517 }
518 
519 // -----------------------------------------------------------
521 {
522  GoalList->clearSelection();
523 }
524 
525 // -----------------------------------------------------------
527 {
528  Q3ListViewItem *Item = GoalList->selectedItem();
529  if(Item == 0) return;
530 
531  Item->setText(1, Text);
532 }
533 
534 // -----------------------------------------------------------
536 {
537  Q3ListViewItem *Item = GoalList->selectedItem();
538  if(Item == 0) return;
539 
540  Item->setText(2, Text);
541 }
542 
543 // -----------------------------------------------------------
545 {
546  slotApply();
547  slotCancel();
548 }
549 
550 // -----------------------------------------------------------
552 {
553  Component *pc;
554  if(NameEdit->text().isEmpty())
555  NameEdit->setText(Comp->Name);
556  else
557  if(NameEdit->text() != Comp->Name) {
558  for(pc = Doc->Components->first(); pc!=0; pc = Doc->Components->next())
559  if(pc->Name == NameEdit->text())
560  break; // found component with the same name ?
561  if(pc)
562  NameEdit->setText(Comp->Name);
563  else {
564  Comp->Name = NameEdit->text();
565  changed = true;
566  }
567  }
568 
569  QString Prop;
570  if(SimEdit->currentText() != Comp->Props.at(0)->Value) {
571  Comp->Props.at(0)->Value = SimEdit->currentText();
572  changed = true;
573  }
574  Prop = QString::number(MethodCombo->currentItem()+1) + "|" +
575  IterEdit->text() + "|" +
576  RefreshEdit->text() + "|" +
577  ParentsEdit->text() + "|" +
578  ConstEdit->text() + "|" +
579  CrossEdit->text() + "|" +
580  SeedEdit->text() + "|" +
581  CostVarEdit->text() + "|" +
582  CostObjEdit->text() + "|" +
583  CostConEdit->text();
584  if(Prop != Comp->Props.at(1)->Value) {
585  Comp->Props.at(1)->Value = Prop;
586  changed = true;
587  }
588 
589  Q3ListViewItem *item;
590  Property *pp = Comp->Props.at(2);
591  // apply all the new property values in the ListView
592  for(item = VarList->firstChild(); item != 0; item = item->itemBelow()) {
593  Prop = item->text(0) + "|" +
594  ((item->text(1) == tr("yes")) ? "yes" : "no") + "|" +
595  item->text(2) + "|" + item->text(3) + "|" +
596  item->text(4) + "|" +
597  ((item->text(5) == tr("linear double")) ? "LIN_DOUBLE" :
598  ((item->text(5) == tr("logarithmic double")) ? "LOG_DOUBLE" :
599  ((item->text(5) == tr("linear integer")) ? "LIN_INT" : "LOG_INT")));
600 
601  if(pp) {
602  if(pp->Name != "Var") {
603  pp->Name = "Var";
604  changed = true;
605  }
606  if(pp->Value != Prop) {
607  pp->Value = Prop;
608  changed = true;
609  }
610  }
611  else {
612  Comp->Props.append(new Property("Var", Prop, false, ""));
613  changed = true;
614  }
615  pp = Comp->Props.next();
616  }
617 
618  for(item = GoalList->firstChild(); item != 0; item = item->itemBelow()) {
619  Prop = item->text(0) + "|" +
620  ((item->text(1) == tr("minimize")) ? "MIN" :
621  ((item->text(1) == tr("maximize")) ? "MAX" :
622  ((item->text(1) == tr("less")) ? "LE" :
623  ((item->text(1) == tr("greater")) ? "GE" :
624  ((item->text(1) == tr("equal")) ? "EQ" : "MON"))))) + "|" +
625  item->text(2);
626 
627  if(pp) {
628  if(pp->Name != "Goal") {
629  pp->Name = "Goal";
630  changed = true;
631  }
632  if(pp->Value != Prop) {
633  pp->Value = Prop;
634  changed = true;
635  }
636  }
637  else {
638  Comp->Props.append(new Property("Goal", Prop, false, ""));
639  changed = true;
640  }
641  pp = Comp->Props.next();
642  }
643 
644  // if more properties than in ListView -> delete the rest
645  if(pp) {
646  pp = Comp->Props.prev();
647  Comp->Props.last();
648  while(pp != Comp->Props.current())
649  Comp->Props.remove();
650  changed = true;
651  }
652 
653  if(changed)
654  Doc->viewport()->repaint();
655 }
656 
657 // -------------------------------------------------------------------------
658 // Is called if the "Cancel"-button is pressed.
660 {
661  if(changed) done(1); // changed could have been done before
662  else done(0); // (by "Apply"-button)
663 }
QLineEdit * CostObjEdit
Q3VBoxLayout * all
QLineEdit * GoalNumEdit
QLineEdit * ParentsEdit
void slotChangeVarActive(bool)
QComboBox * SimEdit
Schematic * Doc
OptimizeDialog(Optimize_Sim *, Schematic *)
QDoubleValidator * numVal
QLineEdit * SeedEdit
void slotChangeVarName(const QString &)
QLineEdit * RefreshEdit
Q3ListView * VarList
QString Value
Definition: element.h:97
QLineEdit * CrossEdit
QLineEdit * VarInitEdit
QLineEdit * GoalNameEdit
QComboBox * GoalTypeCombo
void slotChangeVarMin(const QString &)
void slotEditGoal(Q3ListViewItem *)
Q3PtrList< Component > * Components
Definition: schematic.h:123
Q3PtrList< Property > Props
Definition: component.h:72
void slotEditVariable(Q3ListViewItem *)
void slotChangeGoalType(const QString &)
void slotChangeVarType(const QString &)
Definition: element.h:82
QLineEdit * VarMinEdit
Optimize_Sim * Comp
void slotChangeVarInit(const QString &)
QString Name
Definition: element.h:97
QLineEdit * ConstEdit
void slotChangeGoalNum(const QString &)
QLineEdit * CostConEdit
QString Name
Definition: component.h:80
QString Model
Definition: component.h:80
QIntValidator * intVal
Q3ListView * GoalList
void slotChangeGoalName(const QString &)
QLineEdit * CostVarEdit
QLineEdit * VarMaxEdit
QLineEdit * VarNameEdit
QComboBox * VarTypeCombo
QRegExpValidator * Validator
void slotChangeVarMax(const QString &)
QComboBox * MethodCombo
QCheckBox * VarActiveCheck
QLineEdit * IterEdit
QLineEdit * NameEdit