21 #include <qvgroupbox.h>
24 #include <qpopupmenu.h>
25 #include <qmessagebox.h>
28 #include <qpushbutton.h>
29 #include <qlineedit.h>
30 #include <qcombobox.h>
31 #include <qvalidator.h>
33 #include <qclipboard.h>
34 #include <qapplication.h>
40 setCaption(
"Qucs Attenuator " PACKAGE_VERSION);
42 QPopupMenu *fileMenu =
new QPopupMenu();
43 fileMenu->insertItem(tr(
"E&xit"),
this, SLOT(slotQuit()), CTRL+Key_Q);
45 QPopupMenu *helpMenu =
new QPopupMenu();
46 helpMenu->insertItem(tr(
"Help..."),
this, SLOT(slotHelpIntro()), Key_F1);
47 helpMenu->insertSeparator();
49 tr(
"&About QucsAttenuator..."),
this, SLOT(slotHelpAbout()), 0);
50 helpMenu->insertItem(tr(
"About Qt..."),
this, SLOT(slotHelpAboutQt()), 0);
52 QMenuBar *bar =
new QMenuBar(
this);
53 bar->insertItem(tr(
"&File"), fileMenu);
54 bar->insertSeparator ();
55 bar->insertItem(tr(
"&Help"), helpMenu);
57 QVBoxLayout * v2 =
new QVBoxLayout (
this);
58 QVBox * vm =
new QVBox (
this);
62 QWidget *Space =
new QWidget(
this);
63 Space->setFixedSize(5, bar->height());
66 QHBox * h1 =
new QHBox (
this);
70 QVBox * v1 =
new QVBox (h1);
73 QGroupBox * TopoGroup =
new QGroupBox (tr(
"Topology"), v1);
74 QGridLayout * tbox =
new QGridLayout(TopoGroup, 3,1,5,5);
76 QWidget *Space2 =
new QWidget(TopoGroup);
77 Space2->setFixedSize(8, 8);
78 tbox->addMultiCellWidget(Space2,0,0,0,0);
80 ComboTopology =
new QComboBox(TopoGroup);
81 ComboTopology->insertItem(
"Pi");
82 ComboTopology->insertItem(
"Tee");
83 ComboTopology->insertItem(
"Bridged Tee");
84 connect(ComboTopology, SIGNAL(activated(
int)), SLOT(slotTopologyChanged()));
85 tbox->addWidget(ComboTopology, 1,0);
87 pixTopology =
new QLabel(TopoGroup);
89 tbox->addMultiCellWidget(pixTopology,2,2,0,0);
91 QVBox * vb =
new QVBox (h1);
94 QGroupBox * InputGroup =
new QGroupBox (tr(
"Input"), vb);
95 QGridLayout * ibox =
new QGridLayout(InputGroup, 5,3,5,5);
96 ibox->addMultiCellWidget(Space2,0,0,0,2);
98 IntVal =
new QIntValidator(
this);
99 DoubleVal =
new QDoubleValidator(
this);
101 LabelAtten =
new QLabel(tr(
"Attenuation:"), InputGroup);
102 ibox ->addWidget(LabelAtten, 1,0);
103 lineEdit_Attvalue =
new QLineEdit(tr(
"1"), InputGroup);
104 lineEdit_Attvalue->setValidator(DoubleVal);
105 ibox->addWidget(lineEdit_Attvalue, 1,1);
106 QLabel *Label1 =
new QLabel(tr(
"dB"), InputGroup);
107 ibox->addWidget(Label1, 1,2);
109 LabelImp1 =
new QLabel(tr(
"Zin:"), InputGroup);
110 ibox->addWidget(LabelImp1, 2,0);
111 lineEdit_Zin =
new QLineEdit(tr(
"50"), InputGroup);
112 lineEdit_Zin->setValidator(DoubleVal);
113 connect(lineEdit_Zin, SIGNAL(textChanged(
const QString&)),
this,
114 SLOT(slotSetText_Zin(
const QString&)) );
116 ibox->addWidget(lineEdit_Zin, 2,1);
117 QLabel *Label2 =
new QLabel(tr(
"Ohm"), InputGroup);
118 ibox->addWidget(Label2, 2,2);
120 LabelImp2 =
new QLabel(tr(
"Zout:"), InputGroup);
121 ibox->addWidget(LabelImp2, 3,0);
122 lineEdit_Zout =
new QLineEdit(tr(
"50"), InputGroup);
123 lineEdit_Zout->setValidator(DoubleVal);
124 connect(lineEdit_Zout, SIGNAL(textChanged(
const QString&)),
this,
125 SLOT(slotSetText_Zout(
const QString&)) );
126 ibox->addWidget(lineEdit_Zout, 3,1);
127 QLabel *Label3 =
new QLabel(tr(
"Ohm"), InputGroup);
128 ibox->addWidget(Label3, 3,2);
130 Calculate =
new QPushButton(tr(
"Calculate and put into Clipboard"), vb);
131 connect(Calculate, SIGNAL(clicked()), SLOT(slotCalculate()));
133 QGroupBox * OutputGroup =
new QGroupBox (tr(
"Output"), vb);
134 QGridLayout * obox =
new QGridLayout(OutputGroup, 5,3,5,5);
135 obox->addMultiCellWidget(Space2,0,0,0,2);
137 LabelR1 =
new QLabel(tr(
"R1:"), OutputGroup);
138 obox->addWidget(LabelR1, 1,0);
139 lineEdit_R1 =
new QLineEdit(tr(
"--"), OutputGroup);
140 obox->addWidget(lineEdit_R1, 1,1);
141 QLabel *Label4 =
new QLabel(tr(
"Ohm"), OutputGroup);
142 obox->addWidget(Label4, 1,2);
144 LabelR2 =
new QLabel(tr(
"R2:"), OutputGroup);
145 obox->addWidget(LabelR2, 2,0);
146 lineEdit_R2 =
new QLineEdit(tr(
"--"), OutputGroup);
147 obox->addWidget(lineEdit_R2, 2,1);
148 QLabel *Label5 =
new QLabel(tr(
"Ohm"), OutputGroup);
149 obox->addWidget(Label5, 2,2);
151 LabelR3 =
new QLabel(tr(
"R3:"), OutputGroup);
152 obox->addWidget(LabelR3, 3,0);
153 lineEdit_R3 =
new QLineEdit(tr(
"--"), OutputGroup);
154 obox->addWidget(lineEdit_R3, 3,1);
155 LabelR3_Ohm =
new QLabel(tr(
"Ohm"), OutputGroup);
156 obox->addWidget(LabelR3_Ohm, 3,2);
158 LabelResult =
new QLabel(tr(
"Result:"),
this);
159 v2->addWidget(LabelResult);
160 LabelResult->setAlignment(Qt::AlignHCenter);
162 QWidget *Space1 =
new QWidget(
this);
163 Space1->setFixedSize(5,5);
164 v2->addWidget(Space1);
173 void QucsAttenuator::slotHelpIntro()
179 void QucsAttenuator::slotHelpAboutQt()
181 QMessageBox::aboutQt(
this, tr(
"About Qt"));
184 void QucsAttenuator::slotHelpAbout()
186 QMessageBox::about(
this, tr(
"About..."),
187 "QucsAttenuator Version " PACKAGE_VERSION+
188 tr(
"\nAttenuator synthesis program\n")+
189 tr(
"Copyright (C) 2006 by")+
" Toyoyuki Ishikawa"
191 tr(
"Copyright (C) 2006 by")+
" Stefan Jahn"
193 "\nThis is free software; see the source for copying conditions."
194 "\nThere is NO warranty; not even for MERCHANTABILITY or "
195 "\nFITNESS FOR A PARTICULAR PURPOSE.\n\n");
198 void QucsAttenuator::slotQuit()
210 void QucsAttenuator::slotSetText_Zin(
const QString &text )
213 lineEdit_Zout->blockSignals( TRUE );
214 lineEdit_Zout->setText( text );
215 lineEdit_Zout->blockSignals( FALSE );
219 void QucsAttenuator::slotSetText_Zout(
const QString &text )
222 lineEdit_Zin->blockSignals( TRUE );
223 lineEdit_Zin->setText( text );
224 lineEdit_Zin->blockSignals( FALSE );
228 void QucsAttenuator::slotTopologyChanged()
230 switch(ComboTopology->currentItem())
234 LabelR2->setText(
"R2:");
241 LabelR2->setText(
"R2:");
248 LabelR2->setText(
"R4:");
252 lineEdit_Zout->setText( lineEdit_Zin->text() );
258 void QucsAttenuator::slotCalculate()
266 Values.
Topology = ComboTopology->currentItem();
267 Values.Attenuation = lineEdit_Attvalue->text().toDouble();
268 Values.Zin = lineEdit_Zin->text().toDouble();
269 Values.Zout = lineEdit_Zout->text().toDouble();
270 result = qatt.
Calc(&Values);
274 LabelResult->setText(tr(
"Result:")+
" "+tr(
"Success!"));
275 lineEdit_R1->setText(QString::number(Values.R1,
'f', 1));
276 lineEdit_R2->setText(QString::number(Values.R2,
'f', 1));
277 lineEdit_R3->setText(QString::number(Values.R3,
'f', 1));
282 QClipboard *cb = QApplication::clipboard();
288 LabelResult->setText(tr(
"Error: Set Attenuation more than %1 dB").
arg(QString::number(Values.MinimumATT,
'f', 3)));
289 lineEdit_R1->setText(
"--");
290 lineEdit_R2->setText(
"--");
291 lineEdit_R3->setText(
"--");