|
Isis 3.0 Object Programmers' Reference |
Home |
00001 #ifndef CubeViewport_h 00002 #define CubeViewport_h 00003 00027 // parent of this class 00028 #include <QAbstractScrollArea> 00029 00030 00031 class QPaintEvent; 00032 00033 namespace Isis { 00034 class Brick; 00035 class Camera; 00036 class Cube; 00037 class CubeDataThread; 00038 class Projection; 00039 class Pvl; 00040 class PvlKeyword; 00041 class Stretch; 00042 class Tool; 00043 class UniversalGroundMap; 00044 00045 class ViewportBuffer; 00046 00116 class CubeViewport : public QAbstractScrollArea { 00117 Q_OBJECT 00118 00119 public: 00120 CubeViewport(Cube *cube, CubeDataThread * cdt = 0, QWidget *parent = 0); 00121 virtual ~CubeViewport(); 00122 00123 00129 class BandInfo { 00130 public: 00131 BandInfo(); 00132 BandInfo(const BandInfo &other); 00133 ~BandInfo(); 00134 const BandInfo &operator=(BandInfo other); 00135 Stretch getStretch() const; 00136 void setStretch(const Stretch &newStretch); 00137 int band; 00138 private: 00139 Stretch *stretch; 00140 }; 00141 00142 void setCube(Cube *cube); 00143 int cubeSamples() const; 00144 int cubeLines() const; 00145 int cubeBands() const; 00146 00148 bool isColor() const { 00149 return p_color; 00150 }; 00151 00153 bool isGray() const { 00154 return !p_color; 00155 }; 00156 00158 int grayBand() const { 00159 return p_gray.band; 00160 }; 00161 00163 int redBand() const { 00164 return p_red.band; 00165 }; 00166 00168 int greenBand() const { 00169 return p_green.band; 00170 }; 00171 00173 int blueBand() const { 00174 return p_blue.band; 00175 }; 00176 00178 double scale() const { 00179 return p_scale; 00180 }; 00181 00183 bool cubeShown() const { 00184 return p_cubeShown; 00185 }; 00186 00187 void cubeContentsChanged(QRect rect); 00188 00189 double fitScale() const; 00190 double fitScaleWidth() const; 00191 double fitScaleHeight() const; 00192 00193 void viewportToCube(int x, int y, 00194 double &sample, double &line) const; 00195 void cubeToViewport(double sample, double line, 00196 int &x, int &y) const; 00197 void contentsToCube(int x, int y, 00198 double &sample, double &line) const; 00199 void cubeToContents(double sample, double line, 00200 int &x, int &y) const; 00201 00202 double redPixel(int sample, int line); 00203 double greenPixel(int sample, int line); 00204 double bluePixel(int sample, int line); 00205 double grayPixel(int sample, int line); 00206 00207 Stretch grayStretch() const; 00208 Stretch redStretch() const; 00209 Stretch greenStretch() const; 00210 Stretch blueStretch() const; 00211 00213 Cube *cube() const { 00214 return p_cube; 00215 }; 00216 00218 Projection *projection() const { 00219 return p_projection; 00220 }; 00221 00223 Camera *camera() const { 00224 return p_camera; 00225 }; 00226 00228 UniversalGroundMap *universalGroundMap() const { 00229 return p_groundMap; 00230 }; 00231 00232 void moveCursor(int x, int y); 00233 bool cursorInside() const; 00234 QPoint cursorPosition() const; 00235 void setCursorPosition(int x, int y); 00236 void setCaption(); 00237 00243 void setBackground(QColor color) { 00244 p_bgColor = color; 00245 } 00246 00253 QPixmap pixmap() { 00254 return p_pixmap; 00255 } 00256 00263 ViewportBuffer *grayBuffer() { 00264 return p_grayBuffer; 00265 } 00266 00273 ViewportBuffer *redBuffer() { 00274 return p_redBuffer; 00275 } 00276 00283 ViewportBuffer *greenBuffer() { 00284 return p_greenBuffer; 00285 } 00286 00293 ViewportBuffer *blueBuffer() { 00294 return p_blueBuffer; 00295 } 00296 00297 void bufferUpdated(QRect rect); 00298 00306 virtual void restretch(ViewportBuffer *buffer) = 0; 00307 void paintPixmap(); 00308 00312 void forgetStretches(); 00313 00319 void setAllBandStretches(Stretch stretch); 00320 00321 00325 CubeDataThread *cubeDataThread() { 00326 return p_cubeData; 00327 } 00328 00332 int cubeID() { 00333 return p_cubeId; 00334 } 00335 00336 00342 void getAllWhatsThisInfo(Pvl & pWhatsThisPvl); 00343 00350 void getBandFilterName(PvlKeyword & pFilterNameKey); 00351 00360 void getCubeArea(double & pdStartSample, double & pdEndSample, 00361 double & pdStartLine, double & pdEndLine); 00362 00363 bool confirmClose(); 00364 00365 signals: 00366 void viewportUpdated(); 00367 void viewportClosed(CubeViewport *); 00368 void mouseEnter(); 00369 void mouseMove(QPoint); 00370 void mouseMove(QPoint, Qt::MouseButton); 00371 void mouseLeave(); 00372 void mouseButtonPress(QPoint, Qt::MouseButton); 00373 void mouseButtonRelease(QPoint, Qt::MouseButton); 00374 void mouseDoubleClick(QPoint); 00375 void windowTitleChanged(); 00376 void scaleChanged(); 00377 void saveChanges(CubeViewport *); 00378 void discardChanges(CubeViewport *); 00379 void screenPixelsChanged(); 00380 00384 void progressChanged(int); 00385 00390 void doneWithData(int, const Isis::Brick *); 00391 00392 00393 public slots: 00394 QSize sizeHint() const; 00395 void setScale(double scale); 00396 void setScale(double scale, double sample, double line); 00397 void setScale(double scale, int x, int y); 00398 void center(int x, int y); 00399 void center(double sample, double line); 00400 00401 virtual void viewRGB(int redBand, int greenBand, int blueBand); 00402 virtual void viewGray(int band); 00403 00404 void stretchGray(const QString &string); 00405 void stretchRed(const QString &string); 00406 void stretchGreen(const QString &string); 00407 void stretchBlue(const QString &string); 00408 00409 void stretchGray(const Stretch &stretch); 00410 void stretchRed(const Stretch &stretch); 00411 void stretchGreen(const Stretch &stretch); 00412 void stretchBlue(const Stretch &stretch); 00413 00414 void stretchKnownGlobal(); 00415 00416 void cubeChanged(bool changed); 00417 void showEvent(QShowEvent *); 00418 00419 void scrollBy(int dx, int dy); 00420 00421 void changeCursor(QCursor cursor); 00422 00423 void onProgressTimer(); 00424 void enableProgress(); 00425 00426 00427 protected: 00428 void scrollContentsBy(int dx, int dy); 00429 virtual void resizeEvent(QResizeEvent *e); 00430 virtual bool eventFilter(QObject *o, QEvent *e); 00431 virtual void keyPressEvent(QKeyEvent *e); 00432 virtual void paintEvent(QPaintEvent *e); 00433 00434 00435 00436 protected slots: 00437 virtual void cubeDataChanged(int cubeId, const Isis::Brick *); 00438 00439 00440 private: 00441 00442 void paintPixmap(QRect rect); 00443 void shiftPixmap(int dx, int dy); 00444 00445 void updateScrollBars(int x, int y); 00446 void paintPixmapRects(); 00447 00448 //void computeStretch(Brick *brick, int band, 00449 // int ssamp, int esamp, 00450 // int sline, int eline, int linerate, 00451 // Stretch &stretch); 00452 00453 00454 00455 protected: // data 00456 QPixmap p_pixmap; 00457 00459 QVector< Stretch * > * p_knownStretches; 00460 00462 QVector< Stretch * > * p_globalStretches; 00463 00464 00465 private: // data 00466 ViewportBuffer *p_grayBuffer; 00467 ViewportBuffer *p_redBuffer; 00468 ViewportBuffer *p_greenBuffer; 00469 ViewportBuffer *p_blueBuffer; 00470 00471 QColor p_bgColor; 00472 00473 Cube *p_cube; 00474 Camera *p_camera; 00475 Projection *p_projection; 00476 UniversalGroundMap *p_groundMap; 00477 00479 QTimer *p_progressTimer; 00480 00481 double p_scale; 00482 00483 bool p_color; 00484 BandInfo p_gray; 00485 BandInfo p_red; 00486 BandInfo p_green; 00487 BandInfo p_blue; 00488 00489 Brick *p_redBrick; 00490 Brick *p_grnBrick; 00491 Brick *p_bluBrick; 00492 Brick *p_gryBrick; 00493 Brick *p_pntBrick; 00494 bool p_saveEnabled; 00495 bool p_cubeShown; 00496 QImage *p_image; 00497 bool p_paintPixmap; 00498 bool p_updatingBuffers; 00499 00500 QString p_whatsThisText; 00501 QString p_cubeWhatsThisText; 00502 QString p_viewportWhatsThisText; 00503 void updateWhatsThis(); 00504 00506 QList< QRect * > *p_pixmapPaintRects; 00507 00508 CubeDataThread *p_cubeData; 00509 int p_cubeId; 00510 00515 bool p_thisOwnsCubeData; 00516 }; 00517 } 00518 00519 #endif