Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
diagramdialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  diagramdialog.cpp
3  -------------------
4  begin : Sun Oct 5 2003
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 "diagramdialog.h"
19 #include "qucs.h"
20 #include <QPaintEvent>
21 #include "schematic.h"
22 #include "rect3ddiagram.h"
23 
24 #include <math.h>
25 
26 #include <QLayout>
27 #include <QPushButton>
28 #include <QTabWidget>
29 #include <QLabel>
30 #include <QStringList>
31 #include <QMessageBox>
32 #include <Q3PtrList>
33 #include <QValidator>
34 #include <QColorDialog>
35 #include <QLineEdit>
36 #include <QCheckBox>
37 #include <QSlider>
38 #include <QComboBox>
39 #include <QListWidget>
40 #include <QTableWidget>
41 #include <QStringList>
42 #include <QTreeWidgetItem>
43 
44 
45 #define CROSS3D_SIZE 30
46 #define WIDGET3D_SIZE 2*CROSS3D_SIZE
47 // This widget class paints a small 3-dimensional coordinate cross.
48 class Cross3D : public QWidget {
49 public:
50  Cross3D(float rx_, float ry_, float rz_, QWidget *parent = 0)
51  : QWidget(parent) {
52  rotX = rx_;
53  rotY = ry_;
54  rotZ = rz_;
55  setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
56  setMinimumSize(WIDGET3D_SIZE, WIDGET3D_SIZE);
58  };
59  ~Cross3D() {};
60 
61  double rotX, rotY, rotZ; // in radians !!!!
62 
63 private:
64  void paintEvent(QPaintEvent*) {
65  QPainter Painter(this);
66  float cxx = cos(rotZ);
67  float cxy = sin(rotZ);
68  float cxz = sin(rotY);
69  float cyz = sin(rotX);
70  float cyy = cos(rotX);
71  float cyx = cyy * cxy + cyz * cxz * cxx;
72  cyy = cyy * cxx - cyz * cxz * cxy;
73  cyz *= cos(rotY);
74  cxx *= cos(rotY);
75  cxy *= cos(rotY);
76 
77  Painter.setPen(QPen(Qt::red,2));
78  Painter.drawLine(CROSS3D_SIZE, CROSS3D_SIZE,
79  int(CROSS3D_SIZE * (1.0+cxx)),
80  int(CROSS3D_SIZE * (1.0-cyx)));
81  Painter.setPen(QPen(Qt::green,2));
82  Painter.drawLine(CROSS3D_SIZE, CROSS3D_SIZE,
83  int(CROSS3D_SIZE * (1.0-cxy)),
84  int(CROSS3D_SIZE * (1.0-cyy)));
85  Painter.setPen(QPen(Qt::blue,2));
86  Painter.drawLine(CROSS3D_SIZE, CROSS3D_SIZE,
87  int(CROSS3D_SIZE * (1.0+cxz)),
88  int(CROSS3D_SIZE * (1.0+cyz)));
89  };
90 };
91 
92 
93 
94 // standard colors: blue, red, magenta, green, cyan, yellow, grey, black
95 static const QRgb DefaultColors[]
96  = {0x0000ff, 0xff0000, 0xff00ff, 0x00ff00, 0x00ffff, 0xffff00,
97  0x777777, 0x000000};
98 
99 static const int NumDefaultColors = 8;
100 
101 
102 DiagramDialog::DiagramDialog(Diagram *d, const QString& _DataSet,
103  QWidget *parent, Graph *currentGraph)
104  : QDialog(parent, 0, TRUE, Qt::WDestructiveClose)
105 {
106  Diag = d;
107  Graphs.setAutoDelete(true);
108  copyDiagramGraphs(); // make a copy of all graphs
109  defaultDataSet = _DataSet;
110  setCaption(tr("Edit Diagram Properties"));
111  changed = false;
112  transfer = false; // have changes be applied ? (used by "Cancel")
113  toTake = false; // double-clicked variable be inserted into graph list ?
114 
115  Expr.setPattern("[^\"]+");
116  Validator = new QRegExpValidator(Expr, this);
117  ValInteger = new QIntValidator(0, 360, this);
118  ValDouble = new QDoubleValidator(-1e200, 1e200, 6, this);
119 
120  QString NameY, NameZ;
121  if((Diag->Name == "Rect") || (Diag->Name == "Curve")) {
122  NameY = tr("left Axis");
123  NameZ = tr("right Axis");
124  }
125  else if(Diag->Name == "Polar") {
126  NameY = tr("y-Axis");
127  }
128  else if((Diag->Name == "Smith") || (Diag->Name == "ySmith")) {
129  NameY = tr("y-Axis");
130  }
131  else if(Diag->Name == "PS") {
132  NameY = tr("smith Axis");
133  NameZ = tr("polar Axis");
134  }
135  else if(Diag->Name == "SP") {
136  NameY = tr("polar Axis");
137  NameZ = tr("smith Axis");
138  }
139  else if(Diag->Name == "Rect3D") {
140  NameY = tr("y-Axis");
141  NameZ = tr("z-Axis");
142  }
143 
144 
145  all = new QVBoxLayout(this); // to provide neccessary size
146  QTabWidget *t = new QTabWidget();
147  all->addWidget(t);
148 
149  // Tab #1 - Data ...........................................................
150  QWidget *Tab1 = new QWidget();
151  QVBoxLayout *Tab1Layout = new QVBoxLayout();
152  Tab1->setLayout(Tab1Layout);
153  Tab1Layout->setSpacing(5);
154 
155  Label4 = 0; // different types with same content
156  yrLabel = 0;
157  yAxisBox = 0;
158  Property2 = 0;
159  ColorButt = 0;
160  hideInvisible = 0;
161  rotationX = rotationY = rotationZ = 0;
162 
163  QGroupBox *InputGroup = new QGroupBox(tr("Graph Input"));
164  QVBoxLayout *InputGroupLayout = new QVBoxLayout();
165  InputGroup->setLayout(InputGroupLayout);
166  Tab1Layout->addWidget(InputGroup);
167  GraphInput = new QLineEdit();
168  InputGroupLayout->addWidget(GraphInput);
169  GraphInput->setValidator(Validator);
170  connect(GraphInput, SIGNAL(textChanged(const QString&)), SLOT(slotResetToTake(const QString&)));
171  QWidget *Box2 = new QWidget();
172  QHBoxLayout *Box2Layout = new QHBoxLayout();
173  Box2->setLayout(Box2Layout);
174  InputGroupLayout->addWidget(Box2);
175  Box2Layout->setSpacing(5);
176 
177  if(Diag->Name == "Tab") {
178  Label1 = new QLabel(tr("Number Notation: "));
179  Box2Layout->addWidget(Label1);
180  PropertyBox = new QComboBox();
181  Box2Layout->addWidget(PropertyBox);
182  PropertyBox->insertItem(tr("real/imaginary"));
183  PropertyBox->insertItem(tr("magnitude/angle (degree)"));
184  PropertyBox->insertItem(tr("magnitude/angle (radian)"));
185  PropertyBox->setCurrentItem(1);
186  connect(PropertyBox, SIGNAL(activated(int)), SLOT(slotSetNumMode(int)));
187  Box2Layout->setStretchFactor(new QWidget(Box2), 5); // stretchable placeholder
188 
189  Label2 = new QLabel(tr("Precision:"));
190  Box2Layout->addWidget(Label2);
191  Property2 = new QLineEdit();
192  Box2Layout->addWidget(Property2);
193  Property2->setValidator(ValInteger);
194  Property2->setMaxLength(2);
195  Property2->setMaximumWidth(25);
196  Property2->setText("3");
197  }
198  else if(Diag->Name != "Truth") {
199  Label1 = new QLabel(tr("Color:"));
200  Box2Layout->addWidget(Label1);
201  ColorButt = new QPushButton(" ");
202  Box2Layout->addWidget(ColorButt);
203  ColorButt->setMinimumWidth(50);
204  ColorButt->setEnabled(false);
205  connect(ColorButt, SIGNAL(clicked()), SLOT(slotSetColor()));
206  Box2Layout->setStretchFactor(new QWidget(Box2), 5); // stretchable placeholder
207 
208  Label3 = new QLabel(tr("Style:"));
209  Box2Layout->addWidget(Label3);
210  Label3->setEnabled(false);
211  PropertyBox = new QComboBox();
212  Box2Layout->addWidget(PropertyBox);
213  PropertyBox->insertItem(tr("solid line"));
214  PropertyBox->insertItem(tr("dash line"));
215  PropertyBox->insertItem(tr("dot line"));
216  if(Diag->Name != "Time") {
217  PropertyBox->insertItem(tr("long dash line"));
218  PropertyBox->insertItem(tr("stars"));
219  PropertyBox->insertItem(tr("circles"));
220  PropertyBox->insertItem(tr("arrows"));
221  }
222  connect(PropertyBox, SIGNAL(activated(int)),
223  SLOT(slotSetGraphStyle(int)));
224  Box2Layout->setStretchFactor(new QWidget(Box2), 5); // stretchable placeholder
225 
226  Label2 = new QLabel(tr("Thickness:"));
227  Box2Layout->addWidget(Label2);
228  Property2 = new QLineEdit();
229  Box2Layout->addWidget(Property2);
230  Property2->setValidator(ValInteger);
231  Property2->setMaximumWidth(25);
232  Property2->setMaxLength(2);
233  Property2->setText("0");
234 
235  if((Diag->Name=="Rect") || (Diag->Name=="PS") || (Diag->Name=="SP") || (Diag->Name=="Curve")) {
236 
237  QWidget *Box3 = new QWidget();
238  Box2Layout->addWidget(Box3);
239  QHBoxLayout *Box3Layout = new QHBoxLayout();
240  Box3Layout->setSpacing(5);
241  Box3->setLayout(Box3Layout);
242 
243  Label4 = new QLabel(tr("y-Axis:"));
244  Box3Layout->addWidget(Label4);
245  Label4->setEnabled(false);
246  yAxisBox = new QComboBox();
247  Box3Layout->addWidget(yAxisBox);
248  yAxisBox->insertItem(NameY);
249  yAxisBox->insertItem(NameZ);
250  yAxisBox->setEnabled(false);
251  connect(yAxisBox, SIGNAL(activated(int)), SLOT(slotSetYAxis(int)));
252  Box3Layout->setStretchFactor(new QWidget(Box3), 5); // stretchable placeholder
253  }
254  }
255  if(Property2) {
256  connect(Property2, SIGNAL(textChanged(const QString&)),
257  SLOT(slotSetProp2(const QString&)));
258 
259  Label1->setEnabled(false);
260  PropertyBox->setEnabled(false);
261  Label2->setEnabled(false);
262  Property2->setEnabled(false);
263  }
264 
265  QWidget *Box1 = new QWidget();
266  Tab1Layout->addWidget(Box1);
267  QHBoxLayout *Box1Layout = new QHBoxLayout();
268  Box1->setLayout(Box1Layout);
269  Box1Layout->setSpacing(5);
270 
271  QGroupBox *DataGroup = new QGroupBox(tr("Dataset"));
272  Box1Layout->addWidget(DataGroup);
273  QVBoxLayout *DataGroupLayout = new QVBoxLayout();
274  DataGroup->setLayout(DataGroupLayout);
275  ChooseData = new QComboBox();
276  DataGroupLayout->addWidget(ChooseData);
277  ChooseData->setMinimumWidth(200);
278  connect(ChooseData, SIGNAL(activated(int)), SLOT(slotReadVars(int)));
279  // todo: replace by QTableWidget
280  // see https://gist.github.com/ClemensFMN/8955411
281  ChooseVars = new QTableWidget(1, 3);
282  ChooseVars->setSelectionBehavior(QAbstractItemView::SelectRows);
283  //ChooseVars->selectRow(0);
284  DataGroupLayout->addWidget(ChooseVars);
285  //ChooseVars->addColumn(tr("Name"));
286  //ChooseVars->addColumn(tr("Type"));
287  //ChooseVars->addColumn(tr("Size"));
288  QStringList headers;
289  headers << tr("Name") << tr("Type") << tr("Size");
290  ChooseVars->setHorizontalHeaderLabels(headers);
291 
292  connect(ChooseVars, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), SLOT(slotTakeVar(QTableWidgetItem*)));
293 
294 
295  QGroupBox *GraphGroup = new QGroupBox(tr("Graph"));
296  Box1Layout->addWidget(GraphGroup);
297  QVBoxLayout *GraphGroupLayout = new QVBoxLayout();
298  GraphGroup->setLayout(GraphGroupLayout);
299  GraphList = new QListWidget();
300  GraphGroupLayout->addWidget(GraphList);
301  connect(GraphList, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(slotSelectGraph(QListWidgetItem*)));
302  connect(GraphList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(slotDeleteGraph()));
303  QPushButton *NewButt = new QPushButton(tr("New Graph"));
304  GraphGroupLayout->addWidget(NewButt);
305  connect(NewButt, SIGNAL(clicked()), SLOT(slotNewGraph()));
306  QPushButton *DelButt = new QPushButton(tr("Delete Graph"));
307  GraphGroupLayout->addWidget(DelButt);
308  connect(DelButt, SIGNAL(clicked()), SLOT(slotDeleteGraph()));
309 
310  t->addTab(Tab1, tr("Data"));
311 
312 
313 
314  // Tab #2...........................................................
315  int Row = 0;
316  if(Diag->Name.at(0) != 'T') { // not tabular or timing diagram
317  QWidget *Tab2 = new QWidget(t);
318  QGridLayout *gp = new QGridLayout(Tab2,13,3,5,5);
319 
320  gp->addMultiCellWidget(new QLabel(tr("x-Axis Label:"), Tab2), Row,Row,0,0);
321  xLabel = new QLineEdit(Tab2);
322  xLabel->setValidator(Validator);
323  gp->addMultiCellWidget(xLabel, Row,Row,1,2);
324  Row++;
325 
326  gp->addMultiCellWidget(
327  new QLabel(NameY+" "+tr("Label:"), Tab2), Row,Row,0,0);
328  ylLabel = new QLineEdit(Tab2);
329  ylLabel->setValidator(Validator);
330  gp->addMultiCellWidget(ylLabel, Row,Row,1,2);
331  Row++;
332 
333  if((Diag->Name != "Smith") && (Diag->Name != "Polar")) {
334  gp->addMultiCellWidget(
335  new QLabel(NameZ +" "+tr("Label:"), Tab2), Row,Row,0,0);
336  yrLabel = new QLineEdit(Tab2);
337  yrLabel->setValidator(Validator);
338  gp->addMultiCellWidget(yrLabel, Row,Row,1,2);
339  Row++;
340  }
341 
342  gp->addMultiCellWidget(new QLabel(
343  tr("<b>Label text</b>: Use LaTeX style for special characters, e.g. \\tau"),
344  Tab2), Row,Row,0,2);
345  Row++;
346 
347  if(Diag->Name != "Rect3D") {
348  GridOn = new QCheckBox(tr("show Grid"), Tab2);
349  gp->addMultiCellWidget(GridOn, Row,Row,0,2);
350  Row++;
351 
352  GridLabel1 = new QLabel(tr("Grid Color:"),Tab2);
353  gp->addMultiCellWidget(GridLabel1, Row,Row,0,0);
354  GridColorButt = new QPushButton(" ",Tab2);
355  connect(GridColorButt, SIGNAL(clicked()), SLOT(slotSetGridColor()));
356  gp->addMultiCellWidget(GridColorButt, Row,Row,1,2);
357  Row++;
358  GridColorButt->setPaletteBackgroundColor(Diag->GridPen.color());
359 
360  GridLabel2 = new QLabel(tr("Grid Style: "), Tab2);
361  gp->addMultiCellWidget(GridLabel2, Row,Row,0,0);
362  GridStyleBox = new QComboBox(Tab2);
363  GridStyleBox->insertItem(tr("solid line"));
364  GridStyleBox->insertItem(tr("dash line"));
365  GridStyleBox->insertItem(tr("dot line"));
366  GridStyleBox->insertItem(tr("dash dot line"));
367  GridStyleBox->insertItem(tr("dash dot dot line"));
368  gp->addMultiCellWidget(GridStyleBox, Row,Row,1,2);
369  Row++;
370  GridStyleBox->setCurrentItem(Diag->GridPen.style()-1);
371 
372  GridOn->setChecked(Diag->xAxis.GridOn);
373  if(!Diag->xAxis.GridOn) slotSetGridBox(0);
374  connect(GridOn, SIGNAL(stateChanged(int)), SLOT(slotSetGridBox(int)));
375  }
376  else {
377  GridOn = 0;
378  GridColorButt = 0;
379  GridStyleBox = 0;
380  }
381 
382  // ...........................................................
383  xLabel->setText(Diag->xAxis.Label);
384  ylLabel->setText(Diag->yAxis.Label);
385  if(yrLabel) yrLabel->setText(Diag->zAxis.Label);
386 
387  if((Diag->Name.left(4) == "Rect") || (Diag->Name == "Curve")) {
388  GridLogX = new QCheckBox(tr("logarithmical X Axis Grid"), Tab2);
389  gp->addMultiCellWidget(GridLogX, Row,Row,0,2);
390  Row++;
391 
392  GridLogY = new QCheckBox(tr("logarithmical")+" "+NameY+" "+tr("Grid"), Tab2);
393  gp->addMultiCellWidget(GridLogY, Row,Row,0,2);
394  Row++;
395 
396  GridLogZ = new QCheckBox(tr("logarithmical")+" "+NameZ+" "+tr("Grid"), Tab2);
397  gp->addMultiCellWidget(GridLogZ, Row,Row,0,2);
398  Row++;
399 
400  // ...........................................................
401  // transfer the diagram properties to the dialog
402  GridLogX->setChecked(Diag->xAxis.log);
403  GridLogY->setChecked(Diag->yAxis.log);
404  GridLogZ->setChecked(Diag->zAxis.log);
405 
406 
407  if(Diag->Name == "Rect3D") {
408  hideInvisible = new QCheckBox(tr("hide invisible lines"), Tab2);
409  gp->addMultiCellWidget(hideInvisible, Row,Row,0,2);
410  Row++;
411 
412  QLabel *LabelRotX = new QLabel(tr("Rotation around x-Axis:"), Tab2);
413  LabelRotX->setPaletteForegroundColor(Qt::red);
414  gp->addWidget(LabelRotX, Row,0);
415  SliderRotX = new QSlider(0,360,20, ((Rect3DDiagram*)Diag)->rotX,
416  Qt::Horizontal, Tab2);
417  gp->addWidget(SliderRotX, Row,1);
418  connect(SliderRotX, SIGNAL(valueChanged(int)), SLOT(slotNewRotX(int)));
419  rotationX = new QLineEdit(Tab2);
420  rotationX->setValidator(ValInteger);
421  rotationX->setMaxLength(3);
422  rotationX->setMaximumWidth(40);
423  gp->addWidget(rotationX, Row,2);
424  connect(rotationX, SIGNAL(textChanged(const QString&)),
425  SLOT(slotEditRotX(const QString&)));
426  Row++;
427 
428  QLabel *LabelRotY = new QLabel(tr("Rotation around y-Axis:"), Tab2);
429  LabelRotY->setPaletteForegroundColor(Qt::green);
430  gp->addWidget(LabelRotY, Row,0);
431  SliderRotY = new QSlider(0,360,20, ((Rect3DDiagram*)Diag)->rotY,
432  Qt::Horizontal, Tab2);
433  gp->addWidget(SliderRotY, Row,1);
434  connect(SliderRotY, SIGNAL(valueChanged(int)), SLOT(slotNewRotY(int)));
435  rotationY = new QLineEdit(Tab2);
436  rotationY->setValidator(ValInteger);
437  rotationY->setMaxLength(3);
438  rotationY->setMaximumWidth(40);
439  gp->addWidget(rotationY, Row,2);
440  connect(rotationY, SIGNAL(textChanged(const QString&)),
441  SLOT(slotEditRotY(const QString&)));
442  Row++;
443 
444  QLabel *LabelRotZ = new QLabel(tr("Rotation around z-Axis:"), Tab2);
445  LabelRotZ->setPaletteForegroundColor(Qt::blue);
446  gp->addWidget(LabelRotZ, Row,0);
447  SliderRotZ = new QSlider(0,360,20, ((Rect3DDiagram*)Diag)->rotZ,
448  Qt::Horizontal, Tab2);
449  gp->addWidget(SliderRotZ, Row,1);
450  connect(SliderRotZ, SIGNAL(valueChanged(int)), SLOT(slotNewRotZ(int)));
451  rotationZ = new QLineEdit(Tab2);
452  rotationZ->setValidator(ValInteger);
453  rotationZ->setMaxLength(3);
454  rotationZ->setMaximumWidth(40);
455  gp->addWidget(rotationZ, Row,2);
456  connect(rotationZ, SIGNAL(textChanged(const QString&)),
457  SLOT(slotEditRotZ(const QString&)));
458  Row++;
459 
460  gp->addWidget(new QLabel(tr("2D-projection:"), Tab2), Row,0);
461  DiagCross = new Cross3D(((Rect3DDiagram*)Diag)->rotX,
462  ((Rect3DDiagram*)Diag)->rotY,
463  ((Rect3DDiagram*)Diag)->rotZ, Tab2);
464  gp->addWidget(DiagCross, Row,1);
465 
466  // transfer the diagram properties to the dialog
467  hideInvisible->setChecked(Diag->hideLines);
468  rotationX->setText(QString::number(((Rect3DDiagram*)Diag)->rotX));
469  rotationY->setText(QString::number(((Rect3DDiagram*)Diag)->rotY));
470  rotationZ->setText(QString::number(((Rect3DDiagram*)Diag)->rotZ));
471 
472  }
473  }
474  else GridLogX = GridLogY = GridLogZ = 0;
475 
476  t->addTab(Tab2, tr("Properties"));
477 
478  // Tab #3 - Limits ...........................................................
479  QWidget *Tab3 = new QWidget();
480  QVBoxLayout *Tab3Layout = new QVBoxLayout();
481 
482  QGroupBox *axisX = new QGroupBox(tr("x-Axis"));
483  QHBoxLayout *axisXLayout = new QHBoxLayout();
484 
485  QWidget *VBox1 = new QWidget();
486  axisXLayout->addWidget(VBox1);
487  QVBoxLayout *VBox1Layout = new QVBoxLayout();
488  VBox1Layout->setStretchFactor(new QWidget(VBox1),5); // stretchable placeholder
489 
490  manualX = new QCheckBox(tr("manual"));//, VBox1);
491  VBox1Layout->addWidget(manualX);
492  VBox1->setLayout(VBox1Layout);
493  connect(manualX, SIGNAL(stateChanged(int)), SLOT(slotManualX(int)));
494 
495  QWidget *VBox2 = new QWidget();
496  axisXLayout->addWidget(VBox2);
497  QVBoxLayout *VBox2Layout = new QVBoxLayout();
498  VBox2Layout->addWidget(new QLabel(tr("start")));
499  startX = new QLineEdit();
500  VBox2Layout->addWidget(startX);
501  startX->setValidator(ValDouble);
502  VBox2->setLayout(VBox2Layout);
503 
504  QWidget *VBox3 = new QWidget();
505  axisXLayout->addWidget(VBox3);
506  QVBoxLayout *VBox3Layout = new QVBoxLayout();
507  VBox3Layout->addWidget(new QLabel(tr("step")));
508  stepX = new QLineEdit();//VBox3);
509  VBox3Layout->addWidget(stepX);
510  stepX->setValidator(ValDouble);
511  VBox3->setLayout(VBox3Layout);
512 
513  QWidget *VBox4 = new QWidget();
514  axisXLayout->addWidget(VBox4);
515  QVBoxLayout *VBox4Layout = new QVBoxLayout();
516  VBox4Layout->addWidget(new QLabel(tr("stop")));
517  stopX = new QLineEdit();
518  VBox4Layout->addWidget(stopX);
519  stopX->setValidator(ValDouble);
520  VBox4->setLayout(VBox4Layout);
521 
522  axisX->setLayout(axisXLayout);
523  Tab3Layout->addWidget(axisX);
524 
525  QGroupBox *axisY = new QGroupBox(NameY);
526  QHBoxLayout *axisYLayout = new QHBoxLayout();
527 
528  QWidget *VBox5 = new QWidget();
529  axisYLayout->addWidget(VBox5);
530  QVBoxLayout *VBox5Layout = new QVBoxLayout();
531  VBox5Layout->setStretchFactor(new QWidget(VBox5),5); // stretchable placeholder
532  manualY = new QCheckBox(tr("manual"));
533  VBox5Layout->addWidget(manualY);
534  connect(manualY, SIGNAL(stateChanged(int)), SLOT(slotManualY(int)));
535  VBox5->setLayout(VBox5Layout);
536 
537  QWidget *VBox6 = new QWidget();
538  axisYLayout->addWidget(VBox6);
539  QVBoxLayout *VBox6Layout = new QVBoxLayout();
540  VBox6Layout->addWidget(new QLabel(tr("start")));
541  startY = new QLineEdit();
542  VBox6Layout->addWidget(startY);
543  startY->setValidator(ValDouble);
544  VBox6->setLayout(VBox6Layout);
545 
546  QWidget *VBox7 = new QWidget();
547  axisYLayout->addWidget(VBox7);
548  QVBoxLayout *VBox7Layout = new QVBoxLayout();
549  if((Diag->Name=="Smith") || (Diag->Name=="ySmith") || (Diag->Name=="PS"))
550  VBox7Layout->addWidget(new QLabel(tr("number")));
551  else VBox7Layout->addWidget(new QLabel(tr("step")));
552  stepY = new QLineEdit();
553  VBox7Layout->addWidget(stepY);
554  stepY->setValidator(ValDouble);
555  VBox7->setLayout(VBox7Layout);
556 
557  QWidget *VBox8 = new QWidget();
558  axisYLayout->addWidget(VBox8);
559  QVBoxLayout *VBox8Layout = new QVBoxLayout();
560  VBox8Layout->addWidget(new QLabel(tr("stop")));
561  stopY = new QLineEdit();
562  VBox8Layout->addWidget(stopY);
563  stopY->setValidator(ValDouble);
564  VBox8->setLayout(VBox8Layout);
565 
566  axisY->setLayout(axisYLayout);
567  Tab3Layout->addWidget(axisY);
568 
569  QGroupBox *axisZ = new QGroupBox(NameZ);
570  QHBoxLayout *axisZLayout = new QHBoxLayout();
571 
572  QWidget *VBox9 = new QWidget();
573  axisZLayout->addWidget(VBox9);
574  QVBoxLayout *VBox9Layout = new QVBoxLayout();
575  VBox9Layout->setStretchFactor(new QWidget(VBox9),5); // stretchable placeholder
576  manualZ = new QCheckBox(tr("manual"));
577  VBox9Layout->addWidget(manualZ);
578  connect(manualZ, SIGNAL(stateChanged(int)), SLOT(slotManualZ(int)));
579  VBox9->setLayout(VBox9Layout);
580 
581  QWidget *VBox10 = new QWidget();
582  axisZLayout->addWidget(VBox10);
583  QVBoxLayout *VBox10Layout = new QVBoxLayout();
584  VBox10Layout->addWidget(new QLabel(tr("start")));
585  startZ = new QLineEdit();
586  VBox10Layout->addWidget(startZ);
587  startZ->setValidator(ValDouble);
588  VBox10->setLayout(VBox10Layout);
589 
590  QWidget *VBox11 = new QWidget();
591  axisZLayout->addWidget(VBox11);
592  QVBoxLayout *VBox11Layout = new QVBoxLayout();
593  if(Diag->Name == "SP") VBox11Layout->addWidget(new QLabel(tr("number")));
594  else VBox11Layout->addWidget(new QLabel(tr("step")));
595  stepZ = new QLineEdit();
596  VBox11Layout->addWidget(stepZ);
597  stepZ->setValidator(ValDouble);
598  VBox11->setLayout(VBox11Layout);
599 
600  QWidget *VBox12 = new QWidget();
601  axisZLayout->addWidget(VBox12);
602  QVBoxLayout *VBox12Layout = new QVBoxLayout();
603  VBox12Layout->addWidget(new QLabel(tr("stop")));
604  stopZ = new QLineEdit();
605  VBox12Layout->addWidget(stopZ);
606  stopZ->setValidator(ValDouble);
607  VBox12->setLayout(VBox12Layout);
608 
609  Tab3Layout->setStretchFactor(new QWidget(Tab3),5); // stretchable placeholder
610 
611  axisZ->setLayout(axisZLayout);
612  Tab3Layout->addWidget(axisZ);
613 
614  Tab3->setLayout(Tab3Layout);
615  t->addTab(Tab3, tr("Limits"));
616 
617  // ...........................................................
618  // transfer the diagram properties to the dialog
620  else manualX->setChecked(true);
622  else manualY->setChecked(true);
624  else manualZ->setChecked(true);
625 
626  Diag->calcLimits(); // inserts auto-scale values if not manual
627 
628  startX->setText(QString::number(Diag->xAxis.limit_min));
629  stepX->setText(QString::number(Diag->xAxis.step));
630  stopX->setText(QString::number(Diag->xAxis.limit_max));
631 
632  startY->setText(QString::number(Diag->yAxis.limit_min));
633  stepY->setText(QString::number(Diag->yAxis.step));
634  stopY->setText(QString::number(Diag->yAxis.limit_max));
635 
636  startZ->setText(QString::number(Diag->zAxis.limit_min));
637  stepZ->setText(QString::number(Diag->zAxis.step));
638  stopZ->setText(QString::number(Diag->zAxis.limit_max));
639 
640  if((Diag->Name == "Smith") || (Diag->Name == "ySmith") ||
641  (Diag->Name == "Polar")) {
642  axisZ->setEnabled(false);
643  }
644  if(Diag->Name.left(4) != "Rect") // cartesian 2D and 3D
645  if(Diag->Name != "Curve") {
646  axisX->setEnabled(false);
647  startY->setEnabled(false);
648  startZ->setEnabled(false);
649  }
650  }
651  else stepX = 0;
652 
653  connect(t, SIGNAL(currentChanged(QWidget*)), SLOT(slotChangeTab(QWidget*)));
654  // ...........................................................
655  QWidget *Butts = new QWidget();
656  QHBoxLayout *ButtsLayout = new QHBoxLayout();
657  ButtsLayout->setSpacing(5);
658  ButtsLayout->setMargin(5);
659  Butts->setLayout(ButtsLayout);
660  all->addWidget(Butts);
661 
662  QPushButton *OkButt = new QPushButton(tr("OK"));
663  ButtsLayout->addWidget(OkButt);
664  connect(OkButt, SIGNAL(clicked()), SLOT(slotOK()));
665  QPushButton *ApplyButt = new QPushButton(tr("Apply"));
666  ButtsLayout->addWidget(ApplyButt);
667  connect(ApplyButt, SIGNAL(clicked()), SLOT(slotApply()));
668  QPushButton *CancelButt = new QPushButton(tr("Cancel"));
669  ButtsLayout->addWidget(CancelButt);
670  connect(CancelButt, SIGNAL(clicked()), SLOT(slotCancel()));
671 
672  OkButt->setDefault(true);
673 
674 
675  // ...........................................................
676  // put all data files into ComboBox
677  QFileInfo Info(defaultDataSet);
678  QDir ProjDir(Info.dirPath());
679  QStringList Elements = ProjDir.entryList("*.dat", QDir::Files, QDir::Name);
680  QStringList::iterator it;
681  for(it = Elements.begin(); it != Elements.end(); ++it) {
682  ChooseData->insertItem((*it).left((*it).length()-4));
683  if((*it) == Info.fileName())
684  // default dataset should be the current
685  ChooseData->setCurrentItem(ChooseData->count()-1);
686  }
687  slotReadVars(0); // put variables into the ListView
688 
689  // ...........................................................
690  // put all graphs into the ListBox
691  Row = 0;
692  for(Graph *pg = Diag->Graphs.first(); pg != 0; pg = Diag->Graphs.next()) {
693  GraphList->insertItem(Row, pg->Var);
694  if(pg == currentGraph) {
695  GraphList->setCurrentRow(Row); // select current graph
696  SelectGraph(currentGraph);
697  }
698  Row++;
699  }
700 
701  if(ColorButt)
702  if(!currentGraph)
703  ColorButt->setPaletteBackgroundColor
704  (QColor(DefaultColors[GraphList->count()%NumDefaultColors]));
705 }
706 
708 {
709  delete all; // delete all widgets from heap
710  delete ValInteger;
711  delete ValDouble;
712  delete Validator;
713 }
714 
715 // --------------------------------------------------------------------------
717 {
718  QFileInfo Info(defaultDataSet);
719  QString DocName = ChooseData->currentText()+".dat";
720 
721  QFile file(Info.dirPath() + QDir::separator() + DocName);
722  if(!file.open(QIODevice::ReadOnly)) {
723  return;
724  }
725 
726  QString Line, tmp, Var;
727  int varNumber = 0;
728  // reading the file as a whole improves speed very much, also using
729  // a QByteArray rather than a QString
730  QByteArray FileString = file.readAll();
731  file.close();
732 
733  ChooseVars->clear();
734  int i=0, j=0;
735  i = FileString.find('<')+1;
736  if(i > 0)
737  do {
738  j = FileString.find('>', i);
739  for(int k=0;k<j-i;k++) Line[k]=FileString[k+i];
740  Line.truncate(j-i);
741  i = FileString.find('<', j)+1;
742 
743  Var = Line.section(' ', 1, 1).remove('>');
744  if(Var.length()>0)
745  if(Var.at(0) == '_') continue;
746 
747  if(Line.left(3) == "dep") {
748  tmp = Line.section(' ', 2);
749  //new Q3ListViewItem(ChooseVars, Var, "dep", tmp.remove('>'));
750  qDebug() << varNumber << Var << tmp.remove('>');
751  ChooseVars->setRowCount(varNumber+1);
752  QTableWidgetItem *cell = new QTableWidgetItem(Var);
753  cell->setFlags(cell->flags() ^ Qt::ItemIsEditable);
754  ChooseVars->setItem(varNumber, 0, cell);
755  cell = new QTableWidgetItem("dep");
756  cell->setFlags(cell->flags() ^ Qt::ItemIsEditable);
757  ChooseVars->setItem(varNumber, 1, cell);
758  cell = new QTableWidgetItem(tmp.remove('>'));
759  cell->setFlags(cell->flags() ^ Qt::ItemIsEditable);
760  ChooseVars->setItem(varNumber, 2, cell);
761  varNumber++;
762  }
763  else if(Line.left(5) == "indep") {
764  tmp = Line.section(' ', 2, 2);
765  //new Q3ListViewItem(ChooseVars, Var, "indep", tmp.remove('>'));
766  qDebug() << varNumber << Var << tmp.remove('>');
767  ChooseVars->setRowCount(varNumber+1);
768  QTableWidgetItem *cell = new QTableWidgetItem(Var);
769  cell->setFlags(cell->flags() ^ Qt::ItemIsEditable);
770  ChooseVars->setItem(varNumber, 0, cell);
771  cell = new QTableWidgetItem("indep");
772  cell->setFlags(cell->flags() ^ Qt::ItemIsEditable);
773  ChooseVars->setItem(varNumber, 1, cell);
774  cell = new QTableWidgetItem(tmp.remove('>'));
775  cell->setFlags(cell->flags() ^ Qt::ItemIsEditable);
776  ChooseVars->setItem(varNumber, 2, cell);
777  varNumber++;
778 
779  }
780  } while(i > 0);
781 }
782 
783 // ------------------------------------------------------------------------
784 // Inserts the double-clicked variable into the Graph Input Line at the
785 // cursor position. If the Graph Input is empty, then the variable is
786 // also inserted as graph.
787 void DiagramDialog::slotTakeVar(QTableWidgetItem* Item)
788 {
789  GraphInput->blockSignals(true);
790  if(toTake) GraphInput->setText("");
791 
792  int i = GraphInput->cursorPosition();
793  //QString s="";
794  //QString s1 = Item->text();
795  int row = Item->row();
796  QString s1 = ChooseVars->item(row, 0)->text();
797  QFileInfo Info(defaultDataSet);
798  if(ChooseData->currentText() != Info.baseName(true))
799  s1 = ChooseData->currentText() + ":" + s1;
800  GraphInput->setText(s1);
801 
802  //if(s.isEmpty()) {
803  GraphList->addItem(GraphInput->text());
804  GraphList->setCurrentRow(GraphList->count()-1);
805 
806  Graph *g = new Graph(GraphInput->text()); // create a new graph
807 
808  if(Diag->Name != "Tab") {
809  if(Diag->Name != "Truth") {
810  g->Color = ColorButt->paletteBackgroundColor();
811  g->Thick = Property2->text().toInt();
812  ColorButt->setPaletteBackgroundColor(
813  QColor(DefaultColors[GraphList->count()%NumDefaultColors]));
814  if(g->Var.right(3) == ".Vb") // harmonic balance output ?
815  if(PropertyBox->count() >= GRAPHSTYLE_ARROW)
816  PropertyBox->setCurrentItem(GRAPHSTYLE_ARROW);
817  g->Style = PropertyBox->currentItem();
818  if(yAxisBox) {
819  g->yAxisNo = yAxisBox->currentItem();
820  yAxisBox->setEnabled(true);
821  Label4->setEnabled(true);
822  }
823  else if(Diag->Name == "Rect3D") g->yAxisNo = 1;
824 
825  Label3->setEnabled(true);
826  ColorButt->setEnabled(true);
827  }
828  }
829  else {
830  g->Precision = Property2->text().toInt();
831  g->numMode = PropertyBox->currentItem();
832  }
833 
834  Graphs.append(g);
835  changed = true;
836  toTake = true;
837  //}
838 
839  GraphInput->blockSignals(false);
840 
841  if(Property2) {
842  Label1->setEnabled(true);
843  PropertyBox->setEnabled(true);
844  Label2->setEnabled(true);
845  Property2->setEnabled(true);
846  }
847 }
848 
849 // --------------------------------------------------------------------------
850 // Is called if a graph text is clicked in the BistBox.
851 void DiagramDialog::slotSelectGraph(QListWidgetItem *item)
852 {
853  if(item == 0) {
854  GraphList->clearSelection();
855  return;
856  }
857 
858  SelectGraph (Graphs.at (GraphList->currentRow()));
859 }
860 
861 // --------------------------------------------------------------------------
862 // Puts the text of the selected graph into the line edit.
864 {
865  GraphInput->blockSignals(true);
866  GraphInput->setText(g->Var);
867  GraphInput->blockSignals(false);
868 
869  if(Diag->Name != "Tab") {
870  if(Diag->Name != "Truth") {
871  Property2->setText(QString::number(g->Thick));
872  ColorButt->setPaletteBackgroundColor(g->Color);
873  PropertyBox->setCurrentItem(g->Style);
874  if(yAxisBox) {
875  yAxisBox->setCurrentItem(g->yAxisNo);
876  yAxisBox->setEnabled(true);
877  Label4->setEnabled(true);
878  }
879 
880  Label3->setEnabled(true);
881  ColorButt->setEnabled(true);
882  }
883  }
884  else {
885  Property2->setText(QString::number(g->Precision));
886  PropertyBox->setCurrentItem(g->numMode);
887  }
888  toTake = false;
889 
890  if(Property2) {
891  Label1->setEnabled(true);
892  PropertyBox->setEnabled(true);
893  Label2->setEnabled(true);
894  Property2->setEnabled(true);
895  }
896 }
897 
898 // --------------------------------------------------------------------------
899 // Is called when the 'delelte graph' button is pressed.
901 {
902  int i = GraphList->currentRow();
903  if(i < 0) return; // return, if no item selected
904 
905  GraphList->takeItem(i);
906  Graphs.remove(i);
907 
908  int k=0;
909  if (GraphList->count()!=0) {
910  if (i>(GraphList->count()-1)) {
911  k = GraphList->count()-1;
912  } else {
913  k=i;
914  }
915  GraphInput->setText(GraphList->item(k)->text());
916  } else {
917  GraphInput->setText(""); // erase input line and back to default values
918  }
919 
920  if(Diag->Name != "Tab") {
921  if(Diag->Name != "Truth") {
922  ColorButt->setPaletteBackgroundColor(
923  QColor(DefaultColors[GraphList->count()%NumDefaultColors]));
924  Property2->setText("0");
925  if(yAxisBox) {
926  yAxisBox->setCurrentItem(0);
927  yAxisBox->setEnabled(false);
928  Label4->setEnabled(false);
929  }
930 
931  Label3->setEnabled(false);
932  ColorButt->setEnabled(false);
933  }
934  }
935  else Property2->setText("3");
936  changed = true;
937  toTake = false;
938 
939  if(Property2) {
940  PropertyBox->setCurrentItem(0);
941 
942  Label1->setEnabled(false);
943  PropertyBox->setEnabled(false);
944  Label2->setEnabled(false);
945  Property2->setEnabled(false);
946  }
947 }
948 
949 // --------------------------------------------------------------------------
951 {
952  if(GraphInput->text().isEmpty()) return;
953 
954  GraphList->addItem(GraphInput->text());
955 
956  Graph *g = new Graph(GraphInput->text()); // create a new graph
957  if(Diag->Name != "Tab") {
958  if(Diag->Name != "Truth") {
959  g->Color = ColorButt->paletteBackgroundColor();
960  g->Thick = Property2->text().toInt();
961  g->Style = PropertyBox->currentItem();
962  if(yAxisBox) g->yAxisNo = yAxisBox->currentItem();
963  else if(Diag->Name == "Rect3D") g->yAxisNo = 1;
964  }
965  }
966  else {
967  g->Precision = Property2->text().toInt();
968  g->numMode = PropertyBox->currentItem();
969  }
970  Graphs.append(g);
971  changed = true;
972  toTake = false;
973 }
974 
975 // --------------------------------------------------------------------------
976 // Is called if "Ok" button is pressed.
978 {
979  slotApply();
980  slotCancel();
981 }
982 
983 // --------------------------------------------------------------------------
984 // Is called if "Apply" button is pressed.
986 {
987  if(Diag->Name.at(0) != 'T') { // not tabular or timing
988  if(Diag->xAxis.Label.isEmpty())
989  Diag->xAxis.Label = ""; // can be not 0 and empty!
990  if(xLabel->text().isEmpty()) xLabel->setText("");
991  if(Diag->xAxis.Label != xLabel->text()) {
992  Diag->xAxis.Label = xLabel->text();
993  changed = true;
994  }
995  if(Diag->yAxis.Label.isEmpty())
996  Diag->yAxis.Label = ""; // can be not 0 and empty!
997  if(ylLabel->text().isEmpty()) ylLabel->setText("");
998  if(Diag->yAxis.Label != ylLabel->text()) {
999  Diag->yAxis.Label = ylLabel->text();
1000  changed = true;
1001  }
1002 
1003  if(GridOn) if(Diag->xAxis.GridOn != GridOn->isChecked()) {
1004  Diag->xAxis.GridOn = GridOn->isChecked();
1005  Diag->yAxis.GridOn = GridOn->isChecked();
1006  changed = true;
1007  }
1008  if(GridColorButt)
1009  if(Diag->GridPen.color() != GridColorButt->paletteBackgroundColor()) {
1010  Diag->GridPen.setColor(GridColorButt->paletteBackgroundColor());
1011  changed = true;
1012  }
1013  if(GridStyleBox)
1014  if(Diag->GridPen.style()!=(Qt::PenStyle)(GridStyleBox->currentItem()+1)) {
1015  Diag->GridPen.setStyle((Qt::PenStyle)(GridStyleBox->currentItem()+1));
1016  changed = true;
1017  }
1018  if((Diag->Name != "Smith") && (Diag->Name != "Polar")) {
1019  if(Diag->zAxis.Label.isEmpty())
1020  Diag->zAxis.Label = ""; // can be not 0 and empty!
1021  if(yrLabel->text().isEmpty()) yrLabel->setText("");
1022  if(Diag->zAxis.Label != yrLabel->text()) {
1023  Diag->zAxis.Label = yrLabel->text();
1024  changed = true;
1025  }
1026  }
1027 
1028  if(Diag->Name.left(4) == "Rect") {
1029  if(Diag->xAxis.log != GridLogX->isChecked()) {
1030  Diag->xAxis.log = GridLogX->isChecked();
1031  changed = true;
1032  }
1033  if(Diag->yAxis.log != GridLogY->isChecked()) {
1034  Diag->yAxis.log = GridLogY->isChecked();
1035  changed = true;
1036  }
1037  if(Diag->zAxis.log != GridLogZ->isChecked()) {
1038  Diag->zAxis.log = GridLogZ->isChecked();
1039  changed = true;
1040  }
1041  }
1042 
1043  if((Diag->Name == "Smith") || (Diag->Name == "ySmith") ||
1044  (Diag->Name == "PS"))
1045  if(stopY->text().toDouble() < 1.0)
1046  stopY->setText("1");
1047 
1048  if(Diag->Name == "SP")
1049  if(stopZ->text().toDouble() < 1.0)
1050  stopZ->setText("1");
1051 
1052  if(Diag->xAxis.autoScale == manualX->isChecked()) {
1053  Diag->xAxis.autoScale = !(manualX->isChecked());
1054  changed = true;
1055  }
1056 
1057  // Use string compares for all floating point numbers, in
1058  // order to avoid rounding problems.
1059  if(QString::number(Diag->xAxis.limit_min) != startX->text()) {
1060  Diag->xAxis.limit_min = startX->text().toDouble();
1061  changed = true;
1062  }
1063  if(QString::number(Diag->xAxis.step) != stepX->text()) {
1064  Diag->xAxis.step = stepX->text().toDouble();
1065  changed = true;
1066  }
1067  if(QString::number(Diag->xAxis.limit_max) != stopX->text()) {
1068  Diag->xAxis.limit_max = stopX->text().toDouble();
1069  changed = true;
1070  }
1071  if(Diag->yAxis.autoScale == manualY->isChecked()) {
1072  Diag->yAxis.autoScale = !(manualY->isChecked());
1073  changed = true;
1074  }
1075  if(QString::number(Diag->yAxis.limit_min) != startY->text()) {
1076  Diag->yAxis.limit_min = startY->text().toDouble();
1077  changed = true;
1078  }
1079  if(QString::number(Diag->yAxis.step) != stepY->text()) {
1080  Diag->yAxis.step = stepY->text().toDouble();
1081  changed = true;
1082  }
1083  if(QString::number(Diag->yAxis.limit_max) != stopY->text()) {
1084  Diag->yAxis.limit_max = stopY->text().toDouble();
1085  changed = true;
1086  }
1087  if(Diag->zAxis.autoScale == manualZ->isChecked()) {
1088  Diag->zAxis.autoScale = !(manualZ->isChecked());
1089  changed = true;
1090  }
1091  if(QString::number(Diag->zAxis.limit_min) != startZ->text()) {
1092  Diag->zAxis.limit_min = startZ->text().toDouble();
1093  changed = true;
1094  }
1095  if(QString::number(Diag->zAxis.step) != stepZ->text()) {
1096  Diag->zAxis.step = stepZ->text().toDouble();
1097  changed = true;
1098  }
1099  if(QString::number(Diag->zAxis.limit_max) != stopZ->text()) {
1100  Diag->zAxis.limit_max = stopZ->text().toDouble();
1101  changed = true;
1102  }
1103 
1104  // for "rect3D"
1105  if(hideInvisible)
1106  if(((Rect3DDiagram*)Diag)->hideLines != hideInvisible->isChecked()) {
1107  ((Rect3DDiagram*)Diag)->hideLines = hideInvisible->isChecked();
1108  changed = true;
1109  }
1110 
1111  if(rotationX)
1112  if(((Rect3DDiagram*)Diag)->rotX != rotationX->text().toInt()) {
1113  ((Rect3DDiagram*)Diag)->rotX = rotationX->text().toInt();
1114  changed = true;
1115  }
1116 
1117  if(rotationY)
1118  if(((Rect3DDiagram*)Diag)->rotY != rotationY->text().toInt()) {
1119  ((Rect3DDiagram*)Diag)->rotY = rotationY->text().toInt();
1120  changed = true;
1121  }
1122 
1123  if(rotationZ)
1124  if(((Rect3DDiagram*)Diag)->rotZ != rotationZ->text().toInt()) {
1125  ((Rect3DDiagram*)Diag)->rotZ = rotationZ->text().toInt();
1126  changed = true;
1127  }
1128 
1129  } // of "if(Diag->Name != "Tab")"
1130 
1131  Diag->Graphs.clear(); // delete the graphs
1132  Graphs.setAutoDelete(false);
1133  for(Graph *pg = Graphs.first(); pg != 0; pg = Graphs.next())
1134  Diag->Graphs.append(pg); // transfer the new graphs to diagram
1135  Graphs.clear();
1136  Graphs.setAutoDelete(true);
1137 
1139  ((Schematic*)parent())->viewport()->repaint();
1141  if(changed) transfer = true; // changes have been applied ?
1142 }
1143 
1144 
1145 // --------------------------------------------------------------------------
1146 // Is called if "Cancel" button is pressed.
1148 {
1149 // Diag->loadGraphData(defaultDataSet);
1150 // ((QucsView*)parent())->viewport()->repaint();
1151  if(transfer) done(QDialog::Accepted);
1152  else done(QDialog::Rejected);
1153 }
1154 
1155 //-----------------------------------------------------------------
1156 // To get really all close events (even <Escape> key).
1158 {
1159  slotCancel();
1160 }
1161 
1162 // --------------------------------------------------------------------------
1164 {
1165  QColor c = QColorDialog::getColor(ColorButt->paletteBackgroundColor(),this);
1166  if(!c.isValid()) return;
1167  ColorButt->setPaletteBackgroundColor(c);
1168 
1169  int i = GraphList->currentRow();
1170  if(i < 0) return; // return, if no item selected
1171 
1172  Graph *g = Graphs.at(i);
1173  g->Color = c;
1174  changed = true;
1175  toTake = false;
1176 }
1177 
1178 // --------------------------------------------------------------------------
1180 {
1181  QColor c = QColorDialog::getColor(
1182  GridColorButt->paletteBackgroundColor(),this);
1183  if(!c.isValid()) return;
1184  GridColorButt->setPaletteBackgroundColor(c);
1185  changed = true;
1186 }
1187 
1188 // --------------------------------------------------------------------------
1189 // Is set if the graph input line changes.
1190 void DiagramDialog::slotResetToTake(const QString& s)
1191 {
1192  int i = GraphList->currentRow();
1193  if(i < 0) return; // return, if no item selected
1194 
1195  Graph *g = Graphs.at(i);
1196  g->Var = s;
1197  // \todo GraphList->changeItem(s, i); // must done after the graph settings !!!
1198  changed = true;
1199  toTake = false;
1200 }
1201 
1202 // --------------------------------------------------------------------------
1203 // Is called if the user changes the graph thickness or the precision.
1204 void DiagramDialog::slotSetProp2(const QString& s)
1205 {
1206  int i = GraphList->currentRow();
1207  if(i < 0) return; // return, if no item selected
1208 
1209  Graph *g = Graphs.at(i);
1210  if(Diag->Name == "Tab") g->Precision = s.toInt();
1211  else g->Thick = s.toInt();
1212  changed = true;
1213  toTake = false;
1214 }
1215 
1216 // --------------------------------------------------------------------------
1217 // Is called if the user changes the number mode.
1219 {
1220  int i = GraphList->currentRow();
1221  if(i < 0) return; // return, if no item selected
1222 
1223  Graph *g = Graphs.at(i);
1224  g->numMode = Mode;
1225  changed = true;
1226  toTake = false;
1227 }
1228 
1229 // --------------------------------------------------------------------------
1230 // Is called when the "show grid" checkbox is changed.
1232 {
1233  if(state == 2) {
1234  GridColorButt->setEnabled(true);
1235  GridStyleBox->setEnabled(true);
1236  GridLabel1->setEnabled(true);
1237  GridLabel2->setEnabled(true);
1238  }
1239  else {
1240  GridColorButt->setEnabled(false);
1241  GridStyleBox->setEnabled(false);
1242  GridLabel1->setEnabled(false);
1243  GridLabel2->setEnabled(false);
1244  }
1245 }
1246 
1247 // --------------------------------------------------------------------------
1248 // Is called if the user changes the graph style (combobox).
1250 {
1251  int i = GraphList->currentRow();
1252  if(i < 0) return; // return, if no item selected
1253 
1254  Graph *g = Graphs.at(i);
1255  g->Style = style;
1256  changed = true;
1257  toTake = false;
1258 }
1259 
1260 // --------------------------------------------------------------------------
1261 // Makes a copy of all graphs in the diagram.
1263 {
1264  for(Graph *pg = Diag->Graphs.first(); pg != 0; pg = Diag->Graphs.next())
1265  Graphs.append(pg->sameNewOne());
1266 }
1267 
1268 // --------------------------------------------------------------------------
1269 // Is called if the combobox changes that defines which y axis uses the graph.
1271 {
1272  int i = GraphList->currentRow();
1273  if(i < 0) return; // return, if no item selected
1274 
1275  Graph *g = Graphs.at(i);
1276  g->yAxisNo = axis;
1277  changed = true;
1278  toTake = false;
1279 }
1280 
1281 // --------------------------------------------------------------------------
1283 {
1284  if(state == 2) {
1285  if((Diag->Name.left(4) == "Rect") || (Diag->Name == "Curve"))
1286  startX->setEnabled(true);
1287  stopX->setEnabled(true);
1288  if(GridLogX) if(GridLogX->isChecked()) return;
1289  stepX->setEnabled(true);
1290  }
1291  else {
1292  startX->setEnabled(false);
1293  stepX->setEnabled(false);
1294  stopX->setEnabled(false);
1295  }
1296 }
1297 
1298 // --------------------------------------------------------------------------
1300 {
1301  if(state == 2) {
1302  if((Diag->Name.left(4) == "Rect") || (Diag->Name == "Curve"))
1303  startY->setEnabled(true);
1304  stopY->setEnabled(true);
1305  if(GridLogY) if(GridLogY->isChecked()) return;
1306  stepY->setEnabled(true);
1307  }
1308  else {
1309  startY->setEnabled(false);
1310  stepY->setEnabled(false);
1311  stopY->setEnabled(false);
1312  }
1313 }
1314 
1315 // --------------------------------------------------------------------------
1317 {
1318  if(state == 2) {
1319  if((Diag->Name.left(4) == "Rect") || (Diag->Name == "Curve"))
1320  startZ->setEnabled(true);
1321  stopZ->setEnabled(true);
1322  if(GridLogZ) if(GridLogZ->isChecked()) return;
1323  stepZ->setEnabled(true);
1324  }
1325  else {
1326  startZ->setEnabled(false);
1327  stepZ->setEnabled(false);
1328  stopZ->setEnabled(false);
1329  }
1330 }
1331 
1332 // --------------------------------------------------------------------------
1333 // Is called if the current tab of the QTabWidget changes.
1335 {
1336  if(stepX == 0) return; // defined ?
1337  if(GridLogX) {
1338  if(GridLogX->isChecked()) stepX->setEnabled(false);
1339  else if(manualX->isChecked()) stepX->setEnabled(true);
1340  }
1341  if(GridLogY) {
1342  if(GridLogY->isChecked()) stepY->setEnabled(false);
1343  else if(manualY->isChecked()) stepY->setEnabled(true);
1344  }
1345  if(GridLogZ) {
1346  if(GridLogZ->isChecked()) stepZ->setEnabled(false);
1347  else if(manualZ->isChecked()) stepZ->setEnabled(true);
1348  }
1349 }
1350 
1351 // --------------------------------------------------------------------------
1352 // Is called when the slider for rotation angle is changed.
1354 {
1355  rotationX->setText(QString::number(Value));
1356  DiagCross->rotX = float(Value) * M_PI/180.0;
1357  DiagCross->update();
1358 }
1359 
1360 // --------------------------------------------------------------------------
1361 // Is called when the slider for rotation angle is changed.
1363 {
1364  rotationY->setText(QString::number(Value));
1365  DiagCross->rotY = float(Value) * M_PI/180.0;
1366  DiagCross->update();
1367 }
1368 
1369 // --------------------------------------------------------------------------
1370 // Is called when the slider for rotation angle is changed.
1372 {
1373  rotationZ->setText(QString::number(Value));
1374  DiagCross->rotZ = float(Value) * M_PI/180.0;
1375  DiagCross->update();
1376 }
1377 
1378 // --------------------------------------------------------------------------
1379 // Is called when the number (text) for rotation angle is changed.
1380 void DiagramDialog::slotEditRotX(const QString& Text)
1381 {
1382  SliderRotX->setValue(Text.toInt());
1383  DiagCross->rotX = Text.toFloat() * M_PI/180.0;
1384  DiagCross->update();
1385 }
1386 
1387 // --------------------------------------------------------------------------
1388 // Is called when the number (text) for rotation angle is changed.
1389 void DiagramDialog::slotEditRotY(const QString& Text)
1390 {
1391  SliderRotY->setValue(Text.toInt());
1392  DiagCross->rotY = Text.toFloat() * M_PI/180.0;
1393  DiagCross->update();
1394 }
1395 
1396 // --------------------------------------------------------------------------
1397 // Is called when the number (text) for rotation angle is changed.
1398 void DiagramDialog::slotEditRotZ(const QString& Text)
1399 {
1400  SliderRotZ->setValue(Text.toInt());
1401  DiagCross->rotZ = Text.toFloat() * M_PI/180.0;
1402  DiagCross->update();
1403 }
QLabel * Label2
QSlider * SliderRotZ
static const int NumDefaultColors
QCheckBox * GridOn
Axis xAxis
Definition: diagram.h:101
void slotManualY(int)
QCheckBox * manualX
int Thick
Definition: graph.h:77
void slotNewRotX(int)
QLineEdit * startY
int Precision
Definition: graph.h:82
QLineEdit * startZ
void slotSetProp2(const QString &)
void slotManualZ(int)
QLineEdit * yrLabel
QComboBox * ChooseData
Definition: diagramdialog.h:99
void slotReadVars(int)
QIntValidator * ValInteger
Definition: diagramdialog.h:96
void slotManualX(int)
QLineEdit * stepY
Definition: graph.h:57
QLineEdit * stopY
QLabel * Label1
QPushButton * GridColorButt
void slotNewRotY(int)
QString Name
Definition: diagram.h:92
void slotChangeTab(QWidget *)
QLineEdit * stopX
QLineEdit * stepZ
bool hideLines
Definition: diagram.h:104
#define WIDGET3D_SIZE
double rotY
Diagram * Diag
Definition: diagramdialog.h:91
QLineEdit * rotationY
QPushButton * ColorButt
QCheckBox * hideInvisible
double limit_min
Definition: diagram.h:56
Q3PtrList< Graph > Graphs
QCheckBox * manualZ
void slotSetGraphStyle(int)
void slotTakeVar(QTableWidgetItem *item)
QCheckBox * manualY
bool GridOn
Definition: diagram.h:53
QLabel * GridLabel2
QComboBox * GridStyleBox
QString Var
Definition: graph.h:75
QPen GridPen
Definition: diagram.h:93
virtual void calcLimits()
Definition: diagram.h:69
QLineEdit * startX
#define GRAPHSTYLE_ARROW
Definition: graph.h:41
QCheckBox * GridLogZ
void slotEditRotY(const QString &)
void slotDeleteGraph()
void slotSetNumMode(int)
QComboBox * yAxisBox
QLabel * Label4
Axis zAxis
Definition: diagram.h:101
QLineEdit * stepX
Q3PtrList< Graph > Graphs
Definition: diagram.h:95
bool log
Definition: diagram.h:50
double rotX
Definition: element.h:82
QLabel * Label3
QLineEdit * Property2
Definition: element.h:48
void slotEditRotX(const QString &)
QLineEdit * xLabel
QDoubleValidator * ValDouble
Definition: diagramdialog.h:95
QCheckBox * GridLogY
double limit_max
Definition: diagram.h:56
int numMode
Definition: graph.h:83
QTableWidget * ChooseVars
void paintEvent(QPaintEvent *)
QString Label
Definition: diagram.h:51
int Style
Definition: graph.h:78
QLabel * GridLabel1
QColor Color
Definition: graph.h:76
void slotResetToTake(const QString &)
QString defaultDataSet
Definition: diagramdialog.h:92
Axis yAxis
Definition: diagram.h:101
void slotSetGridBox(int)
void copyDiagramGraphs()
QRegExpValidator * Validator
Definition: diagramdialog.h:97
void SelectGraph(Graph *)
void slotSetYAxis(int)
QSlider * SliderRotY
double step
Definition: diagram.h:56
QVBoxLayout * all
QLineEdit * rotationX
void loadGraphData(const QString &)
Definition: diagram.cpp:724
QLineEdit * rotationZ
double rotZ
Cross3D * DiagCross
void slotEditRotZ(const QString &)
#define M_PI
Definition: diagramdialog.h:25
#define CROSS3D_SIZE
static const QRgb DefaultColors[]
QListWidget * GraphList
void slotSelectGraph(QListWidgetItem *)
QLineEdit * ylLabel
bool autoScale
Definition: diagram.h:55
QSlider * SliderRotX
QLineEdit * stopZ
DiagramDialog(Diagram *d, const QString &_DataSet, QWidget *parent=0, Graph *currentGraph=0)
void slotNewRotZ(int)
QLineEdit * GraphInput
QCheckBox * GridLogX
Cross3D(float rx_, float ry_, float rz_, QWidget *parent=0)
int yAxisNo
Definition: graph.h:70
QComboBox * PropertyBox