#include <ParamLayerWidget.h>
Public Slots | |
| bool | isSelected () |
| void | on_depthThickness_activated (int) |
| void | on_linkedTo_activated (int) |
| void | on_selected_clicked () |
| void | on_selected_toggled (bool) |
| void | on_shape_activated (int) |
| void | setCurrentLink (QString link) |
| void | setDHLinks (QStringList &links) |
| void | setFrom (ParamLayer *p) |
| void | setIndex (int index) |
| void | setLinksFrom (ParamLayer *p) |
| void | setProfile (ParamProfileWidget *p) |
Signals | |
| void | rangeEdited () |
| void | sizeChanged () |
| void | updateDHLinks () |
| void | wantToBeSelected () |
Public Member Functions | |
| int | index () |
| bool | isDepth () const |
| QString | name () |
| ParamLayer * | paramLayer (ParamProfile *profile) |
| ParamLayerWidget (QWidget *parent=0, Qt::WFlags fl=0) | |
| void | setEditable (bool e) |
| bool | tilted () const |
| ~ParamLayerWidget () | |
Protected Attributes | |
| int | _index |
| ParamProfileWidget * | _profile |
| ParamLayerWidget::ParamLayerWidget | ( | QWidget * | parent = 0, |
| Qt::WFlags | fl = 0 |
||
| ) |
References _index, _profile, rangeEdited(), sizeChanged(), and TRACE.
: QWidget(parent, fl)
{
TRACE;
setupUi(this);
_profile=0;
_index=-1;
QPalette palette;
palette.setColor(topLine->foregroundRole(), Qt::darkGray);
topLine->setPalette(palette);
middleLine->setPalette(palette);
connect(topParam, SIGNAL(rangeEdited()), this, SIGNAL(rangeEdited()) );
connect(bottomParam, SIGNAL(rangeEdited()), this, SIGNAL(rangeEdited()) );
connect(dhParam, SIGNAL(rangeEdited()), this, SIGNAL(rangeEdited()) );
connect(topParam, SIGNAL(rangeEdited()), this, SIGNAL(sizeChanged()) );
connect(bottomParam, SIGNAL(rangeEdited()), this, SIGNAL(sizeChanged()) );
connect(dhParam, SIGNAL(rangeEdited()), this, SIGNAL(sizeChanged()) );
}
| int ParamLayerWidget::index | ( | ) | [inline] |
References _index.
Referenced by ParamProfileWidget::moveDown_clicked(), ParamProfileWidget::moveUp_clicked(), and setIndex().
{return _index;}
| bool ParamLayerWidget::isDepth | ( | ) | const |
Referenced by paramLayer().
| bool ParamLayerWidget::isSelected | ( | ) | [slot] |
References TRACE.
Referenced by ParamProfileWidget::deleteLayer(), ParamProfileWidget::moveDown_clicked(), and ParamProfileWidget::moveUp_clicked().
{
TRACE;
return selected->isChecked();
}
| QString ParamLayerWidget::name | ( | ) |
References _index, _profile, ParamProfileWidget::shortName(), and TRACE.
Referenced by on_depthThickness_activated(), on_shape_activated(), setDHLinks(), setFrom(), and setIndex().
{
TRACE;
return ParamLayer::name(_profile->shortName(), _index);
}
| void ParamLayerWidget::on_depthThickness_activated | ( | int | ) | [slot] |
References _index, name(), and TRACE.
Referenced by setIndex(), and setProfile().
| void ParamLayerWidget::on_linkedTo_activated | ( | int | ) | [slot] |
References _index, _profile, ParamProfileWidget::nLayers(), and TRACE.
Referenced by setCurrentLink(), setIndex(), and setProfile().
| void ParamLayerWidget::on_selected_clicked | ( | ) | [slot] |
| void ParamLayerWidget::on_selected_toggled | ( | bool | ) | [slot] |
References TRACE, and wantToBeSelected().
{
TRACE;
if(selected->isChecked()) {
emit wantToBeSelected();
selected->blockSignals(true);
selected->setChecked(true);
selected->blockSignals(false);
}
}
| void ParamLayerWidget::on_shape_activated | ( | int | ) | [slot] |
References _index, _profile, MSG_ID, name(), ParamProfileWidget::nLayers(), sizeChanged(), and TRACE.
Referenced by setIndex(), and setProfile().
{
TRACE;
if(_profile && _index==_profile->nLayers()-1) {
if(shape->currentIndex()!=0)
Message::warning(MSG_ID, "Layer", "Nothing else than Uniform is accepted "
"for the bottom half-space.", Message::ok());
shape->setCurrentIndex(0);
}
if(shape->currentIndex() > 0) {
bottomParam->show();
topParam->pName->setText( "Top " + name() + ":" );
nSubLayersLabel->show();
nSubLayers->show();
} else {
bottomParam->hide();
topParam->pName->setText(name() + ":" );
nSubLayersLabel->hide();
nSubLayers->hide();
}
emit sizeChanged();
}
| ParamLayer * ParamLayerWidget::paramLayer | ( | ParamProfile * | profile | ) |
References _index, DinverDCCore::ParamLayer::bottomMinimumValue(), isDepth(), DinverDCCore::ParamLayer::minimumDepth(), DinverDCCore::ParamLayer::setBottomMaximumValue(), DinverDCCore::ParamLayer::setBottomMinimumValue(), DinverDCCore::ParamLayer::setDepth(), DinverDCCore::ParamLayer::setLastParamCondition(), DinverDCCore::ParamLayer::setLinkedTo(), DinverDCCore::ParamLayer::setMaximumDepth(), DinverDCCore::ParamLayer::setMinimumDepth(), DinverDCCore::ParamLayer::setNSubLayers(), DinverDCCore::ParamLayer::setShape(), DinverDCCore::ParamLayer::setTopMaximumValue(), DinverDCCore::ParamLayer::setTopMinimumValue(), DinverDCCore::ParamLayer::topMinimumValue(), and TRACE.
{
TRACE;
ParamLayer * layer=new ParamLayer(profile, _index);
switch (shape->currentIndex()) {
case 1: layer->setShape(ParamLayer::Linear); break;
case 2: layer->setShape(ParamLayer::LinearIncrease); break;
case 3: layer->setShape(ParamLayer::LinearDecrease); break;
case 4: layer->setShape(ParamLayer::PowerLaw); break;
default: layer->setShape(ParamLayer::Uniform); break;
}
layer->setLastParamCondition(lastParamCondition->isChecked());
layer->setNSubLayers(nSubLayers->value());
layer->setTopMinimumValue(topParam->pMin->value());
if(topParam->pFixed->isChecked())
layer->setTopMaximumValue(layer->topMinimumValue());
else
layer->setTopMaximumValue(topParam->pMax->value());
layer->setBottomMinimumValue(bottomParam->pMin->value());
if(bottomParam->pFixed->isChecked())
layer->setBottomMaximumValue(layer->bottomMinimumValue());
else
layer->setBottomMaximumValue(bottomParam->pMax->value());
layer->setLinkedTo(linkedTo->currentText());
layer->setDepth(isDepth());
layer->setMinimumDepth(dhParam->pMin->value());
if(dhParam->pFixed->isChecked())
layer->setMaximumDepth(layer->minimumDepth());
else
layer->setMaximumDepth(dhParam->pMax->value());
return layer;
}
| void ParamLayerWidget::rangeEdited | ( | ) | [signal] |
Referenced by ParamLayerWidget().
| void ParamLayerWidget::setCurrentLink | ( | QString | link | ) | [slot] |
References on_linkedTo_activated(), and TRACE.
Referenced by setDHLinks(), and setLinksFrom().
{
TRACE;
int n=linkedTo->count();
for(int i=0;i < n;i++ ) {
if(linkedTo->itemText(i)==link) {
linkedTo->setCurrentIndex(i);
on_linkedTo_activated(0);
return;
}
}
linkedTo->setCurrentIndex(0);
on_linkedTo_activated(0);
}
| void ParamLayerWidget::setDHLinks | ( | QStringList & | links | ) | [slot] |
Set the list of possible links only if the layer is already initialized (_iLayer>=0)
References _index, name(), setCurrentLink(), and TRACE.
{
TRACE;
if(_index==-1) return;
QString linkName=linkedTo->currentText();
linkedTo->blockSignals(true);
linkedTo->clear();
linkedTo->addItem( "Not linked" );
for(QStringList::Iterator it=links.begin();it!=links.end();++it) {
if(*it!=name()) linkedTo->addItem( *it);
}
linkedTo->blockSignals(false);
setCurrentLink(linkName);
}
| void ParamLayerWidget::setEditable | ( | bool | e | ) |
References TRACE.
{
TRACE;
selected->setEnabled(e);
shape->setEnabled(e);
lastParamCondition->setEnabled(e);
nSubLayers->setEnabled(e);
nSubLayersLabel->setEnabled(e);
linkedTo->setEnabled(e);
linkedToLabel->setEnabled(e);
depthThickness->setEnabled(e);
topParam->setEnabled(e);
bottomParam->setEnabled(e);
dhParam->setEnabled(e);
}
| void ParamLayerWidget::setFrom | ( | ParamLayer * | p | ) | [slot] |
References _index, _profile, DinverDCCore::ParamLayer::bottomMaximumValue(), DinverDCCore::ParamLayer::bottomMinimumValue(), ParamProfileWidget::defaultCondition(), DinverDCCore::ParamLayer::isDepth(), DinverDCCore::ParamLayer::isLastParamCondition(), DinverDCCore::ParamLayer::maximumDepth(), DinverDCCore::ParamLayer::minimumDepth(), name(), DinverDCCore::ParamLayer::nSubLayers(), DinverDCCore::ParamLayer::shape(), ParamProfileWidget::shortName(), str, DinverDCCore::ParamLayer::topMaximumValue(), DinverDCCore::ParamLayer::topMinimumValue(), and TRACE.
Referenced by ParamProfileWidget::setFrom().
{
TRACE;
QString str=name();
int iShape=0;
switch (p->shape()) {
case ParamLayer::Linear: iShape=1; break;
case ParamLayer::LinearIncrease: iShape=2; break;
case ParamLayer::LinearDecrease: iShape=3; break;
case ParamLayer::PowerLaw: iShape=4; break;
case ParamLayer::Uniform: iShape=0; break;
}
shape->setCurrentIndex(iShape);
if(_index>0) {
switch(_profile->defaultCondition()) {
case SimpleCondition::LessThan:
lastParamCondition->setText(( _profile->shortName() + "%1" ).arg(_index - 1) + " < " + str);
lastParamCondition->setChecked(p->isLastParamCondition());
lastParamCondition->show();
break;
case SimpleCondition::GreaterThan:
lastParamCondition->setText(( _profile->shortName() + "%1" ).arg(_index - 1) + " > " + str);
lastParamCondition->setChecked(p->isLastParamCondition());
lastParamCondition->show();
break;
case SimpleCondition::NoCondition:
lastParamCondition->setChecked(false);
lastParamCondition->hide();
}
}
nSubLayers->setValue(p->nSubLayers());
topParam->pMin->setValue(p->topMinimumValue());
topParam->pMax->setValue(p->topMaximumValue());
topParam->pFixed->setChecked(p->topMinimumValue()==p->topMaximumValue());
bottomParam->pMin->setValue(p->bottomMinimumValue());
bottomParam->pMax->setValue(p->bottomMaximumValue());
bottomParam->pFixed->setChecked(p->bottomMinimumValue()==p->bottomMaximumValue());
dhParam->pMin->setValue(p->minimumDepth());
dhParam->pMax->setValue(p->maximumDepth());
dhParam->pFixed->setChecked(p->minimumDepth()==p->maximumDepth());
depthThickness->setCurrentIndex(p->isDepth() ? 0 : 1);
}
| void ParamLayerWidget::setIndex | ( | int | index | ) | [slot] |
Call it every time the index of this layer may change (move up or down the layer)
References _index, _profile, ParamProfileWidget::defaultCondition(), index(), name(), ParamProfileWidget::nLayers(), on_depthThickness_activated(), on_linkedTo_activated(), on_shape_activated(), ParamProfileWidget::shortName(), str, TRACE, and updateDHLinks().
Referenced by ParamProfileWidget::addLayer(), ParamProfileWidget::createLayer(), ParamProfileWidget::moveDown_clicked(), and ParamProfileWidget::moveUp_clicked().
{
TRACE;
_index=index;
QString str=name();
topParam->pName->setText( "Top " + str + ":" );
bottomParam->pName->setText( "Bottom " + str + ":" );
if(index > 0) {
switch(_profile->defaultCondition()) {
case SimpleCondition::LessThan:
lastParamCondition->show();
lastParamCondition->setText(( _profile->shortName() + "%1" ).arg(index - 1) + " < " + str);
break;
case SimpleCondition::GreaterThan:
lastParamCondition->show();
lastParamCondition->setText(( _profile->shortName() + "%1" ).arg(index - 1) + " > " + str);
break;
case SimpleCondition::NoCondition:
lastParamCondition->setChecked(false);
lastParamCondition->hide();
break;
}
} else {
lastParamCondition->hide();
while(depthThickness->count()>1) depthThickness->removeItem(1);
depthThickness->setCurrentIndex(0);
}
on_linkedTo_activated(0);
on_depthThickness_activated(0);
if(_profile && _index==_profile->nLayers()-1) {
depthThickness->hide();
linkedTo->hide();
linkedToLabel->hide();
dhParam->hide();
} else {
depthThickness->show();
linkedTo->show();
linkedToLabel->show();
if(linkedTo->currentIndex()==0) {
dhParam->show();
}
}
on_shape_activated(0);
emit updateDHLinks();
}
| void ParamLayerWidget::setLinksFrom | ( | ParamLayer * | p | ) | [slot] |
References DinverDCCore::ParamLayer::linkedTo(), setCurrentLink(), and TRACE.
{
TRACE;
setCurrentLink(p->linkedTo());
}
| void ParamLayerWidget::setProfile | ( | ParamProfileWidget * | p | ) | [slot] |
Call it once to propagate profile information to this layer
References _profile, ParamProfileWidget::defaultMaximum(), ParamProfileWidget::defaultMinimum(), on_depthThickness_activated(), on_linkedTo_activated(), on_shape_activated(), TRACE, and ParamProfileWidget::unit().
Referenced by ParamProfileWidget::createLayer().
{
TRACE;
_profile=p;
if(_profile) {
topParam->pUnit->setText(p->unit());
topParam->pMin->setValue(p->defaultMinimum());
topParam->pMax->setValue(p->defaultMaximum());
bottomParam->pUnit->setText(p->unit());
bottomParam->pMin->setValue(p->defaultMinimum());
bottomParam->pMax->setValue(p->defaultMaximum());
if(p->defaultMinimum()==p->defaultMaximum()) {
topParam->pFixed->setChecked(true);
bottomParam->pFixed->setChecked(true);
}
}
dhParam->pUnit->setText( "m" );
dhParam->pMin->setValue(1.0);
dhParam->pMax->setValue(100.0);
on_shape_activated(0);
on_depthThickness_activated(0);
on_linkedTo_activated(0);
}
| void ParamLayerWidget::sizeChanged | ( | ) | [signal] |
Referenced by on_shape_activated(), and ParamLayerWidget().
| bool ParamLayerWidget::tilted | ( | ) | const |
| void ParamLayerWidget::updateDHLinks | ( | ) | [signal] |
Referenced by setIndex().
| void ParamLayerWidget::wantToBeSelected | ( | ) | [signal] |
Referenced by on_selected_toggled().
int ParamLayerWidget::_index [protected] |
Referenced by index(), isDepth(), name(), on_depthThickness_activated(), on_linkedTo_activated(), on_shape_activated(), paramLayer(), ParamLayerWidget(), setDHLinks(), setFrom(), setIndex(), and tilted().
ParamProfileWidget* ParamLayerWidget::_profile [protected] |
Referenced by name(), on_linkedTo_activated(), on_shape_activated(), ParamLayerWidget(), setFrom(), setIndex(), and setProfile().