Beispiel #1
0
/**
 * Calculates the lat/lon of the ControlNet.
 *
 * @param incubes The filename of the list of cubes in the ControlNet
 * @param cnet    The filename of the ControlNet
 */
void setControlPointLatLon(SerialNumberList &snl, ControlNet &cnet) {
  CubeManager manager;
  manager.SetNumOpenCubes(50);   //Should keep memory usage to around 1GB

  Progress progress;
  progress.SetText("Calculating Lat/Lon");
  progress.SetMaximumSteps(cnet.GetNumPoints());
  progress.CheckStatus();

  for (int cp = 0; cp < cnet.GetNumPoints(); cp++) {
    ControlPoint *point = cnet.GetPoint(cp);
    ControlMeasure *cm = point->GetRefMeasure();

    Cube *cube = manager.OpenCube(snl.FileName(cm->GetCubeSerialNumber()));
    try {
      cube->camera()->SetImage(cm->GetSample(), cm->GetLine());
      g_surfacePoints[point->GetId()] = cube->camera()->GetSurfacePoint();
    }
    catch (IException &e) {
      QString msg = "Unable to create camera for cube file [";
      msg += snl.FileName(cm->GetCubeSerialNumber()) + "]";
      throw IException(e, IException::Unknown, msg, _FILEINFO_);
    }
    cube = NULL; //Do not delete, manager still has ownership

    progress.CheckStatus();
  }

  manager.CleanCubes();
}
Beispiel #2
0
/**
 * Slot to set apriori on selected Points from Navigator list box
 *
 * @author 2011-03-24 Tracie Sucharski
 *
 * @internal
 * @todo  This method should be temporary until the control point editor
 *           comes online.  If this stick around, needs to be re-disigned-
 *           put in a separate class??
 *
 * @history 2011-04-04 Tracie Sucharski - Grey out userEntered if more than
 *                        a single point is selected.  Grey out lat,lon,radius
 *                        edits if UserEntered is not selected.
 * @history 2011-04-13 Tracie Sucharski - If single point selected, fill in
 *                        LineEdit's with current controlPoint values.
 * @history 2011-04-19 Tracie Sucharski - Redesign using modeless dialog.
 * @history 2011-04-26 Tracie Sucharski - Move from QnetNavTool to
 *                        QnetSetAprioriDialog.
 */
void QnetSetAprioriDialog::setApriori() {

    double latSigma = Null;
    double lat = Null;
    double lonSigma = Null;
    double lon = Null;
    double radiusSigma = Null;
    double radius = Null;

    if (latitudeConstraintsGroupBox->isChecked()) {

        if (userEnteredRadioButton->isChecked() && aprioriLatEdit->text() != "") {
            lat = aprioriLatEdit->text().toDouble();
        }
        if (latSigmaEdit->text() != "") {
            latSigma = latSigmaEdit->text().toDouble();
        }
    }
    if (longitudeConstraintsGroupBox->isChecked()) {

        if (userEnteredRadioButton->isChecked() && aprioriLonEdit->text() != "") {
            lon = aprioriLonEdit->text().toDouble();
        }
        if (lonSigmaEdit->text() != "") {
            lonSigma = lonSigmaEdit->text().toDouble();
        }
    }

    if (radiusConstraintsGroupBox->isChecked()) {

        if (userEnteredRadioButton->isChecked() && aprioriRadiusEdit->text() != "") {
            radius = aprioriRadiusEdit->text().toDouble();
        }
        if (radiusSigmaEdit->text() != "") {
            radiusSigma = radiusSigmaEdit->text().toDouble();
        }
    }

    //  If the SetAprioriPoint group box selected, set aprioriSurfacePoint for
    //  those points not editLocked.
    for (int i = 0; i < m_points.size(); i++) {
        QString id = m_points.at(i)->text();
        ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
        if (pt->IsEditLocked()) continue;

        if (!pt->HasAprioriCoordinates()) {
            QString msg = "Point [" + id + "] does not have an Apriori coordinate.  "
                          "Make sure to save the ground source measurement then the Point before "
                          "setting the sigmas.  The sigmas for this point will not be set.";
            QMessageBox::warning((QWidget *)parent(), "Warning", msg);
            continue;
        }

        if (pointSourceGroupBox->isChecked()) {
            if (referenceMeasureRadioButton->isChecked()) {
                ControlMeasure *m = pt->GetRefMeasure();
                // Find camera from network camera list
                int camIndex = m_qnetTool->serialNumberList()->SerialNumberIndex(
                                   m->GetCubeSerialNumber());
                Camera *cam = m_qnetTool->controlNet()->Camera(camIndex);
                cam->SetImage(m->GetSample(),m->GetLine());
                pt->SetAprioriSurfacePoint(cam->GetSurfacePoint());
                pt->SetAprioriSurfacePointSource(ControlPoint::SurfacePointSource::Reference);
            }
            else if (averageMeasuresRadioButton->isChecked()) {
                pt->ComputeApriori();
                // Do not need to set AprioriSurfacePointSource or AprioriRadiusSource,
                // ComputeApriori does this for us.
            }
            else if (userEnteredRadioButton->isChecked()) {
                pt->SetAprioriSurfacePoint(SurfacePoint(
                                               Latitude(lat, Angle::Degrees),
                                               Longitude(lon, Angle::Degrees),
                                               Distance(radius,Distance::Meters)));
                pt->SetAprioriSurfacePointSource(ControlPoint::SurfacePointSource::User);
                pt->SetAprioriRadiusSource(ControlPoint::RadiusSource::User);
            }
        }

        try {
            //  Read Surface point from the control point and set the sigmas,
            //  first set the target radii
            SurfacePoint spt = pt->GetAprioriSurfacePoint();
            vector<Distance> targetRadii = m_qnetTool->controlNet()->GetTargetRadii();
            spt.SetRadii(Distance(targetRadii[0]),
                         Distance(targetRadii[1]),
                         Distance(targetRadii[2]));
            spt.SetSphericalSigmasDistance(Distance(latSigma,Distance::Meters),
                                           Distance(lonSigma,Distance::Meters),
                                           Distance(radiusSigma,Distance::Meters));
            //  Write the surface point back out to the controlPoint
            pt->SetAprioriSurfacePoint(spt);
            //  TODO:  Is the following line necessary, should error be thrown
            //  for free or fixed pts?
            //pt->SetType(ControlPoint::Constrained);
            emit pointChanged(id);
            emit netChanged();
        }
        catch (IException &e)  {
            QString message = "Error setting sigmas. \n";
            message += e.toString();
            QMessageBox::critical((QWidget *)parent(),"Error",message);
            QApplication::restoreOverrideCursor();
            // Sigmas failed, but surface pt coordinate was set
            emit pointChanged(id);
            emit netChanged();
            return;
        }
    }

}
Beispiel #3
0
  /**
   * FindCnetRef traverses all the control points and measures in the network and checks for
   * valid Measure which passes the Emission Incidence Angle, DN value tests and chooses the
   * measure with the best Resolution criteria as the reference. Creates a new control network
   * with these adjustments.
   *
   * @author Sharmila Prasad (5/25/2010)
   * @history 2010-10-04 Sharmila Prasad - Modified for Binary CNet (Edit Lock)
   *
   * @param pNewNet   - Modified output Control Net
   *
   */
  void CnetRefByResolution::FindCnetRef(ControlNet &pNewNet) {
    // Process each existing control point in the network
    int iPointsModified = 0;
    int iMeasuresModified = 0;
    int iRefChanged = 0;

    //Status Report
    mStatus.SetText("Choosing Reference by Resolution...");
    mStatus.SetMaximumSteps(pNewNet.GetNumPoints());
    mStatus.CheckStatus();

    //mPvlLog += GetStdOptions();
    for (int point = 0; point < pNewNet.GetNumPoints(); ++point) {
      ControlPoint *newPnt = pNewNet.GetPoint(point);
      bool bError = false;
      
      // Create a copy of original control point
      const ControlPoint origPnt(*newPnt);

      mdResVector.clear();

      // Logging
      PvlObject pvlPointObj("PointDetails");
      pvlPointObj += Isis::PvlKeyword("PointId", newPnt->GetId());

      // Edit Lock Option
      bool bPntEditLock = newPnt->IsEditLocked();
      if (!bPntEditLock) {
        newPnt->SetDateTime(Application::DateTime());
      }
      else {
        pvlPointObj += Isis::PvlKeyword("Reference", "No Change, PointEditLock"); 
      }

      int iNumMeasuresLocked = newPnt->GetNumLockedMeasures();
      bool bRefLocked = newPnt->GetRefMeasure()->IsEditLocked();
      int numMeasures = newPnt->GetNumMeasures();
      
      int iRefIndex = -1;
      if (newPnt->IsReferenceExplicit())
        iRefIndex = newPnt->IndexOfRefMeasure();
      QString istrTemp;

      std::vector <PvlGroup> pvlGrpVector;
      int iBestIndex = 0;

      // Only perform the interest operation on points of type "Free" and
      // Points having atleast 1 measure and Point is not Ignored
      // Check for EditLock in the Measures and also verfify that
      // only a Reference Measure can be Locked else error
      if (!newPnt->IsIgnored() && newPnt->GetType() == ControlPoint::Free && numMeasures > 0 &&
          (iNumMeasuresLocked == 0 || (iNumMeasuresLocked > 0 && bRefLocked))) {
        int iNumIgnore = 0;
        QString istrTemp;
        for (int measure = 0; measure < newPnt->GetNumMeasures(); ++measure) {
          ControlMeasure *newMsr = newPnt->GetMeasure(measure);
          bool bMeasureLocked = newMsr->IsEditLocked();
          double dSample      = newMsr->GetSample();
          double dLine        = newMsr->GetLine();
          QString sn      = newMsr->GetCubeSerialNumber();

          if (!bPntEditLock && !bMeasureLocked) {
            newMsr->SetDateTime(Application::DateTime());
            newMsr->SetChooserName("Application cnetref(Resolution)");
          }
         
          // Log
          PvlGroup pvlMeasureGrp("MeasureDetails");
          pvlMeasureGrp += Isis::PvlKeyword("SerialNum", sn);
          pvlMeasureGrp += Isis::PvlKeyword("OriginalLocation", LocationString(dSample, dLine));

          if (bMeasureLocked)
            pvlMeasureGrp += Isis::PvlKeyword("EditLock", "True");

          if (!newMsr->IsIgnored()) {
            Cube *measureCube = mCubeMgr.OpenCube(mSerialNumbers.FileName(sn));
            
            MeasureValidationResults results =
              ValidStandardOptions(newMsr, measureCube, &pvlMeasureGrp);
            if (!results.isValid()) {
              if (bPntEditLock) {
                pvlMeasureGrp += Isis::PvlKeyword("UnIgnored", "Failed Validation Test but not Ignored as Point EditLock is True");
              }
              else if (bMeasureLocked) {
                pvlMeasureGrp += Isis::PvlKeyword("UnIgnored", "Failed Validation Test but not Ignored as Measure EditLock is True");
              }
              else {
                pvlMeasureGrp += Isis::PvlKeyword("Ignored", "Failed Validation Test");
                newMsr->SetIgnored(true);
                iNumIgnore++;
              }
            } // valid measure
            else {
              if (!bPntEditLock && !bRefLocked) {
                newMsr->SetType(ControlMeasure::Candidate);
                newMsr->SetIgnored(false);
                mdResVector.push_back(mdResolution);
              }
            }
          } // Ignore == false
          else {
            pvlMeasureGrp += Isis::PvlKeyword("Ignored", "Originally Ignored");
            iNumIgnore++;
          }
          if (newMsr != origPnt.GetMeasure(measure)) {
            iMeasuresModified++;
          }

          //newPnt.UpdateMeasure(newMsr); // Redesign fixed this
          pvlGrpVector.push_back(pvlMeasureGrp);
        }// end Measure

        if ((newPnt->GetNumMeasures() - iNumIgnore) < 2) {
          if (bPntEditLock) {
            pvlPointObj += Isis::PvlKeyword("UnIgnored", "Good Measures less than 2 but not Ignored as Point EditLock is True");
          }
          else {
            newPnt->SetIgnored(true);
            pvlPointObj += Isis::PvlKeyword("Ignored", "Good Measures less than 2");
          }
        }
        // Set the Reference if the Point is unlocked and Reference measure is unlocked
        if (!newPnt->IsIgnored() && !bPntEditLock && !bRefLocked) {
          iBestIndex = GetReferenceByResolution(newPnt);
          if (iBestIndex >= 0 && !newPnt->GetMeasure(iBestIndex)->IsIgnored()) {
            newPnt->SetRefMeasure(iBestIndex);
            //newPnt.UpdateMeasure(cm); // Redesign fixed this
            pvlGrpVector[iBestIndex] += Isis::PvlKeyword("Reference", "true");
          }
          else {
            if (iBestIndex < 0 && meType == Range) {
              pvlPointObj += Isis::PvlKeyword("NOTE", "No Valid Measures within the Resolution Range. Reference defaulted to the first Measure");
            }
            iBestIndex = 0;
            newPnt->SetRefMeasure(iBestIndex);
            //newPnt.UpdateMeasure(cm); // Redesign fixed this

            // Log info, if Point not locked, apriori source == Reference and a new reference
            if (iRefIndex != iBestIndex &&
                newPnt->GetAprioriSurfacePointSource() == ControlPoint::SurfacePointSource::Reference) {
              pvlGrpVector[iBestIndex] += Isis::PvlKeyword("AprioriSource", "Reference is the source and has changed");
            }
          }
        }

        for (int i = 0; i < newPnt->GetNumMeasures(); i++) {
          pvlPointObj += pvlGrpVector[i];
        }
      } // end Free
      else {
        int iComment = 0;
        if (numMeasures == 0) {
          QString sComment = "Comment";
          sComment += QString(++iComment);
          pvlPointObj += Isis::PvlKeyword(sComment, "No Measures in the Point");
        }

        if (newPnt->IsIgnored()) {
          QString sComment = "Comment";
          sComment += QString(++iComment);
          pvlPointObj += Isis::PvlKeyword(sComment, "Point was originally Ignored");
        }

        if (newPnt->GetType() == ControlPoint::Fixed) {
          QString sComment = "Comment";
          sComment += QString(++iComment);
          pvlPointObj += Isis::PvlKeyword(sComment, "Fixed Point");
        }
        else if (newPnt->GetType() == ControlPoint::Constrained) {
          QString sComment = "Comment";
          sComment += QString(++iComment);
          pvlPointObj += Isis::PvlKeyword(sComment, "Constrained Point");
        }

        if (iNumMeasuresLocked > 0 && !bRefLocked) {
          pvlPointObj += Isis::PvlKeyword("Error", "Point has a Measure with EditLock set to true "
                                          "but the Reference is not Locked");
          bError = true;
        }
        else {
          for (int measure = 0; measure < newPnt->GetNumMeasures(); measure++) {
            ControlMeasure *cm = newPnt->GetMeasure(iBestIndex);
            cm->SetDateTime(Application::DateTime());
            cm->SetChooserName("Application cnetref(Resolution)");
            //newPnt.UpdateMeasure(cm); // Redesign fixed this
          }
        } 
      }

      if (*newPnt != origPnt) {
        iPointsModified++;
      }
      
      if (!bError && !newPnt->IsIgnored() && newPnt->IsReferenceExplicit() && iBestIndex != iRefIndex 
          && !bPntEditLock && !bRefLocked) {
        iRefChanged++;
        PvlGroup pvlRefChangeGrp("ReferenceChangeDetails");
        if (iRefIndex >= 0) {
          pvlRefChangeGrp += Isis::PvlKeyword("PrevSerialNumber",
              origPnt.GetMeasure(iRefIndex)->GetCubeSerialNumber());
          pvlRefChangeGrp += Isis::PvlKeyword("PrevResolution",   toString(mdResVector[iRefIndex]));
  
          istrTemp = QString((int)origPnt.GetMeasure(iRefIndex)->GetSample());
          istrTemp += ",";
          istrTemp += QString((int)origPnt.GetMeasure(iRefIndex)->GetLine());
          pvlRefChangeGrp += Isis::PvlKeyword("PrevLocation",     istrTemp);
        }
        else {
          pvlRefChangeGrp += Isis::PvlKeyword("PrevReference", "Not Set");
        }
        
        pvlRefChangeGrp += Isis::PvlKeyword("NewSerialNumber",
            newPnt->GetMeasure(iBestIndex)->GetCubeSerialNumber());
        QString sKeyName = "NewHighestResolution";
        if (meType == Low) {
          sKeyName = "NewLeastResolution";
        }
        else if (meType == Mean) {
          pvlRefChangeGrp += Isis::PvlKeyword("MeanResolution",  toString(GetMeanResolution()));
          sKeyName = "NewResolutionNeartoMean";
        }
        else if (meType == Nearest) {
          sKeyName = "NewResolutionNeartoValue";
        }
        else if (meType == Range) {
          sKeyName = "NewResolutionInRange";
        }
        pvlRefChangeGrp += Isis::PvlKeyword(sKeyName,  toString(mdResVector[iBestIndex]));

        istrTemp = QString((int)newPnt->GetMeasure(iBestIndex)->GetSample());
        istrTemp += ",";
        istrTemp += QString((int)newPnt->GetMeasure(iBestIndex)->GetLine());
        pvlRefChangeGrp += Isis::PvlKeyword("NewLocation",      istrTemp);

        pvlPointObj += pvlRefChangeGrp;
      }
      else {
        pvlPointObj += Isis::PvlKeyword("Reference", "No Change");
      }

      //pNewNet.UpdatePoint(newPnt); // Redesign fixed this
      mPvlLog += pvlPointObj;
      mStatus.CheckStatus();
    }// end Point

    // CnetRef Change Statistics
    mStatisticsGrp += Isis::PvlKeyword("PointsModified",   toString(iPointsModified));
    mStatisticsGrp += Isis::PvlKeyword("ReferenceChanged", toString(iRefChanged));
    mStatisticsGrp += Isis::PvlKeyword("MeasuresModified", toString(iMeasuresModified));

    mPvlLog += mStatisticsGrp;
  }
Beispiel #4
0
  /**
   * Repaint the viewport
   *
   * @internal
   *   @history 2011-08-23  Tracie Sucharski - Use the GetMeasuresInCube method
   *                           from ControlNet to get list of measures rather
   *                           than searching through entire net.
   *   @history 2011-11-09 Tracie Sucharski - If there are no measures for
   *                          this cube, return.
   */
  void ChipViewport::paintEvent(QPaintEvent *e) {
    QPainter painter(this);

    if (p_tempView != NULL) {
      painter.drawImage(0, 0, *(p_tempView->p_image));
    }
    else {
      painter.drawImage(0, 0, *p_image);
    }

    if (p_cross == true) {
      painter.setPen(Qt::red);
      painter.drawLine(0, (p_height - 1) / 2, p_width - 1, (p_height - 1) / 2);
      painter.drawLine((p_width - 1) / 2, 0, (p_width - 1) / 2, p_height - 1);
    }

    if (p_circle == true) {
      painter.setPen(Qt::red);
      painter.drawEllipse((p_height - 1) / 2 - p_circleSize / 2,
                          (p_width - 1) / 2 - p_circleSize / 2,
                          p_circleSize, p_circleSize);
    }

    QString serialNumber = p_chipCube? SerialNumber::Compose(*p_chipCube) : QString();
    if (p_controlNet && !serialNumber.isEmpty() && p_controlNet->GetCubeSerials().contains(
                             serialNumber)) {
      // draw measure locations if we have a control network
      //  If the serial number is Unknown, we probably have a ground source
      //  file or level 2 which means it does not exist in the network
      //  TODO:  Is there a better way to handle this?
      if (p_showPoints && serialNumber.compare("Unknown") &&
          p_controlNet->GetNumPoints() != 0) {
        QList<ControlMeasure *> measures =
                                   p_controlNet->GetMeasuresInCube(serialNumber);
        // loop through all points in the control net
        for (int i = 0; i < measures.count(); i++) {
          ControlMeasure *m = measures[i];
          // Find the measurments on the viewport
          double samp = m->GetSample();
          double line = m->GetLine();
          int x, y;

          cubeToViewport(samp, line, x, y);
          // Determine pen color
          // if the point or measure is ignored set to yellow
          if (m->Parent()->IsIgnored() ||
             (!m->Parent()->IsIgnored() && m->IsIgnored())) {
            painter.setPen(QColor(255, 255, 0)); // set point marker yellow
          }
          // check for ground measure
          else if (m->Parent()->GetType() == ControlPoint::Fixed) {
            painter.setPen(Qt::magenta);// set point marker magenta
          }
          else {
            painter.setPen(Qt::green); // set all other point markers green
          }

          // draw points which are not under cross
          if (x != (p_width - 1) / 2 || y != (p_height - 1) / 2) {
            painter.drawLine(x - 5, y, x + 5, y);
            painter.drawLine(x, y - 5, x, y + 5);
          }
        }
      }
    }

    p_tempView = NULL;
    //painter.end();

  }