27 #include "../../../common/STLUtils.h" 
   28 #include "../../../maptools/Utils.h" 
   33 #include <QtGui/QApplication> 
   34 #include <QtGui/QCursor> 
   35 #include <QtGui/QPainter> 
   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);
 
MultiThreadMapDisplay(const QSize &size, const bool &showFeedback=true, QWidget *parent=0, Qt::WindowFlags f=0)
It constructs an empty multi thread map display with the given dimensions which is a child of parent...
 
This class represents a thread responsible to draw a given layer. Basically, this class receives draw...
 
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...
 
virtual void setExtent(te::gm::Envelope &e, bool doRefresh=true)
It sets the world visible area and refreshes the contents in the map display. 
 
bool finishedWithSuccess() const 
This method tells if the thread finished with success. 
 
void showFeedback(const QImage &image)
 
void onDrawLayerFinished(const int &index, const QImage &image)
 
A widget to control the display of a set of layers. 
 
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. 
 
A multi thread Qt4 widget to control the display of a set of layers. 
 
void refresh()
It updates the contents in the map display. 
 
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. 
 
~MultiThreadMapDisplay()
Destructor. 
 
QString getErrorMessage() const 
This method returns an error message if the thread has not finished with success. Otherwise...
 
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...
 
te::map::AbstractLayer * getLayer() const 
This method returns the layer handled by this thread. 
 
virtual QPointF transform(const QPointF &p)
Transforms the given point, in screen coordinates, to a point in world coordinates.