Isis 3 Programmer Reference
MdiCubeViewport.cpp
Go to the documentation of this file.
1 
21 #include "MdiCubeViewport.h"
22 
23 #include <QIcon>
24 #include <QPainter>
25 
26 #include <iostream>
27 #include <string>
28 
29 #include "FileName.h"
30 #include "IString.h"
31 #include "RubberBandTool.h"
32 #include "StretchTool.h"
33 #include "Tool.h"
34 
35 
36 using namespace std;
37 
38 
39 namespace Isis {
40  MdiCubeViewport::MdiCubeViewport(Cube *cube, CubeDataThread * cdt,
41  QWidget *parent) : CubeViewport(cube, cdt, parent) {
42  p_linked = false;
43 
44  QString unlinkedIcon = FileName("$base/icons/unlinked.png").expanded();
45  static QIcon unlinked(unlinkedIcon);
46  parentWidget()->setWindowIcon(unlinked);
47 
48  }
49 
50  MdiCubeViewport::~MdiCubeViewport() {
51  }
52 
53 
60  p_toolList.push_back(tool);
61  }
62 
63 
71  if(!parentWidget() || !parentWidget()->parentWidget())
72  return;
73 
74  QString unlinkedIcon = FileName("$base/icons/unlinked.png").expanded();
75  static QIcon unlinked(unlinkedIcon);
76  QString linkedIcon = FileName("$base/icons/linked.png").expanded();
77  static QIcon linked(linkedIcon);
78 
79  bool notify = false;
80  if(b != p_linked)
81  notify = true;
82 
83  p_linked = b;
84  if(p_linked) {
85  parentWidget()->parentWidget()->setWindowIcon(linked);
86  }
87  else {
88  parentWidget()->parentWidget()->setWindowIcon(unlinked);
89  }
90 
91  if(notify)
92  emit linkChanging(b);
93  }
94 
95 
106  void MdiCubeViewport::paintEvent(QPaintEvent *e) {
108 
109  QPainter painter(viewport());
110  painter.drawPixmap(0, 0, p_pixmap);
111  emit viewportUpdated();
112 
113  // Draw anything the tools might need
114  for(int i = 0; i < p_toolList.size(); i++) {
115  p_toolList[i]->paintViewport(this, &painter);
116  }
117 
118  painter.end();
119  }
120 
121 
122  void MdiCubeViewport::viewGray(int band) {
124 
125  for(int i = 0; i < p_toolList.size(); i++)
126  p_toolList[i]->updateTool();
127  }
128 
129 
130  void MdiCubeViewport::viewRGB(int rband, int gband, int bband) {
131  CubeViewport::viewRGB(rband, gband, bband);
132 
133  for(int i = 0; i < p_toolList.size(); i++)
134  p_toolList[i]->updateTool();
135  }
136 
137 
139  if(buffer == grayBuffer()) {
140  emit requestRestretch(this, (int)StretchTool::Gray);
141  }
142  else if(buffer == redBuffer()) {
143  emit requestRestretch(this, (int)StretchTool::Red);
144  }
145  else if(buffer == greenBuffer()) {
146  emit requestRestretch(this, (int)StretchTool::Green);
147  }
148  else if(buffer == blueBuffer()) {
149  emit requestRestretch(this, (int)StretchTool::Blue);
150  }
151  }
152 }
ViewportBuffer * grayBuffer()
Returns the gray viewport buffer (Will be NULL if in RGB mode.)
Definition: CubeViewport.h:421
void viewportUpdated()
Emitted when viewport updated.
Reads and stores visible DN values.
QPixmap p_pixmap
The qpixmap.
Definition: CubeViewport.h:620
void registerTool(Tool *tool)
Registers the tool given tool.
ViewportBuffer * redBuffer()
Returns the red viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:431
File name manipulation and expansion.
Definition: FileName.h:116
Namespace for the standard library.
virtual void viewRGB(int redBand, int greenBand, int blueBand)
View cube as color.
void restretch(ViewportBuffer *buffer)
This is called by internal viewport buffers when a stretch action should be performed.
void setLinked(bool b)
Change the linked state of the viewport.
void paintEvent(QPaintEvent *e)
Repaint the viewport.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:212
virtual void viewGray(int band)
View cube as gray.
ViewportBuffer * blueBuffer()
Returns the blue viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:451
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
virtual void paintEvent(QPaintEvent *e)
Repaint the viewport.
Base class for the Qisis tools.
Definition: Tool.h:81
ViewportBuffer * greenBuffer()
Returns the green viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:441