#include <ParamGroundModel.h>
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) ); }
DinverDCCore::ParamGroundModel::~ParamGroundModel | ( | ) | [virtual] |
void DinverDCCore::ParamGroundModel::addProfile | ( | ParamProfile * | profile | ) | [inline] |
Referenced by main(), ParamGroundModelWidget::paramGroundModel(), and Forward::setParamSpace().
{_profiles.append(profile);}
const ParamSpaceScript& DinverDCCore::ParamGroundModel::customConditions | ( | ) | const [inline] |
Referenced by ParamGroundModelWidget::setFrom().
{return _customConditions;}
ParamProfile * DinverDCCore::ParamGroundModel::find | ( | QString | shortName | ) |
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; }
bool DinverDCCore::ParamGroundModel::hasGradient | ( | ) | const |
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; }
int DinverDCCore::ParamGroundModel::nProfiles | ( | ) | const [inline] |
Referenced by ParamGroundModelWidget::setFrom().
{return _profiles.count();}
const Point& DinverDCCore::ParamGroundModel::position | ( | ) | const [inline] |
Referenced by DinverDCCore::TargetList2D::setParamProfiles().
{return _position;}
ParamProfile* DinverDCCore::ParamGroundModel::profile | ( | int | index | ) | [inline] |
Referenced by removeProfile(), and ParamGroundModelWidget::setFrom().
{return _profiles[index];}
void DinverDCCore::ParamGroundModel::removeProfile | ( | ParamProfile * | 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().
void DinverDCCore::ParamGroundModel::setPosition | ( | const Point & | p | ) | [inline] |
Referenced by main().
{_position=p;}
bool DinverDCCore::ParamGroundModel::toParameters | ( | RealSpace & | ps | ) | const |
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; }
void DinverDCCore::ParamGroundModel::updateFinalProfiles | ( | const GroundParameter * | from = 0 | ) |
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(); }
XMLMember DinverDCCore::ParamGroundModel::xml_member | ( | XML_MEMBER_ARGS | ) | [protected, virtual] |
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:
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); }
void DinverDCCore::ParamGroundModel::xml_polish | ( | XML_POLISH_ARGS | ) | [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References setDepthLinks().
{ Q_UNUSED(context); setDepthLinks(); }
bool DinverDCCore::ParamGroundModel::xml_setProperty | ( | XML_SETPROPERTY_ARGS | ) | [protected, virtual] |
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] |
Implements QGpCoreTools::XMLClass.
{return xmlParamGroundModelTag;}
void DinverDCCore::ParamGroundModel::xml_writeChildren | ( | XML_WRITECHILDREN_ARGS | ) | const [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References TRACE, and QGpCoreTools::XMLClass::xml_save().
void DinverDCCore::ParamGroundModel::xml_writeProperties | ( | XML_WRITECHILDREN_ARGS | ) | const [protected, virtual] |
References QGpCoreTools::Point::toString(), TRACE, and QGpCoreTools::XMLClass::writeProperty().
{ TRACE; Q_UNUSED(context); writeProperty(s, "position", _position.toString(20)); }
const QString DinverDCCore::ParamGroundModel::xmlParamGroundModelTag = "ParamGroundModel" [static, protected] |