Isis 3 Programmer Reference
CubeViewport.h
1#ifndef CubeViewport_h
2#define CubeViewport_h
3
10/* SPDX-License-Identifier: CC0-1.0 */
11
12
13// parent of this class
14#include <QAbstractScrollArea>
15
16class QPaintEvent;
17
18namespace Isis {
19 class Brick;
20 class Camera;
21 class Cube;
22 class CubeDataThread;
23 class Projection;
24 class Pvl;
25 class PvlKeyword;
26 class CubeStretch;
27 class Stretch;
28 class Tool;
29 class UniversalGroundMap;
30
31 class ViewportBuffer;
32
123 Q_OBJECT
124
125 public:
134 CubeViewport(Cube *cube, CubeDataThread * cdt = 0, QWidget *parent = 0);
135
139 virtual ~CubeViewport();
140
141
147 class BandInfo {
148 public:
149 BandInfo();
151 BandInfo(const BandInfo &other);
153 ~BandInfo();
154
161 const BandInfo &operator=(BandInfo other);
162
164 CubeStretch getStretch() const;
166 void setStretch(const Stretch &newStretch);
168 int band;
169 private:
172 };
173
175 void setCube(Cube *cube);
177 int cubeSamples() const;
179 int cubeLines() const;
181 int cubeBands() const;
182
184 bool isColor() const {
185 return p_color;
186 };
187
189 bool isGray() const {
190 return !p_color;
191 };
192
194 int grayBand() const {
195 return p_gray.band;
196 };
197
199 int redBand() const {
200 return p_red.band;
201 };
202
204 int greenBand() const {
205 return p_green.band;
206 };
207
209 int blueBand() const {
210 return p_blue.band;
211 };
212
214 double scale() const {
215 return p_scale;
216 };
217
219 bool cubeShown() const {
220 return p_cubeShown;
221 };
222
224 int comboCount() const {
225 return p_comboCount;
226 };
227
229 int comboIndex() const {
230 return p_comboIndex;
231 }
232
238 void cubeContentsChanged(QRect rect);
239
241 double fitScale() const;
243 double fitScaleWidth() const;
245 double fitScaleHeight() const;
246
255 void viewportToCube(int x, int y,
256 double &sample, double &line) const;
257
266 void cubeToViewport(double sample, double line,
267 int &x, int &y) const;
276 void contentsToCube(int x, int y,
277 double &sample, double &line) const;
286 void cubeToContents(double sample, double line,
287 int &x, int &y) const;
288
297 double redPixel(int sample, int line);
298
307 double greenPixel(int sample, int line);
308
317 double bluePixel(int sample, int line);
318
327 double grayPixel(int sample, int line);
329 CubeStretch grayStretch() const;
331 CubeStretch redStretch() const;
335 CubeStretch blueStretch() const;
336
338 Cube *cube() const {
339 return p_cube;
340 };
341
344 return p_projection;
345 };
346
348 Camera *camera() const {
349 return p_camera;
350 };
351
354 return p_groundMap;
355 };
356
359 return p_trackingCube;
360 };
361
362 void moveCursor(int x, int y);
363 bool cursorInside() const;
364 QPoint cursorPosition() const;
365 void setCursorPosition(int x, int y);
366 void setCaption();
367
373 void setBackground(QColor color) {
374 p_bgColor = color;
375 }
376
382 void setComboCount(int count) {
383 p_comboCount = count;
384 }
385
391 void setComboIndex(int index) {
392 p_comboIndex = index;
393 }
394
401 QPixmap pixmap() {
402 return p_pixmap;
403 }
404
412 return p_grayBuffer;
413 }
414
422 return p_redBuffer;
423 }
424
434
442 return p_blueBuffer;
443 }
444
445 void bufferUpdated(QRect rect);
446
454 virtual void restretch(ViewportBuffer *buffer) = 0;
455 void paintPixmap();
456
460 void forgetStretches();
461
467 void setAllBandStretches(Stretch stretch);
468
469
476
480 int cubeID() {
481 return p_cubeId;
482 }
483
484
490 void getAllWhatsThisInfo(Pvl & pWhatsThisPvl);
491
498 void getBandFilterName(PvlKeyword & pFilterNameKey);
499
508 void getCubeArea(double & pdStartSample, double & pdEndSample,
509 double & pdStartLine, double & pdEndLine);
510
511 bool confirmClose();
512
513 void setTrackingCube();
514
515 signals:
519 void mouseMove(QPoint);
520 void mouseMove(QPoint, Qt::MouseButton);
522 void mouseButtonPress(QPoint, Qt::MouseButton);
523 void mouseButtonRelease(QPoint, Qt::MouseButton);
524 void mouseDoubleClick(QPoint);
530
539
544 void doneWithData(int, const Isis::Brick *);
545
546
547 public slots:
548 QSize sizeHint() const;
549 void setScale(double scale);
550 void setScale(double scale, double sample, double line);
551 void setScale(double scale, int x, int y);
552 void center(int x, int y);
553 void center(double sample, double line);
554
555 virtual void viewRGB(int redBand, int greenBand, int blueBand);
556 virtual void viewGray(int band);
557
558 void stretchGray(const QString &string);
559 void stretchRed(const QString &string);
560 void stretchGreen(const QString &string);
561 void stretchBlue(const QString &string);
562
563 void stretchGray(const Stretch &stretch);
564 void stretchRed(const Stretch &stretch);
565 void stretchGreen(const Stretch &stretch);
566 void stretchBlue(const Stretch &stretch);
567
568 void stretchKnownGlobal();
569
570 void cubeChanged(bool changed);
571 void showEvent(QShowEvent *);
572
573 void scrollBy(int dx, int dy);
574
575 void changeCursor(QCursor cursor);
576
577 void onProgressTimer();
578 void enableProgress();
579
580
581 protected:
582 void scrollContentsBy(int dx, int dy);
583 virtual void resizeEvent(QResizeEvent *e);
584 virtual bool eventFilter(QObject *o, QEvent *e);
585 virtual void keyPressEvent(QKeyEvent *e);
586 virtual void paintEvent(QPaintEvent *e);
587
588
589
590 protected slots:
591 virtual void cubeDataChanged(int cubeId, const Isis::Brick *);
592
593
594 private:
595
596 void paintPixmap(QRect rect);
597 void shiftPixmap(int dx, int dy);
598
599 void updateScrollBars(int x, int y);
600 void paintPixmapRects();
601
602 //void computeStretch(Brick *brick, int band,
603 // int ssamp, int esamp,
604 // int sline, int eline, int linerate,
605 // Stretch &stretch);
606
607
608
609 protected: // data
610 QPixmap p_pixmap;
611
613 QVector< Stretch * > * p_knownStretches;
614
616 QVector< Stretch * > * p_globalStretches;
617
618
619 private: // data
624
625 QColor p_bgColor;
626
631 Cube *p_trackingCube; //<! The tracking cube associated with p_cube
632
635
636 double p_scale;
637
643
646
654 QImage *p_image;
657
661 void updateWhatsThis();
662
665
668
674 };
675}
676
677#endif
Buffer for containing a three dimensional section of an image.
Definition Brick.h:45
Encapsulation of Cube I/O with Change Notifications.
IO Handler for Isis Cubes.
Definition Cube.h:168
Stores stretch information for a cube.
Definition CubeStretch.h:27
const BandInfo & operator=(BandInfo other)
The BandInfo for the Cube.
CubeStretch getStretch() const
void setStretch(const Stretch &newStretch)
CubeStretch * stretch
The Stretch.
Widget to display Isis cubes for qt apps.
bool p_cubeShown
Is the cube visible?
void stretchGray(const QString &string)
Apply stretch pairs to gray band.
void getCubeArea(double &pdStartSample, double &pdEndSample, double &pdStartLine, double &pdEndLine)
Get Cube area corresponding to the viewport's dimension.
void setBackground(QColor color)
Sets the background color.
double bluePixel(int sample, int line)
Gets the blue pixel.
void updateScrollBars(int x, int y)
Update the scroll bar.
CubeViewport(Cube *cube, CubeDataThread *cdt=0, QWidget *parent=0)
Constructor for the CubeViewport.
Brick * p_pntBrick
Bricks for every color.
double scale() const
void stretchBlue(const QString &string)
Apply stretch pairs to blue bands.
Cube * p_cube
The cube associated with the viewport.
int comboCount() const
CubeStretch grayStretch() const
Return the gray band stretch.
void doneWithData(int, const Isis::Brick *)
Emitted when a brick is no longer needed, should only be sent to cube data thread.
void showEvent(QShowEvent *)
This method is called to initially show the viewport.
void viewportClosed(CubeViewport *)
Emitted when viewport is closed.
void getBandFilterName(PvlKeyword &pFilterNameKey)
Get Band Filter name from the Isis cube label.
Brick * p_redBrick
Bricks for every color.
int cubeLines() const
Return the number of lines in the cube.
void discardChanges(CubeViewport *)
Emitted when changes should be discarded.
double greenPixel(int sample, int line)
Gets the green pixel.
int greenBand() const
ViewportBuffer * p_grayBuffer
Viewport Buffer to manage gray band.
int cubeBands() const
Return the number of bands in the cube.
QString p_whatsThisText
The text for What's this.
virtual void restretch(ViewportBuffer *buffer)=0
This is called by internal viewport buffers when a stretch action should be performed.
ViewportBuffer * p_redBuffer
Viewport Buffer to manage red band.
void mouseMove(QPoint, Qt::MouseButton)
Emitted when the mouse moves.
bool p_color
Is the viewport in color?
bool p_updatingBuffers
Changing RGB and need to not repaint pixmap?
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.
CubeStretch redStretch() const
Return the red band stretch.
void scaleChanged()
Emitted when zoom factor changed just before the repaint event.
int redBand() const
bool p_thisOwnsCubeData
if true then this owns the CubeDataThread, and should thus delete it
void setComboCount(int count)
Sets the band bin combo box count.
void setCube(Cube *cube)
This method sets the viewports cube.
virtual void resizeEvent(QResizeEvent *e)
The viewport is being resized.
bool isColor() const
virtual void paintEvent(QPaintEvent *e)
Repaint the viewport.
void contentsToCube(int x, int y, double &sample, double &line) const
Turns contents to a cube.
QSize sizeHint() const
Make viewports show up as 512 by 512.
void changeCursor(QCursor cursor)
Allows users to change the cursor type on the viewport.
Projection * p_projection
The projection from the cube.
void updateWhatsThis()
Update the What's This text.
virtual bool eventFilter(QObject *o, QEvent *e)
Event filter to watch for mouse events on viewport.
bool cursorInside() const
Is cursor inside viewport.
QPoint cursorPosition() const
Return the cursor position in the viewport.
ViewportBuffer * grayBuffer()
Returns the gray viewport buffer (Will be NULL if in RGB mode.)
virtual ~CubeViewport()
Deconstructor for the Cubeviewport.
virtual void viewRGB(int redBand, int greenBand, int blueBand)
View cube as color.
int p_comboIndex
Current element chosen from combo box.
double fitScaleHeight() const
Determine the scale of cube in heighth to fit in the viewport.
void paintPixmapRects()
Goes through the list of requested paints, from the viewport buffer, and paints them.
int cubeSamples() const
Return the number of samples in the cube.
void mouseDoubleClick(QPoint)
Emitted when double click happens.
void progressComplete()
Emitted when the current progress is complete (100)
void stretchKnownGlobal()
List<Tool *> p This stretches to the global stretch.
QPixmap p_pixmap
The qpixmap.
void stretchGreen(const QString &string)
Apply stretch pairs to green bands.
void scrollContentsBy(int dx, int dy)
Scroll the viewport contents by dx/dy screen pixels.
Brick * p_grnBrick
Bricks for every color.
QString p_viewportWhatsThisText
The text for the viewport's what's this.
double grayPixel(int sample, int line)
Gets the gray pixel.
Cube * trackingCube() const
void setTrackingCube()
Finds the Tracking group from p_cube and stores the tracking cube name so that we can grab it in Adva...
void cubeChanged(bool changed)
This method is called when the cube has changed or changes have been finalized.
void cubeToContents(double sample, double line, int &x, int &y) const
Turns a cube into contents.
bool p_saveEnabled
Has the cube changed?
QString p_cubeWhatsThisText
The text for the cube's What's this.
virtual void keyPressEvent(QKeyEvent *e)
Process arrow keystrokes on cube.
void viewportToCube(int x, int y, double &sample, double &line) const
Turns a viewport into a cube.
QColor p_bgColor
The color to paint the background of the viewport.
void cubeToViewport(double sample, double line, int &x, int &y) const
Turns a cube into a viewport.
void mouseButtonRelease(QPoint, Qt::MouseButton)
Emitted when mouse button released.
BandInfo p_blue
Blue band info.
void mouseButtonPress(QPoint, Qt::MouseButton)
Emitted when mouse button pressed.
void mouseLeave()
Emitted when the mouse leaves the viewport.
double fitScale() const
Determine the scale that causes the full cube to fit in the viewport.
CubeDataThread * p_cubeData
Does all the cube I/O.
void stretchRed(const QString &string)
Apply stretch pairs to red bands.
bool confirmClose()
This method should be called during a close event that would cause this viewport to close.
Brick * p_bluBrick
Bricks for every color.
CubeStretch greenStretch() const
Return the green band stretch.
BandInfo p_green
Green band info.
void saveChanges(CubeViewport *)
Emitted when changes should be saved.
void setScale(double scale)
Change the scale of the cube to the given parameter value.
Camera * camera() const
void forgetStretches()
Resets all remembered stretches.
int grayBand() const
Camera * p_camera
The camera from the cube.
ViewportBuffer * p_greenBuffer
Viewport Buffer to manage green band.
QTimer * p_progressTimer
Activated to update progress bar.
QImage * p_image
The qimage.
void paintPixmap()
Paint the whole pixmap.
void getAllWhatsThisInfo(Pvl &pWhatsThisPvl)
Get All WhatsThis info - viewport, cube, area in PVL format.
BandInfo p_gray
Gray band info.
Cube * cube() const
int comboIndex() const
void mouseEnter()
Emitted when the mouse enters the viewport.
int p_comboCount
Number of elements in band bin combo box.
double redPixel(int sample, int line)
Gets the red pixel.
ViewportBuffer * greenBuffer()
Returns the green viewport buffer (Will be NULL if in Gray mode.)
void enableProgress()
This restarts the progress bar.
virtual void viewGray(int band)
View cube as gray.
ViewportBuffer * redBuffer()
Returns the red viewport buffer (Will be NULL if in Gray mode.)
BandInfo p_red
Red band info.
void windowTitleChanged()
Emitted when window title changes.
UniversalGroundMap * p_groundMap
The universal ground map from the cube.
void scrollBy(int dx, int dy)
Move the scrollbars by dx/dy screen pixels.
QVector< Stretch * > * p_globalStretches
Global stretches for each stretched band.
void shiftPixmap(int dx, int dy)
Shifts the pixels on the pixmap without reading new data.
void progressChanged(int)
Emitted with current progress (0 to 100) when working.
QVector< Stretch * > * p_knownStretches
Stretches for each previously stretched band.
void onProgressTimer()
This updates the progress bar visually.
void screenPixelsChanged()
Emitted when cube pixels that should be on the screen change.
Brick * p_gryBrick
Bricks for every color.
void setAllBandStretches(Stretch stretch)
Sets a stretch for all bands.
void viewportUpdated()
Emitted when viewport updated.
void moveCursor(int x, int y)
Move the cursor by x,y if possible.
int p_cubeId
Cube ID given from cube data thread for I/O.
void cubeContentsChanged(QRect rect)
Calle dhwen the contents of the cube changes.
bool p_paintPixmap
Paint the pixmap?
void setComboIndex(int index)
Sets the band bin combo box index.
QPixmap pixmap()
Returns the pixmap.
ViewportBuffer * blueBuffer()
Returns the blue viewport buffer (Will be NULL if in Gray mode.)
bool isGray() const
void setCaption()
Change the caption on the viewport title bar.
UniversalGroundMap * universalGroundMap() const
bool cubeShown() const
double p_scale
The scale number.
virtual void cubeDataChanged(int cubeId, const Isis::Brick *)
This method updates the internal viewport buffer based on changes in cube DN values.
int blueBand() const
Projection * projection() const
void mouseMove(QPoint)
Emitted when the mouse moves.
double fitScaleWidth() const
Determine the scale of cube in the width to fit in the viewport.
CubeStretch blueStretch() const
Return the blue band stretch.
void center(int x, int y)
Bring the cube pixel under viewport x/y to the center.
ViewportBuffer * p_blueBuffer
Viewport Buffer to manage blue band.
CubeDataThread * cubeDataThread()
void bufferUpdated(QRect rect)
This method is called by ViewportBuffer upon successful completion of all operations and gives the ap...
Base class for Map Projections.
Definition Projection.h:155
Container for cube-like labels.
Definition Pvl.h:119
A single keyword-value pair.
Definition PvlKeyword.h:87
Pixel value mapper.
Definition Stretch.h:58
Universal Ground Map.
Reads and stores visible DN values.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16