1 /******************************************************************************************************
2  * (C) 2016 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 "CurveConnectAs.h"
8 #include "DocumentModelCoords.h"
9 #include "DocumentModelGeneral.h"
10 #include "GeometryStrategyContext.h"
11 #include "GeometryStrategyFunctionSmooth.h"
12 #include "GeometryStrategyFunctionStraight.h"
13 #include "GeometryStrategyRelationSmooth.h"
14 #include "GeometryStrategyRelationStraight.h"
15 #include "Transformation.h"
16 
GeometryStrategyContext()17 GeometryStrategyContext::GeometryStrategyContext()
18 {
19   m_strategies.insert (CONNECT_AS_FUNCTION_SMOOTH  , new GeometryStrategyFunctionSmooth   ());
20   m_strategies.insert (CONNECT_AS_FUNCTION_STRAIGHT, new GeometryStrategyFunctionStraight ());
21   m_strategies.insert (CONNECT_AS_RELATION_SMOOTH  , new GeometryStrategyRelationSmooth   ());
22   m_strategies.insert (CONNECT_AS_RELATION_STRAIGHT, new GeometryStrategyRelationStraight ());
23 }
24 
~GeometryStrategyContext()25 GeometryStrategyContext::~GeometryStrategyContext()
26 {
27   qDeleteAll (m_strategies);
28 }
29 
calculateGeometry(const Points & points,const DocumentModelCoords & modelCoords,const DocumentModelGeneral & modelGeneral,const MainWindowModel & modelMainWindow,const Transformation & transformation,CurveConnectAs connectAs,QString & funcArea,QString & polyArea,QVector<QString> & x,QVector<QString> & y,QVector<bool> & isPotentialExportAmbiguity,QVector<QString> & distanceGraphForward,QVector<QString> & distancePercentForward,QVector<QString> & distanceGraphBackward,QVector<QString> & distancePercentBackward) const30 void GeometryStrategyContext::calculateGeometry (const Points &points,
31                                                  const DocumentModelCoords &modelCoords,
32                                                  const DocumentModelGeneral &modelGeneral,
33                                                  const MainWindowModel &modelMainWindow,
34                                                  const Transformation &transformation,
35                                                  CurveConnectAs connectAs,
36                                                  QString &funcArea,
37                                                  QString &polyArea,
38                                                  QVector<QString> &x,
39                                                  QVector<QString> &y,
40                                                  QVector<bool> &isPotentialExportAmbiguity,
41                                                  QVector<QString> &distanceGraphForward,
42                                                  QVector<QString> &distancePercentForward,
43                                                  QVector<QString> &distanceGraphBackward,
44                                                  QVector<QString> &distancePercentBackward) const
45 {
46   if (transformation.transformIsDefined()) {
47 
48     m_strategies [connectAs]->calculateGeometry (points,
49                                                  modelCoords,
50                                                  modelGeneral,
51                                                  modelMainWindow,
52                                                  transformation,
53                                                  funcArea,
54                                                  polyArea,
55                                                  x,
56                                                  y,
57                                                  isPotentialExportAmbiguity,
58                                                  distanceGraphForward,
59                                                  distancePercentForward,
60                                                  distanceGraphBackward,
61                                                  distancePercentBackward);
62   }
63 }
64