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