All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AbstractView.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file AbstractView.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "AbstractView.h"
30 
32  m_visibleRulers(true)
33 {
34  m_zoomFactors[0.42] = "42%";
35  m_zoomFactors[0.5] = "50%";
36  m_zoomFactors[0.7] = "70%";
37  m_zoomFactors[1.] = "100%";
38  m_zoomFactors[1.5] = "150%";
39  m_zoomFactors[2.] = "200%";
40  m_zoomFactors[3.] = "300%";
41 }
42 
44 {
45  return m_visibleRulers;
46 }
47 
49 {
50  m_visibleRulers = visible;
51 }
52 
53 void te::layout::AbstractView::addZoomFactor( double factor, std::string text )
54 {
55  m_zoomFactors[factor] = text;
56 }
57 
59 {
60  m_zoomFactors.clear();
61 }
62 
63 double te::layout::AbstractView::nextFactor( double currentFactor )
64 {
65  double zoomFactor = 0;
66  std::map<double, std::string>::iterator it;
67 
68  it = m_zoomFactors.find(currentFactor);
69 
70  if(it != m_zoomFactors.end())
71  {
72  ++it;
73  if(it != m_zoomFactors.end())
74  {
75  zoomFactor = it->first;
76  return zoomFactor;
77  }
78  }
79 
80  return zoomFactor;
81 }
82 
83 double te::layout::AbstractView::previousFactor( double currentFactor )
84 {
85  double zoomFactor = 0;
86  std::map<double, std::string>::iterator it;
87 
88  it = m_zoomFactors.find(currentFactor);
89 
90  if(it != m_zoomFactors.end())
91  {
92  --it;
93  if(it != m_zoomFactors.end())
94  {
95  zoomFactor = it->first;
96  return zoomFactor;
97  }
98  }
99 
100  return zoomFactor;
101 }
This is the abstract view for View.
virtual double previousFactor(double currentFactor)
Method that returns the previous zoom factor in the list.
virtual double nextFactor(double currentFactor)
Method that returns the next zoom factor in the list.
std::map< double, std::string > m_zoomFactors
zoom factor list
Definition: AbstractView.h:112
AbstractView()
Constructor.
virtual void clearZoomFactors()
Method that clears the zoom factor list.
virtual bool isVisibleRulers()
Method that return rulers visibility state.
virtual void addZoomFactor(double factor, std::string text)
Method that adds new zoom factor. Ex.: 0.5 - 50%.
virtual void setVisibleRulers(bool visible)
Method that change rulers visibility state.