6 #include <QApplication>
10 #include <QMessageBox>
14 #include <QPrintDialog>
18 #include "BrowseDialog.h"
21 #include "FileDialog.h"
23 #include "MainWindow.h"
31 #include "SaveAsDialog.h"
46 p_dir =
"/thisDirDoesNotExist!";
48 p_open->setShortcut(Qt::CTRL + Qt::Key_O);
49 p_open->setText(
"&Open...");
51 p_open->setToolTip(
"Open cube");
53 "<b>Function:</b> Open an <i>Isis cube</i> in new viewport \
54 <p><b>Shortcut:</b> Ctrl+O\n</p> \
55 <p><b>Hint:</b> Use Ctrl or Shift in file dialog to open \
57 p_open->setWhatsThis(whatsThis);
58 connect(
p_open, SIGNAL(triggered()),
this, SLOT(
open()));
61 p_browse->setShortcut(Qt::CTRL + Qt::Key_B);
63 p_browse->setToolTip(
"Browse cubes");
65 "<b>Function:</b> Browse a <i>Isis cubes</i> in new viewport \
66 <p><b>Shortcut:</b> Ctrl+B\n</p>";
71 p_save->setShortcut(Qt::CTRL + Qt::Key_S);
74 p_save->setToolTip(
"Save");
76 "<b>Function:</b> Save changes to the current Cube \
77 <p><b>Shortcut:</b> Ctrl+S</p>";
78 p_save->setWhatsThis(whatsThis);
79 connect(
p_save, SIGNAL(triggered()),
this, SLOT(
save()));
87 "<b>Function:</b> Save the current Cube to the specified location";
97 "<b>Function:</b> Save the current Cube's Whatsthis Info to the specified location";
107 "<b>Function:</b> Save visible contents of the active \
108 viewport as a png, jpg, tiff \
109 <p><b>Hint:</b> Your local installation of Qt may not support \
110 all formats. Reinstall Qt if necessary</p>";
117 p_print->setShortcut(Qt::CTRL + Qt::Key_P);
121 "<b>Function:</b> Print visible contents of the active viewport \
122 <p><b>Shortcut:</b> Ctrl+P</b>";
123 p_print->setWhatsThis(whatsThis);
124 connect(
p_print, SIGNAL(triggered()),
this, SLOT(
print()));
131 "<b>Function:</b> Close all cube viewports.";
135 p_exit->setShortcut(Qt::CTRL + Qt::Key_Q);
139 "<b>Function:</b> Quit qview \
140 <p><b>Shortcut:</b> Ctrl+Q</p>";
141 p_exit->setWhatsThis(whatsThis);
142 connect(
p_exit, SIGNAL(triggered()),
this, SLOT(
exit()));
176 ws, SLOT(addCubeViewport(QString)));
178 connect(
p_closeAll, SIGNAL(triggered()), ws->mdiArea(), SLOT(closeAllSubWindows()));
203 if (!
p_dir.exists()) {
204 p_dir = QDir::current();
223 if (!
p_dir.exists()) {
224 p_dir = QDir::current();
241 QMessageBox::information((
QWidget *)parent(),
"Error",
"No active cube to save");
246 p_save->setEnabled(
false);
266 QMessageBox::information((
QWidget *)parent(),
"Error",
"No active cube to save");
273 if (!
p_dir.exists()) {
298 QMessageBox::information((
QWidget *)parent(),
"Error",
299 "No active cube to save");
305 QMessageBox::information((
QWidget *)parent(),
"Error",
306 "No output file selected");
313 for (it = vwportList->begin(); it != vwportList->end(); ++it){
314 if (QString((*it)->cube()->fileName()) == psOutFile) {
315 QMessageBox::information((
QWidget *)parent(),
"Error",
316 "Output File is already open\n\""+ psOutFile +
"\"");
337 if (
p_saveAsDialog->getSaveAsType() != SaveAsDialog::ExportAsIs ||
351 double dStartSample=0, dEndSample=0, dStartLine=0, dEndLine=0;
352 p_lastViewport->getCubeArea(dStartSample, dEndSample, dStartLine, dEndLine);
354 if (
p_saveAsDialog->getSaveAsType() == SaveAsDialog::ExportFullRes ||
358 int numSamples = (int)((dEndSample - dStartSample + 1) + 0.5);
359 int numLines = (int)((dEndLine - dStartLine + 1) + 0.5);
364 else if (
p_saveAsDialog->getSaveAsType() == SaveAsDialog::ExportAsIs ) {
372 p_save->setEnabled(
false);
391 double dStartSample=0, dEndSample=0, dStartLine=0, dEndLine=0;
392 p_lastViewport->getCubeArea(dStartSample, dEndSample, dStartLine, dEndLine);
394 double ins = dEndSample - dStartSample + 1;
395 double inl = dEndLine - dStartLine + 1;
397 double ons = (int)(ins * dScale + 0.5);
398 double onl = (int)(inl * dScale + 0.5);
409 imgEnlarge->
SetInputArea((
int)dStartSample, (
int)dEndSample, (
int)dStartLine, (
int)dEndLine);
419 QMessageBox::critical((
QWidget *)parent(),
420 "Error",
"Cannot open file, please check permissions");
437 double dStartSample=0, dEndSample=0, dStartLine=0, dEndLine=0;
438 p_lastViewport->getCubeArea(dStartSample, dEndSample, dStartLine, dEndLine);
440 double ins = dEndSample - dStartSample + 1;
441 double inl = dEndLine - dStartLine + 1;
443 double ons = (int)(ins * dScale + 0.5);
444 double onl = (int)(inl * dScale + 0.5);
447 std::vector<QString> bands = cai.
bands();
448 int inb = bands.size();
452 for(
int i = 1; i <= inb; i++) {
475 near->
setInputBoundary((
int)dStartSample, (
int)dEndSample, (
int)dStartLine, (
int)dEndLine);
520 Cube *ocube,
int piNumSamples,
int piNumLines,
int piNumBands) {
543 double base = icube->
base();
551 QString msg =
"Looks like your refactoring to add different pixel types";
552 msg +=
" you'll need to make changes here";
556 QString msg =
"You've chosen to reduce your output PixelType for [" +
557 psOutFile +
"] you must specify the output pixel range too";
566 int needLabBytes = icube->
labelSize(
true) + (1024 * 6);
577 for(
int i = 0; i < incube.
groups(); i++) {
583 for(
int i = 0; i < inlab.
objects(); i++) {
592 inlab = *icube->
label();
593 for(
int i = 0; i < inlab.
objects(); i++) {
602 inlab = *icube->
label();
603 for(
int i = 0; i < inlab.
objects(); i++) {
633 if (ibrick.Bricks() > obrick.Bricks()) {
634 numBricks = ibrick.
Bricks();
637 numBricks = obrick.Bricks();
643 for(
int i = 0; i < numBricks; i++) {
646 copy(ibrick, obrick);
647 ocube->
write(obrick);
665 Cube *pOutCube,
int pNumSamples,
int pNumLines) {
667 double dStartSample=0, dEndSample=0, dStartLine=0, dEndLine=0;
668 p_lastViewport->getCubeArea(dStartSample, dEndSample, dStartLine, dEndLine);
684 dEndLine, dEndSample, 1.0, 1.0);
690 for(
int iBand=1; iBand<=iNumBands; iBand++) {
692 for(
int iLine=(
int)dStartLine; iLine<=(int)dEndLine; iLine++) {
694 pInCube->
read(iPortal);
696 oPortal.SetPosition(1, ol++, iBand);
697 pOutCube->
read(oPortal);
699 oPortal.Copy(iPortal);
700 pOutCube->
write(oPortal);
714 QMessageBox::information((
QWidget *)parent(),
"Error",
"No active cube to save info");
720 QFileDialog::getSaveFileName((
QWidget *)parent(),
721 "Choose output file",
723 QString(
"PVL Files (*.pvl)"));
726 if (output.isEmpty()) {
729 else if (!output.endsWith(
".pvl")) {
735 whatsThisPvl.
write(output);
763 QMessageBox::information((
QWidget *)parent(),
"Error",
"No active cube to export");
768 QFileDialog::getSaveFileName((
QWidget *)parent(),
769 QString(
"Choose output file"),
771 QString(
"PNG (*.png);;JPG (*.jpg);;TIF (*.tif)"));
772 if (output.isEmpty())
return;
776 QString format = QFileInfo(output).suffix();
778 if (format.isEmpty()) {
779 if (output.endsWith(
'.')) {
780 output.append(QString(
"png"));
783 output.append(QString(
".png"));
786 else if (format.compare(
"png", Qt::CaseInsensitive) &&
787 format.compare(
"jpg", Qt::CaseInsensitive) &&
788 format.compare(
"tif", Qt::CaseInsensitive)) {
790 QMessageBox::information((
QWidget *)parent(),
"Error", format +
" is an invalid extension.");
798 if (!pm.save(output)) {
799 QMessageBox::information((
QWidget *)parent(),
"Error",
"Unable to save " + output);
811 QMessageBox::information((
QWidget *)parent(),
"Error",
"No active cube to print");
816 static QPrinter *printer = NULL;
817 if (printer == NULL) printer =
new QPrinter;
818 printer->setPageSize(QPrinter::Letter);
819 printer->setColorMode(QPrinter::GrayScale);
820 if (
cubeViewport()->isColor()) printer->setColorMode(QPrinter::Color);
822 QPrintDialog printDialog(printer, (
QWidget *)parent());
823 if (printDialog.exec() == QDialog::Accepted) {
826 QImage img = pixmap.toImage();
829 QPainter painter(printer);
830 QRect rect = painter.viewport();
831 QSize size = img.size();
832 size.scale(rect.size(), Qt::KeepAspectRatio);
833 painter.setViewport(rect.x(), rect.y(),
834 size.width(), size.height());
835 painter.setWindow(img.rect());
836 painter.drawImage(0, 0, img);
850 for(
int i = 0; i < (int)tempList.size(); i++) {
855 if (!d->parentWidget()->close()) {
883 p_save->setEnabled(enable);
896 p_save->setEnabled(
false);
910 if (
cubeViewport()->parentWidget()->windowTitle().endsWith(
"*")) {
915 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.
Isis::Cube * SetInputCube(const QString ¶meter, const int requirements=0)
Opens an input cube specified by the user and verifies requirements are met.
bool propagateMinimumMaximum() const
Return true if the min/max are to be propagated from an input cube.
PixelType pixelType() const
double maximum() const
Return the output cube attribute maximum.
bool propagatePixelType() const
Return true if the pixel type is to be propagated from an input cube.
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...
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
double multiplier() const
Returns the multiplier value for converting 8-bit/16-bit pixels to 32-bit.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
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...
void setLabelsAttached(bool attached)
Use prior to calling create, this sets whether or not to use separate label and data files...
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.
void read(Blob &blob) const
This method will read data from the specified Blob object.
This error is for when a programmer made an API call that was illegal.
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.
Cube * cube() const
Return the cube associated with viewport.
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 labelSize(bool actual=false) const
Returns the number of bytes used by the label.
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.
int objects() const
Returns the number of objects.
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.
int bandCount() const
Returns the number of virtual bands for the cube.
void ClearInputCubes()
Close owned input cubes from the list and clear the list.
Class for browsing cubes.
Cube::Format fileFormat() const
Return the file format an Cube::Format.
void close(bool remove=false)
Closes the cube and updates the labels.
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.
double minimum() const
Return the output cube attribute minimum.
Functor for reduce using near functionality.
double base() const
Returns the base value for converting 8-bit/16-bit pixels to 32-bit.
void SetInputArea(double pdStartSample, double pdEndSample, double pdStartLine, double pdEndLine)
Sets the sub area dimensions of the input image.
Container for cube-like labels.
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.
int groups() const
Returns the number of groups contained.
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...
void write(Blob &blob)
This method will write a blob of data (e.g.
ByteOrder byteOrder() const
Return the byte order as an Isis::ByteOrder.
bool isNamed(const QString &match) const
Returns whether the given string is equal to the container name or not.
QString fileName() const
Returns the opened cube's filename.
void write(const QString &file)
Opens and writes PVL information to a file and handles the end of line sequence.
Contains Pvl Groups and Pvl Objects.
void create(const QString &cfile)
This method will create an isis cube for writing.
QString name() const
Returns the container name.
void setLabelSize(int labelBytes)
Used prior to the Create method, this will allocate a specific number of bytes in the label area for ...
IO Handler for Isis Cubes.
PixelType pixelType() const
Return the pixel type as an Isis::PixelType.