Changeset 703 for trunk/demo/viewer/mapwidget.cpp
- Timestamp:
- 06/29/08 06:58:29 (6 months ago)
- Files:
-
- 1 modified
-
trunk/demo/viewer/mapwidget.cpp (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/demo/viewer/mapwidget.cpp
r701 r703 30 30 #include "mapwidget.hpp" 31 31 #include "info_dialog.hpp" 32 #include <unicode/unistr.h>33 32 34 33 using mapnik::Image32; … … 81 80 pen_.setCapStyle(Qt::RoundCap); 82 81 pen_.setJoinStyle(Qt::RoundJoin); 83 connect(&thread_, SIGNAL(renderedMap(const QImage &)),84 this, SLOT(updateMap(const QImage &)));85 82 } 86 83 … … 125 122 { 126 123 map_->resize(ev->size().width(),ev->size().height()); 127 renderMap();124 updateMap(); 128 125 } 129 126 } … … 175 172 if (itr->second.to_string().length() > 0) 176 173 { 177 UnicodeString unicode = itr->second.to_unicode();178 174 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())); 180 176 } 181 177 } … … 228 224 else if (e->button()==Qt::RightButton) 229 225 { 230 // renderMap();226 //updateMap(); 231 227 } 232 228 } … … 256 252 Envelope<double> box = t.backward(Envelope<double>(start_x_,start_y_,end_x_,end_y_)); 257 253 map_->zoomToBox(box); 258 renderMap();254 updateMap(); 259 255 } 260 256 } … … 269 265 int dy = end_y_ - start_y_; 270 266 map_->pan(cx - dx ,cy - dy); 271 renderMap();267 updateMap(); 272 268 } 273 269 } … … 338 334 { 339 335 map_->zoomToBox(bbox); 340 renderMap();336 updateMap(); 341 337 } 342 338 } … … 348 344 map_->resize(width(),height()); 349 345 map_->zoom_all(); 350 renderMap();346 updateMap(); 351 347 } 352 348 } … … 357 353 { 358 354 map_->zoom(0.5); 359 renderMap();355 updateMap(); 360 356 } 361 357 } … … 366 362 { 367 363 map_->zoom(2.0); 368 renderMap();364 updateMap(); 369 365 } 370 366 } … … 377 373 double cy = 0.5*map_->getHeight(); 378 374 map_->pan(int(cx),int(cy - cy*0.25)); 379 renderMap();375 updateMap(); 380 376 } 381 377 } … … 388 384 double cy = 0.5*map_->getHeight(); 389 385 map_->pan(int(cx),int(cy + cy*0.25)); 390 renderMap();386 updateMap(); 391 387 } 392 388 } … … 399 395 double cy = 0.5*map_->getHeight(); 400 396 map_->pan(int(cx - cx * 0.25),int(cy)); 401 renderMap();397 updateMap(); 402 398 } 403 399 } … … 410 406 double cy = 0.5*map_->getHeight(); 411 407 map_->pan(int(cx + cx * 0.25),int(cy)); 412 renderMap();408 updateMap(); 413 409 } 414 410 } … … 433 429 pt.y + 0.5 * height*res); 434 430 map_->zoomToBox(box); 435 renderMap();431 updateMap(); 436 432 } 437 433 } … … 446 442 447 443 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"; 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 } 461 462 } 462 463
