1 #include "JigsawRunWidget.h" 3 #include <QtConcurrent> 11 #include "JigsawSetupDialog.h" 20 #include "ImageList.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) {
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() ) );
250 connect( m_bundleAdjust, SIGNAL( finished() ),
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...");
278 m_ui->JigsawAcceptButton->setEnabled(
false);
297 if (!m_outputControlName.isEmpty()) {
300 m_outputControlName);
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;
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);
409 m_destinationFolder = QDir();
429 FileName destination(QFileInfo(m_destinationFolder, image.
name()).absoluteFilePath());
430 m_destinationFolder.mkpath(destination.path());
436 Cube importCube(image,
"r");
441 QDir relative(m_destinationFolder.absolutePath());
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");
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()));
PvlObject & object(const int index)
Return the object at the specified index.
This represents an ISIS control net in a project-based GUI interface.
void setRunTime(QString runTime)
Sets the run time, and the name if a name is not already set.
QString path() const
Returns the path of the file name.
const char * what() const
Returns a string representation of this exception in its current state.
QString name() const
Get the human-readable name of this image list.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Internalizes a list of images and allows for operations on the entire list.
bool outputText()
Outputs a text file with the results of the BundleAdjust.
The main project for ipce.
QList< ImageList * > imageList()
Returns the images used in the bundle.
static QString CurrentLocalTime()
Returns the current local time This time is taken directly from the system clock, so if the system cl...
File name manipulation and expansion.
Container class for BundleAdjustment results.
int objects() const
Returns the number of objects.
BundleSettingsQsp bundleSettings()
Returns bundle settings.
double sigmaCoord1StatisticsRms() const
Returns the RMS of the adjusted sigmas for coordinate 1.
Table spVector(int index)
Return a table spacecraft vector for the ith cube in the cube list given to the constructor.
double sigmaCoord3StatisticsRms() const
Returns the RMS of the adjusted sigmas for coordinate 3.
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
bool outputImagesCSV()
Outputs the bundleout_images.csv file which contains Jigsaw data about the images within each observa...
ControlNetQsp outputControlNet() const
Returns a shared pointer to the output control network.
static QStringList images(QStringList)
Verify that the input fileNames are image files.
bool hasObject(const QString &name) const
Returns a boolean value based on whether the object exists in the current PvlObject or not...
QString name() const
Returns the container name.
void addBundleSolutionInfo(BundleSolutionInfo *bundleSolutionInfo)
Add the given BundleSolutionInfo to the current project.
QString runTime() const
Returns the run time.
void abortBundle()
Flag to abort when bundle is threaded.
double sigmaCoord2StatisticsRms() const
Returns the RMS of the adjusted sigmas for coordinate 2.
Table cMatrix(int index)
Return a table cmatrix for the ith cube in the cube list given to the constructor.
ControlNetQsp controlNet()
Returns a pointer to the output control network.
virtual Isis::Cube * SetInputCube(const QString ¶meter, const int requirements=0)
Opens an input cube specified by the user and verifies requirements are met.
Manipulate and parse attributes of output cube filenames.
void addAdjustedImages(ImageList *images)
Adds a list of images that were adjusted (their labels were updated).
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
This represents a cube in a project-based GUI interface.
Cube * copy(FileName newFile, const CubeAttributeOutput &newFileAttributes)
Copies the cube to the new fileName.
QDir addBundleSolutionInfoFolder(QString folder)
Create and return the name of a folder for placing BundleSolutionInfo.
void setOutputControl(Control *outputControl)
Returns the name of the output control network.
bool isAborted()
Returns if the BundleAdjust has been aborted.
void append(Image *const &value)
Appends an image to the image list.
void deleteObject(const QString &name)
Remove an object from the current PvlObject.
QList< BundleSolutionInfo * > bundleSolutionInfo()
Return BundleSolutionInfo objects in Project.
bool outputResiduals()
Outputs image coordinate residuals to a csv file.
int numberOfImages() const
Returns the number of images.
QString toString() const
Returns a QString of the full file name including the file path, excluding the attributes with any Is...
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Class for storing Table blobs information.
QString path() const
Get the path to the images in the image list (relative to project root).
void write(Blob &blob)
This method will write a blob of data (e.g.
BundleResults bundleResults()
Returns the bundle results.
void relocateDnData(FileName dnDataFile)
Relocates the DN data for a cube to an external cube label file.
Namespace for ISIS/Bullet specific routines.
PvlObject & Label()
Accessor method that returns a PvlObject containing the Blob label.
static QString bundleSolutionInfoRoot(QString projectRoot)
Appends the root directory name 'bundle' to the project results directory.
QString inputControlNetFileName() const
Returns the name of the input control network.
An image bundle adjustment object.
Contains Pvl Groups and Pvl Objects.
Base class for all cube processing derivatives.
QString fileName() const
Access the name of the control network file associated with this Control.
FileName externalCubeFileName() const
If this is an external cube label file, this will give you the cube dn file that this label reference...
void closeCube()
Cleans up the Cube pointer.
QString fileName() const
Get the file name of the cube that this image represents.
bool outputPointsCSV()
Outputs point data to a csv file.
void setClean(bool value)
Function to change the clean state of the project.
IO Handler for Isis Cubes.