Isis 3.0 Object Programmers' Reference |
Home |
00001 00021 #include "MdiCubeViewport.h" 00022 00023 #include <QIcon> 00024 #include <QPainter> 00025 00026 #include <iostream> 00027 #include <string> 00028 00029 #include "FileName.h" 00030 #include "IString.h" 00031 #include "RubberBandTool.h" 00032 #include "StretchTool.h" 00033 #include "Tool.h" 00034 00035 00036 using namespace std; 00037 00038 00039 namespace Isis { 00040 MdiCubeViewport::MdiCubeViewport(Cube *cube, CubeDataThread * cdt, 00041 QWidget *parent) : CubeViewport(cube, cdt, parent) { 00042 p_linked = false; 00043 00044 QString unlinkedIcon = FileName("$base/icons/unlinked.png").expanded(); 00045 static QIcon unlinked(unlinkedIcon); 00046 parentWidget()->setWindowIcon(unlinked); 00047 00048 } 00049 00050 MdiCubeViewport::~MdiCubeViewport() { 00051 } 00052 00053 00059 void MdiCubeViewport::registerTool(Tool *tool) { 00060 p_toolList.push_back(tool); 00061 } 00062 00063 00070 void MdiCubeViewport::setLinked(bool b) { 00071 if(!parentWidget() || !parentWidget()->parentWidget()) 00072 return; 00073 00074 QString unlinkedIcon = FileName("$base/icons/unlinked.png").expanded(); 00075 static QIcon unlinked(unlinkedIcon); 00076 QString linkedIcon = FileName("$base/icons/linked.png").expanded(); 00077 static QIcon linked(linkedIcon); 00078 00079 bool notify = false; 00080 if(b != p_linked) 00081 notify = true; 00082 00083 p_linked = b; 00084 if(p_linked) { 00085 parentWidget()->parentWidget()->setWindowIcon(linked); 00086 } 00087 else { 00088 parentWidget()->parentWidget()->setWindowIcon(unlinked); 00089 } 00090 00091 if(notify) 00092 emit linkChanging(b); 00093 } 00094 00095 00106 void MdiCubeViewport::paintEvent(QPaintEvent *e) { 00107 CubeViewport::paintEvent(e); 00108 00109 QPainter painter(viewport()); 00110 painter.drawPixmap(0, 0, p_pixmap); 00111 emit viewportUpdated(); 00112 00113 // Draw anything the tools might need 00114 for(int i = 0; i < p_toolList.size(); i++) { 00115 p_toolList[i]->paintViewport(this, &painter); 00116 } 00117 00118 painter.end(); 00119 } 00120 00121 00122 void MdiCubeViewport::viewGray(int band) { 00123 CubeViewport::viewGray(band); 00124 00125 for(int i = 0; i < p_toolList.size(); i++) 00126 p_toolList[i]->updateTool(); 00127 } 00128 00129 00130 void MdiCubeViewport::viewRGB(int rband, int gband, int bband) { 00131 CubeViewport::viewRGB(rband, gband, bband); 00132 00133 for(int i = 0; i < p_toolList.size(); i++) 00134 p_toolList[i]->updateTool(); 00135 } 00136 00137 00138 void MdiCubeViewport::restretch(ViewportBuffer *buffer) { 00139 if(buffer == grayBuffer()) { 00140 emit requestRestretch(this, (int)StretchTool::Gray); 00141 } 00142 else if(buffer == redBuffer()) { 00143 emit requestRestretch(this, (int)StretchTool::Red); 00144 } 00145 else if(buffer == greenBuffer()) { 00146 emit requestRestretch(this, (int)StretchTool::Green); 00147 } 00148 else if(buffer == blueBuffer()) { 00149 emit requestRestretch(this, (int)StretchTool::Blue); 00150 } 00151 } 00152 }