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