#include <ParamProfileWidget.h>
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; }
ParamLayerWidget * ParamProfileWidget::addLayer | ( | ) | [slot] |
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; }
SimpleCondition::Type ParamProfileWidget::defaultCondition | ( | ) | const [inline] |
References _defaultCondition.
Referenced by ParamLayerWidget::setFrom(), ParamLayerWidget::setIndex(), and setParam().
{return _defaultCondition;}
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;}
void ParamProfileWidget::deleteAllLayers | ( | ) | [slot] |
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(); }
void ParamProfileWidget::deleteLayer | ( | ) | [slot] |
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; } } }
QList< ParamLayerWidget * > ParamProfileWidget::interfaces | ( | ) |
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; }
QList< ParamLayerWidget * > ParamProfileWidget::layers | ( | ) |
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; }
void ParamProfileWidget::moveDown_clicked | ( | ) | [slot] |
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; } } }
void ParamProfileWidget::moveUp_clicked | ( | ) | [slot] |
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] |
References _nLayers.
Referenced by ParamLayerWidget::on_linkedTo_activated(), ParamLayerWidget::on_shape_activated(), and ParamLayerWidget::setIndex().
{return _nLayers;}
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; }
void ParamProfileWidget::rangeEdited | ( | ) | [signal] |
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); } }
void ParamProfileWidget::setEditable | ( | bool | e | ) |
References layers(), and TRACE.
Referenced by ParamGroundModelWidget::setEditable().
void ParamProfileWidget::setFrom | ( | ParamProfile * | p | ) | [slot] |
References _defaultCondition, _defaultMaximum, _defaultMinimum, _longName, _shortName, _type, _unit, createLayer(), DinverDCCore::ParamProfile::defaultCondition(), DinverDCCore::ParamProfile::defaultMaximum(), DinverDCCore::ParamProfile::defaultMinimum(), deleteAllLayers(), DinverDCCore::ParamProfile::layer(), DinverDCCore::ParamProfile::longName(), DinverDCCore::ParamProfile::nLayers(), ParamLayerWidget::setFrom(), DinverDCCore::ParamProfile::shortName(), TRACE, DinverDCCore::ParamProfile::type(), and DinverDCCore::ParamProfile::unit().
Referenced by ParamGroundModelWidget::setFrom().
{ TRACE; deleteAllLayers(); _shortName=p->shortName(); _longName=p->longName(); _unit=p->unit(); _defaultMinimum=p->defaultMinimum(); _defaultMaximum=p->defaultMaximum(); _defaultCondition=p->defaultCondition(); _type=p->type(); if(_unit.isEmpty()) { title->setText(_longName); } else { title->setText(_longName + " (" + _unit + ")" ); } int n=p->nLayers(); for(int i=0; i<n; i++ ) { ParamLayerWidget * layerW=createLayer(); layerW->setFrom(p->layer(i)); } }
void ParamProfileWidget::setLayerIndex | ( | ) | [slot] |
References _nLayers, layers(), and TRACE.
Referenced by deleteLayer(), and ParamGroundModelWidget::setFrom().
void ParamProfileWidget::setLinksFrom | ( | ParamProfile * | p | ) | [slot] |
References DinverDCCore::ParamProfile::layer(), layers(), DinverDCCore::ParamProfile::nLayers(), and TRACE.
Referenced by ParamGroundModelWidget::setFrom().
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 _shortName.
Referenced by ParamLayerWidget::name(), ParamLayerWidget::setFrom(), ParamLayerWidget::setIndex(), setParam(), and TargetListWidget::setParamProfiles().
{return _shortName;}
void ParamProfileWidget::sizeChanged | ( | ) | [signal] |
Referenced by addLayer(), createLayer(), deleteAllLayers(), and deleteLayer().
ParamProfile::Type ParamProfileWidget::type | ( | ) | [inline] |
const QString& ParamProfileWidget::unit | ( | ) | [inline] |
void ParamProfileWidget::unselectAll | ( | ) | [slot] |
References layers(), and TRACE.
Referenced by createLayer().
void ParamProfileWidget::updateDHLinks | ( | ) | [signal] |
Referenced by addLayer(), createLayer(), deleteAllLayers(), and deleteLayer().
Referenced by defaultCondition(), paramProfile(), ParamProfileWidget(), setFrom(), and setParam().
double ParamProfileWidget::_defaultMaximum [protected] |
Referenced by defaultMaximum(), paramProfile(), setFrom(), and setParam().
double ParamProfileWidget::_defaultMinimum [protected] |
Referenced by defaultMinimum(), paramProfile(), setFrom(), and setParam().
QVBoxLayout* ParamProfileWidget::_frameLayout [protected] |
Referenced by createLayer(), interfaces(), layers(), moveDown_clicked(), moveUp_clicked(), and ParamProfileWidget().
ParamGroundModelWidget* ParamProfileWidget::_groundModel [protected] |
Referenced by ParamProfileWidget().
QString ParamProfileWidget::_longName [protected] |
Referenced by paramProfile(), setFrom(), and setParam().
int ParamProfileWidget::_nLayers [protected] |
Referenced by addLayer(), createLayer(), deleteAllLayers(), deleteLayer(), moveDown_clicked(), moveUp_clicked(), nLayers(), ParamProfileWidget(), and setLayerIndex().
QString ParamProfileWidget::_shortName [protected] |
Referenced by paramProfile(), setFrom(), setParam(), and shortName().
ParamProfile::Type ParamProfileWidget::_type [protected] |
Referenced by paramProfile(), ParamProfileWidget(), setFrom(), setParam(), and type().
QString ParamProfileWidget::_unit [protected] |
Referenced by paramProfile(), setFrom(), setParam(), and unit().