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

Brief description of class still missing. More...

#include <AutocorrCurves.h>

Inheritance diagram for QGpCoreWave::AutocorrCurves:
QGpCoreTools::XMLClass

List of all members.

Public Member Functions

void add (const AutocorrCurves &curves)
void addCurve (const ModalCurve &c)
void addRing ()
void addRing (const AutocorrRing &r)
const QList< ModalCurve > & curves () const
QList< ModalCurve > & curves ()
ModalCurve dispersionCurve (int index, double kmin, double kmax, int maxSolutionCount) const
int indexOf (const AutocorrRing &r) const
bool isEmpty () const
ModalCurvelastCurve ()
void removeRing (int index)
const AutocorrRingring (int index) const
AutocorrRingring (int index)
int ringCount () const
QList< ModalCurveringCurves (int index) const
const QVector< AutocorrRing > * rings () const
void sort ()
virtual const QString & xml_tagName () const

Static Public Attributes

static const QString xmlAutocorrCurvesTag = "AutocorrCurves"

Protected Member Functions

XMLMember xml_member (XML_MEMBER_ARGS)
void xml_writeChildren (XML_WRITECHILDREN_ARGS) const

Detailed Description

Brief description of class still missing.

Full description of class still missing


Member Function Documentation

Adds all curves and rings from c into this object. Common rings are smartly merged

References addRing(), QGpCoreTools::endl(), indexOf(), QGpCoreWave::ModalCurve::modes(), QGpCoreWave::ModalCurve::name(), ringCount(), QGpCoreTools::tr(), and TRACE.

Referenced by main().

{
  TRACE;
  for(QList<ModalCurve>::ConstIterator it=curves._curves.begin(); it!=curves._curves.end(); it++ ) {
    const ModalCurve& c=*it;
    int iCurvesRing=c.modes().first().ringIndex();
    if(iCurvesRing >= curves._rings.count()) {
      App::stream() << tr("Bad ring index for curve %1: %2 while max is %3").arg(c.name()).arg(iCurvesRing).arg(curves._rings.count()-1) << endl;
    } else {
      const AutocorrRing& r=curves._rings.at(iCurvesRing);
      int iRing=indexOf(r);
      if(iRing==-1) {
        iRing=ringCount();
        addRing(r);
      }
      _curves.append(c);
      QList<Mode>& modes=_curves.last().modes();
      for(QList<Mode>::Iterator it=modes.begin(); it!=modes.end(); it++ ) {
        it->setRingIndex(iRing);
      }
    }
  }
}

Adds a new curve. Make sure ring index fits with the number of rings. At least one ring must be available.

References QGpCoreTools::endl(), QGpCoreWave::ModalCurve::name(), QGpCoreTools::tr(), TRACE, and QGpCoreWave::Mode::Vertical.

Referenced by AutocorrTargetWidget::curves(), and SpacSelector::selectSamples().

{
  TRACE;
  ASSERT(_rings.count()>0);
  _curves.append(c);
  QList<Mode>& modes=_curves.last().modes();
  int iRing;
  if(modes.isEmpty()) {
    _curves.last().addMode(Mode( Mode::Vertical, 0, 0) );
    iRing=0;
  } else {
    iRing=modes.first().ringIndex();
    if(iRing < 0 || iRing >= _rings.count()) {
      App::stream() << tr("Bad ring index for curve %1: %2 while max is %3").arg(c.name()).arg(iRing).arg(_rings.count()-1) << endl;
    }
    for(QList<Mode>::Iterator it=modes.begin(); it!=modes.end(); it++ ) {
      it->setRingIndex(iRing);
    }
  }
}

Add one ring (for convenience)

References TRACE.

{
  TRACE;
  _rings.append(r);
}
const QList<ModalCurve>& QGpCoreWave::AutocorrCurves::curves ( ) const [inline]
{return _curves;}
ModalCurve QGpCoreWave::AutocorrCurves::dispersionCurve ( int  index,
double  kmin,
double  kmax,
int  maxSolutionCount 
) const

Calculate the dispersion curve corresponding to curve index. The solutions are searched between kmin and kmax. The returned curve may contain various values for the same frequency.

References QGpCoreWave::ModalCurve::addMode(), QGpCoreTools::Curve< pointType >::append(), QGpCoreTools::Curve< pointType >::at(), QGpCoreTools::Curve< pointType >::count(), QGpCoreWave::AutocorrDispersion::dispersion(), QGpCoreTools::StatisticalValue< numberType >::isValid(), QGpCoreWave::ModalCurve::modes(), QGpCoreWave::Mode::Phase, QGpCoreWave::Mode::Rayleigh, QGpCoreWave::AutocorrDispersion::setRing(), and QGpCoreTools::StatisticalPoint< numberType >::x().

Referenced by main().

{
  const ModalCurve& autocorr=_curves.at(index);
  int nx=autocorr.count();
  ModalCurve dispersion;
  AutocorrDispersion eng;
  eng.setRing(_rings.at(autocorr.modes().first().ringIndex()) );
  for(int ix=0; ix<nx; ix++ ) {
    const FactoryPoint& p=autocorr.at(ix);
    if(p.isValid()) {
      QVector<double> solutions=eng.dispersion(p, kmin, kmax);
      for(int i=0; i<solutions.count() && i<maxSolutionCount; i++) {
        dispersion.append(FactoryPoint( p.x(), solutions.at(i)));
      }
    }
  }
  dispersion.addMode(Mode( Mode::Phase, Mode::Rayleigh, 0) );
  return dispersion;
}
int QGpCoreWave::AutocorrCurves::indexOf ( const AutocorrRing r) const [inline]

Referenced by add().

{return _rings.indexOf(r);}
bool QGpCoreWave::AutocorrCurves::isEmpty ( ) const [inline]

References QGpCoreTools::Curve< pointType >::last().

{return _curves.last();}

Remove ring with index index

References TRACE.

{
  TRACE;
  _rings.remove(index);
}
const AutocorrRing& QGpCoreWave::AutocorrCurves::ring ( int  index) const [inline]
{return _rings[index];}
QList< ModalCurve > QGpCoreWave::AutocorrCurves::ringCurves ( int  index) const

References QGpCoreTools::Curve< pointType >::append(), and QGpCoreWave::ModalCurve::modes().

Referenced by AutocorrTargetWidget::addCurves(), SpacSelector::createObjects(), SpacSelector::inverse(), SpacSelector::inverseAt(), SpacSelector::selectSamples(), DinverDCGui::AutocorrViewer::setTarget(), DinverDCCore::TargetList::validateTargets(), and xml_writeChildren().

{
  QList<ModalCurve> l;
  for(QList<ModalCurve>::ConstIterator it=_curves.begin(); it!=_curves.end(); it++ ) {
    const ModalCurve& c=*it;
    if(c.modes().first().ringIndex()==index) {
      l.append(c);
    }
  }
  return l;
}

Referenced by DinverDCCore::AutocorrTarget::setCurves().

{
  for(QList<ModalCurve>::Iterator it=_curves.begin(); it!=_curves.end(); it++ ) {
    it->sort();
  }
}

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 addRing(), QGpCoreTools::endl(), QGpCoreTools::tr(), and TRACE.

{
  TRACE;
  Q_UNUSED(context);
  if(tag=="ModalCurve" ) {
    static const QString typeAtt("type");
    XMLRestoreAttributeIterator it=attributes.find(typeAtt);
    if(it!=attributes.end()) {
      if(it.value()=="autocorr") {
        _curves.append(ModalCurve());
        return XMLMember(&_curves.last());
      } else {
        App::stream() << tr("Wrong type of modal curve %1").arg(it.value().toString()) << endl;
        return XMLMember(XMLMember::Unknown);
      }
    } else {
      App::stream() << tr("No type defined for modal curve") << endl;
      return XMLMember(XMLMember::Unknown);
    }
  } else if(tag=="AutocorrRing") {
    addRing();
    return XMLMember(&_rings.last());
  } else return XMLMember(XMLMember::Unknown);
}
virtual const QString& QGpCoreWave::AutocorrCurves::xml_tagName ( ) const [inline, virtual]

Reimplemented from QGpCoreTools::XMLClass.

References QGpCoreTools::XMLSaveAttributes::add(), curves(), ringCurves(), and TRACE.

{
  TRACE;
  int nRings=_rings.count();
  static const QString key("type");
  static const QString value("autocorr");
  XMLSaveAttributes att;
  att.add(key, value);
  for(int iRing=0;iRing<nRings;iRing++ ) {
    _rings.at(iRing).xml_save(s, context);
    QList<ModalCurve> curves=ringCurves(iRing);
    for(QList<ModalCurve>::Iterator it=curves.begin(); it!=curves.end(); it++ ) {
      it->xml_save(s, context, att);
    }
  }
}

Member Data Documentation

const QString QGpCoreWave::AutocorrCurves::xmlAutocorrCurvesTag = "AutocorrCurves" [static]

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