All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Protected Member Functions | Static Protected Attributes
DinverDCCore::ParamGroundModel Class Reference

#include <ParamGroundModel.h>

Inheritance diagram for DinverDCCore::ParamGroundModel:
QGpCoreTools::XMLClass

List of all members.

Public Member Functions

void addProfile (ParamProfile *profile)
const ParamSpaceScriptcustomConditions () const
ParamProfilefind (QString shortName)
bool hasGradient () const
void initFinalProfiles ()
void insertLayer (ParamProfile *profile, int at, ParamLayer *layer)
bool isEmpty ()
int nProfiles () const
 ParamGroundModel ()
 ParamGroundModel (const ParamGroundModel &o)
 ParamGroundModel (Seismic1DModel *m)
const Pointposition () const
ParamProfileprofile (int index)
void removeProfile (ParamProfile *profile)
void setCustomConditions (const QString &t)
void setDepthLinks ()
void setPosition (const Point &p)
bool toParameters (RealSpace &ps) const
void updateFinalProfiles (const GroundParameter *from=0)
virtual ~ParamGroundModel ()

Protected Member Functions

virtual XMLMember xml_member (XML_MEMBER_ARGS)
virtual void xml_polish (XML_POLISH_ARGS)
virtual bool xml_setProperty (XML_SETPROPERTY_ARGS)
virtual const QString & xml_tagName () const
virtual void xml_writeChildren (XML_WRITECHILDREN_ARGS) const
virtual void xml_writeProperties (XML_WRITECHILDREN_ARGS) const

Static Protected Attributes

static const QString xmlParamGroundModelTag = "ParamGroundModel"

Constructor & Destructor Documentation

References TRACE.

{
  TRACE;
}

References setDepthLinks(), and TRACE.

  : XMLClass()
{
  TRACE;
  _customConditions=o._customConditions;
  _position=o._position;
  ProfileList::const_iterator it;
  for(it=o._profiles.begin();it!=o._profiles.end();++it) {
    _profiles.append(new ParamProfile( **it) );
  }
  setDepthLinks();
}

Build a parameterized model from m. All parameters are fixed.

References DinverDCCore::ParamProfile::addLayer(), DinverDCCore::ParamProfile::Condition, QGpCoreWave::Seismic1DModel::h(), QGpCoreWave::Seismic1DModel::layerCount(), DinverDCCore::ParamProfile::Param, QGpCoreWave::Seismic1DModel::rho(), QGpCoreWave::Seismic1DModel::slowP(), QGpCoreWave::Seismic1DModel::slowS(), QGpCoreTools::tr(), and TRACE.

{
  TRACE;
  ParamProfile * vp=new ParamProfile( "Vp", tr("Compression-wave velocity"), "m/s", 200, 5000,
                                              ParamProfile::Param, SimpleCondition::LessThan);
  _profiles.append(vp);
  ParamProfile * nu=new ParamProfile( "Nu", tr("Poisson's Ratio"), "", 0.2, 0.5,
                                              ParamProfile::Condition, SimpleCondition::GreaterThan);
  _profiles.append(nu);
  ParamProfile * vs=new ParamProfile( "Vs", tr("Shear-wave velocity"), "m/s", 150, 3500,
                                              ParamProfile::Param, SimpleCondition::LessThan);
  _profiles.append(vs);
  ParamProfile * rho=new ParamProfile( "Rho", tr("Density"), "kg/m3", 2000, 2000,
                                               ParamProfile::Param, SimpleCondition::LessThan);
  _profiles.append(rho);

  double d=0.0, v;
  for(int i=0; i<m->layerCount();i++) {
    if(i<m->layerCount()-1) d+=m->h(i);
    v=1.0/m->slowP(i);
    vp->addLayer(new ParamLayer(vp, i, v, v, vs) );
    v=1.0/m->slowS(i);
    vs->addLayer(new ParamLayer(vs, i, v, v, d, d) );
    v=m->rho(i);
    rho->addLayer(new ParamLayer(rho, i, v, v, vs) );
  }
  nu->addLayer(new ParamLayer(nu, 0, 0.2, 0.5, vs) );
}

References TRACE.

{
  TRACE;
  ProfileList::iterator it;
  for(it=_profiles.begin();it!=_profiles.end();++it) delete *it;
}

Member Function Documentation

Referenced by ParamGroundModelWidget::setFrom().

{return _customConditions;}

References TRACE.

Referenced by main(), Model2ParamReader::parse(), DinverDCCore::TargetList2D::setParamProfiles(), DinverDCCore::TargetList::setParamProfiles(), Forward::setParamSpace(), and ModelGenerator::setParamSpace().

{
  TRACE;
  ProfileList::iterator it;
  for(it=_profiles.begin();it!=_profiles.end();++it) {
    if((*it)->shortName()==shortName) return *it;
  }
  return 0;
}

References TRACE.

{
  TRACE;
  ProfileList::const_iterator it;
  for(it=_profiles.begin();it!=_profiles.end();++it) {
    if((*it)->hasGradient()) return true;
  }
  return false;
}

References TRACE.

Referenced by main(), and Forward::setParamSpace().

{
  TRACE;
  ProfileList::iterator it;
  for(it=_profiles.begin();it!=_profiles.end();++it) {
    (*it)->initFinalProfile();
  }
}
void DinverDCCore::ParamGroundModel::insertLayer ( ParamProfile profile,
int  at,
ParamLayer layer 
)

Inserts layer at index in profile. Layer indexes and depth links are properly updated.

References DinverDCCore::ParamProfile::insertLayer(), and TRACE.

{
  TRACE;
  profile->insertLayer(at, layer);
  // Update names of links
  ProfileList::iterator it;
  for(it=_profiles.begin();it!=_profiles.end();++it)
    (*it)->setDepthLinkNames();
}

References TRACE.

Referenced by DCPlugin::initForward(), and main().

{
  TRACE;
  if(_profiles.size()==0) return true;
  ProfileList::iterator it;
  for(it=_profiles.begin();it!=_profiles.end();++it) {
    if((*it)->nLayers()==0) return true;
  }
  return false;
}

Referenced by ParamGroundModelWidget::setFrom().

{return _profiles.count();}

Referenced by DinverDCCore::TargetList2D::setParamProfiles().

{return _position;}

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

{return _profiles[index];}

References profile(), and TRACE.

Referenced by Forward::setParamSpace().

{
  TRACE;
  int index=_profiles.indexOf(profile);
  if(index>-1) {
    _profiles.removeAt(index);
  }
  delete profile;
}
void DinverDCCore::ParamGroundModel::setCustomConditions ( const QString &  t) [inline]

Referenced by main(), and ParamGroundModelWidget::paramGroundModel().

{_customConditions.setText(t);}

References TRACE.

Referenced by ParamGroundModel(), and xml_polish().

{
  TRACE;
  LayerMap links;
  ProfileList::iterator it;
  // Collect all layers that can be linked (all except bottom half spaces)
  for(it=_profiles.begin();it!=_profiles.end();++it)
    (*it)->collectDepthLinks(links);
  for(it=_profiles.begin();it!=_profiles.end();++it)
    (*it)->setDepthLinks(links);
}
void DinverDCCore::ParamGroundModel::setPosition ( const Point p) [inline]

Referenced by main().

{_position=p;}

References DinverCore::ParamSpaceScript::apply(), and TRACE.

Referenced by main(), ModelGenerator::setParamSpace(), and Forward::setParamSpace().

{
  TRACE;
  LayerMap links;
  ProfileList::const_iterator it;
  // Collect all layers that can be linked (all except bottom half spaces)
  for(it=_profiles.begin();it!=_profiles.end();++it)
    (*it)->collectDepthLinks(links);
  // Add parameters and conditions to parameter space
  for(it=_profiles.begin();it!=_profiles.end();++it) {
    if(!(*it)->toParam(ps,links, this)) return false;
  }
  // Add conditions on depths generated by linked depths
  for(it=_profiles.begin();it!=_profiles.end();++it) (*it)->setLinkedDepth(ps);
  // Add custom conditions
  if( !_customConditions.apply(&ps) ) {
    return false;
  }

  return true;
}

Called routinely during inversion, it creates a curve for all profiles with the same sampling depths

References DinverDCCore::GroundParameter::count(), DinverDCCore::GroundParameter::Depth, DinverDCCore::ParamLayer::index(), DinverDCCore::GroundParameter::layer(), DinverDCCore::ParamLayer::profile(), DinverDCCore::ParamProfile::setFinalDepths(), DinverDCCore::ParamProfile::setFinalProfileAt(), DinverDCCore::ParamProfile::setFinalProfileDepths(), DinverDCCore::ParamProfile::setFinalProfileFrom(), DinverDCCore::GroundParameter::Thickness, TRACE, and DinverDCCore::GroundParameter::type().

Referenced by main(), ModelGenerator::valueChanged(), and Forward::valueChanged().

{
  TRACE;
  if(from) {
    switch (from->type()) {
    case GroundParameter::Depth:
    case GroundParameter::Thickness:
      for(int i=from->count()-1; i>=0; i-- ) {
        const ParamLayer * l=from->layer(i);
        l->profile()->setFinalDepths(l->index());
      }
      for(int i=from->count()-1; i>=0; i-- ) {
        const ParamLayer * l=from->layer(i);
        l->profile()->setFinalProfileDepths(l->index());
      }
      for(int i=from->count()-1; i>=0; i-- ) {
        const ParamLayer * l=from->layer(i);
        l->profile()->setFinalProfileFrom(l->index());
      }
      break;
    default:
      for(int i=from->count()-1; i>=0; i-- ) {
        const ParamLayer * l=from->layer(i);
        l->profile()->setFinalProfileAt(l->index());
      }
      break;
    }
  } else {
    ProfileList::iterator it;
    for(it=_profiles.begin();it!=_profiles.end();++it) {
      (*it)->setFinalDepths();
    }
    for(it=_profiles.begin();it!=_profiles.end();++it) {
      (*it)->setFinalProfileDepths();
    }
    for(it=_profiles.begin();it!=_profiles.end();++it) {
      (*it)->setFinalProfileFrom();
    }
  }
  resampleProfiles();
}

Re-implement this function to offer XML restore (children and properties) support to your class.

From tag and map (with contains the attibute value) return a unique identifier under the format of a XMLMember. XMLMember is initialized with 3 types of contructors:

  • An integer: id number of a property
  • A XMLClass * : a child of this object identified by tag
  • Default constructor: error, unknow child or property

Map of attributes can be inspected in this way (can be achived also in xml_setProperty()):

    static const QString tmp("childrenName");
    XMLRestoreAttributeIterator it=map.find(tmp);
    if(it!=map.end()) {
      // found attribute "childrenName"
    }

If the map of attributes is not used:

    Q_UNUSED(attributes);
    if(tag=="x1") return XMLMember(0);
    else if(tag=="y1") return XMLMember(1);
    else if(tag=="x2") return XMLMember(2);
    else if(tag=="y2") return XMLMember(3);
    else return XMLMember(XMLMember::Unknown);

Arithmetic operations + and - apply to XMLMember to avoid confusion of property id numbers between inherited objects. Offset 3 corresponds to the number of properties defined in this object.

    if(tag=="anInteger") return XMLMember(0);
    else if(tag=="aString") return XMLMember(1);
    else if(tag=="aDouble") return XMLMember(2);
    return AbstractLine::xml_member(tag, attributes, context)+3;

For the arguments of this function use Macro XML_MEMBER_ARGS.

Reimplemented from QGpCoreTools::XMLClass.

References TRACE.

{
  TRACE;
  Q_UNUSED(attributes)
  Q_UNUSED(context);
  if(tag=="ParamProfile") {
    ParamProfile * p=new ParamProfile;
    _profiles.append(p);
    return XMLMember(p);
  } else if(tag=="ParamSpaceScript") {
    return XMLMember(&_customConditions);
  } else if(tag=="ProfileCondition") {
    return XMLMember(new XMLGenericItem("ProfileCondition"), true);     // Kept for compatibility
  } else if(tag=="position") {
    return XMLMember(0);
  } else return XMLMember(XMLMember::Unknown);
}

Reimplemented from QGpCoreTools::XMLClass.

References setDepthLinks().

{
  Q_UNUSED(context);
  setDepthLinks();
}

Re-implement this function to offer XML restore properties support to your class.

From memberID set the corresponding property with value content. The map of attributes is given as a supplementary information (not useful in all cases).

For a general case:

  Q_UNUSED(attributes);
  double val=content.toDouble();
  switch (memberID) {
  case 0:
    _x1=val;
    return true;
  case 1:
    _y1=val;
    return true;
  case 2:
    _x2=val;
    return true;
  case 3:
    _y2=val;
    return true;
  default:
    return false;
  }

For classes inheriting other classes (see also xml_member())

  switch (memberID) {
  case 0:
    _anInteger=content.toString();
    return true;
  case 1:
    _aString=content.toInt();
    return true;
  case 2:
    _aDouble=content.toDouble();
    return true;
  default:
    return AbstractLine::xml_setProperty(memberID-3, map, content);

For the arguments of this function use Macro XML_SETPROPERTY_ARGS.

Reimplemented from QGpCoreTools::XMLClass.

References QGpCoreTools::Point::fromString(), and TRACE.

{
  TRACE;
  Q_UNUSED(tag)
  Q_UNUSED(attributes)
  Q_UNUSED(context);
  switch (memberID) {
  case 0: _position.fromString(content.toString()); return true;
  default: return false;
  }
}
virtual const QString& DinverDCCore::ParamGroundModel::xml_tagName ( ) const [inline, protected, virtual]

Reimplemented from QGpCoreTools::XMLClass.

References TRACE, and QGpCoreTools::XMLClass::xml_save().

{
  TRACE;
  ProfileList::const_iterator it;
  for(it=_profiles.begin();it!=_profiles.end();++it) (*it)->xml_save(s, context);
  _customConditions.xml_save(s, context);
}

References QGpCoreTools::Point::toString(), TRACE, and QGpCoreTools::XMLClass::writeProperty().

{
  TRACE;
  Q_UNUSED(context);
  writeProperty(s, "position", _position.toString(20));
}

Member Data Documentation

const QString DinverDCCore::ParamGroundModel::xmlParamGroundModelTag = "ParamGroundModel" [static, protected]

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