Qucs-GUI  0.0.19
/home/travis/build/Qucs/qucs/qucs/qucs/diagrams/markerdialog.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           markerdialog.cpp  -  description
00003                              -------------------
00004     begin                : Wed April 21 2004
00005     copyright            : (C) 2003 by Michael Margraf
00006     email                : michael.margraf@alumni.tu-berlin.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 #include "markerdialog.h"
00018 #include "diagram.h"
00019 
00020 #include <QLabel>
00021 #include <QLineEdit>
00022 #include <QPushButton>
00023 #include <QValidator>
00024 #include <QGridLayout>
00025 #include <QComboBox>
00026 #include <QCheckBox>
00027 
00028 
00029 MarkerDialog::MarkerDialog(Marker *pm_, QWidget *parent)
00030                      : QDialog(parent, 0, FALSE, Qt::WDestructiveClose)
00031 {
00032   setWindowTitle(tr("Edit Marker Properties"));
00033   pMarker = pm_;
00034 
00035   QGridLayout *g = new QGridLayout;
00036 
00037   Precision = new QLineEdit();
00038   Precision->setText(QString::number(pMarker->Precision));
00039   Precision->setValidator(new QIntValidator(0, 12, this));
00040 
00041   g->addWidget(new QLabel(tr("Precision: ")), 0, 0);
00042   g->addWidget(Precision, 0, 1);
00043 
00044   NumberBox = new QComboBox();
00045   NumberBox->insertItem(tr("real/imaginary"));
00046   NumberBox->insertItem(tr("magnitude/angle (degree)"));
00047   NumberBox->insertItem(tr("magnitude/angle (radian)"));
00048   NumberBox->setCurrentItem(pMarker->numMode);
00049 
00050   g->addWidget(new QLabel(tr("Number Notation: ")), 1,0);
00051   g->addWidget(NumberBox, 1, 1);
00052 
00053   assert(pMarker->diag());
00054   if(pMarker->diag()->Name=="Smith") // BUG
00055   {
00056     //S parameter also displayed as Z, need Z0 here
00057     SourceImpedance = new QLineEdit();
00058     SourceImpedance->setText(QString::number(pMarker->Z0));
00059 
00060     g->addWidget(new QLabel(tr("Z0: ")), 2,0);
00061     g->addWidget(SourceImpedance,2,1);
00062   }
00063   
00064   TransBox = new QCheckBox(tr("transparent"));
00065   TransBox->setChecked(pMarker->transparent);
00066   g->addMultiCellWidget(TransBox,3,3,0,1);
00067 
00068   // first => activated by pressing RETURN
00069   QPushButton *ButtOK = new QPushButton(tr("OK"));
00070   connect(ButtOK, SIGNAL(clicked()), SLOT(slotAcceptValues()));
00071 
00072   QPushButton *ButtCancel = new QPushButton(tr("Cancel"));
00073   connect(ButtCancel, SIGNAL(clicked()), SLOT(reject()));
00074 
00075   QHBoxLayout *b = new QHBoxLayout();
00076   b->setSpacing(5);
00077   b->addWidget(ButtOK);
00078   b->addWidget(ButtCancel);
00079   g->addMultiCellLayout(b,4,4,0,1);
00080 
00081   this->setLayout(g);
00082 }
00083 
00084 MarkerDialog::~MarkerDialog()
00085 {
00086 }
00087 
00088 // ----------------------------------------------------------
00089 void MarkerDialog::slotAcceptValues()
00090 {
00091   bool changed = false;
00092   int tmp = Precision->text().toInt();
00093   if(tmp != pMarker->Precision) {
00094     pMarker->Precision = tmp;
00095     changed = true;
00096   }
00097   assert(pMarker->diag());
00098   if(pMarker->diag()->Name=="Smith") // BUG: need generic MarkerDialog.
00099   {
00100       double SrcImp = SourceImpedance->text().toDouble();
00101       if(SrcImp != pMarker->Z0)
00102       {
00103           pMarker->Z0 = SrcImp;
00104           changed = true;
00105       }
00106   }
00107   if(NumberBox->currentItem() != pMarker->numMode) {
00108     pMarker->numMode = NumberBox->currentItem();
00109     changed = true;
00110   }
00111   if(TransBox->isChecked() != pMarker->transparent) {
00112     pMarker->transparent = TransBox->isChecked();
00113     changed = true;
00114   }
00115 
00116   if(changed) {
00117     pMarker->createText();
00118     done(2);
00119   }
00120   else done(1);
00121 }
00122 
00123 // vim:ts=8:sw=2:noet
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines