2020-08-26 16:36:07 +08:00
|
|
|
/*
|
2024-02-06 21:50:49 +08:00
|
|
|
Copyright (c) 2008-2024 Jan W. Krieger (<jan@jkrieger.de>)
|
2020-08-26 16:36:07 +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
|
|
|
|
the Free Software Foundation, either version 2.1 of the License, or
|
|
|
|
(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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "jkqtplotter/graphs/jkqtpgeoannotations.h"
|
|
|
|
#include "jkqtplotter/jkqtpbaseplotter.h"
|
|
|
|
#include "jkqtplotter/jkqtplotter.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QApplication>
|
|
|
|
#define SmallestGreaterZeroCompare_xvsgz() if ((xvsgz>10.0*DBL_MIN)&&((smallestGreaterZero<10.0*DBL_MIN) || (xvsgz<smallestGreaterZero))) smallestGreaterZero=xvsgz;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- improved: geometric objects now use an adaptive drawing algorithm to represent curves (before e.g. ellipses were always separated into a fixed number of line-segments)
- improved: constructors and access functions for several geometric objects (e.g. more constructors, additional functions to retrieve parameters in diferent forms, iterators for polygons, ...)
- new: all geometric objects can either be drawn as graphic element (i.e. lines are straight line, even on non-linear axes), or as mathematical curve (i.e. on non-linear axes, lines become the appropriate curve representing the linear function, connecting the given start/end-points). The only exceptions are ellipses (and the derived arcs,pies,chords), which are always drawn as mathematical curves
2020-09-04 05:08:52 +08:00
|
|
|
JKQTPGeoText::JKQTPGeoText(JKQTBasePlotter* parent, double x_, double y_, const QString& text_, double fontSize, QColor color):
|
2020-09-26 21:58:58 +08:00
|
|
|
JKQTPGeoText(parent, x_, y_, text_, fontSize)
|
2020-08-26 16:36:07 +08:00
|
|
|
{
|
|
|
|
setTextColor(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoText::JKQTPGeoText(JKQTPlotter* parent, double x, double y, const QString& text, double fontSize, QColor color):
|
|
|
|
JKQTPGeoText(parent->getPlotter(),x,y,text,fontSize,color)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
JKQTPGeoText::JKQTPGeoText(JKQTBasePlotter* parent, double x_, double y_, const QString& text_, double fontSize):
|
|
|
|
JKQTPGeoText(parent, x_, y_, text_)
|
|
|
|
{
|
|
|
|
setTextFontSize(fontSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoText::JKQTPGeoText(JKQTPlotter* parent, double x, double y, const QString& text, double fontSize):
|
|
|
|
JKQTPGeoText(parent->getPlotter(),x,y,text,fontSize)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
- improved: geometric objects now use an adaptive drawing algorithm to represent curves (before e.g. ellipses were always separated into a fixed number of line-segments)
- improved: constructors and access functions for several geometric objects (e.g. more constructors, additional functions to retrieve parameters in diferent forms, iterators for polygons, ...)
- new: all geometric objects can either be drawn as graphic element (i.e. lines are straight line, even on non-linear axes), or as mathematical curve (i.e. on non-linear axes, lines become the appropriate curve representing the linear function, connecting the given start/end-points). The only exceptions are ellipses (and the derived arcs,pies,chords), which are always drawn as mathematical curves
2020-09-04 05:08:52 +08:00
|
|
|
JKQTPGeoText::JKQTPGeoText(JKQTBasePlotter *parent, double x_, double y_, const QString& text_):
|
2020-09-21 19:15:57 +08:00
|
|
|
JKQTPPlotAnnotationElement(parent), JKQTPGraphTextStyleMixin(parent), x(x_),y(y_),text(text_)
|
2020-08-26 16:36:07 +08:00
|
|
|
{
|
2020-09-26 21:58:58 +08:00
|
|
|
initTextStyle(parent, parentPlotStyle, JKQTPPlotStyleType::Annotation);
|
2020-08-26 16:36:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
void JKQTPGeoText::setP(const QPointF &p)
|
|
|
|
{
|
|
|
|
x=p.x();
|
|
|
|
y=p.y();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF JKQTPGeoText::getP() const
|
|
|
|
{
|
|
|
|
return QPointF(x,y);
|
|
|
|
}
|
|
|
|
|
2020-08-26 16:36:07 +08:00
|
|
|
double JKQTPGeoText::getY() const
|
|
|
|
{
|
|
|
|
return this->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoText::setColor(QColor c)
|
|
|
|
{
|
|
|
|
setTextColor(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool JKQTPGeoText::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
|
|
|
|
minx=maxx=x;
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
if (x>10.0*DBL_MIN) smallestGreaterZero=x;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool JKQTPGeoText::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
|
|
|
|
miny=maxy=y;
|
|
|
|
smallestGreaterZero=0;
|
|
|
|
if (y>10.0*DBL_MIN) smallestGreaterZero=y;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoText::draw(JKQTPEnhancedPainter& painter) {
|
|
|
|
clearHitTestData();
|
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2022-09-01 20:36:34 +08:00
|
|
|
parent->getMathText()->setFontSpecial(getTextFontName());
|
2020-08-26 16:36:07 +08:00
|
|
|
parent->getMathText()->setFontSize(getTextFontSize()*parent->getFontSizeMultiplier());
|
|
|
|
parent->getMathText()->setFontColor(getTextColor());
|
2022-06-03 05:24:41 +08:00
|
|
|
parent->getMathText()->parse("\\;"+text);
|
2022-06-03 05:05:58 +08:00
|
|
|
parent->getMathText()->draw(painter, transformX(x), transformY(y), parent->getCurrentPlotterStyle().debugShowTextBoxes);
|
2020-08-26 16:36:07 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-12-19 05:24:59 +08:00
|
|
|
void JKQTPGeoText::drawKeyMarker(JKQTPEnhancedPainter& painter, const QRectF& rect) {
|
2020-08-26 16:36:07 +08:00
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
|
|
|
painter.setPen(QPen(getTextColor()));
|
|
|
|
double y=rect.top()+rect.height()/2.0;
|
|
|
|
if (rect.width()>0) painter.drawLine(QLineF(rect.left(), y, rect.right(), y));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor JKQTPGeoText::getKeyLabelColor() const {
|
|
|
|
return getTextColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTBasePlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color, QColor fillColor):
|
2020-09-26 21:58:58 +08:00
|
|
|
JKQTPGeoSymbol(parent, x, y, symbol, symbolSize)
|
2020-08-26 16:36:07 +08:00
|
|
|
{
|
|
|
|
setSymbolColor(color);
|
|
|
|
setSymbolFillColor(fillColor);
|
2020-09-26 21:58:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTBasePlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize):
|
|
|
|
JKQTPGeoSymbol(parent, x, y, symbol)
|
|
|
|
{
|
|
|
|
setSymbolSize(symbolSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTPlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize):
|
|
|
|
JKQTPGeoSymbol(parent->getPlotter(), x, y, symbol, symbolSize)
|
|
|
|
{
|
|
|
|
|
2020-08-26 16:36:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTPlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color, QColor fillColor):
|
- improved: geometric objects now use an adaptive drawing algorithm to represent curves (before e.g. ellipses were always separated into a fixed number of line-segments)
- improved: constructors and access functions for several geometric objects (e.g. more constructors, additional functions to retrieve parameters in diferent forms, iterators for polygons, ...)
- new: all geometric objects can either be drawn as graphic element (i.e. lines are straight line, even on non-linear axes), or as mathematical curve (i.e. on non-linear axes, lines become the appropriate curve representing the linear function, connecting the given start/end-points). The only exceptions are ellipses (and the derived arcs,pies,chords), which are always drawn as mathematical curves
2020-09-04 05:08:52 +08:00
|
|
|
JKQTPGeoSymbol(parent->getPlotter(), x, y, symbol, symbolSize, color, fillColor)
|
2020-08-26 16:36:07 +08:00
|
|
|
{
|
2020-09-26 21:58:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTBasePlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color):
|
|
|
|
JKQTPGeoSymbol(parent, x, y, symbol, symbolSize)
|
|
|
|
{
|
|
|
|
setSymbolColor(color);
|
|
|
|
if (parent) {
|
|
|
|
setSymbolFillColor(JKQTPGetDerivedColor(parent->getCurrentPlotterStyle().graphsStyle.annotationStyle.symbolFillColorDerivationMode, color));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTPlotter *parent, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, QColor color):
|
|
|
|
JKQTPGeoSymbol(parent->getPlotter(), x, y, symbol, symbolSize, color)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTBasePlotter *parent, double x, double y, JKQTPGraphSymbols symbol):
|
|
|
|
JKQTPGeoSymbol(parent, x, y)
|
|
|
|
{
|
|
|
|
setSymbolType(symbol);
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTPlotter *parent, double x, double y, JKQTPGraphSymbols symbol):
|
|
|
|
JKQTPGeoSymbol(parent->getPlotter(), x, y, symbol)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTBasePlotter *parent, double x, double y):
|
|
|
|
JKQTPPlotAnnotationElement(parent)
|
|
|
|
{
|
|
|
|
this->x=x;
|
|
|
|
this->y=y;
|
|
|
|
initSymbolStyle(parent, parentPlotStyle, JKQTPPlotStyleType::Annotation);
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPGeoSymbol::JKQTPGeoSymbol(JKQTPlotter *parent, double x, double y):
|
|
|
|
JKQTPGeoSymbol(parent->getPlotter(), x, y)
|
|
|
|
{
|
- improved: geometric objects now use an adaptive drawing algorithm to represent curves (before e.g. ellipses were always separated into a fixed number of line-segments)
- improved: constructors and access functions for several geometric objects (e.g. more constructors, additional functions to retrieve parameters in diferent forms, iterators for polygons, ...)
- new: all geometric objects can either be drawn as graphic element (i.e. lines are straight line, even on non-linear axes), or as mathematical curve (i.e. on non-linear axes, lines become the appropriate curve representing the linear function, connecting the given start/end-points). The only exceptions are ellipses (and the derived arcs,pies,chords), which are always drawn as mathematical curves
2020-09-04 05:08:52 +08:00
|
|
|
|
2020-08-26 16:36:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoSymbol::setColor(QColor c)
|
|
|
|
{
|
|
|
|
setSymbolColor(c);
|
2020-09-26 21:58:58 +08:00
|
|
|
setSymbolFillColor(JKQTPGetDerivedColor(parent->getCurrentPlotterStyle().graphsStyle.annotationStyle.fillColorDerivationMode, c));
|
2020-08-26 16:36:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-09-26 21:58:58 +08:00
|
|
|
void JKQTPGeoSymbol::setP(const QPointF &p)
|
|
|
|
{
|
|
|
|
x=p.x();
|
|
|
|
y=p.y();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointF JKQTPGeoSymbol::getP() const
|
|
|
|
{
|
|
|
|
return QPointF(x,y);
|
|
|
|
}
|
|
|
|
|
2020-08-26 16:36:07 +08:00
|
|
|
bool JKQTPGeoSymbol::getXMinMax(double &minx, double &maxx, double &smallestGreaterZero)
|
|
|
|
{
|
|
|
|
minx=x;
|
|
|
|
maxx=x;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=minx; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
xvsgz=maxx; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool JKQTPGeoSymbol::getYMinMax(double &miny, double &maxy, double &smallestGreaterZero)
|
|
|
|
{
|
|
|
|
miny=y;
|
|
|
|
maxy=y;
|
|
|
|
double xvsgz;
|
|
|
|
xvsgz=miny; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
xvsgz=maxy; SmallestGreaterZeroCompare_xvsgz();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void JKQTPGeoSymbol::draw(JKQTPEnhancedPainter &painter)
|
|
|
|
{
|
|
|
|
clearHitTestData();
|
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
|
|
|
plotStyledSymbol(parent, painter, transformX(x), transformY(y));
|
|
|
|
addHitTestData(x,y);
|
|
|
|
}
|
|
|
|
|
2023-12-19 05:24:59 +08:00
|
|
|
void JKQTPGeoSymbol::drawKeyMarker(JKQTPEnhancedPainter &painter, const QRectF &rect)
|
2020-08-26 16:36:07 +08:00
|
|
|
{
|
|
|
|
painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();});
|
2022-09-02 20:19:47 +08:00
|
|
|
JKQTPPlotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, getSymbolType(), getKeySymbolSizePx(painter, rect, parent), getKeySymbolLineWidthPx(painter, rect, parent), getKeyLabelColor(), getSymbolFillColor(),getSymbolFont());
|
2020-08-26 16:36:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
QColor JKQTPGeoSymbol::getKeyLabelColor() const
|
|
|
|
{
|
|
|
|
return getSymbolColor();
|
|
|
|
}
|