Isis 3 Programmer Reference
ControlNet.h
Go to the documentation of this file.
1 #ifndef ControlNet_h
2 #define ControlNet_h
3 
26 // This is needed for the QVariant macro
27 #include <QMetaType>
28 #include <QObject> // parent class
29 #include <QSharedPointer>
30 #include "SurfacePoint.h"
31 #include <QString>
32 #include <QMap>
33 #include <QVariant>
34 #include <QVector>
35 #include <QVariant>
36 
37 
38 // Boost includes
39 #include <boost/graph/graph_traits.hpp>
40 #include <boost/graph/adjacency_list.hpp>
41 #include <boost/graph/connected_components.hpp>
42 
43 #include "ControlMeasure.h"
44 #include "ControlPoint.h"
45 
46 template< typename A, typename B > class QHash;
47 template< typename T > class QList;
48 template< typename A, typename B > struct QPair;
49 template< typename T > class QSet;
50 
51 class QMutex;
52 class QString;
53 
54 namespace Isis {
55  class Camera;
56  class ControlMeasure;
57  class ControlPoint;
58  class Distance;
59  class Progress;
60  class Pvl;
61  class SerialNumberList;
62 
271  class ControlNet : public QObject {
272  Q_OBJECT
273 
274  friend class ControlMeasure;
275  friend class ControlPoint;
276 
277  public:
278 
288  enum ModType {
289  Swapped,
290  GraphModified
291  };
292 
294  ControlNet(const ControlNet &other);
295  ControlNet(const QString &filename, Progress *progress = 0,
297 
298  ~ControlNet();
299 
300  void clear();
302 
303  void ReadControl(const QString &filename, Progress *progress = 0);
304  void Write(const QString &filename, bool pvl = false);
305 
306  void AddPoint(ControlPoint *point);
307  int DeletePoint(ControlPoint *point);
308  int DeletePoint(QString pointId);
309  int DeletePoint(int index);
310  bool ContainsPoint(QString pointId) const;
311 
313  QString GraphToString() const;
315  int getEdgeCount() const;
316  QList< QString > getAdjacentImages(QString serialNumber) const;
317  QList< ControlMeasure * > GetMeasuresInCube(QString serialNumber);
320  double min,double max);
321 
322  void ComputeResiduals();
323  void ComputeApriori();
324 
325  const ControlPoint *GetPoint(QString pointId) const;
326  ControlPoint *GetPoint(QString pointId);
327  const ControlPoint *GetPoint(int index) const;
328  ControlPoint *GetPoint(int index);
329 
330  double AverageResidual();
331  Isis::Camera *Camera(int index);
332  QString CreatedDate() const;
333  QString Description() const;
334  ControlPoint *FindClosest(QString serialNumber,
335  double sample, double line);
336  //bool IsValid() const;
337  double GetMaximumResidual();
338  QString GetNetworkId() const;
340  int GetNumEditLockPoints();
341  int GetNumIgnoredMeasures();
342  int GetNumberOfValidMeasuresInImage(const QString &serialNumber);
343  int GetNumberOfJigsawRejectedMeasuresInImage(const QString &serialNumber);
344  void ClearJigsawRejected();
345  void IncrementNumberOfRejectedMeasuresInImage(const QString &serialNumber);
346  void DecrementNumberOfRejectedMeasuresInImage(const QString &serialNumber);
347  int GetNumMeasures() const;
348  int GetNumPoints() const;
349  int GetNumValidMeasures();
350  int GetNumValidPoints();
351  QString GetTarget() const;
352  QString GetUserName() const;
353  QString GetLastModified() const;
357 
358  void SetCreatedDate(const QString &date);
359  void SetDescription(const QString &newDescription);
360  void SetImages(const QString &imageListFile);
361  void SetImages(SerialNumberList &list, Progress *progress = 0);
362 
363  void SetModifiedDate(const QString &date);
364  void SetMutex(QMutex *mutex);
365  void SetNetworkId(const QString &id);
366  void SetTarget(const QString &target);
367  void SetTarget(Pvl label);
368  void SetTarget(const ControlNet &other);
369  void SetUserName(const QString &name);
371 
372  void swap(ControlNet &other);
373  ControlNet &operator=(const ControlNet &other);
374 
375  const ControlPoint *operator[](QString id) const;
376  ControlPoint *operator[](QString id);
377  const ControlPoint *operator[](int id) const;
378  ControlPoint *operator[](int id);
379 
380 
381  signals:
382  void networkStructureModified();
383  void networkModified(ControlNet::ModType type);
384  void pointModified(ControlPoint *point, ControlPoint::ModType type, QVariant oldValue, QVariant newValue);
385  void measureModified(ControlMeasure *measure, ControlMeasure::ModType type, QVariant oldValue, QVariant newValue);
386  void pointDeleted(ControlPoint *point);
387  void newPoint(ControlPoint *);
388  void newMeasure(ControlMeasure *);
389  void measureRemoved(ControlMeasure *);
390 
391 
392 
393  private:
394  void nullify();
395  bool ValidateSerialNumber(QString serialNumber) const;
396  void measureAdded(ControlMeasure *measure);
397  void measureDeleted(ControlMeasure *measure);
398  void measureIgnored(ControlMeasure *measure);
399  void measureUnIgnored(ControlMeasure *measure);
400  void pointIgnored(ControlPoint *point);
401  void pointUnIgnored(ControlPoint *point);
402  void UpdatePointReference(ControlPoint *point, QString oldId);
404  void emitMeasureModified(ControlMeasure *measure, ControlMeasure::ModType type, QVariant oldValue, QVariant newValue);
405  void emitPointModified(ControlPoint *point, ControlPoint::ModType type, QVariant oldValue, QVariant newValue);
406  void pointAdded(ControlPoint *point);
407  bool addEdge(QString sourceSerial, QString targetSerial);
408  bool removeEdge(QString sourceSerial, QString targetSerial);
409 
410  private: // graphing functions
417  public std::binary_function<ControlMeasure* const &,
418  ControlMeasure * const &, bool > {
419  public:
420  ControlMeasureLessThanFunctor(double(ControlMeasure::*accessorMethod)() const) {
421  m_accessor = accessorMethod;
422  }
424  this->m_accessor = other.m_accessor;
425  }
427 
428  bool operator()(ControlMeasure* const &, ControlMeasure* const &);
430 
431  private:
432  double(ControlMeasure::*m_accessor)() const;
433  };
434 
435  private: // data
438 
440  struct Image {
441  QString serial;
444  };
445 
447  struct Connection {
448  Connection() : strength(0) {}
449  int strength;
450  };
451 
455  typedef boost::adjacency_list<boost::setS,
456  boost::listS,
457  boost::undirectedS,
458  Image,
460 
461  typedef Network::vertex_descriptor ImageVertex;
462  typedef Network::edge_descriptor ImageConnection;
463 
465  typedef std::map<ImageVertex, size_t> VertexIndexMap;
466 
468  typedef boost::associative_property_map<VertexIndexMap> VertexIndexMapAdaptor;
469 
471  typedef boost::graph_traits<Network>::adjacency_iterator AdjacencyIterator;
472  typedef boost::graph_traits<Network>::vertex_iterator VertexIterator;
473 
474  QHash<QString, ImageVertex> m_vertexMap;
477  QMutex *m_mutex;
478 
479  QString p_targetName;
480  QString p_networkId;
481  QString p_created;
482  QString p_modified;
483  QString p_description;
484  QString p_userName;
490 
491  bool m_ownPoints;
493  };
494 
497 }
498 
501 
502 #endif
Definition: Process.h:32
void UpdatePointReference(ControlPoint *point, QString oldId)
Updates the key reference (poind Id) from the old one to what the point id was changet to...
Definition: ControlNet.cpp:733
void SetTarget(const QString &target)
Sets the target name and target radii, if available.
boost::graph_traits< Network >::adjacency_iterator AdjacencyIterator
Iterates over adjacent verticies.
Definition: ControlNet.h:471
void ReadControl(const QString &filename, Progress *progress=0)
Reads in the control points from the given file.
Definition: ControlNet.cpp:263
void emitNetworkStructureModified()
This method is a wrapper to emit the networkStructureModified() signal.
Definition: ControlNet.cpp:861
void ClearJigsawRejected()
Sets jigsaw rejected flag to false for all points and measures.
QString p_targetName
Name of the target.
Definition: ControlNet.h:479
Used to define the verticies of the graph.
Definition: ControlNet.h:440
void SetMutex(QMutex *mutex)
Set mutex to lock for making Naif calls.
void measureIgnored(ControlMeasure *measure)
Updates the edges in the ControlNet graph to reflect the ignored measure.
Definition: ControlNet.cpp:813
QSharedPointer< ControlNet > ControlNetQsp
This typedef is for future implementation of target body.
Definition: ControlNet.h:496
QStringList * pointIds
The ControlNet graph.
Definition: ControlNet.h:476
double GetMaximumResidual()
Determine the maximum error of all points in the network.
ModType
Control Measure Modification Types.
void ComputeResiduals()
Compute error for each point in the network.
int GetNumValidMeasures()
Return the number of valid (non-ignored) measures for all control points in the network.
QString p_description
Textual Description of network.
Definition: ControlNet.h:483
void DecrementNumberOfRejectedMeasuresInImage(const QString &serialNumber)
Decrement number of jigsaw rejected measures in image specified by serialNumber.
double AverageResidual()
Compute the average error of all points in the network.
QString GetUserName() const
Return the user name.
boost::associative_property_map< VertexIndexMap > VertexIndexMapAdaptor
Converts VertexIndexMap into the appropriate form to be used by boost.
Definition: ControlNet.h:468
QMap< QString, Isis::Camera * > p_cameraMap
A map from serialnumber to camera.
Definition: ControlNet.h:485
bool m_ownPoints
Specifies ownership of point list. True if owned by this object.
Definition: ControlNet.h:491
QHash< ControlPoint *, ControlMeasure *> measures
The serial number associated with the image The measures on the image, hashed by pointers to their pa...
Definition: ControlNet.h:443
void swap(ControlNet &other)
Swaps the member data with the given control net.
QList< QList< QString > > GetSerialConnections() const
This method searches through all the cube serial numbers in the network.
Definition: ControlNet.cpp:959
QString p_networkId
The Network Id.
Definition: ControlNet.h:480
void pointAdded(ControlPoint *point)
Adds a whole point to the control net graph.
Definition: ControlNet.cpp:376
QList< ControlPoint *> GetPoints()
Return QList of all the ControlPoints in the network.
void SetUserName(const QString &name)
Set the user name of the control network.
void emitMeasureModified(ControlMeasure *measure, ControlMeasure::ModType type, QVariant oldValue, QVariant newValue)
This method is a wrapper to emit the measureModified() signal and is called whenever a change is made...
Definition: ControlNet.cpp:145
Network m_controlGraph
The serial number -> vertex hash used by the graph.
Definition: ControlNet.h:475
QList< QString > GetPointIds() const
Return QList of ControlPoint Ids used in hash, in order of addition.
bool ValidateSerialNumber(QString serialNumber) const
Does a check to ensure that the given serial number is contained within the network.
std::map< ImageVertex, size_t > VertexIndexMap
Represents the edges of the graph.
Definition: ControlNet.h:465
QString GetTarget() const
Return the target name.
void measureDeleted(ControlMeasure *measure)
Updates the node for this measure&#39;s serial number to reflect the deletion.
Definition: ControlNet.cpp:746
QString p_created
Creation Date.
Definition: ControlNet.h:481
void measureAdded(ControlMeasure *measure)
Updates the ControlNet graph for the measure&#39;s serial number to reflect the addition.
Definition: ControlNet.cpp:572
void SetCoordType(SurfacePoint::CoordinateType coordType)
Sets the control point coordinate type.
Definition: ControlNet.cpp:853
QString GraphToString() const
Used for verifying graph intergrity.
Definition: ControlNet.cpp:489
Planetocentric latitudinal (lat/lon/rad) coordinates.
Definition: SurfacePoint.h:156
Q_DECLARE_METATYPE(Isis::ControlNet *)
This allows ControlNet *&#39;s to be stored in a QVariant.
int GetNumPoints() const
Return the number of control points in the network.
void pointIgnored(ControlPoint *point)
Update the ControlNet&#39;s internal structure when a ControlPoint is ignored.
Definition: ControlNet.cpp:771
SurfacePoint::CoordinateType m_coordType
The coordinate type of the control points.
Definition: ControlNet.h:492
Program progress reporter.
Definition: Progress.h:58
QString Description() const
Return the description of the network.
QString p_userName
The user who created the network.
Definition: ControlNet.h:484
a control network
Definition: ControlNet.h:271
QMap< QString, int > p_cameraValidMeasuresMap
A map from serialnumber to #measures.
Definition: ControlNet.h:486
void clear()
Clear the contents of this object.
Definition: ControlNet.cpp:172
Used to define the edges of the graph.
Definition: ControlNet.h:447
int getEdgeCount() const
Definition: ControlNet.cpp:995
void SetNetworkId(const QString &id)
Set the network id.
void IncrementNumberOfRejectedMeasuresInImage(const QString &serialNumber)
Increment number of jigsaw rejected measures in image specified by serialNumber.
int GetNumMeasures() const
Returns the total number of measures for all control points in the network.
void pointUnIgnored(ControlPoint *point)
Update the ControlNet&#39;s internal structure when a ControlPoint is un-ignored.
Definition: ControlNet.cpp:629
QList< QString > GetCubeSerials() const
Use this method to get a complete list of all the cube serial numbers in the network.
QList< QString > getAdjacentImages(QString serialNumber) const
Get all images connected to a given image by common control points.
bool addEdge(QString sourceSerial, QString targetSerial)
In the ControlNet graph: adds an edge between the verticies associated with the two serial numbers pr...
Definition: ControlNet.cpp:434
int DeletePoint(ControlPoint *point)
Delete a ControlPoint from the network by the point&#39;s address.
Definition: ControlNet.cpp:871
A single control point.
Definition: ControlPoint.h:369
ModType
Control Point Modification Types.
Definition: ControlNet.h:288
void SetImages(const QString &imageListFile)
Creates the ControlNet&#39;s image cameras based on an input file.
Container for cube-like labels.
Definition: Pvl.h:135
QHash< QString, ControlPoint *> * points
hash ControlPoints by ControlPoint Id
Definition: ControlNet.h:437
int GetNumValidPoints()
Returns the number of non-ignored control points.
Network::edge_descriptor ImageConnection
Reprents the verticies of the graph.
Definition: ControlNet.h:462
SurfacePoint::CoordinateType GetCoordType()
Get the control point coordinate type (see the available types in SurfacePoint.h).
CoordinateType
Defines the coordinate typ, units, and coordinate index for some of the output methods.
Definition: SurfacePoint.h:155
ControlNet(SurfacePoint::CoordinateType=SurfacePoint::Latitudinal)
Creates an empty ControlNet object.
Definition: ControlNet.cpp:52
int GetNumEditLockMeasures()
Return the total number of edit locked measures for all control points in the network.
ModType
Control Point Modification Types.
Definition: ControlPoint.h:446
QString CreatedDate() const
Return the Created Date.
int GetNumIgnoredMeasures()
Return the total number of ignored measures for all control points in the network.
bool ContainsPoint(QString pointId) const
Definition: ControlNet.cpp:943
boost::adjacency_list< boost::setS, boost::listS, boost::undirectedS, Image, Connection > Network
Defines the graph type as an undirected graph that uses Images for verticies, and Connections for edg...
Definition: ControlNet.h:459
void AddPoint(ControlPoint *point)
Adds a ControlPoint to the ControlNet.
Definition: ControlNet.cpp:344
QVector< Isis::Camera * > p_cameraList
Vector of image number to camera.
Definition: ControlNet.h:489
int GetNumEditLockPoints()
Returns the number of edit locked control points.
void SetModifiedDate(const QString &date)
Set the last modified date.
QList< ControlMeasure *> GetMeasuresInCube(QString serialNumber)
Get all the measures pertaining to a given cube serial number.
bool operator()(ControlMeasure *const &, ControlMeasure *const &)
The () operator for the Control Measure less than functor.
QMap< QString, int > p_cameraRejectedMeasuresMap
A map from serialnumber to #rejected measures.
Definition: ControlNet.h:487
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
a control measurement
int GetNumberOfJigsawRejectedMeasuresInImage(const QString &serialNumber)
Return the number of jigsaw rejected measures in image specified by serialNumber. ...
Isis::Camera * Camera(int index)
Returns the camera list from the given image number.
QList< ControlPoint *> take()
Transfer ownership of all points to caller.
Definition: ControlNet.cpp:218
void ComputeApriori()
Compute aprior values for each point in the network.
ControlMeasureLessThanFunctor & operator=(ControlMeasureLessThanFunctor const &other)
Copies the content of the a ControlMeasureLessThanFunctor.
void SetCreatedDate(const QString &date)
Set the creation time.
void SetDescription(const QString &newDescription)
Set the description of the network.
void emitPointModified(ControlPoint *point, ControlPoint::ModType type, QVariant oldValue, QVariant newValue)
This method is a wrapper to emit the pointModified() signal and is called whenever a change is made t...
Definition: ControlNet.cpp:159
ControlNet & operator=(const ControlNet &other)
Assign other to this.
QString p_modified
Date Last Modified.
Definition: ControlNet.h:482
Serial Number list generator.
~ControlNet()
Destructor removes allocated memory.
Definition: ControlNet.cpp:125
QList< ControlMeasure *> sortedMeasureList(double(ControlMeasure::*statFunc)() const, double min, double max)
Get a sorted list of all the measures that have values in a given ragen.
ControlPoint * FindClosest(QString serialNumber, double sample, double line)
Finds and returns a pointer to the closest ControlPoint to the ControlMeasure with the given serial n...
void measureUnIgnored(ControlMeasure *measure)
Updates the connections for the ControlNet graph associated with the measure&#39;s serial number to refle...
Definition: ControlNet.cpp:675
bool removeEdge(QString sourceSerial, QString targetSerial)
In the ControlNet graph, decrements the strength on the edge between the two serial numbers...
Definition: ControlNet.cpp:463
void Write(const QString &filename, bool pvl=false)
Writes out the control network.
Definition: ControlNet.cpp:303
int GetNumberOfValidMeasuresInImage(const QString &serialNumber)
Return the number of measures in image specified by serialNumber.
QString GetLastModified() const
Return the last modified date.
QList< ControlMeasure *> GetValidMeasuresInCube(QString serialNumber)
Get all the valid measures pertaining to a given cube serial number.