Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TuningList.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2015 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OMNI_TUNINGLIST_H
21 #define OMNI_TUNINGLIST_H
22 
23 #include <memory>
24 #include <vector>
26 #include <omni/proj/Tuning.h>
27 
28 namespace omni {
29  class Session;
30 
31  namespace proj {
32  /**@brief Tuning List contains a list of tunings
33  *@detail Tuning List is serializable via QDataStream
34  **/
35  class TuningList : private std::vector<std::unique_ptr<Tuning> >{
36  public:
37  TuningList(Session const&);
38 
39  typedef std::vector<std::unique_ptr<Tuning> >container_type;
40 
41  using container_type::size;
42  using container_type::empty;
43  using container_type::begin;
44  using container_type::end;
45 
46  /**@brief Add tuning to list
47  * @detail Returns pointer new tuning
48  * @param _makeCurrent Flag whether to set current index when added
49  *successfully
50  **/
51  Tuning * add(bool _makeCurrent = true);
52 
53  /// Remove tuning with current index
54  void remove();
55 
56  /// Remove tuning with custom index
57  void remove(int);
58 
59  /**@brief Returns pointer to current tuning
60  * @detail Returns nullptr if currentIdx_ == -1 or tuning list is empty
61  **/
62  Tuning * current();
63 
64  /**@brief Returns pointer to current tuning (const version)
65  * @detail Returns nullptr if currentIdx_ == -1 or tuning list is empty
66  **/
67  Tuning const * current() const;
68 
69  /// Set new current index, must be between 0 and size()-1
70  void setCurrentIndex(int);
71 
72  /// Return current index
73  int currentIndex() const;
74 
75  /// Deletes all tunings
76  void clear();
77 
78  /// Returns tuning at a specific index
79  Tuning * operator[](int);
80 
81  /// Returns tuning at a specific index (const version)
82  Tuning const * operator[](int) const;
83 
84  /// Deserialize list from stream
85  void fromStream(QDataStream&);
86 
87  /// Serialize list to stream
88  void toStream(QDataStream&) const;
89 
90  /// Test both lists for equality
91  friend bool operator==(TuningList const&,
92  TuningList const&);
93 
94  private:
95  /// Test of index is between 0 and size()-1
96  bool validIndex(int) const;
97 
98  int currentIdx_ = -1;
99 
101  };
102  }
103 }
104 
106 
107 #endif /* OMNI_TUNINGLIST_H */
Tuning * current()
Returns pointer to current tuning Returns nullptr if currentIdx_ == -1 or tuning list is empty...
Definition: TuningList.cpp:57
bool validIndex(int) const
Test of index is between 0 and size()-1.
Definition: TuningList.cpp:158
void setCurrentIndex(int)
Set new current index, must be between 0 and size()-1.
Definition: TuningList.cpp:66
A session consists of a canvas, a mapping, a list of tunings and one or several inputs.
Definition: Session.h:41
A projector tuning holds adjustment and distorsion data for a single projector and screen A tuning c...
Definition: Tuning.h:52
Tuning List contains a list of tunings Tuning List is serializable via QDataStream.
Definition: TuningList.h:35
int currentIdx_
Definition: TuningList.h:98
int currentIndex() const
Return current index.
Definition: TuningList.cpp:81
void clear()
Deletes all tunings.
Definition: TuningList.cpp:92
#define OMNI_DECL_STREAM_OPERATORS(CLASS)
Definition: Interface.h:53
Tuning * operator[](int)
Returns tuning at a specific index.
Definition: TuningList.cpp:98
TuningList(Session const &)
Definition: TuningList.cpp:33
Session const & session_
Definition: TuningList.h:100
std::vector< std::unique_ptr< Tuning > > container_type
Definition: TuningList.h:39
friend bool operator==(TuningList const &, TuningList const &)
Test both lists for equality.
Definition: TuningList.cpp:139
void toStream(QDataStream &) const
Serialize list to stream.
Definition: TuningList.cpp:128
Tuning * add(bool _makeCurrent=true)
Add tuning to list Returns pointer new tuning.
Definition: TuningList.cpp:38
void fromStream(QDataStream &)
Deserialize list from stream.
Definition: TuningList.cpp:111