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 "DlgValidatorAbstract.h"
8 #include "DlgValidatorDateTime.h"
9 #include "DlgValidatorDegreesMinutesSeconds.h"
10 #include "DlgValidatorFactory.h"
11 #include "DlgValidatorNumber.h"
12 #include "Logger.h"
13 #include <QLocale>
14 
16 {
17  LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::DlgValidatorFactory";
18 }
19 
21  bool isCartesian,
22  CoordUnitsNonPolarTheta coordUnitsCartesian,
23  CoordUnitsNonPolarTheta coordUnitsPolar,
24  CoordUnitsDate coordUnitsDate,
25  CoordUnitsTime coordUnitsTime,
26  const QLocale &locale) const
27 {
28  LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::createCartesianOrPolarWithNonPolarPolar";
29 
30  if (isCartesian) {
31  return createWithNonPolar (coordScale,
32  coordUnitsCartesian,
33  coordUnitsDate,
34  coordUnitsTime,
35  locale);
36  } else {
37  return createWithNonPolar (coordScale,
38  coordUnitsPolar,
39  coordUnitsDate,
40  coordUnitsTime,
41  locale);
42  }
43 }
44 
46  bool isCartesian,
47  CoordUnitsNonPolarTheta coordUnitsCartesian,
48  CoordUnitsPolarTheta coordUnitsPolar,
49  CoordUnitsDate coordUnitsDate,
50  CoordUnitsTime coordUnitsTime,
51  const QLocale &locale) const
52 {
53  LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::createCartesianOrPolarWithPolarPolar";
54 
55  if (isCartesian) {
56  return createWithNonPolar (coordScale,
57  coordUnitsCartesian,
58  coordUnitsDate,
59  coordUnitsTime,
60  locale);
61  } else {
62  return createWithPolar (coordScale,
63  coordUnitsPolar,
64  locale);
65  }
66 }
67 
69  CoordUnitsNonPolarTheta coordUnits,
70  CoordUnitsDate coordUnitsDate,
71  CoordUnitsTime coordUnitsTime,
72  const QLocale &locale) const
73 {
74  LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::createWithNonPolar";
75 
76  switch (coordUnits) {
77  case COORD_UNITS_NON_POLAR_THETA_DATE_TIME:
78  return new DlgValidatorDateTime (coordScale,
79  coordUnitsDate,
80  coordUnitsTime);
81 
82  case COORD_UNITS_NON_POLAR_THETA_DEGREES_MINUTES_SECONDS:
83  return new DlgValidatorDegreesMinutesSeconds (coordScale);
84 
85  case COORD_UNITS_NON_POLAR_THETA_NUMBER:
86  return new DlgValidatorNumber(coordScale,
87  locale);
88 
89  default:
90  LOG4CPP_ERROR_S ((*mainCat)) << "DlgValidatorFactory::createWithNonPolar";
91  exit (-1);
92  }
93 }
94 
96  CoordUnitsPolarTheta coordUnits,
97  const QLocale &locale) const
98 {
99  LOG4CPP_INFO_S ((*mainCat)) << "DlgValidatorFactory::createWithPolar";
100 
101  switch (coordUnits) {
102  case COORD_UNITS_POLAR_THETA_DEGREES:
103  case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES:
104  case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS:
105  case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW:
106  return new DlgValidatorDegreesMinutesSeconds (coordScale);
107 
108  case COORD_UNITS_POLAR_THETA_GRADIANS:
109  case COORD_UNITS_POLAR_THETA_RADIANS:
110  case COORD_UNITS_POLAR_THETA_TURNS:
111  return new DlgValidatorNumber (coordScale,
112  locale);
113 
114  default:
115  LOG4CPP_ERROR_S ((*mainCat)) << "DlgValidatorFactory::createWithNonPolar";
116  exit (-1);
117  }
118 }
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...