Brief description of class still missing. More...
#include <ChronogramLayer.h>
Classes | |
| struct | StationRange |
Public Member Functions | |
| virtual void | addProperties (PropertyProxy *pp) |
| virtual Rect | boundingRect () const |
| ChronogramLayer (AxisWindow *parent=0) | |
| void | exportGaps (const QString &fileName) |
| virtual bool | hasProperties () |
| int | hitCount () const |
| QString | name (int index) const |
| virtual void | properties (PropertyWidget *w) const |
| void | rangeUpdate () |
| virtual void | removeProperties (PropertyProxy *pp) |
| SubSignalPool | selection () const |
| virtual void | setProperty (uint wid, int pid, QVariant val) |
| const SubSignalPool * | subPool () const |
| void | subPoolUpdate (SubSignalPool *subPool=0) |
| virtual bool | trackRectangle (int id, double rx1, double ry1, double rx2, double ry2, Qt::KeyboardModifiers m) |
| virtual const QString & | xml_tagName () const |
| ~ChronogramLayer () | |
Static Public Attributes | |
| static const QString | xmlChronogramLayerTag = "ChronogramLayer" |
Protected Member Functions | |
| virtual void | paintData (const LayerPainterRequest &lp, QPainter &p, double dotpercm) const |
| XMLMember | xml_member (XML_MEMBER_ARGS) |
| void | xml_polishChild (XML_POLISHCHILD_ARGS) |
| void | xml_writeChildren (XML_WRITECHILDREN_ARGS) const |
Brief description of class still missing.
Full description of class still missing
| GeopsyGui::ChronogramLayer::ChronogramLayer | ( | AxisWindow * | parent = 0 | ) |
Description of constructor still missing
References GeopsyCore::geopsyCore, and TRACE.
: GraphContentLayer(parent) { TRACE; // Required for viewing the layer in figue (through geopsyfigs plugin) if(!geopsyCore) { CoreApplication::addGlobalObject(new GeopsyGuiEngine); } _subPoolOwner=false; _minimumGap=0.0; _subPool=0; }
| void GeopsyGui::ChronogramLayer::addProperties | ( | PropertyProxy * | pp | ) | [virtual] |
Setup property editor
Reimplemented from SciFigs::GraphContentLayer.
References QGpGuiTools::PropertyProxy::addReference(), QGpGuiTools::PropertyProxy::addTab(), QGpGuiTools::PropertyProxy::currentTabWidget(), QGpGuiTools::PropertyProxy::setCurrentTab(), GeopsyGui::ChronogramProperties::setLayer(), QGpCoreTools::tr(), TRACE, and w.
{
TRACE;
if(pp->setCurrentTab(_tab)) {
ChronogramProperties * w=static_cast<ChronogramProperties *>(pp->currentTabWidget());
w->setLayer(this);
pp->addReference(this);
} else {
ChronogramProperties * w=new ChronogramProperties;
w->setLayer(this);
pp->addTab(_tab, tr("Chronogram"), w, this);
}
}
| Rect GeopsyGui::ChronogramLayer::boundingRect | ( | ) | const [virtual] |
Implements SciFigs::GraphContentLayer.
References GeopsyCore::StationSignals::maxTime(), GeopsyCore::StationSignals::minTime(), GeopsyCore::StationList::nComponents(), and TRACE.
Referenced by ChronogramWindow::setLimits().
{
TRACE;
if(_subPool) {
double minTime=1e99;
double maxTime=-1e99;
double t;
for(StationList::const_iterator it=_stations.begin();it!=_stations.end();it++) {
StationSignals * stat=*it;
t=stat->minTime();
if(t<minTime) minTime=t;
t=stat->maxTime();
if(t>maxTime) maxTime=t;
}
Rect r(minTime, 0.5, maxTime, _stations.nComponents()*_stations.count()+0.5);
return r;
} else {
return Rect();
}
}
| void GeopsyGui::ChronogramLayer::exportGaps | ( | const QString & | fileName | ) |
Export gaps from the visible window to fileName
References GeopsyCore::SparseTimeRange::add(), GeopsyCore::SubSignalPool::at(), GeopsyCore::Signal::componentUserName(), GeopsyCore::SubSignalPool::count(), GeopsyCore::TimeRange::end(), QGpCoreTools::endl(), GeopsyCore::SubSignalPool::first(), SciFigs::GraphContentLayer::graphContent(), GeopsyCore::SparseTimeRange::intersection(), GeopsyCore::SparseTimeRange::invert(), GeopsyCore::SubSignalPool::isEmpty(), GeopsyCore::TimeRange::lengthSeconds(), MSG_ID, GeopsyCore::StationSignals::name(), GeopsyCore::StationList::nComponents(), SciFigs::GraphContent::options(), GeopsyCore::StationSignals::originals(), GeopsyCore::SparseTimeRange::ranges(), GeopsyCore::SparseTimeRange::removeGaps(), GeopsyCore::TimeRange::start(), subPool(), GeopsyCore::Signal::timeRange(), QGpCoreTools::tr(), TRACE, SciFigs::GraphContentOptions::xVisMax(), and SciFigs::GraphContentOptions::xVisMin().
{
TRACE;
QFile f(fileName);
if(!f.open(QIODevice::WriteOnly)) {
Message::warning(MSG_ID, tr("Export gaps"), tr("Cannot write to file '%1'.").arg(fileName));
return;
}
QTextStream s(&f);
const GraphContentOptions& gc=graphContent()->options();
TimeRange gcLimits(gc.xVisMin(), gc.xVisMax());
s << tr("Gaps from %1 to %2").arg(Number::secondsToTime(gcLimits.start()))
.arg(Number::secondsToTime(gcLimits.end())) << endl;
s << tr("All gaps smaller than %1 seconds are ignored").arg(_minimumGap) << endl;
int nStations=_stations.count();
int nComp=_stations.nComponents();
for(int iStat=0;iStat<nStations;iStat++) {
StationSignals * stat=_stations.at(iStat);
s << tr("Station %1").arg(stat->name()) << endl;
for(int iComp=0;iComp<nComp;iComp++) {
const SubSignalPool& subPool=stat->originals(iComp);
if(!subPool.isEmpty()) {
s << tr(" Component %1").arg(subPool.first()->componentUserName()) << endl;
}
// Compute available range (green)
SparseTimeRange compRange;
int nSigs=subPool.count();
for(int iSig=0;iSig<nSigs;iSig++) {
compRange.add(subPool.at(iSig)->timeRange().intersection(gcLimits), false);
}
if(_minimumGap>0.0) {
compRange.removeGaps(_minimumGap);
}
// Compute non available range (red)
compRange=compRange.invert(gcLimits);
const QVector<TimeRange> rs=compRange.ranges();
int n=rs.count();
for(int i=0;i<n;i++) {
const TimeRange& r=rs.at(i);
s << tr(" %1 from %2 to %3")
.arg(Number::secondsToTime(r.lengthSeconds()))
.arg(Number::secondsToTime(r.start()))
.arg(Number::secondsToTime(r.end())) << endl;
}
}
}
}
| virtual bool GeopsyGui::ChronogramLayer::hasProperties | ( | ) | [inline, virtual] |
Reimplemented from SciFigs::GraphContentLayer.
{return true;}
| int GeopsyGui::ChronogramLayer::hitCount | ( | ) | const [inline] |
Referenced by ChronogramWindow::updateLabels().
{return _stations.count()*_stations.nComponents();}
| QString GeopsyGui::ChronogramLayer::name | ( | int | index | ) | const |
References GeopsyCore::StationList::component(), GeopsyCore::StationList::nComponents(), and TRACE.
Referenced by ChronogramWindow::updateLabels().
{
TRACE;
int nComp=_stations.nComponents();
int iStat=index/nComp;
int iComp=index-iStat*nComp;
QString compString=Signal::componentLetter(_stations.component(iComp));
return _stations.at(iStat)->name()+" "+compString;
}
| void GeopsyGui::ChronogramLayer::paintData | ( | const LayerPainterRequest & | lp, |
| QPainter & | p, | ||
| double | dotpercm | ||
| ) | const [protected, virtual] |
Implements SciFigs::GraphContentLayer.
References GeopsyCore::SparseTimeRange::intersection(), GeopsyCore::SparseTimeRange::invert(), SciFigs::LayerPainterRequest::options(), GeopsyCore::SparseTimeRange::remove(), GeopsyCore::SparseTimeRange::removeBlocks(), GeopsyCore::SparseTimeRange::removeGaps(), TRACE, SciFigs::GraphContentOptions::xVisMax(), and SciFigs::GraphContentOptions::xVisMin().
{
TRACE;
const GraphContentOptions& gc = lp.options();
TimeRange gcLimits(gc.xVisMin(), gc.xVisMax());
int n=_ranges.count();
for(int i=0; i<n; i++) {
const StationRange& r=_ranges.at(i);
// Draws unselected available range (light green)
SparseTimeRange t=r._available.intersection(gcLimits);
t.remove(r._selected);
t.removeGaps(_minimumGap);
drawRanges(gc, p, t, i+1, -0.45, -0.15, QColor(200, 255, 193, 128), QColor(152, 238, 77));
// Draws selected available range (dark green)
t=r._selected.intersection(gcLimits);
t.removeGaps(_minimumGap);
drawRanges(gc, p, t, i+1, -0.45, -0.15, QColor(103, 229, 87, 128), QColor(152, 238, 77));
// Draws non available range (red)
t=r._available.invert(gcLimits);
t.removeBlocks(_minimumGap);
drawRanges(gc, p, t, i+1, -0.15, 0.15, QColor(254, 156, 158, 128), QColor(255, 75, 78));
// Draws overlapping range (blue)
t=r._overlap.intersection(gcLimits);
t.removeBlocks(_minimumGap);
drawRanges(gc, p, t, i+1, 0.15, 0.45, QColor(158, 156, 254, 128), QColor(78, 75, 255));
}
}
| void GeopsyGui::ChronogramLayer::properties | ( | PropertyWidget * | w | ) | const [virtual] |
Reimplemented from SciFigs::GraphContentLayer.
References QGpGuiTools::PropertyWidget::id(), GeopsyGui::ChronogramProperties::MinimumGap, QGpGuiTools::PropertyWidget::setValue(), and TRACE.
{
TRACE;
if(w->id()==_tab) {
w->setValue(ChronogramProperties::MinimumGap, _minimumGap);
}
}
References GeopsyCore::Signal::add(), GeopsyCore::SubSignalPool::at(), GeopsyCore::SubSignalPool::count(), GeopsyCore::SparseTimeRange::intersection(), GeopsyCore::StationList::nComponents(), GeopsyCore::StationSignals::originals(), subPool(), GeopsyCore::Signal::timeRange(), and TRACE.
Referenced by ChronogramWindow::refreshSignal(), and subPoolUpdate().
{
TRACE;
_ranges.clear();
int nStations=_stations.count();
int nComp=_stations.nComponents();
for(int iStat=0; iStat<nStations; iStat++) {
StationSignals * stat=_stations.at(iStat);
for(int iComp=0; iComp<nComp; iComp++) {
const SubSignalPool& subPool=stat->originals(iComp);
StationRange ranges;
// Computes available range (green)
int nSigs=subPool.count();
for (int iSig=0; iSig<nSigs; iSig++) {
ranges._available.add(subPool.at(iSig)->timeRange(), false);
}
// Computes overlapping range (blue)
for (int iSig=1; iSig<nSigs; iSig++) {
Signal * sig0=subPool.at(iSig-1);
Signal * sig1=subPool.at(iSig);
ranges._overlap.add(sig0->timeRange().intersection(sig1->timeRange()));
}
_ranges.append(ranges);
}
}
}
| void GeopsyGui::ChronogramLayer::removeProperties | ( | PropertyProxy * | pp | ) | [virtual] |
Clean property editor
Reimplemented from SciFigs::GraphContentLayer.
References QGpGuiTools::PropertyProxy::removeTab().
{
pp->removeTab(_tab, this);
}
References GeopsyCore::SubSignalPool::addSignal(), GeopsyCore::SubSignalPool::at(), GeopsyCore::SubSignalPool::count(), GeopsyCore::StationList::nComponents(), GeopsyCore::StationSignals::originals(), subPool(), GeopsyCore::Signal::timeRange(), and TRACE.
Referenced by ChronogramWindow::getSelection().
{
TRACE;
SubSignalPool sel;
int nStations=_stations.count();
int nComp=_stations.nComponents();
int i=0;
for(int iStat=0; iStat<nStations; iStat++) {
StationSignals * stat=_stations.at(iStat);
for(int iComp=0; iComp<nComp; iComp++) {
const StationRange& r=_ranges.at(i);
const SubSignalPool& subPool=stat->originals(iComp);
// Computes available range (green)
int nSigs=subPool.count();
for (int iSig=0; iSig<nSigs; iSig++) {
Signal * sig=subPool.at(iSig);
if(r._selected.intersects(sig->timeRange())) {
sel.addSignal(sig);
}
}
i++;
}
}
return sel;
}
| void GeopsyGui::ChronogramLayer::setProperty | ( | uint | wid, |
| int | pid, | ||
| QVariant | val | ||
| ) | [virtual] |
Reimplemented from SciFigs::GraphContentLayer.
References SciFigs::GraphContentLayer::deepUpdate(), SciFigs::GraphContent::deepUpdate(), SciFigs::GraphContentLayer::graphContent(), GeopsyGui::ChronogramProperties::MinimumGap, and TRACE.
{
TRACE;
LayerLocker ll(this);
if(wid==_tab) {
switch(pid) {
case ChronogramProperties::MinimumGap:
_minimumGap=val.toDouble();
deepUpdate();
break;
default:
break;
}
}
graphContent()->deepUpdate();
}
| const SubSignalPool* GeopsyGui::ChronogramLayer::subPool | ( | ) | const [inline] |
Referenced by exportGaps(), rangeUpdate(), selection(), subPoolUpdate(), ChronogramWindow::updateLabels(), xml_polishChild(), and xml_writeChildren().
{return _subPool;}
| void GeopsyGui::ChronogramLayer::subPoolUpdate | ( | SubSignalPool * | subPool = 0 | ) |
References GeopsyCore::StationList::addSignals(), rangeUpdate(), subPool(), and TRACE.
Referenced by ChronogramWindow::subPoolUpdate(), and xml_polishChild().
{
TRACE;
LayerLocker ll(this);
if(subPool) {
_subPool=subPool;
_subPoolOwner=false;
}
qDeleteAll(_stations);
_stations.clear();
if(!_subPool) {
return;
}
StationSignals::organizeSubPool(_subPool);
if(_stations.addSignals(_subPool)) {
rangeUpdate();
} else {
qDeleteAll(_stations);
_stations.clear();
_subPool=0;
}
}
| bool GeopsyGui::ChronogramLayer::trackRectangle | ( | int | id, |
| double | rx1, | ||
| double | ry1, | ||
| double | rx2, | ||
| double | ry2, | ||
| Qt::KeyboardModifiers | m | ||
| ) | [virtual] |
Reimplemented from SciFigs::GraphContentLayer.
References CHRONOGRAMLAYER_TRACKING_ID, SciFigs::GraphContentLayer::deepUpdate(), and TRACE.
{
TRACE;
if(id!=CHRONOGRAMLAYER_TRACKING_ID) {
return false;
}
if(!(m & Qt::SHIFT)) {
for(int i=_ranges.count()-1; i>=0; i--) {
_ranges[i]._selected.clear();
}
}
// Get min and max Y indexes
if(ry1>ry2) {
std::swap(ry1, ry2);
}
int min=(int)ceil(ry1+0.15)-1;
if(min<0) {
min=0;
}
int max=(int)floor(ry2+0.45)-1;
if(max>=_ranges.count()) {
max=_ranges.count()-1;
}
TimeRange rect(rx1, rx2);
for(int i=min; i<=max; i++) {
StationRange& r=_ranges[i];
r._selected.add(r._available.hit(rect), true);
}
deepUpdate();
return true;
}
| XMLMember GeopsyGui::ChronogramLayer::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(), and TRACE.
{
TRACE;
Q_UNUSED(attributes);
XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context);
if(scifigsContext->data()) {
if(tag==XMLSubSignalPool::xmlSubSignalPoolTag) {
return XMLMember(new XMLSubSignalPool, true);
}
}
return GraphContentLayer::xml_member(tag, attributes, context);
}
| void GeopsyGui::ChronogramLayer::xml_polishChild | ( | XML_POLISHCHILD_ARGS | ) | [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References GeopsyCore::XMLSubSignalPool::subPool(), subPool(), subPoolUpdate(), and TRACE.
{
TRACE;
Q_UNUSED(context);
if(child->xml_tagName()==XMLSubSignalPool::xmlSubSignalPoolTag) {
XMLSubSignalPool * subPool=static_cast<XMLSubSignalPool *>(child);
if(_subPoolOwner) delete _subPool;
_subPool=subPool->subPool();
_subPoolOwner=true;
subPoolUpdate();
}
}
| virtual const QString& GeopsyGui::ChronogramLayer::xml_tagName | ( | ) | const [inline, virtual] |
Reimplemented from SciFigs::GraphContentLayer.
{return xmlChronogramLayerTag;}
| void GeopsyGui::ChronogramLayer::xml_writeChildren | ( | XML_WRITECHILDREN_ARGS | ) | const [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References SciFigs::XMLSciFigs::data(), subPool(), TRACE, and QGpCoreTools::XMLClass::xml_save().
{
TRACE;
XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context);
if(scifigsContext->data()) {
XMLSubSignalPool subPool(*_subPool);
subPool.xml_save(s, context);
}
GraphContentLayer::xml_writeChildren(s, context);
}
const QString GeopsyGui::ChronogramLayer::xmlChronogramLayerTag = "ChronogramLayer" [static] |