26 #include <QApplication>    29 #include <QHBoxLayout>    33 #include <QMessageBox>    35 #include <QStackedWidget>    36 #include <QToolButton>    41 #include "RubberBandTool.h"    75     action->setIcon(QPixmap(
toolIconDir() + 
"/color_line.png"));
    76     action->setToolTip(
"Image Edit (E)");
    77     action->setShortcut(Qt::Key_E);
    80       "<b>Function:</b>  Edit active viewport \    81       <p><b>Shortcut:</b> E</p> ";
    82     action->setWhatsThis(text);
   100     container->setObjectName(
"EditToolActiveToolBarWidget");
   112       "<b>Function:</b> The shape in the image that will be replaced with \   113       a new value.  If Horizontal line is chosen, clicking anywhere on the \   114       image will cause all samples on that line of the cube to be replaced \   115       with the replacement value.  If Vertical Line is chosen, a v ...";
   131       "<b>Function:</b> The value which will be used to replace image data. ";
   141       "<b>Function:</b> This is the dn used to replace image data";
   150       "<b>Function:</b> Undo last edit operation";
   160       "<b>Function:</b> Redo last undo operation";
   171       "<b>Function:</b> Save any changes made, these changes are finalized";
   182       "<b>Function:</b> Save any changes made to the file specified, these changes are finalized";
   188     QHBoxLayout *layout = 
new QHBoxLayout;
   189     layout->setMargin(0);
   197     layout->addStretch(1);
   198     container->setLayout(layout);
   200 m_container = container;
   279     if (vp == NULL) 
return;
   291         QMessageBox::information((
QWidget *)parent(), 
"Error", 
"Cannot open cube read/write");
   296       QMessageBox::information((
QWidget *)parent(),
   297                                "Error", 
"Cannot edit in color mode");
   301     int issamp, isline, iesamp, ieline;
   302     double ssamp, sline, esamp, eline;
   308       if (!rubberBandTool()->
isValid()) 
return;
   311       if ((r.width() < 1) || (r.height() < 1)) 
return;
   316       issamp = (int)(ssamp + 0.5);
   317       isline = (int)(sline + 0.5);
   318       iesamp = (int)(esamp + 0.5);
   319       ieline = (int)(eline + 0.5);
   322       if (issamp < 0) issamp = 0;
   323       if (iesamp < 0) iesamp = 0;
   324       if (isline < 0) isline = 0;
   325       if (ieline < 0) ieline = 0;
   333       if (issamp > iesamp || isline > ieline) {
   334         QMessageBox::information((
QWidget *)parent(),
   335                                  "Error", 
"Rectangle is out of bounds");
   342       if (!rubberBandTool()->
isValid()) 
return;
   343       vp->
viewportToCube(rubberBandTool()->vertices()[0].rx(), rubberBandTool()->vertices()[0].ry(),
   345       vp->
viewportToCube(rubberBandTool()->vertices()[1].rx(), rubberBandTool()->vertices()[1].ry(),
   348       QLine l((
int)ssamp, (
int)sline, (
int)esamp, (
int)eline);
   353       if (linePts->empty()) {
   354         QMessageBox::information((
QWidget *)parent(),
   355                                  "Error", 
"No points in edit line");
   360       issamp = std::min(linePts->front()->x(), linePts->back()->x());
   361       isline = std::min(linePts->front()->y(), linePts->back()->y());
   362       iesamp = std::max(linePts->front()->x(), linePts->back()->x());
   363       ieline = std::max(linePts->front()->y(), linePts->back()->y());
   371     writeToCube(iesamp, issamp, ieline, isline, linePts);
   372     if (linePts) 
delete linePts;
   376     connect(newViewport, SIGNAL(saveChanges(
CubeViewport *)),
   378     connect(newViewport, SIGNAL(discardChanges(
CubeViewport *)),
   380     connect(newViewport, SIGNAL(destroyed(
QObject *)),
   413     if (vp == NULL) 
return;
   431         QMessageBox::information((
QWidget *)parent(), 
"Error", 
"Cannot open cube read/write");
   436       QMessageBox::information((
QWidget *)parent(),
   437                                "Error", 
"Cannot edit in color mode");
   441     int issamp, isline, iesamp, ieline;
   446     if (m == Qt::RightButton &&
   450       issamp = (int)(ssamp + 0.5);
   451       isline = (int)(sline + 0.5);
   456       p_dn = (*pntBrick)[0];
   466       if ((ssamp < 0.5) || (sline < 0.5) ||
   468         QApplication::beep();
   471       issamp = (int)(ssamp + 0.5);
   472       isline = (int)(sline + 0.5);
   504       int nsamps = iesamp - issamp + 1;
   505       int nlines = ieline - isline + 1;
   527         while(!temp->isEmpty()) {
   541         for(
int i = 0; linePts && i < (int)linePts->size(); i++) {
   542           QPoint *pt = (*linePts)[i];
   545           int brickIndex = (il - isline) * nsamps + (is - issamp);
   546           (*brick)[brickIndex] = (double)
p_dn;
   550         for(
int i = 0; i < brick->
size(); i++)(*brick)[i] = (double)
p_dn;
   572       QMessageBox::information((
QWidget *)parent(), 
"Error", 
"Not enough memory to complete this operation.");
   583     Brick *redoBrick = NULL;
   586       if (vp == NULL) 
return;
   590         QApplication::beep();
   596         QMessageBox::information((
QWidget *)parent(), 
"Error", 
"Cube is Read Only");
   602       Brick *brick = s->top();
   616       redo->push(redoBrick);
   646       QMessageBox::information((
QWidget *)parent(), 
"Error", 
"Not enough memory to complete this operation.");
   663           QMessageBox::information((
QWidget *)parent(), 
"Error", 
"Cube is Read Only");
   680           for(
int i = undo->count() - 1; i >= marker; i--) {
   681             Brick *brick = undo->at(i);
   688           marker = marker - undo->count();
   696           for(
int i = redo->count() - 1; i >= redo->count() - marker; i--) {
   697             Brick *brick = redo->at(i);
   707       QMessageBox::information((
QWidget *)parent(), 
"Error",
   708                                "Not enough memory to complete this operation.");
   718     Brick *undoBrick = NULL;
   721       if (vp == NULL) 
return;
   725         QApplication::beep();
   731         QMessageBox::information((
QWidget *)parent(), 
"Error", 
"Cube is Read Only");
   736       Brick *brick = s->top();
   752       undo->push(undoBrick);
   781       QMessageBox::information((
QWidget *)parent(), 
"Error", 
"Not enough memory to complete this operation.");
   825       while(!temp->isEmpty()) {
   832       while(!temp->isEmpty()) {
   861     int x, y, xinc, yinc;
   867     int sx = line.p1().x();
   868     int ex = line.p2().x();
   869     int sy = line.p1().y();
   870     int ey = line.p2().y();
   890       slope = (double)(ex - sx) / (double)(ey - sy);
   892       for(i = 0; i < ysize; i++) {
   893         x = (int)(slope * (
double)(y - sy) + (
double) sx + 0.5);
   896         if (x >= 0 && y >= 0 && x <= vp->cubeSamples() && y <= vp->
cubeLines()) {
   897           QPoint *pt = 
new QPoint;
   900           points->push_back(pt);
   905     else if (xsize == 1) {
   907       if (sx >= 0 && sy >= 0 && sx <= vp->cubeSamples() && sy <= vp->cubeLines()) {
   908         QPoint *pt = 
new QPoint;
   911         points->push_back(pt);
   915       slope = (double)(ey - sy) / (double)(ex - sx);
   917       for(i = 0; i < xsize; i++) {
   918         y = (int)(slope * (
double)(x - sx) + (
double) sy + 0.5);
   921         if (x >= 0 && y >= 0 && x <= vp->cubeSamples() && y <= vp->
cubeLines()) {
   922           QPoint *pt = 
new QPoint;
   925           points->push_back(pt);
   943       rubberBandTool()->
enable(RubberBandTool::LineMode);
   946     else if (index == 4) {
   947       rubberBandTool()->
enable(RubberBandTool::RectangleMode);
 
Cube display widget for certain Isis MDI applications. 
 
int cubeLines() const
Return the number of lines in the cube. 
 
const double Null
Value for an Isis Null pixel. 
 
Buffer for containing a three dimensional section of an image. 
 
void SetBasePosition(const int start_sample, const int start_line, const int start_band)
This method is used to set the base position of the shape buffer. 
 
void cubeContentsChanged(QRect rect)
Calle dhwen the contents of the cube changes. 
 
Widget to display Isis cubes for qt apps. 
 
int LineDimension() const
Returns the number of lines in the shape buffer. 
 
const double Lis
Value for an Isis Low Instrument Saturation pixel. 
 
int size() const
Returns the total number of pixels in the shape buffer. 
 
void reopen(QString access="r")
This method will reopen an isis sube for reading or reading/writing. 
 
int Sample(const int index=0) const
Returns the sample position associated with a shape buffer index. 
 
int Line(const int index=0) const
Returns the line position associated with a shape buffer index. 
 
bool isReadOnly() const
Test if the opened cube is read-only, that is write operations will fail if this is true...
 
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. 
 
PixelType pixelType() const
 
int cubeSamples() const
Return the number of samples in the cube. 
 
int SampleDimension() const
Returns the number of samples in the shape buffer. 
 
void cubeChanged(bool changed)
This method is called when the cube has changed or changes have been finalized. 
 
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. 
 
void setCaption()
Change the caption on the viewport title bar. 
 
const double Lrs
Value for an Isis Low Representation Saturation pixel. 
 
void viewportToCube(int x, int y, double &sample, double &line) const
Turns a viewport into a cube. 
 
const double His
Value for an Isis High Instrument Saturation pixel. 
 
const double Hrs
Value for an Isis High Representation Saturation pixel.