#include <TimeWindowLayer.h>
Classes | |
| struct | XMLTimeWindowList |
Public Member Functions | |
| void | addTimeWindows (const SubSignalPool &subPool, TimeWindowList *l) |
| void | addTimeWindows (Signal *sig, TimeWindowList *l) |
| virtual Rect | boundingRect () const |
| void | clearTimeWindows () |
| void | setShowColors (bool b) |
| void | setSize (double s) |
| bool | showColors () const |
| double | size () const |
| TimeWindowLayer (AxisWindow *parent=0) | |
| TimeWindowLayer (SignalLayer *sig) | |
| virtual const QString & | xml_tagName () const |
| virtual | ~TimeWindowLayer () |
Static Public Attributes | |
| static const QString | xmlTimeWindowLayerTag = "TimeWindowLayer" |
Protected Member Functions | |
| virtual void | xml_layerPolish (XML_POLISH_ARGS) |
| virtual XMLMember | xml_member (XML_MEMBER_ARGS) |
| virtual bool | xml_setProperty (XML_SETPROPERTY_ARGS) |
| virtual void | xml_writeChildren (XML_WRITECHILDREN_ARGS) const |
| virtual void | xml_writeProperties (XML_WRITEPROPERTIES_ARGS) const |
Properties | |
| bool | showColors |
| double | size |
| GeopsyGui::TimeWindowLayer::TimeWindowLayer | ( | AxisWindow * | parent = 0 | ) |
References TRACE.
: GraphContentLayer(parent) { TRACE; _sig=0; _size=0.375; _showColors=false; _windowOwner=false; _xmlWindows=0; }
References SciFigs::GraphContentLayer::addReference(), and TRACE.
: GraphContentLayer(sig->graph()) { TRACE; _sig=sig; _sig->addReference(); _size=0.375; _showColors=false; _windowOwner=false; _xmlWindows=0; }
| GeopsyGui::TimeWindowLayer::~TimeWindowLayer | ( | ) | [virtual] |
References SciFigs::GraphContentLayer::removeReference(), and TRACE.
{
TRACE;
if(_windowOwner) {
for(QMap<Signal *, TimeWindowList *>::iterator it=_windows.begin(); it!=_windows.end(); it++) {
delete it.value();
}
}
if(_sig) {
_sig->removeReference();
}
delete _xmlWindows;
}
| void GeopsyGui::TimeWindowLayer::addTimeWindows | ( | const SubSignalPool & | subPool, |
| TimeWindowList * | l | ||
| ) |
For convenience, links all signals of subPool to time window list l
References GeopsyCore::SubSignalPool::begin(), GeopsyCore::SubSignalPool::end(), and TRACE.
Referenced by ManualPick::init(), ToolSpectrum::initStations(), ToolStructure::initStations(), ToolHV::initStations(), and ToolArrayBase::setTimeWindowLayer().
{
TRACE;
LayerLocker ll(this);
for(SubSignalPool::const_iterator it=subPool.begin(); it!=subPool.end(); it++) {
_windows.insert(*it, l);
}
}
| void GeopsyGui::TimeWindowLayer::addTimeWindows | ( | Signal * | sig, |
| TimeWindowList * | l | ||
| ) |
Links signal sig to time window list l
References TRACE.
{
TRACE;
LayerLocker ll(this);
_windows.insert(sig, l);
}
| Rect GeopsyGui::TimeWindowLayer::boundingRect | ( | ) | const [virtual] |
Implements SciFigs::GraphContentLayer.
References GeopsyGui::SignalLayer::boundingRect(), and TRACE.
{
TRACE;
if(_sig) {
return _sig->boundingRect();
} else {
return Rect();
}
}
References TRACE.
{
TRACE;
LayerLocker ll(this);
_windows.clear();
}
| void GeopsyGui::TimeWindowLayer::setShowColors | ( | bool | b | ) |
Referenced by FKTimeWindows::setTimeWindowLayer(), and MonoStation::AbstractTool::start().
| void GeopsyGui::TimeWindowLayer::setSize | ( | double | s | ) |
References TRACE.
{
TRACE;
LayerLocker ll(this);
_size=s;
}
| bool GeopsyGui::TimeWindowLayer::showColors | ( | ) | const [inline] |
{return _showColors;}
| double GeopsyGui::TimeWindowLayer::size | ( | ) | const [inline] |
{return _size;}
| void GeopsyGui::TimeWindowLayer::xml_layerPolish | ( | XML_POLISH_ARGS | ) | [protected, virtual] |
Reconstruct link to SignalLayer and identifies signal pointers.
Reimplemented from SciFigs::GraphContentLayer.
References SciFigs::GraphContentLayer::addReference(), GeopsyCore::SubSignalPool::at(), SciFigs::XMLSciFigs::data(), SciFigs::GraphContent::findLayer(), SciFigs::GraphContentLayer::graphContent(), GeopsyGui::SignalLayer::subPool(), and GeopsyGui::SignalLayer::xmlSignalLayerTag.
{
XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context);
if(scifigsContext->data() && _xmlWindows) {
_sig=qobject_cast<SignalLayer *>(graphContent()->findLayer(SignalLayer::xmlSignalLayerTag,
_xmlWindows->_signalLayerName));
if(_sig) {
const SubSignalPool * subPool=_sig->subPool();
for(QMap<int, TimeWindowList *>::iterator it=_xmlWindows->_windows.begin(); it!=_xmlWindows->_windows.end(); it++) {
int index=it.key();
if(index>=0 && index<subPool->count()) {
_windows.insert(subPool->at(index), it.value());
} else {
delete it.value();
}
}
_windowOwner=true;
_sig->addReference();
} else {
for(QMap<int, TimeWindowList *>::iterator it=_xmlWindows->_windows.begin(); it!=_xmlWindows->_windows.end(); it++) {
delete it.value();
}
}
delete _xmlWindows;
_xmlWindows=0;
}
}
| XMLMember GeopsyGui::TimeWindowLayer::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 SciFigs::GraphContentLayer.
References SciFigs::XMLSciFigs::data(), QGpCoreTools::endl(), SciFigs::XMLSciFigs::makeUp(), QGpCoreTools::tr(), and TRACE.
{
TRACE;
XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context);
if(scifigsContext->data()) {
if(tag=="TimeWindowList") {
const QString attID="signalIndex";
XMLRestoreAttributeIterator it=attributes.find(attID);
if(it!=attributes.end()) {
int signalIndex=it.value().toInt();
if(!_xmlWindows) {
_xmlWindows=new XMLTimeWindowList;
}
TimeWindowList * w=new TimeWindowList;
_xmlWindows->_windows.insert(signalIndex, w);
return XMLMember(w);
} else {
App::stream() << tr("Missing signal index attribute") << endl;
return XMLMember(XMLMember::Unknown);
}
} else if(tag=="signalLayerName") {
return XMLMember(0);
}
}
if(scifigsContext->makeUp()) {
if(tag=="size") {
return XMLMember(1);
} else if(tag=="showColors") {
return XMLMember(2);
}
}
return GraphContentLayer::xml_member(tag, attributes, context)+3;
}
| bool GeopsyGui::TimeWindowLayer::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 SciFigs::GraphContentLayer.
References TRACE.
{
TRACE;
switch (memberID) {
case 0:
if(!_xmlWindows) {
_xmlWindows=new XMLTimeWindowList;
}
_xmlWindows->_signalLayerName=content.toString();
return true;
case 1:
_size=content.toDouble();
return true;
case 2:
_showColors=content.toBool();
return true;
default:
return GraphContentLayer::xml_setProperty(memberID-3, tag, attributes, content, context);
}
}
| virtual const QString& GeopsyGui::TimeWindowLayer::xml_tagName | ( | ) | const [inline, virtual] |
Reimplemented from SciFigs::GraphContentLayer.
{return xmlTimeWindowLayerTag;}
| void GeopsyGui::TimeWindowLayer::xml_writeChildren | ( | XML_WRITECHILDREN_ARGS | ) | const [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References QGpCoreTools::XMLSaveAttributes::add(), GeopsyCore::SubSignalPool::at(), GeopsyCore::SubSignalPool::count(), SciFigs::XMLSciFigs::data(), GeopsyGui::SignalLayer::subPool(), TRACE, and QGpCoreTools::XMLSaveAttributes::value().
{
TRACE;
XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context);
if(_sig && scifigsContext->data()) {
const SubSignalPool * subPool=_sig->subPool();
if(subPool) {
XMLSaveAttributes att;
att.add("signalIndex");
QString& index=att.value(0);
int n=subPool->count();
QMap<Signal *, TimeWindowList *>::const_iterator it;
for(int i=0; i<n; i++) {
it=_windows.find(subPool->at(i));
if(it!=_windows.end()) {
index=QString::number(i);
it.value()->xml_save(s, context, att);
}
}
}
}
}
| void GeopsyGui::TimeWindowLayer::xml_writeProperties | ( | XML_WRITEPROPERTIES_ARGS | ) | const [protected, virtual] |
Reimplemented from SciFigs::GraphContentLayer.
References SciFigs::XMLSciFigs::data(), SciFigs::GraphContentLayer::objectName, TRACE, and QGpCoreTools::XMLClass::writeProperty().
{
TRACE;
XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context);
if(_sig && scifigsContext->data()) {
writeProperty(s, "signalLayerName", _sig->objectName());
}
writeProperty(s, "size", _size);
writeProperty(s, "showColors", _showColors);
}
const QString GeopsyGui::TimeWindowLayer::xmlTimeWindowLayerTag = "TimeWindowLayer" [static] |
bool GeopsyGui::TimeWindowLayer::showColors [read, write] |
double GeopsyGui::TimeWindowLayer::size [read, write] |