-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjkqtptools.h
More file actions
executable file
·1318 lines (1104 loc) · 49.4 KB
/
Copy pathjkqtptools.h
File metadata and controls
executable file
·1318 lines (1104 loc) · 49.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (c) 2008-2015 Jan W. Krieger (<jan@jkrieger.de>, <j.krieger@dkfz.de>), German Cancer Research Center
This software is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \defgroup jkqtptools Tool Functions and Definitions
* \ingroup jkqtplotter
*/
/** \file jkqtptools.h
* \ingroup jkqtptools
*/
#ifndef JKQTPTOOLS_H_INCLUDED
#define JKQTPTOOLS_H_INCLUDED
#include "jkqtp_imexport.h"
#include <QString>
#include <QElapsedTimer>
#include <QToolBar>
#include <QPainter>
#include <cmath>
#include <cfloat>
#include <QComboBox>
#include <QPrinter>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <time.h>
#include <math.h>
#include <sys/stat.h>
#include <stdint.h>
#include <stdexcept>
#include <cctype>
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#ifndef __WINDOWS__
# if defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)
# define __WINDOWS__
# endif
#endif
#ifndef __LINUX__
# if defined(linux)
# define __LINUX__
# endif
#endif
#undef JKTOOLS_TIMER_USE_TIME
#if defined(__WINDOWS__)
#include<windows.h>
#elif defined(__LINUX__)
#include <sys/time.h>
#else
#define JKTOOLS_TIMER_USE_TIME
#endif
#ifndef __WINDOWS__
# ifndef __LINUX__
# warning("these methods are ment to be used under windows or linux ... no other system were tested")
# endif
#endif
/* This just distinguishes between the different path formats on Windows and Unix:
* - on Windows you use a backslash '\' do separate directories
* - in Unix you use a slash '/' to separate directories
*/
#ifdef __WINDOWS__
/** \brief a separator between two directories in a path between \c " quotes */
#define JKQTPPATHSEPARATOR_STRING "\\"
/** \brief a separator between two directories in a path between \c ' quotes */
#define JKQTPPATHSEPARATOR_CHAR '\\'
#include<windows.h>
#else
/** \brief a separator between two directories in a path between \c " quotes */
#define JKQTPPATHSEPARATOR_STRING "/"
/** \brief a separator between two directories in a path between \c ' quotes */
#define JKQTPPATHSEPARATOR_CHAR '/'
#endif
/**
* \defgroup tools_getset get_var and set_var macros
* \ingroup tools
*
* The macros in this group have the purpose to make writing \c get_<varname>() and \c set_<varname>(<varname>)
* methods for classes easier. They can be used by giving the type and the name of a private variable for which
* \c get_ and \c set_ methods should be created:
* \code
* class a {
* private:
* int var1;
* std::strign var2;
* public:
* GetSetMacro(int, var1);
* JKQTPGetMacro(std::string, var2);
* }
* \endcode
* This code will create a \c set_var1, a \c set_var2 and a \c get_var1 method with the apropriate types.
* All functions will be declared \c virtual and can thus be easily overloaded in inheriting classes. They are also
* declared \c inline so the compiler may optimize them by really inlining them.
*
* The GetSetMacro creates get and set methods while the GetMacro and the SetMacro only create one of the
* both.
*/
/*@{*/
/**
* \brief create get_varname() and set_varname(type __value) methods/functions
* inside a class, where \c type is the type of \c varname and \c varname is a
* previously declared private variable that should be accessed by these
* methodes
*/
#define JKQTPGET_SET_MACRO(type,varname) \
typedef type typedef_set_##varname ;\
/** \brief sets the property varname to the specified \a __value. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER> \see varname for more information */ \
inline virtual void set_##varname (const typedef_set_##varname & __value) \
{ \
this->varname = __value; \
}; \
/** \brief returns the property varname. \see varname for more information */ \
inline virtual type get_##varname () const \
{\
return this->varname; \
};
#define JKQTPGET_SET_VMACRO(type,varname) \
typedef type typedef_set_##varname ;\
/** \brief sets the property varname to the specified \a __value. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER> \see varname for more information */ \
inline virtual void set_##varname (const typedef_set_##varname & __value) \
{ \
this->varname = __value; \
}; \
/** \brief returns the property varname. \see varname for more information */ \
inline virtual type get_##varname () const \
{\
return this->varname; \
};
#define JKQTPGetSetMacro(type,varname) JKQTPGET_SET_MACRO(type,varname)
/**
* \brief create get_varname() and set_varname(type __value) methods/functions
* inside a class, where \c type is the type of \c varname and \c varname is a
* previously declared private variable that should be accessed by these
* methodes. In addition this will set the property paramsChanged to true, which
* you will have to declare in your class.
*/
#define JKQTPGET_SET_MACRO_P(type,varname) \
typedef type typedef_set_##varname ;\
inline virtual void set_##varname (const typedef_set_##varname & __value) /** \brief sets the property varname to the specified \a __value. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER> \see varname for more information */ \
{ \
this->varname = __value; \
this-> paramsChanged=true; \
}; \
inline virtual type get_##varname () const /** \brief returns the property varname. \see varname for more information */ \
{\
return this->varname; \
};
#define JKQTPGetSetMacroP(type,varname) JKQTPGET_SET_MACRO_P(type,varname)
/**
* \brief like GetSetMacroP(), but adds the instruction \a inst to the set method. This may be used
* to update a component after a value has been set.
*/
#define JKQTPGET_SET_MACRO_IP(type,varname,inst) \
typedef type typedef_set_##varname ;\
/** \brief sets the property varname to the specified \a __value. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER> \see varname for more information */ \
inline virtual void set_##varname (const typedef_set_##varname & __value) \
{ \
if (this->varname != __value) { \
this->varname = __value; \
this-> paramsChanged=true; \
inst; \
} \
}; \
/** \brief returns the property varname. \see varname for more information */ \
inline virtual type get_##varname () const \
{ \
return this->varname; \
};
#define JKQTPGetSetMacroIP(type,varname,inst) JKQTPGET_SET_MACRO_IP(type,varname,inst)
/**
* \brief like GetSetMacro(), but adds the instruction \a inst to the set method. This may be used
* to update a component after a value has been set.
*/
#define JKQTPGET_SET_MACRO_I(type,varname,inst) \
typedef type typedef_set_##varname ;\
/** \brief sets the property varname to the specified \a __value. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER> \see varname for more information */ \
inline virtual void set_##varname (const typedef_set_##varname & __value) \
{\
if (this->varname != __value) { \
this->varname = __value; \
inst; \
} \
}; \
/** \brief returns the property varname. \see varname for more information */ \
inline virtual type get_##varname () const \
{\
return this->varname; \
};
#define JKQTPGetSetMacroI(type,varname,inst) JKQTPGET_SET_MACRO_I(type,varname,inst)
/**
* \brief sets two given properties at the same time, i.e. with one setter function with the name <code>set_<name>(type __value, type2 __value2)</code>. The getter methods are still separate. This may be used
* to update a component after a value has been set.
*/
#define JKQTPGET_SET_MACRO_TWO(name,type,varname,type2,varname2) \
/** \brief sets the properties varname and varname2 to the specified \a __value and \a __value2. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER> \details Description of the parameter varname2 is: <CENTER>\copybrief varname2.</CENTER> \see varname and varname2 for more information */ \
inline virtual void set_##name (type __value, type2 __value2) \
{\
bool set=false; \
if (this->varname != __value) { \
this->varname = __value; \
} \
if (this->varname2 != __value2) { \
this->varname2 = __value2; \
} \
}; \
/** \brief returns the property varname. \see varname for more information */ \
inline virtual type get_##varname () const \
{\
return this->varname; \
}; \
/** \brief returns the property varname2. \see varname2 for more information */\
inline virtual type2 get_##varname2 () const \
{\
return this->varname2; \
};
#define JKQTPGetSetMacroTwo(name,type,varname,type2,varname2) JKQTPGET_SET_MACRO_TWO(name,type,varname,type2,varname2)
/**
* \brief like GetSetMacroTwo(), but adds the instruction \a inst to the set method. This may be used
* to update a component after a value has been set.
*/
#define JKQTPGET_SET_MACRO_TWO_I(name,type,varname,type2,varname2,inst) \
/** \brief sets the properties varname and varname2 to the specified \a __value and \a __value2. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER> \details Description of the parameter varname2 is: <CENTER>\copybrief varname2.</CENTER> \see varname and varname2 for more information */ \
inline virtual void set_##name (type __value, type2 __value2) \
{\
bool set=false; \
if (this->varname != __value) { \
this->varname = __value; \
set=true; \
} \
if (this->varname2 != __value2) { \
this->varname2 = __value2; \
set=true; \
} \
if (set) { \
inst; \
} \
}; \
/** \brief returns the property varname. \see varname for more information */ \
inline virtual type get_##varname () const \
{\
return this->varname; \
}; \
/** \brief returns the property varname2. \see varname2 for more information */ \
inline virtual type2 get_##varname2 () const \
{\
return this->varname2; \
};
#define JKQTPGetSetMacroTwoI(name,type,varname,type2,varname2,inst) JKQTPGET_SET_MACRO_TWO_I(name,type,varname,type2,varname2,inst)
/**
* \brief like GetSetMacro(), but adds the instruction \a inst to the set method. This may be used
* to update a component after a value has been set. Alwys updates (no comparison of current
* and former value
*/
#define JKQTPGET_SET_MACRO_INC(type,varname,inst) \
typedef type typedef_set_##varname ;\
/** \brief sets the property varname to the specified \a __value. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER> \see varname for more information */ \
inline virtual void set_##varname (typedef_set_##varnam __value) \
{\
this->varname = __value; \
inst; \
}; \
/** \brief returns the property varname. \see varname for more information */ \
inline virtual type get_##varname () const \
{\
return this->varname; \
};
#define JKQTPGetSetMacroINC(type,varname,inst) JKQTPGET_SET_MACRO_INC(type,varname,inst)
/** \brief create get_varname() and set_varname(type __value) methods/functions
* inside a class, where \c type is the type of \c varname and \c varname is a
* previously declared private variable that should be accessed by these
* methodes
*/
#define JKQTPGET_MACRO(type,varname) \
/** \brief returns the property varname. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER>. \see varname for more information */ \
inline virtual type get_##varname() const \
{ return this->varname; };
#define JKQTPGetMacro(type,varname) JKQTPGET_MACRO(type,varname)
/**
* \brief create set_varname(type __value) methods/functions
* inside a class, where \c type is the type of \c varname and \c varname is a
* previously declared private variable that should be accessed by these
* methodes
*/
#define JKQTPSET_MACRO(type,varname) \
typedef type typedef_set_##varname ;\
/** \brief sets the property varname to the specified \a __value. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER> \see varname for more information */ \
inline virtual void set_##varname (const typedef_set_##varname & __value) \
{ \
this->varname = __value; \
};
#define JKQTPSetMacro(type,varname) JKQTPSET_MACRO(type,varname)
/**
* \brief create set_varname(type __value) methods/functions
* inside a class, where \c type is the type of \c varname and \c varname is a
* previously declared private variable that should be accessed by these
* methodes. In addition this will set the property paramsChanged to true, which
* you will have to declare in your class.
*/
#define JKQTPSET_MACRO_P(type,varname) \
typedef type typedef_set_##varname ;\
/** \brief sets the property varname to the specified \a __value. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER> \see varname for more information */ \
inline virtual void set_##varname (const typedef_set_##varname & __value) \
{ \
if (this->varname != __value) { \
this->varname = __value; \
this->paramsChanged=true; \
} \
};
#define JKQTPSetMacroP(type,varname) JKQTPSET_MACRO_P(type,varname)
/**
* \brief like SetMacro(), but adds the instruction \a inst to the set method. This may be used
* to update a component after a value has been set
*/
#define JKQTPSET_MACRO_I(type,varname,inst) \
typedef type typedef_set_##varname ;\
/** \brief sets the property varname to the specified \a __value. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER> \see varname for more information */ \
inline virtual void set_##varname(const typedef_set_##varname & __value) \
{ \
if (this->varname != __value) { \
this->varname = __value; \
inst; \
} \
};
#define JKQTPSetMacroI(type,varname,inst) JKQTPSET_MACRO_I(type,varname,inst)
/**
* \brief like SetMacro(), but adds the instruction \a inst at the start of the set method. This may be used
* e.g. to lock a mutex in the set operation, e.g. using QMutexLocker locker(mutex); from Qt
*/
#define JKQTPSET_MACRO_I_BEFORE(type,varname,inst) \
typedef type typedef_set_##varname ;\
/** \brief sets the property varname to the specified \a __value. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER> \see varname for more information */ \
inline virtual void set_##varname(const typedef_set_##varname & __value) \
{ \
inst; \
if (this->varname != __value) { \
this->varname = __value; \
} \
};
#define JKQTPSetMacroIBefore(type,varname,inst) JKQTPSET_MACRO_I_BEFORE(type,varname,inst)
/**
* \brief like SetMacroP(), but adds the instruction \a inst to the set method. This may be used
* to update a component after a value has been set
*/
#define JKQTPSET_MACRO_IP(type,varname,inst) \
typedef type typedef_set_##varname ;\
/** \brief sets the property varname to the specified \a __value. \details Description of the parameter varname is: <CENTER>\copybrief varname.</CENTER> \see varname for more information */ \
inline virtual void set_##varname (const typedef_set_##varname & __value) \
{ \
if (this->varname != __value) { \
this->varname = __value; \
this->paramsChanged=true; \
inst; \
} \
};
#define JKQTPSetMacroIP(type,varname,inst) JKQTPSET_MACRO_IP(type,varname,inst)
/*@}*/
/** \defgroup tools_files filesystem and file I/O
* \ingroup tools
*/
/** \defgroup tools_streams C++ stream tools
* \ingroup tools_files
*/
/*@{*/
class JKQTPEnhancedPainter; // forward
#define JKQTPLOTTER_ABS_MIN_LINEWIDTH 0.02
/** \brief check whether the dlotaing point number is OK (i.e. non-inf, non-NAN)
* \ingroup jkqtptools
*/
#define JKQTPIsOKFloat(v) (std::isfinite(v)&&(!std::isinf(v))&&(!std::isnan(v)))
/** \brief converts a QColor into a string using the jkqtp_rgbtostring() method.
* \ingroup jkqtptools
*
* 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((color).red(), (color).green(), (color).blue(), (color).alpha()).c_str())
/** \brief converts a QT::PenStyle into a string
* \ingroup jkqtptools
*/
LIB_EXPORT QString QPenStyle2String(Qt::PenStyle style);
/** \brief converts a QString into a Qt::PenStyle
* \ingroup jkqtptools
*/
LIB_EXPORT Qt::PenStyle String2QPenStyle(QString style);
/** \brief converts a QT::BrushStyle into a string
* \ingroup jkqtptools
*/
LIB_EXPORT QString QBrushStyle2String(Qt::BrushStyle style);
/** \brief converts a QString into a Qt::BrushStyle
* \ingroup jkqtptools
*/
LIB_EXPORT Qt::BrushStyle String2QBrushStyle(QString style);
class JKQtBasePlotter; // forward declaration
/** \brief display mode for an axis
* \ingroup jkqtptools */
enum JKQTPCAdrawMode {
JKQTPCADMcomplete=0, /*!< \brief draw axis with ticks, ticklabels and axis label */
JKQTPCADMticksAndLabels, /*!< \brief draw axis with ticks and tick labels */
JKQTPCADMticks, /*!< \brief draw axis with ticks */
JKQTPCADMline, /*!< \brief draw axis as thick line */
JKQTPCADMnone /*!< \brief draw no axis */
};
/*! \brief a QComboBox which shows JKQTPCAdrawMode
\ingroup jkqtptools
*/
class LIB_EXPORT JKQTPCAdrawModeComboBox: public QComboBox {
Q_OBJECT
public:
JKQTPCAdrawModeComboBox(QWidget* parent=NULL);
JKQTPCAdrawMode getDrawMode() const;
void setDrawMode(JKQTPCAdrawMode position);
protected:
void addDrawMode(JKQTPCAdrawMode position, const QString& name, const QIcon& icon=QIcon());
};
/** \brief converts a JKQTPCAdrawMode variable into a human-readable string
* \ingroup jkqtptools
*/
LIB_EXPORT QString JKQTPCAdrawMode2String(JKQTPCAdrawMode pos);
/** \brief converts a string into a JKQTPCAdrawMode
* \ingroup jkqtptools
*/
LIB_EXPORT JKQTPCAdrawMode String2JKQTPCAdrawMode(QString pos);
/** \brief display mode for the axis labels
* \ingroup jkqtptools */
enum JKQTPCAlabelType {
JKQTPCALTdefault, /*!< \brief simply print the numbers */
JKQTPCALTexponentCharacter, /*!< \brief print the numbers and show a unit character, i.e. \c 5µ for \f$ 5\cdot10^{-6} \f$ , \cd 3k for \f$ 3\cdot10^3 \f$ ... */
JKQTPCALTexponent, /*!< \brief show numbers in exponential for, e.g. \f$ 3\cdot10^5 \f$ ... */
JKQTPCALTdate, /*!< \brief show numbers as dates */
JKQTPCALTtime, /*!< \brief show numbers as times */
JKQTPCALTdatetime, /*!< \brief show numbers as times */
};
/** \brief mode of the axis ticks
* \ingroup jkqtptools */
enum JKQTPLabelTickMode {
JKQTPLTMLinOrPower=0, /*!< \brief linear, or log, depending on whether the axis is log */
JKQTPLTMLin, /*!< \brief always linear (even for log-axes) */
JKQTPLTMPower, /*!< \brief powers (of the log-base) */
};
/** \brief converts a JKQTPLabelTickMode variable into a human-readable string
* \ingroup jkqtptools
*/
LIB_EXPORT QString JKQTPLabelTickMode2String(JKQTPLabelTickMode pos);
/** \brief converts a string into a JKQTPLabelTickMode
* \ingroup jkqtptools
*/
LIB_EXPORT JKQTPLabelTickMode String2JKQTPLabelTickMode(QString pos);
/*! \brief a QComboBox which shows JKQTPCAlabelType
\ingroup jkqtptools
*/
class LIB_EXPORT JKQTPCAlabelTypeComboBox: public QComboBox {
Q_OBJECT
public:
JKQTPCAlabelTypeComboBox(QWidget* parent=NULL);
JKQTPCAlabelType getLabelType() const;
void setLabelType(JKQTPCAlabelType position);
protected:
void addLabelType(JKQTPCAlabelType position, const QString& name, const QIcon& icon=QIcon());
};
/** \brief converts a JKQTPCAlabelType variable into a human-readable string
* \ingroup jkqtptools
*/
LIB_EXPORT QString JKQTPCAlabelType2String(JKQTPCAlabelType pos);
/** \brief converts a string into a JKQTPCAlabelType
* \ingroup jkqtptools
*/
LIB_EXPORT JKQTPCAlabelType String2JKQTPCAlabelType(QString pos);
/** \brief position of the axis labels
* \ingroup jkqtptools
*/
enum JKQTPlabelPosition {
JKQTPlabelMin=0, /*!< \brief the axis label is near the min value of the axis (left/bottom) */
JKQTPlabelMax, /*!< \brief the axis label is near the max value of the axis (right/top) */
JKQTPlabelCenter /*!< \brief the label is at the center of the axis */
};
/*! \brief a QComboBox which shows JKQTPlabelPosition
\ingroup jkqtptools
*/
class LIB_EXPORT JKQTPlabelPositionComboBox: public QComboBox {
Q_OBJECT
public:
JKQTPlabelPositionComboBox(QWidget* parent=NULL);
JKQTPlabelPosition getPosition() const;
void setPosition(JKQTPlabelPosition position);
protected:
void addPosition(JKQTPlabelPosition position, const QString& name, const QIcon& icon=QIcon());
};
/** \brief converts a JKQTPlabelPosition variable into a human-readable string
* \ingroup jkqtptools
*/
LIB_EXPORT QString JKQTPlabelPosition2String(JKQTPlabelPosition pos);
/** \brief converts a string into a JKQTPlabelPosition
* \ingroup jkqtptools
*/
LIB_EXPORT JKQTPlabelPosition String2JKQTPlabelPosition(QString pos);
/** \brief position of the key
* \ingroup jkqtptools
*/
enum JKQTPkeyPosition {
JKQTPkeyOutsideTopRight=0, /*!< \brief the key is positioned on the right side of the graph */
JKQTPkeyOutsideTopLeft, /*!< \brief the key is positioned on the left side of the graph */
JKQTPkeyOutsideLeftTop, /*!< \brief the key is positioned above the graph */
JKQTPkeyOutsideLeftBottom, /*!< \brief the key is positioned below the graph */
JKQTPkeyOutsideRightBottom, /*!< \brief the key is positioned on the right side of the graph */
JKQTPkeyOutsideRightTop, /*!< \brief the key is positioned on the left side of the graph */
JKQTPkeyOutsideBottomLeft, /*!< \brief the key is positioned above the graph */
JKQTPkeyOutsideBottomRight, /*!< \brief the key is positioned below the graph */
JKQTPkeyInsideTopRight, /*!< \brief the key is positioned inside on the right side of the graph, but inside the graph*/
JKQTPkeyInsideTopLeft, /*!< \brief the key is positioned inside on the left side of the graph */
JKQTPkeyInsideBottomLeft, /*!< \brief the key is positioned inside on the upper bound of the graph */
JKQTPkeyInsideBottomRight /*!< \brief the key is positioned inside on the lower bound of the graph */
};
/*! \brief a QComboBox which shows JKQTPkeyPosition
\ingroup jkqtptools
*/
class LIB_EXPORT JKQTPkeyPositionComboBox: public QComboBox {
Q_OBJECT
public:
JKQTPkeyPositionComboBox(QWidget* parent=NULL);
JKQTPkeyPosition getPosition() const;
void setPosition(JKQTPkeyPosition position);
signals:
void currentPositionChanged(JKQTPkeyPosition pos);
protected:
void addPosition(JKQTPkeyPosition position, const QString& name, const QIcon& icon=QIcon());
protected slots:
void posChanged(int index);
};
/** \brief converts a JKQTPlabelPosition variable into a human-readable string
* \ingroup jkqtptools
*/
LIB_EXPORT QString JKQTPkeyPosition2String(JKQTPkeyPosition pos);
/** \brief converts a string into a JKQTPlabelPosition
* \ingroup jkqtptools
*/
LIB_EXPORT JKQTPkeyPosition String2JKQTPkeyPosition(QString pos);
/** \brief layout of the key
* \ingroup jkqtptools
*/
enum JKQTPkeyLayout {
JKQTPkeyLayoutOneColumn, /*!< \brief the key consists of one column */
JKQTPkeyLayoutOneRow, /*!< \brief the key consists of one row */
JKQTPkeyLayoutMultiColumn, /*!< \brief the key consists of multiple columns */
};
/*! \brief a QComboBox which shows JKQTPkeyPosition
\ingroup jkqtptools
*/
class LIB_EXPORT JKQTPkeyLayoutComboBox: public QComboBox {
Q_OBJECT
public:
JKQTPkeyLayoutComboBox(QWidget* parent=NULL);
JKQTPkeyLayout getKeyLayout() const;
void setKeyLayout(JKQTPkeyLayout layout);
signals:
void currentLayoutChanged(JKQTPkeyLayout layout);
protected:
void addKeyLayout(JKQTPkeyLayout layout, const QString& name);
protected slots:
void currentIndexChangedP(int index);
};
/** \brief converts a JKQTPkeyLayout variable into a human-readable string
* \ingroup jkqtptools
*/
LIB_EXPORT QString JKQTPkeyLayout2String(JKQTPkeyLayout pos);
/** \brief converts a String into a JKQTPkeyLayout
* \ingroup jkqtptools
*/
LIB_EXPORT JKQTPkeyLayout String2JKQTPkeyLayout(QString pos);
/** \brief used to represent the position of other graphs in \ref jkqtplotter_base_saveprint
* \ingroup jkqtptools
*/
typedef struct {
size_t x;
size_t y;
JKQtBasePlotter* plotter;
} JKQTPgridPrintingItem;
/** \brief a modified a href="http://doc.trolltech.com/4.5/qtoolbar.html">QToolBar</a> which vanishes when the mouse leaves the toolbar.
* \ingroup jkqtptools
*/
class LIB_EXPORT JKVanishQToolBar: public QToolBar {
Q_OBJECT
public:
/** \brief class constructor */
JKVanishQToolBar(const QString& title, QWidget* parent=0): QToolBar(title, parent) {
toolbarVanishes=true;
};
/** \brief class constructor */
JKVanishQToolBar(QWidget* parent=0): QToolBar(parent){
toolbarVanishes=true;
};
JKQTPGetSetMacro(bool, toolbarVanishes)
protected:
bool toolbarVanishes;
/** \brief this event triggers the vanishing of the toolbar */
void leaveEvent ( QEvent * /*event*/ ) {
if (toolbarVanishes) hide();
};
};
/**
* \brief create a property variable and a default variable for it. Also creates a doxygen comment for the default variable
* \ingroup jkqtptools
*/
#define JKQTPPROPERTY(type,varname) \
type varname; \
/** \brief default value for property property varname. \see varname for more information */ \
type def_##varname;
/**
* \brief saves the given property (for which also a def_property exists) into the given settings object
* \ingroup jkqtptools
*/
#define JKQTPPROPERTYsave(settings, group, var, varname) \
if (var!=def_##var) settings.setValue(group+varname, var);
/**
* \brief loads the given property from the given settings object
* \ingroup jkqtptools
*/
#define JKQTPPROPERTYload(settings, group, var, varname, varconvert) \
var=settings.value(group+varname, var).varconvert;
/** \brief plot styles for the error information
* \ingroup jkqtplotter
*/
enum JKQTPerrorPlotstyle {
JKQTPerrorEllipses=10, /*!< \brief an ellipse spanned by the errors */
JKQTPerrorBoxes=9, /*!< \brief a box spanned by the errors */
JKQTPerrorSimpleBarsPolygons=8, /*!< \brief simplified error barsand polygons for each data point */
JKQTPerrorSimpleBarsLines=7, /*!< \brief simplified error bars and line for each data point */
JKQTPerrorSimpleBars=6, /*!< \brief simplified error bars for each data point */
JKQTPerrorLines=5, /*!< \brief a second and third graph line above and below the actual data which indicates the error value */
JKQTPerrorBars=4, /*!< \brief error bars for each data point */
JKQTPerrorPolygons=3, /*!< \brief line error lines, but with filled range in between */
JKQTPerrorBarsLines=2, /*!< \brief error bars and lines for each data point */
JKQTPerrorBarsPolygons=1, /*!< \brief error bars and polygons for each data point */
JKQTPnoError=0 /*!< \brief don't show error information */
};
/*! \brief a QComboBox which shows JKQTPerrorPlotstyle
\ingroup jkqtptools
*/
class LIB_EXPORT JKQTPerrorPlotstyleComboBox: public QComboBox {
Q_OBJECT
public:
JKQTPerrorPlotstyleComboBox(QWidget* parent=NULL);
JKQTPerrorPlotstyle getErrorStyle() const;
void setSymbol(JKQTPerrorPlotstyle symbol);
void setCurrentErrorStyle(JKQTPerrorPlotstyle symbol);
protected:
void addSymbol(JKQTPerrorPlotstyle symbol, const QString& name, const QIcon &icon=QIcon());
};
/** \brief converts a JKQTPerrorPlotstyle variable into a human-readable string
* \ingroup jkqtptools
*/
LIB_EXPORT QString JKQTPerrorPlotstyle2String(JKQTPerrorPlotstyle pos);
/** \brief converts a String into a JKQTPerrorPlotstyle
* \ingroup jkqtptools
*/
LIB_EXPORT JKQTPerrorPlotstyle String2JKQTPerrorPlotstyle(QString pos);
/** \brief plot styles for a graph
* \ingroup jkqtplotter
*/
enum JKQTPgraphPlotstyle {
JKQTPlines, /*!< \brief plot y=f(x), connect the datapoints by straight lines */
JKQTPfilledCurveX, /*!< \brief plot y=f(x), as filled curve (filled until the y=0/x-axis) */
JKQTPfilledCurveY, /*!< \brief plot x=f(y), as filled curve (filled until the x=0/y-axis) */
JKQTPpoints, /*!< \brief plot y=f(x), plot each datapoint with a symbol */
JKQTPlinesPoints, /*!< \brief plot y=f(x), plot each datapoint with a symbol and connect them by straight lines */
JKQTPimpulsesHorizontal, /*!< \brief plot y=f(x), plot each datapoint as a line from (x,0) to (x,f(x)) */
JKQTPimpulsesVertical, /*!< \brief plot x=f(y), plot each datapoint as a line from (0,f(x)) to (x,f(x)) */
JKQTPstepsX, /*!< \brief plot y=f(x), as a step curve */
JKQTPstepsY /*!< \brief plot x=f(y), as a step curve */
};
/** \brief symbols that can be used to plot a datapoint for a graph
* \ingroup jkqtplotter
*/
enum JKQTPgraphSymbols {
JKQTPnoSymbol=0, /*!< \brief plots no symbol at all (usefull together with error bars) */
JKQTPdot=1, /*!< \brief a small dot */
JKQTPcross=2, /*!< \brief a X cross */
JKQTPplus=3, /*!< \brief a + cross */
JKQTPcircle=4, /*!< \brief an unfilled circle */
JKQTPfilledCircle=5, /*!< \brief a filled circle */
JKQTPrect=6, /*!< \brief an unfilled rectangle */
JKQTPfilledRect=7, /*!< \brief a filled rectangle */
JKQTPtriangle=8, /*!< \brief an unfilled triangle (tip at top) */
JKQTPfilledTriangle=9, /*!< \brief a filled triangle (tip at top) */
JKQTPdownTriangle=10, /*!< \brief an unfilled triangle (tip at bottom) */
JKQTPfilledDownTriangle=11, /*!< \brief a filled triangle (tip at bottom) */
JKQTPdiamond=12, /*!< \brief an unfilled diamond */
JKQTPfilledDiamond=13, /*!< \brief a filled diamond */
JKQTPstar=14, /*!< \brief an unfilled diamond */
JKQTPfilledStar=15, /*!< \brief a filled diamond */
JKQTPpentagon=16, /*!< \brief an unfilled pentagon */
JKQTPfilledPentagon=17, /*!< \brief a filled pentagon */
JKQTPasterisc=18, /*!< \brief an asterisc star '*' */
JKQTPtarget=19, /*!< \brief a target symbol (circle with cross) */
JKQTPmaxSymbolID=JKQTPtarget
};
/** \brief converts a JKQTPgraphSymbols variable into a identifier string
* \ingroup jkqtptools
*/
LIB_EXPORT QString JKQTPgraphSymbols2String(JKQTPgraphSymbols pos);
/** \brief converts a JKQTPgraphSymbols variable into a human-readable string
* \ingroup jkqtptools
*/
LIB_EXPORT QString JKQTPgraphSymbols2NameString(JKQTPgraphSymbols pos);
/** \brief converts a String into a JKQTPgraphSymbols
* \ingroup jkqtptools
*/
LIB_EXPORT JKQTPgraphSymbols String2JKQTPgraphSymbols(QString pos);
/*! \brief a QComboBox which shows JKQTPgraphSymbols
\ingroup jkqtptools
*/
class LIB_EXPORT JKQTPSymbolComboBox: public QComboBox {
Q_OBJECT
public:
JKQTPSymbolComboBox(QWidget* parent=NULL);
JKQTPgraphSymbols getSymbol() const;
void setSymbol(JKQTPgraphSymbols symbol);
void setCurrentSymbol(JKQTPgraphSymbols symbol);
protected:
void addSymbol(JKQTPgraphSymbols symbol, const QString& name);
};
/*! \brief a QComboBox to select whether a line, symbols or both should be displayed
\ingroup jkqtptools
*/
class LIB_EXPORT JKQTPLinePlotStyleComboBox: public QComboBox {
Q_OBJECT
public:
JKQTPLinePlotStyleComboBox(QWidget* parent=NULL);
void setDefaultSymbol(JKQTPgraphSymbols symbol);
void addUsedSymbol(JKQTPgraphSymbols symbol);
JKQTPgraphSymbols getSymbol() const;
bool getDrawLine() const;
protected:
void refill();
void addSymbol(JKQTPgraphSymbols symbol, bool line, const QString& name=QString(""), const QVariant& data=QVariant());
QList<JKQTPgraphSymbols> symbols;
JKQTPgraphSymbols defaultSymbol;
};
/*! \brief a QComboBox to select whether a line, symbols or both should be displayed, in addition to JKQTPLinePlotStyleComboBox this may also have different symbol sizes!
\ingroup jkqtptools
*/
class LIB_EXPORT JKQTPLinePlotStyleWithSymbolSizeComboBox: public QComboBox {
Q_OBJECT
public:
JKQTPLinePlotStyleWithSymbolSizeComboBox(QWidget* parent=NULL);
void setDefaultSymbol(JKQTPgraphSymbols symbol, double size);
void addUsedSymbol(JKQTPgraphSymbols symbol, double symbolSize, bool line);
JKQTPgraphSymbols getSymbol() const;
bool getDrawLine() const;
double getSymbolSize() const;
protected:
void refill();
void addSymbol(JKQTPgraphSymbols symbol, bool line, double symbolSize, const QString& name=QString(""), const QVariant& data=QVariant());
struct styleData {
JKQTPgraphSymbols symbol;
bool line;
double symbolSize;
bool operator==(const styleData& other)const;
};
QList<styleData> symbols;
JKQTPgraphSymbols defaultSymbol;
double defaultSize;
};
/*! \brief plot the specified symbol at pixel position x,y
\ingroup jkqtptools
\param painter the QPainter to draw to
\param x x-coordinate of the symbol center
\param y y-coordinate of the symbol center
\param symbol type of the symbol to plot, see JKQTPgraphSymbols
\param size size (width/height) of the symbol around (\a x , \a y)
\param symbolLineWidth width of the lines used to draw the symbol
\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);
/*! \brief plot the specified symbol at pixel position x,y
\ingroup jkqtptools
\param paintDevice the paint device to draw on
\param x x-coordinate of the symbol center
\param y y-coordinate of the symbol center
\param symbol type of the symbol to plot, see JKQTPgraphSymbols
\param size size (width/height) of the symbol around (\a x , \a y)
\param symbolLineWidth width of the lines used to draw the symbol
\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);
/*! \brief plot an arrow between positions (x1,y1) and (x2,y2)
\ingroup jkqtptools
\param painter the QPainter to draw to
\param x1 first x-coordinate of the arrow
\param y1 first y-coordinate of the arrow
\param x2 second x-coordinate of the arrow
\param y2 second y-coordinate of the arrow
\param symbol type of the symbol to plot, see JKQTPgraphSymbols
\param size size (width/height) of the symbol around (\a x , \a y)
\param symbolLineWidth width of the lines used to draw the symbol
\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);
/*! \brief draw an ellipse without setting pen or brush, or saving the painter!
\ingroup jkqtptools
\return a QVector<QPointF> with points that may be used for drawing
\param x center of ellipse (x-coordinate)
\param y center of ellipse (y-coordinate)
\param a half axis in x-direction
\param b half axis in y-direction
\param angle_start starting angle of ellipse section
\param angle_end ending angle of ellipse section
\param alpha rotation angle of ellipse
\param controlPoints the number of points to use for drawing
\param[out] x_start first point of ellipse
\param[out] x_end last point of ellipse
\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=NULL, QPointF* x_end=NULL);
#include <QDoubleSpinBox>
/*! \brief enhanced QDoubleSpinBox
\ingroup jkqtptools
*/
class LIB_EXPORT JKQTPEnhancedDoubleSpinBox : public QDoubleSpinBox {
Q_OBJECT
public:
JKQTPEnhancedDoubleSpinBox(QWidget* parent=NULL);
~JKQTPEnhancedDoubleSpinBox();
signals:
void editingFinished(double value);
protected slots:
void intEditingFinished();
};
#include <QSpinBox>
/*! \brief enhanced QDoubleSpinBox
\ingroup jkqtptools
*/
class LIB_EXPORT JKQTPEnhancedSpinBox : public QSpinBox {
Q_OBJECT
public:
JKQTPEnhancedSpinBox(QWidget* parent=NULL);
~JKQTPEnhancedSpinBox();
signals:
void editingFinished(int value);
protected slots:
void intEditingFinished();
};
inline QString JKQTPCDoubleToQString(double value) {
QLocale loc=QLocale::c();