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
24using namespace std;
25
26
27namespace 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
47 void MdiCubeViewport::registerTool(Tool *tool) {
48 p_toolList.push_back(tool);
49 }
50
51
58 void MdiCubeViewport::setLinked(bool b) {
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) {
95 CubeViewport::paintEvent(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) {
111 CubeViewport::viewGray(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
126 void MdiCubeViewport::restretch(ViewportBuffer *buffer) {
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}
File name manipulation and expansion.
Definition FileName.h:100
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition FileName.cpp:196
Base class for the Qisis tools.
Definition Tool.h:67
Reads and stores visible DN values.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.