pqAnnotationsModel.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqAnnotationsModel.h
5 
6  Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 ========================================================================*/
32 #ifndef pqAnnotationsModel_h
33 #define pqAnnotationsModel_h
34 
36 #include <QAbstractTableModel>
37 
38 #include <QColor>
39 #include <QIcon>
40 
41 #include <vector>
42 
43 #include "vtkSmartPointer.h"
44 
45 class QModelIndex;
46 
48 
49 //-----------------------------------------------------------------------------
50 // QAbstractTableModel subclass for keeping track of the annotations and their properties (color,
51 // visibilities)
52 class PQAPPLICATIONCOMPONENTS_EXPORT pqAnnotationsModel : public QAbstractTableModel
53 {
54  typedef QAbstractTableModel Superclass;
55 
56 public:
57  pqAnnotationsModel(QObject* parentObject = nullptr);
58  ~pqAnnotationsModel() override;
59 
61  {
62  VISIBILITY = 0,
68  COLOR_DATA = NUMBER_OF_COLUMNS,
69  OPACITY_DATA
70  };
71 
73 
76  Qt::ItemFlags flags(const QModelIndex& idx) const override;
77  int rowCount(const QModelIndex& prnt = QModelIndex()) const override;
78  int columnCount(const QModelIndex& /*parent*/) const override;
79  bool setData(const QModelIndex& idx, const QVariant& value, int role = Qt::EditRole) override;
80  QVariant data(const QModelIndex& idx, int role = Qt::DisplayRole) const override;
81  bool setHeaderData(
82  int section, Qt::Orientation orientation, const QVariant& value, int role) override;
83  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
84  Qt::DropActions supportedDropActions() const override;
85  QStringList mimeTypes() const override;
86  QMimeData* mimeData(const QModelIndexList& indexes) const override;
87  bool dropMimeData(const QMimeData* mime_data, Qt::DropAction action, int row, int column,
88  const QModelIndex& parentIdx) override;
90 
94  int columnCount() const { return NUMBER_OF_COLUMNS; }
95 
96  void setVisibilityDomain(vtkSMStringListDomain* domain);
97 
99 
102  QModelIndex addAnnotation(const QModelIndex& after = QModelIndex());
103  QModelIndex removeAnnotations(const QModelIndexList& toRemove = QModelIndexList());
104  void removeAllAnnotations();
106 
108 
111  void setAnnotations(const std::vector<std::pair<QString, QString> >& newAnnotations);
112  std::vector<std::pair<QString, QString> > annotations() const;
114 
116 
119  void setVisibilities(const std::vector<std::pair<QString, int> >& newVisibilities);
120  std::vector<std::pair<QString, int> > visibilities() const;
122 
124 
127  void setIndexedColors(const std::vector<QColor>& newColors);
128  std::vector<QColor> indexedColors() const;
130 
131  bool hasColors() const;
132 
134 
137  void setIndexedOpacities(const std::vector<double>& newOpacities);
138  std::vector<double> indexedOpacities() const;
140 
142 
145  void setGlobalOpacity(double opacity);
146  double globalOpacity() const { return this->GlobalOpacity; }
148 
149  void setSelectedOpacity(QList<int> rows, double opacity);
150 
152 
155  void setSupportsReorder(bool reorder);
156  bool supportsReorder() const;
158 
162  void reorder(std::vector<int> newOrder);
163 
164 protected:
169 
170 private:
171  Q_DISABLE_COPY(pqAnnotationsModel)
172 
173  class pqInternals;
174  pqInternals* Internals;
175 };
176 
177 #endif
data
vtkSmartPointer< vtkSMStringListDomain > VisibilityDomain
#define PQAPPLICATIONCOMPONENTS_EXPORT
int columnCount() const
Return the number of columns.
double globalOpacity() const
Set/Get Global opacity.