Files
2025/include/seiscomp/gui/datamodel/eventlistview.h

346 lines
11 KiB
C++

/***************************************************************************
* Copyright (C) gempa GmbH *
* All rights reserved. *
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
* *
* GNU Affero General Public License Usage *
* This file may be used under the terms of the GNU Affero *
* Public License version 3.0 as published by the Free Software Foundation *
* and appearing in the file LICENSE included in the packaging of this *
* file. Please review the following information to ensure the GNU Affero *
* Public License version 3.0 requirements will be met: *
* https://www.gnu.org/licenses/agpl-3.0.html. *
* *
* Other Usage *
* Alternatively, this file may be used in accordance with the terms and *
* conditions contained in a signed written agreement between you and *
* gempa GmbH. *
***************************************************************************/
#ifndef SEISCOMP_GUI_EVENTLISTVIEW_H
#define SEISCOMP_GUI_EVENTLISTVIEW_H
#include <seiscomp/gui/core/connectiondialog.h>
#include <seiscomp/gui/core/utils.h>
#include <seiscomp/gui/qt.h>
#include <seiscomp/datamodel/databasequery.h>
#include <seiscomp/datamodel/station.h>
#include <seiscomp/datamodel/eventparameters_package.h>
#ifndef Q_MOC_RUN
#include <seiscomp/core/timewindow.h>
#include <seiscomp/geo/boundingbox.h>
#endif
#include <QWidget>
// Ui forward declarations
class QTreeWidget;
class QTreeWidgetItem;
namespace Ui {
class EventListView;
class EventListViewRegionFilterDialog;
}
namespace Seiscomp {
namespace Client {
DEFINE_SMARTPOINTER(Connection);
}
namespace Geo {
DEFINE_SMARTPOINTER(GeoFeature);
}
namespace Gui {
namespace Private {
class EventTreeItem;
class OriginTreeItem;
class FocalMechanismTreeItem;
class EventFilterWidget;
}
class CommandMessage;
class EventListViewPrivate;
class SC_GUI_API EventListView : public QWidget {
Q_OBJECT
// ------------------------------------------------------------------
// Public types
// ------------------------------------------------------------------
public:
typedef QMap<QString, DataModel::StationPtr> StationMap;
struct Filter {
Filter(const Seiscomp::Core::TimeWindow& tw = Seiscomp::Core::TimeWindow())
: startTime(tw.startTime()), endTime(tw.endTime()) {}
Seiscomp::Core::Time startTime;
Seiscomp::Core::Time endTime;
OPT(float) minLatitude, maxLatitude;
OPT(float) minLongitude, maxLongitude;
OPT(float) minDepth, maxDepth;
OPT(float) minMagnitude, maxMagnitude;
OPT(int) minPhaseCount, maxPhaseCount;
std::string eventID;
bool isNull() const;
};
struct Region {
QString name;
Geo::GeoBoundingBox bbox;
const Geo::GeoFeature *poly{nullptr};
};
using FilterRegions = QList<Region>;
// ------------------------------------------------------------------
// X'truction
// ------------------------------------------------------------------
public:
EventListView(Seiscomp::DataModel::DatabaseQuery* reader,
bool withOrigins = true, bool withFocalMechanisms = false,
QWidget * parent = 0, Qt::WindowFlags f = Qt::WindowFlags());
~EventListView();
public:
void setRelativeMinimumEventTime(const Seiscomp::Core::TimeSpan&);
void add(Seiscomp::DataModel::Event* event,
Seiscomp::DataModel::Origin* origin);
//! Sets the usage of messaging to notify about new objects or updates.
//! When disabled a local EventParameters instance is searched for and
//! all updates and adds are applied to this instance.
void setMessagingEnabled(bool);
void setEventModificationsEnabled(bool);
void setSortingEnabled(bool);
void moveSection(int, int);
void setControlsHidden(bool);
void setCustomControls(QWidget*) const;
void setFMLinkEnabled(bool);
QList<Seiscomp::DataModel::Event*> selectedEvents();
QTreeWidget *eventTree();
static Seiscomp::DataModel::Event *eventFromTreeItem(QTreeWidgetItem *item);
int eventCount() const;
//! \since 15.0.0
int visibleEventCount() const;
signals:
void originAdded();
void focalMechanismAdded();
void originSelected(Seiscomp::DataModel::Origin*,
Seiscomp::DataModel::Event* = nullptr);
void originUpdated(Seiscomp::DataModel::Origin*);
void focalMechanismSelected(Seiscomp::DataModel::FocalMechanism*,
Seiscomp::DataModel::Event* = nullptr);
void focalMechanismUpdated(Seiscomp::DataModel::FocalMechanism*);
void eventSelected(Seiscomp::DataModel::Event*);
void eventFMSelected(Seiscomp::DataModel::Event*);
void originReferenceAdded(const std::string &, Seiscomp::DataModel::OriginReference*);
//! Emitted when the event list is cleared
void reset();
void eventAddedToList(Seiscomp::DataModel::Event*, bool fromNotification);
void eventUpdatedInList(Seiscomp::DataModel::Event*);
void eventRemovedFromList(Seiscomp::DataModel::Event*);
//! \since 15.0.0
void visibleEventCountChanged();
//! Emitted when a bigger update process has finished, such as show/hide
//! of a subset of events.
void eventsUpdated();
public slots:
void setAutoSelect(bool);
void onCommand(Seiscomp::Gui::CommandMessage* cmsg);
void messageAvailable(Seiscomp::Core::Message*, Seiscomp::Client::Packet*);
void notifierAvailable(Seiscomp::DataModel::Notifier*);
void updateOrigin(Seiscomp::DataModel::Origin* origin);
void insertOrigin(Seiscomp::DataModel::Origin* origin,
Seiscomp::DataModel::Event* baseEvent,
const Seiscomp::Gui::ObjectChangeList<Seiscomp::DataModel::Pick>&,
const std::vector<Seiscomp::DataModel::AmplitudePtr>&);
void updateFocalMechanism(Seiscomp::DataModel::FocalMechanism *fm);
void insertFocalMechanism(Seiscomp::DataModel::FocalMechanism *fm,
Seiscomp::DataModel::Event *event,
Seiscomp::DataModel::Origin *origin = 0);
void setInterval(const Seiscomp::Core::TimeWindow&);
void selectFirstEnabledEvent();
void selectEvent(int index);
void selectEventID(const std::string& publicID);
/**
* @brief Activates the previous visible event.
* This is similar to selecting the event before (visually below) the
* current event in the list.
*/
void setPreviousEvent();
/**
* @brief Activates the next visible event.
* This is similar to selecting the event after (visually above) the
* current event in the list.
*/
void setNextEvent();
void readFromDatabase();
void readFromDatabase(const Seiscomp::Gui::EventListView::Filter&);
void clear();
void clearDatabaseFilter();
void selectEventFM(const QString &);
protected slots:
void itemSelected(QTreeWidgetItem*,int);
void itemPressed(QTreeWidgetItem*,int);
void copyRowToClipboard();
void readLastDays();
void readInterval();
void onShowOtherEvents(int checked);
void onShowForeignEvents(int checked);
void onHideOutsideRegion(int checked);
void onHideFinalRejectedEvents(int checked);
void onHideNewEvents(int checked);
void onFilterRegionModeChanged(int mode);
void updateAgencyState();
private slots:
void sortItems(int);
void headerContextMenuRequested(const QPoint &);
void waitDialogDestroyed(QObject *o);
void regionSelectionChanged(int index);
void changeRegion();
void itemEntered(QTreeWidgetItem *item, int);
void itemExpanded(QTreeWidgetItem * item);
void currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
void indicatorResized(const QSize &size);
void evalResultAvailable(const QString &publicID,
const QString &className,
const QString &script,
const QString &result);
void evalResultError(const QString &publicID,
const QString &className,
const QString &script,
int error);
//! \since 17.0.0
void updateOTimeAgo();
protected:
bool eventFilter(QObject *obj, QEvent *event);
private:
void initTree();
Private::EventTreeItem* addEvent(Seiscomp::DataModel::Event*, bool fromNotification);
Private::OriginTreeItem* addOrigin(Seiscomp::DataModel::Origin*, QTreeWidgetItem* parent, bool highPriority);
Private::FocalMechanismTreeItem* addFocalMechanism(Seiscomp::DataModel::FocalMechanism*, QTreeWidgetItem* parent);
Private::EventTreeItem* findEvent(const std::string&);
Private::OriginTreeItem* findOrigin(const std::string&);
Private::FocalMechanismTreeItem* findFocalMechanism(const std::string&);
void removeExpiredEvents();
void updateHideState();
bool updateHideState(QTreeWidgetItem *item);
void updateOriginProcessColumns(QTreeWidgetItem *item, bool highPriority);
void updateEventProcessColumns(QTreeWidgetItem *item, bool highPriority);
bool sendJournalAndWait(const std::string &objectID,
const std::string &action,
const std::string &params, const char *group);
void loadItem(QTreeWidgetItem*);
//! \since 17.0.0
void updateOTimeAgoTimer();
private:
EventListViewPrivate *_d_ptr;
};
class SC_GUI_API EventListViewRegionFilterDialog : public QDialog {
Q_OBJECT
// ------------------------------------------------------------------
// X'truction
// ------------------------------------------------------------------
public:
EventListViewRegionFilterDialog(QWidget *parent, EventListView::Region *target,
EventListView::FilterRegions *regionList);
~EventListViewRegionFilterDialog();
// ------------------------------------------------------------------
// QDialog interface
// ------------------------------------------------------------------
public:
virtual void accept();
// ------------------------------------------------------------------
// Slots
// ------------------------------------------------------------------
private slots:
void regionSelectionChanged(int idx);
void showError(const QString &);
// ------------------------------------------------------------------
// Private members
// ------------------------------------------------------------------
private:
::Ui::EventListViewRegionFilterDialog *_ui;
EventListView::Region *_target;
EventListView::FilterRegions *_regionList;
};
}
}
#endif