Equalizer  1.10.1
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
zoom.h
1 
2 /* Copyright (c) 2009-2012, Stefan Eilemann <eile@equalizergraphics.com>
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License version 2.1 as published
6  * by the Free Software Foundation.
7  *
8  * This library is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11  * details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16  */
17 
18 #ifndef EQFABRIC_ZOOM_H
19 #define EQFABRIC_ZOOM_H
20 
21 #include <eq/fabric/api.h>
22 #include <eq/fabric/types.h>
23 
24 namespace eq
25 {
26 namespace fabric
27 {
34  class Zoom : public Vector2f
35  {
36  public:
38  Zoom() : Vector2f( 1.f, 1.f ) {}
39 
44  Zoom( const float x_, const float y_ ) : Vector2f( x_, y_ ) {}
46 
48  bool isValid() const { return ( x() != 0.f && y() != 0.f ); }
49 
51  void validate()
52  {
53  if( x() == 0.f ) x() = 1.f;
54  if( y() == 0.f ) y() = 1.f;
55  }
56 
58  void invalidate() { x() = y() = 0.f; }
59 
61  void apply( const Zoom& rhs )
62  {
63  x() *= rhs.x();
64  y() *= rhs.y();
65  }
66 
68  EQFABRIC_API static const Zoom NONE;
69  };
70 
71  inline std::ostream& operator << ( std::ostream& os, const Zoom& zoom )
72  {
73  if( zoom.isValid( ))
74  os << "zoom [ " << zoom.x() << ' ' << zoom.y() << " ]";
75  return os;
76  }
77 }
78 }
79 namespace lunchbox
80 {
81 template<> inline void byteswap( eq::fabric::Zoom& value )
82  { byteswap< eq::fabric::Vector2f >( value ); }
83 }
84 #endif // EQFABRIC_ZOOM_H
A zoom specification with methods for manipulation.
Definition: zoom.h:34
Defines export visibility macros for library EqualizerFabric.
bool isValid() const
Definition: zoom.h:48
void invalidate()
Make the zoom factor invalid.
Definition: zoom.h:58
void apply(const Zoom &rhs)
Apply an additional zoom factor to this zoom.
Definition: zoom.h:61
Zoom()
Construct a new zoom specification set to 1, 1.
Definition: zoom.h:38
Zoom(const float x_, const float y_)
Construct a new zoom specification with default values.
Definition: zoom.h:44
void validate()
Enforce the zoom to be valid.
Definition: zoom.h:51
static EQFABRIC_API const Zoom NONE
The zoom NONE (1,1) value.
Definition: zoom.h:68