Isis 3 Programmer Reference
ControlNet.h
1#ifndef ControlNet_h
2#define ControlNet_h
3
10/* SPDX-License-Identifier: CC0-1.0 */
11
12// This is needed for the QVariant macro
13#include <QMetaType>
14#include <QObject> // parent class
15#include <QSharedPointer>
16#include "SurfacePoint.h"
17#include <QString>
18#include <QMap>
19#include <QVariant>
20#include <QVector>
21#include <QVariant>
22
23
24// Boost includes
25#include <boost/graph/graph_traits.hpp>
26#include <boost/graph/adjacency_list.hpp>
27#include <boost/graph/connected_components.hpp>
28
29#include "ControlMeasure.h"
30#include "ControlPoint.h"
31
32template< typename A, typename B > class QHash;
33template< typename T > class QList;
34template< typename A, typename B > struct QPair;
35template< typename T > class QSet;
36
37class QMutex;
38class QString;
39
40namespace Isis {
41 class Camera;
42 class ControlMeasure;
43 class ControlPoint;
44 class Distance;
45 class Progress;
46 class Pvl;
47 class SerialNumberList;
48
258 class ControlNet : public QObject {
259 Q_OBJECT
260
261 friend class ControlMeasure;
262 friend class ControlPoint;
263
264 public:
265
275 enum ModType {
276 Swapped,
277 GraphModified
278 };
279
281 ControlNet(const ControlNet &other);
282 ControlNet(const QString &filename, Progress *progress = 0,
284
285 ~ControlNet();
286
287 void clear();
288 QList< ControlPoint * > take();
289
290 void ReadControl(const QString &filename, Progress *progress = 0);
291 void Write(const QString &filename, bool pvl = false);
292
293 void AddPoint(ControlPoint *point);
294 int DeletePoint(ControlPoint *point);
295 int DeletePoint(QString pointId);
296 int DeletePoint(int index);
297 bool ContainsPoint(QString pointId) const;
298
300 QString GraphToString() const;
301 QList< QList< QString > > GetSerialConnections() const;
302 int getEdgeCount() const;
303 QList< QString > getAdjacentImages(QString serialNumber) const;
304 QList< ControlMeasure * > GetMeasuresInCube(QString serialNumber);
305 QList< ControlMeasure * > GetValidMeasuresInCube(QString serialNumber);
306 QList< ControlMeasure * > sortedMeasureList(double(ControlMeasure::*statFunc)() const,
307 double min,double max);
308
309 void ComputeResiduals();
310 void ComputeApriori();
311
312 const ControlPoint *GetPoint(QString pointId) const;
313 ControlPoint *GetPoint(QString pointId);
314 const ControlPoint *GetPoint(int index) const;
315 ControlPoint *GetPoint(int index);
316
317 double AverageResidual();
318 Isis::Camera *Camera(int index);
319 Isis::Camera *Camera(QString serialNumber);
320 QString CreatedDate() const;
321 QString Description() const;
322 ControlPoint *FindClosest(QString serialNumber,
323 double sample, double line);
324 //bool IsValid() const;
325 double GetMaximumResidual();
326 QString GetNetworkId() const;
330 int GetNumberOfValidMeasuresInImage(const QString &serialNumber);
331 int GetNumberOfJigsawRejectedMeasuresInImage(const QString &serialNumber);
332 void ClearJigsawRejected();
333 void IncrementNumberOfRejectedMeasuresInImage(const QString &serialNumber);
334 void DecrementNumberOfRejectedMeasuresInImage(const QString &serialNumber);
335 int GetNumMeasures() const;
336 int GetNumPoints() const;
338 int GetNumValidPoints();
339 QString GetTarget() const;
340 QString GetUserName() const;
341 QString GetLastModified() const;
342 QList< ControlPoint * > GetPoints();
345
346 void SetCreatedDate(const QString &date);
347 void SetDescription(const QString &newDescription);
348 void SetImages(const QString &imageListFile);
349 void SetImages(SerialNumberList &list, Progress *progress = 0);
350
351 void SetModifiedDate(const QString &date);
352 void SetMutex(QMutex *mutex);
353 void SetNetworkId(const QString &id);
354 void SetTarget(const QString &target);
355 void SetTarget(Pvl label);
356 void SetTarget(const ControlNet &other);
357 void SetUserName(const QString &name);
359
360 void swap(ControlNet &other);
361 ControlNet &operator=(const ControlNet &other);
362
363 const ControlPoint *operator[](QString id) const;
364 ControlPoint *operator[](QString id);
365 const ControlPoint *operator[](int id) const;
366 ControlPoint *operator[](int id);
367
368
369 signals:
370 void networkStructureModified();
371 void networkModified(ControlNet::ModType type);
372 void pointModified(ControlPoint *point, ControlPoint::ModType type, QVariant oldValue, QVariant newValue);
373 void measureModified(ControlMeasure *measure, ControlMeasure::ModType type, QVariant oldValue, QVariant newValue);
374 void pointDeleted(ControlPoint *point);
375 void newPoint(ControlPoint *);
376 void newMeasure(ControlMeasure *);
377 void measureRemoved(ControlMeasure *);
378
379
380
381 private:
382 void nullify();
383 bool ValidateSerialNumber(QString serialNumber) const;
384 void measureAdded(ControlMeasure *measure);
385 void measureDeleted(ControlMeasure *measure);
386 void measureIgnored(ControlMeasure *measure);
387 void measureUnIgnored(ControlMeasure *measure);
388 void pointIgnored(ControlPoint *point);
389 void pointUnIgnored(ControlPoint *point);
390 void UpdatePointReference(ControlPoint *point, QString oldId);
392 void emitMeasureModified(ControlMeasure *measure, ControlMeasure::ModType type, QVariant oldValue, QVariant newValue);
393 void emitPointModified(ControlPoint *point, ControlPoint::ModType type, QVariant oldValue, QVariant newValue);
394 void pointAdded(ControlPoint *point);
395 bool addEdge(QString sourceSerial, QString targetSerial);
396 bool removeEdge(QString sourceSerial, QString targetSerial);
397
398 private: // graphing functions
405 public std::function<bool(ControlMeasure* const &,
406 ControlMeasure * const &)> {
407 public:
408 ControlMeasureLessThanFunctor(double(ControlMeasure::*accessorMethod)() const) {
409 m_accessor = accessorMethod;
410 }
412 this->m_accessor = other.m_accessor;
413 }
415
416 bool operator()(ControlMeasure* const &, ControlMeasure* const &);
418
419 private:
420 double(ControlMeasure::*m_accessor)() const;
421 };
422
423 private: // data
425 QHash< QString, ControlPoint * > * points;
426
428 struct Image {
429 QString serial;
431 QHash< ControlPoint *, ControlMeasure * > measures;
432 };
433
435 struct Connection {
436 Connection() : strength(0) {}
437 int strength;
438 };
439
443 typedef boost::adjacency_list<boost::setS,
444 boost::listS,
445 boost::undirectedS,
446 Image,
448
449 typedef Network::vertex_descriptor ImageVertex;
450 typedef Network::edge_descriptor ImageConnection;
451
453 typedef std::map<ImageVertex, size_t> VertexIndexMap;
454
456 typedef boost::associative_property_map<VertexIndexMap> VertexIndexMapAdaptor;
457
459 typedef boost::graph_traits<Network>::adjacency_iterator AdjacencyIterator;
460 typedef boost::graph_traits<Network>::vertex_iterator VertexIterator;
461
462 QHash<QString, ImageVertex> m_vertexMap;
465 QMutex *m_mutex;
466
467 QString p_targetName;
468 QString p_networkId;
469 QString p_created;
470 QString p_modified;
472 QString p_userName;
473 QMap<QString, Isis::Camera *> p_cameraMap;
474 QMap<QString, int> p_cameraValidMeasuresMap;
475 QMap<QString, int> p_cameraRejectedMeasuresMap;
477 QVector<Isis::Camera *> p_cameraList;
478
481 };
482
485 typedef QSharedPointer<ControlNet> ControlNetQsp;
486}
487
489Q_DECLARE_METATYPE(Isis::ControlNet *);
490
491#endif
a control measurement
ModType
Control Measure Modification Types.
ControlMeasureLessThanFunctor & operator=(ControlMeasureLessThanFunctor const &other)
Copies the content of the a ControlMeasureLessThanFunctor.
bool operator()(ControlMeasure *const &, ControlMeasure *const &)
The () operator for the Control Measure less than functor.
a control network
Definition ControlNet.h:258
int GetNumEditLockPoints()
Returns the number of edit locked control points.
int GetNumMeasures() const
Returns the total number of measures for all control points in the network.
QString Description() const
Return the description of the network.
void pointIgnored(ControlPoint *point)
Update the ControlNet's internal structure when a ControlPoint is ignored.
int getEdgeCount() const
ControlNet(SurfacePoint::CoordinateType=SurfacePoint::Latitudinal)
Creates an empty ControlNet object.
QString GraphToString() const
Used for verifying graph intergrity.
void AddPoint(ControlPoint *point)
Adds a ControlPoint to the ControlNet.
QList< QList< QString > > GetSerialConnections() const
This method searches through all the cube serial numbers in the network.
QString GetLastModified() const
Return the last modified date.
double GetMaximumResidual()
Determine the maximum error of all points in the network.
QList< QString > getAdjacentImages(QString serialNumber) const
Get all images connected to a given image by common control points.
ControlNet & operator=(const ControlNet &other)
Assign other to this.
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:447
void ReadControl(const QString &filename, Progress *progress=0)
Reads in the control points from the given file.
void SetDescription(const QString &newDescription)
Set the description of the network.
SurfacePoint::CoordinateType m_coordType
The coordinate type of the control points.
Definition ControlNet.h:480
int GetNumPoints() const
Return the number of control points in the network.
QString p_targetName
Name of the target.
Definition ControlNet.h:467
QString p_description
Textual Description of network.
Definition ControlNet.h:471
QMap< QString, int > p_cameraRejectedMeasuresMap
A map from serialnumber to #rejected measures.
Definition ControlNet.h:475
QStringList * pointIds
The ControlNet graph.
Definition ControlNet.h:464
QString p_modified
Date Last Modified.
Definition ControlNet.h:470
void ComputeApriori()
Compute aprior values for each point in the network.
SurfacePoint::CoordinateType GetCoordType()
Get the control point coordinate type (see the available types in SurfacePoint.h).
QString CreatedDate() const
Return the Created Date.
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...
void DecrementNumberOfRejectedMeasuresInImage(const QString &serialNumber)
Decrement number of jigsaw rejected measures in image specified by serialNumber.
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.
void measureUnIgnored(ControlMeasure *measure)
Updates the connections for the ControlNet graph associated with the measure's serial number to refle...
QHash< QString, ControlPoint * > * points
hash ControlPoints by ControlPoint Id
Definition ControlNet.h:425
void SetImages(const QString &imageListFile)
Creates the ControlNet's image cameras based on an input file.
QString GetUserName() const
Return the user name.
QMap< QString, int > p_cameraValidMeasuresMap
A map from serialnumber to #measures.
Definition ControlNet.h:474
int GetNumberOfValidMeasuresInImage(const QString &serialNumber)
Return the number of measures in image specified by serialNumber.
Network m_controlGraph
The serial number -> vertex hash used by the graph.
Definition ControlNet.h:463
int GetNumberOfJigsawRejectedMeasuresInImage(const QString &serialNumber)
Return the number of jigsaw rejected measures in image specified by serialNumber.
void Write(const QString &filename, bool pvl=false)
Writes out the control network.
void SetCoordType(SurfacePoint::CoordinateType coordType)
Sets the control point coordinate type.
void emitNetworkStructureModified()
This method is a wrapper to emit the networkStructureModified() signal.
int GetNumValidMeasures()
Return the number of valid (non-ignored) measures for all control points in the network.
std::map< ImageVertex, size_t > VertexIndexMap
Represents the edges of the graph.
Definition ControlNet.h:453
int GetNumValidPoints()
Returns the number of non-ignored control points.
Network::edge_descriptor ImageConnection
Reprents the verticies of the graph.
Definition ControlNet.h:450
void pointAdded(ControlPoint *point)
Adds a whole point to the control net graph.
void measureAdded(ControlMeasure *measure)
Updates the ControlNet graph for the measure's serial number to reflect the addition.
QVector< Isis::Camera * > p_cameraList
Vector of image number to camera.
Definition ControlNet.h:477
QList< QString > GetPointIds() const
Return QList of ControlPoint Ids used in hash, in order of addition.
int GetNumIgnoredMeasures()
Return the total number of ignored measures for all control points in the network.
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 SetCreatedDate(const QString &date)
Set the creation time.
QString GetTarget() const
Return the target name.
double AverageResidual()
Compute the average error of all points in the network.
QMap< QString, Isis::Camera * > p_cameraMap
A map from serialnumber to camera.
Definition ControlNet.h:473
bool ContainsPoint(QString pointId) const
void clear()
Clear the contents of this object.
ModType
Control Point Modification Types.
Definition ControlNet.h:275
QString p_created
Creation Date.
Definition ControlNet.h:469
boost::associative_property_map< VertexIndexMap > VertexIndexMapAdaptor
Converts VertexIndexMap into the appropriate form to be used by boost.
Definition ControlNet.h:456
~ControlNet()
Destructor removes allocated memory.
Isis::Camera * Camera(int index)
Returns the camera list from the given image number.
bool m_ownPoints
Specifies ownership of point list. True if owned by this object.
Definition ControlNet.h:479
QList< ControlMeasure * > GetMeasuresInCube(QString serialNumber)
Get all the measures pertaining to a given cube serial number.
void SetUserName(const QString &name)
Set the user name of the control network.
QString p_networkId
The Network Id.
Definition ControlNet.h:468
QList< ControlPoint * > GetPoints()
Return QList of all the ControlPoints in the network.
void ClearJigsawRejected()
Sets jigsaw rejected flag to false for all points and measures.
void SetMutex(QMutex *mutex)
Set mutex to lock for making Naif calls.
void UpdatePointReference(ControlPoint *point, QString oldId)
Updates the key reference (poind Id) from the old one to what the point id was changet to.
void measureDeleted(ControlMeasure *measure)
Updates the node for this measure's serial number to reflect the deletion.
boost::graph_traits< Network >::adjacency_iterator AdjacencyIterator
Iterates over adjacent verticies.
Definition ControlNet.h:459
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...
void ComputeResiduals()
Compute error for each point in the network.
bool removeEdge(QString sourceSerial, QString targetSerial)
In the ControlNet graph, decrements the strength on the edge between the two serial numbers.
int DeletePoint(ControlPoint *point)
Delete a ControlPoint from the network by the point's address.
void pointUnIgnored(ControlPoint *point)
Update the ControlNet's internal structure when a ControlPoint is un-ignored.
void swap(ControlNet &other)
Swaps the member data with the given control net.
bool addEdge(QString sourceSerial, QString targetSerial)
In the ControlNet graph: adds an edge between the verticies associated with the two serial numbers pr...
QList< QString > GetCubeSerials() const
Use this method to get a complete list of all the cube serial numbers in the network.
void SetNetworkId(const QString &id)
Set the network id.
QString p_userName
The user who created the network.
Definition ControlNet.h:472
void SetModifiedDate(const QString &date)
Set the last modified date.
QList< ControlMeasure * > GetValidMeasuresInCube(QString serialNumber)
Get all the valid measures pertaining to a given cube serial number.
void IncrementNumberOfRejectedMeasuresInImage(const QString &serialNumber)
Increment number of jigsaw rejected measures in image specified by serialNumber.
int GetNumEditLockMeasures()
Return the total number of edit locked measures for all control points in the network.
void SetTarget(const QString &target)
Sets the target name and target radii, if available.
void measureIgnored(ControlMeasure *measure)
Updates the edges in the ControlNet graph to reflect the ignored measure.
QList< ControlPoint * > take()
Transfer ownership of all points to caller.
bool ValidateSerialNumber(QString serialNumber) const
Does a check to ensure that the given serial number is contained within the network.
A single control point.
ModType
Control Point Modification Types.
Program progress reporter.
Definition Progress.h:42
Container for cube-like labels.
Definition Pvl.h:119
Serial Number list generator.
CoordinateType
Defines the coordinate typ, units, and coordinate index for some of the output methods.
@ Latitudinal
Planetocentric latitudinal (lat/lon/rad) coordinates.
This is free and unencumbered software released into the public domain.
Definition ControlNet.h:32
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Definition Process.h:16
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QSharedPointer< ControlNet > ControlNetQsp
Typedef for QSharedPointer to control network. This typedef is for future implementation of target bo...
Definition ControlNet.h:485
Used to define the edges of the graph.
Definition ControlNet.h:435
Used to define the verticies of the graph.
Definition ControlNet.h:428
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:431
This is free and unencumbered software released into the public domain.