Engauge Digitizer 2
Loading...
Searching...
No Matches
DlgValidatorFactory.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
11#include "DlgValidatorFactory.h"
12#include "DlgValidatorNumber.h"
13#include "Logger.h"
14#include <QLocale>
15
17{
18 LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::DlgValidatorFactory";
19}
20
22{
23 return new DlgValidatorAboveZero (locale);
24}
25
27 bool isCartesian,
28 CoordUnitsNonPolarTheta coordUnitsCartesian,
29 CoordUnitsNonPolarTheta coordUnitsPolar,
30 CoordUnitsDate coordUnitsDate,
31 CoordUnitsTime coordUnitsTime,
32 const QLocale &locale) const
33{
34 LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::createCartesianOrPolarWithNonPolarPolar";
35
36 if (isCartesian) {
37 return createWithNonPolar (coordScale,
38 coordUnitsCartesian,
39 coordUnitsDate,
40 coordUnitsTime,
41 locale);
42 } else {
43 return createWithNonPolar (coordScale,
44 coordUnitsPolar,
45 coordUnitsDate,
46 coordUnitsTime,
47 locale);
48 }
49}
50
52 bool isCartesian,
53 CoordUnitsNonPolarTheta coordUnitsCartesian,
54 CoordUnitsPolarTheta coordUnitsPolar,
55 CoordUnitsDate coordUnitsDate,
56 CoordUnitsTime coordUnitsTime,
57 const QLocale &locale) const
58{
59 LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::createCartesianOrPolarWithPolarPolar";
60
61 if (isCartesian) {
62 return createWithNonPolar (coordScale,
63 coordUnitsCartesian,
64 coordUnitsDate,
65 coordUnitsTime,
66 locale);
67 } else {
68 return createWithPolar (coordScale,
69 coordUnitsPolar,
70 locale);
71 }
72}
73
75 CoordUnitsNonPolarTheta coordUnits,
76 CoordUnitsDate coordUnitsDate,
77 CoordUnitsTime coordUnitsTime,
78 const QLocale &locale) const
79{
80 LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::createWithNonPolar";
81
82 switch (coordUnits) {
84 return new DlgValidatorDateTime (coordScale,
85 coordUnitsDate,
86 coordUnitsTime);
87
89 return new DlgValidatorDegreesMinutesSeconds (coordScale);
90
92 return new DlgValidatorNumber(coordScale,
93 locale);
94
95 default:
96 LOG4CPP_ERROR_S ((*mainCat)) << "DlgValidatorFactory::createWithNonPolar";
97 exit (-1);
98 }
99}
100
102 CoordUnitsPolarTheta coordUnits,
103 const QLocale &locale) const
104{
105 LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::createWithPolar";
106
107 switch (coordUnits) {
112 return new DlgValidatorDegreesMinutesSeconds (coordScale);
113
117 return new DlgValidatorNumber (coordScale,
118 locale);
119
120 default:
121 LOG4CPP_ERROR_S ((*mainCat)) << "DlgValidatorFactory::createWithNonPolar";
122 exit (-1);
123 }
124}
CoordScale
Definition CoordScale.h:12
CoordUnitsDate
CoordUnitsNonPolarTheta
@ COORD_UNITS_NON_POLAR_THETA_DEGREES_MINUTES_SECONDS
@ COORD_UNITS_NON_POLAR_THETA_NUMBER
@ COORD_UNITS_NON_POLAR_THETA_DATE_TIME
CoordUnitsPolarTheta
@ COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW
@ COORD_UNITS_POLAR_THETA_TURNS
@ COORD_UNITS_POLAR_THETA_RADIANS
@ COORD_UNITS_POLAR_THETA_DEGREES_MINUTES
@ COORD_UNITS_POLAR_THETA_DEGREES
@ COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS
@ COORD_UNITS_POLAR_THETA_GRADIANS
CoordUnitsTime
log4cpp::Category * mainCat
Definition Logger.cpp:14
Validator for generic (=simple) numbers that must be greater than zero.
Abstract validator for all numeric formats.
Validator for numeric value expressed as date and/or time.
Validator for angles in real degrees, integer degrees and real minutes, or integer degrees with integ...
DlgValidatorAbstract * createCartesianOrPolarWithPolarPolar(CoordScale coordScale, bool isCartesian, CoordUnitsNonPolarTheta coordUnitsCartesian, CoordUnitsPolarTheta coordUnitsPolar, CoordUnitsDate coordUnitsDate, CoordUnitsTime coordUnitsTime, const QLocale &locale) const
Factory method for generating validators for either cartesian or polar case, when polar format is spe...
DlgValidatorAbstract * createWithNonPolar(CoordScale coordScale, CoordUnitsNonPolarTheta coordUnits, CoordUnitsDate coordUnitsDate, CoordUnitsTime coordUnitsTime, const QLocale &locale) const
Factory method for generating validators when cartesian/polar case handling is handled externally,...
DlgValidatorAbstract * createAboveZero(const QLocale &locale) const
Factory method for generating validators for scale length which must be a number greater than zero.
DlgValidatorFactory()
Single constructor.
DlgValidatorAbstract * createWithPolar(CoordScale coordScale, CoordUnitsPolarTheta coordUnits, const QLocale &locale) const
Factory method for generating validators when cartesian/polar case handling is handled externally,...
DlgValidatorAbstract * createCartesianOrPolarWithNonPolarPolar(CoordScale coordScale, bool isCartesian, CoordUnitsNonPolarTheta coordUnitsCartesian, CoordUnitsNonPolarTheta coordUnitsPolar, CoordUnitsDate coordUnitsDate, CoordUnitsTime coordUnitsTime, const QLocale &locale) const
Factory method for generating validators for either cartesian or polar case, when polar format is spe...
Validator for generic (=simple) numbers.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18
#define LOG4CPP_ERROR_S(logger)
Definition convenience.h:12