20 #include <QPaintEvent>
27 #include <QPushButton>
30 #include <QStringList>
31 #include <QMessageBox>
34 #include <QColorDialog>
39 #include <QListWidget>
40 #include <QTableWidget>
41 #include <QStringList>
42 #include <QTreeWidgetItem>
45 #define CROSS3D_SIZE 30
46 #define WIDGET3D_SIZE 2*CROSS3D_SIZE
50 Cross3D(
float rx_,
float ry_,
float rz_, QWidget *parent = 0)
55 setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
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;
77 Painter.setPen(QPen(Qt::red,2));
81 Painter.setPen(QPen(Qt::green,2));
85 Painter.setPen(QPen(Qt::blue,2));
96 = {0x0000ff, 0xff0000, 0xff00ff, 0x00ff00, 0x00ffff, 0xffff00,
103 QWidget *parent,
Graph *currentGraph)
104 : QDialog(parent, 0, TRUE, Qt::WDestructiveClose)
107 Graphs.setAutoDelete(
true);
110 setCaption(tr(
"Edit Diagram Properties"));
115 Expr.setPattern(
"[^\"]+");
118 ValDouble =
new QDoubleValidator(-1e200, 1e200, 6,
this);
120 QString NameY, NameZ;
122 NameY = tr(
"left Axis");
123 NameZ = tr(
"right Axis");
126 NameY = tr(
"y-Axis");
129 NameY = tr(
"y-Axis");
132 NameY = tr(
"smith Axis");
133 NameZ = tr(
"polar Axis");
136 NameY = tr(
"polar Axis");
137 NameZ = tr(
"smith Axis");
140 NameY = tr(
"y-Axis");
141 NameZ = tr(
"z-Axis");
145 all =
new QVBoxLayout(
this);
146 QTabWidget *t =
new QTabWidget();
150 QWidget *Tab1 =
new QWidget();
151 QVBoxLayout *Tab1Layout =
new QVBoxLayout();
152 Tab1->setLayout(Tab1Layout);
153 Tab1Layout->setSpacing(5);
163 QGroupBox *InputGroup =
new QGroupBox(tr(
"Graph Input"));
164 QVBoxLayout *InputGroupLayout =
new QVBoxLayout();
165 InputGroup->setLayout(InputGroupLayout);
166 Tab1Layout->addWidget(InputGroup);
171 QWidget *Box2 =
new QWidget();
172 QHBoxLayout *Box2Layout =
new QHBoxLayout();
173 Box2->setLayout(Box2Layout);
174 InputGroupLayout->addWidget(Box2);
175 Box2Layout->setSpacing(5);
178 Label1 =
new QLabel(tr(
"Number Notation: "));
179 Box2Layout->addWidget(
Label1);
183 PropertyBox->insertItem(tr(
"magnitude/angle (degree)"));
184 PropertyBox->insertItem(tr(
"magnitude/angle (radian)"));
187 Box2Layout->setStretchFactor(
new QWidget(Box2), 5);
189 Label2 =
new QLabel(tr(
"Precision:"));
190 Box2Layout->addWidget(
Label2);
199 Label1 =
new QLabel(tr(
"Color:"));
200 Box2Layout->addWidget(
Label1);
206 Box2Layout->setStretchFactor(
new QWidget(Box2), 5);
208 Label3 =
new QLabel(tr(
"Style:"));
209 Box2Layout->addWidget(
Label3);
210 Label3->setEnabled(
false);
224 Box2Layout->setStretchFactor(
new QWidget(Box2), 5);
226 Label2 =
new QLabel(tr(
"Thickness:"));
227 Box2Layout->addWidget(
Label2);
237 QWidget *Box3 =
new QWidget();
238 Box2Layout->addWidget(Box3);
239 QHBoxLayout *Box3Layout =
new QHBoxLayout();
240 Box3Layout->setSpacing(5);
241 Box3->setLayout(Box3Layout);
243 Label4 =
new QLabel(tr(
"y-Axis:"));
244 Box3Layout->addWidget(
Label4);
245 Label4->setEnabled(
false);
252 Box3Layout->setStretchFactor(
new QWidget(Box3), 5);
256 connect(
Property2, SIGNAL(textChanged(
const QString&)),
259 Label1->setEnabled(
false);
261 Label2->setEnabled(
false);
265 QWidget *Box1 =
new QWidget();
266 Tab1Layout->addWidget(Box1);
267 QHBoxLayout *Box1Layout =
new QHBoxLayout();
268 Box1->setLayout(Box1Layout);
269 Box1Layout->setSpacing(5);
271 QGroupBox *DataGroup =
new QGroupBox(tr(
"Dataset"));
272 Box1Layout->addWidget(DataGroup);
273 QVBoxLayout *DataGroupLayout =
new QVBoxLayout();
274 DataGroup->setLayout(DataGroupLayout);
282 ChooseVars->setSelectionBehavior(QAbstractItemView::SelectRows);
289 headers << tr(
"Name") << tr(
"Type") << tr(
"Size");
290 ChooseVars->setHorizontalHeaderLabels(headers);
292 connect(
ChooseVars, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), SLOT(
slotTakeVar(QTableWidgetItem*)));
295 QGroupBox *GraphGroup =
new QGroupBox(tr(
"Graph"));
296 Box1Layout->addWidget(GraphGroup);
297 QVBoxLayout *GraphGroupLayout =
new QVBoxLayout();
298 GraphGroup->setLayout(GraphGroupLayout);
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);
310 t->addTab(Tab1, tr(
"Data"));
317 QWidget *Tab2 =
new QWidget(t);
318 QGridLayout *gp =
new QGridLayout(Tab2,13,3,5,5);
320 gp->addMultiCellWidget(
new QLabel(tr(
"x-Axis Label:"), Tab2), Row,Row,0,0);
321 xLabel =
new QLineEdit(Tab2);
323 gp->addMultiCellWidget(
xLabel, Row,Row,1,2);
326 gp->addMultiCellWidget(
327 new QLabel(NameY+
" "+tr(
"Label:"), Tab2), Row,Row,0,0);
330 gp->addMultiCellWidget(
ylLabel, Row,Row,1,2);
334 gp->addMultiCellWidget(
335 new QLabel(NameZ +
" "+tr(
"Label:"), Tab2), Row,Row,0,0);
338 gp->addMultiCellWidget(
yrLabel, Row,Row,1,2);
342 gp->addMultiCellWidget(
new QLabel(
343 tr(
"<b>Label text</b>: Use LaTeX style for special characters, e.g. \\tau"),
348 GridOn =
new QCheckBox(tr(
"show Grid"), Tab2);
349 gp->addMultiCellWidget(
GridOn, Row,Row,0,2);
352 GridLabel1 =
new QLabel(tr(
"Grid Color:"),Tab2);
353 gp->addMultiCellWidget(
GridLabel1, Row,Row,0,0);
360 GridLabel2 =
new QLabel(tr(
"Grid Style: "), Tab2);
361 gp->addMultiCellWidget(
GridLabel2, Row,Row,0,0);
388 GridLogX =
new QCheckBox(tr(
"logarithmical X Axis Grid"), Tab2);
389 gp->addMultiCellWidget(
GridLogX, Row,Row,0,2);
392 GridLogY =
new QCheckBox(tr(
"logarithmical")+
" "+NameY+
" "+tr(
"Grid"), Tab2);
393 gp->addMultiCellWidget(
GridLogY, Row,Row,0,2);
396 GridLogZ =
new QCheckBox(tr(
"logarithmical")+
" "+NameZ+
" "+tr(
"Grid"), Tab2);
397 gp->addMultiCellWidget(
GridLogZ, Row,Row,0,2);
408 hideInvisible =
new QCheckBox(tr(
"hide invisible lines"), Tab2);
412 QLabel *LabelRotX =
new QLabel(tr(
"Rotation around x-Axis:"), Tab2);
413 LabelRotX->setPaletteForegroundColor(Qt::red);
414 gp->addWidget(LabelRotX, Row,0);
416 Qt::Horizontal, Tab2);
424 connect(
rotationX, SIGNAL(textChanged(
const QString&)),
428 QLabel *LabelRotY =
new QLabel(tr(
"Rotation around y-Axis:"), Tab2);
429 LabelRotY->setPaletteForegroundColor(Qt::green);
430 gp->addWidget(LabelRotY, Row,0);
432 Qt::Horizontal, Tab2);
440 connect(
rotationY, SIGNAL(textChanged(
const QString&)),
444 QLabel *LabelRotZ =
new QLabel(tr(
"Rotation around z-Axis:"), Tab2);
445 LabelRotZ->setPaletteForegroundColor(Qt::blue);
446 gp->addWidget(LabelRotZ, Row,0);
448 Qt::Horizontal, Tab2);
456 connect(
rotationZ, SIGNAL(textChanged(
const QString&)),
460 gp->addWidget(
new QLabel(tr(
"2D-projection:"), Tab2), Row,0);
476 t->addTab(Tab2, tr(
"Properties"));
479 QWidget *Tab3 =
new QWidget();
480 QVBoxLayout *Tab3Layout =
new QVBoxLayout();
482 QGroupBox *axisX =
new QGroupBox(tr(
"x-Axis"));
483 QHBoxLayout *axisXLayout =
new QHBoxLayout();
485 QWidget *VBox1 =
new QWidget();
486 axisXLayout->addWidget(VBox1);
487 QVBoxLayout *VBox1Layout =
new QVBoxLayout();
488 VBox1Layout->setStretchFactor(
new QWidget(VBox1),5);
490 manualX =
new QCheckBox(tr(
"manual"));
491 VBox1Layout->addWidget(
manualX);
492 VBox1->setLayout(VBox1Layout);
495 QWidget *VBox2 =
new QWidget();
496 axisXLayout->addWidget(VBox2);
497 QVBoxLayout *VBox2Layout =
new QVBoxLayout();
498 VBox2Layout->addWidget(
new QLabel(tr(
"start")));
500 VBox2Layout->addWidget(
startX);
502 VBox2->setLayout(VBox2Layout);
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();
509 VBox3Layout->addWidget(
stepX);
511 VBox3->setLayout(VBox3Layout);
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);
520 VBox4->setLayout(VBox4Layout);
522 axisX->setLayout(axisXLayout);
523 Tab3Layout->addWidget(axisX);
525 QGroupBox *axisY =
new QGroupBox(NameY);
526 QHBoxLayout *axisYLayout =
new QHBoxLayout();
528 QWidget *VBox5 =
new QWidget();
529 axisYLayout->addWidget(VBox5);
530 QVBoxLayout *VBox5Layout =
new QVBoxLayout();
531 VBox5Layout->setStretchFactor(
new QWidget(VBox5),5);
532 manualY =
new QCheckBox(tr(
"manual"));
533 VBox5Layout->addWidget(
manualY);
535 VBox5->setLayout(VBox5Layout);
537 QWidget *VBox6 =
new QWidget();
538 axisYLayout->addWidget(VBox6);
539 QVBoxLayout *VBox6Layout =
new QVBoxLayout();
540 VBox6Layout->addWidget(
new QLabel(tr(
"start")));
542 VBox6Layout->addWidget(
startY);
544 VBox6->setLayout(VBox6Layout);
546 QWidget *VBox7 =
new QWidget();
547 axisYLayout->addWidget(VBox7);
548 QVBoxLayout *VBox7Layout =
new QVBoxLayout();
550 VBox7Layout->addWidget(
new QLabel(tr(
"number")));
551 else VBox7Layout->addWidget(
new QLabel(tr(
"step")));
552 stepY =
new QLineEdit();
553 VBox7Layout->addWidget(
stepY);
555 VBox7->setLayout(VBox7Layout);
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);
564 VBox8->setLayout(VBox8Layout);
566 axisY->setLayout(axisYLayout);
567 Tab3Layout->addWidget(axisY);
569 QGroupBox *axisZ =
new QGroupBox(NameZ);
570 QHBoxLayout *axisZLayout =
new QHBoxLayout();
572 QWidget *VBox9 =
new QWidget();
573 axisZLayout->addWidget(VBox9);
574 QVBoxLayout *VBox9Layout =
new QVBoxLayout();
575 VBox9Layout->setStretchFactor(
new QWidget(VBox9),5);
576 manualZ =
new QCheckBox(tr(
"manual"));
577 VBox9Layout->addWidget(
manualZ);
579 VBox9->setLayout(VBox9Layout);
581 QWidget *VBox10 =
new QWidget();
582 axisZLayout->addWidget(VBox10);
583 QVBoxLayout *VBox10Layout =
new QVBoxLayout();
584 VBox10Layout->addWidget(
new QLabel(tr(
"start")));
586 VBox10Layout->addWidget(
startZ);
588 VBox10->setLayout(VBox10Layout);
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);
598 VBox11->setLayout(VBox11Layout);
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);
607 VBox12->setLayout(VBox12Layout);
609 Tab3Layout->setStretchFactor(
new QWidget(Tab3),5);
611 axisZ->setLayout(axisZLayout);
612 Tab3Layout->addWidget(axisZ);
614 Tab3->setLayout(Tab3Layout);
615 t->addTab(Tab3, tr(
"Limits"));
620 else manualX->setChecked(
true);
622 else manualY->setChecked(
true);
624 else manualZ->setChecked(
true);
642 axisZ->setEnabled(
false);
646 axisX->setEnabled(
false);
647 startY->setEnabled(
false);
648 startZ->setEnabled(
false);
653 connect(t, SIGNAL(currentChanged(QWidget*)), SLOT(
slotChangeTab(QWidget*)));
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);
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()));
672 OkButt->setDefault(
true);
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())
694 if(pg == currentGraph) {
719 QString DocName =
ChooseData->currentText()+
".dat";
721 QFile file(Info.dirPath() + QDir::separator() + DocName);
722 if(!file.open(QIODevice::ReadOnly)) {
726 QString
Line, tmp, Var;
730 QByteArray FileString = file.readAll();
735 i = FileString.find(
'<')+1;
738 j = FileString.find(
'>', i);
739 for(
int k=0;k<j-i;k++) Line[k]=FileString[k+i];
741 i = FileString.find(
'<', j)+1;
743 Var = Line.section(
' ', 1, 1).remove(
'>');
745 if(Var.at(0) ==
'_')
continue;
747 if(Line.left(3) ==
"dep") {
748 tmp = Line.section(
' ', 2);
750 qDebug() << varNumber << Var << tmp.remove(
'>');
752 QTableWidgetItem *cell =
new QTableWidgetItem(Var);
753 cell->setFlags(cell->flags() ^ Qt::ItemIsEditable);
755 cell =
new QTableWidgetItem(
"dep");
756 cell->setFlags(cell->flags() ^ Qt::ItemIsEditable);
758 cell =
new QTableWidgetItem(tmp.remove(
'>'));
759 cell->setFlags(cell->flags() ^ Qt::ItemIsEditable);
763 else if(Line.left(5) ==
"indep") {
764 tmp = Line.section(
' ', 2, 2);
766 qDebug() << varNumber << Var << tmp.remove(
'>');
768 QTableWidgetItem *cell =
new QTableWidgetItem(Var);
769 cell->setFlags(cell->flags() ^ Qt::ItemIsEditable);
771 cell =
new QTableWidgetItem(
"indep");
772 cell->setFlags(cell->flags() ^ Qt::ItemIsEditable);
774 cell =
new QTableWidgetItem(tmp.remove(
'>'));
775 cell->setFlags(cell->flags() ^ Qt::ItemIsEditable);
795 int row = Item->row();
796 QString s1 =
ChooseVars->item(row, 0)->text();
798 if(
ChooseData->currentText() != Info.baseName(
true))
814 if(g->
Var.right(3) ==
".Vb")
928 Label4->setEnabled(
false);
931 Label3->setEnabled(
false);
942 Label1->setEnabled(
false);
944 Label2->setEnabled(
false);
1045 if(
stopY->text().toDouble() < 1.0)
1046 stopY->setText(
"1");
1049 if(
stopZ->text().toDouble() < 1.0)
1050 stopZ->setText(
"1");
1132 Graphs.setAutoDelete(
false);
1136 Graphs.setAutoDelete(
true);
1139 ((
Schematic*)parent())->viewport()->repaint();
1151 if(
transfer) done(QDialog::Accepted);
1152 else done(QDialog::Rejected);
1165 QColor c = QColorDialog::getColor(
ColorButt->paletteBackgroundColor(),
this);
1166 if(!c.isValid())
return;
1167 ColorButt->setPaletteBackgroundColor(c);
1181 QColor c = QColorDialog::getColor(
1183 if(!c.isValid())
return;
1211 else g->
Thick = s.toInt();
1265 Graphs.append(pg->sameNewOne());
1286 startX->setEnabled(
true);
1287 stopX->setEnabled(
true);
1289 stepX->setEnabled(
true);
1292 startX->setEnabled(
false);
1293 stepX->setEnabled(
false);
1294 stopX->setEnabled(
false);
1303 startY->setEnabled(
true);
1304 stopY->setEnabled(
true);
1306 stepY->setEnabled(
true);
1309 startY->setEnabled(
false);
1310 stepY->setEnabled(
false);
1311 stopY->setEnabled(
false);
1320 startZ->setEnabled(
true);
1321 stopZ->setEnabled(
true);
1323 stepZ->setEnabled(
true);
1326 startZ->setEnabled(
false);
1327 stepZ->setEnabled(
false);
1328 stopZ->setEnabled(
false);
1336 if(
stepX == 0)
return;
1355 rotationX->setText(QString::number(Value));
1364 rotationY->setText(QString::number(Value));
1373 rotationZ->setText(QString::number(Value));
static const int NumDefaultColors
void slotSetProp2(const QString &)
QIntValidator * ValInteger
QPushButton * GridColorButt
void slotChangeTab(QWidget *)
QCheckBox * hideInvisible
Q3PtrList< Graph > Graphs
void slotSetGraphStyle(int)
void slotTakeVar(QTableWidgetItem *item)
virtual void calcLimits()
void slotEditRotY(const QString &)
Q3PtrList< Graph > Graphs
void slotEditRotX(const QString &)
QDoubleValidator * ValDouble
QTableWidget * ChooseVars
void paintEvent(QPaintEvent *)
void slotResetToTake(const QString &)
QRegExpValidator * Validator
void SelectGraph(Graph *)
void loadGraphData(const QString &)
void slotEditRotZ(const QString &)
static const QRgb DefaultColors[]
void slotSelectGraph(QListWidgetItem *)
DiagramDialog(Diagram *d, const QString &_DataSet, QWidget *parent=0, Graph *currentGraph=0)
Cross3D(float rx_, float ry_, float rz_, QWidget *parent=0)