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 MainWindowModel &modelMainWindow,
30  const Transformation &transformation,
31  CurveConnectAs connectAs,
32  QString &funcArea,
33  QString &polyArea,
34  QVector<QString> &x,
35  QVector<QString> &y,
36  QVector<QString> &distanceGraphForward,
37  QVector<QString> &distancePercentForward,
38  QVector<QString> &distanceGraphBackward,
39  QVector<QString> &distancePercentBackward) const
40 {
41  if (transformation.transformIsDefined()) {
42 
43  m_strategies [connectAs]->calculateGeometry (points,
44  modelCoords,
45  modelMainWindow,
46  transformation,
47  funcArea,
48  polyArea,
49  x,
50  y,
51  distanceGraphForward,
52  distancePercentForward,
53  distanceGraphBackward,
54  distancePercentBackward);
55  }
56 }
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.
void calculateGeometry(const Points &points, const DocumentModelCoords &modelCoords, 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.
bool transformIsDefined() const
Transform is defined when at least three axis points have been digitized.