Isis 3.0 Developer's Reference (API) |
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 00106 class CubeViewport : public QAbstractScrollArea { 00107 Q_OBJECT 00108 00109 public: 00110 CubeViewport(Cube *cube, CubeDataThread * cdt = 0, QWidget *parent = 0); 00111 virtual ~CubeViewport(); 00112 00113 00119 class BandInfo { 00120 public: 00121 BandInfo(); 00122 BandInfo(const BandInfo &other); 00123 ~BandInfo(); 00124 const BandInfo &operator=(BandInfo other); 00125 Stretch getStretch() const; 00126 void setStretch(const Stretch &newStretch); 00127 int band; 00128 private: 00129 Stretch *stretch; 00130 }; 00131 00132 void setCube(Cube *cube); 00133 int cubeSamples() const; 00134 int cubeLines() const; 00135 int cubeBands() const; 00136 00138 bool isColor() const { 00139 return p_color; 00140 }; 00141 00143 bool isGray() const { 00144 return !p_color; 00145 }; 00146 00148 int grayBand() const { 00149 return p_gray.band; 00150 }; 00151 00153 int redBand() const { 00154 return p_red.band; 00155 }; 00156 00158 int greenBand() const { 00159 return p_green.band; 00160 }; 00161 00163 int blueBand() const { 00164 return p_blue.band; 00165 }; 00166 00168 double scale() const { 00169 return p_scale; 00170 }; 00171 00173 bool cubeShown() const { 00174 return p_cubeShown; 00175 }; 00176 00177 void cubeContentsChanged(QRect rect); 00178 00179 double fitScale() const; 00180 double fitScaleWidth() const; 00181 double fitScaleHeight() const; 00182 00183 void viewportToCube(int x, int y, 00184 double &sample, double &line) const; 00185 void cubeToViewport(double sample, double line, 00186 int &x, int &y) const; 00187 void contentsToCube(int x, int y, 00188 double &sample, double &line) const; 00189 void cubeToContents(double sample, double line, 00190 int &x, int &y) const; 00191 00192 double redPixel(int sample, int line); 00193 double greenPixel(int sample, int line); 00194 double bluePixel(int sample, int line); 00195 double grayPixel(int sample, int line); 00196 00197 Stretch grayStretch() const; 00198 Stretch redStretch() const; 00199 Stretch greenStretch() const; 00200 Stretch blueStretch() const; 00201 00203 Cube *cube() const { 00204 return p_cube; 00205 }; 00206 00208 Projection *projection() const { 00209 return p_projection; 00210 }; 00211 00213 Camera *camera() const { 00214 return p_camera; 00215 }; 00216 00218 UniversalGroundMap *universalGroundMap() const { 00219 return p_groundMap; 00220 }; 00221 00222 void moveCursor(int x, int y); 00223 bool cursorInside() const; 00224 QPoint cursorPosition() const; 00225 void setCursorPosition(int x, int y); 00226 void setCaption(); 00227 00233 void setBackground(QColor color) { 00234 p_bgColor = color; 00235 } 00236 00243 QPixmap pixmap() { 00244 return p_pixmap; 00245 } 00246 00253 ViewportBuffer *grayBuffer() { 00254 return p_grayBuffer; 00255 } 00256 00263 ViewportBuffer *redBuffer() { 00264 return p_redBuffer; 00265 } 00266 00273 ViewportBuffer *greenBuffer() { 00274 return p_greenBuffer; 00275 } 00276 00283 ViewportBuffer *blueBuffer() { 00284 return p_blueBuffer; 00285 } 00286 00287 void bufferUpdated(QRect rect); 00288 00296 virtual void restretch(ViewportBuffer *buffer) = 0; 00297 void paintPixmap(); 00298 00302 void forgetStretches(); 00303 00309 void setAllBandStretches(Stretch stretch); 00310 00311 00315 CubeDataThread *cubeDataThread() { 00316 return p_cubeData; 00317 } 00318 00322 int cubeID() { 00323 return p_cubeId; 00324 } 00325 00326 00332 void getAllWhatsThisInfo(Pvl & pWhatsThisPvl); 00333 00340 void getBandFilterName(PvlKeyword & pFilterNameKey); 00341 00350 void getCubeArea(double & pdStartSample, double & pdEndSample, 00351 double & pdStartLine, double & pdEndLine); 00352 00353 00354 signals: 00355 void viewportUpdated(); 00356 void mouseEnter(); 00357 void mouseMove(QPoint); 00358 void mouseMove(QPoint, Qt::MouseButton); 00359 void mouseLeave(); 00360 void mouseButtonPress(QPoint, Qt::MouseButton); 00361 void mouseButtonRelease(QPoint, Qt::MouseButton); 00362 void mouseDoubleClick(QPoint); 00363 void windowTitleChanged(); 00364 void scaleChanged(); 00365 void saveChanges(); 00366 void discardChanges(); 00367 void screenPixelsChanged(); 00368 00372 void progressChanged(int); 00373 00378 void doneWithData(int, const Isis::Brick *); 00379 00380 00381 public slots: 00382 QSize sizeHint() const; 00383 void setScale(double scale); 00384 void setScale(double scale, double sample, double line); 00385 void setScale(double scale, int x, int y); 00386 void center(int x, int y); 00387 void center(double sample, double line); 00388 00389 virtual void viewRGB(int redBand, int greenBand, int blueBand); 00390 virtual void viewGray(int band); 00391 00392 void stretchGray(const QString &string); 00393 void stretchRed(const QString &string); 00394 void stretchGreen(const QString &string); 00395 void stretchBlue(const QString &string); 00396 00397 void stretchGray(const Stretch &stretch); 00398 void stretchRed(const Stretch &stretch); 00399 void stretchGreen(const Stretch &stretch); 00400 void stretchBlue(const Stretch &stretch); 00401 00402 void stretchKnownGlobal(); 00403 00404 void cubeChanged(bool changed); 00405 void showEvent(QShowEvent *); 00406 00407 void scrollBy(int dx, int dy); 00408 00409 void changeCursor(QCursor cursor); 00410 00411 void onProgressTimer(); 00412 void enableProgress(); 00413 00414 00415 protected: 00416 virtual void closeEvent(QCloseEvent *event); 00417 void scrollContentsBy(int dx, int dy); 00418 virtual void resizeEvent(QResizeEvent *e); 00419 virtual bool eventFilter(QObject *o, QEvent *e); 00420 virtual void keyPressEvent(QKeyEvent *e); 00421 virtual void paintEvent(QPaintEvent *e); 00422 00423 00424 00425 protected slots: 00426 virtual void cubeDataChanged(int cubeId, const Isis::Brick *); 00427 00428 00429 private: 00430 00431 void paintPixmap(QRect rect); 00432 void shiftPixmap(int dx, int dy); 00433 00434 void updateScrollBars(int x, int y); 00435 void paintPixmapRects(); 00436 00437 //void computeStretch(Brick *brick, int band, 00438 // int ssamp, int esamp, 00439 // int sline, int eline, int linerate, 00440 // Stretch &stretch); 00441 00442 00443 00444 protected: // data 00445 QPixmap p_pixmap; 00446 00448 QVector< Stretch * > * p_knownStretches; 00449 00451 QVector< Stretch * > * p_globalStretches; 00452 00453 00454 private: // data 00455 ViewportBuffer *p_grayBuffer; 00456 ViewportBuffer *p_redBuffer; 00457 ViewportBuffer *p_greenBuffer; 00458 ViewportBuffer *p_blueBuffer; 00459 00460 QColor p_bgColor; 00461 00462 Cube *p_cube; 00463 Camera *p_camera; 00464 Projection *p_projection; 00465 UniversalGroundMap *p_groundMap; 00466 00468 QTimer *p_progressTimer; 00469 00470 double p_scale; 00471 00472 bool p_color; 00473 BandInfo p_gray; 00474 BandInfo p_red; 00475 BandInfo p_green; 00476 BandInfo p_blue; 00477 00478 Brick *p_redBrick; 00479 Brick *p_grnBrick; 00480 Brick *p_bluBrick; 00481 Brick *p_gryBrick; 00482 Brick *p_pntBrick; 00483 bool p_saveEnabled; 00484 bool p_cubeShown; 00485 QImage *p_image; 00486 bool p_paintPixmap; 00487 bool p_updatingBuffers; 00488 00489 QString p_whatsThisText; 00490 QString p_cubeWhatsThisText; 00491 QString p_viewportWhatsThisText; 00492 void updateWhatsThis(); 00493 00495 QList< QRect * > *p_pixmapPaintRects; 00496 00497 CubeDataThread *p_cubeData; 00498 int p_cubeId; 00499 00504 bool p_thisOwnsCubeData; 00505 }; 00506 } 00507 00508 #endif