Engauge Digitizer  2
GeometryStrategyContext.cpp
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 "GeometryStrategyContext.h"
9 #include "GeometryStrategyFunctionSmooth.h"
10 #include "GeometryStrategyFunctionStraight.h"
11 #include "GeometryStrategyRelationSmooth.h"
12 #include "GeometryStrategyRelationStraight.h"
13 #include "Transformation.h"
14 
16 {
17  m_strategies.insert (CONNECT_AS_FUNCTION_SMOOTH , new GeometryStrategyFunctionSmooth ());
18  m_strategies.insert (CONNECT_AS_FUNCTION_STRAIGHT, new GeometryStrategyFunctionStraight ());
19  m_strategies.insert (CONNECT_AS_RELATION_SMOOTH , new GeometryStrategyRelationSmooth ());
20  m_strategies.insert (CONNECT_AS_RELATION_STRAIGHT, new GeometryStrategyRelationStraight ());
21 }
22 
23 GeometryStrategyContext::~GeometryStrategyContext()
24 {
25 }
26 
27 void GeometryStrategyContext::calculateGeometry (const Points &points,
28  const DocumentModelCoords &modelCoords,
29  const DocumentModelGeneral &modelGeneral,
30  const MainWindowModel &modelMainWindow,
31  const Transformation &transformation,
32  CurveConnectAs connectAs,
33  QString &funcArea,
34  QString &polyArea,
35  QVector<QString> &x,
36  QVector<QString> &y,
37  QVector<QString> &distanceGraphForward,
38  QVector<QString> &distancePercentForward,
39  QVector<QString> &distanceGraphBackward,
40  QVector<QString> &distancePercentBackward) const
41 {
42  if (transformation.transformIsDefined()) {
43 
44  m_strategies [connectAs]->calculateGeometry (points,
45  modelCoords,
46  modelGeneral,
47  modelMainWindow,
48  transformation,
49  funcArea,
50  polyArea,
51  x,
52  y,
53  distanceGraphForward,
54  distancePercentForward,
55  distanceGraphBackward,
56  distancePercentBackward);
57  }
58 }
Model for DlgSettingsGeneral and CmdSettingsGeneral.
Calculate for line through the points that is smoothly connected as a function.
Calculate for line through the points that is straightly connected as a function. ...
GeometryStrategyContext()
Single constructor.
Calculate for line through the points that is smoothly connected as a relation.
Affine transformation between screen and graph coordinates, based on digitized axis points...
Calculate for line through the points that is straightly connected as a relation. ...
Model for DlgSettingsMainWindow.
Model for DlgSettingsCoords and CmdSettingsCoords.
bool transformIsDefined() const
Transform is defined when at least three axis points have been digitized.
void 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< QString > &distanceGraphForward, QVector< QString > &distancePercentForward, QVector< QString > &distanceGraphBackward, QVector< QString > &distancePercentBackward) const
Calculate geometry parameters.