Public Member Functions | Static Public Member Functions
Event Class Reference

Brief description of class still missing. More...

#include <Event.h>

List of all members.

Public Member Functions

 Event ()
QString id () const
double magnitude (bool &ok) const
void save (QTextStream &s, const QString &eventId)
void setId (QDir d, const QString &id)
void sortStations ()
Stationstation (const QString &name) const
Stationstation (int index) const
int stationCount () const
Station::Status status () const
 ~Event ()

Static Public Member Functions

static bool lessThan (const Event *e1, const Event *e2)
static void setSortIndex (int index)

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

Description of constructor still missing

References TRACE.

{
  TRACE;
}

Description of destructor still missing

References TRACE.

{
  TRACE;
  qDeleteAll(_stations);
}

Member Function Documentation

QString Event::id ( ) const [inline]
bool Event::lessThan ( const Event e1,
const Event e2 
) [static]

References QGpCoreTools::abs(), COMPARE_ITEMS, magnitude(), status(), and Station::statusToString().

Referenced by EventListModel::sort(), and sortStations().

{
  bool trueValue=_sortIndex>=0 ? true : false;
  switch(abs(_sortIndex)) {
  default: {
      QString v1=e1->_id;
      QString v2=e2->_id;
      COMPARE_ITEMS;
    }
  case 2: {
      bool ok1, ok2;
      double v1=e1->magnitude(ok1);
      double v2=e2->magnitude(ok2);
      if(ok1 && ok2) {
        COMPARE_ITEMS;
      } else if(ok1) {
        return trueValue;
      } else {
        return false;
      }
    }
    break;
  case 3: {
      QString v1=Station::statusToString(e1->status());
      QString v2=Station::statusToString(e2->status());
      COMPARE_ITEMS;
    }
  }
}
double Event::magnitude ( bool &  ok) const

References TRACE.

Referenced by EventListModel::data(), and lessThan().

{
  TRACE;
  for(QList<Station *>::const_iterator it=_stations.begin(); it!=_stations.end(); it++) {
    double m=(*it)->magnitude(ok);
    if(ok) {
      ok=true;
      return m;
    }
  }
  return 0.0;
}
void Event::save ( QTextStream &  s,
const QString &  eventId 
)

References QGpCoreTools::endl(), Station::name(), Station::status(), and Station::statusToString().

Referenced by EventListModel::save().

{
  for(QList<Station *>::const_iterator it=_stations.begin(); it!=_stations.end(); it++) {
    Station * stat=*it;
    s << eventId << "\t" << stat->name() << "\t" << Station::statusToString(stat->status()) << endl;
  }
}
void Event::setId ( QDir  d,
const QString &  id 
)

References Station::addComponent(), QGpCoreTools::endl(), QGpCoreTools::exp(), id(), Station::setName(), station(), QGpCoreTools::tr(), and TRACE.

Referenced by EventListModel::setBaseDirectory().

{
  TRACE;
  _id=id;
  App::stream() << tr("Event %1").arg(_id) << endl;
  d.cd(_id);
  QStringList filters;
  filters << "????.???.??.??.??.????.??.????.??.H??.?.SAC";
  QStringList files=d.entryList(filters, QDir::Files);
  QRegExp exp("[0-9]{4}\\.[0-9]{3}\\.[0-9]{2}\\.[0-9]{2}\\.[0-9]{2}\\.[0-9]{4}\\.[A-Z]{2}\\.([A-Z0-9]{4})\\.[0-9]{2}\\.HN(.)\\..\\.SAC");
  foreach(QString f, files) {
    if(!exp.exactMatch(f)) {
      App::stream() << tr("Recording file name does not match the standard pattern %1, skipping").arg(f) << endl;
    } else {
      QString statName=exp.cap(1);
      Station * s=station(statName);
      if(!s) {
        s=new Station;
        s->setName(exp.cap(1));
        _stations.append(s);
      }
      s->addComponent(exp.cap(2)[0], d.absoluteFilePath(f));
    }
  }
  for(int i=_stations.count()-1; i>=0; i--) {
    if(!_stations.at(i)->checkComponents()) {
      App::stream() << tr("!!  Station %1 skipped").arg(_stations.at(i)->name()) << endl;
      _stations.removeAt(i);
    }
  }
}
static void Event::setSortIndex ( int  index) [inline, static]

Referenced by EventListModel::sort().

{_sortIndex=index;}

References lessThan(), and TRACE.

Referenced by StationListModel::sort().

{
  TRACE;
  qStableSort(_stations.begin(), _stations.end(), Station::lessThan);
}
Station * Event::station ( const QString &  name) const

References TRACE.

Referenced by StationListModel::data(), EventListModel::load(), setId(), and StationListModel::station().

{
  TRACE;
  for(QList<Station *>::const_iterator it=_stations.begin(); it!=_stations.end(); it++) {
    if(name==(*it)->name()) {
      return *it;
    }
  }
  return 0;
}
Station* Event::station ( int  index) const [inline]
{return _stations.at(index);}
int Event::stationCount ( ) const [inline]

Referenced by StationListModel::rowCount().

{return _stations.count();}

References Station::Rejected, Station::ToSort, TRACE, Station::Unknown, and Station::Valid.

Referenced by EventListModel::data(), and lessThan().

{
  TRACE;
  Station::Status s=Station::Rejected;

  for(QList<Station *>::const_iterator it=_stations.begin(); it!=_stations.end(); it++) {
    switch((*it)->status()) {
    case Station::Unknown:
      break;
    case Station::ToSort:
      s=Station::ToSort;
      break;
    case Station::Valid:
      if(s!=Station::ToSort) {
        s=Station::Valid;
      }
      break;
    case Station::Rejected:
      break;
    }
  }
  return s;
}

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