2015-07-11 18:56:02 +08:00
|
|
|
/*
|
2019-01-20 23:15:10 +08:00
|
|
|
Copyright (c) 2008-2019 Jan W. Krieger (<jan@jkrieger.de>)
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2015-07-12 22:34:27 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
This software is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License (LGPL) as published by
|
2019-02-08 00:24:46 +08:00
|
|
|
the Free Software Foundation, either version 2.1 of the License, or
|
2015-07-11 18:56:02 +08:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License (LGPL) for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License (LGPL)
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-20 22:06:31 +08:00
|
|
|
#include "jkqtplotter/graphs/jkqtpgeometric.h"
|
2018-11-26 03:25:44 +08:00
|
|
|
#include "jkqtplotter/jkqtpbaseplotter.h"
|
2019-02-08 00:24:46 +08:00
|
|
|
#include "jkqtplotter/jkqtplotter.h"
|
2015-07-11 18:56:02 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <QDebug>
|
2019-02-08 00:24:46 +08:00
|
|
|
#include <QApplication>
|
2015-07-11 18:56:02 +08:00
|
|
|
#define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgz<smallestGreaterZero))) smallestGreaterZero=xvsgz;
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseLine::JKQTPGeoBaseLine(QColor color, double lineWidth, Qt::PenStyle style, JKQTBasePlotter* parent):
|
|
|
|
JKQTPPlotObject(parent)
|
2015-07-11 18:56:02 +08:00
|
|
|
{
|
2019-04-22 19:27:50 +08:00
|
|
|
setLineColor(color);
|
|
|
|
setLineWidth(lineWidth);
|
|
|
|
setLineStyle(style);
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoBaseLine::JKQTPGeoBaseLine(QColor color, double lineWidth, Qt::PenStyle style, JKQTPlotter* parent):
|
2019-04-22 19:27:50 +08:00
|
|
|
JKQTPGeoBaseLine(color, lineWidth, style, parent->getPlotter())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoBaseLine::JKQTPGeoBaseLine(JKQTBasePlotter *parent):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPPlotObject(parent)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
2019-04-22 19:27:50 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoBaseLine::JKQTPGeoBaseLine(JKQTPlotter *parent):
|
|
|
|
JKQTPGeoBaseLine(parent->getPlotter())
|
|
|
|
{
|
|
|
|
|
2015-08-02 19:36:54 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoBaseLine::setAlpha(float alpha)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
2019-04-22 19:27:50 +08:00
|
|
|
auto color=getLineColor();
|
2019-01-08 04:00:56 +08:00
|
|
|
color.setAlphaF(alpha);
|
2019-04-22 19:27:50 +08:00
|
|
|
setLineColor(color);
|
2019-01-08 04:00:56 +08:00
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
void JKQTPGeoBaseLine::setColor(QColor c)
|
|
|
|
{
|
|
|
|
setLineColor(c);
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoBaseLine::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
painter.setPen(getLinePen(painter, parent));
|
2019-01-08 04:00:56 +08:00
|
|
|
double y=rect.top()+rect.height()/2.0;
|
|
|
|
if (rect.width()>0) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
QColor JKQTPGeoBaseLine::getKeyLabelColor() const {
|
|
|
|
return getLineColor();
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style, Qt::BrushStyle fillStyle, JKQTBasePlotter* parent):
|
|
|
|
JKQTPGeoBaseLine(color, lineWidth, style, parent)
|
2015-07-11 18:56:02 +08:00
|
|
|
{
|
2019-04-22 19:27:50 +08:00
|
|
|
setFillColor(fillColor);
|
|
|
|
setFillStyle(fillStyle);
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style, Qt::BrushStyle fillStyle, JKQTPlotter* parent):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseLine(color, lineWidth, style, parent)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
2019-04-22 19:27:50 +08:00
|
|
|
setFillColor(fillColor);
|
|
|
|
setFillStyle(fillStyle);
|
2015-08-02 19:36:54 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, Qt::PenStyle style, JKQTPlotter* parent):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseLine(color, lineWidth, style, parent)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
2019-04-22 19:27:50 +08:00
|
|
|
setFillColor(fillColor);
|
|
|
|
setFillStyle(Qt::SolidPattern);
|
2015-08-02 19:36:54 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(QColor color, QColor fillColor, double lineWidth, JKQTPlotter* parent):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseLine(color, lineWidth, Qt::SolidLine, parent)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
2019-04-22 19:27:50 +08:00
|
|
|
setFillColor(fillColor);
|
|
|
|
setFillStyle(Qt::SolidPattern);
|
2015-08-02 19:36:54 +08:00
|
|
|
}
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoBaseFilled::JKQTPGeoBaseFilled(QColor color, QColor fillColor, JKQTPlotter* parent):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseLine(color, 2.0, Qt::SolidLine, parent)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
2019-04-22 19:27:50 +08:00
|
|
|
setFillColor(fillColor);
|
|
|
|
setFillStyle(Qt::SolidPattern);
|
2015-08-02 19:36:54 +08:00
|
|
|
}
|
2019-01-08 04:00:56 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoBaseFilled::setAlpha(float alpha)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseLine::setAlpha(alpha);
|
2019-04-22 19:27:50 +08:00
|
|
|
auto fillColor=getFillColor();
|
2019-01-08 04:00:56 +08:00
|
|
|
fillColor.setAlphaF(alpha);
|
2019-04-22 19:27:50 +08:00
|
|
|
setFillColor(fillColor);
|
2019-01-08 04:00:56 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoBaseFilled::setAlpha(float alphaLine, float alphaFill)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseLine::setAlpha(alphaLine);
|
2019-04-22 19:27:50 +08:00
|
|
|
auto fillColor=getFillColor();
|
2019-01-08 04:00:56 +08:00
|
|
|
fillColor.setAlphaF(alphaFill);
|
2019-04-22 19:27:50 +08:00
|
|
|
setFillColor(fillColor);
|
2019-01-08 04:00:56 +08:00
|
|
|
}
|
2019-04-22 19:27:50 +08:00
|
|
|
|
|
|
|
void JKQTPGeoBaseFilled::setColor(QColor c)
|
|
|
|
{
|
|
|
|
JKQTPGeoBaseLine::setColor(c);
|
|
|
|
setFillColor(JKQTPGetDerivedColor(parent->getCurrentPlotterStyle().graphFillColorDerivationMode, c));
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoBaseFilled::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
painter.setPen(getLinePen(painter, parent));
|
|
|
|
painter.setBrush(getFillBrush(painter, parent));
|
2015-07-11 18:56:02 +08:00
|
|
|
painter.drawRect(rect);
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-26 19:28:44 +08:00
|
|
|
JKQTPGeoText::JKQTPGeoText(JKQTBasePlotter* parent, double x, double y, const QString& text, double fontSize, QColor color):
|
2019-04-22 19:27:50 +08:00
|
|
|
JKQTPPlotObject(parent), JKQTPGraphTextStyleMixin(parent)
|
2015-07-11 18:56:02 +08:00
|
|
|
{
|
|
|
|
this->x=x;
|
|
|
|
this->y=y;
|
|
|
|
this->text=text;
|
2019-04-22 19:27:50 +08:00
|
|
|
setTextFontSize(fontSize);
|
|
|
|
setTextColor(color);
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-01-26 19:28:44 +08:00
|
|
|
JKQTPGeoText::JKQTPGeoText(JKQTPlotter* parent, double x, double y, const QString& text, double fontSize, QColor color):
|
2019-02-08 00:24:46 +08:00
|
|
|
JKQTPGeoText(parent->getPlotter(),x,y,text,fontSize,color)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
|
|
|
}
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
JKQTPGeoText::JKQTPGeoText(JKQTBasePlotter *parent, double x, double y, const QString &text):
|
|
|
|
JKQTPPlotObject(parent), JKQTPGraphTextStyleMixin(parent)
|
|
|
|
{
|
|
|
|
this->x=x;
|
|
|
|
this->y=y;
|
|
|
|
this->text=text;
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoText::JKQTPGeoText(JKQTPlotter *parent, double x, double y, const QString &text):
|
|
|
|
JKQTPGeoText(parent->getPlotter(),x,y,text)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoText::setText(const QString &__value)
|
|
|
|
{
|
|
|
|
this->text = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString JKQTPGeoText::getText() const
|
|
|
|
{
|
|
|
|
return this->text;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoText::setX(double __value)
|
|
|
|
{
|
|
|
|
this->x = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoText::getX() const
|
|
|
|
{
|
|
|
|
return this->x;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoText::setY(double __value)
|
|
|
|
{
|
|
|
|
this->y = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoText::getY() const
|
|
|
|
{
|
|
|
|
return this->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoText::setColor(QColor c)
|
|
|
|
{
|
|
|
|
setTextColor(c);
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoText::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
minx=maxx=x;
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
if (x>10.0*DBL_MIN) smallestGreaterZero=x;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoText::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
miny=maxy=y;
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
if (y>10.0*DBL_MIN) smallestGreaterZero=y;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoText::draw(JKQTPEnhancedPainter& painter) {
|
2019-05-06 01:31:20 +08:00
|
|
|
clearHitTestData();
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
parent->getMathText()->setFontRomanOrSpecial(getTextFontName());
|
|
|
|
parent->getMathText()->setFontSize(getTextFontSize()*parent->getFontSizeMultiplier());
|
|
|
|
parent->getMathText()->setFontColor(getTextColor());
|
2019-01-26 03:16:04 +08:00
|
|
|
parent->getMathText()->parse(text);
|
|
|
|
parent->getMathText()->draw(painter, transformX(x), transformY(y));
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoText::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
painter.setPen(QPen(getTextColor()));
|
2019-01-08 04:00:56 +08:00
|
|
|
double y=rect.top()+rect.height()/2.0;
|
|
|
|
if (rect.width()>0) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
QColor JKQTPGeoText::getKeyLabelColor() const {
|
|
|
|
return getTextColor();
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoLine::JKQTPGeoLine(JKQTBasePlotter* parent, double x1, double y1, double x2, double y2, QColor color, double lineWidth, Qt::PenStyle style):
|
|
|
|
JKQTPGeoBaseLine(color, lineWidth, style, parent)
|
2015-07-11 18:56:02 +08:00
|
|
|
{
|
|
|
|
this->x1=x1;
|
|
|
|
this->y1=y1;
|
|
|
|
this->x2=x2;
|
|
|
|
this->y2=y2;
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoLine::JKQTPGeoLine(JKQTPlotter* parent, double x1, double y1, double x2, double y2, QColor color, double lineWidth, Qt::PenStyle style):
|
2019-04-22 19:27:50 +08:00
|
|
|
JKQTPGeoLine(parent->getPlotter(), x1,y1,x2,y2,color, lineWidth, style)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoLine::JKQTPGeoLine(JKQTBasePlotter *parent, double x1, double y1, double x2, double y2):
|
|
|
|
JKQTPGeoBaseLine(parent)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
|
|
|
this->x1=x1;
|
|
|
|
this->y1=y1;
|
|
|
|
this->x2=x2;
|
|
|
|
this->y2=y2;
|
|
|
|
}
|
2019-04-22 19:27:50 +08:00
|
|
|
|
|
|
|
JKQTPGeoLine::JKQTPGeoLine(JKQTPlotter *parent, double x1, double y1, double x2, double y2):
|
|
|
|
JKQTPGeoLine(parent->getPlotter(), x1,y1,x2,y2)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoLine::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
minx=qMin(x1, x2);
|
|
|
|
maxx=qMax(x1, x2);
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=x1; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
xvsgz=x2; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoLine::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
miny=qMin(y1, y2);
|
|
|
|
maxy=qMax(y1, y2);
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=y1; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
xvsgz=y2; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoLine::draw(JKQTPEnhancedPainter& painter) {
|
2019-05-06 01:31:20 +08:00
|
|
|
clearHitTestData();
|
|
|
|
reserveHitTestData(2);
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
painter.setPen(getLinePen(painter, parent));
|
2018-12-28 05:52:00 +08:00
|
|
|
QLineF l(QPointF(transformX(x1), transformY(y1)), QPointF(transformX(x2), transformY(y2)));
|
2019-05-06 01:31:20 +08:00
|
|
|
if (l.length()>0) {
|
|
|
|
painter.drawLine(l);
|
|
|
|
addHitTestData(x1, y1);
|
|
|
|
addHitTestData(x2, y2);
|
|
|
|
}
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
void JKQTPGeoLine::setX1(double __value)
|
|
|
|
{
|
|
|
|
this->x1 = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoLine::getX1() const
|
|
|
|
{
|
|
|
|
return this->x1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoLine::setY1(double __value)
|
|
|
|
{
|
|
|
|
this->y1 = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoLine::getY1() const
|
|
|
|
{
|
|
|
|
return this->y1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoLine::setX2(double __value)
|
|
|
|
{
|
|
|
|
this->x2 = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoLine::getX2() const
|
|
|
|
{
|
|
|
|
return this->x2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoLine::setY2(double __value)
|
|
|
|
{
|
|
|
|
this->y2 = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoLine::getY2() const
|
|
|
|
{
|
|
|
|
return this->y2;
|
|
|
|
}
|
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoInfiniteLine::JKQTPGeoInfiniteLine(JKQTBasePlotter* parent, double x, double y, double dx, double dy, QColor color, double lineWidth, Qt::PenStyle style):
|
|
|
|
JKQTPGeoBaseLine(color, lineWidth, style, parent)
|
2015-07-11 18:56:02 +08:00
|
|
|
{
|
|
|
|
this->x=x;
|
|
|
|
this->y=y;
|
|
|
|
this->dx=dx;
|
|
|
|
this->dy=dy;
|
|
|
|
this->two_sided=false;
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoInfiniteLine::JKQTPGeoInfiniteLine(JKQTPlotter* parent, double x, double y, double dx, double dy, QColor color, double lineWidth, Qt::PenStyle style):
|
2019-04-22 19:27:50 +08:00
|
|
|
JKQTPGeoInfiniteLine(parent->getPlotter(), x, y, dx, dy, color, lineWidth, style)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoInfiniteLine::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
minx=x;
|
|
|
|
maxx=x;
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
if (x>10.0*DBL_MIN) smallestGreaterZero=x;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoInfiniteLine::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
miny=y;
|
|
|
|
maxy=y;
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
if (y>10.0*DBL_MIN) smallestGreaterZero=y;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoInfiniteLine::draw(JKQTPEnhancedPainter& painter) {
|
2019-05-06 01:31:20 +08:00
|
|
|
clearHitTestData();
|
|
|
|
reserveHitTestData(2);
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-01-26 03:16:04 +08:00
|
|
|
double xmin=parent->getXAxis()->getMin();
|
|
|
|
double xmax=parent->getXAxis()->getMax();
|
|
|
|
double ymin=parent->getYAxis()->getMin();
|
|
|
|
double ymax=parent->getYAxis()->getMax();
|
2015-07-11 18:56:02 +08:00
|
|
|
QRectF bbox(QPointF(xmin, ymin), QPointF(xmax, ymax));
|
|
|
|
bool doDraw=false;
|
|
|
|
double x2=x, y2=y;
|
|
|
|
double x1=x, y1=y;
|
|
|
|
|
|
|
|
// normalize lengh of direction
|
|
|
|
double dl=sqrt(dx*dx+dy*dy);
|
|
|
|
dx=dx/dl;
|
|
|
|
dy=dy/dl;
|
|
|
|
|
|
|
|
// first catch cases where we are parallel to one coordinate axis
|
|
|
|
if (dy==0) {
|
|
|
|
doDraw=((y>=ymin)&&(y<=ymax));
|
|
|
|
x1=xmin;
|
|
|
|
x2=xmax;
|
|
|
|
if (!two_sided) {
|
|
|
|
if ((dx>0)&&(x>xmin)) {
|
|
|
|
x1=x;
|
|
|
|
} else if ((dx<0)&&(x<xmax)) {
|
|
|
|
x2=x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (dx==0) {
|
|
|
|
doDraw=((x>=xmin)&&(x<=xmax));
|
|
|
|
y1=ymin;
|
|
|
|
y2=ymax;
|
|
|
|
if (!two_sided) {
|
|
|
|
if ((dy>0)&&(y>ymin)) {
|
|
|
|
y1=y;
|
|
|
|
} else if ((dy<0)&&(y<ymax)) {
|
|
|
|
y2=y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// first we find intersection points of line and y=ymin, as well as y=ymax
|
|
|
|
double tymin=(ymin-y)/dy;
|
|
|
|
double xymin=x+tymin*dx;
|
|
|
|
double tymax=(ymax-y)/dy;
|
|
|
|
double xymax=x+tymax*dx;
|
|
|
|
double t1=0, t2=0;
|
|
|
|
if ((xymin>xmin)&&(xymin<xmax)) {
|
|
|
|
// (xymin,ymin) is on the rectangle circumference => use it
|
|
|
|
t1=tymin;
|
|
|
|
if (two_sided) {
|
|
|
|
doDraw=true;
|
|
|
|
} else if (t1>0) {
|
|
|
|
doDraw=true;
|
|
|
|
} else {
|
|
|
|
t1=0;
|
|
|
|
}
|
|
|
|
} else if (xymin<xmin) {
|
|
|
|
//(xymin,ymin) is on the left, next to the rectangle, so we have to intersect with x=xmin
|
|
|
|
t1=(xmin-x)/dx;
|
|
|
|
if (two_sided) {
|
|
|
|
doDraw=true;
|
|
|
|
} else if (t1>0) {
|
|
|
|
doDraw=true;
|
|
|
|
} else {
|
|
|
|
t1=0;
|
|
|
|
}
|
|
|
|
} else if (xymin>xmax) {
|
|
|
|
//(xymin,ymin) is on the right, next to the rectangle, so we have to intersect with x=xmax
|
|
|
|
t1=(xmax-x)/dx;
|
|
|
|
if (two_sided) {
|
|
|
|
doDraw=true;
|
|
|
|
} else if (t1>0) {
|
|
|
|
doDraw=true;
|
|
|
|
} else {
|
|
|
|
t1=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((xymax>xmin)&&(xymax<xmax)) {
|
|
|
|
// (xymax,ymin) is on the rectangle circumference => use it
|
|
|
|
t2=tymax;
|
|
|
|
if (two_sided) {
|
|
|
|
doDraw=true;
|
|
|
|
} else if (t2>0) {
|
|
|
|
doDraw=true;
|
|
|
|
} else {
|
|
|
|
t2=0;
|
|
|
|
}
|
|
|
|
} else if (xymax<xmin) {
|
|
|
|
//(xymax,ymax) is on the left, next to the rectangle, so we have to intersect with x=xmin
|
|
|
|
t2=(xmin-x)/dx;
|
|
|
|
if (two_sided) {
|
|
|
|
doDraw=true;
|
|
|
|
} else if (t2>0) {
|
|
|
|
doDraw=true;
|
|
|
|
} else {
|
|
|
|
t2=0;
|
|
|
|
}
|
|
|
|
} else if (xymax>xmax) {
|
|
|
|
//(xymax,ymax) is on the right, next to the rectangle, so we have to intersect with x=xmax
|
|
|
|
t2=(xmax-x)/dx;
|
|
|
|
if (two_sided) {
|
|
|
|
doDraw=true;
|
|
|
|
} else if (t2>0) {
|
|
|
|
doDraw=true;
|
|
|
|
} else {
|
|
|
|
t2=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x1=x+t1*dx;
|
|
|
|
y1=y+t1*dy;
|
|
|
|
x2=x+t2*dx;
|
|
|
|
y2=y+t2*dy;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doDraw) {
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
painter.setPen(getLinePen(painter, parent));
|
2018-12-28 05:52:00 +08:00
|
|
|
QLineF l(QPointF(transformX(x1), transformY(y1)), QPointF(transformX(x2), transformY(y2)));
|
2019-05-06 01:31:20 +08:00
|
|
|
if (l.length()>0) {
|
|
|
|
painter.drawLine(l);
|
|
|
|
addHitTestData(x, y, formatHitTestDefaultLabel(x,y)+
|
2019-05-30 04:40:02 +08:00
|
|
|
QString(", \\ensuremath{\\mathrm{\\mathbf{d}}y/\\mathrm{\\mathbf{d}}x\\;=\\;%1/%2\\;=\\;%3\\;=\\;%4\\degree}").arg(jkqtp_floattolatexqstr(dy, 3)).arg(jkqtp_floattolatexqstr(dx, 3)).arg(jkqtp_floattolatexqstr(dy/dx, 3)).arg(jkqtp_floattolatexqstr(atan2(dy,dx), 1)));
|
2019-05-06 01:31:20 +08:00
|
|
|
addHitTestData(x1, y1);
|
|
|
|
addHitTestData(x2, y2);
|
|
|
|
}
|
|
|
|
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
void JKQTPGeoInfiniteLine::setX(double __value)
|
|
|
|
{
|
|
|
|
this->x = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoInfiniteLine::getX() const
|
|
|
|
{
|
|
|
|
return this->x;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoInfiniteLine::setY(double __value)
|
|
|
|
{
|
|
|
|
this->y = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoInfiniteLine::getY() const
|
|
|
|
{
|
|
|
|
return this->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoInfiniteLine::setDx(double __value)
|
|
|
|
{
|
|
|
|
this->dx = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoInfiniteLine::getDx() const
|
|
|
|
{
|
|
|
|
return this->dx;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoInfiniteLine::setDy(double __value)
|
|
|
|
{
|
|
|
|
this->dy = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoInfiniteLine::getDy() const
|
|
|
|
{
|
|
|
|
return this->dy;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoInfiniteLine::setTwoSided(bool __value)
|
|
|
|
{
|
|
|
|
this->two_sided = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool JKQTPGeoInfiniteLine::getTwoSided() const
|
|
|
|
{
|
|
|
|
return this->two_sided;
|
|
|
|
}
|
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoPolyLines::JKQTPGeoPolyLines(JKQTBasePlotter* parent, const QVector<QPointF>& points, QColor color, double lineWidth, Qt::PenStyle style):
|
|
|
|
JKQTPGeoBaseLine(color, lineWidth, style, parent)
|
2015-07-11 18:56:02 +08:00
|
|
|
{
|
|
|
|
this->points=points;
|
|
|
|
}
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoPolyLines::JKQTPGeoPolyLines(JKQTPlotter* parent, const QVector<QPointF>& points, QColor color, double lineWidth, Qt::PenStyle style):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseLine(color, lineWidth, style, parent)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
|
|
|
this->points=points;
|
|
|
|
}
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoPolyLines::JKQTPGeoPolyLines(JKQTBasePlotter *parent, QColor color, double lineWidth, Qt::PenStyle style):
|
|
|
|
JKQTPGeoBaseLine(color, lineWidth, style, parent)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoPolyLines::JKQTPGeoPolyLines(JKQTPlotter *parent, QColor color, double lineWidth, Qt::PenStyle style):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseLine(color, lineWidth, style, parent)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoPolyLines::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
minx=0;
|
|
|
|
maxx=0;
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
if (points.size()>0) {
|
|
|
|
minx=points[0].x();
|
|
|
|
maxx=points[0].x();
|
|
|
|
for (int i=1; i<points.size(); i++) {
|
|
|
|
double x=points[i].x();
|
|
|
|
if (x>maxx) maxx=x;
|
|
|
|
if (x<minx) minx=x;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=x; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
//qDebug()<<"getXMinMax"<<minx<<maxx;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoPolyLines::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
miny=0;
|
|
|
|
maxy=0;
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
if (points.size()>0) {
|
|
|
|
miny=points[0].y();
|
|
|
|
maxy=points[0].y();
|
|
|
|
for (int i=1; i<points.size(); i++) {
|
|
|
|
double y=points[i].y();
|
|
|
|
if (y>maxy) maxy=y;
|
|
|
|
if (y<miny) miny=y;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=y; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
//qDebug()<<"getYMinMax"<<miny<<maxy;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoPolyLines::draw(JKQTPEnhancedPainter& painter) {
|
2019-05-06 01:31:20 +08:00
|
|
|
clearHitTestData();
|
|
|
|
reserveHitTestData(points.size());
|
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
QPainterPath path=transformToLinePath(points);
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
painter.setPen(getLinePen(painter, parent));
|
2015-07-11 18:56:02 +08:00
|
|
|
painter.drawPath(path);
|
2019-05-06 01:31:20 +08:00
|
|
|
for (const auto& p:points) {
|
|
|
|
addHitTestData(p.x(), p.y());
|
|
|
|
}
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
void JKQTPGeoPolyLines::setPoints(const QVector<QPointF> &__value)
|
|
|
|
{
|
|
|
|
this->points = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVector<QPointF> JKQTPGeoPolyLines::getPoints() const
|
|
|
|
{
|
|
|
|
return this->points;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoPolyLines::appendPoint(const QPointF &p) {
|
|
|
|
points.append(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoPolyLines::appendPoint(const double x, const double y) {
|
|
|
|
points.append(QPointF(x, y));
|
|
|
|
}
|
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTBasePlotter* parent, double x, double y, double width, double height, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
|
|
|
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
2015-07-11 18:56:02 +08:00
|
|
|
{
|
|
|
|
this->x=x;
|
|
|
|
this->y=y;
|
2019-01-08 04:00:56 +08:00
|
|
|
angle=0;
|
2015-07-11 18:56:02 +08:00
|
|
|
this->width=width;
|
|
|
|
this->height=height;
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTPlotter* parent, double x, double y, double width, double height, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
|
|
|
this->x=x;
|
|
|
|
this->y=y;
|
2019-01-08 04:00:56 +08:00
|
|
|
angle=0;
|
|
|
|
this->width=width;
|
|
|
|
this->height=height;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTBasePlotter *parent, double x, double y, double width, double height, double angle, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
|
|
|
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
this->x=x;
|
|
|
|
this->y=y;
|
|
|
|
this->angle=angle;
|
|
|
|
this->width=width;
|
|
|
|
this->height=height;
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTPlotter *parent, double x, double y, double width, double height, double angle, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
this->x=x;
|
|
|
|
this->y=y;
|
|
|
|
this->angle=angle;
|
2015-08-02 19:36:54 +08:00
|
|
|
this->width=width;
|
|
|
|
this->height=height;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTBasePlotter *parent, QPointF bottomleft, QPointF topright, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
|
|
|
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
this->angle=0;
|
|
|
|
this->width=fabs(topright.x()-bottomleft.x());
|
|
|
|
this->height=fabs(topright.y()-bottomleft.y());
|
|
|
|
this->x=bottomleft.x()+this->width/2.0;
|
|
|
|
this->y=bottomleft.y()+this->height/2.0;
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoRectangle::JKQTPGeoRectangle(JKQTPlotter *parent, QPointF bottomleft, QPointF topright, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
this->angle=0;
|
|
|
|
this->width=fabs(topright.x()-bottomleft.x());
|
|
|
|
this->height=fabs(topright.y()-bottomleft.y());
|
|
|
|
this->x=bottomleft.x()+this->width/2.0;
|
|
|
|
this->y=bottomleft.y()+this->height/2.0;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
QMatrix JKQTPGeoRectangle::getMatrix() {
|
2015-07-11 18:56:02 +08:00
|
|
|
QMatrix trans;
|
2019-01-08 04:00:56 +08:00
|
|
|
trans.rotate(angle);
|
2015-07-11 18:56:02 +08:00
|
|
|
return trans;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoRectangle::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QRectF bound=getPolygon().boundingRect();
|
2019-01-20 17:49:29 +08:00
|
|
|
//std::cout<<"JKQTPGeoRectangle::getXMinMax: b.left="<<bound.left()<<" b.right="<<bound.right()<<" b.top="<<bound.top()<<" b.bottom="<<bound.bottom()<<std::endl;
|
2015-07-11 18:56:02 +08:00
|
|
|
minx=bound.left();
|
|
|
|
maxx=bound.right();
|
|
|
|
if (minx>maxx) std::swap(minx, maxx);
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=minx; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
xvsgz=maxx; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoRectangle::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QRectF bound=getPolygon().boundingRect();
|
|
|
|
miny=bound.bottom();
|
|
|
|
maxy=bound.top();
|
|
|
|
if (miny>maxy) std::swap(miny, maxy);
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=miny; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
xvsgz=maxy; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
QPolygonF JKQTPGeoRectangle::getPolygon() {
|
2015-07-11 18:56:02 +08:00
|
|
|
QMatrix m=getMatrix();
|
|
|
|
QPolygonF rect;
|
|
|
|
rect.append(m.map(QPointF(0-width/2.0, 0-height/2.0)));
|
|
|
|
rect.append(m.map(QPointF(0-width/2.0, 0+height/2.0)));
|
|
|
|
rect.append(m.map(QPointF(0+width/2.0, 0+height/2.0)));
|
|
|
|
rect.append(m.map(QPointF(0+width/2.0, 0-height/2.0)));
|
|
|
|
rect.translate(x,y);
|
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoRectangle::draw(JKQTPEnhancedPainter& painter) {
|
2019-05-06 01:31:20 +08:00
|
|
|
clearHitTestData();
|
2015-07-11 18:56:02 +08:00
|
|
|
QPolygonF poly=getPolygon();
|
2019-05-06 01:31:20 +08:00
|
|
|
reserveHitTestData(poly.size());
|
2015-07-11 18:56:02 +08:00
|
|
|
QPolygonF rect;
|
|
|
|
for (int i=0; i<poly.size(); i++) {
|
2018-12-28 05:52:00 +08:00
|
|
|
rect.append(QPointF(transformX(poly[i].x()), transformY(poly[i].y())));
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
2019-05-06 01:31:20 +08:00
|
|
|
for (const auto& p:poly) {
|
|
|
|
addHitTestData(p.x(), p.y());
|
|
|
|
}
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
painter.setPen(getLinePenForRects(painter, parent));
|
|
|
|
painter.setBrush(getFillBrush(painter, parent));
|
2015-07-11 18:56:02 +08:00
|
|
|
painter.drawPolygon(rect);
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
void JKQTPGeoRectangle::setX(double __value)
|
|
|
|
{
|
|
|
|
this->x = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoRectangle::getX() const
|
|
|
|
{
|
|
|
|
return this->x;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoRectangle::setY(double __value)
|
|
|
|
{
|
|
|
|
this->y = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoRectangle::getY() const
|
|
|
|
{
|
|
|
|
return this->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoRectangle::setWidth(double __value)
|
|
|
|
{
|
|
|
|
this->width = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoRectangle::getWidth() const
|
|
|
|
{
|
|
|
|
return this->width;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoRectangle::setHeight(double __value)
|
|
|
|
{
|
|
|
|
this->height = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoRectangle::getHeight() const
|
|
|
|
{
|
|
|
|
return this->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoRectangle::setAngle(double __value)
|
|
|
|
{
|
|
|
|
this->angle = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoRectangle::getAngle() const
|
|
|
|
{
|
|
|
|
return this->angle;
|
|
|
|
}
|
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-01-26 20:00:40 +08:00
|
|
|
void JKQTPGeoRectangle::setBottomleftrectangle(double x, double y, double width, double height) {
|
2015-07-11 18:56:02 +08:00
|
|
|
this->x=x+width/2.0;
|
|
|
|
this->y=y+height/2.0;
|
|
|
|
this->width=width;
|
|
|
|
this->height=height;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTBasePlotter* parent, const QVector<QPointF>& points, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
|
|
|
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
2015-07-11 18:56:02 +08:00
|
|
|
{
|
|
|
|
this->points=points;
|
|
|
|
}
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTPlotter* parent, const QVector<QPointF>& points, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
|
|
|
this->points=points;
|
|
|
|
}
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTBasePlotter* parent, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
|
|
|
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
}
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoPolygon::JKQTPGeoPolygon(JKQTPlotter* parent, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoBaseFilled(color, fillColor, lineWidth, style, fillStyle, parent)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoPolygon::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
minx=0;
|
|
|
|
maxx=0;
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
if (points.size()>0) {
|
|
|
|
minx=points[0].x();
|
|
|
|
maxx=points[0].x();
|
|
|
|
for (int i=1; i<points.size(); i++) {
|
|
|
|
double x=points[i].x();
|
|
|
|
if (x>maxx) maxx=x;
|
|
|
|
if (x<minx) minx=x;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=x; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoPolygon::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
miny=0;
|
|
|
|
maxy=0;
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
if (points.size()>0) {
|
|
|
|
miny=points[0].y();
|
|
|
|
maxy=points[0].y();
|
|
|
|
for (int i=1; i<points.size(); i++) {
|
|
|
|
double y=points[i].y();
|
|
|
|
if (y>maxy) maxy=y;
|
|
|
|
if (y<miny) miny=y;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=y; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoPolygon::draw(JKQTPEnhancedPainter& painter) {
|
2019-05-06 01:31:20 +08:00
|
|
|
clearHitTestData();
|
|
|
|
reserveHitTestData(points.size());
|
2015-07-11 18:56:02 +08:00
|
|
|
QPolygonF path=transformToPolygon(points);
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
painter.setPen(getLinePen(painter, parent));
|
|
|
|
painter.setBrush(getFillBrush(painter, parent));
|
2015-07-11 18:56:02 +08:00
|
|
|
painter.drawPolygon(path);
|
2019-05-06 01:31:20 +08:00
|
|
|
for (const auto& p:points) {
|
|
|
|
addHitTestData(p.x(), p.y());
|
|
|
|
}
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
void JKQTPGeoPolygon::setPoints(const QVector<QPointF> &__value)
|
|
|
|
{
|
|
|
|
this->points = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVector<QPointF> JKQTPGeoPolygon::getPoints() const
|
|
|
|
{
|
|
|
|
return this->points;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoPolygon::appendPoint(const QPointF &p) {
|
|
|
|
points.append(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoPolygon::appendPoint(const double x, const double y) {
|
|
|
|
points.append(QPointF(x, y));
|
|
|
|
}
|
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTBasePlotter* parent, double x, double y, double width, double height, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
|
|
|
JKQTPGeoRectangle(parent, x, y, width, height, color, lineWidth, style, fillColor, fillStyle)
|
2015-07-11 18:56:02 +08:00
|
|
|
{
|
|
|
|
controlPoints=180;
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTPlotter* parent, double x, double y, double width, double height, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoRectangle(parent, x, y, width, height, color, lineWidth, style, fillColor, fillStyle)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
|
|
|
controlPoints=180;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTBasePlotter *parent, double x, double y, double width, double height, double angle, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
|
|
|
JKQTPGeoRectangle(parent, x, y, width, height, angle, color, lineWidth, style, fillColor, fillStyle)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
controlPoints=180;
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTPlotter *parent, double x, double y, double width, double height, double angle, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoRectangle(parent, x, y, width, height, angle, color, lineWidth, style, fillColor, fillStyle)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
controlPoints=180;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTBasePlotter *parent, QPointF bottomleft, QPointF topright, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
|
|
|
JKQTPGeoRectangle(parent, bottomleft, topright, color, lineWidth, style, fillColor, fillStyle)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
controlPoints=180;
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoEllipse::JKQTPGeoEllipse(JKQTPlotter *parent, QPointF bottomleft, QPointF topright, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoRectangle(parent, bottomleft, topright, color, lineWidth, style, fillColor, fillStyle)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
controlPoints=180;
|
|
|
|
}
|
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoEllipse::draw(JKQTPEnhancedPainter& painter) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QPainterPath rect;
|
2019-01-20 17:49:29 +08:00
|
|
|
rect=transformToLinePath(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,0,360,angle, controlPoints));
|
2015-07-11 18:56:02 +08:00
|
|
|
rect.closeSubpath();
|
|
|
|
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
painter.setPen(getLinePen(painter, parent));
|
|
|
|
painter.setBrush(getFillBrush(painter, parent));
|
2015-07-11 18:56:02 +08:00
|
|
|
painter.drawPath(rect);
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
void JKQTPGeoEllipse::setControlPoints(const unsigned int &__value)
|
|
|
|
{
|
|
|
|
this->controlPoints = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int JKQTPGeoEllipse::getControlPoints() const
|
|
|
|
{
|
|
|
|
return this->controlPoints;
|
|
|
|
}
|
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoArc::JKQTPGeoArc(JKQTBasePlotter* parent, double x, double y, double width, double height, double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style):
|
|
|
|
JKQTPGeoBaseLine(color, lineWidth, style, parent)
|
2015-07-11 18:56:02 +08:00
|
|
|
{
|
|
|
|
this->angleStart=angleStart;
|
|
|
|
this->angleStop=angleStop;
|
|
|
|
this->x=x;
|
|
|
|
this->y=y;
|
|
|
|
this->width=width;
|
|
|
|
this->height=height;
|
2019-01-08 04:00:56 +08:00
|
|
|
this->angle=0;
|
2015-07-11 18:56:02 +08:00
|
|
|
this->controlPoints=180;
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoArc::JKQTPGeoArc(JKQTPlotter* parent, double x, double y, double width, double height, double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style):
|
2019-04-22 19:27:50 +08:00
|
|
|
JKQTPGeoArc(parent->getPlotter(), x, y, width, height, angleStart, angleStop, color, lineWidth, style)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoArc::draw(JKQTPEnhancedPainter& painter) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QPainterPath rect;
|
2019-01-20 17:49:29 +08:00
|
|
|
rect=transformToLinePath(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
painter.setPen(getLinePen(painter, parent));
|
2015-07-11 18:56:02 +08:00
|
|
|
painter.drawPath(rect);
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
void JKQTPGeoArc::setControlPoints(const unsigned int &__value)
|
|
|
|
{
|
|
|
|
this->controlPoints = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int JKQTPGeoArc::getControlPoints() const
|
|
|
|
{
|
|
|
|
return this->controlPoints;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoArc::setAngleStart(double __value)
|
|
|
|
{
|
|
|
|
this->angleStart = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoArc::getAngleStart() const
|
|
|
|
{
|
|
|
|
return this->angleStart;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoArc::setAngleStop(double __value)
|
|
|
|
{
|
|
|
|
this->angleStop = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoArc::getAngleStop() const
|
|
|
|
{
|
|
|
|
return this->angleStop;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoArc::setX(double __value)
|
|
|
|
{
|
|
|
|
this->x = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoArc::getX() const
|
|
|
|
{
|
|
|
|
return this->x;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoArc::setY(double __value)
|
|
|
|
{
|
|
|
|
this->y = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoArc::getY() const
|
|
|
|
{
|
|
|
|
return this->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoArc::setWidth(double __value)
|
|
|
|
{
|
|
|
|
this->width = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoArc::getWidth() const
|
|
|
|
{
|
|
|
|
return this->width;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoArc::setHeight(double __value)
|
|
|
|
{
|
|
|
|
this->height = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoArc::getHeight() const
|
|
|
|
{
|
|
|
|
return this->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoArc::setAngle(double __value)
|
|
|
|
{
|
|
|
|
this->angle = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoArc::getAngle() const
|
|
|
|
{
|
|
|
|
return this->angle;
|
|
|
|
}
|
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoArc::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QPolygonF rect;
|
2019-01-20 17:49:29 +08:00
|
|
|
rect=QPolygonF(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
2015-07-11 18:56:02 +08:00
|
|
|
minx=rect.boundingRect().left();
|
|
|
|
maxx=rect.boundingRect().right();
|
|
|
|
if (minx>maxx) std::swap(minx, maxx);
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=minx; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
xvsgz=maxx; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoArc::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QPolygonF rect;
|
2019-01-20 17:49:29 +08:00
|
|
|
rect=QPolygonF(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
2015-07-11 18:56:02 +08:00
|
|
|
miny=rect.boundingRect().bottom();
|
|
|
|
maxy=rect.boundingRect().top();
|
|
|
|
if (miny>maxy) std::swap(miny, maxy);
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=miny; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
xvsgz=maxy; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoPie::JKQTPGeoPie(JKQTBasePlotter* parent, double x, double y, double width, double height,double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
|
|
|
JKQTPGeoEllipse(parent, x, y, width, height, color, lineWidth, style, fillColor, fillStyle)
|
2015-07-11 18:56:02 +08:00
|
|
|
{
|
|
|
|
this->angleStart=angleStart;
|
|
|
|
this->angleStop=angleStop;
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoPie::JKQTPGeoPie(JKQTPlotter* parent, double x, double y, double width, double height,double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoEllipse(parent, x, y, width, height, color, lineWidth, style, fillColor, fillStyle)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
|
|
|
this->angleStart=angleStart;
|
|
|
|
this->angleStop=angleStop;
|
|
|
|
}
|
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoPie::draw(JKQTPEnhancedPainter& painter) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QPainterPath rect;
|
2019-01-20 17:49:29 +08:00
|
|
|
rect=transformToLinePath(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
2015-07-11 18:56:02 +08:00
|
|
|
rect.lineTo(transform(x,y));
|
|
|
|
rect.closeSubpath();
|
|
|
|
|
|
|
|
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
painter.setPen(getLinePenForRects(painter, parent));
|
|
|
|
painter.setBrush(getFillBrush(painter, parent));
|
2015-07-11 18:56:02 +08:00
|
|
|
painter.drawPath(rect);
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
void JKQTPGeoPie::setAngleStart(double __value)
|
|
|
|
{
|
|
|
|
this->angleStart = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoPie::getAngleStart() const
|
|
|
|
{
|
|
|
|
return this->angleStart;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoPie::setAngleStop(double __value)
|
|
|
|
{
|
|
|
|
this->angleStop = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoPie::getAngleStop() const
|
|
|
|
{
|
|
|
|
return this->angleStop;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoPie::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QPolygonF rect;
|
2019-01-20 17:49:29 +08:00
|
|
|
rect=QPolygonF(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
2015-07-11 18:56:02 +08:00
|
|
|
rect.append(QPointF(x,y));
|
|
|
|
minx=rect.boundingRect().left();
|
|
|
|
maxx=rect.boundingRect().right();
|
|
|
|
if (minx>maxx) std::swap(minx, maxx);
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=minx; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
xvsgz=maxx; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoPie::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QPolygonF rect;
|
2019-01-20 17:49:29 +08:00
|
|
|
rect=QPolygonF(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
2015-07-11 18:56:02 +08:00
|
|
|
rect.append(QPointF(x,y));
|
|
|
|
miny=rect.boundingRect().bottom();
|
|
|
|
maxy=rect.boundingRect().top();
|
|
|
|
if (miny>maxy) std::swap(miny, maxy);
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=miny; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
xvsgz=maxy; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoChord::JKQTPGeoChord(JKQTBasePlotter* parent, double x, double y, double width, double height,double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
|
|
|
JKQTPGeoPie(parent, x, y, width, height, angleStart, angleStop, color, lineWidth, style, fillColor, fillStyle)
|
2015-07-11 18:56:02 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoChord::JKQTPGeoChord(JKQTPlotter* parent, double x, double y, double width, double height,double angleStart, double angleStop, QColor color, double lineWidth, Qt::PenStyle style, QColor fillColor, Qt::BrushStyle fillStyle):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoPie(parent, x, y, width, height, angleStart, angleStop, color, lineWidth, style, fillColor, fillStyle)
|
2015-08-02 19:36:54 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoChord::draw(JKQTPEnhancedPainter& painter) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QPainterPath rect;
|
2019-01-20 17:49:29 +08:00
|
|
|
rect=transformToLinePath(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
2015-07-11 18:56:02 +08:00
|
|
|
rect.closeSubpath();
|
|
|
|
|
|
|
|
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
painter.setPen(getLinePen(painter, parent));
|
|
|
|
painter.setBrush(getFillBrush(painter, parent));
|
2015-07-11 18:56:02 +08:00
|
|
|
painter.drawPath(rect);
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoChord::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QPolygonF rect;
|
2019-01-20 17:49:29 +08:00
|
|
|
rect=QPolygonF(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
2015-07-11 18:56:02 +08:00
|
|
|
minx=rect.boundingRect().left();
|
|
|
|
maxx=rect.boundingRect().right();
|
|
|
|
if (minx>maxx) std::swap(minx, maxx);
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=minx; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
xvsgz=maxx; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoChord::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QPolygonF rect;
|
2019-01-20 17:49:29 +08:00
|
|
|
rect=QPolygonF(JKQTPDrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,angle, controlPoints));
|
2015-07-11 18:56:02 +08:00
|
|
|
miny=rect.boundingRect().bottom();
|
|
|
|
maxy=rect.boundingRect().top();
|
|
|
|
if (miny>maxy) std::swap(miny, maxy);
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=miny; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
xvsgz=maxy; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-08 04:00:56 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTBasePlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color, QColor fillColor):
|
|
|
|
JKQTPPlotObject(parent)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
this->x=x;
|
|
|
|
this->y=y;
|
2019-04-22 19:27:50 +08:00
|
|
|
setSymbolType(symbol);
|
|
|
|
setSymbolSize(symbolSize);
|
|
|
|
setSymbolColor(color);
|
|
|
|
setSymbolFillColor(fillColor);
|
|
|
|
setSymbolLineWidth(1);
|
2019-01-08 04:00:56 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 23:15:10 +08:00
|
|
|
JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTPlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color, QColor fillColor):
|
2019-01-20 17:49:29 +08:00
|
|
|
JKQTPPlotObject(parent)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
this->x=x;
|
|
|
|
this->y=y;
|
2019-04-22 19:27:50 +08:00
|
|
|
setSymbolType(symbol);
|
|
|
|
setSymbolSize(symbolSize);
|
|
|
|
setSymbolColor(color);
|
|
|
|
setSymbolFillColor(fillColor);
|
|
|
|
setSymbolLineWidth(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoSymbol::setColor(QColor c)
|
|
|
|
{
|
|
|
|
setSymbolColor(c);
|
|
|
|
setSymbolFillColor(JKQTPGetDerivedColor(parent->getCurrentPlotterStyle().graphFillColorDerivationMode, c));
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoSymbol::setX(double __value)
|
|
|
|
{
|
|
|
|
this->x = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoSymbol::getX() const
|
|
|
|
{
|
|
|
|
return this->x;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoSymbol::setY(double __value)
|
|
|
|
{
|
|
|
|
this->y = __value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double JKQTPGeoSymbol::getY() const
|
|
|
|
{
|
|
|
|
return this->y;
|
2019-01-08 04:00:56 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoSymbol::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
minx=x;
|
|
|
|
maxx=x;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=minx; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
xvsgz=maxx; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
bool JKQTPGeoSymbol::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
miny=y;
|
|
|
|
maxy=y;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=miny; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
xvsgz=maxy; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoSymbol::draw(JKQTPEnhancedPainter &painter)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
2019-05-06 01:31:20 +08:00
|
|
|
clearHitTestData();
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
plotStyledSymbol(parent, painter, transformX(x), transformY(y));
|
2019-05-06 01:31:20 +08:00
|
|
|
addHitTestData(x,y);
|
2019-01-08 04:00:56 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
void JKQTPGeoSymbol::drawKeyMarker(JKQTPEnhancedPainter &painter, QRectF &rect)
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
|
|
|
const double minSize=qMin(rect.width(), rect.height());
|
2019-04-22 19:27:50 +08:00
|
|
|
double symbolSize=parent->pt2px(painter, this->getSymbolSize());
|
2019-01-08 04:00:56 +08:00
|
|
|
if (symbolSize>minSize*0.9) symbolSize=minSize*0.9;
|
2019-04-22 19:27:50 +08:00
|
|
|
double symbolWidth=parent->pt2px(painter, this->getSymbolLineWidth()*parent->getLineWidthMultiplier());
|
2019-01-08 04:00:56 +08:00
|
|
|
if (symbolWidth>0.3*symbolSize) symbolWidth=0.3*symbolSize;
|
|
|
|
|
2019-02-08 00:24:46 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2019-04-22 19:27:50 +08:00
|
|
|
JKQTPPlotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, getSymbolType(), symbolSize, symbolWidth, getSymbolColor(), getSymbolFillColor());
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2019-01-08 04:00:56 +08:00
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
QColor JKQTPGeoSymbol::getKeyLabelColor() const
|
2019-01-08 04:00:56 +08:00
|
|
|
{
|
2019-04-22 19:27:50 +08:00
|
|
|
return getSymbolColor();
|
2019-01-08 04:00:56 +08:00
|
|
|
}
|