Isis 3 Programmer Reference
MdiCubeViewport.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "MdiCubeViewport.h"
10 
11 #include <QIcon>
12 #include <QPainter>
13 
14 #include <iostream>
15 #include <string>
16 
17 #include "FileName.h"
18 #include "IString.h"
19 #include "RubberBandTool.h"
20 #include "StretchTool.h"
21 #include "Tool.h"
22 
23 
24 using namespace std;
25 
26 
27 namespace Isis {
28  MdiCubeViewport::MdiCubeViewport(Cube *cube, CubeDataThread * cdt,
29  QWidget *parent) : CubeViewport(cube, cdt, parent) {
30  p_linked = false;
31 
32  QString unlinkedIcon = FileName("$ISISROOT/appdata/images/icons/unlinked.png").expanded();
33  static QIcon unlinked(unlinkedIcon);
34  parentWidget()->setWindowIcon(unlinked);
35 
36  }
37 
38  MdiCubeViewport::~MdiCubeViewport() {
39  }
40 
41 
48  p_toolList.push_back(tool);
49  }
50 
51 
59  if(!parentWidget() || !parentWidget()->parentWidget())
60  return;
61 
62  QString unlinkedIcon = FileName("$ISISROOT/appdata/images/icons/unlinked.png").expanded();
63  static QIcon unlinked(unlinkedIcon);
64  QString linkedIcon = FileName("$ISISROOT/appdata/images/icons/linked.png").expanded();
65  static QIcon linked(linkedIcon);
66 
67  bool notify = false;
68  if(b != p_linked)
69  notify = true;
70 
71  p_linked = b;
72  if(p_linked) {
73  parentWidget()->parentWidget()->setWindowIcon(linked);
74  }
75  else {
76  parentWidget()->parentWidget()->setWindowIcon(unlinked);
77  }
78 
79  if(notify)
80  emit linkChanging(b);
81  }
82 
83 
94  void MdiCubeViewport::paintEvent(QPaintEvent *e) {
96 
97  QPainter painter(viewport());
98  painter.drawPixmap(0, 0, p_pixmap);
99  emit viewportUpdated();
100 
101  // Draw anything the tools might need
102  for(int i = 0; i < p_toolList.size(); i++) {
103  p_toolList[i]->paintViewport(this, &painter);
104  }
105 
106  painter.end();
107  }
108 
109 
110  void MdiCubeViewport::viewGray(int band) {
112 
113  for(int i = 0; i < p_toolList.size(); i++)
114  p_toolList[i]->updateTool();
115  }
116 
117 
118  void MdiCubeViewport::viewRGB(int rband, int gband, int bband) {
119  CubeViewport::viewRGB(rband, gband, bband);
120 
121  for(int i = 0; i < p_toolList.size(); i++)
122  p_toolList[i]->updateTool();
123  }
124 
125 
127  if(buffer == grayBuffer()) {
128  emit requestRestretch(this, (int)StretchTool::Gray);
129  }
130  else if(buffer == redBuffer()) {
131  emit requestRestretch(this, (int)StretchTool::Red);
132  }
133  else if(buffer == greenBuffer()) {
134  emit requestRestretch(this, (int)StretchTool::Green);
135  }
136  else if(buffer == blueBuffer()) {
137  emit requestRestretch(this, (int)StretchTool::Blue);
138  }
139  }
140 }
Isis::ViewportBuffer
Reads and stores visible DN values.
Definition: ViewportBuffer.h:63
QWidget
Isis::CubeViewport::redBuffer
ViewportBuffer * redBuffer()
Returns the red viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:421
Isis::CubeViewport::viewportUpdated
void viewportUpdated()
Emitted when viewport updated.
Isis::Tool
Base class for the Qisis tools.
Definition: Tool.h:67
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::CubeViewport::p_pixmap
QPixmap p_pixmap
The qpixmap.
Definition: CubeViewport.h:610
Isis::MdiCubeViewport::paintEvent
void paintEvent(QPaintEvent *e)
Repaint the viewport.
Definition: MdiCubeViewport.cpp:94
Isis::CubeViewport::viewRGB
virtual void viewRGB(int redBand, int greenBand, int blueBand)
View cube as color.
Definition: CubeViewport.cpp:2002
Isis::StretchTool::Red
@ Red
Red Band.
Definition: StretchTool.h:98
Isis::MdiCubeViewport::setLinked
void setLinked(bool b)
Change the linked state of the viewport.
Definition: MdiCubeViewport.cpp:58
Isis::FileName::expanded
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:196
Isis::StretchTool::Blue
@ Blue
Blue Band.
Definition: StretchTool.h:100
Isis::StretchTool::Gray
@ Gray
Gray Band.
Definition: StretchTool.h:97
Isis::MdiCubeViewport::restretch
void restretch(ViewportBuffer *buffer)
This is called by internal viewport buffers when a stretch action should be performed.
Definition: MdiCubeViewport.cpp:126
std
Namespace for the standard library.
Isis::CubeViewport::blueBuffer
ViewportBuffer * blueBuffer()
Returns the blue viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:441
Isis::CubeViewport::viewGray
virtual void viewGray(int band)
View cube as gray.
Definition: CubeViewport.cpp:1918
Isis::StretchTool::Green
@ Green
Green Band.
Definition: StretchTool.h:99
Isis::CubeViewport::paintEvent
virtual void paintEvent(QPaintEvent *e)
Repaint the viewport.
Definition: CubeViewport.cpp:1089
Isis::MdiCubeViewport::registerTool
void registerTool(Tool *tool)
Registers the tool given tool.
Definition: MdiCubeViewport.cpp:47
Isis::CubeViewport::grayBuffer
ViewportBuffer * grayBuffer()
Returns the gray viewport buffer (Will be NULL if in RGB mode.)
Definition: CubeViewport.h:411
Isis::CubeViewport::greenBuffer
ViewportBuffer * greenBuffer()
Returns the green viewport buffer (Will be NULL if in Gray mode.)
Definition: CubeViewport.h:431
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16