Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
markerdialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  markerdialog.cpp - description
3  -------------------
4  begin : Wed April 21 2004
5  copyright : (C) 2003 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 #include "markerdialog.h"
19 
20 #include <QLayout>
21 #include <QLabel>
22 #include <Q3HBox>
23 #include <QPushButton>
24 #include <QValidator>
25 //Added by qt3to4:
26 #include <Q3GridLayout>
27 #include "diagram.h"
28 
29 
30 MarkerDialog::MarkerDialog(Marker *pm_, QWidget *parent)
31  : QDialog(parent, 0, FALSE, Qt::WDestructiveClose)
32 {
33  setCaption(tr("Edit Marker Properties"));
34  pMarker = pm_;
35 
36  Q3GridLayout *g = new Q3GridLayout(this, 5,2,5,5);
37 
38  g->addWidget(new QLabel(tr("Precision: "), this), 0,0);
39  Precision = new QLineEdit(this);
40  Precision->setText(QString::number(pMarker->Precision));
41  Precision->setValidator(new QIntValidator(0, 12, this));
42  g->addWidget(Precision, 0, 1);
43  if(pMarker->Diag->Name=="Smith") //S parameter also displayed as Z, need Z0 here
44  {
45  g->addWidget(new QLabel(tr("Z0: "), this), 2,0);
46  SourceImpedance = new QLineEdit(this);
47  SourceImpedance->setText(QString::number(pMarker->Z0));
48  g->addWidget(SourceImpedance,2,1);
49  }
50  g->addWidget(new QLabel(tr("Number Notation: "), this), 1,0);
51  NumberBox = new QComboBox(this);
52  NumberBox->insertItem(tr("real/imaginary"));
53  NumberBox->insertItem(tr("magnitude/angle (degree)"));
54  NumberBox->insertItem(tr("magnitude/angle (radian)"));
55  NumberBox->setCurrentItem(pMarker->numMode);
56  g->addWidget(NumberBox, 1, 1);
57 
58  TransBox = new QCheckBox(tr("transparent"), this);
59  TransBox->setChecked(pMarker->transparent);
60  g->addMultiCellWidget(TransBox,3,3,0,1);
61 
62 
63 
64  Q3HBox *b = new Q3HBox(this);
65  b->setSpacing(5);
66  g->addMultiCellWidget(b,4,4,0,1);
67 
68  // first => activated by pressing RETURN
69  QPushButton *ButtOK = new QPushButton(tr("OK"),b);
70  connect(ButtOK, SIGNAL(clicked()), SLOT(slotAcceptValues()));
71 
72  QPushButton *ButtCancel = new QPushButton(tr("Cancel"),b);
73  connect(ButtCancel, SIGNAL(clicked()), SLOT(reject()));
74 }
75 
77 {
78 }
79 
80 // ----------------------------------------------------------
82 {
83  bool changed = false;
84  int tmp = Precision->text().toInt();
85  if(tmp != pMarker->Precision) {
86  pMarker->Precision = tmp;
87  changed = true;
88  }
89  if(pMarker->Diag->Name=="Smith")
90  {
91  double SrcImp = SourceImpedance->text().toDouble();
92  if(SrcImp != pMarker->Z0)
93  {
94  pMarker->Z0 = SrcImp;
95  changed = true;
96  }
97  }
98  if(NumberBox->currentItem() != pMarker->numMode) {
99  pMarker->numMode = NumberBox->currentItem();
100  changed = true;
101  }
102  if(TransBox->isChecked() != pMarker->transparent) {
103  pMarker->transparent = TransBox->isChecked();
104  changed = true;
105  }
106 
107  if(changed) {
108  pMarker->createText();
109  done(2);
110  }
111  else done(1);
112 }
Marker * pMarker
Definition: markerdialog.h:39
QString Name
Definition: diagram.h:92
Definition: marker.h:31
QLineEdit * Precision
Definition: markerdialog.h:42
QComboBox * NumberBox
Definition: markerdialog.h:41
QCheckBox * TransBox
Definition: markerdialog.h:44
double Z0
Definition: marker.h:63
QLineEdit * SourceImpedance
Definition: markerdialog.h:43
void slotAcceptValues()
int numMode
Definition: marker.h:62
int Precision
Definition: marker.h:61
void createText()
Definition: marker.cpp:186
bool transparent
Definition: marker.h:59
MarkerDialog(Marker *pm_, QWidget *parent=0)
Diagram * Diag
Definition: marker.h:51