pqAnnotationsModel.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqAnnotationsModel_h
5 #define pqAnnotationsModel_h
6 
7 #include "pqCoreModule.h"
8 
9 #include "vtkParaViewDeprecation.h" // for PARAVIEW_DEPRECATED_IN_5_12_0
10 #include "vtkSmartPointer.h"
11 
12 #include <QAbstractTableModel>
13 #include <QColor>
14 #include <QIcon>
15 
16 #include <vector>
17 
18 class QModelIndex;
19 
21 
22 //-----------------------------------------------------------------------------
23 // QAbstractTableModel subclass for keeping track of the annotations and their properties (color,
24 // visibilities)
25 class PQCORE_EXPORT pqAnnotationsModel : public QAbstractTableModel
26 {
27  Q_OBJECT
28  typedef QAbstractTableModel Superclass;
29 
30 public:
31  pqAnnotationsModel(QObject* parentObject = nullptr);
32  ~pqAnnotationsModel() override;
33 
35  {
36  VISIBILITY = 0,
42  COLOR_DATA = NUMBER_OF_COLUMNS,
43  OPACITY_DATA
44  };
45 
47 
50  Qt::ItemFlags flags(const QModelIndex& idx) const override;
51  int rowCount(const QModelIndex& prnt = QModelIndex()) const override;
52  int columnCount(const QModelIndex& /*parent*/) const override;
53  bool setData(const QModelIndex& idx, const QVariant& value, int role = Qt::EditRole) override;
54  QVariant data(const QModelIndex& idx, int role = Qt::DisplayRole) const override;
55  bool setHeaderData(
56  int section, Qt::Orientation orientation, const QVariant& value, int role) override;
57  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
58  Qt::DropActions supportedDropActions() const override;
59  QStringList mimeTypes() const override;
60  QMimeData* mimeData(const QModelIndexList& indexes) const override;
61  bool dropMimeData(const QMimeData* mime_data, Qt::DropAction action, int row, int column,
62  const QModelIndex& parentIdx) override;
64 
68  int columnCount() const { return NUMBER_OF_COLUMNS; }
69 
70  void setVisibilityDomain(vtkSMStringListDomain* domain);
71 
73 
76  QModelIndex addAnnotation(const QModelIndex& after = QModelIndex());
77  QModelIndex removeAnnotations(const QModelIndexList& toRemove = QModelIndexList());
78  void removeAllAnnotations();
80 
82 
86  void setAnnotations(
87  const std::vector<std::pair<QString, QString>>& newAnnotations, bool quiet = false);
88  std::vector<std::pair<QString, QString>> annotations() const;
90 
92 
95  void setVisibilities(const std::vector<std::pair<QString, int>>& newVisibilities);
96  std::vector<std::pair<QString, int>> visibilities() const;
98 
100 
103  void setIndexedColors(const std::vector<QColor>& newColors);
104  std::vector<QColor> indexedColors() const;
106 
107  bool hasColors() const;
108 
110 
113  void setIndexedOpacities(const std::vector<double>& newOpacities);
114  std::vector<double> indexedOpacities() const;
116 
118 
125  void setGlobalOpacity(double opacity) { this->GlobalOpacity = opacity; };
126  double globalOpacity() const { return this->GlobalOpacity; }
128 
130 
133  void setSelectedOpacity(QList<int> rows, double opacity);
135 
137 
140  void setSupportsReorder(bool reorder);
141  bool supportsReorder() const;
143 
147  void reorder(std::vector<int> newOrder);
148 
149 protected:
150  PARAVIEW_DEPRECATED_IN_5_12_0("Unused protected member variable.")
151  QIcon MissingColorIcon;
152  double GlobalOpacity = 1.0;
154  bool SupportsReorder = false;
155 
156 private:
157  Q_DISABLE_COPY(pqAnnotationsModel)
158 
159  class pqInternals;
160  pqInternals* Internals;
161 };
162 
163 #endif
data
#define PARAVIEW_DEPRECATED_IN_5_12_0(reason)
#define PQCORE_EXPORT
Definition: pqCoreModule.h:15
int columnCount() const
Return the number of columns.
double globalOpacity() const
Set/Get the global opacity value.
void setGlobalOpacity(double opacity)
Set/Get the global opacity value.