1#include "JigsawRunWidget.h"
11#include "JigsawSetupDialog.h"
13#include "BundleAdjust.h"
14#include "BundleSolutionInfo.h"
18#include "IException.h"
21#include "JigsawSetupDialog.h"
26#include "ui_JigsawRunWidget.h"
40 m_selectedControl = NULL;
60 QString outputControlFileName,
64 m_bundleSettings = bundleSettings;
65 m_selectedControl = selectedControl;
67 m_outputControlName = outputControlFileName;
86 m_ui->JigsawRunButton->setEnabled(
false);
88 m_bundleAdjust = NULL;
94 if (bundleSolutionInfo.size() <= 0) {
95 m_ui->useLastSettings->setEnabled(
false);
98 QString lastSettingsToolTip(
"Use the settings from the most recently accepted bundle adjust.");
99 QString lastSettingsWhat(
"When checked, the settings from the most recently accepted bundle "
100 "adjust (i.e. the most recent bundle results in the project) will be "
101 "used for running the next bundle adjust when \"Run\" is clicked.");
102 m_ui->useLastSettings->setToolTip(lastSettingsToolTip);
103 m_ui->useLastSettings->setWhatsThis(lastSettingsWhat);
115 if (m_bundleAdjust) {
116 m_bundleAdjust->deleteLater();
117 m_bundleAdjust = NULL;
131 void JigsawRunWidget::on_JigsawSetupButton_clicked() {
139 m_ui->useLastSettings->isChecked(),
148 BundleSettingsQsp lastBundleSettings = (bundleSolutionInfo.last())->bundleSettings();
149 setupdlg.loadSettings(lastBundleSettings);
151 setupdlg.selectControl(m_selectedControlName);
153 else if (m_bundleSettings) {
154 setupdlg.loadSettings(m_bundleSettings);
156 setupdlg.selectControl(m_selectedControlName);
159 if (setupdlg.exec() == QDialog::Accepted) {
160 m_selectedControlName = setupdlg.selectedControlName();
161 m_outputControlName = setupdlg.outputControlName();
162 m_selectedControl = setupdlg.selectedControl();
163 m_bundleSettings = setupdlg.bundleSettings();
165 m_ui->useLastSettings->setChecked(
false);
166 m_ui->JigsawRunButton->setEnabled(
true);
171 void JigsawRunWidget::on_JigsawRunButton_clicked() {
173 m_ui->JigsawAcceptButton->setEnabled(
false);
174 m_ui->statusOutputLabel->setText(
"Initialization");
178 if (m_selectedControl == NULL) {
181 if (m_project->images().size() == 0) {
185 if (m_bundleSettings == NULL) {
188 QList<BundleSolutionInfo *> bundleSolutionInfo = m_project->bundleSolutionInfo();
189 if (
m_ui->useLastSettings->isChecked() && bundleSolutionInfo.size() > 0) {
190 BundleSettingsQsp lastBundleSettings = (bundleSolutionInfo.last())->bundleSettings();
192 if (lastBundleSettings) {
193 m_bundleSettings = lastBundleSettings;
197 m_selectedControlName
198 = FileName(bundleSolutionInfo.last()->inputControlNetFileName()).name();
207 if (m_bundleAdjust) {
208 delete m_bundleAdjust;
209 m_bundleAdjust = NULL;
212 m_bundleAdjust =
new BundleAdjust(m_bundleSettings, *m_selectedControl, m_project->images(),
218 connect( m_bundleAdjust, SIGNAL( statusUpdate(QString) ),
222 connect( m_bundleAdjust, SIGNAL( error(QString) ),
226 connect( m_bundleAdjust, SIGNAL( iterationUpdate(
int) ),
229 connect( m_bundleAdjust, SIGNAL( pointUpdate(
int) ),
232 connect( m_bundleAdjust, SIGNAL( statusBarUpdate(QString) ),
237 m_bundleAdjust, SLOT( solveCholesky() ) );
241 connect( m_bundleAdjust, SIGNAL( resultsReady(BundleSolutionInfo *) ),
250 connect( m_bundleAdjust, SIGNAL( finished() ),
253 m_ui->imagesLcdNumber->display(m_bundleAdjust->numberOfImages());
254 m_ui->pointsLcdNumber->display(m_bundleAdjust->controlNet()->GetNumPoints());
255 m_ui->measuresLcdNumber->display(m_bundleAdjust->controlNet()->GetNumMeasures());
261 m_ui->JigsawRunButton->setText(
"&Abort");
266 m_ui->JigsawRunButton->setText(
"&Aborting...");
267 m_ui->statusOutputLabel->setText(
"Aborting...");
268 m_bundleAdjust->abortBundle();
278 m_ui->JigsawAcceptButton->setEnabled(
false);
282 QDir bundleDir = m_project->addBundleSolutionInfoFolder(runTime);
297 if (!m_outputControlName.isEmpty()) {
299 =
FileName(m_project->bundleSolutionInfoRoot() +
"/" + runTime +
"/" +
300 m_outputControlName);
304 =
FileName(m_project->bundleSolutionInfoRoot() +
"/" + runTime +
"/Out-" + runTime +
"-" +
314 if (
m_ui->detachedLabelsCheckBox->isChecked()) {
317 foreach (
ImageList *imageList, imageLists) {
323 foreach (
Image *image, *imageList) {
326 imagesToCopy.append(original.
expanded());
332 QFuture<Cube *> copiedCubes = QtConcurrent::mapped(imagesToCopy, copyImage);
338 for (
int i = 0; i < imagesToCopy.size(); i++) {
339 Cube *ecub = copiedCubes.resultAt(i);
350 for (
int iobj = 0; iobj < ecub->
label()->objects(); iobj++) {
352 if (obj.
name() !=
"Table")
continue;
353 if (obj[
"Name"][0] != QString(
"CameraStatistics"))
continue;
360 Table cMatrix = m_bundleAdjust->cMatrix(i);
361 Table spVector = m_bundleAdjust->spVector(i);
362 cMatrix.
Label().addComment(bundleTimestamp);
363 spVector.
Label().addComment(bundleTimestamp);
364 ecub->
write(cMatrix);
365 ecub->
write(spVector);
368 adjustedImages->
append(newImage);
383 m_ui->useLastSettings->setEnabled(
true);
392 m_project->setClean(
false);
436 Cube importCube(image,
"r");
443 QString s = relative.relativeFilePath(dnCubeFileName.
toString());
448 dnCubeFileName =
FileName(QDir(image.
path()).canonicalPath() +
"/" +
450 Cube dnCube(dnCubeFileName,
"r");
459 Cube dnCube(dnCubeFileName,
"r");
466 std::cout <<
"\nerror: " << e.
what();
478 m_ui->statusUpdatesLabel->clear();
479 m_ui->iterationLcdNumber->display(0);
480 m_ui->pointLcdNumber->display(0);
482 m_ui->imagesLcdNumber->display(0);
483 m_ui->pointsLcdNumber->display(0);
484 m_ui->measuresLcdNumber->display(0);
486 m_ui->rmsAdjustedPointSigmasGroupBox->setEnabled(
false);
487 m_ui->latitudeLcdNumber->display(0);
488 m_ui->longitudeLcdNumber->display(0);
489 m_ui->radiusLcdNumber->display(0);
499 m_ui->statusUpdateScrollArea->verticalScrollBar()->setSliderPosition(
500 m_ui->statusUpdateScrollArea->verticalScrollBar()->maximum());
511 QString updateStr =
"\n" + status;
513 m_ui->statusUpdatesLabel->setText(
m_ui->statusUpdatesLabel->text().append(updateStr) );
527 QString errorStr =
"\n" + error;
528 m_ui->statusUpdatesLabel->setText(
m_ui->statusUpdatesLabel->text().append(errorStr) );
542 QString exceptionStr =
"\n" + exception;
543 m_ui->statusUpdatesLabel->setText(
m_ui->statusUpdatesLabel->text().append(exceptionStr) );
557 m_ui->iterationLcdNumber->display(iteration);
568 m_ui->pointLcdNumber->display(point);
579 m_ui->statusOutputLabel->setText(status);
596 m_ui->JigsawRunButton->setText(
"&Run");
598 if (m_bundleAdjust->isAborted()) {
599 m_ui->statusOutputLabel->setText(
"Aborted");
602 if (m_bundleSettings->errorPropagation()) {
603 m_ui->rmsAdjustedPointSigmasGroupBox->setEnabled(
true);
604 m_ui->latitudeLcdNumber->display(
606 m_ui->longitudeLcdNumber->display(
609 if (m_bundleSettings->solveRadius()) {
610 m_ui->radiusLcdNumber->display(
612 m_ui->radiusLcdNumber->setEnabled(
true);
613 m_ui->radiusLcdLabel->setEnabled(
true);
616 m_ui->radiusLcdNumber->setEnabled(
false);
617 m_ui->radiusLcdLabel->setEnabled(
false);
622 m_ui->rmsAdjustedPointSigmasGroupBox->setEnabled(
false);
649 m_ui->JigsawAcceptButton->setEnabled(
true);
662 QMessageBox::StandardButton resBtn =
663 QMessageBox::question(
this,
665 tr(
"You are about to abort the bundle adjustment. Are you sure?\n"),
666 QMessageBox::No | QMessageBox::Yes);
667 if (resBtn != QMessageBox::Yes) {
674 connect(
m_bundleThread, SIGNAL(finished()),
this, SLOT(deleteLater()));
675 m_bundleAdjust->abortBundle();
Container class for BundleAdjustment results.
void setRunTime(QString runTime)
Sets the run time, and the name if a name is not already set.
This represents an ISIS control net in a project-based GUI interface.
QString fileName() const
Access the name of the control network file associated with this Control.
Manipulate and parse attributes of output cube filenames.
IO Handler for Isis Cubes.
void relocateDnData(FileName dnDataFile)
Relocates the DN data for a cube to an external cube label file.
FileName externalCubeFileName() const
If this is an external cube label file, this will give you the cube dn file that this label reference...
Cube * copy(FileName newFile, const CubeAttributeOutput &newFileAttributes)
Copies the cube to the new fileName.
void write(Blob &blob, bool overwrite=true)
This method will write a blob of data (e.g.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
File name manipulation and expansion.
QString path() const
Returns the path of the file name.
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
QString toString() const
Returns a QString of the full file name including the file path, excluding the attributes with any Is...
const char * what() const
Returns a string representation of this exception in its current state.
This represents a cube in a project-based GUI interface.
void closeCube()
Cleans up the Cube pointer.
QString fileName() const
Get the file name of the cube that this image represents.
Internalizes a list of images and allows for operations on the entire list.
QString path() const
Get the path to the images in the image list (relative to project root).
void append(Image *const &value)
Appends an image to the image list.
QString name() const
Get the human-readable name of this image list.
Base class for all cube processing derivatives.
virtual Isis::Cube * SetInputCube(const QString ¶meter, const int requirements=0)
Opens an input cube specified by the user and verifies requirements are met.
The main project for ipce.
QList< BundleSolutionInfo * > bundleSolutionInfo()
Return BundleSolutionInfo objects in Project.
QString name() const
Returns the container name.
Contains Pvl Groups and Pvl Objects.
bool hasObject(const QString &name) const
Returns a boolean value based on whether the object exists in the current PvlObject or not.
void deleteObject(const QString &name)
Remove an object from the current PvlObject.
PvlObject & object(const int index)
Return the object at the specified index.
Class for storing Table blobs information.
PvlObject & Label()
The Table's label.
static QString CurrentLocalTime()
Returns the current local time This time is taken directly from the system clock, so if the system cl...
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
QSharedPointer< BundleSettings > BundleSettingsQsp
Definition for a BundleSettingsQsp, a shared pointer to a BundleSettings object.