Isis 3.0 Programmer Reference
Back | Home
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 
31 class QPaintEvent;
32 
33 namespace Isis {
34  class Brick;
35  class Camera;
36  class Cube;
37  class CubeDataThread;
38  class Projection;
39  class Pvl;
40  class PvlKeyword;
41  class Stretch;
42  class Tool;
43  class UniversalGroundMap;
44 
45  class ViewportBuffer;
46 
122  Q_OBJECT
123 
124  public:
125  CubeViewport(Cube *cube, CubeDataThread * cdt = 0, QWidget *parent = 0);
126  virtual ~CubeViewport();
127 
128 
134  class BandInfo {
135  public:
136  BandInfo();
137  BandInfo(const BandInfo &other);
138  ~BandInfo();
139  const BandInfo &operator=(BandInfo other);
140  Stretch getStretch() const;
141  void setStretch(const Stretch &newStretch);
142  int band;
143  private:
144  Stretch *stretch;
145  };
146 
147  void setCube(Cube *cube);
148  int cubeSamples() const;
149  int cubeLines() const;
150  int cubeBands() const;
151 
153  bool isColor() const {
154  return p_color;
155  };
156 
158  bool isGray() const {
159  return !p_color;
160  };
161 
163  int grayBand() const {
164  return p_gray.band;
165  };
166 
168  int redBand() const {
169  return p_red.band;
170  };
171 
173  int greenBand() const {
174  return p_green.band;
175  };
176 
178  int blueBand() const {
179  return p_blue.band;
180  };
181 
183  double scale() const {
184  return p_scale;
185  };
186 
188  bool cubeShown() const {
189  return p_cubeShown;
190  };
191 
193  int comboCount() const {
194  return p_comboCount;
195  };
196 
198  int comboIndex() const {
199  return p_comboIndex;
200  }
201 
202  void cubeContentsChanged(QRect rect);
203 
204  double fitScale() const;
205  double fitScaleWidth() const;
206  double fitScaleHeight() const;
207 
208  void viewportToCube(int x, int y,
209  double &sample, double &line) const;
210  void cubeToViewport(double sample, double line,
211  int &x, int &y) const;
212  void contentsToCube(int x, int y,
213  double &sample, double &line) const;
214  void cubeToContents(double sample, double line,
215  int &x, int &y) const;
216 
217  double redPixel(int sample, int line);
218  double greenPixel(int sample, int line);
219  double bluePixel(int sample, int line);
220  double grayPixel(int sample, int line);
221 
222  Stretch grayStretch() const;
223  Stretch redStretch() const;
224  Stretch greenStretch() const;
225  Stretch blueStretch() const;
226 
228  Cube *cube() const {
229  return p_cube;
230  };
231 
234  return p_projection;
235  };
236 
238  Camera *camera() const {
239  return p_camera;
240  };
241 
244  return p_groundMap;
245  };
246 
247  void moveCursor(int x, int y);
248  bool cursorInside() const;
249  QPoint cursorPosition() const;
250  void setCursorPosition(int x, int y);
251  void setCaption();
252 
258  void setBackground(QColor color) {
259  p_bgColor = color;
260  }
261 
267  void setComboCount(int count) {
268  p_comboCount = count;
269  }
270 
276  void setComboIndex(int index) {
277  p_comboIndex = index;
278  }
279 
286  QPixmap pixmap() {
287  return p_pixmap;
288  }
289 
297  return p_grayBuffer;
298  }
299 
307  return p_redBuffer;
308  }
309 
317  return p_greenBuffer;
318  }
319 
327  return p_blueBuffer;
328  }
329 
330  void bufferUpdated(QRect rect);
331 
339  virtual void restretch(ViewportBuffer *buffer) = 0;
340  void paintPixmap();
341 
345  void forgetStretches();
346 
352  void setAllBandStretches(Stretch stretch);
353 
354 
359  return p_cubeData;
360  }
361 
365  int cubeID() {
366  return p_cubeId;
367  }
368 
369 
375  void getAllWhatsThisInfo(Pvl & pWhatsThisPvl);
376 
383  void getBandFilterName(PvlKeyword & pFilterNameKey);
384 
393  void getCubeArea(double & pdStartSample, double & pdEndSample,
394  double & pdStartLine, double & pdEndLine);
395 
396  bool confirmClose();
397 
398  signals:
399  void viewportUpdated();
401  void mouseEnter();
402  void mouseMove(QPoint);
403  void mouseMove(QPoint, Qt::MouseButton);
404  void mouseLeave();
405  void mouseButtonPress(QPoint, Qt::MouseButton);
406  void mouseButtonRelease(QPoint, Qt::MouseButton);
407  void mouseDoubleClick(QPoint);
408  void windowTitleChanged();
409  void scaleChanged();
410  void saveChanges(CubeViewport *);
411  void discardChanges(CubeViewport *);
412  void screenPixelsChanged();
413 
417  void progressChanged(int);
418 
423  void doneWithData(int, const Isis::Brick *);
424 
425 
426  public slots:
427  QSize sizeHint() const;
428  void setScale(double scale);
429  void setScale(double scale, double sample, double line);
430  void setScale(double scale, int x, int y);
431  void center(int x, int y);
432  void center(double sample, double line);
433 
434  virtual void viewRGB(int redBand, int greenBand, int blueBand);
435  virtual void viewGray(int band);
436 
437  void stretchGray(const QString &string);
438  void stretchRed(const QString &string);
439  void stretchGreen(const QString &string);
440  void stretchBlue(const QString &string);
441 
442  void stretchGray(const Stretch &stretch);
443  void stretchRed(const Stretch &stretch);
444  void stretchGreen(const Stretch &stretch);
445  void stretchBlue(const Stretch &stretch);
446 
447  void stretchKnownGlobal();
448 
449  void cubeChanged(bool changed);
450  void showEvent(QShowEvent *);
451 
452  void scrollBy(int dx, int dy);
453 
454  void changeCursor(QCursor cursor);
455 
456  void onProgressTimer();
457  void enableProgress();
458 
459 
460  protected:
461  void scrollContentsBy(int dx, int dy);
462  virtual void resizeEvent(QResizeEvent *e);
463  virtual bool eventFilter(QObject *o, QEvent *e);
464  virtual void keyPressEvent(QKeyEvent *e);
465  virtual void paintEvent(QPaintEvent *e);
466 
467 
468 
469  protected slots:
470  virtual void cubeDataChanged(int cubeId, const Isis::Brick *);
471 
472 
473  private:
474 
475  void paintPixmap(QRect rect);
476  void shiftPixmap(int dx, int dy);
477 
478  void updateScrollBars(int x, int y);
479  void paintPixmapRects();
480 
481  //void computeStretch(Brick *brick, int band,
482  // int ssamp, int esamp,
483  // int sline, int eline, int linerate,
484  // Stretch &stretch);
485 
486 
487 
488  protected: // data
489  QPixmap p_pixmap;
490 
493 
496 
497 
498  private: // data
503 
504  QColor p_bgColor;
505 
510 
513 
514  double p_scale;
515 
516  bool p_color;
521 
524 
532  QImage *p_image;
535 
539  void updateWhatsThis();
540 
543 
545  int p_cubeId;
546 
552  };
553 }
554 
555 #endif
void setAllBandStretches(Stretch stretch)
Sets a stretch for all bands.
QTimer * p_progressTimer
Activated to update progress bar.
Definition: CubeViewport.h:512
QVector< Stretch * > * p_knownStretches
Stretches for each previously stretched band.
Definition: CubeViewport.h:492
Stretch redStretch() const
Return the red band stretch.
bool p_updatingBuffers
Changing RGB and need to not repaint pixmap?
Definition: CubeViewport.h:534
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:296
void viewportUpdated()
Emitted when viewport updated.
double fitScaleWidth() const
Determine the scale of cube in the width to fit in the viewport.
void shiftPixmap(int dx, int dy)
Shifts the pixels on the pixmap without reading new data.
UniversalGroundMap * universalGroundMap() const
Return the universal ground map associated with the cube (NULL implies none)
Definition: CubeViewport.h:243
Reads and stores visible DN values.
QPixmap p_pixmap
The qpixmap.
Definition: CubeViewport.h:489
ViewportBuffer * p_grayBuffer
Viewport Buffer to manage gray band.
Definition: CubeViewport.h:499
void scaleChanged()
Emitted when zoom factor changed just before the repaint event.
Brick * p_redBrick
Bricks for every color.
Definition: CubeViewport.h:525
ViewportBuffer * p_greenBuffer
Viewport Buffer to manage green band.
Definition: CubeViewport.h:501
Camera * p_camera
The camera from the cube.
Definition: CubeViewport.h:507
Stretch greenStretch() const
Return the green band stretch.
ViewportBuffer * redBuffer()
Returns the red viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:306
BandInfo p_red
Red band info.
Definition: CubeViewport.h:518
void stretchBlue(const QString &string)
Apply stretch pairs to blue bands.
Universal Ground Map.
void forgetStretches()
Resets all remembered stretches.
void stretchRed(const QString &string)
Apply stretch pairs to red bands.
bool isGray() const
Is the viewport shown in gray / b&amp;w.
Definition: CubeViewport.h:158
void updateWhatsThis()
Update the What&#39;s This text.
BandInfo p_green
Green band info.
Definition: CubeViewport.h:519
bool isColor() const
Is the viewport shown in 3-band color.
Definition: CubeViewport.h:153
QPixmap pixmap()
Returns the pixmap.
Definition: CubeViewport.h:286
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.
bool cursorInside() const
Is cursor inside viewport.
int cubeSamples() const
Return the number of samples in the cube.
Buffer for containing a three dimensional section of an image.
Definition: Brick.h:60
void getBandFilterName(PvlKeyword &pFilterNameKey)
Get Band Filter name from the Isis cube label.
int greenBand() const
Return the green band currently viewed.
Definition: CubeViewport.h:173
void center(int x, int y)
Bring the cube pixel under viewport x/y to the center.
void setScale(double scale)
Change the scale of the cube to the given parameter value.
void cubeContentsChanged(QRect rect)
Cube changed, repaint given area.
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:542
BandInfo p_blue
Blue band info.
Definition: CubeViewport.h:520
bool p_saveEnabled
Has the cube changed?
Definition: CubeViewport.h:530
void discardChanges(CubeViewport *)
Emitted when changes should be discarded.
int redBand() const
Return the red band currently viewed.
Definition: CubeViewport.h:168
virtual void viewRGB(int redBand, int greenBand, int blueBand)
View cube as color.
QPoint cursorPosition() const
Return the cursor position in the viewport.
Projection * projection() const
Return the projection associated with cube (NULL implies none)
Definition: CubeViewport.h:233
Widget to display Isis cubes for qt apps.
Definition: CubeViewport.h:121
void mouseButtonPress(QPoint, Qt::MouseButton)
Emitted when mouse button pressed.
void setComboCount(int count)
Sets the band bin combo box count.
Definition: CubeViewport.h:267
void updateScrollBars(int x, int y)
Update the scroll bar.
ViewportBuffer * p_blueBuffer
Viewport Buffer to manage blue band.
Definition: CubeViewport.h:502
void screenPixelsChanged()
Emitted when cube pixels that should be on the screen change.
Brick * p_bluBrick
Bricks for every color.
Definition: CubeViewport.h:527
bool p_thisOwnsCubeData
if true then this owns the CubeDataThread, and should thus delete it
Definition: CubeViewport.h:551
void paintPixmap()
Paint the whole pixmap.
double greenPixel(int sample, int line)
Return the green pixel value at a sample/line.
bool p_color
Is the viewport in color?
Definition: CubeViewport.h:516
double redPixel(int sample, int line)
Return the red pixel value at a sample/line.
void setComboIndex(int index)
Sets the band bin combo box index.
Definition: CubeViewport.h:276
double grayPixel(int sample, int line)
Return the gray pixel value at a sample/line.
Stretch blueStretch() const
Return the blue band stretch.
void windowTitleChanged()
Emitted when window title changes.
int comboCount() const
Return the BandBin combo box count.
Definition: CubeViewport.h:193
QString p_whatsThisText
The text for What&#39;s this.
Definition: CubeViewport.h:536
Stretch grayStretch() const
Return the gray band stretch.
Base class for Map Projections.
Definition: Projection.h:169
Cube * cube() const
Return the cube associated with viewport.
Definition: CubeViewport.h:228
void stretchKnownGlobal()
List&lt;Tool *&gt; 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.
int grayBand() const
Return the gray band currently viewed.
Definition: CubeViewport.h:163
bool p_paintPixmap
Paint the pixmap?
Definition: CubeViewport.h:533
int comboIndex() const
Return the BandBin combo box index.
Definition: CubeViewport.h:198
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
Projection * p_projection
The projection from the cube.
Definition: CubeViewport.h:508
Camera * camera() const
Return the camera associated with the cube (NULL implies none)
Definition: CubeViewport.h:238
void mouseMove(QPoint)
Emitted when the mouse moves.
double fitScaleHeight() const
Determine the scale of cube in heighth to fit in the viewport.
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:517
void cubeToContents(double sample, double line, int &x, int &y) const
Convert a cube sample/line to a contents x/y (should not be outside)
void enableProgress()
This restarts the progress bar.
virtual void resizeEvent(QResizeEvent *e)
The viewport is being resized.
double bluePixel(int sample, int line)
Return the blue pixel value at a sample/line.
void mouseEnter()
Emitted when the mouse enters the viewport.
void viewportToCube(int x, int y, double &sample, double &line) const
Convert a viewport x/y to a cube sample/line (may be outside the cube)
int p_comboCount
Number of elements in band bin combo box.
Definition: CubeViewport.h:522
QString p_viewportWhatsThisText
The text for the viewport&#39;s what&#39;s this.
Definition: CubeViewport.h:538
Encapsulation of Cube I/O with Change Notifications.
Container for cube-like labels.
Definition: Pvl.h:135
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:526
ViewportBuffer * blueBuffer()
Returns the blue viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:326
int cubeBands() const
Return the number of bands in the cube.
QVector< Stretch * > * p_globalStretches
Global stretches for each stretched band.
Definition: CubeViewport.h:495
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:523
int p_cubeId
Cube ID given from cube data thread for I/O.
Definition: CubeViewport.h:545
virtual void restretch(ViewportBuffer *buffer)=0
This is called by internal viewport buffers when a stretch action should be performed.
void cubeToViewport(double sample, double line, int &x, int &y) const
Convert a cube sample/line to a viewport x/y (may be outside the viewport)
UniversalGroundMap * p_groundMap
The universal ground map from the cube.
Definition: CubeViewport.h:509
bool p_cubeShown
Is the cube visible?
Definition: CubeViewport.h:531
virtual void cubeDataChanged(int cubeId, const Isis::Brick *)
This method updates the internal viewport buffer based on changes in cube DN values.
bool cubeShown() const
Return if the cube is visible.
Definition: CubeViewport.h:188
CubeDataThread * cubeDataThread()
Definition: CubeViewport.h:358
void stretchGreen(const QString &string)
Apply stretch pairs to green bands.
ViewportBuffer * p_redBuffer
Viewport Buffer to manage red band.
Definition: CubeViewport.h:500
CubeViewport(Cube *cube, CubeDataThread *cdt=0, QWidget *parent=0)
Construct a cube viewport.
virtual void paintEvent(QPaintEvent *e)
Repaint the viewport.
CubeDataThread * p_cubeData
Does all the cube I/O.
Definition: CubeViewport.h:544
QString p_cubeWhatsThisText
The text for the cube&#39;s What&#39;s this.
Definition: CubeViewport.h:537
void setBackground(QColor color)
Sets the background color.
Definition: CubeViewport.h:258
Cube * p_cube
The cube associated with the viewport.
Definition: CubeViewport.h:506
virtual ~CubeViewport()
Destructor.
double scale() const
Return the scale.
Definition: CubeViewport.h:183
void contentsToCube(int x, int y, double &sample, double &line) const
Convert a contents x/y to a cube sample/line (may be outside the cube)
QSize sizeHint() const
Make viewports show up as 512 by 512.
void setCube(Cube *cube)
This method sets the viewports cube.
void setCaption()
Change the caption on the viewport title bar.
virtual void keyPressEvent(QKeyEvent *e)
Process arrow keystrokes on cube.
int blueBand() const
Return the blue band currently viewed.
Definition: CubeViewport.h:178
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:529
void onProgressTimer()
This updates the progress bar visually.
void stretchGray(const QString &string)
Apply stretch pairs to gray band.
int cubeLines() const
Return the number of lines in the cube.
ViewportBuffer * greenBuffer()
Returns the green viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:316
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:504
double p_scale
The scale number.
Definition: CubeViewport.h:514
double fitScale() const
Determine the scale that causes the full cube to fit in the viewport.
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:528
virtual bool eventFilter(QObject *o, QEvent *e)
Event filter to watch for mouse events on viewport.
IO Handler for Isis Cubes.
Definition: Cube.h:158
void paintPixmapRects()
Goes through the list of requested paints, from the viewport buffer, and paints them.
QImage * p_image
The qimage.
Definition: CubeViewport.h:532

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:17:19