My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
qucstrans.h
Go to the documentation of this file.
1 /***************************************************************************
2  qucstrans.h - description
3  -------------------
4  begin : Sun Feb 27 2005
5  copyright : (C) 2005 by Stefan Jahn
6  email : stefan@lkcc.org
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 
18 #ifndef QUCSTRANS_H
19 #define QUCSTRANS_H
20 
21 #include <qdialog.h>
22 #include <qfont.h>
23 #include <qstring.h>
24 
25 class QComboBox;
26 class QLineEdit;
27 class QLabel;
28 class QHGroupBox;
29 class QVBox;
30 class QVBoxLayout;
31 class QRadioButton;
32 class QGridLayout;
33 class QStatusBar;
34 class QTextStream;
35 class QButtonGroup;
36 class QWidgetStack;
37 
38 class transline;
39 
40 // Current limit defintions.
41 #define MAX_TRANS_BOXES 4
42 #define MAX_TRANS_TYPES 6
43 #define MAX_TRANS_RESULTS 7
44 
45 // Types of transmission line properties.
46 #define TRANS_SUBSTRATE 0
47 #define TRANS_COMPONENT 1
48 #define TRANS_PHYSICAL 2
49 #define TRANS_ELECTRICAL 3
50 
51 #define TRANS_FREQS { "GHz", "Hz", "kHz", "MHz", NULL }
52 #define TRANS_OHMS { "Ohm", "kOhm", NULL }
53 #define TRANS_ANGLES { "Deg", "Rad", NULL }
54 #define TRANS_LENGTHS { "mil", "cm", "mm", "m", "um", "in", "ft", NULL }
55 #define TRANS_NONES { "NA", NULL }
56 
57 // Application settings.
58 struct tQucsSettings {
59  int x, y, dx, dy; // position and size of main window
60  QFont font; // font
61  QString BitmapDir; // pixmap directory
62  QString LangDir; // translation directory
63  QString Language;
64  int length_unit; // default length unit
65  int freq_unit; // default frequency unit
66  int res_unit; // default resistance unit
67  int ang_unit; // default angle unit
68  QString Mode; // current mode
69 };
70 
72 
73 // Transmission line value.
74 struct TransValue {
75  const char * name; // label
76  double value; // value
77  QString * tip; // tool tip description
78  const char * units[8]; // unit choise
79  int unit; // unit index
80  QLabel * label; // Qt label widget
81  QLineEdit * lineedit; // Qt value widget
82  QComboBox * combobox; // Qt unit widget
83  QRadioButton * radio; // Qt fixed widget
84  QWidgetStack * stack; // Qt fixed stack
85 };
86 
87 // Array of transmission line values.
88 struct TransArray {
89  struct TransValue item[12];
90 };
91 
92 // Extraneous calculation results.
93 struct TransResult {
94  QString * name; // textual description
95  QLabel * label; // Qt name widget
96  QLabel * value; // Qt value widget
97 };
98 
99 // Transmission line types.
100 enum TransMode {
108 };
109 
110 // A transmission line type structure.
111 struct TransType {
112  int type; // type of transmission line (see TransMode)
113  const char * description; // description
114  const char * bitmap; // bitmap file name
115  transline * line; // transmission line instance
117  int results; // number of extraneous results
119  int radio[4];
120 };
121 
122 struct TransUnit {
123  const char * description;
124  const char * units[8];
125 };
126 
131 class QucsTranscalc : public QDialog {
132  Q_OBJECT
133 public:
134  QucsTranscalc();
135  ~QucsTranscalc();
136 
137  void setProperty (QString, double);
138  double getProperty (QString);
139  void setUnit (QString, const char *);
140  char * getUnit (QString);
141  void setResult (int, const char *);
142  bool isSelected (QString);
143 
144  void saveMode (QTextStream&);
145  void saveModes (QTextStream&);
146  bool loadFile (QString, int * _mode = 0);
147  QString getMode (void);
148  void setMode (QString);
149  static int translateUnit(const char *, int);
150 
151 private slots:
152  void slotAbout();
153  void slotQuit();
154  void slotSelectType(int);
155  void slotSynthesize();
156  void slotAnalyze();
157  void slotValueChanged();
158  void slotFileLoad();
159  void slotFileSave();
160  void slotHelpIntro();
161  void slotOptions();
162  void slotRadioChecked(int);
163  void slotCopyToClipBoard();
164 
165 private:
166  void updateSelection ();
167  void createPropItem (QVBox **, TransValue *, int, QButtonGroup *);
168  void createResultItem (QVBox **, TransResult *);
169  void updateResultItem (TransResult *);
170  void createResultItems (QHGroupBox *);
171  void updateResultItems ();
172  void createPropItems (QHGroupBox *, int);
173  int getTypeIndex ();
174  void updatePropItem (TransValue *);
175  void setMode (int);
176  struct TransValue * findProperty (QString);
177  void setupTranslations ();
178  bool saveFile (QString);
179  void updateMode (void);
180  void storeValues (void);
181  void updatePixmap (int);
182 
183  private:
184  void closeEvent (QCloseEvent*);
185 
186 private:
187  QStatusBar * statBar;
188  QLabel * pix;
189  QComboBox * tranType;
190  QHGroupBox * calculated;
191  int mode;
192 };
193 
194 #endif /* QUCSTRANS_H */