Show
Ignore:
Timestamp:
06/29/08 06:40:08 (5 months ago)
Author:
artem
Message:

applied font fallbacj patch from Beau Gunderson

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/demo/viewer/mapwidget.cpp

    r544 r701  
    3030#include "mapwidget.hpp" 
    3131#include "info_dialog.hpp" 
     32#include <unicode/unistr.h> 
    3233 
    3334using mapnik::Image32; 
     
    8081   pen_.setCapStyle(Qt::RoundCap); 
    8182   pen_.setJoinStyle(Qt::RoundJoin); 
     83   connect(&thread_, SIGNAL(renderedMap(const QImage &)), 
     84                this, SLOT(updateMap(const QImage &))); 
    8285} 
    8386 
     
    122125   { 
    123126      map_->resize(ev->size().width(),ev->size().height()); 
    124       updateMap(); 
     127      renderMap(); 
    125128   } 
    126129} 
     
    172175                        if (itr->second.to_string().length() > 0) 
    173176                        { 
     177                           UnicodeString unicode = itr->second.to_unicode(); 
    174178                           info.push_back(QPair<QString,QString>(QString(itr->first.c_str()), 
    175                                                                  itr->second.to_string().c_str())); 
     179                                                                 QString((QChar*)unicode.getBuffer(),unicode.length()))); 
    176180                        } 
    177181                     } 
     
    224228   else if (e->button()==Qt::RightButton)  
    225229   {     
    226       //updateMap(); 
     230      //renderMap(); 
    227231   } 
    228232} 
     
    252256            Envelope<double> box = t.backward(Envelope<double>(start_x_,start_y_,end_x_,end_y_)); 
    253257            map_->zoomToBox(box); 
    254             updateMap(); 
     258            renderMap(); 
    255259         } 
    256260      } 
     
    265269            int dy = end_y_ - start_y_; 
    266270            map_->pan(cx - dx ,cy - dy);  
    267             updateMap(); 
     271            renderMap(); 
    268272         } 
    269273      } 
     
    334338   { 
    335339      map_->zoomToBox(bbox); 
    336       updateMap(); 
     340      renderMap(); 
    337341   } 
    338342} 
     
    344348      map_->resize(width(),height()); 
    345349      map_->zoom_all(); 
    346       updateMap(); 
     350      renderMap(); 
    347351   } 
    348352} 
     
    353357   { 
    354358      map_->zoom(0.5); 
    355       updateMap(); 
     359      renderMap(); 
    356360   } 
    357361} 
     
    362366   { 
    363367      map_->zoom(2.0); 
    364       updateMap(); 
     368      renderMap(); 
    365369   } 
    366370} 
     
    373377      double cy = 0.5*map_->getHeight(); 
    374378      map_->pan(int(cx),int(cy - cy*0.25)); 
    375       updateMap(); 
     379      renderMap(); 
    376380   } 
    377381} 
     
    384388      double cy = 0.5*map_->getHeight(); 
    385389      map_->pan(int(cx),int(cy + cy*0.25)); 
    386       updateMap(); 
     390      renderMap(); 
    387391   } 
    388392} 
     
    395399      double cy = 0.5*map_->getHeight(); 
    396400      map_->pan(int(cx - cx * 0.25),int(cy)); 
    397       updateMap(); 
     401      renderMap(); 
    398402   } 
    399403} 
     
    406410      double cy = 0.5*map_->getHeight(); 
    407411      map_->pan(int(cx + cx * 0.25),int(cy));  
    408       updateMap(); 
     412      renderMap(); 
    409413   } 
    410414} 
     
    429433                                   pt.y + 0.5 * height*res); 
    430434      map_->zoomToBox(box); 
    431       updateMap(); 
     435      renderMap(); 
    432436   } 
    433437} 
     
    442446        
    443447 
    444 void MapWidget::updateMap()  
    445 {    
    446    if (map_) 
    447    { 
    448       unsigned width=map_->getWidth(); 
    449       unsigned height=map_->getHeight(); 
    450        
    451       Image32 buf(width,height); 
    452       mapnik::agg_renderer<Image32> ren(*map_,buf); 
    453       ren.apply(); 
    454        
    455       QImage image((uchar*)buf.raw_data(),width,height,QImage::Format_ARGB32); 
    456       pix_=QPixmap::fromImage(image.rgbSwapped()); 
    457       update(); 
    458       // emit signal to interested widgets 
    459       emit mapViewChanged(); 
    460       std::cout << map_->getCurrentExtent() << "\n"; 
    461    } 
     448void MapWidget::renderMap() 
     449{ 
     450   thread_.render(map_); 
     451} 
     452 
     453void MapWidget::updateMap(QImage const& image)  
     454 
     455   std::cout << "updateMap called \n"; 
     456   pix_ = QPixmap::fromImage(image); 
     457   update(); 
     458   // emit signal to interested widgets 
     459   emit mapViewChanged(); 
     460   std::cout << map_->getCurrentExtent() << "\n"; 
    462461} 
    463462