2018-12-29 00:46:47 +08:00
|
|
|
#include "TestWidgetGeometry.h"
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QDate>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QApplication>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TestWidgetGeometry::TestWidgetGeometry(QWidget *parent) :
|
|
|
|
QWidget(parent)
|
|
|
|
{
|
|
|
|
// create third plotter with output of a geometric drawing
|
2019-06-21 21:46:53 +08:00
|
|
|
QVBoxLayout* layout1=new QVBoxLayout();
|
2018-12-29 00:46:47 +08:00
|
|
|
setLayout(layout1);
|
|
|
|
resize(1000, 800);
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPlotter* plotGeo=new JKQTPlotter(true, this);
|
2019-01-26 03:16:04 +08:00
|
|
|
plotGeo->setPlotUpdateEnabled(false);
|
2018-12-29 00:46:47 +08:00
|
|
|
plotGeo->setObjectName("plotGeo");
|
|
|
|
layout1->addWidget(plotGeo);
|
|
|
|
plotGeo->setXY(0,1,0,1);
|
2019-01-26 03:16:04 +08:00
|
|
|
plotGeo->getPlotter()->getXAxis()->setAxisLabel("$x$ [mm]");
|
|
|
|
plotGeo->getPlotter()->getYAxis()->setAxisLabel("$y$ [mm]");
|
2019-01-26 20:00:40 +08:00
|
|
|
/*plotGeo->getPlotter()->getXAxis()->setLinkedAxis(plotGeo->getPlotter()->getYAxis());
|
|
|
|
plotGeo->getPlotter()->getXAxis()->setChangeWidthToAspectRatio(true);*/
|
2019-01-26 03:16:04 +08:00
|
|
|
plotGeo->getPlotter()->setMaintainAspectRatio(true);
|
|
|
|
plotGeo->getPlotter()->setAspectRatio(1);
|
|
|
|
plotGeo->getPlotter()->setMaintainAxisAspectRatio(true);
|
|
|
|
plotGeo->getPlotter()->setAxisAspectRatio(1);
|
|
|
|
|
|
|
|
|
|
|
|
// JKQTPGeoLine* line1=new JKQTPGeoLine(plotGeo->getPlotter(), -1, -2, 2, 1.5);
|
|
|
|
//plotGeo->getPlotter()->addGraph(line1);
|
|
|
|
// JKQTPGeoLine* line2=new JKQTPGeoLine(plotGeo->getPlotter(), 1, -5, 4, 3, QColor("blue"), 4);
|
|
|
|
//plotGeo->getPlotter()->addGraph(line2);
|
|
|
|
|
|
|
|
JKQTPGeoRectangle* rect1=new JKQTPGeoRectangle(plotGeo->getPlotter(), 1,1,2,2, QColor("blue"),2, Qt::SolidLine, QColor("lightblue"));
|
2019-06-21 21:46:53 +08:00
|
|
|
rect1->setAngle(30);
|
2019-01-26 03:16:04 +08:00
|
|
|
//plotGeo->getPlotter()->addGraph(rect1);
|
|
|
|
JKQTPGeoRectangle* rect2=new JKQTPGeoRectangle(plotGeo->getPlotter(), 1,1,2,2, QColor("red"),2);
|
2019-06-21 21:46:53 +08:00
|
|
|
rect2->setAngle(45);
|
2019-01-26 03:16:04 +08:00
|
|
|
//plotGeo->getPlotter()->addGraph(rect2);
|
|
|
|
JKQTPGeoRectangle* rect3=new JKQTPGeoRectangle(plotGeo->getPlotter(), 1,1,2,4, QColor("green"),2);
|
2019-06-21 21:46:53 +08:00
|
|
|
rect3->setAngle(-30);
|
2019-01-26 03:16:04 +08:00
|
|
|
//plotGeo->getPlotter()->addGraph(rect3);
|
|
|
|
JKQTPGeoEllipse* ell3=new JKQTPGeoEllipse(plotGeo->getPlotter(), 1,1,2,4, QColor("green"),2, Qt::SolidLine, QColor("lightgreen"), Qt::CrossPattern);
|
2019-06-21 21:46:53 +08:00
|
|
|
ell3->setAngle(-30);
|
2019-01-26 03:16:04 +08:00
|
|
|
//plotGeo->getPlotter()->addGraph(ell3);
|
2018-12-29 00:46:47 +08:00
|
|
|
|
|
|
|
QVector<QPointF> p;
|
|
|
|
p.append(QPointF(4,1));
|
|
|
|
p.append(QPointF(-11,5));
|
|
|
|
p.append(QPointF(1,11));
|
|
|
|
p.append(QPointF(0,-2));
|
2019-11-24 17:42:44 +08:00
|
|
|
p.append(QPointF(JKQTPSTATISTICS_PI,5.5));
|
2018-12-29 00:46:47 +08:00
|
|
|
|
2019-01-26 03:16:04 +08:00
|
|
|
// JKQTPGeoPolygon* poly=new JKQTPGeoPolygon(plotGeo->getPlotter(), p, QColor("black"), 1.5, Qt::SolidLine, QColor(128,128,0,128));
|
|
|
|
//plotGeo->getPlotter()->addGraph(poly);
|
2019-06-21 21:46:53 +08:00
|
|
|
// JKQTPGeoPolyLines* lines=new JKQTPGeoPolyLines(plotGeo->getPlotter(), p, QColor(255,255,0), 3);
|
2019-01-26 03:16:04 +08:00
|
|
|
//plotGeo->getPlotter()->addGraph(lines);
|
|
|
|
|
|
|
|
JKQTPGeoEllipse* ell1=new JKQTPGeoEllipse(plotGeo->getPlotter(), 0,0,2,4, QColor("black"),1.5, Qt::DotLine);
|
|
|
|
plotGeo->getPlotter()->addGraph(ell1);
|
|
|
|
// JKQTPGeoArc* arc=new JKQTPGeoArc(plotGeo->getPlotter(), 0,0,2,4,0, 135, QColor("blue"),3, Qt::SolidLine);
|
|
|
|
//plotGeo->getPlotter()->addGraph(arc);
|
|
|
|
// JKQTPGeoPie* pie=new JKQTPGeoPie(plotGeo->getPlotter(), 0,0,2,4,35, 98, QColor("blue"),3, Qt::SolidLine, QColor(0,0,255,127));
|
|
|
|
//plotGeo->getPlotter()->addGraph(pie);
|
|
|
|
// JKQTPGeoChord* chord=new JKQTPGeoChord(plotGeo->getPlotter(), 0,0,2,4,35, 98, QColor("blue"),3, Qt::SolidLine, QColor(0,0,255,127));
|
|
|
|
//plotGeo->getPlotter()->addGraph(chord);
|
|
|
|
|
|
|
|
JKQTPGeoInfiniteLine* iline=new JKQTPGeoInfiniteLine(plotGeo->getPlotter(), 0.5,1,1,1, QColor("blue"), 3);
|
|
|
|
plotGeo->getPlotter()->addGraph(iline);
|
|
|
|
JKQTPGeoInfiniteLine* iline1=new JKQTPGeoInfiniteLine(plotGeo->getPlotter(), 0.5,1,-1,0, QColor("red"), 3);
|
|
|
|
plotGeo->getPlotter()->addGraph(iline1);
|
|
|
|
JKQTPGeoInfiniteLine* iline2=new JKQTPGeoInfiniteLine(plotGeo->getPlotter(), 0.5,1,0,1, QColor("red"), 3);
|
|
|
|
plotGeo->getPlotter()->addGraph(iline2);
|
|
|
|
JKQTPGeoInfiniteLine* iline3=new JKQTPGeoInfiniteLine(plotGeo->getPlotter(), 0.5,1,-1,0.5, QColor("green"), 3);
|
2019-01-26 20:00:40 +08:00
|
|
|
iline3->setTwoSided(true);
|
2019-01-26 03:16:04 +08:00
|
|
|
plotGeo->getPlotter()->addGraph(iline3);
|
2018-12-29 00:46:47 +08:00
|
|
|
|
2019-01-26 03:16:04 +08:00
|
|
|
JKQTPGeoText* text=new JKQTPGeoText(plotGeo->getPlotter(), -1, -1, "Test $f(x)=\\sqrt{\\sin(x^2)}$ \\textbf{bold}", 12, QColor("red"));
|
|
|
|
plotGeo->getPlotter()->addGraph(text);
|
2018-12-29 00:46:47 +08:00
|
|
|
|
2019-01-26 03:16:04 +08:00
|
|
|
plotGeo->setPlotUpdateEnabled(true);
|
|
|
|
plotGeo->getPlotter()->zoomToFit();
|
|
|
|
plotGeo->getPlotter()->setKeyAutosize(true);
|
2018-12-29 00:46:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
QCheckBox* chkAspect=new QCheckBox("keep aspect ratio", this);
|
2019-01-26 03:16:04 +08:00
|
|
|
chkAspect->setChecked(plotGeo->getPlotter()->doesMaintainAxisAspectRatio());
|
|
|
|
connect(chkAspect, SIGNAL(toggled(bool)), plotGeo->getPlotter(), SLOT(setMaintainAspectRatio(bool)));
|
|
|
|
connect(chkAspect, SIGNAL(toggled(bool)), plotGeo->getPlotter(), SLOT(setMaintainAxisAspectRatio(bool)));
|
2018-12-29 00:46:47 +08:00
|
|
|
layout1->addWidget(chkAspect);
|
|
|
|
|
|
|
|
}
|