diff --git a/src/qgsabout.ui b/src/qgsabout.ui index 62a19fcf88b..c3be9de4f8b 100644 --- a/src/qgsabout.ui +++ b/src/qgsabout.ui @@ -156,10 +156,10 @@ WidgetOrigin - Panel + PopupPanel - Raised + Sunken true @@ -209,6 +209,11 @@ 20 + + + 11 + + Quantum GIS is licensed under the GNU General Public License @@ -219,12 +224,17 @@ - 70 + 80 50 194 21 + + + 11 + + http://www.gnu.org/licenses diff --git a/src/qgsdatabaselayer.cpp b/src/qgsdatabaselayer.cpp index 889ac84def9..9d5b20c7285 100644 --- a/src/qgsdatabaselayer.cpp +++ b/src/qgsdatabaselayer.cpp @@ -37,7 +37,7 @@ QgsMapLayer(QgsMapLayer::DATABASE, table, conninfo), tableName(table) if (pd->Status() == CONNECTION_OK) { // get the geometry column QString sql = "select f_geometry_column,type from geometry_columns where f_table_name='" + tableName + "'"; -// qWarning("Getting geometry column: " + sql); +// qWarning("Getting geometry column: " + sql); int result = pd->ExecTuplesOk((const char *) sql); if (result) { // set the simple type for use with symbology operations @@ -53,7 +53,7 @@ QgsMapLayer(QgsMapLayer::DATABASE, table, conninfo), tableName(table) QString sql = "select xmax(extent(" + geometryColumn + ")) as xmax," "xmin(extent(" + geometryColumn + ")) as xmin," "ymax(extent(" + geometryColumn + ")) as ymax," "ymin(extent(" + geometryColumn + ")) as ymin" " from " + tableName; -// qWarning("Getting extents: " + sql); +// qWarning("Getting extents: " + sql); result = pd->ExecTuplesOk((const char *) sql); if (result) { @@ -67,7 +67,7 @@ QgsMapLayer(QgsMapLayer::DATABASE, table, conninfo), tableName(table) QTextOStream(&xMsg).width(18); QTextOStream(&xMsg) << "Set extents to: " << layerExtent. xMin() << ", " << layerExtent.yMin() << " " << layerExtent.xMax() << ", " << layerExtent.yMax(); -// qWarning(xMsg); +// qWarning(xMsg); } else { QString msg = "Unable to access " + tableName; @@ -114,7 +114,7 @@ void QgsDatabaseLayer::draw(QPainter * p, QgsRect * viewExtent, int yTransform) sql += " where " + geometryColumn; sql += " && GeometryFromText('BOX3D(" + viewExtent->stringRep(); sql += ")'::box3d,-1)"; -// qWarning(sql); +// qWarning(sql); pgs.Declare((const char *) sql, true); //! \todo Check return from Fecth(); int res = pgs.Fetch(); @@ -267,13 +267,13 @@ void QgsDatabaseLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTra sql += " where " + geometryColumn; sql += " && GeometryFromText('BOX3D(" + viewExtent->stringRep(); sql += ")'::box3d,-1)"; -// qWarning(sql); +// qWarning(sql); pgs.Declare((const char *) sql, true); int res = pgs.Fetch(); QString msg; QTextOStream(&msg) << "Number of matching records: " << pgs.Tuples() << endl; -// qWarning(msg); -// std::cout << "Using following transform parameters:\n" << cXf->showParameters() << std::endl; +// qWarning(msg); +// std::cout << "Using following transform parameters:\n" << cXf->showParameters() << std::endl; for (int idx = 0; idx < pgs.Tuples(); idx++) { // allocate memory for the item char *feature = new char[pgs.GetLength(idx, 0) + 1]; @@ -416,7 +416,8 @@ void QgsDatabaseLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTra } -void QgsDatabaseLayer::identify(QgsRect *r){ +void QgsDatabaseLayer::identify(QgsRect * r) +{ } int QgsDatabaseLayer::endian() { diff --git a/src/qgsdbsourceselect.cpp b/src/qgsdbsourceselect.cpp index 2eb2076b164..59719fdd728 100644 --- a/src/qgsdbsourceselect.cpp +++ b/src/qgsdbsourceselect.cpp @@ -83,7 +83,7 @@ void QgsDbSourceSelect::dbConnect() m_connInfo = host + " " + database + " " + username + " " + password; qDebug(m_connInfo); PgDatabase *pd = new PgDatabase((const char *) m_connInfo); -// std::cout << pd->ErrorMessage(); +// std::cout << pd->ErrorMessage(); if (pd->Status() == CONNECTION_OK) { // clear the existing entries lstTables->clear(); diff --git a/src/qgslayerproperties.cpp b/src/qgslayerproperties.cpp index f5c173a3986..d8558aebcf2 100644 --- a/src/qgslayerproperties.cpp +++ b/src/qgslayerproperties.cpp @@ -38,7 +38,7 @@ QgsLayerProperties::QgsLayerProperties(QgsMapLayer * lyr):layer(lyr) sym = layer->symbol(); btnSetColor->setPaletteBackgroundColor(sym->color()); - + btnSetFillColor->setPaletteBackgroundColor(sym->fillColor()); spinLineWidth->setValue(sym->lineWidth()); setCaption("Layer Properties - " + lyr->name()); @@ -49,10 +49,10 @@ QgsLayerProperties::~QgsLayerProperties() } void QgsLayerProperties::selectFillColor() { - + QColor fc = QColorDialog::getColor(sym->fillColor(), this); if (fc.isValid()) { - + btnSetFillColor->setPaletteBackgroundColor(fc); sym->setFillColor(fc); } @@ -61,18 +61,18 @@ void QgsLayerProperties::selectOutlineColor() { QColor oc = QColorDialog::getColor(sym->color(), this); if (oc.isValid()) { - + btnSetColor->setPaletteBackgroundColor(oc); sym->setColor(oc); } } -QString QgsLayerProperties::displayName(){ +QString QgsLayerProperties::displayName() +{ return txtDisplayName->text(); } -void QgsLayerProperties::setLineWidth(int w){ +void QgsLayerProperties::setLineWidth(int w) +{ sym->setLineWidth(w); } - - \ No newline at end of file diff --git a/src/qgslegend.cpp b/src/qgslegend.cpp index 452ba0860aa..5ed3347a920 100644 --- a/src/qgslegend.cpp +++ b/src/qgslegend.cpp @@ -46,15 +46,15 @@ void QgsLegend::update() listView->clear(); - std::list< QString>::iterator zi = map->zOrder.begin(); -while (zi != map->zOrder.end()) { - QgsMapLayer *lyr = map->layerByName(*zi); - QgsLegendItem *lvi = new QgsLegendItem(lyr, listView); // lyr->name(), QCheckListItem::CheckBox ); + std::list < QString >::iterator zi = map->zOrder.begin(); + while (zi != map->zOrder.end()) { + QgsMapLayer *lyr = map->layerByName(*zi); + QgsLegendItem *lvi = new QgsLegendItem(lyr, listView); // lyr->name(), QCheckListItem::CheckBox ); + + zi++; + } - zi++; -} - // Get the list of layers in order from the // map canvas and add legenditems to the legend diff --git a/src/qgsmapcanvas.cpp b/src/qgsmapcanvas.cpp index f6f4b324de7..011dc59885f 100644 --- a/src/qgsmapcanvas.cpp +++ b/src/qgsmapcanvas.cpp @@ -95,7 +95,7 @@ void QgsMapCanvas::addLayer(QgsMapLayer * lyr) incrementZpos(); lyr->setZ(layers.size() - 1); updateZpos(); - zOrder.push_back(lyr->name()); + zOrder.push_back(lyr->name()); connect(lyr, SIGNAL(visibilityChanged()), this, SLOT(layerStateChange())); //lyr->zpos = 0; } @@ -106,78 +106,80 @@ void QgsMapCanvas::incrementZpos() void QgsMapCanvas::updateZpos() { } -QgsMapLayer *QgsMapCanvas::getZpos(int ) +QgsMapLayer *QgsMapCanvas::getZpos(int) { -// QString name = zOrder[index]; -// return layers[name]; +// QString name = zOrder[index]; +// return layers[name]; return 0; } + QgsMapLayer *QgsMapCanvas::layerByName(QString name) { return layers[name]; } + void QgsMapCanvas::render2() { -QString msg = frozen?"frozen":"thawed"; + QString msg = frozen ? "frozen" : "thawed"; //std::cout << "Map canvas is " << msg << std::endl; -if(!frozen){ - if (!drawing) { -// std::cout << "IN RENDER 2" << std::endl; - drawing = true; - QPainter *paint = new QPainter(); - paint->begin(this); + if (!frozen) { + if (!drawing) { +// std::cout << "IN RENDER 2" << std::endl; + drawing = true; + QPainter *paint = new QPainter(); + paint->begin(this); - // calculate the translation and scaling parameters - double muppX, muppY; - muppY = currentExtent.height() / height(); - muppX = currentExtent.width() / width(); -// std::cout << "MuppX is: " << muppX << "\nMuppY is: " << muppY << std::endl; - m_mupp = muppY > muppX ? muppY : muppX; - // calculate the actual extent of the mapCanvas - double dxmin, dxmax, dymin, dymax, whitespace; - if (muppY > muppX) { - dymin = currentExtent.yMin(); - dymax = currentExtent.yMax(); - whitespace = ((width() * m_mupp) - currentExtent.width()) / 2; - dxmin = currentExtent.xMin() - whitespace; - dxmax = currentExtent.xMax() + whitespace; - } else { - dxmin = currentExtent.xMin(); - dxmax = currentExtent.xMax(); - whitespace = ((height() * m_mupp) - currentExtent.height()) / 2; - dymin = currentExtent.yMin() - whitespace; - dymax = currentExtent.yMax() + whitespace; + // calculate the translation and scaling parameters + double muppX, muppY; + muppY = currentExtent.height() / height(); + muppX = currentExtent.width() / width(); +// std::cout << "MuppX is: " << muppX << "\nMuppY is: " << muppY << std::endl; + m_mupp = muppY > muppX ? muppY : muppX; + // calculate the actual extent of the mapCanvas + double dxmin, dxmax, dymin, dymax, whitespace; + if (muppY > muppX) { + dymin = currentExtent.yMin(); + dymax = currentExtent.yMax(); + whitespace = ((width() * m_mupp) - currentExtent.width()) / 2; + dxmin = currentExtent.xMin() - whitespace; + dxmax = currentExtent.xMax() + whitespace; + } else { + dxmin = currentExtent.xMin(); + dxmax = currentExtent.xMax(); + whitespace = ((height() * m_mupp) - currentExtent.height()) / 2; + dymin = currentExtent.yMin() - whitespace; + dymax = currentExtent.yMax() + whitespace; - } -// std::cout << "dxmin: " << dxmin << std::endl << "dymin: " << dymin << std:: -// endl << "dymax: " << dymax << std::endl << "whitespace: " << whitespace << std::endl; - coordXForm->setParameters(m_mupp, dxmin, dymin, height()); //currentExtent.xMin(), currentExtent.yMin(), currentExtent.yMax()); - // update the currentExtent to match the device coordinates - currentExtent.setXmin(dxmin); - currentExtent.setXmax(dxmax); - currentExtent.setYmin(dymin); - currentExtent.setYmax(dymax); - // render all layers in the stack, starting at the base - std::map < QString, QgsMapLayer * >::iterator mi = layers.begin(); -// std::cout << "MAP LAYER COUNT: " << layers.size() << std::endl; - while (mi != layers.end()) { - QgsMapLayer *ml = (*mi).second; - if(ml){ - // QgsDatabaseLayer *dbl = (QgsDatabaseLayer *)&ml; -// std::cout << "Rendering " << ml->name() << std::endl; - if (ml->visible()) - ml->draw(paint, ¤tExtent, coordXForm); - mi++; - // mi.draw(p, &fullExtent); } - } +// std::cout << "dxmin: " << dxmin << std::endl << "dymin: " << dymin << std:: +// endl << "dymax: " << dymax << std::endl << "whitespace: " << whitespace << std::endl; + coordXForm->setParameters(m_mupp, dxmin, dymin, height()); //currentExtent.xMin(), currentExtent.yMin(), currentExtent.yMax()); + // update the currentExtent to match the device coordinates + currentExtent.setXmin(dxmin); + currentExtent.setXmax(dxmax); + currentExtent.setYmin(dymin); + currentExtent.setYmax(dymax); + // render all layers in the stack, starting at the base + std::map < QString, QgsMapLayer * >::iterator mi = layers.begin(); +// std::cout << "MAP LAYER COUNT: " << layers.size() << std::endl; + while (mi != layers.end()) { + QgsMapLayer *ml = (*mi).second; + if (ml) { + // QgsDatabaseLayer *dbl = (QgsDatabaseLayer *)&ml; +// std::cout << "Rendering " << ml->name() << std::endl; + if (ml->visible()) + ml->draw(paint, ¤tExtent, coordXForm); + mi++; + // mi.draw(p, &fullExtent); + } + } - paint->end(); - drawing = false; + paint->end(); + drawing = false; + } } } -} void QgsMapCanvas::render() { @@ -220,12 +222,12 @@ void QgsMapCanvas::render() paint->end(); */ } -void QgsMapCanvas::paintEvent(QPaintEvent * ) +void QgsMapCanvas::paintEvent(QPaintEvent *) { - if (!drawing) + if (!drawing) render2(); -// else -// std::cout << "Can't paint in paint event -- drawing = true" << std::endl; +// else +// std::cout << "Can't paint in paint event -- drawing = true" << std::endl; } QgsRect QgsMapCanvas::extent() @@ -260,16 +262,18 @@ void QgsMapCanvas::mousePressEvent(QMouseEvent * e) boxStartPoint = e->pos(); switch (mapTool) { case QGis::ZoomIn: + case QGis::ZoomOut: zoomBox.setRect(0, 0, 0, 0); break; + case QGis::Pan: // create a pixmap to use in panning the map canvas tempPanImage = new QPixmap(); - + //*tempPanImage = QPixmap::grabWidget(this); - *tempPanImage = QPixmap::grabWindow(winId()); - - + *tempPanImage = QPixmap::grabWindow(winId()); + + backgroundFill = new QPixmap(tempPanImage->width(), tempPanImage->height()); backgroundFill->fill(bgColor); break; @@ -283,6 +287,7 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e) QPainter paint; QPen pen(Qt::gray); QgsPoint ll, ur; + QgsRect *zoomRect ; if (dragging) { dragging = false; switch (mapTool) { @@ -309,6 +314,32 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e) clear(); render2(); break; + case QGis::ZoomOut: + // erase the rubber band box + paint.begin(this); + paint.setPen(pen); + paint.setRasterOp(Qt::XorROP); + paint.drawRect(zoomBox); + paint.end(); + // store the rectangle + zoomBox.setRight(e->pos().x()); + zoomBox.setBottom(e->pos().y()); + // scale the extent so the current view fits inside the zoomBox + ll = coordXForm->toMapCoordinates(zoomBox.left(), zoomBox.bottom()); + ur = coordXForm->toMapCoordinates(zoomBox.right(), zoomBox.top()); + zoomRect = new QgsRect( ll, ur); + double sf; + if (zoomBox.width() > zoomBox.height()) { + sf = currentExtent.width()/zoomRect->width(); + } else { + sf = currentExtent.height()/zoomRect->height(); + } + delete zoomRect; + currentExtent.scale(sf); + clear(); + render2(); + break; + case QGis::Pan: // new extent based on offset delete tempPanImage; @@ -351,9 +382,10 @@ void QgsMapCanvas::mouseMoveEvent(QMouseEvent * e) QPainter paint; QPen pen(Qt::gray); // this is a drag-type operation (zoom, pan or other maptool) - + switch (mapTool) { case QGis::ZoomIn: + case QGis::ZoomOut: // draw the rubber band box as the user drags the mouse dragging = true; @@ -425,35 +457,37 @@ int QgsMapCanvas::layerCount() void QgsMapCanvas::layerStateChange() { -if(!frozen){ - clear(); - render2(); + if (!frozen) { + clear(); + render2(); } } -void QgsMapCanvas::freeze(bool frz){ +void QgsMapCanvas::freeze(bool frz) +{ frozen = frz; } -void QgsMapCanvas::remove(QString key){ - std::mapnewLayers; +void QgsMapCanvas::remove(QString key) +{ + std::map < QString, QgsMapLayer * >newLayers; - std::map < QString, QgsMapLayer * >::iterator mi = layers.begin(); - while (mi != layers.end()) { - QgsMapLayer *ml = (*mi).second; - if(ml->name() != key) - newLayers[ml->name()] = ml; - - mi++; + std::map < QString, QgsMapLayer * >::iterator mi = layers.begin(); + while (mi != layers.end()) { + QgsMapLayer *ml = (*mi).second; + if (ml->name() != key) + newLayers[ml->name()] = ml; + + mi++; + + } - } - QgsMapLayer *l = layers[key]; - - + + layers = newLayers; delete l; - zOrder.remove(key); + zOrder.remove(key); } diff --git a/src/qgsmaplayer.cpp b/src/qgsmaplayer.cpp index 44a39d8af79..4d58f749b90 100644 --- a/src/qgsmaplayer.cpp +++ b/src/qgsmaplayer.cpp @@ -48,9 +48,11 @@ const QString QgsMapLayer::name() { return layerName; } -QString QgsMapLayer::source(){ + +QString QgsMapLayer::source() +{ return dataSource; - } +} const QgsRect QgsMapLayer::extent() { return layerExtent; @@ -62,12 +64,12 @@ QgsRect QgsMapLayer::calculateExtent() } void QgsMapLayer::draw(QPainter *, QgsRect * viewExtent, int yTransform) { -// std::cout << "In QgsMapLayer::draw" << std::endl; +// std::cout << "In QgsMapLayer::draw" << std::endl; } void QgsMapLayer::draw(QPainter *, QgsRect *, QgsCoordinateTransform *) { -// std::cout << "In QgsMapLayer::draw" << std::endl; +// std::cout << "In QgsMapLayer::draw" << std::endl; } @@ -133,5 +135,6 @@ void QgsMapLayer::setFeatureType(const int &_newVal) feature = _newVal; } -void QgsMapLayer::identify(QgsRect *r){ - } \ No newline at end of file +void QgsMapLayer::identify(QgsRect * r) +{ +} diff --git a/src/qgsnewconnection.cpp b/src/qgsnewconnection.cpp index e257122d452..d658fcab248 100644 --- a/src/qgsnewconnection.cpp +++ b/src/qgsnewconnection.cpp @@ -50,7 +50,7 @@ void QgsNewConnection::testConnection() "host=" + txtHost->text() + " dbname=" + txtDatabase->text() + " user=" + txtUsername->text() + " password=" + txtPassword->text(); PgDatabase *pd = new PgDatabase((const char *) connInfo); -// std::cout << pd->ErrorMessage(); +// std::cout << pd->ErrorMessage(); if (pd->Status() == CONNECTION_OK) { // Database successfully opened; we can now issue SQL commands. QMessageBox::information(this, "Test connection", "Connection to " + txtDatabase->text() + " was successfull"); diff --git a/src/qgsrasterlayer.cpp b/src/qgsrasterlayer.cpp index f0e02e38707..26530baffaa 100644 --- a/src/qgsrasterlayer.cpp +++ b/src/qgsrasterlayer.cpp @@ -27,5 +27,6 @@ void QgsRasterLayer::draw(QPainter * p, QRect * viewExtent) { } -void QgsRasterLayer::identify(QgsRect *r){ - } \ No newline at end of file +void QgsRasterLayer::identify(QgsRect * r) +{ +} diff --git a/src/qgsrect.cpp b/src/qgsrect.cpp index 1df2248336f..735c23dd193 100644 --- a/src/qgsrect.cpp +++ b/src/qgsrect.cpp @@ -15,11 +15,18 @@ * * ***************************************************************************/ #include +#include "qgspoint.h" #include "qgsrect.h" QgsRect::QgsRect(double minX, double minY, double maxX, double maxY):xmin(minX), ymin(minY), xmax(maxX), ymax(maxY) { } - +QgsRect::QgsRect(QgsPoint p1, QgsPoint p2){ + xmin = p1.x(); + xmax = p2.x(); + ymin = p1.y(); + ymax = p2.y(); + normalize(); +} QgsRect::~QgsRect() { } diff --git a/src/qgsrect.h b/src/qgsrect.h index f7004c72840..18868a4a18f 100644 --- a/src/qgsrect.h +++ b/src/qgsrect.h @@ -19,6 +19,7 @@ #define QGSRECT_H class QString; +class QgsPoint; /*! \class QgsRect * \brief A rectangle specified with double values. @@ -30,6 +31,8 @@ class QgsRect{ public: //! Constructor QgsRect(double xmin=0, double ymin=0, double xmax=0, double ymax=0); + //! Construct a rectangle from two points + QgsRect(QgsPoint p1, QgsPoint p2); //! Destructor ~QgsRect(); //! Set the minimum x value diff --git a/src/qgsshapefilelayer.cpp b/src/qgsshapefilelayer.cpp index 6eac27c2504..c09418a48e8 100644 --- a/src/qgsshapefilelayer.cpp +++ b/src/qgsshapefilelayer.cpp @@ -82,7 +82,7 @@ void QgsShapeFileLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTr // reset the pointer to read from start of features // set the spatial filter -// std::cout << "Drawing " << dataSource << std::endl; +// std::cout << "Drawing " << dataSource << std::endl; OGRGeometry *filter = 0; filter = new OGRPolygon(); std::ostrstream wktExtent; @@ -238,7 +238,7 @@ void QgsShapeFileLayer::draw(QPainter * p, QgsRect * viewExtent, QgsCoordinateTr delete[]feature; delete fet; } -// std::cout << featureCount << " features in ogr layer within the extent" << std::endl; +// std::cout << featureCount << " features in ogr layer within the extent" << std::endl; OGRGeometry *filt = ogrLayer->GetSpatialFilter(); filt->dumpReadable(stdout); ogrLayer->ResetReading(); @@ -259,5 +259,6 @@ int QgsShapeFileLayer::endian() return XDR; } -void QgsShapeFileLayer::identify(QgsRect *r){ +void QgsShapeFileLayer::identify(QgsRect * r) +{ } diff --git a/src/qgssymbol.cpp b/src/qgssymbol.cpp index 324d0fd8e85..57d1b80752f 100644 --- a/src/qgssymbol.cpp +++ b/src/qgssymbol.cpp @@ -46,11 +46,12 @@ void QgsSymbol::setFillColor(QColor c) m_fillColor = c; } -int QgsSymbol::lineWidth(){ +int QgsSymbol::lineWidth() +{ return m_lineWidth; } -void QgsSymbol::setLineWidth(int w){ +void QgsSymbol::setLineWidth(int w) +{ m_lineWidth = w; } - \ No newline at end of file