|
Isis 3.0 Object Programmers' Reference |
Home |
00001 #ifndef ControlNet_h 00002 #define ControlNet_h 00003 00026 #include <QObject> // parent class 00027 00028 #include <map> 00029 #include <vector> 00030 00031 #include "ControlNetFile.h" 00032 00033 #include <QString> 00034 00035 template< typename A, typename B > class QHash; 00036 template< typename T > class QList; 00037 template< typename A, typename B > class QPair; 00038 template< typename T > class QSet; 00039 00040 namespace Isis { 00041 class Camera; 00042 class ControlMeasure; 00043 class ControlPoint; 00044 class ControlCubeGraphNode; 00045 class Distance; 00046 class Progress; 00047 class SerialNumberList; 00048 00168 class ControlNet : public QObject { 00169 Q_OBJECT 00170 00171 friend class ControlMeasure; 00172 friend class ControlPoint; 00173 00174 public: 00175 ControlNet(); 00176 ControlNet(const ControlNet &other); 00177 ControlNet(const QString &filename, Progress *progress = 0); 00178 00179 ~ControlNet(); 00180 00181 void ReadControl(const QString &filename, Progress *progress = 0); 00182 void Write(const QString &filename, bool pvl = false); 00183 00184 void AddPoint(ControlPoint *point); 00185 int DeletePoint(ControlPoint *point); 00186 int DeletePoint(QString pointId); 00187 int DeletePoint(int index); 00188 bool ContainsPoint(QString pointId) const; 00189 00190 QList< QString > GetCubeSerials() const; 00191 QList< ControlCubeGraphNode * > GetCubeGraphNodes(); 00192 QList< QList< QString > > GetSerialConnections() const; 00193 QList< QList< ControlCubeGraphNode * > > GetNodeConnections() const; 00194 QSet< ControlMeasure * > MinimumSpanningTree( 00195 QList< ControlCubeGraphNode *> &island, 00196 bool lessThan(const ControlMeasure *, const ControlMeasure *)) const; 00197 int getEdgeCount() const; 00198 QString CubeGraphToString() const; 00199 QList< ControlMeasure * > GetMeasuresInCube(QString serialNumber); 00200 QList< ControlMeasure * > sortedMeasureList(double(ControlMeasure::*statFunc)() const, 00201 double min,double max); 00202 void DeleteMeasuresWithId(QString serialNumber); 00203 00204 void ComputeResiduals(); 00205 void ComputeApriori(); 00206 00207 const ControlPoint *GetPoint(QString pointId) const; 00208 ControlPoint *GetPoint(QString pointId); 00209 const ControlPoint *GetPoint(int index) const; 00210 ControlPoint *GetPoint(int index); 00211 00212 const ControlCubeGraphNode *getGraphNode(QString serialNumber) const; 00213 ControlCubeGraphNode *getGraphNode(QString serialNumber); 00214 00215 double AverageResidual(); 00216 Isis::Camera *Camera(int index); 00217 QString CreatedDate() const; 00218 QString Description() const; 00219 ControlPoint *FindClosest(QString serialNumber, 00220 double sample, double line); 00221 bool IsValid() const; 00222 double GetMaximumResidual(); 00223 QString GetNetworkId() const; 00224 int GetNumEditLockMeasures(); 00225 int GetNumEditLockPoints(); 00226 int GetNumIgnoredMeasures(); 00227 int GetNumberOfMeasuresInImage(const QString &serialNumber); 00228 int GetNumberOfJigsawRejectedMeasuresInImage(const QString &serialNumber); 00229 void ClearJigsawRejected(); 00230 void IncrementNumberOfRejectedMeasuresInImage(const QString &serialNumber); 00231 void DecrementNumberOfRejectedMeasuresInImage(const QString &serialNumber); 00232 int GetNumMeasures() const; 00233 int GetNumPoints() const; 00234 int GetNumValidMeasures(); 00235 int GetNumValidPoints(); 00236 QString GetTarget() const; 00237 QString GetUserName() const; 00238 QList< ControlPoint * > GetPoints(); 00239 QList< QString > GetPointIds() const; 00240 std::vector<Distance> GetTargetRadii(); 00241 00242 void SetCreatedDate(const QString &date); 00243 void SetDescription(const QString &newDescription); 00244 void SetImages(const QString &imageListFile); 00245 void SetImages(SerialNumberList &list, Progress *progress = 0); 00246 void SetModifiedDate(const QString &date); 00247 void SetNetworkId(const QString &id); 00248 void SetTarget(const QString &target); 00249 void SetUserName(const QString &name); 00250 00251 const ControlNet &operator=(ControlNet other); 00252 00253 const ControlPoint *operator[](QString id) const; 00254 ControlPoint *operator[](QString id); 00255 const ControlPoint *operator[](int id) const; 00256 ControlPoint *operator[](int id); 00257 00258 00259 signals: 00260 void networkStructureModified(); 00261 00262 private: 00263 void nullify(); 00264 void ValidateSerialNumber(QString serialNumber) const; 00265 void measureAdded(ControlMeasure *measure); 00266 void measureDeleted(ControlMeasure *measure); 00267 void measureIgnored(ControlMeasure *measure); 00268 void measureUnIgnored(ControlMeasure *measure); 00269 void UpdatePointReference(ControlPoint *point, QString oldId); 00270 void emitNetworkStructureModified(); 00271 00272 00273 private: // graphing functions 00274 QList< ControlCubeGraphNode * > RandomBFS(QList < 00275 ControlCubeGraphNode * > list) const; 00276 void Shuffle(QList< ControlCubeGraphNode * > & list) const; 00277 QPair< int, int > CalcBWAndCE(QList< QString > serials) const; 00278 00284 class ControlMeasureLessThanFunctor : 00285 public std::binary_function<ControlMeasure* const &, 00286 ControlMeasure * const &, bool > { 00287 public: 00288 ControlMeasureLessThanFunctor(double(ControlMeasure::*accessorMethod)() const) { 00289 m_accessor = accessorMethod; 00290 } 00291 ControlMeasureLessThanFunctor(ControlMeasureLessThanFunctor const &other) { 00292 this->m_accessor = other.m_accessor; 00293 } 00294 ~ControlMeasureLessThanFunctor() {} 00295 00296 bool operator()(ControlMeasure* const &, ControlMeasure* const &); 00297 ControlMeasureLessThanFunctor & operator=(ControlMeasureLessThanFunctor const &other); 00298 00299 private: 00300 double(ControlMeasure::*m_accessor)() const; 00301 }; 00302 00303 00314 class ControlVertex { 00315 public: 00317 ControlVertex(ControlCubeGraphNode *node) { 00318 m_node = node; 00319 m_point = NULL; 00320 m_parent = NULL; 00321 } 00322 00324 ControlVertex(ControlPoint *point) { 00325 m_point = point; 00326 m_node = NULL; 00327 m_parent = NULL; 00328 } 00329 00331 ~ControlVertex() {} 00332 00334 void setParent(ControlVertex *v) { m_parent = v; } 00335 00337 ControlVertex * getRoot() { 00338 ControlVertex *current = this; 00339 while (current->getParent() != NULL) 00340 current = current->getParent(); 00341 return current; 00342 } 00343 00345 ControlVertex * getParent() { return m_parent; } 00346 00348 ControlCubeGraphNode * getNode() { return m_node; } 00349 00351 ControlPoint * getPoint() { return m_point; } 00352 00354 static void join(ControlVertex *v1, ControlVertex *v2) { 00355 v1->getRoot()->setParent(v2->getRoot()); 00356 } 00357 00358 private: 00360 ControlCubeGraphNode *m_node; 00361 00363 ControlPoint *m_point; 00364 00366 ControlVertex *m_parent; 00367 }; 00368 00369 00370 private: // data 00372 QHash< QString, ControlPoint * > * points; 00373 00375 QHash< QString, ControlCubeGraphNode * > * cubeGraphNodes; 00376 QStringList *pointIds; 00377 00378 QString p_targetName; 00379 QString p_networkId; 00380 QString p_created; 00381 QString p_modified; 00382 QString p_description; 00383 QString p_userName; 00384 std::map<QString, Isis::Camera *> p_cameraMap; 00385 std::map<QString, int> p_cameraMeasuresMap; 00386 std::map<QString, int> p_cameraRejectedMeasuresMap; 00387 00388 std::vector<Isis::Camera *> p_cameraList; 00389 std::vector<Distance> p_targetRadii; 00390 00391 bool p_invalid; 00392 }; 00393 } 00394 00395 #endif