35 #include <QPushButton>
36 #include <QMessageBox>
38 #include <Q3GridLayout>
39 #include <Q3VBoxLayout>
43 : QDialog(d_, 0, TRUE, Qt::WDestructiveClose)
48 setCaption(tr(
"Edit Optimization Properties"));
50 Expr.setPattern(
"[\\w_]+");
52 numVal =
new QDoubleValidator(
this);
53 intVal =
new QIntValidator(
this);
55 all =
new Q3VBoxLayout(
this);
56 QTabWidget *t =
new QTabWidget(
this);
60 QWidget *Tab1 =
new QWidget(t);
61 Q3GridLayout *gp1 =
new Q3GridLayout(Tab1,3,2,3,3);
63 gp1->addWidget(
new QLabel(tr(
"Name:"), Tab1), 0,0);
68 gp1->addWidget(
new QLabel(tr(
"Simulation:"), Tab1), 1,0);
73 t->addTab(Tab1, tr(
"General"));
76 QWidget *Tab4 =
new QWidget(t);
77 Q3GridLayout *gp4 =
new Q3GridLayout(Tab4,11,2,3,3);
79 gp4->addWidget(
new QLabel(tr(
"Method:"), Tab4), 0,0);
93 gp4->addWidget(
new QLabel(tr(
"Maximum number of iterations:"), Tab4), 1,0);
98 gp4->addWidget(
new QLabel(tr(
"Output refresh cycle:"), Tab4), 2,0);
103 gp4->addWidget(
new QLabel(tr(
"Number of parents:"), Tab4), 3,0);
108 gp4->addWidget(
new QLabel(tr(
"Constant F:"), Tab4), 4,0);
113 gp4->addWidget(
new QLabel(tr(
"Crossing over factor:"), Tab4), 5,0);
118 gp4->addWidget(
new QLabel(tr(
"Pseudo random number seed:"), Tab4), 6,0);
123 gp4->addWidget(
new QLabel(tr(
"Minimum cost variance:"), Tab4), 7,0);
128 gp4->addWidget(
new QLabel(tr(
"Cost objectives:"), Tab4), 8,0);
133 gp4->addWidget(
new QLabel(tr(
"Cost constraints:"), Tab4), 9,0);
138 t->addTab(Tab4, tr(
"Algorithm"));
141 QWidget *Tab2 =
new QWidget(t);
142 Q3GridLayout *gp2 =
new Q3GridLayout(Tab2,5,3,3,3);
144 VarList =
new Q3ListView(Tab2);
145 VarList->addColumn(tr(
"Name"));
146 VarList->addColumn(tr(
"active"));
147 VarList->addColumn(tr(
"initial"));
150 VarList->addColumn(tr(
"Type"));
152 gp2->addMultiCellWidget(
VarList,0,0,0,2);
153 connect(
VarList, SIGNAL(selectionChanged(Q3ListViewItem*)),
156 Q3HBox *VarLine =
new Q3HBox(Tab2);
157 VarLine->setSpacing(3);
158 gp2->addMultiCellWidget(VarLine, 1,1,0,2);
160 new QLabel(tr(
"Name:"), VarLine);
163 connect(
VarNameEdit, SIGNAL(textChanged(
const QString&)),
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);
176 connect(
VarInitEdit, SIGNAL(textChanged(
const QString&)),
181 connect(
VarMinEdit, SIGNAL(textChanged(
const QString&)),
186 connect(
VarMaxEdit, SIGNAL(textChanged(
const QString&)),
189 Q3HBox *VarButtons =
new Q3HBox(Tab2);
190 VarButtons->setSpacing(3);
191 gp2->addMultiCellWidget(VarButtons, 4,4,0,2);
193 new QLabel(tr(
"Type:"), VarButtons);
199 connect(
VarTypeCombo, SIGNAL(activated(
const QString&)),
202 VarButtons->setStretchFactor(
new QWidget(VarButtons), 10);
203 QPushButton *AddVar_Butt =
new QPushButton(tr(
"Add"), VarButtons);
205 QPushButton *DelVar_Butt =
new QPushButton(tr(
"Delete"), VarButtons);
208 t->addTab(Tab2, tr(
"Variables"));
211 QWidget *Tab3 =
new QWidget(t);
212 Q3GridLayout *gp3 =
new Q3GridLayout(Tab3,4,3,3,3);
219 gp3->addMultiCellWidget(
GoalList,0,0,0,2);
220 connect(
GoalList, SIGNAL(selectionChanged(Q3ListViewItem*)),
223 gp3->addWidget(
new QLabel(tr(
"Name:"), Tab3), 1,0);
227 connect(
GoalNameEdit, SIGNAL(textChanged(
const QString&)),
230 gp3->addWidget(
new QLabel(tr(
"Value:"), Tab3), 2,0);
234 connect(
GoalNumEdit, SIGNAL(textChanged(
const QString&)),
248 Q3HBox *GoalButtons =
new Q3HBox(Tab3);
249 GoalButtons->setSpacing(3);
250 gp3->addMultiCellWidget(GoalButtons, 3,3,0,2);
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);
258 t->addTab(Tab3, tr(
"Goals"));
262 Q3HBox *Butts =
new Q3HBox(
this);
263 Butts->setSpacing(3);
265 all->addWidget(Butts);
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()));
281 if(pc->
Model[0] ==
'.' && pc->
Model !=
".Opt")
286 if(!pp->
Value.isEmpty())
290 if(!pp->
Value.isEmpty()) {
306 if(pp->
Name ==
"Var") {
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")))));
316 if(pp->
Name ==
"Goal") {
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") :
324 pp->
Value.section(
'|',2,2));
369 QMessageBox::critical(
this, tr(
"Error"),
370 tr(
"Every text field must be non-empty!"));
374 Q3ListViewItem *item;
375 for(item =
VarList->firstChild(); item != 0; item = item->itemBelow())
377 QMessageBox::critical(
this, tr(
"Error"),
378 tr(
"Variable \"%1\" already in list!").arg(
VarNameEdit->text()));
395 Q3ListViewItem *next_item = 0;
397 Q3ListViewItem *Item =
VarList->selectedItem();
399 next_item = Item->itemBelow();
400 if(next_item == 0) next_item = Item->itemAbove();
411 Q3ListViewItem *Item =
VarList->selectedItem();
412 if(Item == 0)
return;
414 Item->setText(1, On ? tr(
"yes") : tr(
"no"));
426 Q3ListViewItem *Item =
VarList->selectedItem();
427 if(Item == 0)
return;
429 Item->setText(2, Text);
435 Q3ListViewItem *Item =
VarList->selectedItem();
436 if(Item == 0)
return;
438 Item->setText(3, Text);
444 Q3ListViewItem *Item =
VarList->selectedItem();
445 if(Item == 0)
return;
447 Item->setText(4, Text);
453 Q3ListViewItem *Item =
VarList->selectedItem();
454 if(Item == 0)
return;
456 Item->setText(5, Text);
482 QMessageBox::critical(
this, tr(
"Error"),
483 tr(
"Every text field must be non-empty!"));
487 Q3ListViewItem *item;
488 for(item =
GoalList->firstChild(); item != 0; item = item->itemBelow())
490 QMessageBox::critical(
this, tr(
"Error"),
491 tr(
"Goal \"%1\" already in list!").arg(
GoalNameEdit->text()));
506 Q3ListViewItem *next_item = 0;
508 Q3ListViewItem *Item =
GoalList->selectedItem();
510 next_item = Item->itemBelow();
511 if(next_item == 0) next_item = Item->itemAbove();
528 Q3ListViewItem *Item =
GoalList->selectedItem();
529 if(Item == 0)
return;
531 Item->setText(1, Text);
537 Q3ListViewItem *Item =
GoalList->selectedItem();
538 if(Item == 0)
return;
540 Item->setText(2, Text);
574 Prop = QString::number(
MethodCombo->currentItem()+1) +
"|" +
589 Q3ListViewItem *item;
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")));
602 if(pp->
Name !=
"Var") {
606 if(pp->
Value != Prop) {
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"))))) +
"|" +
628 if(pp->
Name !=
"Goal") {
632 if(pp->
Value != Prop) {
654 Doc->viewport()->repaint();
void slotChangeVarActive(bool)
OptimizeDialog(Optimize_Sim *, Schematic *)
QDoubleValidator * numVal
void slotChangeVarName(const QString &)
void slotDeleteVariable()
QComboBox * GoalTypeCombo
void slotChangeVarMin(const QString &)
void slotEditGoal(Q3ListViewItem *)
Q3PtrList< Component > * Components
Q3PtrList< Property > Props
void slotEditVariable(Q3ListViewItem *)
void slotChangeGoalType(const QString &)
void slotChangeVarType(const QString &)
void slotChangeVarInit(const QString &)
void slotChangeGoalNum(const QString &)
void slotChangeGoalName(const QString &)
QRegExpValidator * Validator
void slotChangeVarMax(const QString &)
QCheckBox * VarActiveCheck