27 #include "../../../common/STLUtils.h"
28 #include "../../../maptools/Utils.h"
33 #include <QApplication>
39 m_showFeedback(showFeedback),
42 setAttribute(Qt::WA_OpaquePaintEvent,
true);
47 m_showFeedback(showFeedback),
50 setAttribute(Qt::WA_OpaquePaintEvent,
true);
81 m_displayPixmap->fill(m_backgroundColor);
82 m_draftPixmap->fill(Qt::transparent);
85 m_visibleLayers.clear();
88 if(m_visibleLayers.empty())
94 int n = m_visibleLayers.size() - m_threads.size();
95 for(
int i = 0; i < n; ++i)
100 connect(thread, SIGNAL(feedback(QImage)),
this, SLOT(showFeedback(QImage)));
102 connect(thread, SIGNAL(drawLayerFinished(
int, QImage)),
this, SLOT(onDrawLayerFinished(
int, QImage)));
104 m_threads.push_back(thread);
107 QApplication::setOverrideCursor(Qt::WaitCursor);
112 std::list<te::map::AbstractLayerPtr>::reverse_iterator it;
113 for(it = m_visibleLayers.rbegin(); it != m_visibleLayers.rend(); ++it)
115 m_threads[i]->draw(it->get(), m_extent, m_srid, size(), i);
122 connect(
this, SIGNAL(drawLayersFinished(
const QMap<QString, QString>&)), &wait, SLOT(quit()));
129 if(!m_extent.isValid())
132 return m_matrix.inverted().map(p);
142 if(!m_extent.isValid())
146 double ww = m_extent.m_urx - m_extent.m_llx;
147 double wh = m_extent.m_ury - m_extent.m_lly;
149 double widthByHeight =
static_cast<double>(width()) / static_cast<double>(height());
151 if(widthByHeight > ww / wh)
154 ww = wh * widthByHeight;
155 m_extent.m_llx = m_extent.m_llx - (ww - v) * 0.5;
156 m_extent.m_urx = m_extent.m_llx + ww;
161 wh = ww / widthByHeight;
162 m_extent.m_lly = m_extent.m_lly - (wh - v) * 0.5;
163 m_extent.m_ury = m_extent.m_lly + wh;
167 double xScale =
static_cast<double>(width()) / (m_extent.m_urx - m_extent.m_llx);
168 double yScale =
static_cast<double>(height()) / (m_extent.m_ury - m_extent.m_lly);
170 m_matrix.scale(xScale, -yScale);
171 m_matrix.translate(-m_extent.m_llx, -m_extent.m_ury);
176 QPainter painter(m_displayPixmap);
177 painter.setOpacity(0.1);
178 painter.drawImage(0, 0, image);
185 m_images.insert(std::pair<int, QImage>(index, image));
186 if(m_images.size() != m_visibleLayers.size())
188 QPainter painter(m_displayPixmap);
189 painter.drawImage(0, 0, image);
198 m_displayPixmap->fill(m_backgroundColor);
200 QPainter painter(m_displayPixmap);
202 std::list<te::map::AbstractLayerPtr>::reverse_iterator itLayer = m_visibleLayers.rbegin();
203 std::map<int, QImage>::iterator it;
204 for(it = m_images.begin(); it != m_images.end(); ++it)
208 painter.drawImage(0, 0, it->second);
222 QApplication::restoreOverrideCursor();
225 QMap<QString, QString> errors;
226 for(std::size_t i = 0; i < m_threads.size(); ++i)
234 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.
CompositionMode
The composition mode used to render the canvas.
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.