27 #include "../../../common/STLUtils.h"
28 #include "../../../maptools/Utils.h"
33 #include <QApplication>
38 : te::qt::widgets::
MapDisplay(size, parent, f),
39 m_showFeedback(showFeedback)
41 setAttribute(Qt::WA_OpaquePaintEvent,
true);
72 m_displayPixmap->fill(m_backgroundColor);
73 m_draftPixmap->fill(Qt::transparent);
76 m_visibleLayers.clear();
79 if(m_visibleLayers.empty())
85 int n = m_visibleLayers.size() - m_threads.size();
86 for(
int i = 0; i < n; ++i)
91 connect(thread, SIGNAL(feedback(QImage)),
this, SLOT(showFeedback(QImage)));
93 connect(thread, SIGNAL(drawLayerFinished(
int, QImage)),
this, SLOT(onDrawLayerFinished(
int, QImage)));
95 m_threads.push_back(thread);
98 QApplication::setOverrideCursor(Qt::WaitCursor);
103 std::list<te::map::AbstractLayerPtr>::reverse_iterator it;
104 for(it = m_visibleLayers.rbegin(); it != m_visibleLayers.rend(); ++it)
106 m_threads[i]->draw(it->get(), m_extent, m_srid, size(), i);
113 if(!m_extent.isValid())
116 return m_matrix.inverted().map(p);
121 if(!m_extent.isValid())
125 double ww = m_extent.m_urx - m_extent.m_llx;
126 double wh = m_extent.m_ury - m_extent.m_lly;
128 double widthByHeight =
static_cast<double>(width()) / static_cast<double>(height());
130 if(widthByHeight > ww / wh)
133 ww = wh * widthByHeight;
134 m_extent.m_llx = m_extent.m_llx - (ww - v) * 0.5;
135 m_extent.m_urx = m_extent.m_llx + ww;
140 wh = ww / widthByHeight;
141 m_extent.m_lly = m_extent.m_lly - (wh - v) * 0.5;
142 m_extent.m_ury = m_extent.m_lly + wh;
146 double xScale =
static_cast<double>(width()) / (m_extent.m_urx - m_extent.m_llx);
147 double yScale =
static_cast<double>(height()) / (m_extent.m_ury - m_extent.m_lly);
149 m_matrix.scale(xScale, -yScale);
150 m_matrix.translate(-m_extent.m_llx, -m_extent.m_ury);
155 QPainter painter(m_displayPixmap);
156 painter.setOpacity(0.1);
158 painter.drawPixmap(0, 0, QPixmap::fromImage(image));
164 m_images.insert(std::pair<int, QImage>(index, image));
165 if(m_images.size() != m_visibleLayers.size())
167 QPainter painter(m_displayPixmap);
169 painter.drawPixmap(0, 0, QPixmap::fromImage(image));
177 m_displayPixmap->fill(m_backgroundColor);
179 QPainter painter(m_displayPixmap);
181 std::map<int, QImage>::iterator it;
182 for(it = m_images.begin(); it != m_images.end(); ++it)
183 painter.drawPixmap(0, 0, QPixmap::fromImage(it->second));
194 QApplication::restoreOverrideCursor();
197 QMap<QString, QString> errors;
198 for(std::size_t i = 0; i < m_threads.size(); ++i)
206 emit drawLayersFinished(errors);
virtual const std::string & getId() const
It returns the layer id.
This class represents a thread responsible to draw a given layer. Basically, this class receives draw...
A multi thread Qt4 widget to control the display of a set of layers.
virtual void setExtent(te::gm::Envelope &e, bool doRefresh=true)
It sets the world visible area and refreshes the contents in the map display.
An Envelope defines a 2D rectangular region.
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
TEMAPEXPORT void GetVisibleLayers(const std::list< te::map::AbstractLayerPtr > &layers, std::list< te::map::AbstractLayerPtr > &visibleLayers)
It gets the visible layers of the given layer list.