Isis 3 Programmer Reference
CubeViewport.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "IsisDebug.h"
10 #include "CubeViewport.h"
11 
12 #include <iomanip>
13 #include <iostream>
14 #include <QApplication>
15 #include <QClipboard>
16 #include <QCloseEvent>
17 #include <QCursor>
18 #include <QDebug>
19 #include <QIcon>
20 #include <QPen>
21 #include <QPainter>
22 #include <QFileInfo>
23 #include <QMessageBox>
24 #include <QMouseEvent>
25 #include <QRgb>
26 #include <QScrollBar>
27 #include <QString>
28 #include <QTimer>
29 
30 #include "Brick.h"
31 #include "Camera.h"
32 #include "CubeDataThread.h"
33 #include "IException.h"
34 #include "IString.h"
35 #include "FileName.h"
36 #include "Histogram.h"
37 #include "Pvl.h"
38 #include "PvlGroup.h"
39 #include "PvlKeyword.h"
40 #include "PvlObject.h"
41 #include "Stretch.h"
42 #include "CubeStretch.h"
43 #include "StretchTool.h"
44 #include "Tool.h"
45 #include "UniversalGroundMap.h"
46 #include "ViewportBuffer.h"
47 
48 
49 using namespace std;
50 
51 
52 namespace Isis {
60  CubeViewport::CubeViewport(Cube *cube, CubeDataThread * cubeData,
61  QWidget *parent) : QAbstractScrollArea(parent) {
62  // Is the cube usable?
63  if(cube == NULL) {
65  "Can not view NULL cube pointer",
66  _FILEINFO_);
67  }
68  else if(!cube->isOpen()) {
70  "Can not view unopened cube",
71  _FILEINFO_);
72  }
73 
74  p_cube = cube;
75  p_cubeData = NULL;
76 
77  if (cubeData)
78  {
79  p_cubeData = cubeData;
80  p_thisOwnsCubeData = false;
82  }
83  else
84  {
85  p_cubeData = new CubeDataThread();
86  p_thisOwnsCubeData = true;
88  }
89 
90  if(p_cube->hasGroup("Tracking")) {
92  }
93  else {
94  p_trackingCube = NULL;
95  }
96 
97 
98  connect(p_cubeData, SIGNAL(BrickChanged(int, const Isis::Brick *)),
99  this, SLOT(cubeDataChanged(int, const Isis::Brick *)));
100  connect(this, SIGNAL(doneWithData(int, const Isis::Brick *)),
101  p_cubeData, SLOT(DoneWithData(int, const Isis::Brick *)));
102 
104 
105  void doneWithData(int, const Brick *);
106 
107  // Set up the scroll area
108  setAttribute(Qt::WA_DeleteOnClose);
109  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
110  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
111  viewport()->setObjectName("viewport");
112  viewport()->setCursor(QCursor(Qt::CrossCursor));
113  viewport()->installEventFilter(this);
114  viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
115 
116  setAttribute(Qt::WA_NoSystemBackground);
117  setFrameShadow(QFrame::Plain);
118  setFrameShape(QFrame::NoFrame);
119  setAutoFillBackground(false);
120 
121 // viewport()->setAttribute(Qt::WA_NoSystemBackground);
122 // viewport()->setAttribute(Qt::WA_PaintOnScreen,false);
123 
124  p_saveEnabled = false;
125  // Save off info about the cube
126  p_scale = -1.0;
127  p_color = false;
128 
129 
130  setCaption();
131 
132  p_redBrick = new Brick(4, 1, 1, cube->pixelType());
133  p_grnBrick = new Brick(4, 1, 1, cube->pixelType());
134  p_bluBrick = new Brick(4, 1, 1, cube->pixelType());
135  p_gryBrick = new Brick(4, 1, 1, cube->pixelType());
136  p_pntBrick = new Brick(4, 1, 1, cube->pixelType());
137 
138  p_paintPixmap = false;
139  p_image = NULL;
140  p_cubeShown = true;
141  p_updatingBuffers = false;
142 
143  //updateScrollBars(1,1);
144 
145  p_groundMap = NULL;
146  p_projection = NULL;
147  p_camera = NULL;
148 
149  // Setup a universal ground map
150  try {
152  }
153  catch(IException &) {
154  }
155 
156  if(p_groundMap != NULL) {
157  // Setup the camera or the projection
158  if(p_groundMap->Camera() != NULL) {
160  if(p_camera->HasProjection()) {
161  try {
163  }
164  catch(IException &) {
165  }
166  }
167  }
168  else {
170  }
171  }
172 
173 
174  // Setup context sensitive help
175  QString cubeFileName = p_cube->fileName();
176  p_whatsThisText = QString("<b>Function: </b>Viewport to ") + cubeFileName;
177 
179  "<p><b>Cube Dimensions:</b> \
180  <blockQuote>Samples = " +
181  QString::number(cube->sampleCount()) + "<br>" +
182  "Lines = " +
183  QString::number(cube->lineCount()) + "<br>" +
184  "Bands = " +
185  QString::number(cube->bandCount()) + "</blockquote></p>";
186 
187  /*setting up the qlist of CubeBandsStretch objs.
188  for( int b = 0; b < p_cube->bandCount(); b++) {
189  CubeBandsStretch *stretch = new CubeBandsStretch();
190  p_bandsStretchList.push_back(stretch);
191  }*/
192 
194  p_grayBuffer->enable(false);
195  p_grayBuffer->setBand(1);
196 
197  p_redBuffer = NULL;
198  p_greenBuffer = NULL;
199  p_blueBuffer = NULL;
200  p_pixmapPaintRects = NULL;
201 
203  p_progressTimer = new QTimer();
204  p_progressTimer->setInterval(250);
205 
208 
209  while(p_cube->bandCount() > p_knownStretches->size()) {
210  p_knownStretches->push_back(NULL);
211  p_globalStretches->push_back(NULL);
212  }
213 
214  connect(p_progressTimer, SIGNAL(timeout()), this, SLOT(onProgressTimer()));
215 
216  p_bgColor = Qt::black;
217 
218  p_comboCount = 0;
219  p_comboIndex = 0;
220 
221  p_image = new QImage(viewport()->size(), QImage::Format_RGB32);
222  }
223 
224 
233  void CubeViewport::showEvent(QShowEvent *event) {
234  if(p_scale == -1) {
235  // This doesn't equal fitScale() ... causes misalignment in qview initial
236  // view versus zoomFit
237  //double sampScale = (double) sizeHint().width() / (double) cubeSamples();
238  //double lineScale = (double) sizeHint().height() / (double) cubeLines();
239  //double scale = sampScale < lineScale ? sampScale : lineScale;
240 
241  setScale(fitScale(), cubeSamples() / 2.0 + 0.5, cubeLines() / 2.0 + 0.5);
242  }
243 
244  if(p_grayBuffer && !p_grayBuffer->enabled()) {
245  p_grayBuffer->enable(true);
246 
247  // gives a proper initial stretch (entire cube)
249  }
250 
251  QAbstractScrollArea::show();
252 
253  p_paintPixmap = true;
254 
255  paintPixmap();
256  }
257 
258 
264  double progress = 0.0;
265  bool completed = false;
266 
267  if(p_grayBuffer) {
268  progress += p_grayBuffer->currentProgress();
269  completed = !p_grayBuffer->working();
270  }
271 
272  if(p_redBuffer) {
273  progress += p_redBuffer->currentProgress() / 3.0;
274  completed = !p_redBuffer->working();
275  }
276 
277  if(p_greenBuffer) {
278  progress += p_greenBuffer->currentProgress() / 3.0;
279  completed = completed && !p_greenBuffer->working();
280  }
281 
282  if(p_blueBuffer) {
283  progress += p_blueBuffer->currentProgress() / 3.0;
284  completed = completed && !p_blueBuffer->working();
285  }
286 
287  int realProgress = (int)(progress * 100.0);
288 
289  if(completed) {
290  realProgress = 100;
291  p_progressTimer->stop();
292  emit progressComplete();
293  emit screenPixelsChanged();
294  }
295  else if(realProgress == 100) {
296  realProgress = 99;
297  }
298 
299  emit progressChanged(realProgress);
300  }
301 
302 
308  if(p_redBrick) {
309  delete p_redBrick;
310  p_redBrick = NULL;
311  }
312 
313  if(p_grnBrick) {
314  delete p_grnBrick;
315  p_grnBrick = NULL;
316  }
317 
318  if(p_bluBrick) {
319  delete p_bluBrick;
320  p_bluBrick = NULL;
321  }
322 
323  if(p_gryBrick) {
324  delete p_gryBrick;
325  p_gryBrick = NULL;
326  }
327 
328  if(p_pntBrick) {
329  delete p_pntBrick;
330  p_pntBrick = NULL;
331  }
332 
333  if(p_groundMap) {
334  delete p_groundMap;
335  p_groundMap = NULL;
336  }
337 
338  if(p_grayBuffer) {
339  delete p_grayBuffer;
340  p_grayBuffer = NULL;
341  }
342 
343  if(p_redBuffer) {
344  delete p_redBuffer;
345  p_redBuffer = NULL;
346  }
347 
348  if(p_greenBuffer) {
349  delete p_greenBuffer;
350  p_greenBuffer = NULL;
351  }
352 
353  if(p_blueBuffer) {
354  delete p_blueBuffer;
355  p_blueBuffer = NULL;
356  }
357 
358  // p_cubeData MUST be deleted AFTER all viewport buffers!!!
359  if(p_cubeData) {
361 
363  delete p_cubeData;
364 
365  p_cubeData = NULL;
366  }
367 
368  p_cube = NULL;
369 
370  delete p_trackingCube;
371  p_trackingCube = NULL;
372 
373  if(p_progressTimer) {
374  delete p_progressTimer;
375  p_progressTimer = NULL;
376  }
377 
378  if(p_image) {
379  delete p_image;
380  p_image = NULL;
381  }
382 
383  if(p_pixmapPaintRects) {
384  for(int rect = 0; rect < p_pixmapPaintRects->size(); rect++) {
385  delete(*p_pixmapPaintRects)[rect];
386  }
387 
388  delete p_pixmapPaintRects;
389  p_pixmapPaintRects = NULL;
390  }
391 
392  if(p_knownStretches) {
393  for(int stretch = 0; stretch < p_knownStretches->size(); stretch ++) {
394  if((*p_knownStretches)[stretch] != NULL) {
395  delete(*p_knownStretches)[stretch];
396  (*p_knownStretches)[stretch] = NULL;
397  }
398  }
399 
400  p_knownStretches->clear();
401 
402  delete p_knownStretches;
403  p_knownStretches = NULL;
404  }
405 
406  if(p_globalStretches) {
407  for(int stretch = 0; stretch < p_globalStretches->size(); stretch ++) {
408  if((*p_globalStretches)[stretch] != NULL) {
409  delete(*p_globalStretches)[stretch];
410  (*p_globalStretches)[stretch] = NULL;
411  }
412  }
413 
414  p_globalStretches->clear();
415 
416  delete p_globalStretches;
417  p_globalStretches = NULL;
418  }
419  }
420 
427  p_cube = cube;
428  setCaption();
429  }
430 
431 
434  return p_cube->sampleCount();
435  }
436 
437 
440  return p_cube->lineCount();
441  }
442 
443 
446  return p_cube->bandCount();
447  }
448 
449 
457  void CubeViewport::cubeDataChanged(int cubeId, const Brick *data) {
458  if(cubeId == p_cubeId) {
459  double ss, sl, es, el;
460  ss = data->Sample();
461  sl = data->Line();
462  es = data->Sample() + data->SampleDimension();
463  el = data->Line() + data->LineDimension();
464  if(ss < 0.5){
465  ss = 0.5;
466  }
467  if(sl < 0.5){
468  sl = 0.5;
469  }
470  if(es > cube()->sampleCount() + 0.5){
471  es = cube()->sampleCount() + 0.5;
472  }
473  if(el > cube()->lineCount() + 0.5){
474  el = cube()->lineCount() + 0.5;
475  }
476 
477  int sx, sy, ex, ey;
478 
479  cubeToViewport(ss, sl, sx, sy);
480  cubeToViewport(es, el, ex, ey);
481  if(sx < 0){
482  sx = 0;
483  }
484  if(sy < 0){
485  sy = 0;
486  }
487  if(ex > viewport()->width()){
488  ex = viewport()->width();
489  }
490  if(ey > viewport()->height()){
491  ey = viewport()->height();
492  }
493  QRect vpRect(sx, sy, ex - sx + 1, ey - sy + 1);
494 
495  p_updatingBuffers = true;
496  if(p_grayBuffer){
497  p_grayBuffer->fillBuffer(vpRect, data);
498  }
499  if(p_redBuffer){
500  p_redBuffer->fillBuffer(vpRect, data);
501  }
502  if(p_greenBuffer){
503  p_greenBuffer->fillBuffer(vpRect, data);
504  }
505  if(p_blueBuffer){
506  p_blueBuffer->fillBuffer(vpRect, data);
507  }
508  p_updatingBuffers = false;
509 
511  }
512 
513  emit doneWithData(cubeId, data);
514  }
515 
516 
526  bool canClose = true;
527  if(p_saveEnabled) {
528  // Enter == button 0, Escape == button 2
529  switch(QMessageBox::information(this, tr("Confirm Save"),
530  tr("The cube [<font color='red'>%1</font>] contains unsaved changes. "
531  "Do you want to save the changes before exiting?").arg(cube()->fileName()),
532  QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel)) {
533  //Save changes and close viewport
534  case QMessageBox::Save:
535  emit saveChanges(this);
536  break;
537 
538  //Discard changes and close viewport
539  case QMessageBox::Discard:
540  emit discardChanges(this);
541  break;
542 
543  //Cancel, don't close viewport
544  case QMessageBox::Cancel:
545  default:
546  canClose = false;
547  break;
548  }
549  }
550 
551 // if (canClose) emit viewportClosed(this);
552  return canClose;
553  }
554 
561  void CubeViewport::cubeChanged(bool changed) {
562  p_saveEnabled = changed;
563  }
564 
571  QSize CubeViewport::sizeHint() const {
572  QSize s(512, 512);
573  return s;
574  }
575 
576 
588  void CubeViewport::setScale(double scale) {
589  // Sanitize the scale value
590  if (scale == p_scale){
591  return;
592  }
593 
594  if (viewport()->width() && viewport()->height()) {
595  // don't let zoom scale be larger than the viewport size
596  double maxScale = max(viewport()->width(),viewport()->height());
597  if (scale > maxScale) {
598  scale = maxScale;
599  }
600  // don't let zoom scale be smaller than one pixel high/wide showing
601  double minScale = 1.0 / (min(cubeSamples(),cubeLines()));
602  if (scale < minScale) {
603  scale = minScale;
604  }
605  }
606 
607  // Resize the scrollbars to reflect the new scale
608  double samp, line;
609  contentsToCube(horizontalScrollBar()->value(), verticalScrollBar()->value(),
610  samp, line);
611  p_scale = scale;
612  updateScrollBars(1, 1); // Setting to 1,1 make sure we don't have bad values
613 
614  // Now update the scroll bar value to the old line/sample
615  int x, y;
616  cubeToContents(samp, line, x, y);
617  updateScrollBars(x, y);
618 
619  p_updatingBuffers = true;
620  if (p_grayBuffer){
622  }
623  if (p_redBuffer){
625  }
626  if (p_greenBuffer){
628  }
629  if (p_blueBuffer){
631  }
632  p_updatingBuffers = false;
633 
635 
636  // Notify other tools about the scale change
637  emit scaleChanged();
638 
639  // Update the display
640  setCaption();
641  paintPixmap(); // Will get rid of old data in the display
642 
643  viewport()->repaint();
644  emit screenPixelsChanged();
645  }
646 
655  void CubeViewport::setScale(double scale, int x, int y) {
656  double samp, line;
657  viewportToCube(x, y, samp, line);
658  setScale(scale, samp, line);
659  }
660 
661 
671  void CubeViewport::setScale(double scale, double sample, double line) {
672  viewport()->setUpdatesEnabled(false);
673 
674  bool wasEnabled = false;
675 
676  if ((p_grayBuffer && p_grayBuffer->enabled()) ||
677  (p_redBuffer && p_redBuffer->enabled())) {
678  wasEnabled = true;
679  }
680 
681  if (p_grayBuffer){
682  p_grayBuffer->enable(false);
683  }
684  if (p_redBuffer){
685  p_redBuffer->enable(false);
686  }
687  if (p_greenBuffer){
688  p_greenBuffer->enable(false);
689  }
690  if (p_blueBuffer){
691  p_blueBuffer->enable(false);
692  }
693  if (p_paintPixmap) {
694  p_paintPixmap = false;
695  setScale(scale);
696  p_paintPixmap = true;
697  }
698  else {
699  setScale(scale);
700  }
701  center(sample, line);
702 
703  if (p_grayBuffer){
704  p_grayBuffer->enable(wasEnabled);
705  }
706  if (p_redBuffer){
707  p_redBuffer->enable(wasEnabled);
708  }
709  if (p_greenBuffer){
710  p_greenBuffer->enable(wasEnabled);
711  }
712  if (p_blueBuffer){
713  p_blueBuffer->enable(wasEnabled);
714  }
715 
716  paintPixmap();
717  viewport()->setUpdatesEnabled(true);
718  viewport()->update();
719  emit screenPixelsChanged();
720  }
721 
722 
730  void CubeViewport::center(int x, int y) {
731  double sample, line;
732  viewportToCube(x, y, sample, line);
733  center(sample, line);
734  }
735 
736 
743  void CubeViewport::center(double sample, double line) {
744  int x, y;
745  cubeToContents(sample, line, x, y);
746 
747  int panX = horizontalScrollBar()->value() - x;
748  int panY = verticalScrollBar()->value() - y;
749 
750  updateScrollBars(x, y);
751 
752  p_updatingBuffers = true;
753  if(p_grayBuffer){
754  p_grayBuffer->pan(panX, panY);
755  }
756  if(p_redBuffer){
757  p_redBuffer->pan(panX, panY);
758  }
759  if(p_greenBuffer){
760  p_greenBuffer->pan(panX, panY);
761  }
762  if(p_blueBuffer){
763  p_blueBuffer->pan(panX, panY);
764  }
765  p_updatingBuffers = false;
766 
768 
769  shiftPixmap(panX, panY);
770 
771  emit screenPixelsChanged();
772  }
773 
774 
780  for(int rect = 0; rect < p_pixmapPaintRects->size(); rect++) {
781  paintPixmap(*(*p_pixmapPaintRects)[rect]);
782  }
783 
784  p_pixmapPaintRects->clear();
785  }
786 
787 
798  void CubeViewport::contentsToCube(int x, int y,
799  double &sample, double &line) const {
800  sample = x / p_scale;
801  line = y / p_scale;
802  }
803 
804 
815  void CubeViewport::viewportToCube(int x, int y,
816  double &sample, double &line) const {
817  x += horizontalScrollBar()->value();
818  x -= viewport()->width() / 2;
819  y += verticalScrollBar()->value();
820  y -= viewport()->height() / 2;
821  contentsToCube(x, y, sample, line);
822  }
823 
824 
835  void CubeViewport::cubeToContents(double sample, double line,
836  int &x, int &y) const {
837  x = (int)(sample * p_scale + 0.5);
838  y = (int)(line * p_scale + 0.5);
839  }
840 
841 
852  void CubeViewport::cubeToViewport(double sample, double line,
853  int &x, int &y) const {
854  cubeToContents(sample, line, x, y);
855  x -= horizontalScrollBar()->value();
856  x += viewport()->width() / 2;
857  y -= verticalScrollBar()->value();
858  y += viewport()->height() / 2;
859  }
860 
861 
869  void CubeViewport::scrollBy(int dx, int dy) {
870  // Make sure we don't generate bad values outside of the scroll range
871  int x = horizontalScrollBar()->value() + dx;
872  if(x <= 1) {
873  dx = 1 - horizontalScrollBar()->value();
874  }
875  else if(x >= horizontalScrollBar()->maximum()) {
876  dx = horizontalScrollBar()->maximum() - horizontalScrollBar()->value();
877  }
878 
879  // Make sure we don't generate bad values outside of the scroll range
880  int y = verticalScrollBar()->value() + dy;
881  if(y <= 1) {
882  dy = 1 - verticalScrollBar()->value();
883  }
884  else if(y >= verticalScrollBar()->maximum()) {
885  dy = verticalScrollBar()->maximum() - verticalScrollBar()->value();
886  }
887 
888  // Do we do anything?
889  if((dx == 0) && (dy == 0)){
890  return;
891  }
892 
893  // We do so update the scroll bars
894  updateScrollBars(horizontalScrollBar()->value() + dx,
895  verticalScrollBar()->value() + dy);
896 
897  // Scroll the the pixmap
898  scrollContentsBy(-dx, -dy);
899  }
900 
901 
909  void CubeViewport::scrollContentsBy(int dx, int dy) {
910 
911  // We shouldn't do anything if scrollbars are being updated
912  if(viewport()->signalsBlocked()) {
913  return;
914  }
915 
916  // Tell the buffers to update appropriate for the pan and upon completion
917  // they will call bufferUpdated. We don't want bufferUpdated to happen
918  // until afterwards. If only shrinking and no new data then the viewport
919  // buffers will complete immediately. When all buffers don't have their
920  // appropriate actions queued bufferUpdated can't succeed.
921 
922  // Also block paints because we'll repaint it all when we're done
923  // telling each buffer about the pan.
924  bool panQueued = false;
925  QRect bufferXYRect;
926 
927  p_updatingBuffers = true;
928 
929  if(p_grayBuffer) {
930  p_grayBuffer->pan(dx, dy);
931  panQueued |= p_grayBuffer->working();
932  bufferXYRect = p_grayBuffer->bufferXYRect();
933  }
934 
935  if(p_redBuffer) {
936  p_redBuffer->pan(dx, dy);
937  panQueued |= p_redBuffer->working();
938  bufferXYRect = p_redBuffer->bufferXYRect();
939  }
940 
941  if(p_greenBuffer) {
942  p_greenBuffer->pan(dx, dy);
943  panQueued |= p_greenBuffer->working();
944  }
945 
946  if(p_blueBuffer) {
947  p_blueBuffer->pan(dx, dy);
948  panQueued |= p_blueBuffer->working();
949  }
950 
951  p_updatingBuffers = false;
952 
953  // shift the pixmap by x,y if the viewport buffer didn't do it immediately
954  if(panQueued) {
955  shiftPixmap(dx, dy);
956  }
957  else {
958  // Need to do this to clear area outside of cube
959  p_pixmapPaintRects->clear();
960  paintPixmap();
961  }
962 
963  viewport()->update();
964  emit screenPixelsChanged();
965  }
966 
967 
973  if(!p_progressTimer->isActive()) {
974  p_progressTimer->start();
975 
976  emit progressChanged(0);
977  }
978  }
979 
980 
986  QString cubeFileName = p_cube->fileName();
987  QString str = QFileInfo(cubeFileName).fileName();
988  str += QString(" @ ");
989  str += QString::number(p_scale * 100.0);
990  str += QString("% ");
991 
992  if(p_color) {
993  str += QString("(RGB = ");
994  str += QString::number(p_red.band);
995  str += QString(",");
996  str += QString::number(p_green.band);
997  str += QString(",");
998  str += QString::number(p_blue.band);
999  str += QString(")");
1000  }
1001  else {
1002  str += QString("(Gray = ");
1003  str += QString::number(p_gray.band);
1004  str += QString(")");
1005  }
1006 
1007  //If changes have been made make sure to add '*' to the end
1008  if(p_saveEnabled) {
1009  str += "*";
1010  }
1011 
1012  parentWidget()->setWindowTitle(str);
1013  emit windowTitleChanged();
1014  }
1015 
1016 
1023  void CubeViewport::resizeEvent(QResizeEvent *e) {
1024  p_paintPixmap = false;
1025 
1026  // Tell the buffers to update their coefficients to reinitialize
1027  // and have their immediate paint events happen afterwards. Should not
1028  // happen, but if buffers have actions complete immediately and call
1029  // bufferUpdated. We don't want to have bufferUpdated ever when all
1030  // buffers don't have their appropriate actions queued. It can't succeed.
1031  p_updatingBuffers = true;
1032  if(p_grayBuffer){
1034  }
1035  if(p_redBuffer){
1037  }
1038  if(p_greenBuffer){
1040  }
1041  if(p_blueBuffer){
1043  }
1044  p_updatingBuffers = false;
1045 
1046  paintPixmapRects();
1047 
1048  // Change the size of the image and pixmap
1049  if(p_image) {
1050  delete p_image;
1051  p_image = NULL;
1052  }
1053 
1054  p_image = new QImage(viewport()->size(), QImage::Format_RGB32);
1055  p_pixmap = QPixmap(viewport()->size());
1056 
1057  p_paintPixmap = true;
1058 
1059  // Fixup the scroll bars
1060  updateScrollBars(horizontalScrollBar()->value(),
1061  verticalScrollBar()->value());
1062 
1064  "<p><b>Viewport Dimensions:</b> \
1065  <blockQuote>Samples = " +
1066  QString::number(viewport()->width()) + "<br>" +
1067  "Lines = " +
1068  QString::number(viewport()->height()) + "</blockquote></p>";
1069 
1070  // Repaint the pixmap
1071  paintPixmap();
1072 
1073  // Repaint the internal viewport and scroll bars
1074  viewport()->update();
1075  emit screenPixelsChanged();
1076  }
1077 
1078 
1089  void CubeViewport::paintEvent(QPaintEvent *e) {
1090  if(!p_cubeShown || !viewport()->isVisible()){
1091  return;
1092  }
1093  }
1094 
1095 
1104  void CubeViewport::bufferUpdated(QRect rect) {
1105  paintPixmap(rect);
1106 
1107  // Don't repaint from buffer updates if any buffers are working...
1108  // This set of statements fixes a flash of black when in RGB mode
1109  // and a pan (or other operation?) completes. What would happen is
1110  // the first would reset to black then other buffers still working so
1111  // not restored to DN values.
1112  if(p_grayBuffer && p_grayBuffer->working()){
1113  return;
1114  }
1115  if(p_redBuffer && p_redBuffer->working()){
1116  return;
1117  }
1119  return;
1120  }
1121  if(p_blueBuffer && p_blueBuffer->working()){
1122  return;
1123  }
1124 
1125  viewport()->repaint(rect);
1126  }
1127 
1130  QRect rect(0, 0, p_image->width(), p_image->height());
1131  paintPixmap(rect);
1132  }
1133 
1134 
1141  void CubeViewport::paintPixmap(QRect rect) {
1142  if(!p_paintPixmap) {
1143  return;
1144  }
1145 
1146  if(p_updatingBuffers) {
1147  p_pixmapPaintRects->push_back(new QRect(rect));
1148  return;
1149  }
1150 
1151  if(p_pixmap.isNull()){
1152  return;
1153  }
1154 
1155  QPainter p(&p_pixmap);
1156 
1157  p.fillRect(rect, QBrush(p_bgColor));
1158 
1159  QRect dataArea;
1160 
1161  if(p_grayBuffer && p_grayBuffer->enabled()) {
1162  if(p_grayBuffer->working()){
1163  return;
1164  }
1165 
1166  dataArea = QRect(p_grayBuffer->bufferXYRect().intersected(rect));
1167 
1168  for(int y = dataArea.top();
1169  !dataArea.isNull() && y <= dataArea.bottom();
1170  y++) {
1171  const vector< double > & line =
1173 
1174  if(line.size() == 0) {
1175  break;
1176  }
1177 
1178  if(y >= p_image->height()) {
1179  throw IException(IException::Programmer, "y too big", _FILEINFO_);
1180  }
1181 
1182  QRgb *rgb = (QRgb *) p_image->scanLine(y);
1183 
1187 
1188  for(int x = dataArea.left(); x <= dataArea.right(); x++) {
1189  int bufferLeft = p_grayBuffer->bufferXYRect().left();
1190  int bufferX = x - bufferLeft;
1191 
1192  if(bufferX >= (int)line.size()){
1193  break;
1194  }
1195 
1196  if(bufferX < 0) {
1197  throw IException(IException::Programmer, "bufferX < 0", _FILEINFO_);
1198  }
1199 
1200  if(x >= p_image->width()) {
1201  throw IException(IException::Programmer, "x too big", _FILEINFO_);
1202  }
1203 
1204  double bufferVal = line.at(bufferX);
1205 
1206  // This is still RGB; the pairs are identical but the boundary
1207  // conditions are different. Display saturations cause this.
1208  int redPix = (int)(redStretch.Map(bufferVal) + 0.5);
1209  int greenPix = (int)(greenStretch.Map(bufferVal) + 0.5);
1210  int bluePix = (int)(blueStretch.Map(bufferVal) + 0.5);
1211  rgb[x] = qRgb(redPix, greenPix, bluePix);
1212  }
1213  }
1214  }
1215  else {
1216  if(p_redBuffer && p_redBuffer->enabled()) {
1217  if(p_redBuffer->working() || p_greenBuffer->working() ||
1218  p_blueBuffer->working()) {
1219  return;
1220  }
1221 
1222 
1223  if((p_greenBuffer->bufferXYRect().top() !=
1224  p_redBuffer->bufferXYRect().top()) ||
1225  (p_greenBuffer->bufferXYRect().top() !=
1226  p_blueBuffer->bufferXYRect().top())) {
1228  "Buffer rects mismatched",
1229  _FILEINFO_);
1230  }
1231 
1232  if((p_greenBuffer->bufferXYRect().left() !=
1233  p_redBuffer->bufferXYRect().left()) ||
1234  (p_greenBuffer->bufferXYRect().left() !=
1235  p_blueBuffer->bufferXYRect().left())) {
1237  "Buffer rects mismatched",
1238  _FILEINFO_);
1239  }
1240 
1241  dataArea = QRect(p_redBuffer->bufferXYRect().intersected(rect));
1242 
1243  for(int y = dataArea.top();
1244  !dataArea.isNull() && y <= dataArea.bottom();
1245  y++) {
1246  int bufferLine = y - p_redBuffer->bufferXYRect().top();
1247 
1248  const vector<double> &redLine = p_redBuffer->getLine(bufferLine);
1249  const vector<double> &greenLine = p_greenBuffer->getLine(bufferLine);
1250  const vector<double> &blueLine = p_blueBuffer->getLine(bufferLine);
1251 
1252  if((int)redLine.size() < dataArea.width() ||
1253  (int)greenLine.size() < dataArea.width() ||
1254  (int)blueLine.size() < dataArea.width()) {
1256  "Empty buffer line",
1257  _FILEINFO_);
1258  }
1259 
1260  QRgb *rgb = (QRgb *) p_image->scanLine(y);
1261 
1265 
1266  for(int x = dataArea.left(); x <= dataArea.right(); x++) {
1267  int redPix = (int)(redStretch.Map(redLine[ x - p_redBuffer->bufferXYRect().left()]) + 0.5);
1268  int greenPix = (int)(greenStretch.Map(greenLine[ x - p_greenBuffer->bufferXYRect().left()]) + 0.5);
1269  int bluePix = (int)(blueStretch.Map(blueLine[ x - p_blueBuffer->bufferXYRect().left()]) + 0.5);
1270 
1271  rgb[x] = qRgb(redPix, greenPix, bluePix);
1272  }
1273  }
1274  }
1275  }
1276 
1277  if(!dataArea.isNull()){
1278  p.drawImage(dataArea.topLeft(), *p_image, dataArea);
1279  }
1280 
1281  // Change whats this info
1282  updateWhatsThis();
1283  }
1284 
1285 
1292  void CubeViewport::shiftPixmap(int dx, int dy) {
1293  if(!p_paintPixmap || !p_pixmap){
1294  return;
1295  }
1296 
1297  // Prep to scroll the pixmap
1298  int drawStartX = dx;
1299  int pixmapStartX = 0;
1300  if(drawStartX < 0) {
1301  drawStartX = 0;
1302  pixmapStartX = -dx;
1303  }
1304 
1305  int drawStartY = dy;
1306  int pixmapStartY = 0;
1307  if(dy < 0) {
1308  drawStartY = 0;
1309  pixmapStartY = -dy;
1310  }
1311 
1312  // Ok we can shift the pixmap and filling
1313  int pixmapDrawWidth = p_pixmap.width() - pixmapStartX + 1;
1314  int pixmapDrawHeight = p_pixmap.height() - pixmapStartY + 1;
1315 
1316  QRect rect(0, 0, p_pixmap.width(), p_pixmap.height());
1317  QPixmap pixmapCopy = p_pixmap.copy();
1318 
1319  QPainter painter(&p_pixmap);
1320  painter.fillRect(rect, QBrush(p_bgColor));
1321  painter.drawPixmap(drawStartX, drawStartY,
1322  pixmapCopy,
1323  pixmapStartX, pixmapStartY,
1324  pixmapDrawWidth, pixmapDrawHeight);
1325  painter.end();
1326 
1327  // Now fill in the left or right side
1328  QRect xFillRect;
1329  QRect yFillRect;
1330 
1331  if(dx > 0) {
1332  xFillRect = QRect(QPoint(0, 0),
1333  QPoint(dx, p_pixmap.height()));
1334  }
1335  else {
1336  if(dx < 0){
1337  xFillRect = QRect(QPoint(p_pixmap.width() + dx, 0),
1338  QPoint(p_pixmap.width(), p_pixmap.height()));
1339  }
1340  }
1341 
1342  // Fill in the top or bottom side
1343  if(dy > 0) {
1344  yFillRect = QRect(QPoint(0, 0),
1345  QPoint(p_pixmap.width(), dy));
1346  }
1347  else {
1348  if(dy < 0){
1349  yFillRect = QRect(QPoint(0, p_pixmap.height() + dy),
1350  QPoint(p_pixmap.width(), p_pixmap.height()));
1351  }
1352  }
1353 
1354  if(dx != 0) {
1355  paintPixmap(xFillRect);
1356  }
1357 
1358  if(dy != 0) {
1359  paintPixmap(yFillRect);
1360  }
1361 
1362  viewport()->update();
1363  }
1364 
1373  {
1374  // Get Cube Info
1375  PvlObject whatsThisObj = PvlObject("WhatsThis");
1376  whatsThisObj += PvlKeyword("Cube", p_cube->fileName());
1377 
1378  PvlGroup cubeGrp("CubeDimensions");
1379  cubeGrp += PvlKeyword("Samples", toString(p_cube->sampleCount()));
1380  cubeGrp += PvlKeyword("Lines", toString(p_cube->lineCount()));
1381  cubeGrp += PvlKeyword("Bands", toString(p_cube->bandCount()));
1382  whatsThisObj += cubeGrp;
1383 
1384  // Get Viewport Info
1385  PvlGroup viewportGrp("ViewportDimensions");
1386  viewportGrp += PvlKeyword("Samples", toString(viewport()->width()));
1387  viewportGrp += PvlKeyword("Lines", toString(viewport()->height()));
1388  whatsThisObj += viewportGrp;
1389 
1390  // Get Cube area Info
1391  PvlObject cubeAreaPvl("CubeArea");
1392  PvlGroup bandGrp("Bands");
1393 
1394  PvlKeyword filterName;
1395  getBandFilterName(filterName);
1396  int iFilterSize = filterName.size();
1397 
1398  // color
1399  if(p_color ) {
1400  PvlKeyword virtualKey("Virtual"), physicalKey("Physical"), filterNameKey;
1401  int iRedBand = p_redBuffer->getBand();
1402  int iGreenBand = p_greenBuffer->getBand();
1403  int iBlueBand = p_blueBuffer->getBand();
1404 
1405  bandGrp += PvlKeyword("Color", "RGB");
1406 
1407  virtualKey = toString(iRedBand);
1408  virtualKey += toString(iGreenBand);
1409  virtualKey += toString(iBlueBand);
1410  bandGrp += virtualKey;
1411 
1412  physicalKey = toString(p_cube->physicalBand(iRedBand));
1413  physicalKey += toString(p_cube->physicalBand(iGreenBand));
1414  physicalKey += toString(p_cube->physicalBand(iBlueBand));
1415  bandGrp += physicalKey;
1416 
1417  if(iFilterSize) {
1418  if(iRedBand <= iFilterSize) {
1419  filterNameKey += filterName[iRedBand-1];
1420  }
1421  else {
1422  filterNameKey += "None";
1423  }
1424 
1425  if(iGreenBand <= iFilterSize) {
1426  filterNameKey += filterName[iGreenBand-1];
1427  }
1428  else {
1429  filterNameKey += "None";
1430  }
1431 
1432  if(iBlueBand <= iFilterSize) {
1433  filterNameKey += filterName[iBlueBand-1];
1434  }
1435  else {
1436  filterNameKey += "None";
1437  }
1438  bandGrp += filterNameKey;
1439  }
1440  }
1441  else { // gray
1442  int iGrayBand = p_grayBuffer->getBand();
1443 
1444  bandGrp += PvlKeyword("Color", "Gray");
1445 
1446  bandGrp += PvlKeyword("Virtual", toString(iGrayBand));
1447  bandGrp += PvlKeyword("Physical", toString(p_cube->physicalBand(iGrayBand)));
1448 
1449  if(iFilterSize && iGrayBand <= iFilterSize) {
1450  bandGrp += PvlKeyword("FilterName", filterName[iGrayBand-1]);
1451  }
1452  }
1453 
1454  //start, end line and sample
1455  double sl, ss, es, el;
1456  getCubeArea(ss, es, sl, el);
1457  cubeAreaPvl += PvlKeyword("StartSample", toString(int(ss + 0.5)));
1458  cubeAreaPvl += PvlKeyword("EndSample", toString(int(es + 0.5)));
1459  cubeAreaPvl += PvlKeyword("StartLine", toString(int(sl + 0.5)));
1460  cubeAreaPvl += PvlKeyword("EndLine", toString(int(el + 0.5)));
1461  cubeAreaPvl += bandGrp;
1462  whatsThisObj += cubeAreaPvl;
1463  pWhatsThisPvl += whatsThisObj;
1464  }
1465 
1475  {
1476  // get the band info
1477  Pvl* cubeLbl = p_cube->label();
1478  PvlObject isisObj = cubeLbl->findObject("IsisCube");
1479  if (isisObj.hasGroup("BandBin")) {
1480  PvlGroup bandBinGrp = isisObj.findGroup("BandBin");
1481  if(bandBinGrp.hasKeyword("FilterName")) {
1482  pFilterNameKey =bandBinGrp.findKeyword("FilterName") ;
1483  }
1484  }
1485  }
1486 
1495  void CubeViewport::getCubeArea(double & pdStartSample, double & pdEndSample,
1496  double & pdStartLine, double & pdEndLine)
1497  {
1498  viewportToCube(0, 0, pdStartSample, pdStartLine);
1499  if(pdStartSample < 1.0){
1500  pdStartSample = 1.0;
1501  }
1502  if(pdStartLine < 1.0){
1503  pdStartLine = 1.0;
1504  }
1505 
1506  //end line and samples
1507  viewportToCube(viewport()->width() - 1, viewport()->height() - 1, pdEndSample, pdEndLine);
1508  if(pdEndSample > cubeSamples()){
1509  pdEndSample = cubeSamples();
1510  }
1511  if(pdEndLine > cubeLines()){
1512  pdEndLine = cubeLines();
1513  }
1514  }
1515 
1521  //start, end line and sample
1522  double sl, ss, es, el;
1523  getCubeArea(ss, es, sl, el);
1524 
1525  QString sBandInfo ;
1526  PvlKeyword filterNameKey;
1527  getBandFilterName(filterNameKey);
1528  int iFilterSize = filterNameKey.size();
1529 
1530  // color
1531  if(p_color ) {
1532  int iRedBand = p_redBuffer->getBand();
1533  int iGreenBand = p_greenBuffer->getBand();
1534  int iBlueBand = p_blueBuffer->getBand();
1535 
1536  sBandInfo = "Bands(RGB)&nbsp;Virtual = " +
1537  QString::number(iRedBand) + ", ";
1538  sBandInfo += QString::number(iGreenBand) + ", ";
1539  sBandInfo += QString::number(iBlueBand) + " ";
1540 
1541  sBandInfo += "Physical = " +
1542  QString::number(p_cube->physicalBand(iRedBand)) + ", ";
1543  sBandInfo += QString::number(p_cube->physicalBand(iGreenBand)) + ", ";
1544  sBandInfo += QString::number(p_cube->physicalBand(iBlueBand));
1545 
1546  if(iFilterSize) {
1547  sBandInfo += "<br>FilterName = ";
1548  if(iRedBand <= iFilterSize) {
1549  sBandInfo += QString(filterNameKey[iRedBand-1]);
1550  }
1551  else {
1552  sBandInfo += "None";
1553  }
1554  sBandInfo += ", ";
1555 
1556  if(iGreenBand <= iFilterSize) {
1557  sBandInfo += QString(filterNameKey[iGreenBand-1]);
1558  }
1559  else {
1560  sBandInfo += "None";
1561  }
1562  sBandInfo += ", ";
1563 
1564  if(iBlueBand <= iFilterSize) {
1565  sBandInfo += QString(filterNameKey[iBlueBand-1]);
1566  }
1567  else {
1568  sBandInfo += "None";
1569  }
1570  }
1571  }
1572  else { // gray
1573  int iGrayBand = p_grayBuffer->getBand();
1574 
1575  sBandInfo = "Band(Gray)&nbsp;Virtual = " + QString::number(iGrayBand) + " ";
1576 
1577  sBandInfo += "Physical = " + QString::number(p_cube->physicalBand(iGrayBand));
1578 
1579  if(iFilterSize && iGrayBand <= iFilterSize) {
1580  sBandInfo += "<br>FilterName = " + QString(filterNameKey[iGrayBand-1]);
1581  }
1582  }
1583 
1584  QString area =
1585  "<p><b>Visible Cube Area:</b><blockQuote> \
1586  Samples = " + QString::number(int(ss + 0.5)) + "-" +
1587  QString::number(int(es + 0.5)) + "<br> \
1588  Lines = " + QString::number(int(sl + 0.5)) + "-" +
1589  QString::number(int(el + 0.5)) + "<br> " +
1590  sBandInfo + "</blockQuote></p>";
1591 
1592  QString fullWhatsThis = p_whatsThisText + area + p_cubeWhatsThisText + p_viewportWhatsThisText;
1593  setWhatsThis(fullWhatsThis);
1594  viewport()->setWhatsThis(fullWhatsThis);
1595  }
1596 
1606  double CubeViewport::redPixel(int sample, int line) {
1607  p_pntBrick->SetBasePosition(sample, line, p_red.band);
1608  p_cube->read(*p_pntBrick);
1609  return (*p_pntBrick)[0];
1610  }
1611 
1612 
1622  double CubeViewport::greenPixel(int sample, int line) {
1623  p_pntBrick->SetBasePosition(sample, line, p_green.band);
1624  p_cube->read(*p_pntBrick);
1625  return (*p_pntBrick)[0];
1626  }
1627 
1628 
1638  double CubeViewport::bluePixel(int sample, int line) {
1639  p_pntBrick->SetBasePosition(sample, line, p_blue.band);
1640  p_cube->read(*p_pntBrick);
1641  return (*p_pntBrick)[0];
1642  }
1643 
1644 
1654  double CubeViewport::grayPixel(int sample, int line) {
1655  p_pntBrick->SetBasePosition(sample, line, p_gray.band);
1656  p_cube->read(*p_pntBrick);
1657  return (*p_pntBrick)[0];
1658  }
1659 
1660 
1663  return p_gray.getStretch();
1664  }
1665 
1666 
1669  return p_red.getStretch();
1670  };
1671 
1672 
1675  return p_green.getStretch();
1676  };
1677 
1678 
1681  return p_blue.getStretch();
1682  };
1683 
1684 
1694  bool CubeViewport::eventFilter(QObject *o, QEvent *e) {
1695  // Handle standard mouse tracking on the viewport
1696  if(o == viewport()) {
1697  switch(e->type()) {
1698  case QEvent::Enter: {
1699  viewport()->setMouseTracking(true);
1700  emit mouseEnter();
1701  return true;
1702  }
1703 
1704  case QEvent::MouseMove: {
1705  QMouseEvent *m = (QMouseEvent *) e;
1706  emit mouseMove(m->pos());
1707  emit mouseMove(m->pos(), (Qt::MouseButton)(m->button() +
1708  m->modifiers()));
1709  return true;
1710  }
1711 
1712  case QEvent::Leave: {
1713  viewport()->setMouseTracking(false);
1714  emit mouseLeave();
1715  return true;
1716  }
1717 
1718  case QEvent::MouseButtonPress: {
1719  QMouseEvent *m = (QMouseEvent *) e;
1720  emit mouseButtonPress(m->pos(),
1721  (Qt::MouseButton)(m->button() + m->modifiers()));
1722  return true;
1723  }
1724 
1725  case QEvent::MouseButtonRelease: {
1726  QMouseEvent *m = (QMouseEvent *) e;
1727  emit mouseButtonRelease(m->pos(),
1728  (Qt::MouseButton)(m->button() + m->modifiers()));
1729  return true;
1730  }
1731 
1732  case QEvent::MouseButtonDblClick: {
1733  QMouseEvent *m = (QMouseEvent *) e;
1734  emit mouseDoubleClick(m->pos());
1735  return true;
1736  }
1737 
1738  default: {
1739  return false;
1740  }
1741  }
1742  }
1743  else {
1744  return QAbstractScrollArea::eventFilter(o, e);
1745  }
1746  }
1747 
1748 
1759  void CubeViewport::keyPressEvent(QKeyEvent *e) {
1760  if(e->key() == Qt::Key_Plus) {
1761  double scale = p_scale * 2.0;
1762  setScale(scale);
1763  e->accept();
1764  }
1765  else if(e->key() == Qt::Key_Minus) {
1766  double scale = p_scale / 2.0;
1767  setScale(scale);
1768  e->accept();
1769  }
1770  else if(e->key() == Qt::Key_Up) {
1771  moveCursor(0, -1);
1772  e->accept();
1773  }
1774  else if(e->key() == Qt::Key_Down) {
1775  moveCursor(0, 1);
1776  e->accept();
1777  }
1778  else if(e->key() == Qt::Key_Left) {
1779  moveCursor(-1, 0);
1780  e->accept();
1781  }
1782  else if(e->key() == Qt::Key_Right) {
1783  moveCursor(1, 0);
1784  e->accept();
1785  }
1786  else if ((e->key() == Qt::Key_C) &&
1787  QApplication::keyboardModifiers() &
1788  Qt::ControlModifier) {
1789 
1790  //QString fileName = p_cube->fileName();
1791  QFileInfo fileName = p_cube->fileName();
1792 
1793  // Grabs the clipboard and copies the file name into it.
1794  QClipboard *clipboard = QApplication::clipboard();
1795  clipboard->setText(fileName.absoluteFilePath());
1796  }
1797  else {
1798  QAbstractScrollArea::keyPressEvent(e);
1799  }
1800  }
1801 
1802 
1810  QPoint g = QCursor::pos();
1811  QPoint v = viewport()->mapFromGlobal(g);
1812  if(v.x() < 0){
1813  return false;
1814  }
1815  if(v.y() < 0){
1816  return false;
1817  }
1818  if(v.x() >= viewport()->width()){
1819  return false;
1820  }
1821  if(v.y() >= viewport()->height()){
1822  return false;
1823  }
1824  return true;
1825  }
1826 
1827 
1835  QPoint g = QCursor::pos();
1836  return viewport()->mapFromGlobal(g);
1837  }
1838 
1839 
1847  void CubeViewport::moveCursor(int x, int y) {
1848  QPoint g = QCursor::pos();
1849  g += QPoint(x, y);
1850  QPoint v = viewport()->mapFromGlobal(g);
1851  if(v.x() < 0){
1852  return;
1853  }
1854  if(v.y() < 0){
1855  return;
1856  }
1857  if(v.x() >= viewport()->width()){
1858  return;
1859  }
1860  if(v.y() >= viewport()->height()){
1861  return;
1862  }
1863  QCursor::setPos(g);
1864  }
1865 
1866 
1874  void CubeViewport::setCursorPosition(int x, int y) {
1875  QPoint g(x, y);
1876  QPoint v = viewport()->mapToGlobal(g);
1877  QCursor::setPos(v);
1878  }
1879 
1880 
1888  void CubeViewport::updateScrollBars(int x, int y) {
1889  viewport()->blockSignals(true);
1890 
1891  verticalScrollBar()->setValue(1);
1892  verticalScrollBar()->setMinimum(1);
1893  verticalScrollBar()->setMaximum((int)(ceil(cubeLines() * p_scale) + 0.5));
1894  verticalScrollBar()->setPageStep(viewport()->height() / 2);
1895 
1896  horizontalScrollBar()->setValue(1);
1897  horizontalScrollBar()->setMinimum(1);
1898  horizontalScrollBar()->setMaximum((int)(ceil(cubeSamples() * p_scale) + 0.5));
1899  horizontalScrollBar()->setPageStep(viewport()->width() / 2);
1900 
1901  if(horizontalScrollBar()->value() != x || verticalScrollBar()->value() != y) {
1902  horizontalScrollBar()->setValue(x);
1903  verticalScrollBar()->setValue(y);
1904  emit scaleChanged();
1905  }
1906 
1907  QApplication::sendPostedEvents(viewport(), 0);
1908  viewport()->blockSignals(false);
1909  }
1910 
1911 
1918  void CubeViewport::viewGray(int band) {
1919  p_gray.band = band;
1920  p_color = false;
1921  setCaption();
1922 
1923  if(!p_grayBuffer){
1925  p_cubeId);
1926  }
1927 
1928  if(p_redBuffer){
1929  delete p_redBuffer;
1930  }
1931  p_redBuffer = NULL;
1932 
1933  if(p_greenBuffer){
1934  delete p_greenBuffer;
1935  }
1936  p_greenBuffer = NULL;
1937 
1938  if(p_blueBuffer){
1939  delete p_blueBuffer;
1940  }
1941  p_blueBuffer = NULL;
1942 
1943  if(p_grayBuffer->getBand() != band) {
1944  int oldBand = p_grayBuffer->getBand();
1945 
1946  if(oldBand >= 0) {
1947  if((*p_knownStretches)[oldBand - 1]) {
1948  delete(*p_knownStretches)[oldBand - 1];
1949  }
1950 
1951  (*p_knownStretches)[oldBand - 1] = new Stretch(p_gray.getStretch());
1952  }
1953 
1954  p_grayBuffer->setBand(band);
1955  p_gray.band = band;
1956 
1957  if((*p_knownStretches)[band - 1]) {
1958  stretchGray(*(*p_knownStretches)[band - 1]);
1959  }
1960  else {
1962  }
1963  }
1964 
1965  if(p_camera) {
1966  p_camera->SetBand(band);
1967  }
1968 
1969  viewport()->repaint();
1970  }
1971 
1972 
1974  for(int stretch = 0; stretch < p_knownStretches->size(); stretch++) {
1975  if((*p_knownStretches)[stretch]) {
1976  delete(*p_knownStretches)[stretch];
1977  (*p_knownStretches)[stretch] = NULL;
1978  }
1979  }
1980  }
1981 
1982 
1984  for(int index = 0; index < p_knownStretches->size(); index ++) {
1985  if((*p_knownStretches)[index]) {
1986  delete(*p_knownStretches)[index];
1987  }
1988 
1989  (*p_knownStretches)[index] = new Stretch(stretch);
1990  }
1991  }
1992 
1993 
2002  void CubeViewport::viewRGB(int rband, int gband, int bband) {
2003  p_red.band = rband;
2004  p_green.band = gband;
2005  p_blue.band = bband;
2006  p_color = true;
2007  setCaption();
2008 
2009  if(!p_redBuffer) {
2011  }
2012 
2013  if(!p_greenBuffer) {
2015  }
2016 
2017  if(!p_blueBuffer) {
2019  }
2020 
2021  if(p_redBuffer->getBand() != rband) {
2022  int oldBand = p_redBuffer->getBand();
2023 
2024  // Remember current stretch for future band changes
2025  if(oldBand >= 0) {
2026  if((*p_knownStretches)[oldBand - 1]) {
2027  delete(*p_knownStretches)[oldBand - 1];
2028  }
2029 
2030  (*p_knownStretches)[oldBand - 1] = new Stretch(p_red.getStretch());
2031  }
2032 
2033  p_redBuffer->setBand(rband);
2034  p_red.band = rband;
2035 
2036  if((*p_knownStretches)[rband - 1]) {
2037  p_red.setStretch(*(*p_knownStretches)[rband - 1]);
2038  }
2039  else {
2041  }
2042  }
2043 
2044  if(p_greenBuffer->getBand() != gband) {
2045  int oldBand = p_greenBuffer->getBand();
2046 
2047  // Remember current stretch for future band changes
2048  if(oldBand >= 0) {
2049  if((*p_knownStretches)[oldBand - 1]) {
2050  delete(*p_knownStretches)[oldBand - 1];
2051  }
2052 
2053  (*p_knownStretches)[oldBand - 1] = new Stretch(p_green.getStretch());
2054  }
2055 
2056  p_greenBuffer->setBand(gband);
2057  p_green.band = gband;
2058 
2059  if((*p_knownStretches)[gband - 1]) {
2060  p_green.setStretch(*(*p_knownStretches)[gband - 1]);
2061  }
2062  else {
2064  }
2065  }
2066 
2067  if(p_blueBuffer->getBand() != bband) {
2068  int oldBand = p_blueBuffer->getBand();
2069 
2070  // Remember current stretch for future band changes
2071  if(oldBand >= 0) {
2072  if((*p_knownStretches)[oldBand - 1]) {
2073  delete(*p_knownStretches)[oldBand - 1];
2074  }
2075 
2076  (*p_knownStretches)[oldBand - 1] = new Stretch(p_blue.getStretch());
2077  }
2078 
2079  p_blueBuffer->setBand(bband);
2080  p_blue.band = bband;
2081 
2082  if((*p_knownStretches)[bband - 1]) {
2083  p_blue.setStretch(*(*p_knownStretches)[bband - 1]);
2084  }
2085  else {
2087  }
2088  }
2089 
2090  if(p_grayBuffer){
2091  delete p_grayBuffer;
2092  }
2093  p_grayBuffer = NULL;
2094 
2095  if(p_camera) {
2096  p_camera->SetBand(rband);
2097  }
2098  }
2099 
2100 
2107  void CubeViewport::stretchGray(const QString &string) {
2108  Stretch stretch;
2109  stretch.Parse(string);
2110  stretchGray(stretch);
2111  }
2112 
2113 
2119  void CubeViewport::stretchRed(const QString &string) {
2120  Stretch stretch;
2121  stretch.Parse(string);
2122  stretchRed(stretch);
2123  }
2124 
2125 
2131  void CubeViewport::stretchGreen(const QString &string) {
2132  Stretch stretch;
2133  stretch.Parse(string);
2134  stretchGreen(stretch);
2135  }
2136 
2137 
2143  void CubeViewport::stretchBlue(const QString &string) {
2144  Stretch stretch;
2145  stretch.Parse(string);
2146  stretchBlue(stretch);
2147  }
2148 
2149 
2154  if(!p_globalStretches){
2155  return;
2156  }
2157 
2158  if(isGray()) {
2159  if((*p_globalStretches)[grayBand() - 1]) {
2161  }
2162  }
2163  else {
2164  if((*p_globalStretches)[redBand() - 1]) {
2165  stretchRed(*(*p_globalStretches)[redBand() - 1]);
2166  }
2167 
2168  if((*p_globalStretches)[greenBand() - 1]) {
2170  }
2171 
2172  if((*p_globalStretches)[blueBand() - 1]) {
2174  }
2175  }
2176  }
2177 
2178 
2184  void CubeViewport::stretchGray(const Stretch &stretch) {
2185  // Assume first stretch is always the global stretch (and it should be)
2186  if((*p_globalStretches)[grayBand() - 1] == NULL && stretch.Pairs()) {
2187  (*p_globalStretches)[grayBand() - 1] = new Stretch(stretch);
2188  }
2189 
2190  p_gray.setStretch(stretch);
2191 
2192  Stretch newRed(p_red.getStretch());
2193  newRed.CopyPairs(stretch);
2194  p_red.setStretch(newRed);
2195 
2196  Stretch newGreen(p_green.getStretch());
2197  newGreen.CopyPairs(stretch);
2198  p_green.setStretch(newGreen);
2199 
2200  Stretch newBlue(p_blue.getStretch());
2201  newBlue.CopyPairs(stretch);
2202  p_blue.setStretch(newBlue);
2203 
2204  paintPixmap();
2205  viewport()->update();
2206  }
2207 
2208 
2214  void CubeViewport::stretchRed(const Stretch &stretch) {
2215  p_red.setStretch(stretch);
2216 
2217  // Assume first stretch is always the global stretch (and it should be)
2218  if((*p_globalStretches)[redBand() - 1] == NULL && stretch.Pairs()) {
2219  (*p_globalStretches)[redBand() - 1] = new Stretch(p_red.getStretch());
2220  }
2221 
2222  paintPixmap();
2223  viewport()->update();
2224  }
2225 
2226 
2232  void CubeViewport::stretchGreen(const Stretch &stretch) {
2233  p_green.setStretch(stretch);
2234 
2235  // Assume first stretch is always the global stretch (and it should be)
2236  if((*p_globalStretches)[greenBand() - 1] == NULL && stretch.Pairs()) {
2237  (*p_globalStretches)[greenBand() - 1] = new Stretch(p_green.getStretch());
2238  }
2239 
2240  paintPixmap();
2241  viewport()->update();
2242  }
2243 
2244 
2250  void CubeViewport::stretchBlue(const Stretch &stretch) {
2251  p_blue.setStretch(stretch);
2252 
2253  // Assume first stretch is always the global stretch (and it should be)
2254  if((*p_globalStretches)[blueBand() - 1] == NULL && stretch.Pairs()) {
2255  (*p_globalStretches)[blueBand() - 1] = new Stretch(p_blue.getStretch());
2256  }
2257 
2258  paintPixmap();
2259  viewport()->update();
2260  }
2261 
2262 
2270  double CubeViewport::fitScale() const {
2271  double sampScale = (double) viewport()->width() / (double) cubeSamples();
2272  double lineScale = (double) viewport()->height() / (double) cubeLines();
2273  double scale = sampScale < lineScale ? sampScale : lineScale;
2274 // scale = floor(scale * 100.0) / 100.0;
2275  return scale;
2276  }
2277 
2278 
2286  double scale = (double) viewport()->width() / (double) cubeSamples();
2287 
2288 // scale = floor(scale * 100.0) / 100.0;
2289  return scale;
2290  }
2291 
2299  double scale = (double) viewport()->height() / (double) cubeLines();
2300 
2301 // scale = floor(scale * 100.0) / 100.0;
2302  return scale;
2303  }
2304 
2313  //start sample/line and end sample/line
2314  double ss, sl, es, el;
2315  ss = (double)(rect.left()) - 1.;
2316  sl = (double)(rect.top()) - 1.;
2317  es = (double)(rect.right()) + 1.;
2318  el = (double)(rect.bottom()) + 1.;
2319  if(ss < 1){
2320  ss = 0.5;
2321  }
2322  if(sl < 1){
2323  sl = 0.5;
2324  }
2325  if(es > cube()->sampleCount()){
2326  es = cube()->sampleCount() + 0.5;
2327  }
2328  if(el > cube()->lineCount()){
2329  el = cube()->lineCount() + 0.5;
2330  }
2331 
2332  //start x/y and end x/y
2333  int sx, sy, ex, ey;
2334 
2335  cubeToViewport(ss, sl, sx, sy);
2336  cubeToViewport(es, el, ex, ey);
2337  if(sx < 0){
2338  sx = 0;
2339  }
2340  if(sy < 0){
2341  sy = 0;
2342  }
2343  if(ex > viewport()->width()){
2344  ex = viewport()->width();
2345  }
2346  if(ey > viewport()->height()){
2347  ey = viewport()->height();
2348  }
2349  QRect vpRect(sx, sy, ex - sx + 1, ey - sy + 1);
2350 
2351  p_updatingBuffers = true;
2352  if(p_grayBuffer){
2353  p_grayBuffer->fillBuffer(vpRect);
2354  }
2355  if(p_redBuffer){
2356  p_redBuffer->fillBuffer(vpRect);
2357  }
2358  if(p_greenBuffer){
2359  p_greenBuffer->fillBuffer(vpRect);
2360  }
2361  if(p_blueBuffer){
2362  p_blueBuffer->fillBuffer(vpRect);
2363  }
2364  p_updatingBuffers = false;
2365 
2366  paintPixmapRects();
2367  }
2368 
2369 
2376  PvlGroup trackingGroup = p_cube->group("Tracking");
2377  //Because the tracking group does not have a path, get the path from the main cube
2378  FileName cubeName(p_cube->fileName());
2379  QString trackingCubeName = trackingGroup.findKeyword("Filename")[0];
2380  FileName trackingCubeFileName(cubeName.path() + "/" + trackingCubeName);
2381  Cube *trackingCube = new Cube(trackingCubeFileName);
2382  p_trackingCube = trackingCube;
2383  }
2384 
2385 
2392  void CubeViewport::changeCursor(QCursor cursor) {
2393  viewport()->setCursor(cursor);
2394  }
2395 
2396 
2397  CubeViewport::BandInfo::BandInfo() : band(1), stretch(NULL) {
2398  stretch = new CubeStretch;
2399  stretch->SetNull(0.0);
2400  stretch->SetLis(0.0);
2401  stretch->SetLrs(0.0);
2402  stretch->SetHis(255.0);
2403  stretch->SetHrs(255.0);
2404  stretch->SetMinimum(0.0);
2405  stretch->SetMaximum(255.0);
2406  };
2407 
2408 
2409  CubeViewport::BandInfo::BandInfo(const CubeViewport::BandInfo &other) :
2410  band(other.band) {
2411  stretch = NULL;
2412  stretch = new CubeStretch(*other.stretch);
2413  }
2414 
2415 
2417  if(stretch) {
2418  delete stretch;
2419  stretch = NULL;
2420  }
2421  }
2422 
2423 
2425  ASSERT_PTR(stretch);
2426 
2427  return *stretch;
2428  }
2429 
2430 
2432  *stretch = newStretch;
2433  }
2434 
2435 
2437  CubeViewport::BandInfo other) {
2438  ASSERT_PTR(other.stretch);
2439 
2440  stretch = NULL;
2441  stretch = new CubeStretch;
2442  *stretch = *other.stretch;
2443  band = other.band;
2444 
2445  return *this;
2446  }
2447 
2448 }
Isis::CubeViewport::p_green
BandInfo p_green
Green band info.
Definition: CubeViewport.h:641
Isis::CubeViewport::cubeLines
int cubeLines() const
Return the number of lines in the cube.
Definition: CubeViewport.cpp:439
Isis::Brick::SetBasePosition
void SetBasePosition(const int start_sample, const int start_line, const int start_band)
This method is used to set the base position of the shape buffer.
Definition: Brick.h:120
Isis::Camera::SetBand
virtual void SetBand(const int band)
Virtual method that sets the band number.
Definition: Camera.cpp:2680
Isis::CubeViewport::setCaption
void setCaption()
Change the caption on the viewport title bar.
Definition: CubeViewport.cpp:985
Isis::CubeViewport::scaleChanged
void scaleChanged()
Emitted when zoom factor changed just before the repaint event.
QAbstractScrollArea
Isis::CubeViewport::keyPressEvent
virtual void keyPressEvent(QKeyEvent *e)
Process arrow keystrokes on cube.
Definition: CubeViewport.cpp:1759
Isis::CubeViewport::p_gryBrick
Brick * p_gryBrick
Bricks for every color.
Definition: CubeViewport.h:650
Isis::CubeViewport::scrollContentsBy
void scrollContentsBy(int dx, int dy)
Scroll the viewport contents by dx/dy screen pixels.
Definition: CubeViewport.cpp:909
Isis::CubeViewport::p_pntBrick
Brick * p_pntBrick
Bricks for every color.
Definition: CubeViewport.h:651
Isis::ViewportBuffer
Reads and stores visible DN values.
Definition: ViewportBuffer.h:63
Isis::CubeViewport::p_image
QImage * p_image
The qimage.
Definition: CubeViewport.h:654
QWidget
Isis::CubeViewport::p_progressTimer
QTimer * p_progressTimer
Activated to update progress bar.
Definition: CubeViewport.h:634
Isis::CubeViewport::p_camera
Camera * p_camera
The camera from the cube.
Definition: CubeViewport.h:628
Isis::CubeViewport::setAllBandStretches
void setAllBandStretches(Stretch stretch)
Sets a stretch for all bands.
Definition: CubeViewport.cpp:1983
Isis::CubeViewport::p_updatingBuffers
bool p_updatingBuffers
Changing RGB and need to not repaint pixmap?
Definition: CubeViewport.h:656
Isis::PvlObject::findGroup
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:129
Isis::Cube::fileName
virtual QString fileName() const
Returns the opened cube's filename.
Definition: Cube.cpp:1563
Isis::Buffer::SampleDimension
int SampleDimension() const
Returns the number of samples in the shape buffer.
Definition: Buffer.h:70
Isis::ViewportBuffer::getLine
const std::vector< double > & getLine(int line)
Retrieves a line from the buffer.
Definition: ViewportBuffer.cpp:342
Isis::CubeViewport::BandInfo::band
int band
The band.
Definition: CubeViewport.h:168
Isis::UniversalGroundMap
Universal Ground Map.
Definition: UniversalGroundMap.h:69
Isis::PvlObject
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:61
Isis::ViewportBuffer::resizedViewport
void resizedViewport()
Call this when the viewport is resized (not zoomed).
Definition: ViewportBuffer.cpp:901
Isis::CubeViewport::p_pixmapPaintRects
QList< QRect * > * p_pixmapPaintRects
A list of rects that the viewport buffers have requested painted.
Definition: CubeViewport.h:664
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Isis::CubeViewport::cubeContentsChanged
void cubeContentsChanged(QRect rect)
Calle dhwen the contents of the cube changes.
Definition: CubeViewport.cpp:2312
QList< QRect * >
Isis::CubeViewport::eventFilter
virtual bool eventFilter(QObject *o, QEvent *e)
Event filter to watch for mouse events on viewport.
Definition: CubeViewport.cpp:1694
Isis::CubeViewport::p_saveEnabled
bool p_saveEnabled
Has the cube changed?
Definition: CubeViewport.h:652
Isis::CubeViewport::p_greenBuffer
ViewportBuffer * p_greenBuffer
Viewport Buffer to manage green band.
Definition: CubeViewport.h:622
Isis::Cube::group
PvlGroup & group(const QString &group) const
Read a group from the cube into a Label.
Definition: Cube.cpp:1991
Isis::CubeViewport::fitScale
double fitScale() const
Determine the scale that causes the full cube to fit in the viewport.
Definition: CubeViewport.cpp:2270
Isis::CubeViewport::saveChanges
void saveChanges(CubeViewport *)
Emitted when changes should be saved.
Isis::CubeViewport::getAllWhatsThisInfo
void getAllWhatsThisInfo(Pvl &pWhatsThisPvl)
Get All WhatsThis info - viewport, cube, area in PVL format.
Definition: CubeViewport.cpp:1372
Isis::CubeViewport::paintPixmapRects
void paintPixmapRects()
Goes through the list of requested paints, from the viewport buffer, and paints them.
Definition: CubeViewport.cpp:779
Isis::Cube::read
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
Definition: Cube.cpp:807
Isis::CubeViewport::p_knownStretches
QVector< Stretch * > * p_knownStretches
Stretches for each previously stretched band.
Definition: CubeViewport.h:613
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::CubeViewport::isGray
bool isGray() const
Definition: CubeViewport.h:189
Isis::CubeViewport::center
void center(int x, int y)
Bring the cube pixel under viewport x/y to the center.
Definition: CubeViewport.cpp:730
Isis::Stretch
Pixel value mapper.
Definition: Stretch.h:58
Isis::CubeViewport::setScale
void setScale(double scale)
Change the scale of the cube to the given parameter value.
Definition: CubeViewport.cpp:588
Isis::CubeViewport::BandInfo::~BandInfo
~BandInfo()
Deconstructor.
Definition: CubeViewport.cpp:2416
Isis::CubeViewport::p_pixmap
QPixmap p_pixmap
The qpixmap.
Definition: CubeViewport.h:610
Isis::CubeViewport::p_blue
BandInfo p_blue
Blue band info.
Definition: CubeViewport.h:642
Isis::CubeViewport::setCursorPosition
void setCursorPosition(int x, int y)
Set the cursor position to x/y in the viewport.
Definition: CubeViewport.cpp:1874
Isis::CubeViewport::BandInfo::getStretch
CubeStretch getStretch() const
Definition: CubeViewport.cpp:2424
Isis::CubeViewport::p_grayBuffer
ViewportBuffer * p_grayBuffer
Viewport Buffer to manage gray band.
Definition: CubeViewport.h:620
Isis::Cube::physicalBand
virtual int physicalBand(const int &virtualBand) const
This method will return the physical band number given a virtual band number.
Definition: Cube.cpp:1773
Isis::CubeViewport::p_redBrick
Brick * p_redBrick
Bricks for every color.
Definition: CubeViewport.h:647
Isis::PvlObject::hasGroup
bool hasGroup(const QString &name) const
Returns a boolean value based on whether the object has the specified group or not.
Definition: PvlObject.h:210
Isis::CubeViewport::mouseLeave
void mouseLeave()
Emitted when the mouse leaves the viewport.
Isis::CubeViewport::grayPixel
double grayPixel(int sample, int line)
Gets the gray pixel.
Definition: CubeViewport.cpp:1654
Isis::CubeViewport::p_red
BandInfo p_red
Red band info.
Definition: CubeViewport.h:640
Isis::PvlContainer::hasKeyword
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Definition: PvlContainer.cpp:159
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::CubeViewport::forgetStretches
void forgetStretches()
Resets all remembered stretches.
Definition: CubeViewport.cpp:1973
Isis::CubeViewport::p_blueBuffer
ViewportBuffer * p_blueBuffer
Viewport Buffer to manage blue band.
Definition: CubeViewport.h:623
Isis::Stretch::Pairs
int Pairs() const
Returns the number of stretch pairs.
Definition: Stretch.h:162
Isis::CubeStretch
Stores stretch information for a cube.
Definition: CubeStretch.h:27
Isis::UniversalGroundMap::Camera
Isis::Camera * Camera() const
Return the camera associated with the ground map (NULL implies none)
Definition: UniversalGroundMap.h:136
Isis::ViewportBuffer::setBand
void setBand(int band)
Sets the band to read from, the buffer will be re-read if the band changes.
Definition: ViewportBuffer.cpp:1319
Isis::CubeViewport::p_bluBrick
Brick * p_bluBrick
Bricks for every color.
Definition: CubeViewport.h:649
Isis::CubeViewport::contentsToCube
void contentsToCube(int x, int y, double &sample, double &line) const
Turns contents to a cube.
Definition: CubeViewport.cpp:798
Isis::CubeViewport::greenStretch
CubeStretch greenStretch() const
Return the green band stretch.
Definition: CubeViewport.cpp:1674
Isis::ViewportBuffer::getBand
int getBand()
Return the band associated with this viewport buffer.
Definition: ViewportBuffer.h:88
Isis::CubeViewport::moveCursor
void moveCursor(int x, int y)
Move the cursor by x,y if possible.
Definition: CubeViewport.cpp:1847
Isis::CubeViewport::discardChanges
void discardChanges(CubeViewport *)
Emitted when changes should be discarded.
Isis::CubeViewport::viewRGB
virtual void viewRGB(int redBand, int greenBand, int blueBand)
View cube as color.
Definition: CubeViewport.cpp:2002
Isis::CubeViewport::cubeToContents
void cubeToContents(double sample, double line, int &x, int &y) const
Turns a cube into contents.
Definition: CubeViewport.cpp:835
Isis::Brick
Buffer for containing a three dimensional section of an image.
Definition: Brick.h:45
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::CubeViewport::p_whatsThisText
QString p_whatsThisText
The text for What's this.
Definition: CubeViewport.h:658
Isis::CubeViewport::getBandFilterName
void getBandFilterName(PvlKeyword &pFilterNameKey)
Get Band Filter name from the Isis cube label.
Definition: CubeViewport.cpp:1474
Isis::CubeViewport::updateScrollBars
void updateScrollBars(int x, int y)
Update the scroll bar.
Definition: CubeViewport.cpp:1888
Isis::CubeDataThread
Encapsulation of Cube I/O with Change Notifications.
Definition: CubeDataThread.h:59
Isis::CubeDataThread::FindCubeId
int FindCubeId(const Cube *) const
Given a Cube pointer, return the cube ID associated with it.
Definition: CubeDataThread.cpp:351
Isis::CubeViewport::blueBand
int blueBand() const
Definition: CubeViewport.h:209
Isis::CubeViewport::redStretch
CubeStretch redStretch() const
Return the red band stretch.
Definition: CubeViewport.cpp:1668
Isis::CubeDataThread::AddChangeListener
void AddChangeListener()
You must call this method after connecting to the BrickChanged signal, otherwise you are not guarante...
Definition: CubeDataThread.cpp:230
Isis::CubeViewport::fitScaleWidth
double fitScaleWidth() const
Determine the scale of cube in the width to fit in the viewport.
Definition: CubeViewport.cpp:2285
Isis::CubeViewport::stretchKnownGlobal
void stretchKnownGlobal()
List<Tool *> p This stretches to the global stretch.
Definition: CubeViewport.cpp:2153
Isis::CubeViewport::p_thisOwnsCubeData
bool p_thisOwnsCubeData
if true then this owns the CubeDataThread, and should thus delete it
Definition: CubeViewport.h:673
Isis::CubeViewport::mouseEnter
void mouseEnter()
Emitted when the mouse enters the viewport.
Isis::CubeViewport::paintPixmap
void paintPixmap()
Paint the whole pixmap.
Definition: CubeViewport.cpp:1129
Isis::CubeViewport::p_paintPixmap
bool p_paintPixmap
Paint the pixmap?
Definition: CubeViewport.h:655
Isis::ViewportBuffer::enabled
bool enabled()
Returns whether the buffer is enabled (reading data) or not.
Definition: ViewportBuffer.h:105
Isis::CubeViewport::mouseDoubleClick
void mouseDoubleClick(QPoint)
Emitted when double click happens.
Isis::CubeViewport::blueStretch
CubeStretch blueStretch() const
Return the blue band stretch.
Definition: CubeViewport.cpp:1680
Isis::CubeViewport::cubeToViewport
void cubeToViewport(double sample, double line, int &x, int &y) const
Turns a cube into a viewport.
Definition: CubeViewport.cpp:852
Isis::CubeViewport::mouseButtonPress
void mouseButtonPress(QPoint, Qt::MouseButton)
Emitted when mouse button pressed.
Isis::ViewportBuffer::currentProgress
double currentProgress()
Returns the viewport buffer's loading progress.
Definition: ViewportBuffer.cpp:633
Isis::CubeDataThread::AddCube
int AddCube(const FileName &fileName, bool mustOpenReadWrite=false)
This method is designed to be callable from any thread before data is requested, though no known side...
Definition: CubeDataThread.cpp:125
Isis::CubeViewport::BandInfo
Definition: CubeViewport.h:147
Isis::CubeViewport::BandInfo::setStretch
void setStretch(const Stretch &newStretch)
Definition: CubeViewport.cpp:2431
Isis::CubeViewport::BandInfo::operator=
const BandInfo & operator=(BandInfo other)
The BandInfo for the Cube.
Definition: CubeViewport.cpp:2436
Isis::CubeViewport::grayBand
int grayBand() const
Definition: CubeViewport.h:194
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::Cube::lineCount
int lineCount() const
Definition: Cube.cpp:1734
Isis::CubeViewport::resizeEvent
virtual void resizeEvent(QResizeEvent *e)
The viewport is being resized.
Definition: CubeViewport.cpp:1023
Isis::CubeViewport::enableProgress
void enableProgress()
This restarts the progress bar.
Definition: CubeViewport.cpp:972
Isis::CubeViewport::screenPixelsChanged
void screenPixelsChanged()
Emitted when cube pixels that should be on the screen change.
Isis::CubeViewport::grayStretch
CubeStretch grayStretch() const
Return the gray band stretch.
Definition: CubeViewport.cpp:1662
Isis::Stretch::CopyPairs
void CopyPairs(const Stretch &other)
Copies the stretch pairs from another Stretch object, but maintains special pixel values.
Definition: Stretch.cpp:392
Isis::Cube::hasGroup
bool hasGroup(const QString &group) const
Return if the cube has a specified group in the labels.
Definition: Cube.cpp:2004
Isis::Stretch::Parse
void Parse(const QString &pairs)
Parses a string of the form "i1:o1 i2:o2...iN:oN" where each i:o represents an input:output pair.
Definition: Stretch.cpp:181
Isis::CubeViewport::p_color
bool p_color
Is the viewport in color?
Definition: CubeViewport.h:638
Isis::CubeViewport::redPixel
double redPixel(int sample, int line)
Gets the red pixel.
Definition: CubeViewport.cpp:1606
Isis::CubeViewport::greenPixel
double greenPixel(int sample, int line)
Gets the green pixel.
Definition: CubeViewport.cpp:1622
Isis::CubeViewport::confirmClose
bool confirmClose()
This method should be called during a close event that would cause this viewport to close.
Definition: CubeViewport.cpp:525
Isis::CubeViewport::p_projection
Projection * p_projection
The projection from the cube.
Definition: CubeViewport.h:629
Isis::CubeViewport::p_comboCount
int p_comboCount
Number of elements in band bin combo box.
Definition: CubeViewport.h:644
Isis::CubeViewport::windowTitleChanged
void windowTitleChanged()
Emitted when window title changes.
Isis::Buffer::LineDimension
int LineDimension() const
Returns the number of lines in the shape buffer.
Definition: Buffer.h:79
Isis::CubeViewport::trackingCube
Cube * trackingCube() const
Definition: CubeViewport.h:358
Isis::CubeViewport::mouseMove
void mouseMove(QPoint)
Emitted when the mouse moves.
Isis::PvlObject::findObject
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition: PvlObject.h:274
Isis::Cube::sampleCount
int sampleCount() const
Definition: Cube.cpp:1807
Isis::CubeViewport::getCubeArea
void getCubeArea(double &pdStartSample, double &pdEndSample, double &pdStartLine, double &pdEndLine)
Get Cube area corresponding to the viewport's dimension.
Definition: CubeViewport.cpp:1495
Isis::CubeViewport::sizeHint
QSize sizeHint() const
Make viewports show up as 512 by 512.
Definition: CubeViewport.cpp:571
Isis::CubeViewport::bufferUpdated
void bufferUpdated(QRect rect)
This method is called by ViewportBuffer upon successful completion of all operations and gives the ap...
Definition: CubeViewport.cpp:1104
Isis::Cube::isOpen
bool isOpen() const
Test if a cube file has been opened/created.
Definition: Cube.cpp:183
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::CubeViewport::doneWithData
void doneWithData(int, const Isis::Brick *)
Emitted when a brick is no longer needed, should only be sent to cube data thread.
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::CubeViewport::cubeSamples
int cubeSamples() const
Return the number of samples in the cube.
Definition: CubeViewport.cpp:433
Isis::Cube::bandCount
virtual int bandCount() const
Returns the number of virtual bands for the cube.
Definition: Cube.cpp:1410
Isis::CubeViewport::p_cubeData
CubeDataThread * p_cubeData
Does all the cube I/O.
Definition: CubeViewport.h:666
Isis::ViewportBuffer::bufferXYRect
QRect bufferXYRect()
Returns a rect, in screen pixels, of the area this buffer covers.
Definition: ViewportBuffer.cpp:1257
Isis::CubeViewport::cursorPosition
QPoint cursorPosition() const
Return the cursor position in the viewport.
Definition: CubeViewport.cpp:1834
Isis::CubeViewport::p_cubeId
int p_cubeId
Cube ID given from cube data thread for I/O.
Definition: CubeViewport.h:667
Isis::UniversalGroundMap::Projection
Isis::Projection * Projection() const
Return the projection associated with the ground map (NULL implies none)
Definition: UniversalGroundMap.h:131
Isis::CubeViewport::BandInfo::stretch
CubeStretch * stretch
The Stretch.
Definition: CubeViewport.h:171
Isis::CubeViewport::scrollBy
void scrollBy(int dx, int dy)
Move the scrollbars by dx/dy screen pixels.
Definition: CubeViewport.cpp:869
Isis::CubeViewport::p_gray
BandInfo p_gray
Gray band info.
Definition: CubeViewport.h:639
Isis::Stretch::SetNull
void SetNull(const double value)
Sets the mapping for NULL pixels.
Definition: Stretch.h:94
Isis::CubeViewport::bluePixel
double bluePixel(int sample, int line)
Gets the blue pixel.
Definition: CubeViewport.cpp:1638
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
Isis::CubeDataThread::RemoveChangeListener
void RemoveChangeListener()
You must call this method after disconnecting from the BrickChanged signal, otherwise bricks cannot b...
Definition: CubeDataThread.cpp:238
std
Namespace for the standard library.
Isis::CubeViewport::changeCursor
void changeCursor(QCursor cursor)
Allows users to change the cursor type on the viewport.
Definition: CubeViewport.cpp:2392
Isis::CubeViewport::stretchGreen
void stretchGreen(const QString &string)
Apply stretch pairs to green bands.
Definition: CubeViewport.cpp:2131
Isis::ViewportBuffer::addStretchAction
void addStretchAction()
When all current operations finish the cube viewport will be asked to do a stretch if you call this.
Definition: ViewportBuffer.cpp:1220
Isis::Cube::pixelType
PixelType pixelType() const
Definition: Cube.cpp:1758
Isis::CubeViewport::p_redBuffer
ViewportBuffer * p_redBuffer
Viewport Buffer to manage red band.
Definition: CubeViewport.h:621
Isis::ViewportBuffer::scaleChanged
void scaleChanged()
Call this when zoomed, re-reads visible area.
Definition: ViewportBuffer.cpp:1281
Isis::CubeViewport::p_globalStretches
QVector< Stretch * > * p_globalStretches
Global stretches for each stretched band.
Definition: CubeViewport.h:616
Isis::CubeViewport::setTrackingCube
void setTrackingCube()
Finds the Tracking group from p_cube and stores the tracking cube name so that we can grab it in Adva...
Definition: CubeViewport.cpp:2375
Isis::Cube::label
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1701
Isis::ViewportBuffer::enable
void enable(bool enabled)
This turns on or off reading from the cube.
Definition: ViewportBuffer.cpp:1302
Isis::CubeViewport::~CubeViewport
virtual ~CubeViewport()
Deconstructor for the Cubeviewport.
Definition: CubeViewport.cpp:307
Isis::CubeViewport::cubeChanged
void cubeChanged(bool changed)
This method is called when the cube has changed or changes have been finalized.
Definition: CubeViewport.cpp:561
Isis::CubeViewport::p_comboIndex
int p_comboIndex
Current element chosen from combo box.
Definition: CubeViewport.h:645
Isis::CubeViewport::p_viewportWhatsThisText
QString p_viewportWhatsThisText
The text for the viewport's what's this.
Definition: CubeViewport.h:660
Isis::ViewportBuffer::pan
void pan(int deltaX, int deltaY)
Call this when the viewport is panned.
Definition: ViewportBuffer.cpp:1048
Isis::CubeViewport::setCube
void setCube(Cube *cube)
This method sets the viewports cube.
Definition: CubeViewport.cpp:426
Isis::CubeViewport::mouseButtonRelease
void mouseButtonRelease(QPoint, Qt::MouseButton)
Emitted when mouse button released.
Isis::PvlKeyword::size
int size() const
Returns the number of values stored in this keyword.
Definition: PvlKeyword.h:125
Isis::CubeViewport::viewGray
virtual void viewGray(int band)
View cube as gray.
Definition: CubeViewport.cpp:1918
Isis::CubeViewport::fitScaleHeight
double fitScaleHeight() const
Determine the scale of cube in heighth to fit in the viewport.
Definition: CubeViewport.cpp:2298
Isis::CubeViewport::scale
double scale() const
Definition: CubeViewport.h:214
Isis::CubeViewport::p_grnBrick
Brick * p_grnBrick
Bricks for every color.
Definition: CubeViewport.h:648
Isis::CubeViewport::onProgressTimer
void onProgressTimer()
This updates the progress bar visually.
Definition: CubeViewport.cpp:263
Isis::CubeViewport::viewportToCube
void viewportToCube(int x, int y, double &sample, double &line) const
Turns a viewport into a cube.
Definition: CubeViewport.cpp:815
Isis::CubeViewport::paintEvent
virtual void paintEvent(QPaintEvent *e)
Repaint the viewport.
Definition: CubeViewport.cpp:1089
Isis::PvlContainer::findKeyword
PvlKeyword & findKeyword(const QString &name)
Find a keyword with a specified name.
Definition: PvlContainer.cpp:62
QObject
QVector
This is free and unencumbered software released into the public domain.
Definition: Calculator.h:18
Isis::CubeViewport::shiftPixmap
void shiftPixmap(int dx, int dy)
Shifts the pixels on the pixmap without reading new data.
Definition: CubeViewport.cpp:1292
Isis::CubeViewport::progressChanged
void progressChanged(int)
Emitted with current progress (0 to 100) when working.
Isis::CubeViewport::p_cube
Cube * p_cube
The cube associated with the viewport.
Definition: CubeViewport.h:627
Isis::Buffer::Sample
int Sample(const int index=0) const
Returns the sample position associated with a shape buffer index.
Definition: Buffer.cpp:127
Isis::CubeViewport::showEvent
void showEvent(QShowEvent *)
This method is called to initially show the viewport.
Definition: CubeViewport.cpp:233
Isis::ViewportBuffer::fillBuffer
void fillBuffer(QRect rect)
This method will convert the rect to sample/line positions and read from the cube into the buffer.
Definition: ViewportBuffer.cpp:114
Isis::CubeViewport::cube
Cube * cube() const
Definition: CubeViewport.h:338
Isis::CubeViewport::p_groundMap
UniversalGroundMap * p_groundMap
The universal ground map from the cube.
Definition: CubeViewport.h:630
Isis::Camera::HasProjection
bool HasProjection()
Checks to see if the camera object has a projection.
Definition: Camera.cpp:2638
Isis::CubeViewport::redBand
int redBand() const
Definition: CubeViewport.h:199
Isis::CubeViewport::cursorInside
bool cursorInside() const
Is cursor inside viewport.
Definition: CubeViewport.cpp:1809
Isis::CubeViewport::p_cubeShown
bool p_cubeShown
Is the cube visible?
Definition: CubeViewport.h:653
Isis::Cube::projection
Projection * projection()
Definition: Cube.cpp:1794
Isis::Buffer::Line
int Line(const int index=0) const
Returns the line position associated with a shape buffer index.
Definition: Buffer.cpp:145
Isis::CubeViewport::cubeDataChanged
virtual void cubeDataChanged(int cubeId, const Isis::Brick *)
This method updates the internal viewport buffer based on changes in cube DN values.
Definition: CubeViewport.cpp:457
Isis::CubeViewport::cubeBands
int cubeBands() const
Return the number of bands in the cube.
Definition: CubeViewport.cpp:445
Isis::CubeViewport::stretchGray
void stretchGray(const QString &string)
Apply stretch pairs to gray band.
Definition: CubeViewport.cpp:2107
Isis::FileName::path
QString path() const
Returns the path of the file name.
Definition: FileName.cpp:103
Isis::CubeViewport::stretchBlue
void stretchBlue(const QString &string)
Apply stretch pairs to blue bands.
Definition: CubeViewport.cpp:2143
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::CubeViewport::greenBand
int greenBand() const
Definition: CubeViewport.h:204
Isis::CubeViewport::p_bgColor
QColor p_bgColor
The color to paint the background of the viewport.
Definition: CubeViewport.h:625
Isis::CubeViewport::progressComplete
void progressComplete()
Emitted when the current progress is complete (100)
Isis::CubeViewport::p_cubeWhatsThisText
QString p_cubeWhatsThisText
The text for the cube's What's this.
Definition: CubeViewport.h:659
Isis::CubeViewport::p_scale
double p_scale
The scale number.
Definition: CubeViewport.h:636
Isis::CubeViewport::updateWhatsThis
void updateWhatsThis()
Update the What's This text.
Definition: CubeViewport.cpp:1520
Isis::ViewportBuffer::working
bool working()
This tests if queued actions exist in the viewport buffer.
Definition: ViewportBuffer.cpp:759
Isis::Stretch::Map
double Map(const double value) const
Maps an input value to an output value based on the stretch pairs and/or special pixel mappings.
Definition: Stretch.cpp:69
Isis::CubeViewport::stretchRed
void stretchRed(const QString &string)
Apply stretch pairs to red bands.
Definition: CubeViewport.cpp:2119