Isis 3 Programmer Reference
CubeViewport.h
Go to the documentation of this file.
1 #ifndef CubeViewport_h
2 #define CubeViewport_h
3 
27 // parent of this class
28 #include <QAbstractScrollArea>
29 
30 class QPaintEvent;
31 
32 namespace Isis {
33  class Brick;
34  class Camera;
35  class Cube;
36  class CubeDataThread;
37  class Projection;
38  class Pvl;
39  class PvlKeyword;
40  class Stretch;
41  class Tool;
42  class UniversalGroundMap;
43 
44  class ViewportBuffer;
45 
133  Q_OBJECT
134 
135  public:
144  CubeViewport(Cube *cube, CubeDataThread * cdt = 0, QWidget *parent = 0);
145 
149  virtual ~CubeViewport();
150 
151 
157  class BandInfo {
158  public:
159  BandInfo();
161  BandInfo(const BandInfo &other);
163  ~BandInfo();
164 
171  const BandInfo &operator=(BandInfo other);
172 
174  Stretch getStretch() const;
176  void setStretch(const Stretch &newStretch);
178  int band;
179  private:
182  };
183 
185  void setCube(Cube *cube);
187  int cubeSamples() const;
189  int cubeLines() const;
191  int cubeBands() const;
192 
194  bool isColor() const {
195  return p_color;
196  };
197 
199  bool isGray() const {
200  return !p_color;
201  };
202 
204  int grayBand() const {
205  return p_gray.band;
206  };
207 
209  int redBand() const {
210  return p_red.band;
211  };
212 
214  int greenBand() const {
215  return p_green.band;
216  };
217 
219  int blueBand() const {
220  return p_blue.band;
221  };
222 
224  double scale() const {
225  return p_scale;
226  };
227 
229  bool cubeShown() const {
230  return p_cubeShown;
231  };
232 
234  int comboCount() const {
235  return p_comboCount;
236  };
237 
239  int comboIndex() const {
240  return p_comboIndex;
241  }
242 
248  void cubeContentsChanged(QRect rect);
249 
251  double fitScale() const;
253  double fitScaleWidth() const;
255  double fitScaleHeight() const;
256 
265  void viewportToCube(int x, int y,
266  double &sample, double &line) const;
267 
276  void cubeToViewport(double sample, double line,
277  int &x, int &y) const;
286  void contentsToCube(int x, int y,
287  double &sample, double &line) const;
296  void cubeToContents(double sample, double line,
297  int &x, int &y) const;
298 
307  double redPixel(int sample, int line);
308 
317  double greenPixel(int sample, int line);
318 
327  double bluePixel(int sample, int line);
328 
337  double grayPixel(int sample, int line);
339  Stretch grayStretch() const;
341  Stretch redStretch() const;
343  Stretch greenStretch() const;
345  Stretch blueStretch() const;
346 
348  Cube *cube() const {
349  return p_cube;
350  };
351 
354  return p_projection;
355  };
356 
358  Camera *camera() const {
359  return p_camera;
360  };
361 
364  return p_groundMap;
365  };
366 
368  Cube *trackingCube() const {
369  return p_trackingCube;
370  };
371 
372  void moveCursor(int x, int y);
373  bool cursorInside() const;
374  QPoint cursorPosition() const;
375  void setCursorPosition(int x, int y);
376  void setCaption();
377 
383  void setBackground(QColor color) {
384  p_bgColor = color;
385  }
386 
392  void setComboCount(int count) {
393  p_comboCount = count;
394  }
395 
401  void setComboIndex(int index) {
402  p_comboIndex = index;
403  }
404 
411  QPixmap pixmap() {
412  return p_pixmap;
413  }
414 
422  return p_grayBuffer;
423  }
424 
432  return p_redBuffer;
433  }
434 
442  return p_greenBuffer;
443  }
444 
452  return p_blueBuffer;
453  }
454 
455  void bufferUpdated(QRect rect);
456 
464  virtual void restretch(ViewportBuffer *buffer) = 0;
465  void paintPixmap();
466 
470  void forgetStretches();
471 
477  void setAllBandStretches(Stretch stretch);
478 
479 
484  return p_cubeData;
485  }
486 
490  int cubeID() {
491  return p_cubeId;
492  }
493 
494 
500  void getAllWhatsThisInfo(Pvl & pWhatsThisPvl);
501 
508  void getBandFilterName(PvlKeyword & pFilterNameKey);
509 
518  void getCubeArea(double & pdStartSample, double & pdEndSample,
519  double & pdStartLine, double & pdEndLine);
520 
521  bool confirmClose();
522 
523  void setTrackingCube();
524 
525  signals:
526  void viewportUpdated();
528  void mouseEnter();
529  void mouseMove(QPoint);
530  void mouseMove(QPoint, Qt::MouseButton);
531  void mouseLeave();
532  void mouseButtonPress(QPoint, Qt::MouseButton);
533  void mouseButtonRelease(QPoint, Qt::MouseButton);
534  void mouseDoubleClick(QPoint);
535  void windowTitleChanged();
536  void scaleChanged();
537  void saveChanges(CubeViewport *);
538  void discardChanges(CubeViewport *);
539  void screenPixelsChanged();
540 
544  void progressChanged(int);
548  void progressComplete();
549 
554  void doneWithData(int, const Isis::Brick *);
555 
556 
557  public slots:
558  QSize sizeHint() const;
559  void setScale(double scale);
560  void setScale(double scale, double sample, double line);
561  void setScale(double scale, int x, int y);
562  void center(int x, int y);
563  void center(double sample, double line);
564 
565  virtual void viewRGB(int redBand, int greenBand, int blueBand);
566  virtual void viewGray(int band);
567 
568  void stretchGray(const QString &string);
569  void stretchRed(const QString &string);
570  void stretchGreen(const QString &string);
571  void stretchBlue(const QString &string);
572 
573  void stretchGray(const Stretch &stretch);
574  void stretchRed(const Stretch &stretch);
575  void stretchGreen(const Stretch &stretch);
576  void stretchBlue(const Stretch &stretch);
577 
578  void stretchKnownGlobal();
579 
580  void cubeChanged(bool changed);
581  void showEvent(QShowEvent *);
582 
583  void scrollBy(int dx, int dy);
584 
585  void changeCursor(QCursor cursor);
586 
587  void onProgressTimer();
588  void enableProgress();
589 
590 
591  protected:
592  void scrollContentsBy(int dx, int dy);
593  virtual void resizeEvent(QResizeEvent *e);
594  virtual bool eventFilter(QObject *o, QEvent *e);
595  virtual void keyPressEvent(QKeyEvent *e);
596  virtual void paintEvent(QPaintEvent *e);
597 
598 
599 
600  protected slots:
601  virtual void cubeDataChanged(int cubeId, const Isis::Brick *);
602 
603 
604  private:
605 
606  void paintPixmap(QRect rect);
607  void shiftPixmap(int dx, int dy);
608 
609  void updateScrollBars(int x, int y);
610  void paintPixmapRects();
611 
612  //void computeStretch(Brick *brick, int band,
613  // int ssamp, int esamp,
614  // int sline, int eline, int linerate,
615  // Stretch &stretch);
616 
617 
618 
619  protected: // data
620  QPixmap p_pixmap;
621 
624 
627 
628 
629  private: // data
634 
635  QColor p_bgColor;
636 
641  Cube *p_trackingCube; //<! The tracking cube associated with p_cube
642 
645 
646  double p_scale;
647 
648  bool p_color;
653 
656 
664  QImage *p_image;
667 
671  void updateWhatsThis();
672 
675 
677  int p_cubeId;
678 
684  };
685 }
686 
687 #endif
void setAllBandStretches(Stretch stretch)
Sets a stretch for all bands.
QTimer * p_progressTimer
Activated to update progress bar.
Definition: CubeViewport.h:644
QVector< Stretch *> * p_knownStretches
Stretches for each previously stretched band.
Definition: CubeViewport.h:623
bool p_updatingBuffers
Changing RGB and need to not repaint pixmap?
Definition: CubeViewport.h:666
void progressComplete()
Emitted when the current progress is complete (100)
Stretch redStretch() const
Return the red band stretch.
void progressChanged(int)
Emitted with current progress (0 to 100) when working.
ViewportBuffer * grayBuffer()
Returns the gray viewport buffer (Will be NULL if in RGB mode.)
Definition: CubeViewport.h:421
void viewportUpdated()
Emitted when viewport updated.
void shiftPixmap(int dx, int dy)
Shifts the pixels on the pixmap without reading new data.
int cubeLines() const
Return the number of lines in the cube.
Reads and stores visible DN values.
QPixmap p_pixmap
The qpixmap.
Definition: CubeViewport.h:620
ViewportBuffer * p_grayBuffer
Viewport Buffer to manage gray band.
Definition: CubeViewport.h:630
void scaleChanged()
Emitted when zoom factor changed just before the repaint event.
Cube * cube() const
Definition: CubeViewport.h:348
Brick * p_redBrick
Bricks for every color.
Definition: CubeViewport.h:657
ViewportBuffer * p_greenBuffer
Viewport Buffer to manage green band.
Definition: CubeViewport.h:632
Camera * p_camera
The camera from the cube.
Definition: CubeViewport.h:638
ViewportBuffer * redBuffer()
Returns the red viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:431
BandInfo p_red
Red band info.
Definition: CubeViewport.h:650
int cubeBands() const
Return the number of bands in the cube.
int greenBand() const
Definition: CubeViewport.h:214
void stretchBlue(const QString &string)
Apply stretch pairs to blue bands.
Universal Ground Map.
Stretch greenStretch() const
Return the green band stretch.
bool isGray() const
Definition: CubeViewport.h:199
void forgetStretches()
Resets all remembered stretches.
void stretchRed(const QString &string)
Apply stretch pairs to red bands.
void updateWhatsThis()
Update the What&#39;s This text.
BandInfo p_green
Green band info.
Definition: CubeViewport.h:651
QPixmap pixmap()
Returns the pixmap.
Definition: CubeViewport.h:411
void mouseLeave()
Emitted when the mouse leaves the viewport.
void getAllWhatsThisInfo(Pvl &pWhatsThisPvl)
Get All WhatsThis info - viewport, cube, area in PVL format.
void saveChanges(CubeViewport *)
Emitted when changes should be saved.
void cubeToContents(double sample, double line, int &x, int &y) const
Turns a cube into contents.
Buffer for containing a three dimensional section of an image.
Definition: Brick.h:61
void getBandFilterName(PvlKeyword &pFilterNameKey)
Get Band Filter name from the Isis cube label.
void center(int x, int y)
Bring the cube pixel under viewport x/y to the center.
int blueBand() const
Definition: CubeViewport.h:219
void setScale(double scale)
Change the scale of the cube to the given parameter value.
void cubeContentsChanged(QRect rect)
Calle dhwen the contents of the cube changes.
void setCursorPosition(int x, int y)
Set the cursor position to x/y in the viewport.
QList< QRect *> * p_pixmapPaintRects
A list of rects that the viewport buffers have requested painted.
Definition: CubeViewport.h:674
bool isColor() const
Definition: CubeViewport.h:194
BandInfo p_blue
Blue band info.
Definition: CubeViewport.h:652
double fitScale() const
Determine the scale that causes the full cube to fit in the viewport.
bool p_saveEnabled
Has the cube changed?
Definition: CubeViewport.h:662
void discardChanges(CubeViewport *)
Emitted when changes should be discarded.
virtual void viewRGB(int redBand, int greenBand, int blueBand)
View cube as color.
Widget to display Isis cubes for qt apps.
Definition: CubeViewport.h:132
void cubeToViewport(double sample, double line, int &x, int &y) const
Turns a cube into a viewport.
void mouseButtonPress(QPoint, Qt::MouseButton)
Emitted when mouse button pressed.
void setComboCount(int count)
Sets the band bin combo box count.
Definition: CubeViewport.h:392
void updateScrollBars(int x, int y)
Update the scroll bar.
ViewportBuffer * p_blueBuffer
Viewport Buffer to manage blue band.
Definition: CubeViewport.h:633
void screenPixelsChanged()
Emitted when cube pixels that should be on the screen change.
Brick * p_bluBrick
Bricks for every color.
Definition: CubeViewport.h:659
int comboCount() const
Definition: CubeViewport.h:234
bool p_thisOwnsCubeData
if true then this owns the CubeDataThread, and should thus delete it
Definition: CubeViewport.h:683
void paintPixmap()
Paint the whole pixmap.
Stretch grayStretch() const
Return the gray band stretch.
double greenPixel(int sample, int line)
Gets the green pixel.
bool p_color
Is the viewport in color?
Definition: CubeViewport.h:648
double redPixel(int sample, int line)
Gets the red pixel.
void setComboIndex(int index)
Sets the band bin combo box index.
Definition: CubeViewport.h:401
double grayPixel(int sample, int line)
Gets the gray pixel.
void windowTitleChanged()
Emitted when window title changes.
QString p_whatsThisText
The text for What&#39;s this.
Definition: CubeViewport.h:668
Base class for Map Projections.
Definition: Projection.h:171
Camera * camera() const
Definition: CubeViewport.h:358
double fitScaleWidth() const
Determine the scale of cube in the width to fit in the viewport.
void contentsToCube(int x, int y, double &sample, double &line) const
Turns contents to a cube.
void stretchKnownGlobal()
List<Tool *> p This stretches to the global stretch.
void doneWithData(int, const Isis::Brick *)
Emitted when a brick is no longer needed, should only be sent to cube data thread.
void moveCursor(int x, int y)
Move the cursor by x,y if possible.
bool p_paintPixmap
Paint the pixmap?
Definition: CubeViewport.h:665
void mouseDoubleClick(QPoint)
Emitted when double click happens.
bool confirmClose()
This method should be called during a close event that would cause this viewport to close...
Pixel value mapper.
Definition: Stretch.h:72
UniversalGroundMap * universalGroundMap() const
Definition: CubeViewport.h:363
Projection * p_projection
The projection from the cube.
Definition: CubeViewport.h:639
int grayBand() const
Definition: CubeViewport.h:204
void mouseMove(QPoint)
Emitted when the mouse moves.
A single keyword-value pair.
Definition: PvlKeyword.h:98
void bufferUpdated(QRect rect)
This method is called by ViewportBuffer upon successful completion of all operations and gives the ap...
BandInfo p_gray
Gray band info.
Definition: CubeViewport.h:649
QSize sizeHint() const
Make viewports show up as 512 by 512.
void enableProgress()
This restarts the progress bar.
Stretch * stretch
The Stretch.
Definition: CubeViewport.h:181
virtual void resizeEvent(QResizeEvent *e)
The viewport is being resized.
double bluePixel(int sample, int line)
Gets the blue pixel.
void mouseEnter()
Emitted when the mouse enters the viewport.
int p_comboCount
Number of elements in band bin combo box.
Definition: CubeViewport.h:654
QString p_viewportWhatsThisText
The text for the viewport&#39;s what&#39;s this.
Definition: CubeViewport.h:670
Encapsulation of Cube I/O with Change Notifications.
Container for cube-like labels.
Definition: Pvl.h:135
QPoint cursorPosition() const
Return the cursor position in the viewport.
virtual void viewGray(int band)
View cube as gray.
void getCubeArea(double &pdStartSample, double &pdEndSample, double &pdStartLine, double &pdEndLine)
Get Cube area corresponding to the viewport&#39;s dimension.
void scrollBy(int dx, int dy)
Move the scrollbars by dx/dy screen pixels.
Brick * p_grnBrick
Bricks for every color.
Definition: CubeViewport.h:658
int cubeSamples() const
Return the number of samples in the cube.
ViewportBuffer * blueBuffer()
Returns the blue viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:451
QVector< Stretch *> * p_globalStretches
Global stretches for each stretched band.
Definition: CubeViewport.h:626
void viewportClosed(CubeViewport *)
Emitted when viewport is closed.
void cubeChanged(bool changed)
This method is called when the cube has changed or changes have been finalized.
int p_comboIndex
Current element chosen from combo box.
Definition: CubeViewport.h:655
Cube * trackingCube() const
Definition: CubeViewport.h:368
int p_cubeId
Cube ID given from cube data thread for I/O.
Definition: CubeViewport.h:677
int comboIndex() const
Definition: CubeViewport.h:239
virtual void restretch(ViewportBuffer *buffer)=0
This is called by internal viewport buffers when a stretch action should be performed.
void setStretch(const Stretch &newStretch)
UniversalGroundMap * p_groundMap
The universal ground map from the cube.
Definition: CubeViewport.h:640
bool p_cubeShown
Is the cube visible?
Definition: CubeViewport.h:663
virtual void cubeDataChanged(int cubeId, const Isis::Brick *)
This method updates the internal viewport buffer based on changes in cube DN values.
CubeDataThread * cubeDataThread()
Definition: CubeViewport.h:483
void stretchGreen(const QString &string)
Apply stretch pairs to green bands.
ViewportBuffer * p_redBuffer
Viewport Buffer to manage red band.
Definition: CubeViewport.h:631
CubeViewport(Cube *cube, CubeDataThread *cdt=0, QWidget *parent=0)
Constructor for the CubeViewport.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
virtual void paintEvent(QPaintEvent *e)
Repaint the viewport.
Projection * projection() const
Definition: CubeViewport.h:353
CubeDataThread * p_cubeData
Does all the cube I/O.
Definition: CubeViewport.h:676
QString p_cubeWhatsThisText
The text for the cube&#39;s What&#39;s this.
Definition: CubeViewport.h:669
void setBackground(QColor color)
Sets the background color.
Definition: CubeViewport.h:383
Cube * p_cube
The cube associated with the viewport.
Definition: CubeViewport.h:637
virtual ~CubeViewport()
Deconstructor for the Cubeviewport.
const BandInfo & operator=(BandInfo other)
The BandInfo for the Cube.
void setCube(Cube *cube)
This method sets the viewports cube.
void setCaption()
Change the caption on the viewport title bar.
int redBand() const
Definition: CubeViewport.h:209
virtual void keyPressEvent(QKeyEvent *e)
Process arrow keystrokes on cube.
double fitScaleHeight() const
Determine the scale of cube in heighth to fit in the viewport.
void scrollContentsBy(int dx, int dy)
Scroll the viewport contents by dx/dy screen pixels.
Brick * p_pntBrick
Bricks for every color.
Definition: CubeViewport.h:661
bool cubeShown() const
Definition: CubeViewport.h:229
void onProgressTimer()
This updates the progress bar visually.
void stretchGray(const QString &string)
Apply stretch pairs to gray band.
ViewportBuffer * greenBuffer()
Returns the green viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:441
void viewportToCube(int x, int y, double &sample, double &line) const
Turns a viewport into a cube.
void changeCursor(QCursor cursor)
Allows users to change the cursor type on the viewport.
QColor p_bgColor
The color to paint the background of the viewport.
Definition: CubeViewport.h:635
void setTrackingCube()
Finds the Tracking group from p_cube and stores the tracking cube name so that we can grab it in Adva...
double p_scale
The scale number.
Definition: CubeViewport.h:646
void showEvent(QShowEvent *)
This method is called to initially show the viewport.
void mouseButtonRelease(QPoint, Qt::MouseButton)
Emitted when mouse button released.
Brick * p_gryBrick
Bricks for every color.
Definition: CubeViewport.h:660
Stretch blueStretch() const
Return the blue band stretch.
virtual bool eventFilter(QObject *o, QEvent *e)
Event filter to watch for mouse events on viewport.
double scale() const
Definition: CubeViewport.h:224
bool cursorInside() const
Is cursor inside viewport.
IO Handler for Isis Cubes.
Definition: Cube.h:170
void paintPixmapRects()
Goes through the list of requested paints, from the viewport buffer, and paints them.
QImage * p_image
The qimage.
Definition: CubeViewport.h:664