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 "vtkSmartPointer.h"
10 
11 #include <QAbstractTableModel>
12 #include <QColor>
13 #include <QIcon>
14 
15 #include <vector>
16 
17 class QModelIndex;
18 
20 
21 //-----------------------------------------------------------------------------
22 // QAbstractTableModel subclass for keeping track of the annotations and their properties (color,
23 // visibilities)
24 class PQCORE_EXPORT pqAnnotationsModel : public QAbstractTableModel
25 {
26  Q_OBJECT
27  typedef QAbstractTableModel Superclass;
28 
29 public:
30  pqAnnotationsModel(QObject* parentObject = nullptr);
31  ~pqAnnotationsModel() override;
32 
34  {
35  VISIBILITY = 0,
41  COLOR_DATA = NUMBER_OF_COLUMNS,
42  OPACITY_DATA
43  };
44 
46 
49  Qt::ItemFlags flags(const QModelIndex& idx) const override;
50  int rowCount(const QModelIndex& prnt = QModelIndex()) const override;
51  int columnCount(const QModelIndex& /*parent*/) const override;
52  bool setData(const QModelIndex& idx, const QVariant& value, int role = Qt::EditRole) override;
53  QVariant data(const QModelIndex& idx, int role = Qt::DisplayRole) const override;
54  bool setHeaderData(
55  int section, Qt::Orientation orientation, const QVariant& value, int role) override;
56  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
57  Qt::DropActions supportedDropActions() const override;
58  QStringList mimeTypes() const override;
59  QMimeData* mimeData(const QModelIndexList& indexes) const override;
60  bool dropMimeData(const QMimeData* mime_data, Qt::DropAction action, int row, int column,
61  const QModelIndex& parentIdx) override;
63 
67  int columnCount() const { return NUMBER_OF_COLUMNS; }
68 
69  void setVisibilityDomain(vtkSMStringListDomain* domain);
70 
72 
75  QModelIndex addAnnotation(const QModelIndex& after = QModelIndex());
76  QModelIndex removeAnnotations(const QModelIndexList& toRemove = QModelIndexList());
77  void removeAllAnnotations();
79 
81 
85  void setAnnotations(
86  const std::vector<std::pair<QString, QString>>& newAnnotations, bool quiet = false);
87  std::vector<std::pair<QString, QString>> annotations() const;
89 
91 
94  void setVisibilities(const std::vector<std::pair<QString, int>>& newVisibilities);
95  std::vector<std::pair<QString, int>> visibilities() const;
97 
99 
102  void setIndexedColors(const std::vector<QColor>& newColors);
103  std::vector<QColor> indexedColors() const;
105 
106  bool hasColors() const;
107 
109 
112  void setIndexedOpacities(const std::vector<double>& newOpacities);
113  std::vector<double> indexedOpacities() const;
115 
117 
124  void setGlobalOpacity(double opacity) { this->GlobalOpacity = opacity; };
125  double globalOpacity() const { return this->GlobalOpacity; }
127 
129 
132  void setSelectedOpacity(QList<int> rows, double opacity);
134 
136 
139  void setSupportsReorder(bool reorder);
140  bool supportsReorder() const;
142 
146  void reorder(std::vector<int> newOrder);
147 
148 protected:
149  double GlobalOpacity = 1.0;
151  bool SupportsReorder = false;
152 
153 private:
154  Q_DISABLE_COPY(pqAnnotationsModel)
155 
156  class pqInternals;
157  pqInternals* Internals;
158 };
159 
160 #endif
data
vtkSmartPointer< vtkSMStringListDomain > VisibilityDomain
#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.