00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "SlicerBase.h"
00023 #include <qmenubar.h>
00024 #include <qapplication.h>
00025 #include <qlayout.h>
00026 #include <iostream>
00027 #include <util/NrroQT.h>
00028
00029 using namespace std;
00030
00031
00032
00033
00034
00035 SlicerBase::SlicerBase(QWidget *parent, const char *name, WFlags wf)
00036 : QMainWindow(parent,name,wf), _qcentral(new QWidget(this)), _sliceInfo(0)
00037 {
00038 setCaption("Simian 3.0 ~ Slicer");
00039 confMenu();
00040 setCentralWidget(_qcentral);
00041 confSliceView();
00042 }
00043
00044 SlicerBase::SlicerBase(int views, QWidget *parent, const char *name, WFlags wf)
00045 : QMainWindow(parent,name,wf), _qcentral(new QWidget(this)), _sliceInfo(0)
00046 {
00047 }
00048
00049
00050
00051
00052
00053
00054 SlicerBase::~SlicerBase()
00055 {
00056 }
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 void SlicerBase::setVolume(VolumeSP vol)
00068 {
00069 if(vol.isNull())
00070 {
00071 cerr << typeid(*this).name()
00072 << "::setVolume(), attempting to set a null volume" << endl;
00073 return;
00074 }
00075 _vol = vol;
00076
00077 volumeChanged(_vol);
00078 }
00079
00080 void SlicerBase::setProbePos(int xp, int yp, int zp)
00081 {
00082 probePosChanged(xp,yp,zp);
00083 }
00084
00085
00086
00087
00088
00089 void SlicerBase::setNrro(NrroSP n)
00090 {
00091 if(n.isNull())
00092 {
00093 cerr << typeid(*this).name()
00094 << "::setNrro(), attempting to set a null Nrro" << endl;
00095 return;
00096 }
00097 if(_vol.isNull())
00098 {
00099 _vol = new Volume();
00100 }
00101 _vol->fields.addNrro(n);
00102 setVolume(_vol);
00103
00104 }
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 void SlicerBase::saveImage()
00117 {
00118 cerr << "saveImage not implemented" << endl;
00119 }
00120
00121 void SlicerBase::openNrrd()
00122 {
00123 NrroSP n = openNrroQT("/home/jmk/data");
00124 setNrro(n);
00125 }
00126
00127 void SlicerBase::insertNrrd()
00128 {
00129 NrroSP n = openNrroQT("/home/jmk/data");
00130 if(n.isNull())
00131 {
00132 cerr << typeid(*this).name()
00133 << "::insertNrrd(), no nrrd file found" << endl;
00134 return;
00135 }
00136 if(_vol.isNull())
00137 {
00138 _vol = new Volume();
00139 }
00140
00141 _vol->fields.addNrro(n);
00142 setVolume(_vol);
00143
00144 }
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 void SlicerBase::confMenu()
00157 {
00158
00159 QMenuBar* menu = menuBar();
00160
00161
00162 QPopupMenu* file = new QPopupMenu( menu );
00163 menu->insertItem("&File", file);
00164
00165 file->insertItem("&Open Nrrd", this, SLOT(openNrrd()), CTRL+Key_O);
00166 file->insertItem("&Insert Nrrd", this, SLOT(insertNrrd()), CTRL+Key_I);
00167 file->insertItem("&Save Image", this, SLOT(saveImage()), CTRL+Key_S);
00168 file->insertItem("E&xit", qApp, SLOT(quit()), CTRL+Key_Q);
00169
00170
00171 QPopupMenu *imgMenu = new QPopupMenu( menu );
00172 menu->insertItem("&Image", imgMenu);
00173
00174
00175 QPopupMenu *samp = new QPopupMenu( menu );
00176 imgMenu->insertItem("&Sampling", samp);
00177 samp->insertItem("&Nearest", this, SLOT(setNearest()));
00178 samp->insertItem("Bi&linear", this, SLOT(setBiLin()));
00179 samp->insertItem("Bi&cubic", this, SLOT(setBiCube()));
00180 samp->insertItem("B-&spline", this, SLOT(setBSpline()));
00181
00182
00183 }
00184
00185
00186
00187
00188 void SlicerBase::confSliceView()
00189 {
00190
00191 QHBoxLayout *topLayout = new QHBoxLayout( _qcentral, 1 );
00192
00193
00194 QGridLayout *_mainGrid = new QGridLayout(topLayout, 2, 1);
00195
00196 SlicerWidget *sw1 = new SlicerWidget(_qcentral,"slicer widget 1");
00197 sw1->connect(this,SIGNAL(volumeChanged(VolumeSP)),SLOT(setVolume(VolumeSP)));
00198 sw1->connect(this,SIGNAL(filterChanged(int)), SLOT(setFilter(int)));
00199 _mainGrid->addWidget(sw1, 0, 0);
00200
00201
00202 }
00203
00204
00205
00206
00207 void SlicerBase::keyPressEvent(QKeyEvent *key)
00208 {
00209 switch(key->key())
00210 {
00211 case 4096:
00212 key->accept();
00213 close();
00214 break;
00215
00216 default:
00217 cerr << "Key event : " << key->key() << " = ' " << char(key->ascii()) << " ' " << endl;
00218 break;
00219 }
00220 }
00221