6 #include <QApplication> 11 #include <QMessageBox> 15 #include <QPrintDialog> 19 #include "BrowseDialog.h" 22 #include "FileDialog.h" 24 #include "MainWindow.h" 32 #include "SaveAsDialog.h" 34 #include "ViewportMainWindow.h" 48 p_dir =
"/thisDirDoesNotExist!";
50 p_open->setShortcut(Qt::CTRL + Qt::Key_O);
51 p_open->setText(
"&Open...");
53 p_open->setToolTip(
"Open cube");
55 "<b>Function:</b> Open an <i>Isis cube</i> in new viewport \ 56 <p><b>Shortcut:</b> Ctrl+O\n</p> \ 57 <p><b>Hint:</b> Use Ctrl or Shift in file dialog to open \ 59 p_open->setWhatsThis(whatsThis);
60 connect(
p_open, SIGNAL(triggered()),
this, SLOT(
open()));
63 p_browse->setShortcut(Qt::CTRL + Qt::Key_B);
65 p_browse->setToolTip(
"Browse cubes");
67 "<b>Function:</b> Browse a <i>Isis cubes</i> in new viewport \ 68 <p><b>Shortcut:</b> Ctrl+B\n</p>";
73 p_save->setShortcut(Qt::CTRL + Qt::Key_S);
76 p_save->setToolTip(
"Save");
78 "<b>Function:</b> Save changes to the current Cube \ 79 <p><b>Shortcut:</b> Ctrl+S</p>";
80 p_save->setWhatsThis(whatsThis);
81 connect(
p_save, SIGNAL(triggered()),
this, SLOT(
save()));
89 "<b>Function:</b> Save the current Cube to the specified location";
99 "<b>Function:</b> Save the current Cube's Whatsthis Info to the specified location";
109 "<b>Function:</b> Save visible contents of the active \ 110 viewport as a png, jpg, tiff \ 111 <p><b>Hint:</b> Your local installation of Qt may not support \ 112 all formats. Reinstall Qt if necessary</p>";
122 "<b>Function:</b> Save all open cubes \ 123 to a .lis file containing their file names";
130 p_print->setShortcut(Qt::CTRL + Qt::Key_P);
134 "<b>Function:</b> Print visible contents of the active viewport \ 135 <p><b>Shortcut:</b> Ctrl+P</b>";
136 p_print->setWhatsThis(whatsThis);
137 connect(
p_print, SIGNAL(triggered()),
this, SLOT(
print()));
144 "<b>Function:</b> Close all cube viewports.";
148 p_exit->setShortcut(Qt::CTRL + Qt::Key_Q);
152 "<b>Function:</b> Quit qview \ 153 <p><b>Shortcut:</b> Ctrl+Q</p>";
154 p_exit->setWhatsThis(whatsThis);
155 connect(
p_exit, SIGNAL(triggered()),
this, SLOT(
exit()));
192 ws, SLOT(addCubeViewport(QString)));
194 connect(
p_closeAll, SIGNAL(triggered()), ws->
mdiArea(), SLOT(closeAllSubWindows()));
221 if (!
p_dir.exists()) {
222 p_dir = QDir::current();
242 if (!
p_dir.exists()) {
243 p_dir = QDir::current();
261 QMessageBox::information((
QWidget *)parent(),
"Error",
"No active cube to save");
266 p_save->setEnabled(
false);
287 QMessageBox::information((
QWidget *)parent(),
"Error",
"No active cube to save");
294 if (!
p_dir.exists()) {
320 QMessageBox::information((
QWidget *)parent(),
"Error",
321 "No active cube to save");
327 QMessageBox::information((
QWidget *)parent(),
"Error",
328 "No output file selected");
335 for (it = vwportList->begin(); it != vwportList->end(); ++it){
336 if (QString((*it)->cube()->fileName()) == psOutFile) {
337 QMessageBox::information((
QWidget *)parent(),
"Error",
338 "Output File is already open\n\""+ psOutFile +
"\"");
359 if (
p_saveAsDialog->getSaveAsType() != SaveAsDialog::ExportAsIs ||
373 double dStartSample=0, dEndSample=0, dStartLine=0, dEndLine=0;
374 p_lastViewport->getCubeArea(dStartSample, dEndSample, dStartLine, dEndLine);
376 if (
p_saveAsDialog->getSaveAsType() == SaveAsDialog::ExportFullRes ||
380 int numSamples = (int)((dEndSample - dStartSample + 1) + 0.5);
381 int numLines = (int)((dEndLine - dStartLine + 1) + 0.5);
386 else if (
p_saveAsDialog->getSaveAsType() == SaveAsDialog::ExportAsIs ) {
394 p_save->setEnabled(
false);
414 double dStartSample=0, dEndSample=0, dStartLine=0, dEndLine=0;
415 p_lastViewport->getCubeArea(dStartSample, dEndSample, dStartLine, dEndLine);
417 double ins = dEndSample - dStartSample + 1;
418 double inl = dEndLine - dStartLine + 1;
420 double ons = (int)(ins * dScale + 0.5);
421 double onl = (int)(inl * dScale + 0.5);
432 imgEnlarge->
SetInputArea((
int)dStartSample, (
int)dEndSample, (
int)dStartLine, (
int)dEndLine);
445 QObject::tr(
"The cube could not be saved, unable to create the cube"),
464 double dStartSample=0, dEndSample=0, dStartLine=0, dEndLine=0;
465 p_lastViewport->getCubeArea(dStartSample, dEndSample, dStartLine, dEndLine);
467 double ins = dEndSample - dStartSample + 1;
468 double inl = dEndLine - dStartLine + 1;
470 double ons = (int)(ins * dScale + 0.5);
471 double onl = (int)(inl * dScale + 0.5);
474 std::vector<QString> bands = cai.
bands();
475 int inb = bands.size();
479 for(
int i = 1; i <= inb; i++) {
496 near->
setInputBoundary((
int)dStartSample, (
int)dEndSample, (
int)dStartLine, (
int)dEndLine);
511 QObject::tr(
"The cube could not be saved, unable to create the cube"),
553 Cube *ocube,
int piNumSamples,
int piNumLines,
int piNumBands) {
576 double base = icube->
base();
584 (ocube->
pixelType() != Isis::UnsignedInteger) &&
585 (ocube->
pixelType() != Isis::SignedInteger)) {
586 QString msg =
"Looks like your refactoring to add different pixel types";
587 msg +=
" you'll need to make changes here";
591 QString msg =
"You've chosen to reduce your output PixelType for [" +
592 psOutFile +
"] you must specify the output pixel range too";
601 int needLabBytes = icube->
labelSize(
true) + (1024 * 6);
612 for(
int i = 0; i < incube.
groups(); i++) {
618 for(
int i = 0; i < inlab.
objects(); i++) {
627 inlab = *icube->
label();
628 for(
int i = 0; i < inlab.
objects(); i++) {
637 inlab = *icube->
label();
638 for(
int i = 0; i < inlab.
objects(); i++) {
669 if (ibrick.Bricks() > obrick.Bricks()) {
670 numBricks = ibrick.
Bricks();
673 numBricks = obrick.Bricks();
679 for(
int i = 0; i < numBricks; i++) {
682 copy(ibrick, obrick);
683 ocube->
write(obrick);
702 Cube *pOutCube,
int pNumSamples,
int pNumLines) {
704 double dStartSample=0, dEndSample=0, dStartLine=0, dEndLine=0;
705 p_lastViewport->getCubeArea(dStartSample, dEndSample, dStartLine, dEndLine);
721 dEndLine, dEndSample, 1.0, 1.0);
727 for(
int iBand=1; iBand<=iNumBands; iBand++) {
729 for(
int iLine=(
int)dStartLine; iLine<=(int)dEndLine; iLine++) {
731 pInCube->
read(iPortal);
733 oPortal.SetPosition(1, ol++, iBand);
734 pOutCube->
read(oPortal);
736 oPortal.Copy(iPortal);
737 pOutCube->
write(oPortal);
752 QMessageBox::information((
QWidget *)parent(),
"Error",
"No active cube to save info");
758 QFileDialog::getSaveFileName((
QWidget *)parent(),
759 "Choose output file",
761 QString(
"PVL Files (*.pvl)"));
764 if (output.isEmpty()) {
767 else if (!output.endsWith(
".pvl")) {
773 whatsThisPvl.
write(output);
804 QMessageBox::information((
QWidget *)parent(),
"Error",
"No active cube to export");
809 QFileDialog::getSaveFileName((
QWidget *)parent(),
810 QString(
"Choose output file"),
812 QString(
"PNG (*.png);;JPG (*.jpg);;TIF (*.tif)"));
813 if (output.isEmpty())
return;
817 QString format = QFileInfo(output).suffix();
819 if (format.isEmpty()) {
820 if (output.endsWith(
'.')) {
821 output.append(QString(
"png"));
824 output.append(QString(
".png"));
827 else if (format.compare(
"png", Qt::CaseInsensitive) &&
828 format.compare(
"jpg", Qt::CaseInsensitive) &&
829 format.compare(
"tif", Qt::CaseInsensitive)) {
831 QMessageBox::information((
QWidget *)parent(),
"Error", format +
" is an invalid extension.");
839 if (!pm.save(output)) {
840 QMessageBox::information((
QWidget *)parent(),
"Error",
"Unable to save " + output);
856 QMessageBox::information((
QWidget *)parent(),
"Error",
"No active cubes to export");
865 if (window == NULL) {
866 QMessageBox::critical((
QWidget *)parent(),
"Error",
"There was an error reading the viewport window.");
873 for (
int i = 0; i < openCubes.size(); i++) {
880 cubeFilePaths.append(cubeFileName.absoluteFilePath());
883 QString fileName = QFileDialog::getSaveFileName((
QWidget *) parent(),
884 "Export to cube list",
886 "Cube List (*.lis)");
888 if (!fileName.contains(
".lis")) {
889 fileName.append(
".lis");
892 QFile outputFile(fileName);
893 outputFile.open(QIODevice::WriteOnly | QIODevice::Text);
895 QTextStream out(&outputFile);
898 for (
int i = 0; i < cubeFilePaths.size(); i++){
899 out << cubeFilePaths.value(i) <<
"\n";
912 QMessageBox::information((
QWidget *)parent(),
"Error",
"No active cube to print");
917 static QPrinter *printer = NULL;
918 if (printer == NULL) printer =
new QPrinter;
919 printer->setPageSize(QPrinter::Letter);
920 printer->setColorMode(QPrinter::GrayScale);
921 if (
cubeViewport()->isColor()) printer->setColorMode(QPrinter::Color);
923 QPrintDialog printDialog(printer, (
QWidget *)parent());
924 if (printDialog.exec() == QDialog::Accepted) {
927 QImage img = pixmap.toImage();
930 QPainter painter(printer);
931 QRect rect = painter.viewport();
932 QSize size = img.size();
933 size.scale(rect.size(), Qt::KeepAspectRatio);
934 painter.setViewport(rect.x(), rect.y(),
935 size.width(), size.height());
936 painter.setWindow(img.rect());
937 painter.drawImage(0, 0, img);
952 for(
int i = 0; i < (int)tempList.size(); i++) {
957 if (!d->parentWidget()->close()) {
986 p_save->setEnabled(enable);
999 p_save->setEnabled(
false);
1014 if (
cubeViewport()->parentWidget()->windowTitle().endsWith(
"*")) {
1015 p_save->setEnabled(
true);
1019 p_save->setEnabled(
false);
PvlObject & object(const int index)
Return the object at the specified index.
Cube display widget for certain Isis MDI applications.
Buffer for reading and writing cube data.
Read and store original labels.
void ProcessCubeInPlace(const Functor &funct, bool threaded=true)
Same functionality as StartProcess(void funct(Isis::Buffer &inout)) using Functors.
virtual void StartProcess(Transform &trans, Interpolator &interp)
Applies a Transform and an Interpolator to every pixel in the output cube.
void EndProcess()
End the processing sequence and cleans up by closing cubes, freeing memory, etc.
PixelType pixelType() const
Return the pixel type as an Isis::PixelType.
Isis::Cube * SetInputCube(const QString ¶meter, const int requirements=0)
Opens an input cube specified by the user and verifies requirements are met.
ByteOrder byteOrder() const
Return the byte order as an Isis::ByteOrder.
int objects() const
Returns the number of objects.
Class for browsing cubes.
Buffer for containing a two dimensional section of an image.
Widget to save(Save As) Isis cubes(used in qview) to display the FileDialog to select the output cube...
double base() const
Returns the base value for converting 8-bit/16-bit pixels to 32-bit.
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
void getAllWhatsThisInfo(Pvl &pWhatsThisPvl)
Get All WhatsThis info - viewport, cube, area in PVL format.
virtual Cube * SetOutputCube(const QString &fname, const CubeAttributeOutput &att)
Create the output file.
void addGroup(const Isis::PvlGroup &group)
Add a group to the object.
Buffer for containing a three dimensional section of an image.
void setFormat(Format format)
Used prior to the Create method, this will specify the format of the cube, either band...
bool propagatePixelType() const
Return true if the pixel type is to be propagated from an input cube.
void setLabelsAttached(bool attached)
Use prior to calling create, this sets whether or not to use separate label and data files...
bool propagateMinimumMaximum() const
Return true if the min/max are to be propagated from an input cube.
void Copy(const Buffer &in, bool includeRawBuf=true)
Allows copying of the buffer contents to another Buffer.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Widget to display Isis cubes for qt apps.
This error is for when a programmer made an API call that was illegal.
A type of error that occurred when performing an actual I/O operation.
virtual void EndProcess()
End the processing sequence and cleans up by closing cubes, freeing memory, etc.
void setDimensions(int ns, int nl, int nb)
Used prior to the Create method to specify the size of the cube.
void reopen(QString access="r")
This method will reopen an isis sube for reading or reading/writing.
QString name() const
Returns the container name.
This was called the Qisis MainWindow.
void SetSubArea(const int orignl, const int origns, const int sl, const int ss, const int el, const int es, const double linc, const double sinc)
Defines the subarea.
void setPixelType(PixelType pixelType)
Used prior to the Create method, this will specify the output pixel type.
Derivative of Process, designed for geometric transformations.
int Bricks()
Returns the number of Bricks in the cube.
Contains multiple PvlContainers.
virtual Isis::Cube * SetInputCube(const QString ¶meter, const int requirements=0)
Opens an input cube specified by the user and verifies requirements are met.
#define _FILEINFO_
Macro for the filename and line number.
Enlarge the pixel dimensions of an image.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Manipulate and parse attributes of output cube filenames.
A type of error that could only have occurred due to a mistake on the user's part (e...
void setBaseMultiplier(double base, double mult)
Used prior to the Create method, this will specify the base and multiplier for converting 8-bit/16-bi...
A single keyword-value pair.
void setInputBoundary(int startSample, int endSample, int startLine, int endLine)
Parameters to input image sub area.
void ClearInputCubes()
Close owned input cubes from the list and clear the list.
Class for browsing cubes.
void close(bool remove=false)
Closes the cube and updates the labels.
double maximum() const
Return the output cube attribute maximum.
void read(Blob &blob) const
This method will read data from the specified Blob object.
void open(const QString &cfile, QString access="r")
This method will open an isis cube for reading or reading/writing.
The input label is embedded in the image file.
Cube::Format fileFormat() const
Return the file format an Cube::Format.
Functor for reduce using near functionality.
void SetInputArea(double pdStartSample, double pdEndSample, double pdStartLine, double pdEndLine)
Sets the sub area dimensions of the input image.
Container for cube-like labels.
PixelType pixelType() const
virtual Isis::Cube * SetOutputCube(const QString ¶meter)
Allocates a user-specified output cube whose size matches the first input cube.
void SetPosition(const double sample, const double line, const int band)
Sets the line and sample position of the buffer.
Apply corrections to a cube label for subarea extraction.
void setByteOrder(ByteOrder byteOrder)
Used prior to the Create method, this will specify the byte order of pixels, either least or most sig...
Isis::PvlGroup UpdateOutputLabel(Isis::Cube *pOutCube)
Create label for the reduced output image.
PvlGroup UpdateOutputLabel(Cube *pOutCube)
Update the Mapping, Instrument, and AlphaCube groups in the output cube label.
void UpdateLabel(Cube *icube, Cube *ocube, PvlGroup &results)
Modifies a label for a file containing a subarea.
bool isNamed(const QString &match) const
Returns whether the given string is equal to the container name or not.
PvlGroup & group(const int index)
Return the group at the specified index.
void setMinMax(double min, double max)
Used prior to the Create method, this will compute a good base and multiplier value given the minimum...
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
virtual QString fileName() const
Returns the opened cube's filename.
void write(Blob &blob)
This method will write a blob of data (e.g.
Namespace for ISIS/Bullet specific routines.
virtual int bandCount() const
Returns the number of virtual bands for the cube.
QMdiArea * mdiArea()
This method returns the QMdiArea.
int groups() const
Returns the number of groups contained.
int labelSize(bool actual=false) const
Returns the number of bytes used by the label.
void write(const QString &file)
Opens and writes PVL information to a file and handles the end of line sequence.
double minimum() const
Return the output cube attribute minimum.
Contains Pvl Groups and Pvl Objects.
void create(const QString &cfile)
This method will create an isis cube for writing.
void setLabelSize(int labelBytes)
Used prior to the Create method, this will allocate a specific number of bytes in the label area for ...
double multiplier() const
Returns the multiplier value for converting 8-bit/16-bit pixels to 32-bit.
IO Handler for Isis Cubes.