Commit 156d52ad authored by Stephan Herrnkind's avatar Stephan Herrnkind
Browse files

added tag jakarta/2014.269.01

parent 306f692c
......@@ -142,9 +142,6 @@
/src/trunk/libs/3rd-party/spread/stdutil/src/*.lto
/src/trunk/libs/3rd-party/spread/stdutil/src/Makefile
# /src/trunk/libs/3rd-party/spread/stdutil/src/stdutil/
/src/trunk/libs/3rd-party/spread/stdutil/src/stdutil/
# /src/trunk/libs/3rd-party/spread/stdutil/src/stdutil/private/
/src/trunk/libs/3rd-party/spread/stdutil/src/stdutil/private/stdarch_autoconf.h
......
......@@ -62,7 +62,7 @@ copyright = u'2014, GFZ Potsdam, gempa GmbH'
# built documents.
#
# The short X.Y version.
version = '2014.248'
version = '2014.255'
# The full version, including alpha/beta/rc tags.
release = 'Jakarta'
......
SC_BEGIN_PACKAGE(ARCLINK)
SET(Boost_DETAILED_FAILURE_MSG ON)
FIND_PACKAGE(Boost REQUIRED COMPONENTS program_options thread filesystem iostreams regex)
IF (WIN32)
ADD_DEFINITIONS("-DBOOST_ALL_NO_LIB")
ADD_DEFINITIONS("-DBOOST_LIB_DIAGNOSTIC")
ENDIF (WIN32)
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
SUBDIRS(libs apps templates)
......@@ -26,8 +26,27 @@ using namespace Seiscomp;
#include "recordwidget.h"
namespace sc = Seiscomp::Core;
#define CHCK255(x) ((x)>255?255:((x)<0?0:(x)))
#define CHCK_RANGE \
double diff = _tmax - _tmin; \
if ( _tmin < sc::MinTime ) { \
_tmin = sc::MinTime; \
_tmax = _tmin + diff; \
} \
\
if ( _tmax > sc::MaxTime ) { \
_tmax = sc::MaxTime; \
_tmin = _tmax - diff; \
if ( _tmin < sc::MinTime ) { \
_tmin = sc::MinTime; \
diff = _tmax - _tmin; \
_pixelPerSecond = width() / diff; \
} \
} \
namespace {
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
......@@ -1414,6 +1433,7 @@ void RecordWidget::setTimeScale (double t) {
_pixelPerSecond = t;
_tmax = _tmin + (_pixelPerSecond > 0 && width()?width()/_pixelPerSecond:0);
CHCK_RANGE
if ( _autoMaxScale )
setNormalizationWindow(visibleTimeWindow());
else
......@@ -1453,6 +1473,8 @@ void RecordWidget::scroll(int v) {
void RecordWidget::setScale (double t, float a) {
_pixelPerSecond = t;
_tmax = _tmin + (_pixelPerSecond > 0 && width()?width()/_pixelPerSecond:0);
CHCK_RANGE
setAmplScale(a);
if ( _autoMaxScale )
......@@ -1472,6 +1494,7 @@ void RecordWidget::setTimeRange (double t1, double t2) {
_tmin = t1;
_tmax = _tmin + (_pixelPerSecond > 0 && width()?width()/_pixelPerSecond:0);
CHCK_RANGE
if ( _autoMaxScale )
setNormalizationWindow(visibleTimeWindow());
......
......@@ -10,12 +10,7 @@
* SeisComP Public License for more details. *
***************************************************************************/
#include <iostream>
#include <float.h>
#include <math.h>
#include "ruler.h"
#include <QFrame>
#include <QPixmap>
......@@ -25,7 +20,10 @@
#include <QEvent>
#include <QStyleOptionFocusRect>
#include "ruler.h"
#include <iostream>
#include <float.h>
#include <math.h>
#include <limits>
#define CHCK255(x) ((x)>255?255:((x)<0?0:(x)))
......@@ -37,6 +35,9 @@ Ruler::Ruler(QWidget *parent, Qt::WindowFlags f, Position pos)
setFrameStyle(QFrame::Panel | QFrame::Plain);
setLineWidth(0);
setPosition(pos);
setLimits(std::numeric_limits<double>::min(),
std::numeric_limits<double>::max(),
0, 0);
_scl = 1.;
_da = _dt = -1.;
_min = _max = 0.;
......@@ -93,6 +94,17 @@ void Ruler::setPosition(Position pos) {
void Ruler::setScale(double scl) {
_scl = scl;
// If the scale does not fit the configured min/max resolution
// the scale will be changed to a valid value
if ( _limitMinRange > 0 && _scl > rulerWidth() / _limitMinRange ) _scl = rulerWidth() / _limitMinRange;
if ( _limitMaxRange > 0 && _scl < rulerWidth() / _limitMaxRange ) {
double diff = _max - _min;
_min += diff / 2.0 - _limitMaxRange / 2.0;
_max = _min + _limitMaxRange;
_scl = rulerWidth() / _limitMaxRange;
}
emit scaleChanged(_scl);
updateIntervals();
update();
......@@ -360,7 +372,7 @@ void Ruler::paintEvent(QPaintEvent *e) {
// Draw ticks and counts
int rx = (int)((cpos-pos)*_scl);
QString str;
QVector<double> lastPos(_lc, -DBL_MAX);
QVector<double> lastPos(_lc, 0);
while ( rx < rw ) {
painter.drawLine(r2wPos(rx, 0), r2wPos(rx, tick));
if ( k == 0 ) {
......@@ -449,14 +461,14 @@ void Ruler::mouseReleaseEvent(QMouseEvent *e) {
double smax = (_pos+_rangemax) / _scl + _min;
if ( smin < smax )
emit rangeChangeRequested(smin, smax);
changeRange(smin, smax);
else {
std::swap(smin, smax);
double max = rulerWidth() / _scl + _min;
double s = (max-_min) / (smax-smin);
double tmin = s * (_min-smin) + _min;
double tmax = s * (max-smax) + max;
emit rangeChangeRequested(tmin, tmax);
changeRange(tmin, tmax);
}
}
_rangemin = _rangemax = 0;
......@@ -465,6 +477,45 @@ void Ruler::mouseReleaseEvent(QMouseEvent *e) {
}
}
void Ruler::checkLimit(double &tmin, double &tmax) {
tmin += _ofs;
tmax += _ofs;
double trange = tmax-tmin;
double tcen = tmin + trange*0.5;
// Clip to allowed ranges
if ( trange < _limitMinRange ) {
trange = _limitMinRange;
tmin = tcen - trange*0.5;
tmax = tcen + trange*0.5;
}
else if ( trange > _limitMaxRange ) {
trange = _limitMaxRange;
tmin = tcen - trange*0.5;
tmax = tcen + trange*0.5;
}
if ( (tmin < _limitLeft) || (tmax < _limitLeft) ) {
tmin = _limitLeft;
tmax = tmin + trange;
}
else if ( (tmin > _limitRight) || (tmax > _limitRight) ) {
tmax = _limitRight;
tmin = tmax - trange;
}
tmin -= _ofs;
tmax -= _ofs;
}
void Ruler::changeRange(double tmin, double tmax) {
checkLimit(tmin, tmax);
emit rangeChangeRequested(tmin, tmax);
}
void Ruler::mouseMoveEvent(QMouseEvent *e) {
if ( _dragMode == 0 ) {
if ( _enableSelection ) {
......@@ -505,9 +556,12 @@ void Ruler::mouseMoveEvent(QMouseEvent *e) {
double fDragOffset = double(dragOffset) / _scl;
_dragStart = p;
_iDragStart = rx;
emit dragged(fDragOffset);
double tmin = _min+fDragOffset;
double tmax = _max+fDragOffset;
checkLimit(tmin, tmax);
emit dragged(tmin-_min);
if ( _enableRangeSelection && _emitRangeChangeWhileDragging )
emit rangeChangeRequested(_min+fDragOffset, _max+fDragOffset);
emit rangeChangeRequested(tmin, tmax);
}
else if ( _dragMode == -2 ) {
_rangemax = rx < 0 ? 0 : rx >= rulerWidth() ? rulerWidth()-1 : rx;
......@@ -552,12 +606,12 @@ void Ruler::wheelEvent(QWheelEvent *event) {
QPoint rp = w2rPos(event->x(), event->y());
double center = (double)(rp.x() + _pos) / rulerWidth();
double ofs = delta / _scl;
emit rangeChangeRequested(_min + ofs * center, _max - ofs * (1-center));
changeRange(_min + ofs * center, _max - ofs * (1-center));
}
// translate
else {
double ofs = delta / _scl;
emit rangeChangeRequested(_min + ofs, _max + ofs);
changeRange(_min + ofs, _max + ofs);
}
event->accept();
......@@ -610,5 +664,12 @@ void Ruler::updateIntervals() {
emit changedInterval(_drx[0], _drx[1], _ofs);
}
void Ruler::setLimits(double leftValue, double rightValue, double minRange, double maxRange) {
_limitLeft = leftValue;
_limitRight = rightValue;
_limitMinRange = minRange;
_limitMaxRange = maxRange;
}
} // ns Gui
} // ns Seiscomp
......@@ -34,6 +34,7 @@ class SC_GUI_API Ruler : public QFrame
void setPosition(Position);
void setRange(double, double);
void setLimits(double leftValue, double rightValue, double minRange, double maxRange);
void setScale(double);
bool setSelected(double, double);
bool setSelectionHandle(int handle, double pos);
......@@ -135,14 +136,19 @@ class SC_GUI_API Ruler : public QFrame
const QString &text, bool allowClip = false,
bool allowRotate = false) const;
void checkLimit(double &tmin, double &tmax);
void changeRange(double tmin, double tmax);
protected:
Position _position;
double _ofs;
double _scl,
_min, _max, // ruler range
_da, // annotation interval
_dt; // tick mark interval
_min, _max, // ruler range
_da, // annotation interval
_dt, // tick mark interval
_limitLeft, _limitRight,
_limitMinRange, _limitMaxRange;
int _pos, _tickLong, _tickShort, _lc;
QVector<double> _selectionHandles;
int _currentSelectionHandle;
......
......@@ -23,6 +23,7 @@
#include "timescale.h"
#include <seiscomp3/core/exceptions.h>
namespace Seiscomp {
namespace Gui {
......@@ -32,6 +33,7 @@ TimeScale::TimeScale(QWidget *parent, Qt::WindowFlags f, Position pos)
: Ruler(parent, f, pos) {
_showAbsoluteValues = false;
_showAbsoluteDate= false;
setLimits(Seiscomp::Core::MinTime, Seiscomp::Core::MaxTime, 0.001, 315360000.0);
}
......@@ -132,24 +134,35 @@ bool TimeScale::getTickText(double pos, double lastPos,
if ( !_showAbsoluteValues )
return Ruler::getTickText(pos, lastPos, line, str);
// Fixed floating point precision error
pos += 0.0005;
if ( line == 0 ) {
Seiscomp::Core::Time time(pos);
if ( !time.valid() ) return false;
str = time.toString(_primaryTimeFormat).c_str();
return true;
try {
Seiscomp::Core::Time time(pos);
if ( !time.valid() ) return false;
str = time.toString(_primaryTimeFormat).c_str();
return true;
}
catch ( const Core::OverflowException&) { return false; }
}
if ( line == 1 && _showAbsoluteDate ) {
Seiscomp::Core::Time time(pos);
if ( time.valid() ) {
std::string timeStr = time.toString(_secondaryTimeFormat);
Seiscomp::Core::Time prevTime(lastPos);
if ( !prevTime.valid() ||
prevTime.toString(_secondaryTimeFormat) != timeStr ) {
str = timeStr.c_str();
return true;
try {
Seiscomp::Core::Time time(pos);
if ( time.valid() ) {
std::string timeStr = time.toString(_secondaryTimeFormat);
Seiscomp::Core::Time prevTime(lastPos);
if ( !prevTime.valid() ||
prevTime.toString(_secondaryTimeFormat) != timeStr ) {
str = timeStr.c_str();
return true;
}
}
}
catch ( const Core::OverflowException&) { return false; }
}
return false;
......
......@@ -16,9 +16,9 @@
#include <seiscomp3/gui/datamodel/eventedit.h>
#include <seiscomp3/gui/datamodel/originsymbol.h>
#include <seiscomp3/gui/datamodel/publicobjectevaluator.h>
#include <seiscomp3/gui/datamodel/tensorsymbol.h>
#include <seiscomp3/gui/core/application.h>
#include <seiscomp3/gui/core/utils.h>
#include <seiscomp3/gui/map/projection.h>
#include <seiscomp3/core/system.h>
#include <seiscomp3/datamodel/journalentry.h>
......@@ -312,16 +312,469 @@ QString axisToString(const Axis &a) {
}
double subGeo(double a, double b) {
double s = a - b;
if ( s < -180 )
s += 360;
else if ( s > 180 )
s -= 360;
return s;
}
QSize FMDefaultSize = QSize(32, 32);
QSize FMSelectedSize = QSize(40, 40);
} // namespace anonymous
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ExtTensorSymbol::ExtTensorSymbol(const Math::Tensor2Sd &t,
const FocalMechanism *fm,
Map::Decorator* decorator)
: TensorSymbol(t, decorator) {
if ( !fm ) return;
// agencyID + created
try {
_agency = fm->creationInfo().agencyID().c_str();
_created = fm->creationInfo().creationTime();
}
catch (Seiscomp::Core::ValueException &) {}
if ( !fm->momentTensorCount() ) return;
MomentTensor *mt = fm->momentTensor(0);
if ( _agency.isEmpty() ) {
try { _agency = mt->creationInfo().agencyID().c_str(); }
catch (Seiscomp::Core::ValueException &) {}
}
if ( !_created ) {
try { _created = mt->creationInfo().creationTime(); }
catch (Seiscomp::Core::ValueException &) {}
}
Origin *o = Origin::Find(mt->derivedOriginID());
Magnitude *m = Magnitude::Find(mt->momentMagnitudeID());
// depth
if ( o ) {
try { _depth = QString("%1 km").arg(o->depth().value(), 0, 'f', 0); }
catch (Seiscomp::Core::ValueException &) {}
}
// magnitude
if ( m ) {
_magnitude = QString("%1 %2")
.arg(m->type().empty() ? "M" : m->type().c_str())
.arg(m->magnitude().value(), 0, 'f', 1);
}
_selected = false;
_refPosEnabled = false;
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void ExtTensorSymbol::customDraw(const Map::Canvas *c, QPainter &p) {
p.save();
if ( size() != _lastSize ) {
_lastSize = size();
resize(_lastSize.width(), _lastSize.height());
}
QPoint symbolPos;
if ( _refPosEnabled ) {
c->projection()->project(symbolPos, _refPos);
symbolPos += _offset;
QColor color = _selected ? Qt::black : QColor(64, 64, 64);
p.setPen(QPen(color, 1, _selected ? Qt::SolidLine : Qt::DashLine));
p.drawLine(_mapPosition, symbolPos);
p.setPen(color);
p.setBrush(QBrush(color));
p.drawEllipse(_mapPosition, 2, 2);
}
else
symbolPos = _mapPosition;
p.drawImage(symbolPos - QPoint(_size.width()/2, _size.height()/2), _buffer);
// draw label
QString text;
int lines = 0;
int width = 0;
QFont f = SCScheme.fonts.smaller;
QFontMetrics fm(f);
if ( _drawAgency && !_agency.isEmpty() ) {
text += _agency;
++lines;
width = fm.width(_agency);
}
if ( _drawMagnitude && !_magnitude.isEmpty() ) {
if ( !text.isEmpty() ) text += "\n";
text += _magnitude;
++lines;
width = max(width, fm.width(_magnitude));
}
if ( _drawDepth && !_depth.isEmpty() ) {
if ( !text.isEmpty() ) text += "\n";
text += _depth;
++lines;
width = max(width, fm.width(_depth));
}
if ( lines ) {
p.setFont(f);
p.setBrush(QColor(255, 255, 255, 192));
p.setPen(Qt::black);
int margin = 4;
QRect r(0, 0, width + 2*margin, lines * fm.height() + margin);
p.translate(symbolPos - QPoint(r.width()/2, -FMDefaultSize.height()/2 - margin));
p.drawRect(r);
p.drawText(r, text, QTextOption(Qt::AlignCenter));
}
p.restore();
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
FMMap::~FMMap() {
QSettings settings;
settings.beginGroup("FocalMechanismMap");
settings.setValue("tensorDrawAgency", _drawAgency);
settings.setValue("tensorDrawMagnitude", _drawMagnitude);
settings.setValue("tensorDrawDepth", _drawDepth);
settings.setValue("tensorSmartLayout", _smartLayout);
settings.setValue("tensorGroupByAgency", _groupByAgency);
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void FMMap::draw(QPainter& p) {
if ( _smartLayout && _smartLayoutDirty && _originSymbol ) {
_smartLayoutDirty = false;
int items = 0;
for ( FMSymbols::iterator it = _fmSymbols.begin();
it != _fmSymbols.end(); ++it ) {
if ( it->second->isVisible() ) ++items;
}
QSize itemSize(1.7*FMDefaultSize.width(), 3*FMDefaultSize.height());
int xItems = items < 4 ? 0 : 2;
int yItems = 0;
int i = -1;
int x, y;
for ( FMSymbols::iterator it = _fmSymbols.begin();
it != _fmSymbols.end(); ++it ) {
if ( !it->second->isVisible() ) continue;
if ( i < 0 || i >= 2*xItems + 2*yItems ) {
i = 0;
xItems += 2; yItems += 2;
x = -xItems / 2; y = yItems / 2;
}
else if ( i <= xItems ) ++x;
else if ( i <= xItems + yItems ) --y;
else if ( i <= 2*xItems + yItems ) --x;
else ++y;
it->second->setOffset(QPoint(x * itemSize.width(), y * itemSize.height()));
++i;
}
}
MapWidget::draw(p);
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void FMMap::init() {
_originSymbol = NULL;
QSettings settings;
settings.beginGroup("FocalMechanismMap");
_drawAgency = settings.value("tensorDrawAgency", false).toBool();
_drawMagnitude = settings.value("tensorDrawMagnitude", false).toBool();
_drawDepth = settings.value("tensorDrawDepth", false).toBool();
_smartLayout = settings.value("tensorSmartLayout", false).toBool();
_groupByAgency = settings.value("tensorGroupByAgency", false).toBool();
_smartLayoutDirty = false;
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void FMMap::addFM(const DataModel::FocalMechanism *fm) {
Origin *o = NULL;
MomentTensor *mt = NULL;
if ( fm->momentTensorCount() > 0 ) {
mt = fm->momentTensor(0);
o = Origin::Find(mt->derivedOriginID());
}
if ( !o )
o = Origin::Find(fm->triggeringOriginID());
const NodalPlane *np = NULL;
try { np = &(fm->nodalPlanes().nodalPlane1()); }
catch ( Core::ValueException& ) {}
if ( !o || !np ) return;
QColor c = Qt::black;
try {
if ( o->depth() < 50 )
c = Qt::red;