arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

FieldProbes.cpp

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 //
00003 //   Joe Kniss
00004 //     6-20-03
00005 //                   ________    ____   ___ 
00006 //                  |        \  /    | /  /
00007 //                  +---+     \/     |/  /
00008 //                  +--+|  |\    /|     < 
00009 //                  |  ||  | \  / |  |\  \ 
00010 //                  |      |  \/  |  | \  \ 
00011 //                   \_____|      |__|  \__\
00012 //                       Copyright  2003 
00013 //                      Joe Michael Kniss
00014 //                   <<< jmk@cs.utah.edu >>>
00015 //               "All Your Base are Belong to Us"
00016 //-------------------------------------------------------------------------
00017 
00018 /// FieldProbes.cpp
00019 ///  simianUI
00020 
00021 
00022 #include "FieldProbes.h"
00023 #include <qlayout.h>
00024 #include <string>
00025 #include <mathGutz.h>
00026 
00027 using namespace std;
00028 using namespace gutz;
00029 
00030 FieldProbes::FieldProbes(VolFieldSP vf, QWidget *parent, const char *name, WFlags wf)
00031 :QWidget(parent, name, wf), _vf(vf), _nvals(0)
00032 {
00033    for(int i=0; i<MAX_NUM_VALS; ++i)
00034       _nums[i] = 0;
00035 
00036    conf();
00037 }
00038 
00039 FieldProbes::~FieldProbes()
00040 {
00041    for(int i=0; i<MAX_NUM_VALS; ++i)
00042       if(_nums[i]) delete _nums[i];
00043 }
00044 
00045 //////////////////////////////////////////////////////////////////////////
00046 //////////////////////////////////////////////////////////////////////////
00047 /// Public Slots
00048 //////////////////////////////////////////////////////////////////////////
00049 //////////////////////////////////////////////////////////////////////////
00050 
00051 void FieldProbes::setProbePos(int xp, int yp, int zp)
00052 {
00053    if(_vf.isNull()) return;
00054    NrroSP n = _vf->getNrro(0);
00055    if(n.isNull()) return;
00056    
00057    if(n->getKind() == Nrro::VOLUME)
00058    {
00059       if(n->dim() == 3)
00060       {
00061          xp = clamp(0,xp,int(n->dim(0))-1);
00062          yp = clamp(0,yp,int(n->dim(1))-1);
00063          zp = clamp(0,zp,int(n->dim(2))-1);
00064          QString v = QString::number((double)(n->v(xp,yp,zp)));
00065          _nums[0]->setText(v);
00066          _nums[0]->repaint(true);
00067       }
00068       if(n->dim() == 4)
00069       {
00070          for(int i=0; i<_nvals; ++i)
00071          {
00072             xp = clamp(0,xp,int(n->dim(1))-1);
00073             yp = clamp(0,yp,int(n->dim(2))-1);
00074             zp = clamp(0,zp,int(n->dim(3))-1);
00075             QString v = QString::number(n->v(i,xp,yp,zp));
00076             _nums[i]->setText(v);
00077             _nums[i]->repaint(true);
00078          }
00079       }
00080    }
00081 
00082 }
00083 
00084 //////////////////////////////////////////////////////////////////////////
00085 //////////////////////////////////////////////////////////////////////////
00086 /// Protected Members
00087 //////////////////////////////////////////////////////////////////////////
00088 //////////////////////////////////////////////////////////////////////////
00089 
00090 //////////////////////////////////////////////////////////////////////////
00091 /// configure
00092 //////////////////////////////////////////////////////////////////////////
00093 void FieldProbes::conf()
00094 {
00095    if(_vf.isNull()) return;
00096    NrroSP n = _vf->getNrro(0);
00097    if(n.isNull()) return;
00098    
00099    // Create a layout to position the widgets
00100    QHBoxLayout *topLayout = new QHBoxLayout( this, 5 );
00101    topLayout->setAlignment(Qt::AlignTop);
00102 
00103    if(n->getKind() == Nrro::VOLUME)
00104    {
00105       string name = _vf->getName();
00106       if(name.empty())
00107       {
00108          name = n->getName();
00109          if(name.empty())
00110          {
00111             name = "unnammed";
00112          }
00113       }
00114 
00115       if(n->dim() == 3)
00116       {
00117          QGridLayout *grid = new QGridLayout(topLayout, 1, 1);
00118          grid->setAlignment(Qt::AlignLeft);      
00119          grid->addWidget(new QLabel(name.c_str(), this), 0, 0);
00120 
00121          _nvals = 1;
00122          _nums[0] = new QLabel("N/A",this,"probe val 0");
00123          _nums[0]->setFrameStyle( QFrame::Panel | QFrame::Sunken );
00124          grid->addWidget(_nums[0], 0, 1);
00125       }
00126       if(n->dim() == 4)
00127       {
00128          _nvals = n->dim(0);
00129          QGridLayout *grid = new QGridLayout(topLayout, 1, _nvals);
00130          grid->setAlignment(Qt::AlignLeft);      
00131          grid->addWidget(new QLabel(name.c_str(), this),0, 0);
00132 
00133          for(int i=0; i<_nvals; ++i)
00134          {
00135             _nums[i] = new QLabel("N/A",this,"probe val n");
00136             _nums[i]->setFrameStyle( QFrame::Panel | QFrame::Sunken );
00137             grid->addWidget(_nums[i], 0, i+1);
00138          }
00139       }
00140    }
00141 }
00142 
00143 

Send questions, comments, and bug reports to:
jmk