25 #include <qpushbutton.h>
27 #include <qtextstream.h>
28 #include <qmessagebox.h>
29 #include <qtoolbutton.h>
31 #include <qfiledialog.h>
34 #include <qpopupmenu.h>
35 #include <qhgroupbox.h>
36 #include <qvgroupbox.h>
37 #include <qcombobox.h>
39 #include <qlineedit.h>
42 #include <qscrollview.h>
44 #include <qradiobutton.h>
45 #include <qstatusbar.h>
47 #include <qbuttongroup.h>
48 #include <qwidgetstack.h>
50 #include <qvalidator.h>
51 #include <qclipboard.h>
52 #include <qapplication.h>
71 #define TRANS_RADIOS { -1, -1, -1, -1 }
72 #define TRANS_QOBJS NULL, NULL, NULL, NULL, NULL
73 #define TRANS_END { NULL, 0, NULL, { NULL }, 0, TRANS_QOBJS }
74 #define TRANS_RESULT { NULL, NULL, NULL }
75 #define TRANS_RESULTS { TRANS_RESULT }
255 setCaption(
"Qucs Transcalc " PACKAGE_VERSION);
257 QMenuBar * menuBar =
new QMenuBar (
this);
260 QPopupMenu * fileMenu =
new QPopupMenu ();
262 new QAction (tr(
"Load"), tr(
"&Load"), CTRL+Key_L,
this);
263 fileLoad->addTo (fileMenu);
264 connect(fileLoad, SIGNAL(activated()), SLOT(slotFileLoad()));
266 new QAction (tr(
"Save"), tr(
"&Save"), CTRL+Key_S,
this);
267 fileSave->addTo (fileMenu);
268 connect(fileSave, SIGNAL(activated()), SLOT(slotFileSave()));
269 fileMenu->insertSeparator ();
270 QAction * fileOption =
271 new QAction (tr(
"Options"), tr(
"&Options"), CTRL+Key_O,
this);
272 fileOption->addTo (fileMenu);
273 connect(fileOption, SIGNAL(activated()), SLOT(slotOptions()));
274 fileMenu->insertSeparator ();
276 new QAction (tr(
"Quit"), tr(
"&Quit"), CTRL+Key_Q,
this);
277 fileQuit->addTo (fileMenu);
278 connect(fileQuit, SIGNAL(activated()), SLOT(slotQuit()));
281 QPopupMenu * execMenu =
new QPopupMenu ();
283 new QAction (tr(
"Copy to Clipboard"),
284 tr(
"&Copy to Clipboard"), Key_F2,
this);
285 execCopy->addTo (execMenu);
286 connect(execCopy, SIGNAL(activated()), SLOT(slotCopyToClipBoard()));
287 QAction * execAnalyze =
288 new QAction (tr(
"Analyze"), tr(
"&Analyze"), Key_F3,
this);
289 execAnalyze->addTo (execMenu);
290 connect(execAnalyze, SIGNAL(activated()), SLOT(slotAnalyze()));
291 QAction * execSynthesize =
292 new QAction (tr(
"Synthesize"), tr(
"&Synthesize"), Key_F4,
this);
293 execSynthesize->addTo (execMenu);
294 connect(execSynthesize, SIGNAL(activated()), SLOT(slotSynthesize()));
297 QPopupMenu * helpMenu =
new QPopupMenu ();
299 new QAction (tr(
"Help"), tr(
"&Help"), Key_F1,
this);
300 helpHelp->addTo (helpMenu);
301 connect(helpHelp, SIGNAL(activated()), SLOT(slotHelpIntro()));
302 QAction * helpAbout =
303 new QAction (tr(
"About"), tr(
"About"), 0, helpMenu);
304 helpAbout->addTo (helpMenu);
305 connect(helpAbout, SIGNAL(activated()), SLOT(slotAbout()));
308 menuBar->insertItem (tr(
"&File"), fileMenu);
309 menuBar->insertItem (tr(
"&Execute"), execMenu);
310 menuBar->insertSeparator ();
311 menuBar->insertItem (tr(
"&Help"), helpMenu);
314 QVBoxLayout * v =
new QVBoxLayout (
this);
319 QWidget * Space =
new QWidget (
this);
320 Space->setFixedSize(5, menuBar->height() + 2);
321 v->addWidget (Space);
324 QHBox * h =
new QHBox (
this);
329 QWidget * sl =
new QWidget (h);
330 sl->setFixedWidth (2);
333 QVGroupBox * lineGroup =
new QVGroupBox (tr(
"Transmission Line Type"), h);
334 tranType =
new QComboBox (lineGroup);
335 tranType->insertItem (tr(
"Microstrip Line"));
336 tranType->insertItem (tr(
"Coplanar Waveguide"));
337 tranType->insertItem (tr(
"Grounded Coplanar"));
338 tranType->insertItem (tr(
"Rectangular Waveguide"));
339 tranType->insertItem (tr(
"Coaxial Line"));
340 tranType->insertItem (tr(
"Coupled Microstrip"));
341 connect(tranType, SIGNAL(activated(
int)), SLOT(slotSelectType(
int)));
343 pix =
new QLabel (lineGroup);
347 QVBox * vm =
new QVBox (h);
349 QVBox * vr =
new QVBox (h);
353 QWidget * sr =
new QWidget (h);
354 sr->setFixedWidth (2);
357 setupTranslations ();
363 QHGroupBox *
substrate =
new QHGroupBox (tr(
"Substrate Parameters"), vm);
367 QHGroupBox * component =
new QHGroupBox (tr(
"Component Parameters"), vm);
371 QHGroupBox * physical =
new QHGroupBox (tr(
"Physical Parameters"), vr);
375 QHBox * h2 =
new QHBox (vr);
376 QPushButton * analyze =
new QPushButton (tr(
"Analyze"), h2);
377 QToolTip::add (analyze, tr(
"Derive Electrical Parameters"));
378 connect(analyze, SIGNAL(clicked()), SLOT(slotAnalyze()));
379 QPushButton * synthesize =
new QPushButton (tr(
"Synthesize"), h2);
380 QToolTip::add (synthesize, tr(
"Compute Physical Parameters"));
381 connect(synthesize, SIGNAL(clicked()), SLOT(slotSynthesize()));
384 QHGroupBox * electrical =
new QHGroupBox (tr(
"Electrical Parameters"), vr);
387 calculated =
new QHGroupBox (tr(
"Calculated Results"), vr);
390 statBar =
new QStatusBar (
this);
391 QLabel * statText =
new QLabel (
"Ready.", statBar);
392 statBar->message (tr(
"Ready."));
393 statBar->setFixedHeight (statText->height ());
394 v->addWidget (statBar);
398 createResultItems (calculated);
410 TransLineTypes[4].
line =
new coax ();
420 if (TransLineTypes[
i].line)
421 delete TransLineTypes[
i].
line;
427 void QucsTranscalc::setupTranslations () {
430 TransLineTypes[
i].
result[0].
name =
new QString(tr(
"ErEff"));
431 TransLineTypes[
i].
result[1].
name =
new QString(tr(
"Conductor Losses"));
432 TransLineTypes[
i].
result[2].
name =
new QString(tr(
"Dielectric Losses"));
433 TransLineTypes[
i].
result[3].
name =
new QString(tr(
"Skin Depth"));
436 TransLineTypes[
i].
result[0].
name =
new QString(tr(
"ErEff"));
437 TransLineTypes[
i].
result[1].
name =
new QString(tr(
"Conductor Losses"));
438 TransLineTypes[
i].
result[2].
name =
new QString(tr(
"Dielectric Losses"));
439 TransLineTypes[
i].
result[3].
name =
new QString(tr(
"Skin Depth"));
442 TransLineTypes[
i].
result[0].
name =
new QString(tr(
"ErEff"));
443 TransLineTypes[
i].
result[1].
name =
new QString(tr(
"Conductor Losses"));
444 TransLineTypes[
i].
result[2].
name =
new QString(tr(
"Dielectric Losses"));
445 TransLineTypes[
i].
result[3].
name =
new QString(tr(
"Skin Depth"));
448 TransLineTypes[
i].
result[0].
name =
new QString(tr(
"ErEff"));
449 TransLineTypes[
i].
result[1].
name =
new QString(tr(
"Conductor Losses"));
450 TransLineTypes[
i].
result[2].
name =
new QString(tr(
"Dielectric Losses"));
451 TransLineTypes[
i].
result[3].
name =
new QString(tr(
"TE-Modes"));
452 TransLineTypes[
i].
result[4].
name =
new QString(tr(
"TM-Modes"));
455 TransLineTypes[
i].
result[0].
name =
new QString(tr(
"Conductor Losses"));
456 TransLineTypes[
i].
result[1].
name =
new QString(tr(
"Dielectric Losses"));
457 TransLineTypes[
i].
result[2].
name =
new QString(tr(
"TE-Modes"));
458 TransLineTypes[
i].
result[3].
name =
new QString(tr(
"TM-Modes"));
461 TransLineTypes[
i].
result[0].
name =
new QString(tr(
"ErEff Even"));
462 TransLineTypes[
i].
result[1].
name =
new QString(tr(
"ErEff Odd"));
463 TransLineTypes[
i].
result[2].
name =
new QString(tr(
"Conductor Losses Even"));
464 TransLineTypes[
i].
result[3].
name =
new QString(tr(
"Conductor Losses Odd"));
465 TransLineTypes[
i].
result[4].
name =
new QString(tr(
"Dielectric Losses Even"));
466 TransLineTypes[
i].
result[5].
name =
new QString(tr(
"Dielectric Losses Odd"));
467 TransLineTypes[
i].
result[6].
name =
new QString(tr(
"Skin Depth"));
471 t->
array[0].
item[0].
tip =
new QString(tr(
"Relative Permittivity"));
472 t->
array[0].
item[1].
tip =
new QString(tr(
"Relative Permeability"));
473 t->
array[0].
item[2].
tip =
new QString(tr(
"Height of Substrate"));
474 t->
array[0].
item[3].
tip =
new QString(tr(
"Height of Box Top"));
475 t->
array[0].
item[4].
tip =
new QString(tr(
"Strip Thickness"));
476 t->
array[0].
item[5].
tip =
new QString(tr(
"Strip Conductivity"));
477 t->
array[0].
item[6].
tip =
new QString(tr(
"Dielectric Loss Tangent"));
478 t->
array[0].
item[7].
tip =
new QString(tr(
"Conductor Roughness"));
480 t->
array[2].
item[0].
tip =
new QString(tr(
"Line Width"));
481 t->
array[2].
item[1].
tip =
new QString(tr(
"Line Length"));
482 t->
array[3].
item[0].
tip =
new QString(tr(
"Characteristic Impedance"));
483 t->
array[3].
item[1].
tip =
new QString(tr(
"Electrical Length"));
486 t->
array[0].
item[0].
tip =
new QString(tr(
"Relative Permittivity"));
487 t->
array[0].
item[1].
tip =
new QString(tr(
"Height of Substrate"));
488 t->
array[0].
item[2].
tip =
new QString(tr(
"Strip Thickness"));
489 t->
array[0].
item[3].
tip =
new QString(tr(
"Strip Conductivity"));
490 t->
array[0].
item[4].
tip =
new QString(tr(
"Dielectric Loss Tangent"));
492 t->
array[2].
item[0].
tip =
new QString(tr(
"Line Width"));
494 t->
array[2].
item[2].
tip =
new QString(tr(
"Line Length"));
495 t->
array[3].
item[0].
tip =
new QString(tr(
"Characteristic Impedance"));
496 t->
array[3].
item[1].
tip =
new QString(tr(
"Electrical Length"));
499 t->
array[0].
item[0].
tip =
new QString(tr(
"Relative Permittivity"));
500 t->
array[0].
item[1].
tip =
new QString(tr(
"Height of Substrate"));
501 t->
array[0].
item[2].
tip =
new QString(tr(
"Strip Thickness"));
502 t->
array[0].
item[3].
tip =
new QString(tr(
"Strip Conductivity"));
503 t->
array[0].
item[4].
tip =
new QString(tr(
"Dielectric Loss Tangent"));
505 t->
array[2].
item[0].
tip =
new QString(tr(
"Line Width"));
507 t->
array[2].
item[2].
tip =
new QString(tr(
"Line Length"));
508 t->
array[3].
item[0].
tip =
new QString(tr(
"Characteristic Impedance"));
509 t->
array[3].
item[1].
tip =
new QString(tr(
"Electrical Length"));
512 t->
array[0].
item[0].
tip =
new QString(tr(
"Relative Permittivity"));
513 t->
array[0].
item[1].
tip =
new QString(tr(
"Relative Permeability"));
514 t->
array[0].
item[2].
tip =
new QString(tr(
"Conductivity of Metal"));
515 t->
array[0].
item[3].
tip =
new QString(tr(
"Dielectric Loss Tangent"));
516 t->
array[0].
item[4].
tip =
new QString(tr(
"Magnetic Loss Tangent"));
518 t->
array[2].
item[0].
tip =
new QString(tr(
"Width of Waveguide"));
519 t->
array[2].
item[1].
tip =
new QString(tr(
"Height of Waveguide"));
520 t->
array[2].
item[2].
tip =
new QString(tr(
"Waveguide Length"));
521 t->
array[3].
item[0].
tip =
new QString(tr(
"Characteristic Impedance"));
522 t->
array[3].
item[1].
tip =
new QString(tr(
"Electrical Length"));
525 t->
array[0].
item[0].
tip =
new QString(tr(
"Relative Permittivity"));
526 t->
array[0].
item[1].
tip =
new QString(tr(
"Relative Permeability"));
527 t->
array[0].
item[2].
tip =
new QString(tr(
"Dielectric Loss Tangent"));
528 t->
array[0].
item[3].
tip =
new QString(tr(
"Conductivity of Metal"));
530 t->
array[2].
item[0].
tip =
new QString(tr(
"Inner Diameter"));
531 t->
array[2].
item[1].
tip =
new QString(tr(
"Outer Diameter"));
533 t->
array[3].
item[0].
tip =
new QString(tr(
"Characteristic Impedance"));
534 t->
array[3].
item[1].
tip =
new QString(tr(
"Electrical Length"));
537 t->
array[0].
item[0].
tip =
new QString(tr(
"Relative Permittivity"));
538 t->
array[0].
item[1].
tip =
new QString(tr(
"Relative Permeability"));
539 t->
array[0].
item[2].
tip =
new QString(tr(
"Height of Substrate"));
540 t->
array[0].
item[3].
tip =
new QString(tr(
"Height of Box Top"));
541 t->
array[0].
item[4].
tip =
new QString(tr(
"Strip Thickness"));
542 t->
array[0].
item[5].
tip =
new QString(tr(
"Strip Conductivity"));
543 t->
array[0].
item[6].
tip =
new QString(tr(
"Dielectric Loss Tangent"));
544 t->
array[0].
item[7].
tip =
new QString(tr(
"Conductor Roughness"));
546 t->
array[2].
item[0].
tip =
new QString(tr(
"Line Width"));
549 t->
array[3].
item[0].
tip =
new QString(tr(
"Even-Mode Impedance"));
550 t->
array[3].
item[1].
tip =
new QString(tr(
"Odd-Mode Impedance"));
551 t->
array[3].
item[2].
tip =
new QString(tr(
"Electrical Length"));
556 void QucsTranscalc::createPropItem (QVBox ** parentRows,
TransValue * val,
557 int box, QButtonGroup * group) {
558 QRadioButton * r = NULL;
562 QDoubleValidator * v =
new QDoubleValidator (
this);
565 l =
new QLabel (val->
name, parentRows[0]);
566 l->setAlignment (Qt::AlignRight);
567 if (val->
tip) QToolTip::add (l, *(val->
tip));
571 e =
new QLineEdit (parentRows[1]);
572 e->setText (QString::number (val->
value));
573 e->setAlignment (Qt::AlignRight);
575 connect(e, SIGNAL(textChanged(
const QString&)), SLOT(slotValueChanged()));
576 if (!val->
name) e->setDisabled (
true);
580 c =
new QComboBox (parentRows[2]);
581 if (!val->
units[0]) {
582 c->insertItem (
"NA");
583 c->setDisabled(
true);
587 for (
int i = 0; val->
units[
i]; i++) {
588 c->insertItem (val->
units[i]);
589 if (!strcmp (val->
units[i],
"NA")) nounit++;
591 c->setDisabled (nounit != 0);
592 c->setCurrentItem (0);
594 connect(c, SIGNAL(activated(
int)), SLOT(slotValueChanged()));
599 QWidgetStack *
s =
new QWidgetStack(parentRows[3]);
601 r =
new QRadioButton (s);
602 QWidget * spacer =
new QWidget (s);
604 s->addWidget (spacer, 2);
605 r->setDisabled (
true);
614 void QucsTranscalc::updatePropItem (
TransValue * val) {
617 QToolTip::remove (val->
label);
618 if (val->
tip) QToolTip::add (val->
label, *(val->
tip));
626 if (!val->
units[0]) {
632 for (
int i = 0; val->
units[
i]; i++) {
634 if (!strcmp (val->
units[i],
"NA")) nounit++;
637 val->
combobox->setDisabled (nounit);
644 if (mode == _mode)
return;
647 setUpdatesEnabled(
false);
652 updateResultItems ();
655 setUpdatesEnabled(
true);
660 void QucsTranscalc::updateMode (
void) {
663 int last = 0, idx = getTypeIndex();
666 for (
int i = 0; i < TransMaxBox[box]; i++) {
668 if (val->
name == NULL) last++;
673 val->
units[0] = NULL;
675 updatePropItem (val);
682 void QucsTranscalc::updateSelection () {
683 int idx = getTypeIndex ();
686 if (TransLineTypes[idx].
radio[i] != -1) {
687 val->
stack->raiseWidget (1);
688 if (TransLineTypes[idx].
radio[i] == 1) {
689 val->
radio->setDown (
true);
690 val->
radio->setChecked (
true);
691 QToolTip::add (val->
radio, tr(
"Selected for Calculation"));
694 val->
radio->setDown (
false);
695 val->
radio->setChecked (
false);
696 QToolTip::add (val->
radio, tr(
"Check item for Calculation"));
698 val->
radio->setDisabled (
false);
701 QToolTip::remove (val->
radio);
702 val->
stack->raiseWidget (2);
703 val->
radio->setDown (
false);
704 val->
radio->setChecked (
false);
705 val->
radio->setDisabled (
true);
713 void QucsTranscalc::createPropItems (QHGroupBox * parent,
int box) {
715 int last = 0, idx = getTypeIndex ();
716 val = TransLineTypes[idx].
array[box].
item;
719 QButtonGroup * group =
new QButtonGroup();
720 connect(group, SIGNAL(pressed(
int)), SLOT(slotRadioChecked(
int)));
721 rows[0] =
new QVBox (parent);
722 rows[1] =
new QVBox (parent);
723 rows[2] =
new QVBox (parent);
724 rows[3] =
new QVBox (parent);
726 parent->layout()->setSpacing (2);
727 rows[0]->setSpacing (2);
728 rows[1]->setSpacing (2);
729 rows[2]->setSpacing (2);
730 rows[3]->setSpacing (2);
733 for (
int i = 0; i < TransMaxBox[box]; i++) {
735 if (val->
name == NULL) last++;
740 val->
units[0] = NULL;
742 createPropItem (rows, val, box, group);
746 dup = & TransLineTypes[_mode].
array[box].
item[
i];
759 void QucsTranscalc::createResultItem (QVBox ** parentRows,
TransResult * res) {
761 new QLabel (res->
name ? *(res->
name) +
":" : QString(), parentRows[0]);
762 n->setAlignment (Qt::AlignRight);
764 QLabel * v =
new QLabel (parentRows[1]);
765 v->setAlignment (Qt::AlignLeft);
774 void QucsTranscalc::updateResultItem (
TransResult * res) {
776 res->
label->setText (*(res->
name) +
":");
786 void QucsTranscalc::createResultItems (QHGroupBox * parent) {
788 int idx = getTypeIndex ();
789 res = & TransLineTypes[idx].
result[0];
792 rows[0] =
new QVBox (parent);
793 rows[1] =
new QVBox (parent);
795 parent->layout()->setSpacing (2);
796 rows[0]->setSpacing (2);
797 rows[1]->setSpacing (2);
800 createResultItem (rows, res);
803 dup = & TransLineTypes[_mode].
result[
i];
815 res = & TransLineTypes[getTypeIndex ()].
result[line];
816 res->
value->setText (text);
820 void QucsTranscalc::updateResultItems() {
821 int idx = getTypeIndex ();
824 updateResultItem (res);
830 int QucsTranscalc::getTypeIndex () {
833 if (type->
type == mode)
return i;
840 struct TransValue * QucsTranscalc::findProperty (QString prop) {
843 val = TransLineTypes[getTypeIndex ()].
array[box].
item;
844 for (
int i = 0; val->
name; i++) {
845 if (prop == val->
name)
return val;
854 struct TransValue * val = findProperty (prop);
856 val->
lineedit->setText (QString::number (value));
863 struct TransValue * val = findProperty (prop);
865 QString str = val->
lineedit->text ();
866 val->
value = str.toDouble ();
874 struct TransValue * val = findProperty (prop);
880 else for (
int i = 0; val->
units[
i]; i++) {
881 if (!strcmp (unit, val->
units[i])) {
892 struct TransValue * val = findProperty (prop);
894 QString str = val->
combobox->currentText ();
895 for (
int i = 0; val->
units[
i]; i++) {
896 if (str == val->
units[i]) {
898 return (
char *) val->
units[
i];
907 struct TransValue * val = findProperty (prop);
910 if (val->
radio->isChecked ()) {
917 void QucsTranscalc::slotAbout()
919 QMessageBox::about(
this, tr(
"About..."),
920 "QucsTranscalc Version " PACKAGE_VERSION
"\n"+
921 tr(
"Transmission Line Calculator for Qucs\n")+
922 tr(
"Copyright (C) 2001 by Gopal Narayanan\n")+
923 tr(
"Copyright (C) 2002 by Claudio Girardi\n")+
924 tr(
"Copyright (C) 2005 by Stefan Jahn\n")+
925 tr(
"Copyright (C) 2008 by Michael Margraf\n")+
926 "\nThis is free software; see the source for copying conditions."
927 "\nThere is NO warranty; not even for MERCHANTABILITY or "
928 "\nFITNESS FOR A PARTICULAR PURPOSE.");
931 void QucsTranscalc::slotQuit()
943 void QucsTranscalc::closeEvent(QCloseEvent *Event)
955 void QucsTranscalc::slotSelectType (
int Type)
957 pix->setPixmap (QPixmap (QImage (
960 statBar->message(tr(
"Ready."));
963 void QucsTranscalc::slotAnalyze()
965 if (TransLineTypes[getTypeIndex()].line)
967 statBar->message(tr(
"Values are consistent."));
970 void QucsTranscalc::slotSynthesize()
972 if (TransLineTypes[getTypeIndex()].line)
974 statBar->message(tr(
"Values are consistent."));
977 void QucsTranscalc::slotValueChanged()
979 statBar->message(tr(
"Values are inconsistent."));
984 QFile file(QDir::convertSeparators (fname));
985 if(!file.open(IO_ReadOnly))
return false;
987 QTextStream stream(&file);
992 while(!stream.atEnd()) {
993 Line = stream.readLine();
995 if (Line ==
"<" + QString(TransLineTypes[i].description) +
">") {
997 *_mode = TransLineTypes[
i].
type;
1001 mode = TransLineTypes[
i].
type;
1003 while(!stream.atEnd()) {
1004 Line = stream.readLine();
1005 if (Line ==
"</" + QString(TransLineTypes[i].description) +
">")
1007 Line = Line.simplifyWhiteSpace();
1008 Name = Line.section(
' ',0,0);
1009 Value = Line.section(
' ',1,1).toDouble();
1010 Unit = Line.section(
' ',2,2);
1018 if (!_mode) mode = oldmode;
1025 bool QucsTranscalc::saveFile(QString fname) {
1026 QFile file (QDir::convertSeparators (fname));
1027 if(!file.open (IO_WriteOnly))
return false;
1028 QTextStream stream (&file);
1031 stream <<
"# QucsTranscalc " << PACKAGE_VERSION <<
" " << fname <<
"\n";
1032 stream <<
"# Generated on " << QDate::currentDate().toString()
1033 <<
" at " << QTime::currentTime().toString() <<
".\n";
1034 stream <<
"# It is not suggested to edit the file, use QucsTranscalc "
1046 struct TransType * t = &TransLineTypes[getTypeIndex ()];
1052 stream <<
" " << val->
name <<
" " << val->
value <<
" "
1064 mode = TransLineTypes[
i].
type;
1071 void QucsTranscalc::storeValues (
void) {
1072 struct TransType * t = &TransLineTypes[getTypeIndex ()];
1081 if (val->
radio->isEnabled()) {
1082 if (val->
radio->isChecked())
1095 void QucsTranscalc::slotFileLoad()
1097 statBar->message(tr(
"Loading file..."));
1099 QString s = QFileDialog::getOpenFileName(
QucsWorkDir.path(),
1100 tr(
"Transcalc File")+
" (*.trc)",
this,
"", tr(
"Enter a Filename"));
1104 QMessageBox::critical (
this, tr(
"Error"),
1105 tr(
"Cannot load file:")+
" '"+s+
"'!");
1108 else statBar->message(tr(
"Loading aborted."), 2000);
1110 statBar->message(tr(
"Ready."));
1113 void QucsTranscalc::slotFileSave()
1115 statBar->message(tr(
"Saving file..."));
1117 QString s = QFileDialog::getSaveFileName(
QucsWorkDir.path(),
1118 tr(
"Transcalc File")+
" (*.trc)",
this,
"", tr(
"Enter a Filename"));
1121 if (!saveFile (s)) {
1122 QMessageBox::critical (
this, tr(
"Error"),
1123 tr(
"Cannot save file:")+
" '"+s+
"'!");
1126 else statBar->message(tr(
"Saving aborted."), 2000);
1128 statBar->message(tr(
"Ready."));
1133 return TransLineTypes[getTypeIndex ()].
description;
1139 if (TransLineTypes[i].description == _mode) {
1140 setMode (TransLineTypes[i].type);
1141 updatePixmap (mode);
1148 void QucsTranscalc::updatePixmap (
int _mode) {
1149 pix->setPixmap (QPixmap (QImage (
1151 tranType->setCurrentItem(_mode);
1154 void QucsTranscalc::slotHelpIntro()
1160 void QucsTranscalc::slotOptions()
1168 for (
int i = 0; TransUnits[type].
units[
i]; i++) {
1169 if (unit && !strcmp (unit, TransUnits[type].
units[i]))
1175 void QucsTranscalc::slotRadioChecked(
int id)
1177 int idx = getTypeIndex ();
1179 if (TransLineTypes[idx].
radio[i] != -1) {
1180 TransLineTypes[idx].
radio[
i] = 0;
1182 TransLineTypes[idx].
radio[
i] = 1;
1189 void QucsTranscalc::slotCopyToClipBoard()
1192 QString s =
"<Qucs Schematic " PACKAGE_VERSION
">\n";
1197 s +=
"<Components>\n";
1198 s +=
" <Pac P1 1 90 150 -74 -26 1 1 \"1\" 1 \"50 Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0 \"26.85\" 0>\n";
1199 s +=
" <Pac P2 1 270 150 18 -26 0 1 \"2\" 1 \"50 Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0 \"26.85\" 0>\n";
1200 s +=
" <GND * 1 90 180 0 0 0 0>\n";
1201 s +=
" <GND * 1 270 180 0 0 0 0>\n";
1202 s += QString(
" <SUBST SubstTC1 1 390 140 -30 24 0 0 \"%1\" 1 \"%2 mm\" 1 \"%3 um\" 1 \"%4\" 1 \"%5\" 1 \"%6\" 1>\n").
1209 s +=
" <.SP SPTC1 1 90 240 0 51 0 0 ";
1212 s += QString(
"\"log\" 1 \"%1 GHz\" 1 \"%2 GHz\" 1 ").
1213 arg(freq / 10).arg(freq * 10);
1215 s +=
"\"lin\" 1 \"0 GHz\" 1 \"10 GHz\" 1 ";
1216 s +=
"\"51\" 1 \"no\" 0 \"1\" 0 \"2\" 0>\n";
1217 s += QString(
" <MLIN MSTC1 1 180 100 -26 15 0 0 \"SubstTC1\" 1 \"%1 mm\" 1 \"%2 mm\" 1 \"Hammerstad\" 0 \"Kirschning\" 0 \"26.85\" 0>\n").
1220 s +=
" <Eqn EqnTC1 1 240 260 -23 12 0 0 \"A=twoport(S,'S','A')\" 1 \"ZL=real(sqrt(A[1,2]/A[2,1]))\" 1 \"yes\" 0>\n";
1221 s +=
"</Components>\n";
1223 s +=
" <90 100 150 100 \"\" 0 0 0 \"\">\n";
1224 s +=
" <90 100 90 120 \"\" 0 0 0 \"\">\n";
1225 s +=
" <210 100 270 100 \"\" 0 0 0 \"\">\n";
1226 s +=
" <270 100 270 120 \"\" 0 0 0 \"\">\n";
1234 s +=
"<Components>\n";
1235 s +=
" <Pac P1 1 100 130 -74 -26 1 1 \"1\" 1 \"50 Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0 \"26.85\" 0>\n";
1236 s +=
" <Pac P2 1 320 130 18 -26 0 1 \"2\" 1 \"50 Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0 \"26.85\" 0>\n";
1237 s +=
" <Pac P3 1 280 220 18 -26 0 1 \"3\" 1 \"50 Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0 \"26.85\" 0>\n";
1238 s +=
" <Pac P4 1 140 200 -74 -26 1 1 \"4\" 1 \"50 Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0 \"26.85\" 0>\n";
1239 s +=
" <GND * 1 100 160 0 0 0 0>\n";
1240 s +=
" <GND * 1 140 230 0 0 0 0>\n";
1241 s +=
" <GND * 1 320 160 0 0 0 0>\n";
1242 s +=
" <GND * 1 280 250 0 0 0 0>\n";
1243 s += QString(
" <SUBST SubstTC1 1 410 220 -30 24 0 0 \"%1\" 1 \"%2 mm\" 1 \"%3 um\" 1 \"%4\" 1 \"%5\" 1 \"%6\" 1>\n").
1250 s +=
" <.SP SPTC1 1 100 290 0 51 0 0 ";
1253 s += QString(
"\"log\" 1 \"%1 GHz\" 1 \"%2 GHz\" 1 ").
1254 arg(freq / 10).arg(freq * 10);
1256 s +=
"\"lin\" 1 \"0 GHz\" 1 \"10 GHz\" 1 ";
1257 s +=
"\"51\" 1 \"no\" 0 \"1\" 0 \"2\" 0>\n";
1258 s += QString(
" <MCOUPLED MSTC1 1 190 110 -26 37 0 0 \"SubstTC1\" 1 \"%1 mm\" 1 \"%2 mm\" 1 \"%3 mm\" 1 \"Kirschning\" 0 \"Kirschning\" 0 \"26.85\" 0>\n").
1262 s +=
"</Components>\n";
1264 s +=
" <100 80 160 80 \"\" 0 0 0 \"\">\n";
1265 s +=
" <100 80 100 100 \"\" 0 0 0 \"\">\n";
1266 s +=
" <140 140 140 170 \"\" 0 0 0 \"\">\n";
1267 s +=
" <140 140 160 140 \"\" 0 0 0 \"\">\n";
1268 s +=
" <320 80 320 100 \"\" 0 0 0 \"\">\n";
1269 s +=
" <220 80 320 80 \"\" 0 0 0 \"\">\n";
1270 s +=
" <280 140 280 190 \"\" 0 0 0 \"\">\n";
1271 s +=
" <220 140 280 140 \"\" 0 0 0 \"\">\n";
1279 s +=
"<Components>\n";
1280 s +=
" <Pac P1 1 90 150 -74 -26 1 1 \"1\" 1 \"50 Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0 \"26.85\" 0>\n";
1281 s +=
" <Pac P2 1 270 150 18 -26 0 1 \"2\" 1 \"50 Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0 \"26.85\" 0>\n";
1282 s +=
" <GND * 1 90 180 0 0 0 0>\n";
1283 s +=
" <GND * 1 270 180 0 0 0 0>\n";
1284 s +=
" <.SP SPTC1 1 90 240 0 51 0 0 ";
1287 s += QString(
"\"log\" 1 \"%1 GHz\" 1 \"%2 GHz\" 1 ").
1288 arg(freq / 10).arg(freq * 10);
1290 s +=
"\"lin\" 1 \"0 GHz\" 1 \"10 GHz\" 1 ";
1291 s +=
"\"51\" 1 \"no\" 0 \"1\" 0 \"2\" 0>\n";
1292 s += QString(
" <COAX CXTC1 1 180 100 -26 15 0 0 \"%1\" 1 \"%2\" 0 \"%3\" 0 \"%4 mm\" 1 \"%5 mm\" 1 \"%6 mm\" 1 \"%7\" 0 \"26.85\" 0>\n").
1300 s +=
"</Components>\n";
1302 s +=
" <90 100 150 100 \"\" 0 0 0 \"\">\n";
1303 s +=
" <90 100 90 120 \"\" 0 0 0 \"\">\n";
1304 s +=
" <210 100 270 100 \"\" 0 0 0 \"\">\n";
1305 s +=
" <270 100 270 120 \"\" 0 0 0 \"\">\n";
1313 s +=
"<Components>\n";
1314 s +=
" <Pac P1 1 90 150 -74 -26 1 1 \"1\" 1 \"50 Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0 \"26.85\" 0>\n";
1315 s +=
" <Pac P2 1 270 150 18 -26 0 1 \"2\" 1 \"50 Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0 \"26.85\" 0>\n";
1316 s +=
" <GND * 1 90 180 0 0 0 0>\n";
1317 s +=
" <GND * 1 270 180 0 0 0 0>\n";
1318 s += QString(
" <SUBST SubstTC1 1 390 140 -30 24 0 0 \"%1\" 1 \"%2 mm\" 1 \"%3 um\" 1 \"%4\" 1 \"%5\" 1 \"0\" 1>\n").
1324 s +=
" <.SP SPTC1 1 90 240 0 51 0 0 ";
1327 s += QString(
"\"log\" 1 \"%1 GHz\" 1 \"%2 GHz\" 1 ").
1328 arg(freq / 10).arg(freq * 10);
1330 s +=
"\"lin\" 1 \"0 GHz\" 1 \"10 GHz\" 1 ";
1331 s +=
"\"51\" 1 \"no\" 0 \"1\" 0 \"2\" 0>\n";
1332 s += QString(
" <CLIN CLTC1 1 180 100 -26 25 0 0 \"SubstTC1\" 1 \"%1 mm\" 1 \"%2 mm\" 1 \"%3 mm\" 1 \"Air\" 1 \"yes\" 0>\n").
1336 s +=
" <Eqn EqnTC1 1 240 260 -23 12 0 0 \"A=twoport(S,'S','A')\" 1 \"ZL=real(sqrt(A[1,2]/A[2,1]))\" 1 \"yes\" 0>\n";
1337 s +=
"</Components>\n";
1339 s +=
" <90 100 150 100 \"\" 0 0 0 \"\">\n";
1340 s +=
" <90 100 90 120 \"\" 0 0 0 \"\">\n";
1341 s +=
" <210 100 270 100 \"\" 0 0 0 \"\">\n";
1342 s +=
" <270 100 270 120 \"\" 0 0 0 \"\">\n";
1350 s +=
"<Components>\n";
1351 s +=
" <Pac P1 1 90 150 -74 -26 1 1 \"1\" 1 \"50 Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0 \"26.85\" 0>\n";
1352 s +=
" <Pac P2 1 270 150 18 -26 0 1 \"2\" 1 \"50 Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0 \"26.85\" 0>\n";
1353 s +=
" <GND * 1 90 180 0 0 0 0>\n";
1354 s +=
" <GND * 1 270 180 0 0 0 0>\n";
1355 s += QString(
" <SUBST SubstTC1 1 390 140 -30 24 0 0 \"%1\" 1 \"%2 mm\" 1 \"%3 um\" 1 \"%4\" 1 \"%5\" 1 \"0\" 1>\n").
1361 s +=
" <.SP SPTC1 1 90 240 0 51 0 0 ";
1364 s += QString(
"\"log\" 1 \"%1 GHz\" 1 \"%2 GHz\" 1 ").
1365 arg(freq / 10).arg(freq * 10);
1367 s +=
"\"lin\" 1 \"0 GHz\" 1 \"10 GHz\" 1 ";
1368 s +=
"\"51\" 1 \"no\" 0 \"1\" 0 \"2\" 0>\n";
1369 s += QString(
" <CLIN CLTC1 1 180 100 -26 25 0 0 \"SubstTC1\" 1 \"%1 mm\" 1 \"%2 mm\" 1 \"%3 mm\" 1 \"Metal\" 1 \"yes\" 0>\n").
1373 s +=
" <Eqn EqnTC1 1 240 260 -23 12 0 0 \"A=twoport(S,'S','A')\" 1 \"ZL=real(sqrt(A[1,2]/A[2,1]))\" 1 \"yes\" 0>\n";
1374 s +=
"</Components>\n";
1376 s +=
" <90 100 150 100 \"\" 0 0 0 \"\">\n";
1377 s +=
" <90 100 90 120 \"\" 0 0 0 \"\">\n";
1378 s +=
" <210 100 270 100 \"\" 0 0 0 \"\">\n";
1379 s +=
" <270 100 270 120 \"\" 0 0 0 \"\">\n";
1387 s +=
"<Components>\n";
1388 s +=
" <Pac P1 1 90 150 -74 -26 1 1 \"1\" 1 \"50 Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0 \"26.85\" 0>\n";
1389 s +=
" <Pac P2 1 270 150 18 -26 0 1 \"2\" 1 \"50 Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0 \"26.85\" 0>\n";
1390 s +=
" <GND * 1 90 180 0 0 0 0>\n";
1391 s +=
" <GND * 1 270 180 0 0 0 0>\n";
1392 s +=
" <.SP SPTC1 1 90 240 0 51 0 0 ";
1395 s += QString(
"\"log\" 1 \"%1 GHz\" 1 \"%2 GHz\" 1 ").
1396 arg(freq / 10).arg(freq * 10);
1398 s +=
"\"lin\" 1 \"0 GHz\" 1 \"10 GHz\" 1 ";
1399 s +=
"\"51\" 1 \"no\" 0 \"1\" 0 \"2\" 0>\n";
1400 s += QString(
" <RECTLINE RLTC1 1 180 100 -26 25 0 0 \"%1 mm\" 1 \"%2 mm\" 1 \"%3 mm\" 1 \"%4\" 0 \"%5\" 0 \"%6\" 0 \"%7\" 0 \"26.85\" 0>\n").
1408 s +=
" <Eqn EqnTC1 1 240 260 -23 12 0 0 \"A=twoport(S,'S','A')\" 1 \"ZL=real(sqrt(A[1,2]/A[2,1]))\" 1 \"yes\" 0>\n";
1409 s +=
"</Components>\n";
1411 s +=
" <90 100 150 100 \"\" 0 0 0 \"\">\n";
1412 s +=
" <90 100 90 120 \"\" 0 0 0 \"\">\n";
1413 s +=
" <210 100 270 100 \"\" 0 0 0 \"\">\n";
1414 s +=
" <270 100 270 120 \"\" 0 0 0 \"\">\n";
1420 QClipboard *cb = QApplication::clipboard();
1425 statBar->message(tr(
"Schematic copied into clipboard."), 2000);
1427 statBar->message(tr(
"Transmission line type not available."), 2000);