Public Slots | Signals | Public Member Functions | Protected Attributes
ParamProfileWidget Class Reference

#include <ParamProfileWidget.h>

List of all members.

Public Slots

ParamLayerWidgetaddLayer ()
void deleteAllLayers ()
void deleteLayer ()
void moveDown_clicked ()
void moveUp_clicked ()
void setDHLinks (QList< ParamLayerWidget * > layerList)
void setFrom (ParamProfile *p)
void setLayerIndex ()
void setLinksFrom (ParamProfile *p)
void setParam (QString shortName, QString longName, QString unit, double defaultMinimum, double defaultMaximum, ParamProfile::Type type, SimpleCondition::Type defaultCondition)
void unselectAll ()

Signals

void rangeEdited ()
void sizeChanged ()
void updateDHLinks ()

Public Member Functions

ParamLayerWidgetcreateLayer ()
SimpleCondition::Type defaultCondition () const
double defaultMaximum () const
double defaultMinimum () const
QList< ParamLayerWidget * > interfaces ()
QList< ParamLayerWidget * > layers ()
int nLayers () const
ParamProfileparamProfile ()
 ParamProfileWidget (ParamGroundModelWidget *parent=0, Qt::WFlags fl=0)
void setEditable (bool e)
const QString & shortName ()
ParamProfile::Type type ()
const QString & unit ()
 ~ParamProfileWidget ()

Protected Attributes

SimpleCondition::Type _defaultCondition
double _defaultMaximum
double _defaultMinimum
QVBoxLayout * _frameLayout
ParamGroundModelWidget_groundModel
QString _longName
int _nLayers
QString _shortName
ParamProfile::Type _type
QString _unit

Constructor & Destructor Documentation

ParamProfileWidget::ParamProfileWidget ( ParamGroundModelWidget parent = 0,
Qt::WFlags  fl = 0 
)

References _defaultCondition, _frameLayout, _groundModel, _nLayers, _type, addLayer(), deleteLayer(), moveDown_clicked(), moveUp_clicked(), and TRACE.

    : QWidget(parent, fl)
{
  TRACE;
  setupUi(this);

  _frameLayout=new QVBoxLayout(frame);
  _frameLayout->setSpacing(1);
  _frameLayout->setMargin(1);
  // signals and slots connections
  connect(addLayerBut, SIGNAL(clicked()), this, SLOT(addLayer()) );
  connect(delLayerBut, SIGNAL(clicked()), this, SLOT(deleteLayer()) );
  connect(moveUp, SIGNAL(clicked()), this, SLOT(moveUp_clicked()) );
  connect(moveDown, SIGNAL(clicked()), this, SLOT(moveDown_clicked()) );
  _nLayers=0;
  _type=ParamProfile::Param;
  _defaultCondition=SimpleCondition::LessThan;
  _groundModel=parent;
}

References TRACE.

{
  TRACE;
  // no need to delete child widgets, Qt does it all for us
}

Member Function Documentation

References _nLayers, createLayer(), layers(), ParamLayerWidget::setIndex(), sizeChanged(), TRACE, and updateDHLinks().

Referenced by ParamProfileWidget().

{
  TRACE;
  QList<ParamLayerWidget *> objList=layers();
  ParamLayerWidget * lastLayer;
  if(objList.isEmpty()) lastLayer=0; else lastLayer=objList.last();
  ParamLayerWidget * p=createLayer();
  p->setIndex(_nLayers - 1);
  if(lastLayer) lastLayer->setIndex(_nLayers - 2);
  emit updateDHLinks();
  emit sizeChanged();
  return p;
}

References _frameLayout, _nLayers, rangeEdited(), ParamLayerWidget::setIndex(), ParamLayerWidget::setProfile(), sizeChanged(), TRACE, unselectAll(), and updateDHLinks().

Referenced by addLayer(), and setFrom().

{
  TRACE;
  ParamLayerWidget * p=new ParamLayerWidget;
  p->setProfile(this);
  connect(p, SIGNAL(sizeChanged()), this, SIGNAL(sizeChanged()));
  connect(p, SIGNAL(rangeEdited()), this, SIGNAL(rangeEdited()));
  connect(p, SIGNAL(wantToBeSelected()), this, SLOT(unselectAll()) );
  connect(p, SIGNAL(updateDHLinks()), this, SIGNAL(updateDHLinks()) );
  p->setIndex(_nLayers);
  _nLayers++;
  p->selected->setChecked(true);
  p->lastParamCondition->setChecked(true);
  _frameLayout->insertWidget(_nLayers, p);
  p->show();
  return p;
}
double ParamProfileWidget::defaultMaximum ( ) const [inline]

References _defaultMaximum.

Referenced by setParam(), and ParamLayerWidget::setProfile().

{return _defaultMaximum;}
double ParamProfileWidget::defaultMinimum ( ) const [inline]

References _defaultMinimum.

Referenced by setParam(), and ParamLayerWidget::setProfile().

{return _defaultMinimum;}

References _nLayers, layers(), sizeChanged(), TRACE, and updateDHLinks().

Referenced by setFrom().

{
  TRACE;
  QList<ParamLayerWidget *> objList=layers();
  for(int i=0;i<_nLayers;i++) delete objList.at(i);
  _nLayers=0;
  emit sizeChanged();
  emit updateDHLinks();
}

References _nLayers, ParamLayerWidget::isSelected(), layers(), setLayerIndex(), sizeChanged(), TRACE, and updateDHLinks().

Referenced by ParamProfileWidget().

{
  TRACE;
  QList<ParamLayerWidget *> objList=layers();
  ASSERT(objList.count()==_nLayers);
  for(int i=0;i<_nLayers;i++) {
    ParamLayerWidget * lw=objList.at(i);
    if(lw->isSelected()) {
      delete lw;
      _nLayers--;
      setLayerIndex();
      if(i== _nLayers) --i; else ++i;
      if(_nLayers>0) objList.at(i)->selected->setChecked(true);
      emit updateDHLinks();
      emit sizeChanged();
      break;
    }
  }
}

Return all layers exept the last one (bottom half space)

References _frameLayout.

Referenced by ParamGroundModelWidget::setDHLinks().

{
  QList<ParamLayerWidget *> objList;
  int n=_frameLayout->count()-1;
  for(int i=0; i<n; i++) {
    ParamLayerWidget * layer=qobject_cast<ParamLayerWidget *>(_frameLayout->itemAt(i)->widget());
    ASSERT(layer);
    objList << layer;
  }
  return objList;
}

Return all layers

References _frameLayout.

Referenced by addLayer(), deleteAllLayers(), deleteLayer(), paramProfile(), setDHLinks(), setEditable(), setLayerIndex(), setLinksFrom(), and unselectAll().

{
  QList<ParamLayerWidget *> objList;
  int n=_frameLayout->count();
  for(int i=0; i<n; i++) {
    ParamLayerWidget * layer=qobject_cast<ParamLayerWidget *>(_frameLayout->itemAt(i)->widget());
    ASSERT(layer);
    objList << layer;
  }
  return objList;
}

References _frameLayout, _nLayers, ParamLayerWidget::index(), ParamLayerWidget::isSelected(), ParamLayerWidget::setIndex(), and TRACE.

Referenced by ParamProfileWidget().

{
  TRACE;
  int n=_frameLayout->count();
  ASSERT(_nLayers==n);
  for(int i=_nLayers-2;i>=0;i--) {
    ParamLayerWidget * cur=qobject_cast<ParamLayerWidget *>(_frameLayout->itemAt(i)->widget());
    ASSERT(cur);
    if(cur->isSelected()) {
      ParamLayerWidget * down=qobject_cast<ParamLayerWidget *>(_frameLayout->itemAt(i+1)->widget());
      ASSERT(down);
      _frameLayout->removeWidget(cur);
      _frameLayout->removeWidget(down);
      _frameLayout->insertWidget(i, cur);
      _frameLayout->insertWidget(i, down);
      int curLayer=cur->index();
      cur->setIndex(down->index());
      down->setIndex(curLayer);
      break;
    }
  }
}

References _frameLayout, _nLayers, ParamLayerWidget::index(), ParamLayerWidget::isSelected(), ParamLayerWidget::setIndex(), and TRACE.

Referenced by ParamProfileWidget().

{
  TRACE;
  int n=_frameLayout->count();
  ASSERT(_nLayers==n);
  for(int i=0;i<_nLayers;i++) {
    ParamLayerWidget * cur=qobject_cast<ParamLayerWidget *>(_frameLayout->itemAt(i)->widget());
    ASSERT(cur);
    if(cur->isSelected() && i>0) {
      i--;
      ParamLayerWidget * up=qobject_cast<ParamLayerWidget *>(_frameLayout->itemAt(i)->widget());
      ASSERT(up);
      _frameLayout->removeWidget(cur);
      _frameLayout->removeWidget(up);
      _frameLayout->insertWidget(i, up);
      _frameLayout->insertWidget(i, cur);
      int curLayer=cur->index();
      cur->setIndex(up->index());
      up->setIndex(curLayer);
      break;
    }
  }
}
int ParamProfileWidget::nLayers ( ) const [inline]

Return the profile corresponding to this profile widget. The returned profile must be manually deleted.

References _defaultCondition, _defaultMaximum, _defaultMinimum, _longName, _shortName, _type, _unit, DinverDCCore::ParamProfile::addLayer(), layers(), and TRACE.

{
  TRACE;
  ParamProfile * p=new ParamProfile(_shortName, _longName, _unit, _defaultMinimum, _defaultMaximum,
                                             _type, _defaultCondition);
  QList<ParamLayerWidget *> objList=layers();
  ParamLayer * layer=0;
  for(QList<ParamLayerWidget *>::iterator it=objList.begin(); it!=objList.end();++it) {
    layer=( * it) ->paramLayer(p);
    p->addLayer(layer);
  }
  /* TODO: in my opinion useless because topDepthIndex() is still 0
  if(layer) {
    p->_raw.resize(layer->topDepthIndex()+1);
    if(p->type()==ParamProfile::Condition) p->_maxRaw.resize(layer->topDepthIndex()+1);
  }*/
  return p;
}

Referenced by createLayer().

void ParamProfileWidget::setDHLinks ( QList< ParamLayerWidget * >  layerList) [slot]

References layers(), and TRACE.

Referenced by ParamGroundModelWidget::setDHLinks().

{
  TRACE;
  QStringList links;
  for(QList<ParamLayerWidget *>::iterator it=layerList.begin(); it!=layerList.end();++it) {
    links.append((*it)->name());
  }
  QList<ParamLayerWidget *> objList=layers();
  for(QList<ParamLayerWidget *>::iterator it=objList.begin(); it!=objList.end();++it) {
    (*it)->setDHLinks(links);
  }
}

References layers(), and TRACE.

Referenced by ParamGroundModelWidget::setEditable().

{
  TRACE;
  addLayerBut->setEnabled(e);
  delLayerBut->setEnabled(e);
  moveUp->setEnabled(e);
  moveDown->setEnabled(e);
  QList<ParamLayerWidget *> objList=layers();
  for(QList<ParamLayerWidget *>::iterator it=objList.begin(); it!=objList.end();++it) {
    ( * it)->setEditable(e);
  }
}

References _nLayers, layers(), and TRACE.

Referenced by deleteLayer(), and ParamGroundModelWidget::setFrom().

{
  TRACE;
  QList<ParamLayerWidget *> objList=layers();
  for(int i=0;i<_nLayers;i++) {
    objList.at(i)->setIndex(i);
  }
}

References DinverDCCore::ParamProfile::layer(), layers(), DinverDCCore::ParamProfile::nLayers(), and TRACE.

Referenced by ParamGroundModelWidget::setFrom().

{
  TRACE;
  QList<ParamLayerWidget *> objList=layers();
  int n=objList.count();
  ASSERT(p->nLayers()==n);
  for(int i=0;i<n;i++) {
    objList.at(i)->setLinksFrom(p->layer(i));
  }
}
void ParamProfileWidget::setParam ( QString  shortName,
QString  longName,
QString  unit,
double  defaultMinimum,
double  defaultMaximum,
ParamProfile::Type  type,
SimpleCondition::Type  defaultCondition 
) [slot]

References _defaultCondition, _defaultMaximum, _defaultMinimum, _longName, _shortName, _type, _unit, defaultCondition(), defaultMaximum(), defaultMinimum(), shortName(), QGpCoreTools::tr(), TRACE, type(), and unit().

Referenced by TargetListWidget::setParamProfiles().

{
  TRACE;
  _shortName=shortName;
  _longName=longName;
  _unit=unit;
  _defaultMinimum=defaultMinimum;
  _defaultMaximum=defaultMaximum;
  QString tstr;
  if(_unit.isEmpty()) {
    tstr=_longName;
  } else {
    tstr=_longName + " (" + _unit + ")";
  }
  tstr+="\n";
  switch (type) {
  case ParamProfile::Param:
    tstr += tr("(Parameters)");
    break;
  case ParamProfile::Condition:
    tstr += tr("(Conditions)");
    break;
  }
  title->setText(tstr);
  _type=type;
  _defaultCondition=defaultCondition;
}
const QString& ParamProfileWidget::shortName ( ) [inline]

References _type.

Referenced by setParam().

{return _type;}
const QString& ParamProfileWidget::unit ( ) [inline]

References _unit.

Referenced by setParam(), and ParamLayerWidget::setProfile().

{return _unit;}

References layers(), and TRACE.

Referenced by createLayer().

{
  TRACE;
  QList<ParamLayerWidget *> objList=layers();
  for(QList<ParamLayerWidget *>::iterator it=objList.begin(); it!=objList.end();++it) {
    (*it)->selected->setChecked(false);
  }
}

Member Data Documentation

QVBoxLayout* ParamProfileWidget::_frameLayout [protected]

Referenced by ParamProfileWidget().

QString ParamProfileWidget::_longName [protected]

Referenced by paramProfile(), setFrom(), and setParam().

QString ParamProfileWidget::_shortName [protected]
QString ParamProfileWidget::_unit [protected]

Referenced by paramProfile(), setFrom(), setParam(), and unit().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines