2015-07-11 18:56:02 +08:00
|
|
|
/*
|
2022-07-19 19:40:43 +08:00
|
|
|
Copyright (c) 2008-2022 Jan W. Krieger (<jan@jkrieger.de>)
|
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-05-30 04:40:02 +08:00
|
|
|
#include "jkqtplotter/jkqtptools.h"
|
|
|
|
#include "jkqtcommon/jkqtpenhancedpainter.h"
|
2015-07-11 18:56:02 +08:00
|
|
|
#include <cmath>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QSet>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QClipboard>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QLocale>
|
2015-09-09 15:31:09 +08:00
|
|
|
#include <cstring>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <locale>
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-02-08 00:24:46 +08:00
|
|
|
|
2015-07-11 18:56:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
QString JKQTPCADrawMode2String(JKQTPCADrawMode pos) {
|
2022-09-24 02:43:53 +08:00
|
|
|
if (pos==JKQTPCADMnone) return "none";
|
|
|
|
if (pos==JKQTPCADMcomplete) return "complete";
|
|
|
|
if (pos==JKQTPCADMcompleteMaxArrow) return "complete+max_filled_arrow";
|
|
|
|
if (pos==JKQTPCADMcompleteMinMaxArrow) return "complete+max_filled_arrow+min_filled_arrow";
|
|
|
|
|
|
|
|
QString s="";
|
|
|
|
if (pos.testFlag(JKQTPCADMLine)) JKQTPExtendString(s, "+", "line");
|
|
|
|
if (pos.testFlag(JKQTPCADMMaxArrow)) JKQTPExtendString(s, "+", "max_arrow");
|
|
|
|
if (pos.testFlag(JKQTPCADMMaxFilledArrow)) JKQTPExtendString(s, "+", "max_filled_arrow");
|
|
|
|
if (pos.testFlag(JKQTPCADMMinArrow)) JKQTPExtendString(s, "+", "min_arrow");
|
|
|
|
if (pos.testFlag(JKQTPCADMMinFilledArrow)) JKQTPExtendString(s, "+", "min_filled_arrow");
|
|
|
|
if (pos.testFlag(JKQTPCADMTicks)) JKQTPExtendString(s, "+", "ticks");
|
|
|
|
if (pos.testFlag(JKQTPCADMTickLabels)) JKQTPExtendString(s, "+", "labels");
|
|
|
|
if (pos.testFlag(JKQTPCADMAxisLabel)) JKQTPExtendString(s, "+", "axislabel");
|
|
|
|
|
|
|
|
return s;
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-02-08 00:24:46 +08:00
|
|
|
|
|
|
|
|
2019-01-26 20:00:40 +08:00
|
|
|
JKQTPCADrawMode String2JKQTPCADrawMode(const QString& pos) {
|
2022-09-24 02:43:53 +08:00
|
|
|
QStringList slist=pos.trimmed().toLower().split('+');
|
|
|
|
|
|
|
|
JKQTPCADrawMode res=JKQTPCADMnone;
|
|
|
|
for (const QString& s: slist) {
|
|
|
|
if (s=="all" || s=="complete") res |= JKQTPCADMcomplete;
|
|
|
|
if (s=="labels" || s=="ticklabels") res |= JKQTPCADMTickLabels;
|
|
|
|
if (s=="axislabel") res |= JKQTPCADMAxisLabel;
|
|
|
|
if (s=="ticks") res |= JKQTPCADMTicks;
|
|
|
|
if (s=="line") res |= JKQTPCADMLine;
|
|
|
|
if (s=="max_arrow"||s=="maxarrow") res |= JKQTPCADMMaxArrow;
|
|
|
|
if (s=="max_filled_arrow"||s=="maxfilledarrow") res |= JKQTPCADMMaxFilledArrow;
|
|
|
|
if (s=="min_arrow"||s=="minarrow") res |= JKQTPCADMMinArrow;
|
|
|
|
if (s=="min_filled_arrow"||s=="minfilledarrow") res |= JKQTPCADMMinFilledArrow;
|
|
|
|
}
|
|
|
|
return res;
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString JKQTPLabelTickMode2String(JKQTPLabelTickMode pos) {
|
|
|
|
switch(pos) {
|
|
|
|
case JKQTPLTMLinOrPower: return "lin_or_power";
|
|
|
|
case JKQTPLTMLin: return "lin";
|
|
|
|
case JKQTPLTMPower: return "power";
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:00:40 +08:00
|
|
|
JKQTPLabelTickMode String2JKQTPLabelTickMode(const QString& pos) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QString s=pos.trimmed().toLower();
|
|
|
|
if (s=="lin_or_power") return JKQTPLTMLinOrPower;
|
|
|
|
if (s=="lin") return JKQTPLTMLin;
|
|
|
|
if (s=="power") return JKQTPLTMPower;
|
|
|
|
return JKQTPLTMLinOrPower;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
QString JKQTPCALabelType2String(JKQTPCALabelType pos) {
|
2015-07-11 18:56:02 +08:00
|
|
|
switch(pos) {
|
|
|
|
case JKQTPCALTdefault: return "default";
|
|
|
|
case JKQTPCALTexponentCharacter: return "exponent_character";
|
|
|
|
case JKQTPCALTexponent: return "exponent";
|
|
|
|
case JKQTPCALTtime: return "time";
|
|
|
|
case JKQTPCALTdate: return "date";
|
|
|
|
case JKQTPCALTdatetime: return "datetime";
|
2022-09-22 06:44:54 +08:00
|
|
|
case JKQTPCALTscientific: return "scientific";
|
|
|
|
case JKQTPCALTintfrac: return "intfrac";
|
|
|
|
case JKQTPCALTintsfrac: return "intsfrac";
|
|
|
|
case JKQTPCALTintslashfrac: return "intslashfrac";
|
|
|
|
case JKQTPCALTfrac: return "frac";
|
|
|
|
case JKQTPCALTsfrac: return "sfrac";
|
|
|
|
case JKQTPCALTslashfrac: return "slashfrac";
|
2022-09-24 06:16:57 +08:00
|
|
|
case JKQTPCALTprintf: return "printf";
|
2022-09-24 02:43:53 +08:00
|
|
|
case JKQTPCALTcount: return "";
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:00:40 +08:00
|
|
|
JKQTPCALabelType String2JKQTPCALabelType(const QString& pos) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QString s=pos.trimmed().toLower();
|
2022-09-22 06:44:54 +08:00
|
|
|
if (s=="default" || s=="f") return JKQTPCALTdefault;
|
|
|
|
if (s=="scientifc" || s=="g") return JKQTPCALTscientific;
|
2015-07-11 18:56:02 +08:00
|
|
|
if (s=="exponent_character") return JKQTPCALTexponentCharacter;
|
|
|
|
if (s=="exponent") return JKQTPCALTexponent;
|
|
|
|
if (s=="time") return JKQTPCALTtime;
|
|
|
|
if (s=="date") return JKQTPCALTdate;
|
|
|
|
if (s=="datetime") return JKQTPCALTdatetime;
|
2022-09-22 06:44:54 +08:00
|
|
|
if (s=="frac") return JKQTPCALTfrac;
|
|
|
|
if (s=="sfrac") return JKQTPCALTsfrac;
|
|
|
|
if (s=="slashfrac") return JKQTPCALTslashfrac;
|
|
|
|
if (s=="intfrac") return JKQTPCALTintfrac;
|
|
|
|
if (s=="intsfrac") return JKQTPCALTintsfrac;
|
|
|
|
if (s=="intslashfrac") return JKQTPCALTintslashfrac;
|
2022-09-24 06:16:57 +08:00
|
|
|
if (s=="printf" || s=="sprintf") return JKQTPCALTprintf;
|
2015-07-11 18:56:02 +08:00
|
|
|
return JKQTPCALTdefault;
|
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
QString JKQTPLabelPosition2String(JKQTPLabelPosition pos) {
|
2015-07-11 18:56:02 +08:00
|
|
|
switch(pos) {
|
2019-01-20 17:49:29 +08:00
|
|
|
case JKQTPLabelMin: return "min";
|
|
|
|
case JKQTPLabelMax: return "max";
|
|
|
|
case JKQTPLabelCenter: return "center";
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:00:40 +08:00
|
|
|
JKQTPLabelPosition String2JKQTPLabelPosition(const QString& pos) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QString s=pos.trimmed().toLower();
|
2019-01-20 17:49:29 +08:00
|
|
|
if (s=="min") return JKQTPLabelMin;
|
|
|
|
if (s=="max") return JKQTPLabelMax;
|
|
|
|
if (s=="center") return JKQTPLabelCenter;
|
|
|
|
return JKQTPLabelCenter;
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
QString JKQTPKeyPosition2String(JKQTPKeyPosition pos) {
|
2015-07-11 18:56:02 +08:00
|
|
|
switch(pos) {
|
2019-01-20 17:49:29 +08:00
|
|
|
case JKQTPKeyOutsideLeftBottom: return "outside_leftbottom";
|
|
|
|
case JKQTPKeyOutsideTopLeft: return "outside_topleft";
|
|
|
|
case JKQTPKeyOutsideTopRight: return "outside_topright";
|
|
|
|
case JKQTPKeyOutsideLeftTop: return "outside_lefttop";
|
|
|
|
|
|
|
|
case JKQTPKeyOutsideRightBottom: return "outside_rightbottom";
|
|
|
|
case JKQTPKeyOutsideBottomLeft: return "outside_bottomleft";
|
|
|
|
case JKQTPKeyOutsideBottomRight: return "outside_bottomright";
|
|
|
|
case JKQTPKeyOutsideRightTop: return "outside_righttop";
|
|
|
|
|
|
|
|
case JKQTPKeyInsideBottomRight: return "inside_bottomright";
|
|
|
|
case JKQTPKeyInsideTopLeft: return "inside_topleft";
|
|
|
|
case JKQTPKeyInsideTopRight: return "inside_topright";
|
|
|
|
case JKQTPKeyInsideBottomLeft: return "inside_bottomleft";
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:00:40 +08:00
|
|
|
JKQTPKeyPosition String2JKQTPKeyPosition(const QString& pos) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QString s=pos.trimmed().toLower();
|
2019-01-20 17:49:29 +08:00
|
|
|
if (s=="outside_bottom" || s=="outsidebottom" || s=="outside_leftbottom" || s=="outsideleftbottom" || s=="olb") return JKQTPKeyOutsideLeftBottom;
|
|
|
|
if (s=="outside_left" || s=="outsideleft" || s=="outside_topleft" || s=="outsidetopleft" || s=="otl") return JKQTPKeyOutsideTopLeft;
|
|
|
|
if (s=="outside_right" || s=="outsideright" || s=="outside_topright" || s=="outsidetopright" || s=="otr") return JKQTPKeyOutsideTopRight;
|
|
|
|
if (s=="outside_top" || s=="outsidetop" || s=="outside_lefttop" || s=="outsidelefttop" || s=="olt") return JKQTPKeyOutsideLeftTop;
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
if (s=="outside_rightbottom" || s=="outsiderightbottom" || s=="orb" ) return JKQTPKeyOutsideRightBottom;
|
|
|
|
if (s=="outside_bottomleft" || s=="outsidebottomleft" || s=="obl" ) return JKQTPKeyOutsideBottomLeft;
|
|
|
|
if (s=="outside_bottomright" || s=="outsidebottomright" || s=="obr" ) return JKQTPKeyOutsideBottomRight;
|
|
|
|
if (s=="outside_righttop" || s=="outsiderighttop" || s=="ort" ) return JKQTPKeyOutsideRightTop;
|
2015-07-11 18:56:02 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
if (s=="inside_bottom" || s=="insidebottom" || s=="inside_bottomright" || s=="insidebottomright" || s=="ibr") return JKQTPKeyInsideBottomRight;
|
|
|
|
if (s=="inside_top" || s=="insidetop" || s=="inside_left" || s=="insideleft" || s=="inside_topleft" || s=="insidetopleft" || s=="itl") return JKQTPKeyInsideTopLeft;
|
|
|
|
if (s=="inside_right" || s=="insideright" || s=="inside_topright" || s=="insidetopright" || s=="itr") return JKQTPKeyInsideTopRight;
|
|
|
|
if (s=="inside_bottomleft" || s=="insidebottomleft" || s=="ibl") return JKQTPKeyInsideBottomLeft;
|
|
|
|
return JKQTPKeyInsideTopRight;
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
QString JKQTPKeyLayout2String(JKQTPKeyLayout pos) {
|
2015-07-11 18:56:02 +08:00
|
|
|
switch(pos) {
|
2019-01-20 17:49:29 +08:00
|
|
|
case JKQTPKeyLayoutOneColumn: return "one_column";
|
|
|
|
case JKQTPKeyLayoutOneRow: return "one_row";
|
|
|
|
case JKQTPKeyLayoutMultiColumn: return "multi_column";
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:00:40 +08:00
|
|
|
JKQTPKeyLayout String2JKQTPKeyLayout(const QString& pos) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QString s=pos.trimmed().toLower();
|
2019-01-20 17:49:29 +08:00
|
|
|
if (s=="one_column" || s=="onecolumn" || s=="one") return JKQTPKeyLayoutOneColumn;
|
|
|
|
if (s=="one_row" || s=="onerow") return JKQTPKeyLayoutOneRow;
|
|
|
|
if (s=="multi_column" || s=="multicolumn" || s=="multi") return JKQTPKeyLayoutMultiColumn;
|
|
|
|
return JKQTPKeyLayoutOneColumn;
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
QString JKQTPErrorPlotstyle2String(JKQTPErrorPlotstyle pos) {
|
2022-09-15 04:03:46 +08:00
|
|
|
QString s="";
|
|
|
|
if (pos==JKQTPNoError) return "error_none";
|
|
|
|
if (pos.testFlag(JKQTPErrorSimpleBars)&&pos.testFlag(JKQTPErrorIndicatorBar)) JKQTPExtendString(s, "+", "error_bars");
|
|
|
|
else if (pos.testFlag(JKQTPErrorSimpleBars)&&pos.testFlag(JKQTPErrorIndicatorArrows)) JKQTPExtendString(s, "+", "error_arrows");
|
|
|
|
else if (pos.testFlag(JKQTPErrorSimpleBars)&&pos.testFlag(JKQTPErrorIndicatorInwardArrows)) JKQTPExtendString(s, "+", "error_inwardarrows");
|
|
|
|
else if (pos.testFlag(JKQTPErrorSimpleBars)) JKQTPExtendString(s, "+", "error_simplebars");
|
|
|
|
|
|
|
|
if (pos.testFlag(JKQTPErrorLines)) JKQTPExtendString(s, "+", "error_lines");
|
|
|
|
if (pos.testFlag(JKQTPErrorPolygons)) JKQTPExtendString(s, "+", "error_polygons");
|
|
|
|
if (pos.testFlag(JKQTPErrorEllipses)) JKQTPExtendString(s, "+", "error_ell");
|
|
|
|
if (pos.testFlag(JKQTPErrorBoxes)) JKQTPExtendString(s, "+", "error_box");
|
|
|
|
|
|
|
|
if (pos.testFlag(JKQTPErrorDirectionOutwards)) JKQTPExtendString(s, "+", "outwards");
|
|
|
|
if (pos.testFlag(JKQTPErrorDirectionInwards)) JKQTPExtendString(s, "+", "inwards");
|
|
|
|
if (pos.testFlag(JKQTPErrorDirectionAbove)) JKQTPExtendString(s, "+", "above");
|
|
|
|
if (pos.testFlag(JKQTPErrorDirectionBelow)) JKQTPExtendString(s, "+", "below");
|
|
|
|
|
|
|
|
if (!pos.testFlag(JKQTPErrorSimpleBars)&&pos.testFlag(JKQTPErrorIndicatorBar)) JKQTPExtendString(s, "+", "bars");
|
|
|
|
if (!pos.testFlag(JKQTPErrorSimpleBars)&&pos.testFlag(JKQTPErrorIndicatorArrows)) JKQTPExtendString(s, "+", "arrows");
|
|
|
|
if (!pos.testFlag(JKQTPErrorSimpleBars)&&pos.testFlag(JKQTPErrorIndicatorInwardArrows)) JKQTPExtendString(s, "+", "inwardarrows");
|
|
|
|
|
|
|
|
return s;
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
2019-01-26 20:00:40 +08:00
|
|
|
JKQTPErrorPlotstyle String2JKQTPErrorPlotstyle(const QString& pos) {
|
2015-07-11 18:56:02 +08:00
|
|
|
QString s=pos.trimmed().toLower();
|
2019-01-20 17:49:29 +08:00
|
|
|
if (s=="error_lines") return JKQTPErrorLines;
|
|
|
|
if (s=="error_box") return JKQTPErrorBoxes;
|
|
|
|
if (s=="error_ell") return JKQTPErrorEllipses;
|
|
|
|
if (s=="error_bars") return JKQTPErrorBars;
|
|
|
|
if (s=="error_simplebars") return JKQTPErrorSimpleBars;
|
|
|
|
if (s=="error_polygons") return JKQTPErrorPolygons;
|
|
|
|
if (s=="error_bars_lines") return JKQTPErrorBarsLines;
|
|
|
|
if (s=="error_bars_polygons") return JKQTPErrorBarsPolygons;
|
|
|
|
if (s=="error_simplebars_lines") return JKQTPErrorSimpleBarsLines;
|
|
|
|
if (s=="error_simplebars_polygons") return JKQTPErrorSimpleBarsPolygons;
|
2022-09-11 04:35:30 +08:00
|
|
|
if (s=="error_bars_half_above") return JKQTPErrorHalfBarsAbove;
|
|
|
|
if (s=="error_bars_half_below") return JKQTPErrorHalfBarsBelow;
|
|
|
|
if (s=="error_bars_half_inwards") return JKQTPErrorHalfBarsInwards;
|
|
|
|
if (s=="error_bars_half_outwards") return JKQTPErrorHalfBarsOutwards;
|
2022-09-15 04:03:46 +08:00
|
|
|
const QStringList sl=s.split("+");
|
|
|
|
JKQTPErrorPlotstyle es=JKQTPNoError;
|
|
|
|
for (const QString& s: sl) {
|
|
|
|
if (s=="error_arrows") es|=JKQTPErrorArrows;
|
|
|
|
if (s=="error_inwardarrows") es|=JKQTPErrorInwardArrows;
|
|
|
|
if (s=="error_bars") es|=JKQTPErrorBars;
|
|
|
|
if (s=="error_simplebars") es|=JKQTPErrorSimpleBars;
|
|
|
|
if (s=="error_lines") es|=JKQTPErrorLines;
|
|
|
|
if (s=="error_polygons") es|=JKQTPErrorPolygons;
|
|
|
|
if (s=="error_ell" || s=="error_ellipses") es|=JKQTPErrorEllipses;
|
|
|
|
if (s=="error_box" || s=="error_boxes") es|=JKQTPErrorBoxes;
|
|
|
|
if (s=="outwards") es|=JKQTPErrorDirectionOutwards;
|
|
|
|
if (s=="inwards") es|=JKQTPErrorDirectionInwards;
|
|
|
|
if (s=="above") es|=JKQTPErrorDirectionAbove;
|
|
|
|
if (s=="below") es|=JKQTPErrorDirectionBelow;
|
|
|
|
if (s=="bars"||s=="bar") es|=JKQTPErrorIndicatorBar;
|
|
|
|
if (s=="arrow" || s=="arrows") es|=JKQTPErrorIndicatorArrows;
|
|
|
|
if ( s=="inwardarrows" || s=="inwardsarrows" || s=="inwardarrow" || s=="inwardsarrow"
|
|
|
|
||s=="inward_arrows" || s=="inwards_arrows" || s=="inward_arrow" || s=="inwards_arrow") es|=JKQTPErrorIndicatorInwardArrows;
|
|
|
|
}
|
|
|
|
return es;
|
2015-07-11 18:56:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
QString JKQTPSpecialLineType2String(JKQTPSpecialLineType pos)
|
2018-12-07 04:41:35 +08:00
|
|
|
{
|
|
|
|
switch(pos) {
|
2019-01-20 17:49:29 +08:00
|
|
|
case JKQTPStepLeft: return "step_left";
|
|
|
|
case JKQTPStepCenter: return "step_center";
|
|
|
|
case JKQTPStepRight: return "step_right";
|
2019-04-22 19:27:50 +08:00
|
|
|
case JKQTPStepAverage: return "step_average";
|
|
|
|
case JKQTPDirectLine: return "direct_line";
|
2018-12-07 04:41:35 +08:00
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2019-04-22 19:27:50 +08:00
|
|
|
JKQTPSpecialLineType String2JKQTPSpecialLineType(const QString& pos)
|
2018-12-07 04:41:35 +08:00
|
|
|
{
|
|
|
|
QString s=pos.trimmed().toLower();
|
2019-01-20 17:49:29 +08:00
|
|
|
if (s=="step_left"||s=="left"||s=="l") return JKQTPStepLeft;
|
|
|
|
if (s=="step_center"||s=="center"||s=="c") return JKQTPStepCenter;
|
|
|
|
if (s=="step_right"||s=="right"||s=="r") return JKQTPStepRight;
|
2019-04-22 19:27:50 +08:00
|
|
|
if (s=="step_average"||s=="step_avg"||s=="average"||s=="avg"||s=="a") return JKQTPStepAverage;
|
|
|
|
if (s=="direct_line"||s=="line"||s=="d") return JKQTPDirectLine;
|
2018-12-07 04:41:35 +08:00
|
|
|
|
2019-01-20 17:49:29 +08:00
|
|
|
return JKQTPStepLeft;
|
2018-12-07 04:41:35 +08:00
|
|
|
}
|
|
|
|
|
2019-02-08 00:24:46 +08:00
|
|
|
|
|
|
|
QString JKQTPContextMenuModes2String(JKQTPContextMenuModes act)
|
|
|
|
{
|
|
|
|
if (act==jkqtpcmmStandardContextMenu) return "standard";
|
|
|
|
if (act==jkqtpcmmSpecialContextMenu) return "special";
|
|
|
|
if (act==jkqtpcmmStandardAndSpecialContextMenu) return "both";
|
|
|
|
if (act==jkqtpcmmNoContextMenu) return "none";
|
|
|
|
return "none";
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPContextMenuModes String2JKQTPContextMenuModes(const QString &act)
|
|
|
|
{
|
|
|
|
QString s=act.trimmed().toLower();
|
|
|
|
if (s=="jkqtpcmmstandardcontextmenu"||s=="standardcontextmenu" ||s=="standard") return jkqtpcmmStandardContextMenu;
|
|
|
|
if (s=="jkqtpcmmspecialcontextmenu"||s=="specialcontextmenu"||s=="special") return jkqtpcmmSpecialContextMenu;
|
|
|
|
if (s=="jkqtpcmmstandardandspecialcontextmenu"||s=="standardandspecialcontextmenu"||s=="standardandspecial"||s=="standard+special"||s=="both") return jkqtpcmmStandardAndSpecialContextMenu;
|
|
|
|
|
|
|
|
return jkqtpcmmNoContextMenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPMouseWheelActions String2JKQTPMouseWheelActions(const QString &act)
|
|
|
|
{
|
|
|
|
QString s=act.trimmed().toLower();
|
|
|
|
if (s=="jkqtpmwazoombywheel"||s=="zoombywheel" ||s=="zoom") return jkqtpmwaZoomByWheel;
|
|
|
|
if (s=="jkqtpmwapanbywheel"||s=="panbywheel"||s=="pan") return jkqtpmwaPanByWheel;
|
2023-06-16 19:41:47 +08:00
|
|
|
if (s=="jkqtpmwazoombywheelandtrackpadpan"||s=="zoombywheelortrackpan"||s=="zoomortrackpan") return jkqtpmwaZoomByWheelAndTrackpadPan;
|
2019-02-08 00:24:46 +08:00
|
|
|
return jkqtpmwaZoomByWheel;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QString JKQTPMouseWheelActions2String(JKQTPMouseWheelActions act)
|
|
|
|
{
|
|
|
|
if (act==jkqtpmwaZoomByWheel) return "zoom";
|
|
|
|
if (act==jkqtpmwaPanByWheel) return "pan";
|
2023-06-16 19:41:47 +08:00
|
|
|
if (act==jkqtpmwaZoomByWheelAndTrackpadPan) return "zoomortrackpan";
|
2019-02-08 00:24:46 +08:00
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPMouseDoubleClickActions String2JKQTPMouseDoubleClickActions(const QString &act)
|
|
|
|
{
|
|
|
|
QString s=act.trimmed().toLower();
|
|
|
|
if (s=="jkqtpdcaclickzoomsin"||s=="clickzoomsin" ||s=="zoomsin" ||s=="zoomin") return jkqtpdcaClickZoomsIn;
|
|
|
|
if (s=="jkqtpdcaclickzoomsout"||s=="clickzoomsout" ||s=="zoomsout" ||s=="zoomout") return jkqtpdcaClickZoomsOut;
|
|
|
|
if (s=="jkqtpdcaclickopenscontextmenu"||s=="openscontextmenu"||s=="opencontextmenu"||s=="contextmenu") return jkqtpdcaClickOpensContextMenu;
|
|
|
|
if (s=="jkqtpdcaclickopensspecialcontextmenu"||s=="opensspecialcontextmenu"||s=="openspecialcontextmenu"||s=="specialcontextmenu") return jkqtpdcaClickOpensSpecialContextMenu;
|
|
|
|
if (s=="jkqtpdcaclickmovesviewport"||s=="clickmovesviewport"||s=="movesviewport"||s=="moveviewport"||s=="moveview") return jkqtpdcaClickMovesViewport;
|
|
|
|
|
|
|
|
return jkqtpdcaClickZoomsIn;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString JKQTPMouseDoubleClickActions2String(JKQTPMouseDoubleClickActions act)
|
|
|
|
{
|
|
|
|
if (act==jkqtpdcaClickZoomsIn) return "zoomin";
|
|
|
|
if (act==jkqtpdcaClickZoomsOut) return "zoomout";
|
|
|
|
if (act==jkqtpdcaClickOpensContextMenu) return "contextmenu";
|
|
|
|
if (act==jkqtpdcaClickOpensSpecialContextMenu) return "specialcontextmenu";
|
|
|
|
if (act==jkqtpdcaClickMovesViewport) return "moveviewport";
|
|
|
|
return "unknown";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPMouseDragActions String2JKQTPMouseDragActions(const QString &act)
|
|
|
|
{
|
|
|
|
QString s=act.trimmed().toLower();
|
|
|
|
if (s=="jkqtpmdapanonmove"||s=="panonmove" ||s=="panmove") return jkqtpmdaPanPlotOnMove;
|
|
|
|
if (s=="jkqtpmdapanonrelease"||s=="panonrelease" ||s=="panrelease") return jkqtpmdaPanPlotOnRelease;
|
|
|
|
if (s=="jkqtpmdazoombyrectangle"||s=="zoomrectangle"||s=="zoomrect"||s=="zoombyrectangle"||s=="zoombyrect") return jkqtpmdaZoomByRectangle;
|
|
|
|
if (s=="jkqtpmdadrawrectforevent"||s=="drawrectangle"||s=="drawrect"||s=="rectangle"||s=="rect") return jkqtpmdaDrawRectangleForEvent;
|
|
|
|
if (s=="jkqtpmdadrawrectforevent"||s=="drawcircle"||s=="circle") return jkqtpmdaDrawCircleForEvent;
|
|
|
|
if (s=="jkqtpmdadrawrectforevent"||s=="drawellipse"||s=="ellipse") return jkqtpmdaDrawEllipseForEvent;
|
|
|
|
if (s=="jkqtpmdadrawrectforevent"||s=="drawline"||s=="line") return jkqtpmdaDrawLineForEvent;
|
|
|
|
if (s=="jkqtpmdascribbleforevents"||s=="scribble") return jkqtpmdaScribbleForEvents;
|
2019-05-06 01:31:20 +08:00
|
|
|
if (s=="jkqtpmdatooltipforclosestdatapoint"||s=="closestdatapointtooltip"||s=="tooltipforclosestdatapoint"||s=="tooltip") return jkqtpmdaToolTipForClosestDataPoint;
|
|
|
|
if (s=="jkqtpmdaruler"||s=="ruler") return jkqtpmdaRuler;
|
|
|
|
|
2019-02-08 00:24:46 +08:00
|
|
|
|
|
|
|
return jkqtpmdaZoomByRectangle;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QString JKQTPMouseDragActions2String(JKQTPMouseDragActions act)
|
|
|
|
{
|
|
|
|
if (act==jkqtpmdaPanPlotOnMove) return "PanOnMove";
|
|
|
|
if (act==jkqtpmdaPanPlotOnRelease) return "PanOnRelease";
|
|
|
|
if (act==jkqtpmdaZoomByRectangle) return "ZoomRectangle";
|
|
|
|
if (act==jkqtpmdaDrawRectangleForEvent) return "DrawRectangle";
|
|
|
|
if (act==jkqtpmdaDrawCircleForEvent) return "DrawCircle";
|
|
|
|
if (act==jkqtpmdaDrawEllipseForEvent) return "DrawEllipse";
|
|
|
|
if (act==jkqtpmdaDrawLineForEvent) return "DrawLine";
|
|
|
|
if (act==jkqtpmdaScribbleForEvents) return "Scribble";
|
2019-05-06 01:31:20 +08:00
|
|
|
if (act==jkqtpmdaToolTipForClosestDataPoint) return "ToolTipForClosestDataPoint";
|
|
|
|
if (act==jkqtpmdaRuler) return "Ruler";
|
2019-02-08 00:24:46 +08:00
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-03 03:21:17 +08:00
|
|
|
|
|
|
|
JKQTPColorDerivationMode::JKQTPColorDerivationMode(PredefinedModes mode):
|
|
|
|
colorModification(ColorChangeMode::SameColor),
|
|
|
|
targetColor("black"),
|
|
|
|
colorModificationStrength(200),
|
|
|
|
transparencyModification(TransparencyChangeMode::SameTransparency),
|
2022-07-23 22:05:13 +08:00
|
|
|
targetTransparency(0.5f),
|
|
|
|
transparencyModficationStrength(0.66f)
|
2019-02-08 00:24:46 +08:00
|
|
|
{
|
|
|
|
switch(mode) {
|
2022-06-03 03:21:17 +08:00
|
|
|
case JKQTPFFCMFullyTransparentColor:
|
|
|
|
targetColor=QColor(Qt::transparent);
|
|
|
|
colorModification=ColorChangeMode::ReplaceColorAndTransparency;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMBlack:
|
|
|
|
targetColor=QColor(Qt::black);
|
|
|
|
colorModification=ColorChangeMode::ReplaceColorAndTransparency;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMWhite:
|
|
|
|
targetColor=QColor(Qt::white);
|
|
|
|
colorModification=ColorChangeMode::ReplaceColorAndTransparency;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMGrey25:
|
|
|
|
targetColor=QColor(64,64,64);
|
|
|
|
colorModification=ColorChangeMode::ReplaceColorAndTransparency;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMGrey50:
|
|
|
|
targetColor=QColor(127,127,127);
|
|
|
|
colorModification=ColorChangeMode::ReplaceColorAndTransparency;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMGrey75:
|
|
|
|
targetColor=QColor(191,191,191);
|
|
|
|
colorModification=ColorChangeMode::ReplaceColorAndTransparency;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMBlackTransparent:
|
|
|
|
targetColor=QColor(0,0,0,175);
|
|
|
|
colorModification=ColorChangeMode::ReplaceColorAndTransparency;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMWhiteTransparent:
|
|
|
|
targetColor=QColor(255,255,255,175);
|
|
|
|
colorModification=ColorChangeMode::ReplaceColorAndTransparency;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMGrey25Transparent:
|
|
|
|
targetColor=QColor(64,64,64,175);
|
|
|
|
colorModification=ColorChangeMode::ReplaceColorAndTransparency;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMGrey50Transparent:
|
|
|
|
targetColor=QColor(127,127,127,175);
|
|
|
|
colorModification=ColorChangeMode::ReplaceColorAndTransparency;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMGrey75Transparent:
|
|
|
|
targetColor=QColor(191,191,191,175);
|
|
|
|
colorModification=ColorChangeMode::ReplaceColorAndTransparency;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMSameColor:
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMSameNonTransparentColor:
|
|
|
|
transparencyModification=TransparencyChangeMode::ReplaceTransparency;
|
|
|
|
targetTransparency=0.0;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMSameMoreTransparentColor:
|
|
|
|
transparencyModification=TransparencyChangeMode::MoreTransparent;
|
2022-07-23 22:05:13 +08:00
|
|
|
transparencyModficationStrength=0.33f;
|
2022-06-03 03:21:17 +08:00
|
|
|
break;
|
|
|
|
case JKQTPFFCMSameEvenMoreTransparentColor:
|
|
|
|
transparencyModification=TransparencyChangeMode::MoreTransparent;
|
2022-07-23 22:05:13 +08:00
|
|
|
transparencyModficationStrength=0.66f;
|
2022-06-03 03:21:17 +08:00
|
|
|
break;
|
|
|
|
case JKQTPFFCMSameLessTransparentColor:
|
|
|
|
transparencyModification=TransparencyChangeMode::LessTransparent;
|
2022-07-23 22:05:13 +08:00
|
|
|
transparencyModficationStrength=0.33f;
|
2022-06-03 03:21:17 +08:00
|
|
|
break;
|
|
|
|
case JKQTPFFCMSameEvenLessTransparentColor:
|
|
|
|
transparencyModification=TransparencyChangeMode::LessTransparent;
|
2022-07-23 22:05:13 +08:00
|
|
|
transparencyModficationStrength=0.66f;
|
2022-07-22 04:17:37 +08:00
|
|
|
break;
|
2022-06-03 03:21:17 +08:00
|
|
|
case JKQTPFFCMInvertedColor:
|
|
|
|
colorModification=ColorChangeMode::InvertColor;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMInvertedTransparentColor:
|
|
|
|
colorModification=ColorChangeMode::InvertColor;
|
|
|
|
transparencyModification=TransparencyChangeMode::MoreTransparent;
|
2022-07-23 22:05:13 +08:00
|
|
|
transparencyModficationStrength=0.33f;
|
2022-06-03 03:21:17 +08:00
|
|
|
break;
|
|
|
|
case JKQTPFFCMInvertedNonTransparentColor:
|
|
|
|
colorModification=ColorChangeMode::InvertColor;
|
|
|
|
transparencyModification=TransparencyChangeMode::ReplaceTransparency;
|
|
|
|
targetTransparency=0.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case JKQTPFFCMLighterColor:
|
|
|
|
colorModification=ColorChangeMode::LighterColor;
|
|
|
|
colorModificationStrength=150;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMLighterAndTransparentColor:
|
|
|
|
colorModification=ColorChangeMode::LighterColor;
|
|
|
|
colorModificationStrength=150;
|
|
|
|
transparencyModification=TransparencyChangeMode::MoreTransparent;
|
2022-07-23 22:05:13 +08:00
|
|
|
transparencyModficationStrength=0.33f;
|
2022-06-03 03:21:17 +08:00
|
|
|
break;
|
|
|
|
case JKQTPFFCMLighterAndNonTransparentColor:
|
|
|
|
colorModification=ColorChangeMode::LighterColor;
|
|
|
|
colorModificationStrength=150;
|
|
|
|
transparencyModification=TransparencyChangeMode::ReplaceTransparency;
|
|
|
|
targetTransparency=0.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case JKQTPFFCMEvenLighterColor:
|
|
|
|
colorModification=ColorChangeMode::LighterColor;
|
|
|
|
colorModificationStrength=200;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMEvenLighterAndTransparentColor:
|
|
|
|
colorModification=ColorChangeMode::LighterColor;
|
|
|
|
colorModificationStrength=200;
|
|
|
|
transparencyModification=TransparencyChangeMode::MoreTransparent;
|
2022-07-23 22:05:13 +08:00
|
|
|
transparencyModficationStrength=0.33f;
|
2022-06-03 03:21:17 +08:00
|
|
|
break;
|
|
|
|
case JKQTPFFCMEvenLighterAndNonTransparentColor:
|
|
|
|
colorModification=ColorChangeMode::LighterColor;
|
|
|
|
colorModificationStrength=200;
|
|
|
|
transparencyModification=TransparencyChangeMode::ReplaceTransparency;
|
2022-07-23 22:05:13 +08:00
|
|
|
targetTransparency=0.0f;
|
2022-06-03 03:21:17 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case JKQTPFFCMDarkerColor:
|
|
|
|
colorModification=ColorChangeMode::DarkerColor;
|
|
|
|
colorModificationStrength=200;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMDarkerAndTransparentColor:
|
|
|
|
colorModification=ColorChangeMode::DarkerColor;
|
|
|
|
colorModificationStrength=200;
|
|
|
|
transparencyModification=TransparencyChangeMode::MoreTransparent;
|
2022-07-23 22:05:13 +08:00
|
|
|
transparencyModficationStrength=0.33f;
|
2022-06-03 03:21:17 +08:00
|
|
|
break;
|
|
|
|
case JKQTPFFCMDarkerAndNonTransparentColor:
|
|
|
|
colorModification=ColorChangeMode::DarkerColor;
|
|
|
|
colorModificationStrength=200;
|
|
|
|
transparencyModification=TransparencyChangeMode::ReplaceTransparency;
|
2022-07-23 22:05:13 +08:00
|
|
|
targetTransparency=0.0f;
|
2022-06-03 03:21:17 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case JKQTPFFCMEvenDarkerColor:
|
|
|
|
colorModification=ColorChangeMode::DarkerColor;
|
|
|
|
colorModificationStrength=300;
|
|
|
|
break;
|
|
|
|
case JKQTPFFCMEvenDarkerAndTransparentColor:
|
|
|
|
colorModification=ColorChangeMode::DarkerColor;
|
|
|
|
colorModificationStrength=300;
|
|
|
|
transparencyModification=TransparencyChangeMode::MoreTransparent;
|
2022-07-23 22:05:13 +08:00
|
|
|
transparencyModficationStrength=0.33f;
|
2022-06-03 03:21:17 +08:00
|
|
|
break;
|
|
|
|
case JKQTPFFCMEvenDarkerAndNonTransparentColor:
|
|
|
|
colorModification=ColorChangeMode::DarkerColor;
|
|
|
|
colorModificationStrength=300;
|
|
|
|
transparencyModification=TransparencyChangeMode::ReplaceTransparency;
|
2022-07-23 22:05:13 +08:00
|
|
|
targetTransparency=0.0f;
|
2022-06-03 03:21:17 +08:00
|
|
|
break;
|
2019-02-08 00:24:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-03 03:21:17 +08:00
|
|
|
JKQTPColorDerivationMode::JKQTPColorDerivationMode(const QString &mode):
|
|
|
|
JKQTPColorDerivationMode()
|
|
|
|
{
|
|
|
|
*this=fromString(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString JKQTPColorDerivationMode::toString() const
|
|
|
|
{
|
|
|
|
// some shortcut strings
|
|
|
|
if (*this == JKQTPFFCMFullyTransparentColor) return "transparent";
|
|
|
|
if (*this == JKQTPFFCMSameColor) return "same";
|
|
|
|
if (*this == JKQTPFFCMInvertedColor) return "inverted";
|
|
|
|
if (*this == JKQTPFFCMWhite) return "white";
|
|
|
|
if (*this == JKQTPFFCMSameNonTransparentColor) return "same_non_transparent";
|
|
|
|
if (*this == JKQTPFFCMLighterColor) return "lighter";
|
|
|
|
if (*this == JKQTPFFCMDarkerColor) return "darker";
|
|
|
|
if (*this == JKQTPFFCMLighterAndTransparentColor) return "lighter_transparent";
|
|
|
|
if (*this == JKQTPFFCMDarkerAndTransparentColor) return "darker_transparent";
|
|
|
|
|
|
|
|
QString name;
|
|
|
|
switch (colorModification) {
|
|
|
|
case ColorChangeMode::SameColor:
|
|
|
|
name="same_color";
|
|
|
|
break;
|
|
|
|
case ColorChangeMode::ReplaceColorNotTransparency:
|
|
|
|
name="replace_color_not_transparency("+jkqtp_QColor2String(targetColor)+")";
|
|
|
|
break;
|
|
|
|
case ColorChangeMode::ReplaceColorAndTransparency:
|
|
|
|
name="replace_color_and_transparency("+jkqtp_QColor2String(targetColor)+")";
|
|
|
|
break;
|
|
|
|
case ColorChangeMode::DarkerColor:
|
|
|
|
name="darker_color("+QString::number(colorModificationStrength)+")";
|
|
|
|
break;
|
|
|
|
case ColorChangeMode::LighterColor:
|
|
|
|
name="lighter_color("+QString::number(colorModificationStrength)+")";
|
|
|
|
break;
|
|
|
|
case ColorChangeMode::InvertColor:
|
|
|
|
name="inverted_color";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// alpha=0: transparent, alpha=1: ppaque
|
|
|
|
switch (transparencyModification) {
|
|
|
|
case TransparencyChangeMode::SameTransparency:
|
|
|
|
break;
|
|
|
|
case TransparencyChangeMode::ReplaceTransparency:
|
|
|
|
name+=",transparency("+QString::number(targetTransparency*100,'f',1)+")";
|
|
|
|
break;
|
|
|
|
case TransparencyChangeMode::MoreTransparent:
|
|
|
|
name+=",more_transparent("+QString::number(transparencyModficationStrength,'f',3)+")";
|
|
|
|
break;
|
|
|
|
case TransparencyChangeMode::LessTransparent:
|
|
|
|
name+=",less_transparent("+QString::number(transparencyModficationStrength,'f',3)+")";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPColorDerivationMode JKQTPColorDerivationMode::fromString(const QString &mode)
|
2019-02-08 00:24:46 +08:00
|
|
|
{
|
2020-09-26 21:58:58 +08:00
|
|
|
const QString m=mode.trimmed().toLower();
|
2022-06-03 03:21:17 +08:00
|
|
|
|
|
|
|
// legacy strings
|
|
|
|
if (m=="transparent" || m=="no_color" || m=="none") return JKQTPColorDerivationMode(JKQTPFFCMFullyTransparentColor);
|
|
|
|
if (m=="same"||m=="same_color") return JKQTPColorDerivationMode(JKQTPFFCMSameColor);
|
|
|
|
if (m=="black") return JKQTPColorDerivationMode(JKQTPFFCMBlack);
|
|
|
|
if (m=="white") return JKQTPColorDerivationMode(JKQTPFFCMWhite);
|
|
|
|
if (m=="grey25") return JKQTPColorDerivationMode(JKQTPFFCMGrey25);
|
|
|
|
if (m=="grey50") return JKQTPColorDerivationMode(JKQTPFFCMGrey50);
|
|
|
|
if (m=="grey75") return JKQTPColorDerivationMode(JKQTPFFCMGrey75);
|
|
|
|
if (m=="transparent_black" || m=="black_transparent") return JKQTPColorDerivationMode(JKQTPFFCMBlackTransparent);
|
|
|
|
if (m=="transparent_white" || m=="white_transparent") return JKQTPColorDerivationMode(JKQTPFFCMWhiteTransparent);
|
|
|
|
if (m=="transparent_grey25" || m=="grey25_transparent") return JKQTPColorDerivationMode(JKQTPFFCMGrey25Transparent);
|
|
|
|
if (m=="transparent_grey50" || m=="grey50_transparent") return JKQTPColorDerivationMode(JKQTPFFCMGrey50Transparent);
|
|
|
|
if (m=="transparent_grey75" || m=="grey75_transparent") return JKQTPColorDerivationMode(JKQTPFFCMGrey75Transparent);
|
|
|
|
if (m=="inverted") return JKQTPColorDerivationMode(JKQTPFFCMInvertedColor);
|
|
|
|
if (m=="transparent_inverted" || m=="inverted_transparent") return JKQTPColorDerivationMode(JKQTPFFCMInvertedTransparentColor);
|
|
|
|
if (m=="non_transparent_inverted" || m=="inverted_non_transparent") return JKQTPColorDerivationMode(JKQTPFFCMInvertedNonTransparentColor);
|
|
|
|
if (m=="lighter") return JKQTPColorDerivationMode(JKQTPFFCMLighterColor);
|
|
|
|
if (m=="even_lighter") return JKQTPColorDerivationMode(JKQTPFFCMEvenLighterColor);
|
|
|
|
if (m=="darker") return JKQTPColorDerivationMode(JKQTPFFCMDarkerColor);
|
|
|
|
if (m=="even_darker") return JKQTPColorDerivationMode(JKQTPFFCMEvenDarkerColor);
|
|
|
|
if (m=="lighter_transparent"||m=="lighter_and_transparent") return JKQTPColorDerivationMode(JKQTPFFCMLighterAndTransparentColor);
|
|
|
|
if (m=="even_lighter_transparent"||m=="even_lighter_and_transparent") return JKQTPColorDerivationMode(JKQTPFFCMEvenLighterAndTransparentColor);
|
|
|
|
if (m=="darker_transparent"||m=="darker_and_transparent") return JKQTPColorDerivationMode(JKQTPFFCMDarkerAndTransparentColor);
|
|
|
|
if (m=="even_darker_transparent"||m=="even_darker_and_transparent") return JKQTPColorDerivationMode(JKQTPFFCMEvenDarkerAndTransparentColor);
|
|
|
|
if (m=="lighter_non_transparent"||m=="lighter_and_non_transparent") return JKQTPColorDerivationMode(JKQTPFFCMLighterAndNonTransparentColor);
|
|
|
|
if (m=="even_lighter_non_transparent"||m=="even_lighter_and_non_transparent") return JKQTPColorDerivationMode(JKQTPFFCMEvenLighterAndNonTransparentColor);
|
|
|
|
if (m=="darker_non_transparent"||m=="darker_and_non_transparent") return JKQTPColorDerivationMode(JKQTPFFCMDarkerAndNonTransparentColor);
|
|
|
|
if (m=="even_darker_non_transparent"||m=="even_darker_and_non_transparent") return JKQTPColorDerivationMode(JKQTPFFCMEvenDarkerAndNonTransparentColor);
|
|
|
|
if (m=="same_more_transparent"||m=="more_transparent") return JKQTPColorDerivationMode(JKQTPFFCMSameMoreTransparentColor);
|
|
|
|
if (m=="same_even_more_transparent"||m=="even_more_transparent") return JKQTPColorDerivationMode(JKQTPFFCMSameEvenMoreTransparentColor);
|
|
|
|
if (m=="same_less_transparent"||m=="less_transparent") return JKQTPColorDerivationMode(JKQTPFFCMSameLessTransparentColor);
|
|
|
|
if (m=="same_even_less_transparent"||m=="even_less_transparent") return JKQTPColorDerivationMode(JKQTPFFCMSameEvenLessTransparentColor);
|
|
|
|
if (m=="same_non_transparent" || m=="non_transparent") return JKQTPColorDerivationMode(JKQTPFFCMSameNonTransparentColor);
|
|
|
|
|
|
|
|
// cleanly analyze string
|
|
|
|
|
|
|
|
|
|
|
|
return JKQTPColorDerivationMode();
|
2019-02-08 00:24:46 +08:00
|
|
|
}
|
|
|
|
|
2022-06-03 03:21:17 +08:00
|
|
|
QColor JKQTPColorDerivationMode::apply(const QColor& basecolor) const
|
2019-02-08 00:24:46 +08:00
|
|
|
{
|
2022-06-03 03:21:17 +08:00
|
|
|
QColor c=basecolor;
|
|
|
|
switch (colorModification) {
|
|
|
|
case ColorChangeMode::SameColor:
|
|
|
|
c=basecolor;
|
|
|
|
break;
|
|
|
|
case ColorChangeMode::ReplaceColorNotTransparency:
|
|
|
|
c=targetColor;
|
|
|
|
c.setAlphaF(basecolor.alphaF());
|
|
|
|
break;
|
|
|
|
case ColorChangeMode::ReplaceColorAndTransparency:
|
|
|
|
c=targetColor;
|
|
|
|
break;
|
|
|
|
case ColorChangeMode::DarkerColor:
|
|
|
|
c=c.darker(static_cast<int>(colorModificationStrength));
|
|
|
|
break;
|
|
|
|
case ColorChangeMode::LighterColor:
|
|
|
|
c=c.lighter(static_cast<int>(colorModificationStrength));
|
|
|
|
break;
|
|
|
|
case ColorChangeMode::InvertColor:
|
|
|
|
c=QColor(255-c.red(), 255-c.green(), 255-c.blue(), c.alpha());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// alpha=0: transparent, alpha=1: ppaque
|
|
|
|
switch (transparencyModification) {
|
|
|
|
case TransparencyChangeMode::SameTransparency:
|
|
|
|
c.setAlphaF(c.alphaF());
|
|
|
|
break;
|
|
|
|
case TransparencyChangeMode::ReplaceTransparency:
|
|
|
|
c.setAlphaF(1.0-targetTransparency);
|
|
|
|
break;
|
|
|
|
case TransparencyChangeMode::MoreTransparent:
|
|
|
|
c.setAlphaF(c.alphaF()-transparencyModficationStrength*c.alphaF());
|
|
|
|
break;
|
|
|
|
case TransparencyChangeMode::LessTransparent:
|
|
|
|
c.setAlphaF(c.alphaF()+(1.0-c.alphaF())*transparencyModficationStrength);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool JKQTPColorDerivationMode::operator==(const JKQTPColorDerivationMode &other) const
|
|
|
|
{
|
|
|
|
if (colorModification!=other.colorModification) return false;
|
|
|
|
else {
|
|
|
|
if (colorModification==ColorChangeMode::ReplaceColorNotTransparency || colorModification==ColorChangeMode::ReplaceColorAndTransparency) {
|
|
|
|
if (targetColor!=other.targetColor) return false;
|
|
|
|
} else if (colorModification==ColorChangeMode::DarkerColor || colorModification==ColorChangeMode::LighterColor) {
|
|
|
|
if (colorModificationStrength!=other.colorModificationStrength) return false;
|
2020-09-27 22:11:58 +08:00
|
|
|
}
|
2022-06-03 03:21:17 +08:00
|
|
|
}
|
|
|
|
if (transparencyModification!=other.transparencyModification) return false;
|
|
|
|
else {
|
|
|
|
if (transparencyModification==TransparencyChangeMode::ReplaceTransparency) {
|
|
|
|
if (targetTransparency!=other.targetTransparency) return false;
|
|
|
|
} else if (transparencyModification==TransparencyChangeMode::MoreTransparent || transparencyModification==TransparencyChangeMode::LessTransparent) {
|
|
|
|
if (transparencyModficationStrength!=other.transparencyModficationStrength) return false;
|
2020-09-27 22:11:58 +08:00
|
|
|
}
|
2019-02-08 00:24:46 +08:00
|
|
|
}
|
2022-06-03 03:21:17 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool JKQTPColorDerivationMode::operator==(const JKQTPColorDerivationMode::PredefinedModes &other) const
|
|
|
|
{
|
|
|
|
return operator==(JKQTPColorDerivationMode(other));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString JKQTPColorDerivationMode2String(JKQTPColorDerivationMode mode)
|
|
|
|
{
|
|
|
|
return mode.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPColorDerivationMode String2JKQTPColorDerivationMode(const QString &mode)
|
|
|
|
{
|
|
|
|
return JKQTPColorDerivationMode::fromString(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor JKQTPGetDerivedColor(JKQTPColorDerivationMode mode, const QColor &basecolor)
|
|
|
|
{
|
|
|
|
return mode.apply(basecolor);
|
2019-02-08 00:24:46 +08:00
|
|
|
}
|
2019-05-06 01:31:20 +08:00
|
|
|
|
|
|
|
QString JKQTPUserActionMarkerType2String(JKQTPUserActionMarkerType act)
|
|
|
|
{
|
|
|
|
switch(act) {
|
|
|
|
case jkqtpuamtCircle: return "circle";
|
|
|
|
case jkqtpuamtCrossHair: return "crosshair";
|
|
|
|
case jkqtpuamtCircleAndCrossHair: return "circle+crosshair";
|
|
|
|
}
|
|
|
|
return "circle";
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPUserActionMarkerType String2JKQTPUserActionMarkerType(const QString &act)
|
|
|
|
{
|
|
|
|
QString m=act.trimmed().toLower();
|
|
|
|
if (m=="circle") return jkqtpuamtCircle;
|
|
|
|
if (m=="crosshair" || m=="cross") return jkqtpuamtCrossHair;
|
|
|
|
if (m=="circle+crosshair" || m=="circle+cross") return jkqtpuamtCircleAndCrossHair;
|
|
|
|
return jkqtpuamtCircle;
|
|
|
|
}
|
2022-05-15 20:15:15 +08:00
|
|
|
|
|
|
|
QString JKQTPMouseMoveActions2String(JKQTPMouseMoveActions act)
|
|
|
|
{
|
|
|
|
if (act==jkqtpmmaToolTipForClosestDataPoint) return "ToolTipForClosestDataPoint";
|
|
|
|
return "ToolTipForClosestDataPoint";
|
|
|
|
}
|
|
|
|
|
|
|
|
JKQTPMouseMoveActions String2JKQTPMouseMoveActions(const QString &s)
|
|
|
|
{
|
|
|
|
if (s=="jkqtpmmatooltipforclosestdatapoint"||s=="closestdatapointtooltip"||s=="tooltipforclosestdatapoint"||s=="tooltip") return jkqtpmmaToolTipForClosestDataPoint;
|
|
|
|
return jkqtpmmaToolTipForClosestDataPoint;
|
|
|
|
}
|