Show
Ignore:
Timestamp:
06/29/08 06:58:29 (6 months ago)
Author:
artem
Message:

reverting back to 700

Files:
1 modified

Legend:

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

    r701 r703  
    3030#include "mapwidget.hpp" 
    3131#include "info_dialog.hpp" 
    32 #include <unicode/unistr.h> 
    3332 
    3433using mapnik::Image32; 
     
    8180   pen_.setCapStyle(Qt::RoundCap); 
    8281   pen_.setJoinStyle(Qt::RoundJoin); 
    83    connect(&thread_, SIGNAL(renderedMap(const QImage &)), 
    84                 this, SLOT(updateMap(const QImage &))); 
    8582} 
    8683 
     
    125122   { 
    126123      map_->resize(ev->size().width(),ev->size().height()); 
    127       renderMap(); 
     124      updateMap(); 
    128125   } 
    129126} 
     
    175172                        if (itr->second.to_string().length() > 0) 
    176173                        { 
    177                            UnicodeString unicode = itr->second.to_unicode(); 
    178174                           info.push_back(QPair<QString,QString>(QString(itr->first.c_str()), 
    179                                                                  QString((QChar*)unicode.getBuffer(),unicode.length()))); 
     175                                                                 itr->second.to_string().c_str())); 
    180176                        } 
    181177                     } 
     
    228224   else if (e->button()==Qt::RightButton)  
    229225   {     
    230       //renderMap(); 
     226      //updateMap(); 
    231227   } 
    232228} 
     
    256252            Envelope<double> box = t.backward(Envelope<double>(start_x_,start_y_,end_x_,end_y_)); 
    257253            map_->zoomToBox(box); 
    258             renderMap(); 
     254            updateMap(); 
    259255         } 
    260256      } 
     
    269265            int dy = end_y_ - start_y_; 
    270266            map_->pan(cx - dx ,cy - dy);  
    271             renderMap(); 
     267            updateMap(); 
    272268         } 
    273269      } 
     
    338334   { 
    339335      map_->zoomToBox(bbox); 
    340       renderMap(); 
     336      updateMap(); 
    341337   } 
    342338} 
     
    348344      map_->resize(width(),height()); 
    349345      map_->zoom_all(); 
    350       renderMap(); 
     346      updateMap(); 
    351347   } 
    352348} 
     
    357353   { 
    358354      map_->zoom(0.5); 
    359       renderMap(); 
     355      updateMap(); 
    360356   } 
    361357} 
     
    366362   { 
    367363      map_->zoom(2.0); 
    368       renderMap(); 
     364      updateMap(); 
    369365   } 
    370366} 
     
    377373      double cy = 0.5*map_->getHeight(); 
    378374      map_->pan(int(cx),int(cy - cy*0.25)); 
    379       renderMap(); 
     375      updateMap(); 
    380376   } 
    381377} 
     
    388384      double cy = 0.5*map_->getHeight(); 
    389385      map_->pan(int(cx),int(cy + cy*0.25)); 
    390       renderMap(); 
     386      updateMap(); 
    391387   } 
    392388} 
     
    399395      double cy = 0.5*map_->getHeight(); 
    400396      map_->pan(int(cx - cx * 0.25),int(cy)); 
    401       renderMap(); 
     397      updateMap(); 
    402398   } 
    403399} 
     
    410406      double cy = 0.5*map_->getHeight(); 
    411407      map_->pan(int(cx + cx * 0.25),int(cy));  
    412       renderMap(); 
     408      updateMap(); 
    413409   } 
    414410} 
     
    433429                                   pt.y + 0.5 * height*res); 
    434430      map_->zoomToBox(box); 
    435       renderMap(); 
     431      updateMap(); 
    436432   } 
    437433} 
     
    446442        
    447443 
    448 void MapWidget::renderMap() 
    449 { 
    450    thread_.render(map_); 
    451 } 
    452  
    453 void 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"; 
     444void 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   } 
    461462} 
    462463