Engauge Digitizer  2
DlgValidatorFactory.cpp
1 #include "DlgValidatorAbstract.h"
2 #include "DlgValidatorDateTime.h"
3 #include "DlgValidatorDegreesMinutesSeconds.h"
4 #include "DlgValidatorFactory.h"
5 #include "DlgValidatorNumber.h"
6 #include "Logger.h"
7 #include <QLocale>
8 
10 {
11  LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::DlgValidatorFactory";
12 }
13 
15  bool isCartesian,
16  CoordUnitsNonPolarTheta coordUnitsCartesian,
17  CoordUnitsNonPolarTheta coordUnitsPolar,
18  CoordUnitsDate coordUnitsDate,
19  CoordUnitsTime coordUnitsTime,
20  const QLocale &locale) const
21 {
22  LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::createCartesianOrPolarWithNonPolarPolar";
23 
24  if (isCartesian) {
25  return createWithNonPolar (coordScale,
26  coordUnitsCartesian,
27  coordUnitsDate,
28  coordUnitsTime,
29  locale);
30  } else {
31  return createWithNonPolar (coordScale,
32  coordUnitsPolar,
33  coordUnitsDate,
34  coordUnitsTime,
35  locale);
36  }
37 }
38 
40  bool isCartesian,
41  CoordUnitsNonPolarTheta coordUnitsCartesian,
42  CoordUnitsPolarTheta coordUnitsPolar,
43  CoordUnitsDate coordUnitsDate,
44  CoordUnitsTime coordUnitsTime,
45  const QLocale &locale) const
46 {
47  LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::createCartesianOrPolarWithPolarPolar";
48 
49  if (isCartesian) {
50  return createWithNonPolar (coordScale,
51  coordUnitsCartesian,
52  coordUnitsDate,
53  coordUnitsTime,
54  locale);
55  } else {
56  return createWithPolar (coordScale,
57  coordUnitsPolar,
58  locale);
59  }
60 }
61 
63  CoordUnitsNonPolarTheta coordUnits,
64  CoordUnitsDate coordUnitsDate,
65  CoordUnitsTime coordUnitsTime,
66  const QLocale &locale) const
67 {
68  LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::createWithNonPolar";
69 
70  switch (coordUnits) {
71  case COORD_UNITS_NON_POLAR_THETA_DATE_TIME:
72  return new DlgValidatorDateTime (coordScale,
73  coordUnitsDate,
74  coordUnitsTime);
75 
76  case COORD_UNITS_NON_POLAR_THETA_DEGREES_MINUTES_SECONDS:
77  return new DlgValidatorDegreesMinutesSeconds (coordScale);
78 
79  case COORD_UNITS_NON_POLAR_THETA_NUMBER:
80  return new DlgValidatorNumber(coordScale,
81  locale);
82 
83  default:
84  LOG4CPP_ERROR_S ((*mainCat)) << "DlgValidatorFactory::createWithNonPolar";
85  exit (-1);
86  }
87 }
88 
90  CoordUnitsPolarTheta coordUnits,
91  const QLocale &locale) const
92 {
93  LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::createWithPolar";
94 
95  switch (coordUnits) {
96  case COORD_UNITS_POLAR_THETA_DEGREES:
97  case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES:
98  case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS:
99  case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW:
100  return new DlgValidatorDegreesMinutesSeconds (coordScale);
101 
102  case COORD_UNITS_POLAR_THETA_GRADIANS:
103  case COORD_UNITS_POLAR_THETA_RADIANS:
104  case COORD_UNITS_POLAR_THETA_TURNS:
105  return new DlgValidatorNumber (coordScale,
106  locale);
107 
108  default:
109  LOG4CPP_ERROR_S ((*mainCat)) << "DlgValidatorFactory::createWithNonPolar";
110  exit (-1);
111  }
112 }
Validator for numeric value expressed as date and/or time.
DlgValidatorFactory()
Single constructor.
Abstract validator for all numeric formats.
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...
Validator for angles in real degrees, integer degrees and real minutes, or integer degrees with integ...
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 * 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.
DlgValidatorAbstract * createWithPolar(CoordScale coordScale, CoordUnitsPolarTheta coordUnits, const QLocale &locale) const
Factory method for generating validators when cartesian/polar case handling is handled externally...