some renames and new example for line styles and symbols

This commit is contained in:
jkriege2 2018-11-29 21:57:35 +01:00
parent c4b27faedb
commit ffb70ace09
19 changed files with 242 additions and 99 deletions

View File

@ -18,6 +18,7 @@ All test-projects are Qt-projects that use qmake to build. You can load them int
| Screenshot | Description | Notes |
|:-------------:| ------------- | ------------- |
| [![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/jkqtplotter_simpletest1_small.png)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest) | [Very Basic Example (Line Graph)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest) | `JKQTPxyLineGraph`<br/>C-style arrays of data |
| [![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/jkqtplotter_simpletest_symbols_and_styles_small.png)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_symbols_and_styles) | [Line Graph with Different Symbols and Line Styles](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_symbols_and_styles) | `JKQTPxyLineGraph`<br/>C++ vector of data |
| [![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/jkqtplotter_simpletest_symbols_and_errors_small.png)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_symbols_and_errors) | [Simple Line/Symbol Graph With Errorbars](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_symbols_and_errors) | `JKQTPxyLineErrorGraph`<br/>C-style arrays of data |
| [![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/jkqtplotter_simpletest_barchart_small.png)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_barchart) | [Simple Bar Charts](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_barchart) | `JKQTPbarVerticalGraph`<br/>C-style arrays of data |
| [![](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/JKQTPbarVerticalGraphStacked_small.png)](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_stackedbars) | [Stacked Bar Charts](https://github.com/jkriege2/JKQtPlotter/tree/master/test/jkqtplotter_simpletest_stackedbars) | `JKQTPbarVerticalStackableGraph`, `JKQTPbarHorizontalStackableGraph`<br/>C++-style vectors of data |

View File

@ -25,7 +25,7 @@
#include <QFontDatabase>
#include <typeinfo>
#include <QApplication>
//#define QColor2String(color) QString(jkqtp_rgbtostring((color).red(), (color).green(), (color).blue(), (color).alpha()).c_str())
//#define JKQTP_QColor2String(color) QString(jkqtp_rgbtostring((color).red(), (color).green(), (color).blue(), (color).alpha()).c_str())
QPainterPath makeHBracePath(double x, double ybrace, double width, double bw, double cubicshrink=0.5, double cubiccontrolfac=0.3) {
@ -3166,7 +3166,7 @@ JKQTmathText::~JKQTmathText() {
void JKQTmathText::loadSettings(QSettings& settings, QString group){
fontSize=settings.value(group+"font_size", fontSize).toDouble();
fontColor=QColor(settings.value(group+"font_color", QColor2String(fontColor)).toString());
fontColor=QColor(settings.value(group+"font_color", JKQTP_QColor2String(fontColor)).toString());
fontRoman=settings.value(group+"font_roman", fontRoman).toString();
fontSans=settings.value(group+"font_sans", fontSans).toString();
fontTypewriter=settings.value(group+"font_typewriter", fontTypewriter).toString();
@ -3209,7 +3209,7 @@ void JKQTmathText::loadSettings(QSettings& settings, QString group){
void JKQTmathText::saveSettings(QSettings& settings, QString group){
JKQTMTPROPERTYsave(settings, group, fontSize,"font_size");
if (fontColor!=def_fontColor) settings.setValue(group+"font_color", QColor2String(fontColor));
if (fontColor!=def_fontColor) settings.setValue(group+"font_color", JKQTP_QColor2String(fontColor));
JKQTMTPROPERTYsave(settings, group, fontRoman, "font_roman");
JKQTMTPROPERTYsave(settings, group, fontSans, "font_sans");
JKQTMTPROPERTYsave(settings, group, fontTypewriter, "font_typewriter");

View File

@ -275,12 +275,12 @@ void JKQTPcoordinateAxis::loadSettings(QSettings& settings, QString group) {
labelPosition=String2JKQTPlabelPosition(settings.value(group+axisPrefix+"label_position", JKQTPlabelPosition2String(labelPosition)).toString());
labelType=String2JKQTPCAlabelType(settings.value(group+axisPrefix+"label_type", JKQTPCAlabelType2String(labelType)).toString());
axisColor=QColor(settings.value(group+axisPrefix+"color", QColor2String(axisColor)).toString());
axisColor=QColor(settings.value(group+axisPrefix+"color", JKQTP_QColor2String(axisColor)).toString());
gridColor=QColor(settings.value(group+axisPrefix+"grid_color", QColor2String(gridColor)).toString());
minorGridColor=QColor(settings.value(group+axisPrefix+"minor_grid_color", QColor2String(minorGridColor)).toString());
gridStyle=String2QPenStyle(settings.value(group+axisPrefix+"grid_style", QPenStyle2String(gridStyle)).toString());
minorGridStyle=String2QPenStyle(settings.value(group+axisPrefix+"minor_grid_style", QPenStyle2String(minorGridStyle)).toString());
gridColor=QColor(settings.value(group+axisPrefix+"grid_color", JKQTP_QColor2String(gridColor)).toString());
minorGridColor=QColor(settings.value(group+axisPrefix+"minor_grid_color", JKQTP_QColor2String(minorGridColor)).toString());
gridStyle=JKQTP_String2QPenStyle(settings.value(group+axisPrefix+"grid_style", JKQTP_QPenStyle2String(gridStyle)).toString());
minorGridStyle=JKQTP_String2QPenStyle(settings.value(group+axisPrefix+"minor_grid_style", JKQTP_QPenStyle2String(minorGridStyle)).toString());
drawMode1=String2JKQTPCAdrawMode(settings.value(group+axisPrefix+"draw_mode1", JKQTPCAdrawMode2String(drawMode1)).toString());
drawMode2=String2JKQTPCAdrawMode(settings.value(group+axisPrefix+"draw_mode2", JKQTPCAdrawMode2String(drawMode2)).toString());
@ -334,14 +334,14 @@ void JKQTPcoordinateAxis::saveSettings(QSettings& settings, QString group) {
if (labelPosition!=def_labelPosition) settings.setValue(group+axisPrefix+"label_position", JKQTPlabelPosition2String(labelPosition));
if (labelType!=def_labelType) settings.setValue(group+axisPrefix+"label_type", JKQTPCAlabelType2String(labelType));
if (axisColor!=def_axisColor) settings.setValue(group+axisPrefix+"color", QColor2String(axisColor));
if (axisColor!=def_axisColor) settings.setValue(group+axisPrefix+"color", JKQTP_QColor2String(axisColor));
if (drawMode1!=def_drawMode1) settings.setValue(group+axisPrefix+"draw_mode1", JKQTPCAdrawMode2String(drawMode1));
if (drawMode2!=def_drawMode2) settings.setValue(group+axisPrefix+"draw_mode2", JKQTPCAdrawMode2String(drawMode2));
if (tickMode!=def_tickMode) settings.setValue(group+axisPrefix+"tick_mode", JKQTPLabelTickMode2String(tickMode));
if (gridColor!=def_gridColor) settings.setValue(group+axisPrefix+"grid_color", QColor2String(gridColor));
if (minorGridColor!=def_minorGridColor) settings.setValue(group+axisPrefix+"minor_grid_style", QPenStyle2String(minorGridStyle));
if (gridStyle!=def_gridStyle) settings.setValue(group+axisPrefix+"grid_color", QColor2String(gridColor));
if (minorGridStyle!=def_minorGridStyle) settings.setValue(group+axisPrefix+"minor_grid_style", QPenStyle2String(minorGridStyle));
if (gridColor!=def_gridColor) settings.setValue(group+axisPrefix+"grid_color", JKQTP_QColor2String(gridColor));
if (minorGridColor!=def_minorGridColor) settings.setValue(group+axisPrefix+"minor_grid_style", JKQTP_QPenStyle2String(minorGridStyle));
if (gridStyle!=def_gridStyle) settings.setValue(group+axisPrefix+"grid_color", JKQTP_QColor2String(gridColor));
if (minorGridStyle!=def_minorGridStyle) settings.setValue(group+axisPrefix+"minor_grid_style", JKQTP_QPenStyle2String(minorGridStyle));
}
double JKQTPcoordinateAxis::calcLinearTickSpacing() {

View File

@ -394,8 +394,8 @@ void JKQtBasePlotter::initSettings() {
for (int i=0; i<manyGraphsColorCount; i++) {
manyGraphsColor[i]=def_manyGraphsColor[i];
//std::cout<<manyGraphsColor[i].red()<<", "<<manyGraphsColor[i].green()<<", "<<manyGraphsColor[i].blue()<<" ";
//std::cout<<"init: manyGraphsColor["<<i<<"] = "<<QColor2String(manyGraphsColor[i]).toStdString()<<" = "<<manyGraphsColor[i].name().toStdString()<<std::endl;
//std::cout<<"init: def_manyGraphsColor["<<i<<"] = "<<QColor2String(def_manyGraphsColor[i]).toStdString()<<" = "<<def_manyGraphsColor[i].name().toStdString()<<std::endl;
//std::cout<<"init: manyGraphsColor["<<i<<"] = "<<JKQTP_QColor2String(manyGraphsColor[i]).toStdString()<<" = "<<manyGraphsColor[i].name().toStdString()<<std::endl;
//std::cout<<"init: def_manyGraphsColor["<<i<<"] = "<<JKQTP_QColor2String(def_manyGraphsColor[i]).toStdString()<<" = "<<def_manyGraphsColor[i].name().toStdString()<<std::endl;
}
def_manyGraphsStyle[0]=Qt::SolidLine;
def_manyGraphsStyle[1]=Qt::DashLine;
@ -484,10 +484,10 @@ void JKQtBasePlotter::saveSettings(QSettings& settings, QString group){
if (keyYMargin!=def_keyYMargin) settings.setValue(g+"key_ymargin", keyYMargin);
if (keyXSeparation!=def_keyXSeparation) settings.setValue(g+"key_xseparation", keyXSeparation);
if (keyYSeparation!=def_keyYSeparation) settings.setValue(g+"key_yseparation", keyYSeparation);
if (keyFrameColor!=def_keyFrameColor) settings.setValue(g+"key_frame_color", QColor2String(keyFrameColor));
if (keyFrameColor!=def_keyFrameColor) settings.setValue(g+"key_frame_color", JKQTP_QColor2String(keyFrameColor));
if (keyFrameWidth!=def_keyFrameWidth) settings.setValue(g+"key_frame_width", keyFrameWidth);
if (showKeyFrame!=def_showKeyFrame) settings.setValue(g+"show_key_frame", showKeyFrame);
if (keyBackgroundColor!=def_keyBackgroundColor) settings.setValue(g+"key_background_color", QColor2String(keyBackgroundColor));
if (keyBackgroundColor!=def_keyBackgroundColor) settings.setValue(g+"key_background_color", JKQTP_QColor2String(keyBackgroundColor));
if (showKey!=def_showKey) settings.setValue(g+"show_key", showKey);
if (keyPosition!=def_keyPosition) settings.setValue(g+"key_position", JKQTPkeyPosition2String(keyPosition));
if (keyLayout!=def_keyLayout) settings.setValue(g+"key_layout", JKQTPkeyLayout2String(keyLayout));
@ -496,10 +496,10 @@ void JKQtBasePlotter::saveSettings(QSettings& settings, QString group){
if (useAntiAliasingForGraphs!=def_useAntiAliasingForGraphs) settings.setValue(g+"use_antialiasing_for_graphs", useAntiAliasingForGraphs);
if (useAntiAliasingForText!=def_useAntiAliasingForText) settings.setValue(g+"use_antialiasing_for_text", useAntiAliasingForText);
if (backgroundColor!=def_backgroundColor) settings.setValue(g+"background_color", QColor2String(backgroundColor));
if (exportBackgroundColor!=def_exportBackgroundColor) settings.setValue(g+"exportBackgroundColor", QColor2String(exportBackgroundColor));
if (plotBackgroundColor!=def_plotBackgroundColor) settings.setValue(g+"plot_background_color", QColor2String(plotBackgroundColor));
if (graphColor!=def_graphColor) settings.setValue(g+"graph_color", QColor2String(graphColor));
if (backgroundColor!=def_backgroundColor) settings.setValue(g+"background_color", JKQTP_QColor2String(backgroundColor));
if (exportBackgroundColor!=def_exportBackgroundColor) settings.setValue(g+"exportBackgroundColor", JKQTP_QColor2String(exportBackgroundColor));
if (plotBackgroundColor!=def_plotBackgroundColor) settings.setValue(g+"plot_background_color", JKQTP_QColor2String(plotBackgroundColor));
if (graphColor!=def_graphColor) settings.setValue(g+"graph_color", JKQTP_QColor2String(graphColor));
if (graphWidth!=def_graphWidth) settings.setValue(g+"graph_linewidth", graphWidth);
@ -522,7 +522,7 @@ void JKQtBasePlotter::saveSettings(QSettings& settings, QString group){
}
if (palette_changed) {
for (int cnt=0; cnt<manyGraphsColorCount; cnt++) {
settings.setValue(QString(g+"manygraphscolor%1").arg(cnt), QColor2String(manyGraphsColor[cnt]));
settings.setValue(QString(g+"manygraphscolor%1").arg(cnt), JKQTP_QColor2String(manyGraphsColor[cnt]));
}
}
mathText.saveSettings(settings, g+"math_text.");
@ -619,10 +619,10 @@ void JKQtBasePlotter::loadSettings(QSettings& settings, QString group){
keyYMargin=settings.value(g+"key_ymargin", keyYMargin).toInt();
keyXSeparation=settings.value(g+"key_xseparation", keyXSeparation).toInt();
keyYSeparation=settings.value(g+"key_yseparation", keyYSeparation).toInt();
keyFrameColor=QColor(settings.value(g+"key_frame_color", QColor2String(keyFrameColor)).toString());
keyFrameColor=QColor(settings.value(g+"key_frame_color", JKQTP_QColor2String(keyFrameColor)).toString());
keyFrameWidth=settings.value(g+"key_frame_width", keyFrameWidth).toDouble();
showKeyFrame=settings.value(g+"show_key_frame", showKeyFrame).toBool();
keyBackgroundColor=QColor(settings.value(g+"key_background_color", QColor2String(keyBackgroundColor)).toString());
keyBackgroundColor=QColor(settings.value(g+"key_background_color", JKQTP_QColor2String(keyBackgroundColor)).toString());
showKey=settings.value(g+"show_key", showKey).toBool();
keyPosition=String2JKQTPkeyPosition(settings.value(g+"key_position", JKQTPkeyPosition2String(keyPosition)).toString());
keyLayout=JKQTPkeyLayoutOneColumn;
@ -634,8 +634,8 @@ void JKQtBasePlotter::loadSettings(QSettings& settings, QString group){
backgroundColor=QColor(settings.value(g+"background_color", def_backgroundColor).toString());
exportBackgroundColor=QColor(settings.value(g+"exportBackgroundColor", def_exportBackgroundColor).toString());
plotBackgroundColor=QColor(settings.value(g+"plot_background_color", QColor2String(plotBackgroundColor)).toString());
graphColor=QColor(settings.value(g+"graph_color", QColor2String(graphColor)).toString());
plotBackgroundColor=QColor(settings.value(g+"plot_background_color", JKQTP_QColor2String(plotBackgroundColor)).toString());
graphColor=QColor(settings.value(g+"graph_color", JKQTP_QColor2String(graphColor)).toString());
graphWidth=settings.value(g+"graph_linewidth", graphWidth).toDouble();
keyFont=settings.value(g+"key_fontname", keyFont).toString();
@ -666,8 +666,8 @@ void JKQtBasePlotter::loadSettings(QSettings& settings, QString group){
#endif
/*for (int i=0; i<manyGraphsColorCount; i++) {
std::cout<<"manyGraphsColor["<<i<<"] = "<<QColor2String(manyGraphsColor[i]).toStdString()<<std::endl;
std::cout<<"def_manyGraphsColor["<<i<<"] = "<<QColor2String(def_manyGraphsColor[i]).toStdString()<<std::endl;
std::cout<<"manyGraphsColor["<<i<<"] = "<<JKQTP_QColor2String(manyGraphsColor[i]).toStdString()<<std::endl;
std::cout<<"def_manyGraphsColor["<<i<<"] = "<<JKQTP_QColor2String(def_manyGraphsColor[i]).toStdString()<<std::endl;
}*/
xAxis->loadSettings(settings, g+"xaxis_");
yAxis->loadSettings(settings, g+"yaxis_");

View File

@ -230,7 +230,7 @@ void JKQTPboxplotVerticalGraph::draw(JKQTPEnhancedPainter& painter) {
if (percentile25Column>=0 && percentile75Column>=0) painter.drawRect(QRectF(xmi, p75, fabs(xma-xmi), fabs(p75-p25)));
if (medianColumn>=0) lines_p.append(QLineF(xmi+p.widthF()/2.0, median, xma-p.widthF()/2.0, median));
if (meanColumn>=0 && JKQTPIsOKFloat(mean)) {
plotSymbol(painter, x, mean, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->get_lineWidthMultiplier()), color, fillColor);
JKQTPplotSymbol(painter, x, mean, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->get_lineWidthMultiplier()), color, fillColor);
}
@ -688,7 +688,7 @@ void JKQTPboxplotHorizontalGraph::draw(JKQTPEnhancedPainter& painter) {
if (medianColumn>=0) lines_p.append(QLineF(median, ymi-p.widthF()/2.0, median, yma+p.widthF()/2.0));
if (meanColumn>=0 && JKQTPIsOKFloat(mean)) {
plotSymbol(painter, mean, y, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->get_lineWidthMultiplier()), color, fillColor);
JKQTPplotSymbol(painter, mean, y, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->get_lineWidthMultiplier()), color, fillColor);
}
//first=true;
@ -856,7 +856,7 @@ void JKQTPboxplotVerticalElement::draw(JKQTPEnhancedPainter& painter) {
if (drawMean) {
double mean=yAxis->x2p(this->mean);
plotSymbol(painter, x, mean, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->get_lineWidthMultiplier()), color, fillColor);
JKQTPplotSymbol(painter, x, mean, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->get_lineWidthMultiplier()), color, fillColor);
}
@ -1134,7 +1134,7 @@ void JKQTPboxplotHorizontalElement::draw(JKQTPEnhancedPainter& painter) {
if (drawMean) {
double mean=yAxis->x2p(this->mean);
plotSymbol(painter, mean, y, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->get_lineWidthMultiplier()), color, fillColor);
JKQTPplotSymbol(painter, mean, y, meanSymbol, parent->pt2px(painter, meanSymbolSize), parent->pt2px(painter, meanSymbolWidth*parent->get_lineWidthMultiplier()), color, fillColor);
}
}

View File

@ -343,9 +343,9 @@ void JKQTPxyLineGraph::draw(JKQTPEnhancedPainter& painter) {
QColor symbFillColor=fillColor;// symbColor.lighter();
if (drawSelectionLine && symbol!=JKQTPnoSymbol) {
plotSymbol(painter, x, y, JKQTPfilledCircle, parent->pt2px(painter, symbolSize*1.5), parent->pt2px(painter, symbolWidth*parent->get_lineWidthMultiplier()), penSelection.color(), penSelection.color());
JKQTPplotSymbol(painter, x, y, JKQTPfilledCircle, parent->pt2px(painter, symbolSize*1.5), parent->pt2px(painter, symbolWidth*parent->get_lineWidthMultiplier()), penSelection.color(), penSelection.color());
}
plotSymbol(painter, x, y, symbol, parent->pt2px(painter, symbolSize), parent->pt2px(painter, symbolWidth*parent->get_lineWidthMultiplier()), symbColor, symbFillColor);
JKQTPplotSymbol(painter, x, y, symbol, parent->pt2px(painter, symbolSize), parent->pt2px(painter, symbolWidth*parent->get_lineWidthMultiplier()), symbColor, symbFillColor);
/*if (drawLine && first) {
double xl1=xold;
double yl1=yold;
@ -399,7 +399,7 @@ void JKQTPxyLineGraph::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect
painter.setPen(p);
int y=rect.top()+rect.height()/2.0;
if (drawLine) painter.drawLine(rect.left(), y, rect.right(), y);
plotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, symbol, symbolSize, symbolWidth, getKeyLabelColor(), fillColor);
JKQTPplotSymbol(painter, rect.left()+rect.width()/2.0, rect.top()+rect.height()/2.0, symbol, symbolSize, symbolWidth, getKeyLabelColor(), fillColor);
painter.restore();
}
@ -2085,9 +2085,9 @@ void JKQTPxyParametrizedScatterGraph::draw(JKQTPEnhancedPainter &painter)
}
if (drawSelectionLine && symbol!=JKQTPnoSymbol && symbolColumn<0) {
plotSymbol(painter, x, y, JKQTPfilledCircle,symbSize, parent->pt2px(painter, symbolWidth*parent->get_lineWidthMultiplier()), penSelection.color(), penSelection.color());
JKQTPplotSymbol(painter, x, y, JKQTPfilledCircle,symbSize, parent->pt2px(painter, symbolWidth*parent->get_lineWidthMultiplier()), penSelection.color(), penSelection.color());
} else {
plotSymbol(painter, x, y, getLocalSymbolType(i), symbSize, parent->pt2px(painter, symbolWidth*parent->get_lineWidthMultiplier()), symbColor, symbFillColor);
JKQTPplotSymbol(painter, x, y, getLocalSymbolType(i), symbSize, parent->pt2px(painter, symbolWidth*parent->get_lineWidthMultiplier()), symbColor, symbFillColor);
}

View File

@ -517,7 +517,7 @@ void JKQTPxFunctionLineGraph::draw(JKQTPEnhancedPainter& painter) {
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) {
double x=xAxis->x2p(xv);
double y=yAxis->x2p(yv);
plotSymbol(painter, x, y, JKQTPcross, 6,1*parent->get_lineWidthMultiplier(), c, QColor(Qt::transparent));
JKQTPplotSymbol(painter, x, y, JKQTPcross, 6,1*parent->get_lineWidthMultiplier(), c, QColor(Qt::transparent));
}
d=d->next;
}
@ -693,7 +693,7 @@ void JKQTPyFunctionLineGraph::draw(JKQTPEnhancedPainter& painter) {
if (JKQTPIsOKFloat(xv) && JKQTPIsOKFloat(yv)) {
double x=xAxis->x2p(xv);
double y=yAxis->x2p(yv);
plotSymbol(painter, x, y, JKQTPcross, 6, 1*parent->get_lineWidthMultiplier(), c, QColor(Qt::transparent));
JKQTPplotSymbol(painter, x, y, JKQTPcross, 6, 1*parent->get_lineWidthMultiplier(), c, QColor(Qt::transparent));
}
d=d->next;
}

View File

@ -618,7 +618,7 @@ JKQTPgeoEllipse::JKQTPgeoEllipse(JKQtPlotter* parent, double x, double y, double
void JKQTPgeoEllipse::draw(JKQTPEnhancedPainter& painter) {
QPainterPath rect;
rect=transformToLinePath(draw_ellipse(x,y,width/2.0, height/2.0,0,360,alpha, controlPoints));
rect=transformToLinePath(JKQTPdrawEllipse(x,y,width/2.0, height/2.0,0,360,alpha, controlPoints));
rect.closeSubpath();
@ -660,7 +660,7 @@ JKQTPgeoArc::JKQTPgeoArc(JKQtPlotter* parent, double x, double y, double width,
void JKQTPgeoArc::draw(JKQTPEnhancedPainter& painter) {
QPainterPath rect;
rect=transformToLinePath(draw_ellipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
rect=transformToLinePath(JKQTPdrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
painter.save();
painter.setPen(getPen(painter));
@ -671,7 +671,7 @@ void JKQTPgeoArc::draw(JKQTPEnhancedPainter& painter) {
bool JKQTPgeoArc::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
QPolygonF rect;
rect=QPolygonF(draw_ellipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
rect=QPolygonF(JKQTPdrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
minx=rect.boundingRect().left();
maxx=rect.boundingRect().right();
if (minx>maxx) std::swap(minx, maxx);
@ -684,7 +684,7 @@ bool JKQTPgeoArc::getXMinMax(double& minx, double& maxx, double& smallestGreater
bool JKQTPgeoArc::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
QPolygonF rect;
rect=QPolygonF(draw_ellipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
rect=QPolygonF(JKQTPdrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
miny=rect.boundingRect().bottom();
maxy=rect.boundingRect().top();
if (miny>maxy) std::swap(miny, maxy);
@ -717,7 +717,7 @@ JKQTPgeoPie::JKQTPgeoPie(JKQtPlotter* parent, double x, double y, double width,
void JKQTPgeoPie::draw(JKQTPEnhancedPainter& painter) {
QPainterPath rect;
rect=transformToLinePath(draw_ellipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
rect=transformToLinePath(JKQTPdrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
rect.lineTo(transform(x,y));
rect.closeSubpath();
@ -731,7 +731,7 @@ void JKQTPgeoPie::draw(JKQTPEnhancedPainter& painter) {
bool JKQTPgeoPie::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
QPolygonF rect;
rect=QPolygonF(draw_ellipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
rect=QPolygonF(JKQTPdrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
rect.append(QPointF(x,y));
minx=rect.boundingRect().left();
maxx=rect.boundingRect().right();
@ -745,7 +745,7 @@ bool JKQTPgeoPie::getXMinMax(double& minx, double& maxx, double& smallestGreater
bool JKQTPgeoPie::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
QPolygonF rect;
rect=QPolygonF(draw_ellipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
rect=QPolygonF(JKQTPdrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
rect.append(QPointF(x,y));
miny=rect.boundingRect().bottom();
maxy=rect.boundingRect().top();
@ -775,7 +775,7 @@ JKQTPgeoChord::JKQTPgeoChord(JKQtPlotter* parent, double x, double y, double wid
void JKQTPgeoChord::draw(JKQTPEnhancedPainter& painter) {
QPainterPath rect;
rect=transformToLinePath(draw_ellipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
rect=transformToLinePath(JKQTPdrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
rect.closeSubpath();
@ -788,7 +788,7 @@ void JKQTPgeoChord::draw(JKQTPEnhancedPainter& painter) {
bool JKQTPgeoChord::getXMinMax(double& minx, double& maxx, double& smallestGreaterZero) {
QPolygonF rect;
rect=QPolygonF(draw_ellipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
rect=QPolygonF(JKQTPdrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
minx=rect.boundingRect().left();
maxx=rect.boundingRect().right();
if (minx>maxx) std::swap(minx, maxx);
@ -800,7 +800,7 @@ bool JKQTPgeoChord::getXMinMax(double& minx, double& maxx, double& smallestGreat
bool JKQTPgeoChord::getYMinMax(double& miny, double& maxy, double& smallestGreaterZero) {
QPolygonF rect;
rect=QPolygonF(draw_ellipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
rect=QPolygonF(JKQTPdrawEllipse(x,y,width/2.0, height/2.0,angleStart,angleStop,alpha, controlPoints));
miny=rect.boundingRect().bottom();
maxy=rect.boundingRect().top();
if (miny>maxy) std::swap(miny, maxy);

View File

@ -1371,7 +1371,7 @@ JKQTPOverlayImageEnhanced::JKQTPOverlayImageEnhanced(JKQtPlotter *parent):
}
void JKQTPOverlayImageEnhanced::drawKeyMarker(JKQTPEnhancedPainter& painter, QRectF& rect) {
if (drawAsRectangles) JKQTPOverlayImage::drawKeyMarker(painter, rect);
else plotSymbol(painter, rect.center().x(), rect.center().y(), symbol, qMin(rect.width(), rect.height()), parent->pt2px(painter, symbolWidth*parent->get_lineWidthMultiplier()), trueColor, trueColor.lighter());
else JKQTPplotSymbol(painter, rect.center().x(), rect.center().y(), symbol, qMin(rect.width(), rect.height()), parent->pt2px(painter, symbolWidth*parent->get_lineWidthMultiplier()), trueColor, trueColor.lighter());
}
void JKQTPOverlayImageEnhanced::draw(JKQTPEnhancedPainter& painter) {
@ -1406,7 +1406,7 @@ void JKQTPOverlayImageEnhanced::draw(JKQTPEnhancedPainter& painter) {
} else {
QPointF p=(p1+p2)/2.0;
if (data[ix+iy*Nx]) {
plotSymbol(painter, p.x(), p.y(), symbol, fabs(p2.x()-p1.x())*symbolSizeFactor, parent->pt2px(painter, symbolWidth*parent->get_lineWidthMultiplier()), trueColor, trueColor.lighter());
JKQTPplotSymbol(painter, p.x(), p.y(), symbol, fabs(p2.x()-p1.x())*symbolSizeFactor, parent->pt2px(painter, symbolWidth*parent->get_lineWidthMultiplier()), trueColor, trueColor.lighter());
}
}
}

View File

@ -157,7 +157,7 @@ void JKQtPlotter::loadSettings(QSettings& settings, QString group) {
set_toolbarIconSize(settings.value(group+"toolbar_icon_size", toolbarIconSize).toInt());
mousePositionTemplate=settings.value(group+"mouse_position_template", mousePositionTemplate).toString();
userActionColor=QColor(settings.value(group+"zoomrect_color", QColor2String(userActionColor)).toString());
userActionColor=QColor(settings.value(group+"zoomrect_color", JKQTP_QColor2String(userActionColor)).toString());
update_plot();
}
@ -165,7 +165,7 @@ void JKQtPlotter::loadSettings(QSettings& settings, QString group) {
void JKQtPlotter::saveSettings(QSettings& settings, QString group) {
plotter->saveSettings(settings, group);
if (userActionColor!=def_userActionColor) settings.setValue(group+"zoomrect_color", QColor2String(userActionColor));
if (userActionColor!=def_userActionColor) settings.setValue(group+"zoomrect_color", JKQTP_QColor2String(userActionColor));
if (toolbarIconSize!=def_toolbarIconSize) settings.setValue(group+"toolbar_icon_size", toolbarIconSize);
if (mousePositionTemplate!=def_mousePositionTemplate) settings.setValue(group+"mouse_position_template", mousePositionTemplate);
}

View File

@ -266,12 +266,12 @@ std::string jkqtp_tolower(const std::string& s){
}
void plotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor) {
void JKQTPplotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor) {
JKQTPEnhancedPainter p(&paintDevice);
plotSymbol(p, x, y, symbol, size, symbolLineWidth, color, fillColor);
JKQTPplotSymbol(p, x, y, symbol, size, symbolLineWidth, color, fillColor);
}
void plotSymbol(JKQTPEnhancedPainter& painter, double x, double y, JKQTPgraphSymbols symbol, double symbolSize, double symbolLineWidth, QColor color, QColor fillColor) {
void JKQTPplotSymbol(JKQTPEnhancedPainter& painter, double x, double y, JKQTPgraphSymbols symbol, double symbolSize, double symbolLineWidth, QColor color, QColor fillColor) {
painter.save();
QPen p=painter.pen();
p.setColor(color);
@ -353,6 +353,28 @@ void plotSymbol(JKQTPEnhancedPainter& painter, double x, double y, JKQTPgraphSym
painter.drawRect(rectangle);
}
break;
case JKQTPrectCross:{
painter.setBrush(QColor(Qt::transparent));
QPainterPath path;
path.moveTo(x-w2,y-w2);
path.lineTo(x+w2,y+w2);
path.moveTo(x-w2,y+w2);
path.lineTo(x+w2,y-w2);
painter.drawPath(path);
QRectF rectangle(x-w2, y-w2, w, w);
painter.drawRect(rectangle);
}
break;
case JKQTPrectPlus:{
painter.setBrush(QColor(Qt::transparent));
QVector<QLineF> lines;
lines<<QLineF(x,y-w2,x,y+w2);
lines<<QLineF(x-w2,y,x+w2,y);
painter.drawLines(lines);
QRectF rectangle(x-w2, y-w2, w, w);
painter.drawRect(rectangle);
}
break;
case JKQTPfilledRect:{
painter.setBrush(b);
QRectF rectangle(x-w2, y-w2, w, w);
@ -445,7 +467,7 @@ void plotSymbol(JKQTPEnhancedPainter& painter, double x, double y, JKQTPgraphSym
QVector<QPointF> draw_ellipse(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<QPointF> 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<QPointF> result;
double start=angle_start*M_PI/180.0;
double stop=angle_end*M_PI/180.0;
@ -472,7 +494,7 @@ QVector<QPointF> draw_ellipse(double x, double y, double a, double b, double ang
QString QPenStyle2String(Qt::PenStyle style) {
QString JKQTP_QPenStyle2String(Qt::PenStyle style) {
switch(style) {
case Qt::DashLine: return "dash";
case Qt::DotLine: return "dot";
@ -483,7 +505,7 @@ QString QPenStyle2String(Qt::PenStyle style) {
}
}
Qt::PenStyle String2QPenStyle(QString style) {
Qt::PenStyle JKQTP_String2QPenStyle(QString style) {
QString s=style.toLower().trimmed();
if (s=="dash" || s=="--") return Qt::DashLine;
if (s=="dot" || s=="." || s=="..") return Qt::DotLine;
@ -493,7 +515,7 @@ Qt::PenStyle String2QPenStyle(QString style) {
return Qt::SolidLine;
}
QString QBrushStyle2String(Qt::BrushStyle style) {
QString JKQTP_QBrushStyle2String(Qt::BrushStyle style) {
switch(style) {
case Qt::NoBrush: return "none";
@ -518,7 +540,7 @@ QString QBrushStyle2String(Qt::BrushStyle style) {
}
}
Qt::BrushStyle String2QBrushStyle(QString style) {
Qt::BrushStyle JKQTP_String2QBrushStyle(QString style) {
QString s=style.toLower().trimmed();
if (s=="none") return Qt::NoBrush;
if (s=="d1") return Qt::Dense1Pattern;
@ -740,6 +762,8 @@ QString JKQTPgraphSymbols2String(JKQTPgraphSymbols pos) {
case JKQTPpentagon: return "symbol_pentagon";
case JKQTPasterisc: return "symbol_asterisc";
case JKQTPfilledPentagon: return "symbol_filled_pentagon";
case JKQTPrectCross: return "symbol_rect_cross";
case JKQTPrectPlus: return "symbol_rect_plus";
case JKQTPnoSymbol: return "none";
}
return "";
@ -766,6 +790,8 @@ QString JKQTPgraphSymbols2NameString(JKQTPgraphSymbols pos) {
case JKQTPfilledPentagon: return QObject::tr("filled pentagon");
case JKQTPtarget: return QObject::tr("target");
case JKQTPasterisc: return QObject::tr("asterisc");
case JKQTPrectCross: return QObject::tr("square with cross");
case JKQTPrectPlus: return QObject::tr("square with plus");
case JKQTPnoSymbol: return QObject::tr("none");
}
return "";
@ -791,6 +817,8 @@ JKQTPgraphSymbols String2JKQTPgraphSymbols(QString pos) {
if (s=="symbol_pentagon"||s=="pentagon"||s=="p") return JKQTPpentagon;
if (s=="symbol_filled_pentagon"||s=="filled_pentagon"||s=="fp") return JKQTPfilledPentagon;
if (s=="symbol_asterisc"||s=="asterisc"||s=="*") return JKQTPasterisc;
if (s=="symbol_rect_cross"||s=="rect_cross"||s=="rx") return JKQTPrectCross;
if (s=="symbol_rect_plus"||s=="rect_plus"||s=="r+") return JKQTPrectPlus;
return JKQTPnoSymbol;
}
@ -799,26 +827,9 @@ JKQTPSymbolComboBox::JKQTPSymbolComboBox(QWidget *parent):
{
clear();
setEditable(false);
addSymbol(JKQTPnoSymbol, tr("none"));
addSymbol(JKQTPdot, tr("dot"));
addSymbol(JKQTPcross, tr("cross"));
addSymbol(JKQTPplus, tr("plus"));
addSymbol(JKQTPasterisc, tr("asterisc"));
addSymbol(JKQTPcircle, tr("circle"));
addSymbol(JKQTPfilledCircle, tr("filled circle"));
addSymbol(JKQTPrect, tr("rect"));
addSymbol(JKQTPfilledRect, tr("filled rect"));
addSymbol(JKQTPtriangle, tr("triangle"));
addSymbol(JKQTPfilledTriangle, tr("filled triangle"));
addSymbol(JKQTPdownTriangle, tr("down triangle"));
addSymbol(JKQTPfilledDownTriangle, tr("filled down triangle"));
addSymbol(JKQTPdiamond, tr("diamond"));
addSymbol(JKQTPfilledDiamond, tr("filled diamond"));
addSymbol(JKQTPstar, tr("star"));
addSymbol(JKQTPfilledStar, tr("filled star"));
addSymbol(JKQTPpentagon, tr("pentagon"));
addSymbol(JKQTPfilledPentagon, tr("filled pentagon"));
addSymbol(JKQTPtarget, tr("target"));
for (int i=0; i<=JKQTPmaxSymbolID; i++) {
addSymbol(static_cast<JKQTPgraphSymbols>(i), JKQTPgraphSymbols2NameString(static_cast<JKQTPgraphSymbols>(i)));
}
setCurrentIndex(0);
}
@ -846,7 +857,7 @@ void JKQTPSymbolComboBox::addSymbol(JKQTPgraphSymbols symbol, const QString &nam
p.begin(&pix);
p.setRenderHint(JKQTPEnhancedPainter::Antialiasing);
p.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing);
plotSymbol(p, 6,6,symbol,10,1,QColor("blue"), QColor("blue").lighter());
JKQTPplotSymbol(p, 6,6,symbol,10,1,QColor("blue"), QColor("blue").lighter());
p.end();
addItem(QIcon(pix), name, JKQTPgraphSymbols2String(symbol));
}
@ -920,7 +931,7 @@ void JKQTPLinePlotStyleComboBox::addSymbol(JKQTPgraphSymbols symbol, bool line,
p.begin(&pix);
p.setRenderHint(JKQTPEnhancedPainter::Antialiasing);
p.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing);
plotSymbol(p, 6,6,symbol,7,1,QColor("blue"), QColor("blue").lighter());
JKQTPplotSymbol(p, 6,6,symbol,7,1,QColor("blue"), QColor("blue").lighter());
p.setPen(QColor("blue"));
if (line) p.drawLine(0,6,12,6);
p.end();
@ -1852,7 +1863,7 @@ void JKQTPLinePlotStyleWithSymbolSizeComboBox::addSymbol(JKQTPgraphSymbols symbo
p.begin(&pix);
p.setRenderHint(JKQTPEnhancedPainter::Antialiasing);
p.setRenderHint(JKQTPEnhancedPainter::TextAntialiasing);
plotSymbol(p, double(pixSize)/2.0,double(pixSize)/2.0,symbol,symbolSize,1,QColor("blue"), QColor("blue").lighter());
JKQTPplotSymbol(p, double(pixSize)/2.0,double(pixSize)/2.0,symbol,symbolSize,1,QColor("blue"), QColor("blue").lighter());
p.setPen(QColor("blue"));
if (line) p.drawLine(QLineF(0,double(pixSize)/2.0,pixSize,double(pixSize)/2.0));
p.end();

View File

@ -447,26 +447,26 @@ class JKQTPEnhancedPainter; // forward
*
* This returns a QString which contains the name of named colors and the RGBA values in a QT readable form othertwise.
*/
#define QColor2String(color) QString(jkqtp_rgbtostring(static_cast<unsigned char>((color).red()), static_cast<unsigned char>((color).green()), static_cast<unsigned char>((color).blue()), static_cast<unsigned char>((color).alpha())).c_str())
#define JKQTP_QColor2String(color) QString(jkqtp_rgbtostring(static_cast<unsigned char>((color).red()), static_cast<unsigned char>((color).green()), static_cast<unsigned char>((color).blue()), static_cast<unsigned char>((color).alpha())).c_str())
/** \brief converts a QT::PenStyle into a string
* \ingroup jkqtptools
*/
LIB_EXPORT QString QPenStyle2String(Qt::PenStyle style);
LIB_EXPORT QString JKQTP_QPenStyle2String(Qt::PenStyle style);
/** \brief converts a QString into a Qt::PenStyle
* \ingroup jkqtptools
*/
LIB_EXPORT Qt::PenStyle String2QPenStyle(QString style);
LIB_EXPORT Qt::PenStyle JKQTP_String2QPenStyle(QString style);
/** \brief converts a QT::BrushStyle into a string
* \ingroup jkqtptools
*/
LIB_EXPORT QString QBrushStyle2String(Qt::BrushStyle style);
LIB_EXPORT QString JKQTP_QBrushStyle2String(Qt::BrushStyle style);
/** \brief converts a QString into a Qt::BrushStyle
* \ingroup jkqtptools
*/
LIB_EXPORT Qt::BrushStyle String2QBrushStyle(QString style);
LIB_EXPORT Qt::BrushStyle JKQTP_String2QBrushStyle(QString style);
class JKQtBasePlotter; // forward declaration
@ -824,8 +824,10 @@ enum JKQTPgraphSymbols {
JKQTPasterisc=18, /*!< \brief an asterisc star '*' */
JKQTPtarget=19, /*!< \brief a target symbol (circle with cross) */
JKQTPrectCross=20, /*!< \brief a square symbol with a cross inside */
JKQTPrectPlus=21, /*!< \brief a square symbol with a plus inside */
JKQTPmaxSymbolID=JKQTPtarget
JKQTPmaxSymbolID=JKQTPrectPlus
};
/** \brief converts a JKQTPgraphSymbols variable into a identifier string
@ -920,7 +922,7 @@ class LIB_EXPORT JKQTPLinePlotStyleWithSymbolSizeComboBox: public QComboBox {
\param color color of the symbol lines
\param fillColor color of the symbol filling
*/
LIB_EXPORT void plotSymbol(JKQTPEnhancedPainter& painter, double x, double y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
LIB_EXPORT void JKQTPplotSymbol(JKQTPEnhancedPainter& painter, double x, double y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
/*! \brief plot the specified symbol at pixel position x,y
\ingroup jkqtptools
@ -934,7 +936,7 @@ LIB_EXPORT void plotSymbol(JKQTPEnhancedPainter& painter, double x, double y, JK
\param color color of the symbol lines
\param fillColor color of the symbol filling
*/
LIB_EXPORT void plotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
LIB_EXPORT void JKQTPplotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
/*! \brief plot an arrow between positions (x1,y1) and (x2,y2)
@ -951,7 +953,7 @@ LIB_EXPORT void plotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPg
\param color color of the symbol lines
\param fillColor color of the symbol filling
*/
//LIB_EXPORT void plotArrow(JKQTPEnhancedPainter& painter, int x, int y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
//LIB_EXPORT void JKQTPplotArrow(JKQTPEnhancedPainter& painter, int x, int y, JKQTPgraphSymbols symbol, double size, double symbolLineWidth, QColor color, QColor fillColor);
/*! \brief draw an ellipse without setting pen or brush, or saving the painter!
@ -971,7 +973,7 @@ LIB_EXPORT void plotSymbol(QPaintDevice& paintDevice, double x, double y, JKQTPg
\note all angles are given in degrees [0..360]
*/
LIB_EXPORT QVector<QPointF> draw_ellipse(double x, double y, double a, double b, double angle_start=0, double angle_end=360, double alpha=0, int controlPoints=180, QPointF* x_start=nullptr, QPointF* x_end=nullptr);
LIB_EXPORT QVector<QPointF> JKQTPdrawEllipse(double x, double y, double a, double b, double angle_start=0, double angle_end=360, double alpha=0, int controlPoints=180, QPointF* x_start=nullptr, QPointF* x_end=nullptr);
#include <QDoubleSpinBox>

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -230,10 +230,10 @@ TestWidgetGraphs::TestWidgetGraphs(QWidget *parent) :
layout->addWidget(chkInvertY);
layout->addWidget(chkInvertX);
layout->addWidget(chkInvertY);
JKQTPSymbolComboBox* cmbPlotSymbol=new JKQTPSymbolComboBox(this);
cmbPlotSymbol->setSymbol(JKQTPplus);
connect(cmbPlotSymbol, SIGNAL(currentIndexChanged(int)), this, SLOT(setESSymbol(int)));
layout->addWidget(cmbPlotSymbol);
JKQTPSymbolComboBox* cmbJKQTPplotSymbol=new JKQTPSymbolComboBox(this);
cmbJKQTPplotSymbol->setSymbol(JKQTPplus);
connect(cmbJKQTPplotSymbol, SIGNAL(currentIndexChanged(int)), this, SLOT(setESSymbol(int)));
layout->addWidget(cmbJKQTPplotSymbol);
JKQTPerrorPlotstyleComboBox* cmbErrors=new JKQTPerrorPlotstyleComboBox(this);
cmbErrors->setCurrentErrorStyle(JKQTPerrorBars);
connect(cmbErrors, SIGNAL(currentIndexChanged(int)), this, SLOT(setErrorStyle(int)));

View File

@ -3,7 +3,7 @@
# JKQtPlotter
## Simple math image plot
This project (see `./test/jkqtplotter_simpletest_imageplot_modifier/`) creates a JKQtPlotter widget (as a new window) and adds a color-coded image plot of a mathematical function (here `sin(r)`). Then a second image (linearly scaling from 1 in the center to 0 at the borders) is used to modify the first image. The modification can
This project (see `./test/jkqtplotter_simpletest_imageplot_modifier/`) creates a JKQtPlotter widget (as a new window) and adds a color-coded image plot of a mathematical function (here `sin(r)`). Then a second image (linearly scaling from 1 in the center to 0 at the borders) is used to modify the first image. The modification can alter several properties of the original image, like its saturation, its transparency (alpha) ...
The soruce code of the main application is (see `./test/jkqtplotter_simpletest_imageplot_modifier/jkqtplotter_simpletest_imageplot_modifier.cpp`):
```c++

View File

@ -0,0 +1,48 @@
[Back to JKQTPlotter main page](https://github.com/jkriege2/JKQtPlotter/)
# JKQtPlotter
## Line Graph with Different Symbols and Line Styles
This project (see `./test/jkqtplotter_simpletest_symbols_and_styles/`) simply creates a JKQtPlotter widget (as a new window) and adds a single line-graph (a sine-wave). Data is initialized from two QVector<double> objects.
The source code of the main application can be found in [`jkqtplotter_simpletest_symbols_and_styles.cpp`](https://github.com/jkriege2/JKQtPlotter/blob/master/jkqtplotter_simpletest_symbols_and_styles/jkqtplotter_simpletest_symbols_and_styles.cpp). Mainly several graphs are generated in a loop and then different symbol and line styles are applied to the graph (set by `graph->set_symbol()` for the symbol and `graph->set_style()` for the line style). The colors are set automtically from an internal default palette. The main loop looks like this:
```c++
QVector<Qt::PenStyle> pens {Qt::NoPen, Qt::SolidLine, Qt::DashLine, Qt::DotLine, Qt::DashDotLine, Qt::DashDotDotLine };
int ipen=0;
for (int symbolID=0; symbolID<=JKQTPmaxSymbolID; symbolID++) {
// generate some plot data
QVector<double> Y;
for (auto& xx: X) {
Y<<sin(xx)+static_cast<double>(symbolID)*1.5;
}
JKQTPxyLineGraph* graph=new JKQTPxyLineGraph(&plot);
// copy data into datastore and immediately set the yColumn
graph->set_xColumn(columnX);
graph->set_yColumn(ds->addCopiedColumn(Y, "y"+QString::number(symbolID)));
// set symbol + pen style and color
graph->set_symbol(static_cast<JKQTPgraphSymbols>(symbolID));
graph->set_style(pens[ipen]);
// graph title is made from symbol+penstyle
graph->set_title(JKQTPgraphSymbols2NameString(static_cast<JKQTPgraphSymbols>(graph->get_symbol()))+QString(", ")+JKQTP_QPenStyle2String(graph->get_style()));
// add the graph to the plot, so it is actually displayed
plot.addGraph(graph);
ipen++;
if (ipen>=pens.size()) ipen=0;
}
```
The result looks like this:
![jkqtplotter_simpletest_symbols_and_styles](https://raw.githubusercontent.com/jkriege2/JKQtPlotter/master/screenshots/jkqtplotter_simpletest_symbols_and_styles.png)
[Back to JKQTPlotter main page](https://github.com/jkriege2/JKQtPlotter/)

View File

@ -0,0 +1,65 @@
#include <QApplication>
#include "jkqtplotter/jkqtplotter.h"
#include "jkqtplottertools/jkqtptools.h"
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
// 1. create a plotter window and get a pointer to the internal datastore (for convenience)
JKQtPlotter plot;
JKQTPdatastore* ds=plot.getDatastore();
// 2. now we create data a vector of x-values for a simple plot (a sine curve)
QVector<double> X;
const int Ndata=10; // number of plot points in each curve
for (int i=0; i<Ndata; i++) {
const double x=double(i)/double(Ndata)*2.0*M_PI;
X<<x;
}
// and copy it to the datastore
size_t columnX=ds->addCopiedColumn(X, "x");
// 3. now we make several plots with different symbol styles and line-styles
// for that we iterate over every symbol style and at the same time over
// pen styles from the vector pens
QVector<Qt::PenStyle> pens {Qt::NoPen, Qt::SolidLine, Qt::DashLine, Qt::DotLine, Qt::DashDotLine, Qt::DashDotDotLine };
int ipen=0;
for (int symbolID=0; symbolID<=JKQTPmaxSymbolID; symbolID++) {
// generate some plot data
QVector<double> Y;
for (auto& xx: X) {
Y<<sin(xx)+static_cast<double>(symbolID)*1.5;
}
JKQTPxyLineGraph* graph=new JKQTPxyLineGraph(&plot);
// copy data into datastore and immediately set the yColumn
graph->set_xColumn(columnX);
graph->set_yColumn(ds->addCopiedColumn(Y, "y"+QString::number(symbolID)));
// set symbol + pen style and color
graph->set_symbol(static_cast<JKQTPgraphSymbols>(symbolID));
graph->set_style(pens[ipen]);
// graph title is made from symbol+penstyle
graph->set_title(JKQTPgraphSymbols2NameString(static_cast<JKQTPgraphSymbols>(graph->get_symbol()))+QString(", ")+JKQTP_QPenStyle2String(graph->get_style()));
// add the graph to the plot, so it is actually displayed
plot.addGraph(graph);
ipen++;
if (ipen>=pens.size()) ipen=0;
}
// 4. autoscale the plot so the graph is contained
plot.zoomToFit();
// 5. show plotter and make it a decent size
plot.show();
plot.resize(800,600);
return app.exec();
}

View File

@ -0,0 +1,16 @@
# source code for this simple demo
SOURCES = jkqtplotter_simpletest_symbols_and_styles.cpp
# configure Qt
CONFIG += qt
QT += core gui svg
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
# output executable name
TARGET = jkqtplotter_simpletest_symbols_and_styles
# include JKQtPlotter source code
include(../../lib/jkqtplotter.pri)
# here you can activate some debug options
#DEFINES += SHOW_JKQTPLOTTER_DEBUG
#DEFINES += JKQTBP_AUTOTIMER