27 #include <qhbuttongroup.h>
28 #include <qvbuttongroup.h>
29 #include <qhgroupbox.h>
30 #include <qpushbutton.h>
31 #include <qtabwidget.h>
33 #include <qstringlist.h>
34 #include <qmessagebox.h>
36 #include <qvalidator.h>
37 #include <qcolordialog.h>
38 #include <qlineedit.h>
39 #include <qcheckbox.h>
41 #include <qcombobox.h>
42 #include <qlistview.h>
46 #define CROSS3D_SIZE 30
47 #define WIDGET3D_SIZE 2*CROSS3D_SIZE
51 Cross3D(
float rx_,
float ry_,
float rz_, QWidget *parent = 0)
56 setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
65 void paintEvent(QPaintEvent*) {
66 QPainter Painter(
this);
72 float cyx = cyy * cxy + cyz * cxz * cxx;
73 cyy = cyy * cxx - cyz * cxz * cxy;
78 Painter.setPen(QPen(QPen::red,2));
82 Painter.setPen(QPen(QPen::green,2));
86 Painter.setPen(QPen(QPen::blue,2));
97 static const QRgb DefaultColors[]
98 = {0x0000ff, 0xff0000, 0xff00ff, 0x00ff00, 0x00ffff, 0xffff00,
103 QWidget *parent,
Graph *currentGraph)
104 : QDialog(parent, 0, TRUE, Qt::WDestructiveClose)
107 Graphs.setAutoDelete(
true);
109 defaultDataSet = _DataSet;
110 setCaption(tr(
"Edit Diagram Properties"));
115 Expr.setPattern(
"[^\"]+");
116 Validator =
new QRegExpValidator(Expr,
this);
117 ValInteger =
new QIntValidator(0, 360,
this);
118 ValDouble =
new QDoubleValidator(-1e200, 1e200, 6,
this);
120 QString NameY, NameZ;
121 if((Diag->
Name ==
"Rect") || (Diag->
Name ==
"Curve")) {
122 NameY = tr(
"left Axis");
123 NameZ = tr(
"right Axis");
125 else if(Diag->
Name ==
"Polar") {
126 NameY = tr(
"y-Axis");
128 else if((Diag->
Name ==
"Smith") || (Diag->
Name ==
"ySmith")) {
129 NameY = tr(
"y-Axis");
131 else if(Diag->
Name ==
"PS") {
132 NameY = tr(
"smith Axis");
133 NameZ = tr(
"polar Axis");
135 else if(Diag->
Name ==
"SP") {
136 NameY = tr(
"polar Axis");
137 NameZ = tr(
"smith Axis");
139 else if(Diag->
Name ==
"Rect3D") {
140 NameY = tr(
"y-Axis");
141 NameZ = tr(
"z-Axis");
145 all =
new QVBoxLayout(
this);
146 QTabWidget *
t =
new QTabWidget(
this);
150 QVBox *Tab1 =
new QVBox(
this);
159 rotationX = rotationY = rotationZ = 0;
161 QVButtonGroup *InputGroup =
new QVButtonGroup(tr(
"Graph Input"), Tab1);
162 GraphInput =
new QLineEdit(InputGroup);
163 GraphInput->setValidator(Validator);
164 connect(GraphInput, SIGNAL(textChanged(
const QString&)),
165 SLOT(slotResetToTake(
const QString&)));
166 QHBox *Box2 =
new QHBox(InputGroup);
169 if(Diag->
Name ==
"Tab") {
170 Label1 =
new QLabel(tr(
"Number Notation: "), Box2);
171 PropertyBox =
new QComboBox(Box2);
172 PropertyBox->insertItem(tr(
"real/imaginary"));
173 PropertyBox->insertItem(tr(
"magnitude/angle (degree)"));
174 PropertyBox->insertItem(tr(
"magnitude/angle (radian)"));
175 PropertyBox->setCurrentItem(1);
176 connect(PropertyBox, SIGNAL(activated(
int)), SLOT(slotSetNumMode(
int)));
177 Box2->setStretchFactor(
new QWidget(Box2), 5);
179 Label2 =
new QLabel(tr(
"Precision:"), Box2);
180 Property2 =
new QLineEdit(Box2);
181 Property2->setValidator(ValInteger);
182 Property2->setMaxLength(2);
183 Property2->setMaximumWidth(25);
184 Property2->setText(
"3");
186 else if(Diag->
Name !=
"Truth") {
187 Label1 =
new QLabel(tr(
"Color:"),Box2);
188 ColorButt =
new QPushButton(
" ",Box2);
189 ColorButt->setMinimumWidth(50);
190 ColorButt->setEnabled(
false);
191 connect(ColorButt, SIGNAL(clicked()), SLOT(slotSetColor()));
192 Box2->setStretchFactor(
new QWidget(Box2), 5);
194 Label3 =
new QLabel(tr(
"Style:"),Box2);
195 Label3->setEnabled(
false);
196 PropertyBox =
new QComboBox(Box2);
197 PropertyBox->insertItem(tr(
"solid line"));
198 PropertyBox->insertItem(tr(
"dash line"));
199 PropertyBox->insertItem(tr(
"dot line"));
200 if(Diag->
Name !=
"Time") {
201 PropertyBox->insertItem(tr(
"long dash line"));
202 PropertyBox->insertItem(tr(
"stars"));
203 PropertyBox->insertItem(tr(
"circles"));
204 PropertyBox->insertItem(tr(
"arrows"));
206 connect(PropertyBox, SIGNAL(activated(
int)),
207 SLOT(slotSetGraphStyle(
int)));
208 Box2->setStretchFactor(
new QWidget(Box2), 5);
210 Label2 =
new QLabel(tr(
"Thickness:"),Box2);
211 Property2 =
new QLineEdit(Box2);
212 Property2->setValidator(ValInteger);
213 Property2->setMaximumWidth(25);
214 Property2->setMaxLength(2);
215 Property2->setText(
"0");
217 if((Diag->
Name==
"Rect") || (Diag->
Name==
"PS") || (Diag->
Name==
"SP") ||
218 (Diag->
Name==
"Curve")) {
219 QHBox *Box3 =
new QHBox(InputGroup);
222 Label4 =
new QLabel(tr(
"y-Axis:"),Box3);
223 Label4->setEnabled(
false);
224 yAxisBox =
new QComboBox(Box3);
225 yAxisBox->insertItem(NameY);
226 yAxisBox->insertItem(NameZ);
227 yAxisBox->setEnabled(
false);
228 connect(yAxisBox, SIGNAL(activated(
int)), SLOT(slotSetYAxis(
int)));
229 Box3->setStretchFactor(
new QWidget(Box3), 5);
233 connect(Property2, SIGNAL(textChanged(
const QString&)),
234 SLOT(slotSetProp2(
const QString&)));
236 Label1->setEnabled(
false);
237 PropertyBox->setEnabled(
false);
238 Label2->setEnabled(
false);
239 Property2->setEnabled(
false);
242 QHBox *Box1 =
new QHBox(Tab1);
245 QVButtonGroup *DataGroup =
new QVButtonGroup(tr(
"Dataset"), Box1);
246 ChooseData =
new QComboBox(
false, DataGroup);
247 ChooseData->setMinimumWidth(200);
248 connect(ChooseData, SIGNAL(activated(
int)), SLOT(slotReadVars(
int)));
249 ChooseVars =
new QListView(DataGroup);
250 ChooseVars->addColumn(tr(
"Name"));
251 ChooseVars->addColumn(tr(
"Type"));
252 ChooseVars->addColumn(tr(
"Size"));
253 connect(ChooseVars, SIGNAL(doubleClicked(QListViewItem*)),
254 SLOT(slotTakeVar(QListViewItem*)));
257 QVButtonGroup *GraphGroup =
new QVButtonGroup(tr(
"Graph"), Box1);
258 GraphList =
new QListBox(GraphGroup);
259 connect(GraphList, SIGNAL(clicked(QListBoxItem*)),
260 SLOT(slotSelectGraph(QListBoxItem*)));
261 connect(GraphList, SIGNAL(doubleClicked(QListBoxItem*)),
262 SLOT(slotDeleteGraph()));
263 QPushButton *NewButt =
new QPushButton(tr(
"New Graph"), GraphGroup);
264 connect(NewButt, SIGNAL(clicked()), SLOT(slotNewGraph()));
265 QPushButton *DelButt =
new QPushButton(tr(
"Delete Graph"), GraphGroup);
266 connect(DelButt, SIGNAL(clicked()), SLOT(slotDeleteGraph()));
268 t->addTab(Tab1, tr(
"Data"));
272 if(Diag->
Name.at(0) !=
'T') {
273 QWidget *Tab2 =
new QWidget(t);
274 QGridLayout *gp =
new QGridLayout(Tab2,13,3,5,5);
276 gp->addMultiCellWidget(
new QLabel(tr(
"x-Axis Label:"), Tab2), Row,Row,0,0);
277 xLabel =
new QLineEdit(Tab2);
278 xLabel->setValidator(Validator);
279 gp->addMultiCellWidget(xLabel, Row,Row,1,2);
282 gp->addMultiCellWidget(
283 new QLabel(NameY+
" "+tr(
"Label:"), Tab2), Row,Row,0,0);
284 ylLabel =
new QLineEdit(Tab2);
285 ylLabel->setValidator(Validator);
286 gp->addMultiCellWidget(ylLabel, Row,Row,1,2);
289 if((Diag->
Name !=
"Smith") && (Diag->
Name !=
"Polar")) {
290 gp->addMultiCellWidget(
291 new QLabel(NameZ +
" "+tr(
"Label:"), Tab2), Row,Row,0,0);
292 yrLabel =
new QLineEdit(Tab2);
293 yrLabel->setValidator(Validator);
294 gp->addMultiCellWidget(yrLabel, Row,Row,1,2);
298 gp->addMultiCellWidget(
new QLabel(
299 tr(
"<b>Label text</b>: Use LaTeX style for special characters, e.g. \\tau"),
303 if(Diag->
Name !=
"Rect3D") {
304 GridOn =
new QCheckBox(tr(
"show Grid"), Tab2);
305 gp->addMultiCellWidget(GridOn, Row,Row,0,2);
308 GridLabel1 =
new QLabel(tr(
"Grid Color:"),Tab2);
309 gp->addMultiCellWidget(GridLabel1, Row,Row,0,0);
310 GridColorButt =
new QPushButton(
" ",Tab2);
311 connect(GridColorButt, SIGNAL(clicked()), SLOT(slotSetGridColor()));
312 gp->addMultiCellWidget(GridColorButt, Row,Row,1,2);
314 GridColorButt->setPaletteBackgroundColor(Diag->
GridPen.color());
316 GridLabel2 =
new QLabel(tr(
"Grid Style: "), Tab2);
317 gp->addMultiCellWidget(GridLabel2, Row,Row,0,0);
318 GridStyleBox =
new QComboBox(Tab2);
319 GridStyleBox->insertItem(tr(
"solid line"));
320 GridStyleBox->insertItem(tr(
"dash line"));
321 GridStyleBox->insertItem(tr(
"dot line"));
322 GridStyleBox->insertItem(tr(
"dash dot line"));
323 GridStyleBox->insertItem(tr(
"dash dot dot line"));
324 gp->addMultiCellWidget(GridStyleBox, Row,Row,1,2);
326 GridStyleBox->setCurrentItem(Diag->
GridPen.style()-1);
329 if(!Diag->
xAxis.
GridOn) slotSetGridBox(QButton::Off);
330 connect(GridOn, SIGNAL(stateChanged(
int)), SLOT(slotSetGridBox(
int)));
341 if(yrLabel) yrLabel->setText(Diag->
zAxis.
Label);
343 if((Diag->
Name.left(4) ==
"Rect") || (Diag->
Name ==
"Curve")) {
344 GridLogX =
new QCheckBox(tr(
"logarithmical X Axis Grid"), Tab2);
345 gp->addMultiCellWidget(GridLogX, Row,Row,0,2);
348 GridLogY =
new QCheckBox(tr(
"logarithmical")+
" "+NameY+
" "+tr(
"Grid"), Tab2);
349 gp->addMultiCellWidget(GridLogY, Row,Row,0,2);
352 GridLogZ =
new QCheckBox(tr(
"logarithmical")+
" "+NameZ+
" "+tr(
"Grid"), Tab2);
353 gp->addMultiCellWidget(GridLogZ, Row,Row,0,2);
358 GridLogX->setChecked(Diag->
xAxis.
log);
359 GridLogY->setChecked(Diag->
yAxis.
log);
360 GridLogZ->setChecked(Diag->
zAxis.
log);
363 if(Diag->
Name ==
"Rect3D") {
364 hideInvisible =
new QCheckBox(tr(
"hide invisible lines"), Tab2);
365 gp->addMultiCellWidget(hideInvisible, Row,Row,0,2);
368 QLabel *LabelRotX =
new QLabel(tr(
"Rotation around x-Axis:"), Tab2);
369 LabelRotX->setPaletteForegroundColor(Qt::red);
370 gp->addWidget(LabelRotX, Row,0);
371 SliderRotX =
new QSlider(0,360,20, ((
Rect3DDiagram*)Diag)->rotX,
372 Qt::Horizontal, Tab2);
373 gp->addWidget(SliderRotX, Row,1);
374 connect(SliderRotX, SIGNAL(valueChanged(
int)), SLOT(slotNewRotX(
int)));
375 rotationX =
new QLineEdit(Tab2);
376 rotationX->setValidator(ValInteger);
377 rotationX->setMaxLength(3);
378 rotationX->setMaximumWidth(40);
379 gp->addWidget(rotationX, Row,2);
380 connect(rotationX, SIGNAL(textChanged(
const QString&)),
381 SLOT(slotEditRotX(
const QString&)));
384 QLabel *LabelRotY =
new QLabel(tr(
"Rotation around y-Axis:"), Tab2);
385 LabelRotY->setPaletteForegroundColor(Qt::green);
386 gp->addWidget(LabelRotY, Row,0);
387 SliderRotY =
new QSlider(0,360,20, ((
Rect3DDiagram*)Diag)->rotY,
388 Qt::Horizontal, Tab2);
389 gp->addWidget(SliderRotY, Row,1);
390 connect(SliderRotY, SIGNAL(valueChanged(
int)), SLOT(slotNewRotY(
int)));
391 rotationY =
new QLineEdit(Tab2);
392 rotationY->setValidator(ValInteger);
393 rotationY->setMaxLength(3);
394 rotationY->setMaximumWidth(40);
395 gp->addWidget(rotationY, Row,2);
396 connect(rotationY, SIGNAL(textChanged(
const QString&)),
397 SLOT(slotEditRotY(
const QString&)));
400 QLabel *LabelRotZ =
new QLabel(tr(
"Rotation around z-Axis:"), Tab2);
401 LabelRotZ->setPaletteForegroundColor(Qt::blue);
402 gp->addWidget(LabelRotZ, Row,0);
403 SliderRotZ =
new QSlider(0,360,20, ((
Rect3DDiagram*)Diag)->rotZ,
404 Qt::Horizontal, Tab2);
405 gp->addWidget(SliderRotZ, Row,1);
406 connect(SliderRotZ, SIGNAL(valueChanged(
int)), SLOT(slotNewRotZ(
int)));
407 rotationZ =
new QLineEdit(Tab2);
408 rotationZ->setValidator(ValInteger);
409 rotationZ->setMaxLength(3);
410 rotationZ->setMaximumWidth(40);
411 gp->addWidget(rotationZ, Row,2);
412 connect(rotationZ, SIGNAL(textChanged(
const QString&)),
413 SLOT(slotEditRotZ(
const QString&)));
416 gp->addWidget(
new QLabel(tr(
"2D-projection:"), Tab2), Row,0);
420 gp->addWidget(DiagCross, Row,1);
423 hideInvisible->setChecked(Diag->
hideLines);
424 rotationX->setText(QString::number(((
Rect3DDiagram*)Diag)->rotX));
425 rotationY->setText(QString::number(((
Rect3DDiagram*)Diag)->rotY));
426 rotationZ->setText(QString::number(((
Rect3DDiagram*)Diag)->rotZ));
430 else GridLogX = GridLogY = GridLogZ = 0;
432 t->addTab(Tab2, tr(
"Properties"));
435 QVBox *Tab3 =
new QVBox(
this);
438 QHGroupBox *axisX =
new QHGroupBox(tr(
"x-Axis"), Tab3);
440 QVBox *VBox1 =
new QVBox(axisX);
441 VBox1->setStretchFactor(
new QWidget(VBox1),5);
442 manualX =
new QCheckBox(tr(
"manual"), VBox1);
443 connect(manualX, SIGNAL(stateChanged(
int)), SLOT(slotManualX(
int)));
445 QVBox *VBox2 =
new QVBox(axisX);
446 new QLabel(tr(
"start"), VBox2);
447 startX =
new QLineEdit(VBox2);
448 startX->setValidator(ValDouble);
450 QVBox *VBox3 =
new QVBox(axisX);
451 new QLabel(tr(
"step"), VBox3);
452 stepX =
new QLineEdit(VBox3);
453 stepX->setValidator(ValDouble);
455 QVBox *VBox4 =
new QVBox(axisX);
456 new QLabel(tr(
"stop"), VBox4);
457 stopX =
new QLineEdit(VBox4);
458 stopX->setValidator(ValDouble);
462 axisY =
new QHGroupBox(NameY, Tab3);
464 QVBox *VBox5 =
new QVBox(axisY);
465 VBox5->setStretchFactor(
new QWidget(VBox5),5);
466 manualY =
new QCheckBox(tr(
"manual"), VBox5);
467 connect(manualY, SIGNAL(stateChanged(
int)), SLOT(slotManualY(
int)));
469 QVBox *VBox6 =
new QVBox(axisY);
470 new QLabel(tr(
"start"), VBox6);
471 startY =
new QLineEdit(VBox6);
472 startY->setValidator(ValDouble);
474 QVBox *VBox7 =
new QVBox(axisY);
475 if((Diag->
Name==
"Smith") || (Diag->
Name==
"ySmith") || (Diag->
Name==
"PS"))
476 new QLabel(tr(
"number"), VBox7);
477 else new QLabel(tr(
"step"), VBox7);
478 stepY =
new QLineEdit(VBox7);
479 stepY->setValidator(ValDouble);
481 QVBox *VBox8 =
new QVBox(axisY);
482 new QLabel(tr(
"stop"), VBox8);
483 stopY =
new QLineEdit(VBox8);
484 stopY->setValidator(ValDouble);
488 axisZ =
new QHGroupBox(NameZ, Tab3);
490 QVBox *VBox9 =
new QVBox(axisZ);
491 VBox9->setStretchFactor(
new QWidget(VBox9),5);
492 manualZ =
new QCheckBox(tr(
"manual"), VBox9);
493 connect(manualZ, SIGNAL(stateChanged(
int)), SLOT(slotManualZ(
int)));
495 QVBox *VBox10 =
new QVBox(axisZ);
496 new QLabel(tr(
"start"), VBox10);
497 startZ =
new QLineEdit(VBox10);
498 startZ->setValidator(ValDouble);
500 QVBox *VBox11 =
new QVBox(axisZ);
501 if(Diag->
Name ==
"SP")
new QLabel(tr(
"number"), VBox11);
502 else new QLabel(tr(
"step"), VBox11);
503 stepZ =
new QLineEdit(VBox11);
504 stepZ->setValidator(ValDouble);
506 QVBox *VBox12 =
new QVBox(axisZ);
507 new QLabel(tr(
"stop"), VBox12);
508 stopZ =
new QLineEdit(VBox12);
509 stopZ->setValidator(ValDouble);
512 Tab3->setStretchFactor(
new QWidget(Tab3),5);
514 t->addTab(Tab3, tr(
"Limits"));
519 else manualX->setChecked(
true);
521 else manualY->setChecked(
true);
523 else manualZ->setChecked(
true);
528 stepX->setText(QString::number(Diag->
xAxis.
step));
532 stepY->setText(QString::number(Diag->
yAxis.
step));
536 stepZ->setText(QString::number(Diag->
zAxis.
step));
539 if((Diag->
Name ==
"Smith") || (Diag->
Name ==
"ySmith") ||
540 (Diag->
Name ==
"Polar")) {
541 axisZ->setEnabled(
false);
543 if(Diag->
Name.left(4) !=
"Rect")
544 if(Diag->
Name !=
"Curve") {
545 axisX->setEnabled(
false);
546 startY->setEnabled(
false);
547 startZ->setEnabled(
false);
552 connect(t, SIGNAL(currentChanged(QWidget*)), SLOT(slotChangeTab(QWidget*)));
554 QHBox *Butts =
new QHBox(
this);
555 Butts->setSpacing(5);
557 all->addWidget(Butts);
559 QPushButton *OkButt =
new QPushButton(tr(
"OK"), Butts);
560 connect(OkButt, SIGNAL(clicked()), SLOT(slotOK()));
561 QPushButton *ApplyButt =
new QPushButton(tr(
"Apply"), Butts);
562 connect(ApplyButt, SIGNAL(clicked()), SLOT(slotApply()));
563 QPushButton *CancelButt =
new QPushButton(tr(
"Cancel"), Butts);
564 connect(CancelButt, SIGNAL(clicked()), SLOT(slotCancel()));
566 OkButt->setDefault(
true);
571 QFileInfo Info(defaultDataSet);
572 QDir ProjDir(Info.dirPath());
573 QStringList Elements = ProjDir.entryList(
"*.dat", QDir::Files, QDir::Name);
574 QStringList::iterator it;
575 for(it = Elements.begin(); it != Elements.end(); ++it) {
576 ChooseData->insertItem((*it).left((*it).length()-4));
577 if((*it) == Info.fileName())
579 ChooseData->setCurrentItem(ChooseData->count()-1);
587 GraphList->insertItem(pg->Var);
588 if(pg == currentGraph) {
589 GraphList->setCurrentItem(Row);
590 SelectGraph(currentGraph);
597 ColorButt->setPaletteBackgroundColor
598 (QColor(DefaultColors[GraphList->count()]));
610 void DiagramDialog::slotReadVars(
int)
612 QFileInfo Info(defaultDataSet);
613 QString DocName = ChooseData->currentText()+
".dat";
615 QFile file(Info.dirPath() + QDir::separator() + DocName);
616 if(!file.open(IO_ReadOnly)) {
620 QString
Line, tmp, Var;
623 QByteArray FileString = file.readAll();
628 i = FileString.find(
'<')+1;
631 j = FileString.find(
'>', i);
632 for(
int k=0;k<j-
i;k++) Line[k]=FileString[k+i];
634 i = FileString.find(
'<', j)+1;
636 Var = Line.section(
' ', 1, 1).remove(
'>');
637 if(Var.at(0) ==
'_')
continue;
639 if(Line.left(3) ==
"dep") {
640 tmp = Line.section(
' ', 2);
641 new QListViewItem(ChooseVars, Var,
"dep", tmp.remove(
'>'));
643 else if(Line.left(5) ==
"indep") {
644 tmp = Line.section(
' ', 2, 2);
645 new QListViewItem(ChooseVars, Var,
"indep", tmp.remove(
'>'));
654 void DiagramDialog::slotTakeVar(QListViewItem *Item)
656 GraphInput->blockSignals(
true);
657 if(toTake) GraphInput->setText(
"");
659 int i = GraphInput->cursorPosition();
660 QString
s = GraphInput->text();
661 QString s1 = Item->text(0);
662 QFileInfo Info(defaultDataSet);
663 if(ChooseData->currentText() != Info.baseName(
true))
664 s1 = ChooseData->currentText() +
":" + s1;
665 GraphInput->setText(s.left(i) + s1 + s.right(s.length()-
i));
668 GraphList->insertItem(GraphInput->text());
669 GraphList->setSelected(GraphList->count()-1,
true);
673 if(Diag->
Name !=
"Tab") {
674 if(Diag->
Name !=
"Truth") {
675 g->
Color = ColorButt->paletteBackgroundColor();
676 g->
Thick = Property2->text().toInt();
677 ColorButt->setPaletteBackgroundColor(
678 QColor(DefaultColors[GraphList->count()]));
679 if(g->
Var.right(3) ==
".Vb")
682 g->
Style = PropertyBox->currentItem();
684 g->
yAxisNo = yAxisBox->currentItem();
685 yAxisBox->setEnabled(
true);
686 Label4->setEnabled(
true);
690 Label3->setEnabled(
true);
691 ColorButt->setEnabled(
true);
695 g->
Precision = Property2->text().toInt();
696 g->
numMode = PropertyBox->currentItem();
704 GraphInput->blockSignals(
false);
707 Label1->setEnabled(
true);
708 PropertyBox->setEnabled(
true);
709 Label2->setEnabled(
true);
710 Property2->setEnabled(
true);
716 void DiagramDialog::slotSelectGraph(QListBoxItem *item)
719 GraphList->clearSelection();
723 SelectGraph (Graphs.at (GraphList->index(item)));
728 void DiagramDialog::SelectGraph(
Graph *g)
730 GraphInput->blockSignals(
true);
731 GraphInput->setText(g->
Var);
732 GraphInput->blockSignals(
false);
734 if(Diag->
Name !=
"Tab") {
735 if(Diag->
Name !=
"Truth") {
736 Property2->setText(QString::number(g->
Thick));
737 ColorButt->setPaletteBackgroundColor(g->
Color);
738 PropertyBox->setCurrentItem(g->
Style);
740 yAxisBox->setCurrentItem(g->
yAxisNo);
741 yAxisBox->setEnabled(
true);
742 Label4->setEnabled(
true);
745 Label3->setEnabled(
true);
746 ColorButt->setEnabled(
true);
750 Property2->setText(QString::number(g->
Precision));
751 PropertyBox->setCurrentItem(g->
numMode);
756 Label1->setEnabled(
true);
757 PropertyBox->setEnabled(
true);
758 Label2->setEnabled(
true);
759 Property2->setEnabled(
true);
765 void DiagramDialog::slotDeleteGraph()
767 int i = GraphList->index(GraphList->selectedItem());
770 GraphList->removeItem(i);
773 GraphInput->setText(
"");
774 if(Diag->
Name !=
"Tab") {
775 if(Diag->
Name !=
"Truth") {
776 ColorButt->setPaletteBackgroundColor(
777 QColor(DefaultColors[GraphList->count()]));
778 Property2->setText(
"0");
780 yAxisBox->setCurrentItem(0);
781 yAxisBox->setEnabled(
false);
782 Label4->setEnabled(
false);
785 Label3->setEnabled(
false);
786 ColorButt->setEnabled(
false);
789 else Property2->setText(
"3");
794 PropertyBox->setCurrentItem(0);
796 Label1->setEnabled(
false);
797 PropertyBox->setEnabled(
false);
798 Label2->setEnabled(
false);
799 Property2->setEnabled(
false);
804 void DiagramDialog::slotNewGraph()
806 if(GraphInput->text().isEmpty())
return;
808 GraphList->insertItem(GraphInput->text());
811 if(Diag->
Name !=
"Tab") {
812 if(Diag->
Name !=
"Truth") {
813 g->
Color = ColorButt->paletteBackgroundColor();
814 g->
Thick = Property2->text().toInt();
815 g->
Style = PropertyBox->currentItem();
816 if(yAxisBox) g->
yAxisNo = yAxisBox->currentItem();
821 g->
Precision = Property2->text().toInt();
822 g->
numMode = PropertyBox->currentItem();
831 void DiagramDialog::slotOK()
839 void DiagramDialog::slotApply()
841 if(Diag->
Name.at(0) !=
'T') {
844 if(xLabel->text().isEmpty()) xLabel->setText(
"");
851 if(ylLabel->text().isEmpty()) ylLabel->setText(
"");
857 if(GridOn)
if(Diag->
xAxis.
GridOn != GridOn->isChecked()) {
863 if(Diag->
GridPen.color() != GridColorButt->paletteBackgroundColor()) {
864 Diag->
GridPen.setColor(GridColorButt->paletteBackgroundColor());
868 if(Diag->
GridPen.style()!=(Qt::PenStyle)(GridStyleBox->currentItem()+1)) {
869 Diag->
GridPen.setStyle((Qt::PenStyle)(GridStyleBox->currentItem()+1));
872 if((Diag->
Name !=
"Smith") && (Diag->
Name !=
"Polar")) {
875 if(yrLabel->text().isEmpty()) yrLabel->setText(
"");
882 if(Diag->
Name.left(4) ==
"Rect") {
883 if(Diag->
xAxis.
log != GridLogX->isChecked()) {
884 Diag->
xAxis.
log = GridLogX->isChecked();
887 if(Diag->
yAxis.
log != GridLogY->isChecked()) {
888 Diag->
yAxis.
log = GridLogY->isChecked();
891 if(Diag->
zAxis.
log != GridLogZ->isChecked()) {
892 Diag->
zAxis.
log = GridLogZ->isChecked();
897 if((Diag->
Name ==
"Smith") || (Diag->
Name ==
"ySmith") ||
898 (Diag->
Name ==
"PS"))
899 if(stopY->text().toDouble() < 1.0)
902 if(Diag->
Name ==
"SP")
903 if(stopZ->text().toDouble() < 1.0)
917 if(QString::number(Diag->
xAxis.
step) != stepX->text()) {
918 Diag->
xAxis.
step = stepX->text().toDouble();
933 if(QString::number(Diag->
yAxis.
step) != stepY->text()) {
934 Diag->
yAxis.
step = stepY->text().toDouble();
949 if(QString::number(Diag->
zAxis.
step) != stepZ->text()) {
950 Diag->
zAxis.
step = stepZ->text().toDouble();
960 if(((
Rect3DDiagram*)Diag)->hideLines != hideInvisible->isChecked()) {
961 ((
Rect3DDiagram*)Diag)->hideLines = hideInvisible->isChecked();
966 if(((
Rect3DDiagram*)Diag)->rotX != rotationX->text().toInt()) {
972 if(((
Rect3DDiagram*)Diag)->rotY != rotationY->text().toInt()) {
978 if(((
Rect3DDiagram*)Diag)->rotZ != rotationZ->text().toInt()) {
986 Graphs.setAutoDelete(
false);
987 for(
Graph *pg = Graphs.first(); pg != 0; pg = Graphs.next())
990 Graphs.setAutoDelete(
true);
993 ((
Schematic*)parent())->viewport()->repaint();
995 if(changed) transfer =
true;
1001 void DiagramDialog::slotCancel()
1005 if(transfer) done(QDialog::Accepted);
1006 else done(QDialog::Rejected);
1017 void DiagramDialog::slotSetColor()
1019 QColor
c = QColorDialog::getColor(ColorButt->paletteBackgroundColor(),
this);
1020 if(!c.isValid())
return;
1021 ColorButt->setPaletteBackgroundColor(c);
1023 int i = GraphList->index(GraphList->selectedItem());
1026 Graph *g = Graphs.at(i);
1033 void DiagramDialog::slotSetGridColor()
1035 QColor c = QColorDialog::getColor(
1036 GridColorButt->paletteBackgroundColor(),
this);
1037 if(!c.isValid())
return;
1038 GridColorButt->setPaletteBackgroundColor(c);
1044 void DiagramDialog::slotResetToTake(
const QString& s)
1046 int i = GraphList->index(GraphList->selectedItem());
1049 Graph *g = Graphs.at(i);
1051 GraphList->changeItem(s, i);
1058 void DiagramDialog::slotSetProp2(
const QString& s)
1060 int i = GraphList->index(GraphList->selectedItem());
1063 Graph *g = Graphs.at(i);
1065 else g->
Thick = s.toInt();
1072 void DiagramDialog::slotSetNumMode(
int Mode)
1074 int i = GraphList->index(GraphList->selectedItem());
1077 Graph *g = Graphs.at(i);
1085 void DiagramDialog::slotSetGridBox(
int state)
1087 if(state == QButton::On) {
1088 GridColorButt->setEnabled(
true);
1089 GridStyleBox->setEnabled(
true);
1090 GridLabel1->setEnabled(
true);
1091 GridLabel2->setEnabled(
true);
1094 GridColorButt->setEnabled(
false);
1095 GridStyleBox->setEnabled(
false);
1096 GridLabel1->setEnabled(
false);
1097 GridLabel2->setEnabled(
false);
1103 void DiagramDialog::slotSetGraphStyle(
int style)
1105 int i = GraphList->index(GraphList->selectedItem());
1108 Graph *g = Graphs.at(i);
1119 Graphs.append(pg->sameNewOne());
1124 void DiagramDialog::slotSetYAxis(
int axis)
1126 int i = GraphList->index(GraphList->selectedItem());
1129 Graph *g = Graphs.at(i);
1136 void DiagramDialog::slotManualX(
int state)
1138 if(state == QButton::On) {
1139 if((Diag->
Name.left(4) ==
"Rect") || (Diag->
Name ==
"Curve"))
1140 startX->setEnabled(
true);
1141 stopX->setEnabled(
true);
1142 if(GridLogX)
if(GridLogX->isChecked())
return;
1143 stepX->setEnabled(
true);
1146 startX->setEnabled(
false);
1147 stepX->setEnabled(
false);
1148 stopX->setEnabled(
false);
1153 void DiagramDialog::slotManualY(
int state)
1155 if(state == QButton::On) {
1156 if((Diag->
Name.left(4) ==
"Rect") || (Diag->
Name ==
"Curve"))
1157 startY->setEnabled(
true);
1158 stopY->setEnabled(
true);
1159 if(GridLogY)
if(GridLogY->isChecked())
return;
1160 stepY->setEnabled(
true);
1163 startY->setEnabled(
false);
1164 stepY->setEnabled(
false);
1165 stopY->setEnabled(
false);
1170 void DiagramDialog::slotManualZ(
int state)
1172 if(state == QButton::On) {
1173 if((Diag->
Name.left(4) ==
"Rect") || (Diag->
Name ==
"Curve"))
1174 startZ->setEnabled(
true);
1175 stopZ->setEnabled(
true);
1176 if(GridLogZ)
if(GridLogZ->isChecked())
return;
1177 stepZ->setEnabled(
true);
1180 startZ->setEnabled(
false);
1181 stepZ->setEnabled(
false);
1182 stopZ->setEnabled(
false);
1188 void DiagramDialog::slotChangeTab(QWidget*)
1190 if(stepX == 0)
return;
1192 if(GridLogX->isChecked()) stepX->setEnabled(
false);
1193 else if(manualX->isChecked()) stepX->setEnabled(
true);
1196 if(GridLogY->isChecked()) stepY->setEnabled(
false);
1197 else if(manualY->isChecked()) stepY->setEnabled(
true);
1200 if(GridLogZ->isChecked()) stepZ->setEnabled(
false);
1201 else if(manualZ->isChecked()) stepZ->setEnabled(
true);
1207 void DiagramDialog::slotNewRotX(
int Value)
1209 rotationX->setText(QString::number(Value));
1210 DiagCross->
rotX = float(Value) *
M_PI/180.0;
1211 DiagCross->update();
1216 void DiagramDialog::slotNewRotY(
int Value)
1218 rotationY->setText(QString::number(Value));
1219 DiagCross->
rotY = float(Value) *
M_PI/180.0;
1220 DiagCross->update();
1225 void DiagramDialog::slotNewRotZ(
int Value)
1227 rotationZ->setText(QString::number(Value));
1228 DiagCross->
rotZ = float(Value) *
M_PI/180.0;
1229 DiagCross->update();
1234 void DiagramDialog::slotEditRotX(
const QString&
Text)
1236 SliderRotX->setValue(Text.toInt());
1237 DiagCross->
rotX = Text.toFloat() *
M_PI/180.0;
1238 DiagCross->update();
1243 void DiagramDialog::slotEditRotY(
const QString& Text)
1245 SliderRotY->setValue(Text.toInt());
1246 DiagCross->
rotY = Text.toFloat() *
M_PI/180.0;
1247 DiagCross->update();
1252 void DiagramDialog::slotEditRotZ(
const QString& Text)
1254 SliderRotZ->setValue(Text.toInt());
1255 DiagCross->
rotZ = Text.toFloat() *
M_PI/180.0;
1256 DiagCross->update();