Engauge Digitizer  2
DlgValidatorFactory.cpp
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 
7 #include "DlgValidatorAboveZero.h"
8 #include "DlgValidatorAbstract.h"
9 #include "DlgValidatorDateTime.h"
10 #include "DlgValidatorDegreesMinutesSeconds.h"
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) {
83  case COORD_UNITS_NON_POLAR_THETA_DATE_TIME:
84  return new DlgValidatorDateTime (coordScale,
85  coordUnitsDate,
86  coordUnitsTime);
87 
88  case COORD_UNITS_NON_POLAR_THETA_DEGREES_MINUTES_SECONDS:
89  return new DlgValidatorDegreesMinutesSeconds (coordScale);
90 
91  case COORD_UNITS_NON_POLAR_THETA_NUMBER:
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) {
108  case COORD_UNITS_POLAR_THETA_DEGREES:
109  case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES:
110  case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS:
111  case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW:
112  return new DlgValidatorDegreesMinutesSeconds (coordScale);
113 
114  case COORD_UNITS_POLAR_THETA_GRADIANS:
115  case COORD_UNITS_POLAR_THETA_RADIANS:
116  case COORD_UNITS_POLAR_THETA_TURNS:
117  return new DlgValidatorNumber (coordScale,
118  locale);
119 
120  default:
121  LOG4CPP_ERROR_S ((*mainCat)) << "DlgValidatorFactory::createWithNonPolar";
122  exit (-1);
123  }
124 }
Validator for numeric value expressed as date and/or time.
DlgValidatorFactory()
Single constructor.
DlgValidatorAbstract * createAboveZero(const QLocale &locale) const
Factory method for generating validators for scale length which must be a number greater than zero...
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...
Abstract validator for all numeric formats.
Validator for angles in real degrees, integer degrees and real minutes, or integer degrees with integ...
Validator for generic (=simple) numbers that must be greater than zero.
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...
DlgValidatorAbstract * createWithPolar(CoordScale coordScale, CoordUnitsPolarTheta coordUnits, const QLocale &locale) const
Factory method for generating validators when cartesian/polar case handling is handled externally...
Validator for generic (=simple) numbers.
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...