/* Copyright (c) 2008-2019 Jan W. Krieger () 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 . */ #include "jkqtplottertools/jkqtpdrawingtools.h" #include "jkqtplottertools/jkqtpenhancedpainter.h" const double JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH= 0.02; void JKQTPPlotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPGraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor) { JKQTPEnhancedPainter p(&paintDevice); JKQTPPlotSymbol(p, x, y, symbol, size, symbolLineWidth, color, fillColor); } void JKQTPPlotSymbol(JKQTPEnhancedPainter& painter, double x, double y, JKQTPGraphSymbols symbol, double symbolSize, double symbolLineWidth, QColor color, QColor fillColor) { painter.save(); auto __finalpaint=JKQTPFinally([&painter]() {painter.restore();}); QPen p=painter.pen(); p.setColor(color); p.setWidthF(qMax(JKQTPlotterDrawinTools::ABS_MIN_LINEWIDTH, symbolLineWidth)); p.setStyle(Qt::SolidLine); painter.setPen(p); QBrush b=painter.brush(); b.setColor(fillColor); b.setStyle(Qt::SolidPattern); const double w=symbolSize; const double w2=w/2.0; const double w3=w/3.0; // calculate star cordinates as static values static int star_items=0; static double starcordsx[10]; static double starcordsy[10]; if (star_items==0) { star_items=5; double angle=360.0/double(star_items)/180.0*M_PI; for (int i=0; i(i)+0.5)*angle; starcordsx[i*2]=sin(a); starcordsx[i*2+1]=0.5*sin(a+angle/2.0); starcordsy[i*2]=cos(a); starcordsy[i*2+1]=0.5*cos(a+angle/2.0); } } switch(symbol) { case JKQTPDot: painter.drawPoint(QPointF(x,y)); break; case JKQTPCross:{ /*QVector lines; lines< lines; lines< lines; lines< lines; QPainterPath path; for (int i=0; i JKQTPDrawEllipse(double x, double y, double a, double b, double angle_start, double angle_end, double alpha, int controlPoints, QPointF* x_start, QPointF* x_end) { QVector result; double start=angle_start*M_PI/180.0; double stop=angle_end*M_PI/180.0; double step=(stop-start)/static_cast(controlPoints); while (fabs(stop-start)/step<10) step=step/2.0; double sina=sin(1.0*alpha/180.0*M_PI); double cosa=cos(1.0*alpha/180.0*M_PI); QPointF xp(x+a*cos(start)*cosa-b*sin(start)*sina, y+a*cos(start)*sina+b*sin(start)*cosa); result.append(xp); if (x_start) *x_start = xp; double t=start+step; for (int i=1; i