Fraxinus  18.10
An IGT application
ProbeXmlConfigParserImpl.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef PROBEXMLCONFIGPARSERIMPL_H_
13 #define PROBEXMLCONFIGPARSERIMPL_H_
14 
15 #include "cxResourceExport.h"
16 
17 #include <ProbeXmlConfigParser.h>
18 
29 class cxResource_EXPORT ProbeXmlConfigParserImpl : public ProbeXmlConfigParser
30 {
31 public:
32  ProbeXmlConfigParserImpl(QString& pathToXml);
33  virtual ~ProbeXmlConfigParserImpl();
34  virtual QString getFileName();
35  virtual void removeConfig(QString scanner, QString probe, QString rtsource, QString configId);
36  virtual void saveCurrentConfig(Configuration config);
37  virtual QStringList getScannerList();
38  virtual QStringList getProbeList(QString scanner);
39  virtual QStringList getRtSourceList(QString scanner, QString probe);
40  virtual QStringList getConfigIdList(QString scanner, QString probe, QString rtSource);
41  virtual Configuration getConfiguration(QString scanner, QString probe, QString rtsource, QString configId);
42 protected:
43  QList<QDomNode> getScannerNodes(QString scanner = "ALL");
44  QList<QDomNode> getProbeNodes(QString scanner, QString probe = "ALL");
45  QList<QDomNode> getRTSourceNodes(QString scanner, QString probe, QString rtSource="ALL");
46  QList<QDomNode> getConfigNodes(QString scanner, QString probe, QString rtsource, QString config="ALL");
47  QList<QDomNode> nodeListToListOfNodes(QDomNodeList list);
48  void addTextElement(QDomElement parent, QString element, QString text);
49 
51 };
52 
53 //------------------------------------------------------------------------------
54 /*
55 http://stackoverflow.com/questions/1709283/how-can-i-sort-a-coordinate-list-for-a-rectangle-counterclockwise
56 
57 I need to sort a coordinate list for a rectangle counterclockwise, and make the north-east corner the first coordinate.
58 
59 solution seems pretty straightforward:
60 
61 >>> import math
62 >>> mlat = sum(x['lat'] for x in l) / len(l)
63 >>> mlng = sum(x['lng'] for x in l) / len(l)
64 >>> def algo(x):
65  return (math.atan2(x['lat'] - mlat, x['lng'] - mlng) + 2 * math.pi) % 2*math.pi
66 
67 >>> l.sort(key=algo)
68 basically, algo normalises the input into the [0, 2pi] space and it would be naturally sorted "counter-clockwise".
69 */
70 
71 //------------------------------------------------------------------------------
72 class cxResource_EXPORT Angular_less
73 {
74 public:
76  {
77  }
78 
80  {
81  return angle(rhs) < angle(lhs);
82  }
83 
85  {
86  double pi = atan(1.0)*4;
87  return fmod( ( ( atan2((double)(pair1.first - mCenter.first), (double)(pair1.second - mCenter.second)) ) + 3*pi/4) , 2*pi);
88  }
90 };
91 
95 #endif /* PROBEXMLCONFIGPARSERIMPL_H_ */
< a easy-to-work-with struct for a specific xml configuration
virtual QStringList getRtSourceList(QString scanner, QString probe)=0
get a list of rt sources for that scanner/probe combo
virtual QStringList getScannerList()=0
get a list of all scanner in the xml
virtual void removeConfig(QString scanner, QString probe, QString rtsource, QString configId)=0
virtual QStringList getProbeList(QString scanner)=0
get a list of all probes for that scanner
virtual QStringList getConfigIdList(QString scanner, QString probe, QString rtSource)=0
get a list of config ids for that scanner/probe/rsource combo
ProbeXmlConfigParser::ColRowPair mCenter
Class that works as a interface to a ProbeCalibConfigs.xml.
virtual Configuration getConfiguration(QString scanner, QString probe, QString rtsource, QString configId)=0
get a easy-to-work-with struct of a specific config
Implementation of abstract interface ProbeXmlConfigParser Interface to ProbeCalibConfigs.xml.
Angular_less(ProbeXmlConfigParser::ColRowPair center)
std::pair< double, double > ColRowPair
int angle(ProbeXmlConfigParser::ColRowPair pair1)
bool operator()(const ProbeXmlConfigParser::ColRowPair &rhs, const ProbeXmlConfigParser::ColRowPair &lhs)
virtual QString getFileName()=0
Helper class for xml files used to store ssc/cx data.
virtual void saveCurrentConfig(Configuration config)=0