Time pick vector for Signal. More...
#include <TimePick.h>
Public Member Functions | |
virtual void | addScriptProperties (SignalHeaderObject *sig) |
virtual QString | baseName (int) const |
virtual MetaData * | clone () const |
virtual int | compare (int subId, const QString &index, const MetaData *o) const |
virtual int | count (int subId) const |
virtual QVariant | data (int subId, const QString &index) const |
virtual const MetaData * | defaultValue () const |
virtual bool | fromString (const QString &index, QString string) |
virtual bool | hasIndex (int subId) const |
virtual bool | hasIndex (int subId, const QString &index) const |
virtual int | id () const |
virtual QStringList | indexList (int) const |
virtual QString | name (int, const QString &index) const |
QStringList | names () const |
virtual Number::Type | numberType (int subId) const |
virtual void | registerScriptTypes (QScriptEngine *engine) |
virtual bool | setData (int subId, const QString &index, const QVariant &val) |
virtual void | setId (int id) const |
void | setValue (const QString &name, double v) |
virtual QStringList | subNames () const |
TimePick () | |
TimePick (const TimePick &o) | |
virtual QString | title (int, const QString &index) const |
virtual QString | toString (const QString &index) const |
double | value (const QString &name) const |
virtual void | writeProperties (XMLStream &s) const |
virtual void | writeProperties (XMLStream &s, const XMLSaveAttributes &attributes) const |
virtual const QString & | xml_tagName () const |
Static Public Member Functions | |
static QString | nextPick (const QString &name) |
static int | pickIndex (const QString &name) |
static bool | pickLocked (const QString &name) |
static const QString & | pickName (int index) |
static QString | previousPick (const QString &name) |
static bool | registered (const QString &name) |
static QStringList | registeredNames () |
static void | renamePick (const QString &oldName, const QString &newName) |
static void | setPickLocked (const QString &name, bool l) |
static int | staticId () |
Static Public Attributes | |
static const QString | xmlTimePickTag = "TimePick" |
Time pick vector for Signal.
Optional meta data
GeopsyCore::TimePick::TimePick | ( | ) | [inline] |
{}
GeopsyCore::TimePick::TimePick | ( | const TimePick & | o | ) | [inline] |
: MetaData(), _values(o._values) {}
void GeopsyCore::TimePick::addScriptProperties | ( | SignalHeaderObject * | sig | ) | [virtual] |
Reimplemented from GeopsyCore::MetaData.
{
//sig->setProperty("timePick", QVariant::fromValue(TimePickSignal(sig)));
}
QString GeopsyCore::TimePick::baseName | ( | int | ) | const [virtual] |
virtual MetaData* GeopsyCore::TimePick::clone | ( | ) | const [inline, virtual] |
Implements GeopsyCore::MetaData.
{return new TimePick(*this);}
int GeopsyCore::TimePick::compare | ( | int | subId, |
const QString & | index, | ||
const MetaData * | o | ||
) | const [virtual] |
Reimplemented from GeopsyCore::MetaData.
References pickIndex(), registered(), and TRACE.
{ TRACE; Q_UNUSED(subId); const TimePick * otp=static_cast<const TimePick *>(o); if(registered(index)) { int i=pickIndex(index); if(_values[i]<otp->_values[i]) { return -1; } else if(_values[i]>otp->_values[i]) { return 1; } else { return 0; } } else { return 0; } }
virtual int GeopsyCore::TimePick::count | ( | int | subId | ) | const [inline, virtual] |
Reimplemented from GeopsyCore::MetaData.
Referenced by GeopsyCore::Signal::timePickCount().
{Q_UNUSED(subId); return _names.count();}
QVariant GeopsyCore::TimePick::data | ( | int | subId, |
const QString & | index | ||
) | const [virtual] |
Reimplemented from GeopsyCore::MetaData.
References pickIndex(), and registered().
{ Q_UNUSED(subId); if(registered(index)) { int i=pickIndex(index); return _values[i]; } else { return 0.0; } }
virtual const MetaData* GeopsyCore::TimePick::defaultValue | ( | ) | const [inline, virtual] |
Implements GeopsyCore::MetaData.
{return &_defaultValue;}
bool GeopsyCore::TimePick::fromString | ( | const QString & | index, |
QString | string | ||
) | [virtual] |
Reimplemented from GeopsyCore::MetaData.
References pickIndex(), and TRACE.
virtual bool GeopsyCore::TimePick::hasIndex | ( | int | subId | ) | const [inline, virtual] |
Reimplemented from GeopsyCore::MetaData.
Referenced by GeopsyCore::DuplicateRays::hasIndex().
{Q_UNUSED(subId); return true;}
bool GeopsyCore::TimePick::hasIndex | ( | int | subId, |
const QString & | index | ||
) | const [virtual] |
Reimplemented from GeopsyCore::MetaData.
References pickIndex(), and registered().
{ Q_UNUSED(subId); if(registered(index)) { int i=pickIndex(index); return _values.contains(i); } else { return false; } }
virtual int GeopsyCore::TimePick::id | ( | ) | const [inline, virtual] |
Implements GeopsyCore::MetaData.
{return _id;}
virtual QStringList GeopsyCore::TimePick::indexList | ( | int | ) | const [inline, virtual] |
Reimplemented from GeopsyCore::MetaData.
{return registeredNames();}
QString GeopsyCore::TimePick::name | ( | int | , |
const QString & | index | ||
) | const [virtual] |
Reimplemented from GeopsyCore::MetaData.
References xmlTimePickTag.
{ return xmlTimePickTag+"[\""+index+"\"]"; }
QStringList GeopsyCore::TimePick::names | ( | ) | const |
Returns the list of available pick names.
References TRACE.
Referenced by GeopsyCore::SubSignalPool::availableTimePicks(), GeopsyGui::PickLayer::paintData(), subNames(), and GeopsyCore::Signal::writeSeg2().
{ TRACE; QStringList l; for(QMap<int, double>::const_iterator it=_values.begin(); it!=_values.end(); it++) { l.append(_names[it.key()]); } return l; }
QString GeopsyCore::TimePick::nextPick | ( | const QString & | name | ) | [static] |
Returns the next pick name after name in alphabetical order.
References pickIndex(), pickName(), and TRACE.
{ TRACE; QMap<QString, int>::const_iterator it=_name2index.find(name); if(it!=_name2index.end()) { it++; if(it!=_name2index.end()) { return it.key(); } else { return _name2index.begin().key(); } } else { if(name.isEmpty()) { if(_name2index.isEmpty()) { return QString::null; } else { return _name2index.begin().key(); } } else { return pickName(pickIndex(name)); // force registration of this new name } } }
virtual Number::Type GeopsyCore::TimePick::numberType | ( | int | subId | ) | const [inline, virtual] |
Reimplemented from GeopsyCore::MetaData.
{Q_UNUSED(subId); return Number::Weeks;}
int GeopsyCore::TimePick::pickIndex | ( | const QString & | name | ) | [static] |
Used internally and by PickFormat. Prefer references by name.
References TRACE.
Referenced by compare(), data(), fromString(), hasIndex(), nextPick(), previousPick(), setData(), setValue(), toString(), and value().
bool GeopsyCore::TimePick::pickLocked | ( | const QString & | name | ) | [static] |
const QString & GeopsyCore::TimePick::pickName | ( | int | index | ) | [static] |
Used internally and by PickFormat. Prefer references by name.
References TRACE.
Referenced by nextPick(), and previousPick().
{ TRACE; ASSERT(index<_names.count() && index>=0); return _names.at(index); }
QString GeopsyCore::TimePick::previousPick | ( | const QString & | name | ) | [static] |
Returns the previous pick name before name in alphabetical order.
References GeopsyCore::MetaData::key(), pickIndex(), pickName(), and TRACE.
{ TRACE; QMap<QString, int>::const_iterator it=_name2index.find(name); if(it!=_name2index.end()) { it--; if(it!=_name2index.end()) { return it.key(); } else { return (--_name2index.end()).key(); } } else { if(name.isEmpty()) { if(_name2index.isEmpty()) { return QString::null; } else { return _name2index.begin().key(); } } else { return pickName(pickIndex(name)); // force registration of this new name } } }
static bool GeopsyCore::TimePick::registered | ( | const QString & | name | ) | [inline, static] |
Referenced by compare(), data(), hasIndex(), toString(), and GeopsyCore::Signal::writeSac().
{return _name2index.contains(name);}
static QStringList GeopsyCore::TimePick::registeredNames | ( | ) | [inline, static] |
Referenced by GeopsyCore::DuplicateRays::count(), and GeopsyCore::DuplicateRays::indexList().
{return _name2index.keys();}
void GeopsyCore::TimePick::registerScriptTypes | ( | QScriptEngine * | engine | ) | [virtual] |
Reimplemented from GeopsyCore::MetaData.
{
//qScriptRegisterMetaType<TimePickSignal>(engine, toScriptValue, fromScriptValue);
}
void GeopsyCore::TimePick::renamePick | ( | const QString & | oldName, |
const QString & | newName | ||
) | [static] |
References QGpCoreTools::endl(), QGpCoreTools::tr(), and TRACE.
{ TRACE; QMap<QString, int>::const_iterator it=_name2index.find(oldName); if(it!=_name2index.end()) { int index=it.value(); _name2index.remove(oldName); _name2index.insert(newName, index); _names[index]=newName; } else { App::stream() << tr("No pick named '%1', rename skipped.").arg(oldName) << endl; } }
bool GeopsyCore::TimePick::setData | ( | int | subId, |
const QString & | index, | ||
const QVariant & | val | ||
) | [virtual] |
Reimplemented from GeopsyCore::MetaData.
References pickIndex(), and TRACE.
virtual void GeopsyCore::TimePick::setId | ( | int | id | ) | const [inline, virtual] |
Implements GeopsyCore::MetaData.
{_id=id;}
void GeopsyCore::TimePick::setPickLocked | ( | const QString & | name, |
bool | l | ||
) | [static] |
void GeopsyCore::TimePick::setValue | ( | const QString & | name, |
double | v | ||
) |
References QGpCoreTools::endl(), pickIndex(), QGpCoreTools::tr(), and TRACE.
Referenced by GeopsyCore::Signal::setTimePick().
static int GeopsyCore::TimePick::staticId | ( | ) | [inline, static] |
Referenced by GeopsyCore::SubSignalPool::availableTimePicks(), GeopsyCore::DuplicateRays::hasIndex(), GeopsyCore::Signal::roundTimePick(), GeopsyCore::Signal::setTimePick(), GeopsyCore::Signal::timePick(), GeopsyCore::Signal::timePickCount(), GeopsyCore::Signal::writeSac(), and GeopsyCore::Signal::writeSeg2().
{return _id;}
QStringList GeopsyCore::TimePick::subNames | ( | ) | const [virtual] |
Reimplemented from GeopsyCore::MetaData.
References names(), and xmlTimePickTag.
{ QStringList names; names << xmlTimePickTag; return names; }
QString GeopsyCore::TimePick::title | ( | int | , |
const QString & | index | ||
) | const [virtual] |
Reimplemented from GeopsyCore::MetaData.
References QGpCoreTools::tr().
{ return tr("Pick[\"%1\"]").arg(index); }
QString GeopsyCore::TimePick::toString | ( | const QString & | index | ) | const [virtual] |
Reimplemented from GeopsyCore::MetaData.
References pickIndex(), registered(), and TRACE.
{ TRACE; if(registered(index)) { int i=pickIndex(index); QMap<int, double>::const_iterator it=_values.find(i); if(it!=_values.end()) { return QString::number(it.value(), 'g', 20); } } return "0.0"; }
double GeopsyCore::TimePick::value | ( | const QString & | name | ) | const |
References pickIndex(), and TRACE.
Referenced by GeopsyCore::Signal::roundTimePick(), GeopsyCore::Signal::timePick(), and writeProperties().
void GeopsyCore::TimePick::writeProperties | ( | XMLStream & | s | ) | const [virtual] |
Reimplemented from GeopsyCore::MetaData.
References QGpCoreTools::XMLSaveAttributes::add(), GeopsyCore::MetaData::key(), TRACE, value(), QGpCoreTools::XMLSaveAttributes::value(), QGpCoreTools::XMLClass::writeProperty(), and xml_tagName().
{ TRACE; static const QString key("index"); XMLSaveAttributes att; QString& value=att.add(key); for(QMap<int, double>::const_iterator it=_values.begin(); it!=_values.end(); it++) { value=_names.at(it.key()); writeProperty(s, xml_tagName(), att, it.value()); } }
void GeopsyCore::TimePick::writeProperties | ( | XMLStream & | s, |
const XMLSaveAttributes & | attributes | ||
) | const [virtual] |
Reimplemented from GeopsyCore::MetaData.
References QGpCoreTools::XMLSaveAttributes::add(), GeopsyCore::MetaData::key(), TRACE, value(), QGpCoreTools::XMLSaveAttributes::value(), QGpCoreTools::XMLClass::writeProperty(), and xml_tagName().
{ TRACE; static const QString key("index"); XMLSaveAttributes att(attributes); QString& value=att.add(key); for(QMap<int, double>::const_iterator it=_values.begin(); it!=_values.end(); it++) { value=_names.at(it.key()); writeProperty(s, xml_tagName(), att, it.value()); } }
virtual const QString& GeopsyCore::TimePick::xml_tagName | ( | ) | const [inline, virtual] |
const QString GeopsyCore::TimePick::xmlTimePickTag = "TimePick" [static] |
Referenced by baseName(), name(), and subNames().