| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| : GPL \(v[23] or later\)$ | ||
| : GPL \(v2 or later\) GENERATED FILE$ | ||
| : \*No copyright\* LGPL \(v2\.1 or later\)$ | ||
| : GPL LGPL$ | ||
| : LGPL$ | ||
| : Apache \(v2\.0\)$ | ||
| : GPL \(v2\)$ | ||
| : LGPL \(v2 or later\)$ | ||
| : Apache \(v2.0\) GPL \(v2 or later\)$ | ||
| : MIT\/X11 \(BSD like\)$ | ||
| : MPL \(v1\.1\) GPL \(unversioned\/unknown version\)$ | ||
| : LGPL \(v2\.1\)$ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,343 @@ | ||
| /*************************************************************************** | ||
| qgsmaptoolrotatefeature.cpp - map tool for rotating features by mouse drag | ||
| --------------------- | ||
| begin : January 2012 | ||
| copyright : (C) 2012 by Vinayan Parameswaran | ||
| email : vinayan123 at gmail dot com | ||
| *************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #include "qgsmaptoolrotatefeature.h" | ||
| #include "qgsgeometry.h" | ||
| #include "qgslogger.h" | ||
| #include "qgsmapcanvas.h" | ||
| #include "qgsrubberband.h" | ||
| #include "qgsvectordataprovider.h" | ||
| #include "qgsvectorlayer.h" | ||
| #include "qgstolerance.h" | ||
| #include <QMessageBox> | ||
| #include <QMouseEvent> | ||
| #include <QSettings> | ||
| #include <limits> | ||
| #include <math.h> | ||
| #include "qgsvertexmarker.h" | ||
|
|
||
| #define PI 3.14159265 | ||
|
|
||
| QgsMapToolRotateFeature::QgsMapToolRotateFeature( QgsMapCanvas* canvas ): QgsMapToolEdit( canvas ), mRubberBand( 0 ) | ||
| { | ||
| mRotation = 0; | ||
| mAnchorPoint = 0; | ||
| mCtrl = false; | ||
| } | ||
|
|
||
| QgsMapToolRotateFeature::~QgsMapToolRotateFeature() | ||
| { | ||
| delete mAnchorPoint; | ||
| delete mRubberBand; | ||
| } | ||
|
|
||
| void QgsMapToolRotateFeature::canvasMoveEvent( QMouseEvent * e ) | ||
| { | ||
| if ( mCtrl == true ) | ||
| { | ||
| if ( !mAnchorPoint ) | ||
| { | ||
| return; | ||
| } | ||
| mAnchorPoint->setCenter( toMapCoordinates( e->pos() ) ); | ||
| mStartPointMapCoords = toMapCoordinates( e->pos() ); | ||
| mStPoint = e->pos(); | ||
| return; | ||
|
|
||
|
|
||
| } | ||
| if ( mRubberBand ) | ||
| { | ||
| double XDistance = mStPoint.x() - e->pos().x(); | ||
| double YDistance = mStPoint.y() - e->pos().y(); | ||
| mRotation = atan2( YDistance, XDistance ) * ( 180 / PI ); | ||
|
|
||
| mStPoint = toCanvasCoordinates( mStartPointMapCoords ); | ||
| double offsetX = mStPoint.x() - mRubberBand->x(); | ||
| double offsetY = mStPoint.y() - mRubberBand->y(); | ||
|
|
||
| mRubberBand->setTransform( QTransform().translate( offsetX, offsetY ).rotate( mRotation ).translate( -1 * offsetX, -1 * offsetY ) ); | ||
| mRubberBand->update(); | ||
| } | ||
| } | ||
|
|
||
| void QgsMapToolRotateFeature::canvasPressEvent( QMouseEvent * e ) | ||
| { | ||
| mRotation = 0; | ||
| if ( mCtrl == true ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| delete mRubberBand; | ||
| mRubberBand = 0; | ||
|
|
||
| mInitialPos = e->pos(); | ||
|
|
||
| QgsVectorLayer* vlayer = currentVectorLayer(); | ||
| if ( !vlayer ) | ||
| { | ||
| notifyNotVectorLayer(); | ||
| return; | ||
| } | ||
|
|
||
| if ( !vlayer->isEditable() ) | ||
| { | ||
| notifyNotEditableLayer(); | ||
| return; | ||
| } | ||
|
|
||
| QgsPoint layerCoords = toLayerCoordinates( vlayer, e->pos() ); | ||
| double searchRadius = QgsTolerance::vertexSearchRadius( mCanvas->currentLayer(), mCanvas->mapRenderer() ); | ||
| QgsRectangle selectRect( layerCoords.x() - searchRadius, layerCoords.y() - searchRadius, | ||
| layerCoords.x() + searchRadius, layerCoords.y() + searchRadius ); | ||
|
|
||
| if ( vlayer->selectedFeatureCount() == 0 ) | ||
| { | ||
| vlayer->select( QgsAttributeList(), selectRect, true ); | ||
|
|
||
| //find the closest feature | ||
| QgsGeometry* pointGeometry = QgsGeometry::fromPoint( layerCoords ); | ||
| if ( !pointGeometry ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| double minDistance = std::numeric_limits<double>::max(); | ||
|
|
||
| QgsFeature cf; | ||
| QgsFeature f; | ||
| while ( vlayer->nextFeature( f ) ) | ||
| { | ||
| if ( f.geometry() ) | ||
| { | ||
| double currentDistance = pointGeometry->distance( *f.geometry() ); | ||
| if ( currentDistance < minDistance ) | ||
| { | ||
| minDistance = currentDistance; | ||
| cf = f; | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| delete pointGeometry; | ||
|
|
||
| if ( minDistance == std::numeric_limits<double>::max() ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| QgsRectangle bound = cf.geometry()->boundingBox(); | ||
| mStartPointMapCoords = toMapCoordinates( vlayer, bound.center() ); | ||
|
|
||
| if ( !mAnchorPoint ) | ||
| { | ||
| mAnchorPoint = new QgsVertexMarker( mCanvas ); | ||
| } | ||
| mAnchorPoint->setIconType( QgsVertexMarker::ICON_CROSS ); | ||
| mAnchorPoint->setCenter( mStartPointMapCoords ); | ||
|
|
||
| mStPoint = toCanvasCoordinates( mStartPointMapCoords ); | ||
|
|
||
| mRotatedFeatures.clear(); | ||
| mRotatedFeatures << cf.id(); //todo: take the closest feature, not the first one... | ||
|
|
||
| mRubberBand = createRubberBand(); | ||
| mRubberBand->setToGeometry( cf.geometry(), vlayer ); | ||
| } | ||
| else | ||
| { | ||
| mRotatedFeatures = vlayer->selectedFeaturesIds(); | ||
|
|
||
| mRubberBand = createRubberBand(); | ||
| for ( int i = 0; i < vlayer->selectedFeatureCount(); i++ ) | ||
| { | ||
| mRubberBand->addGeometry( vlayer->selectedFeatures()[i].geometry(), vlayer ); | ||
| } | ||
| } | ||
|
|
||
| mRubberBand->setColor( Qt::red ); | ||
| mRubberBand->setWidth( 2 ); | ||
| mRubberBand->show(); | ||
|
|
||
| } | ||
|
|
||
| void QgsMapToolRotateFeature::canvasReleaseEvent( QMouseEvent * e ) | ||
| { | ||
| Q_UNUSED( e ); | ||
| if ( !mRubberBand ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| QgsVectorLayer* vlayer = currentVectorLayer(); | ||
| if ( !vlayer ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| //calculations for affine transformation | ||
| double angle = -1 * mRotation * ( PI / 180 ); | ||
| QgsPoint anchorPoint = toLayerCoordinates( vlayer, mStartPointMapCoords ); | ||
| double a = cos( angle ); | ||
| double b = -1 * sin( angle ); | ||
| double c = anchorPoint.x() - cos( angle ) * anchorPoint.x() + sin( angle ) * anchorPoint.y(); | ||
| double d = sin( angle ); | ||
| double ee = cos( angle ); | ||
| double f = anchorPoint.y() - sin( angle ) * anchorPoint.x() - cos( angle ) * anchorPoint.y(); | ||
|
|
||
| vlayer->beginEditCommand( tr( "Features Rotated" ) ); | ||
|
|
||
| int start; | ||
| if ( vlayer->geometryType() == 2 ) | ||
| { | ||
| start = 1; | ||
| } | ||
| else | ||
| { | ||
| start = 0; | ||
| } | ||
|
|
||
| int i = 0; | ||
| foreach ( QgsFeatureId id, mRotatedFeatures ) | ||
| { | ||
| QgsFeature feat; | ||
| vlayer->featureAtId( id, feat ); | ||
| QgsGeometry* geom = feat.geometry(); | ||
| i = start; | ||
|
|
||
| QgsPoint vertex = geom->vertexAt( i ); | ||
| while ( vertex != QgsPoint( 0, 0 ) ) | ||
| { | ||
| double newX = a * vertex.x() + b * vertex.y() + c; | ||
| double newY = d * vertex.x() + ee * vertex.y() + f; | ||
|
|
||
| vlayer->moveVertex( newX, newY, id, i ); | ||
| i = i + 1; | ||
| vertex = geom->vertexAt( i ); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| double anchorX = a * anchorPoint.x() + b * anchorPoint.y() + c; | ||
| double anchorY = d * anchorPoint.x() + ee * anchorPoint.y() + f; | ||
|
|
||
| mAnchorPoint->setCenter( QgsPoint( anchorX, anchorY ) ); | ||
|
|
||
| delete mRubberBand; | ||
| mRubberBand = 0; | ||
|
|
||
| mCanvas->refresh(); | ||
| vlayer->endEditCommand(); | ||
|
|
||
| } | ||
|
|
||
| void QgsMapToolRotateFeature::resetAnchor() | ||
| { | ||
| QgsVectorLayer* vlayer = currentVectorLayer(); | ||
| if ( !vlayer ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| if ( vlayer->selectedFeatureCount() == 0 ) | ||
| { | ||
| return; | ||
| } | ||
| else | ||
| { | ||
|
|
||
| QgsRectangle bound = vlayer->boundingBoxOfSelected(); | ||
| mStartPointMapCoords = toMapCoordinates( vlayer, bound.center() ); | ||
|
|
||
| mAnchorPoint->setCenter( mStartPointMapCoords ); | ||
|
|
||
| mStPoint = toCanvasCoordinates( mStartPointMapCoords ); | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
| void QgsMapToolRotateFeature::keyPressEvent( QKeyEvent* e ) | ||
| { | ||
| if ( e->key() == Qt::Key_Control ) | ||
| { | ||
| mCtrl = true; | ||
| mCanvas->viewport()->setMouseTracking( true ); | ||
| return; | ||
| } | ||
|
|
||
| if ( e->key() == Qt::Key_Escape ) | ||
| { | ||
| this->resetAnchor(); | ||
| } | ||
| } | ||
|
|
||
| void QgsMapToolRotateFeature::keyReleaseEvent( QKeyEvent* e ) | ||
| { | ||
| if ( e->key() == Qt::Key_Control ) | ||
| { | ||
| mCtrl = false; | ||
| mCanvas->viewport()->setMouseTracking( false ); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| void QgsMapToolRotateFeature::activate() | ||
| { | ||
|
|
||
| QgsVectorLayer* vlayer = currentVectorLayer(); | ||
| if ( !vlayer ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| if ( !vlayer->isEditable() ) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| if ( vlayer->selectedFeatureCount() == 0 ) | ||
| { | ||
| return; | ||
| } | ||
| else | ||
| { | ||
|
|
||
| QgsRectangle bound = vlayer->boundingBoxOfSelected(); | ||
| mStartPointMapCoords = toMapCoordinates( vlayer, bound.center() ); | ||
|
|
||
| mAnchorPoint = new QgsVertexMarker( mCanvas ); | ||
| mAnchorPoint->setIconType( QgsVertexMarker::ICON_CROSS ); | ||
| mAnchorPoint->setCenter( mStartPointMapCoords ); | ||
|
|
||
| mStPoint = toCanvasCoordinates( mStartPointMapCoords ); | ||
|
|
||
| QgsMapTool::activate(); | ||
| } | ||
| } | ||
|
|
||
| void QgsMapToolRotateFeature::deactivate() | ||
| { | ||
| delete mRubberBand; | ||
| delete mAnchorPoint; | ||
| mRubberBand = 0; | ||
| mAnchorPoint = 0; | ||
|
|
||
| QgsMapTool::deactivate(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /*************************************************************************** | ||
| qgsmaptoolrotatefeature.h - map tool for rotating features by mouse drag | ||
| --------------------- | ||
| begin : January 2013 | ||
| copyright : (C) 2013 by Vinayan Parameswaran | ||
| email : vinayan123 at gmail dot com | ||
| *************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #ifndef QGSMAPTOOLROTATEFEATURE_H | ||
| #define QGSMAPTOOLROTATEFEATURE_H | ||
|
|
||
| #include "qgsmaptooledit.h" | ||
| #include "qgsvectorlayer.h" | ||
|
|
||
| class QgsVertexMarker; | ||
|
|
||
| /**Map tool for translating feature position by mouse drag*/ | ||
| class QgsMapToolRotateFeature: public QgsMapToolEdit | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| QgsMapToolRotateFeature( QgsMapCanvas* canvas ); | ||
| virtual ~QgsMapToolRotateFeature(); | ||
|
|
||
| virtual void canvasMoveEvent( QMouseEvent * e ); | ||
|
|
||
| virtual void canvasPressEvent( QMouseEvent * e ); | ||
|
|
||
| virtual void canvasReleaseEvent( QMouseEvent * e ); | ||
|
|
||
| void keyPressEvent( QKeyEvent* e ); | ||
|
|
||
| void keyReleaseEvent( QKeyEvent* e ); | ||
|
|
||
|
|
||
| //! to reset the rotation anchor to selectionbound center | ||
| void resetAnchor(); | ||
| //! called when map tool is being deactivated | ||
| void deactivate(); | ||
|
|
||
| void activate(); | ||
|
|
||
|
|
||
| private: | ||
|
|
||
| QgsGeometry rotateGeometry( QgsGeometry geom, QgsPoint point, double angle ); | ||
| QgsPoint rotatePoint( QgsPoint point, double angle ); | ||
|
|
||
| /**Start point of the move in map coordinates*/ | ||
| QgsPoint mStartPointMapCoords; | ||
| QPointF mInitialPos; | ||
|
|
||
| /**Rubberband that shows the feature being moved*/ | ||
| QgsRubberBand* mRubberBand; | ||
|
|
||
| /**Id of moved feature*/ | ||
| QgsFeatureIds mRotatedFeatures; | ||
| double mRotation; | ||
|
|
||
| QPoint mStPoint; | ||
| QgsVertexMarker* mAnchorPoint; | ||
|
|
||
| /** flag if crtl is pressed */ | ||
| bool mCtrl; | ||
| }; | ||
|
|
||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| ######################################################## | ||
| # Files | ||
|
|
||
| ADD_SUBDIRECTORY(ocispatial) | ||
|
|
||
| SET(ORACLE_SRCS | ||
| qgsoracleprovider.cpp | ||
| qgsoracleconn.cpp | ||
| qgsoracledataitems.cpp | ||
| qgsoraclesourceselect.cpp | ||
| qgsoraclenewconnection.cpp | ||
| qgsoracletablemodel.cpp | ||
| qgsoraclecolumntypethread.cpp | ||
| ) | ||
|
|
||
| SET(ORACLE_MOC_HDRS | ||
| qgsoracleprovider.h | ||
| qgsoracleconn.h | ||
| qgsoracledataitems.h | ||
| qgsoraclesourceselect.h | ||
| qgsoraclenewconnection.h | ||
| qgsoracletablemodel.h | ||
| qgsoraclecolumntypethread.h | ||
| ) | ||
|
|
||
|
|
||
| ######################################################## | ||
| # Build | ||
|
|
||
| QT4_WRAP_CPP(ORACLE_MOC_SRCS ${ORACLE_MOC_HDRS}) | ||
|
|
||
| INCLUDE_DIRECTORIES( | ||
| ../../core | ||
| ../../gui | ||
| ${GEOS_INCLUDE_DIR} | ||
| ${CMAKE_CURRENT_BINARY_DIR}/../../ui | ||
| ${QT_QTSQL_INCLUDEDIR} | ||
| ) | ||
|
|
||
| ADD_LIBRARY (oracleprovider MODULE ${ORACLE_SRCS} ${ORACLE_MOC_SRCS}) | ||
|
|
||
| TARGET_LINK_LIBRARIES (oracleprovider | ||
| qgis_core | ||
| qgis_gui | ||
| ${QT_QTSQL_LIBRARY} | ||
| ) | ||
|
|
||
|
|
||
| ######################################################## | ||
| # Install | ||
|
|
||
| INSTALL(TARGETS oracleprovider | ||
| RUNTIME DESTINATION ${QGIS_PLUGIN_DIR} | ||
| LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) | ||
| SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR}/sqldrivers) | ||
| SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR}/sqldrivers) | ||
|
|
||
| FIND_PACKAGE(OCI) | ||
|
|
||
| ADD_DEFINITIONS(${QT_DEFINITIONS}) | ||
| ADD_DEFINITIONS(-DQT_PLUGIN) | ||
| ADD_DEFINITIONS(-DQT_NO_DEBUG) | ||
| ADD_DEFINITIONS(-DQT_SHARED) | ||
|
|
||
| INCLUDE_DIRECTORIES(${OCI_INCLUDE_DIR}) | ||
|
|
||
| SET(QSQLOCISPATIAL_SRC qsql_ocispatial.cpp main.cpp) | ||
| QT4_WRAP_CPP(QSQLOCISPATIAL_SRC qsql_ocispatial.h) | ||
|
|
||
| ADD_LIBRARY(qsqlocispatial SHARED ${QSQLOCISPATIAL_SRC}) | ||
|
|
||
| TARGET_LINK_LIBRARIES(qsqlocispatial | ||
| ${QT_QTCORE_LIBRARY} | ||
| ${QT_QTSQL_LIBRARY} | ||
| ${OCI_LIBRARY} | ||
| ) | ||
|
|
||
| IF(MSVC) | ||
| TARGET_LINK_LIBRARIES(qsqlocispatial wsock32) | ||
| ENDIF(MSVC) | ||
|
|
||
| INSTALL(TARGETS qsqlocispatial | ||
| RUNTIME DESTINATION ${QT_PLUGINS_DIR}/sqldrivers | ||
| LIBRARY DESTINATION ${QT_PLUGINS_DIR}/sqldrivers | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| QOCISPATIAL driver derived from QOCI driver. | ||
|
|
||
| You will need the Oracle development headers and libraries installed | ||
| before compiling this plugin. | ||
|
|
||
| See the Qt SQL documentation for more information on compiling Qt SQL | ||
| driver plugins (sql-driver.html). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # ~~~~~~~~~~ | ||
| # Copyright (c) 2012, Juergen E. Fischer <jef at norbit dot de> | ||
| # Redistribution and use is allowed according to the terms of the BSD license. | ||
| # For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||
| # | ||
| # CMake module to search for OCI library | ||
| # | ||
| # If it's found it sets OCI_FOUND to TRUE | ||
| # and following variables are set: | ||
| # OCI_INCLUDE_DIR | ||
| # OCI_LIBRARY | ||
|
|
||
| FIND_PATH(OCI_INCLUDE_DIR oci.h | ||
| PATHS | ||
| /usr/include/oracle/11.2/client64 | ||
| $ENV{OSGEO4W_ROOT}/include | ||
| $ENV{ORACLE_HOME}/rdbms/public | ||
| ) | ||
|
|
||
| FIND_LIBRARY(OCI_LIBRARY clntsh oci | ||
| PATHS | ||
| /usr/lib/oracle/11.2/client64/lib/ | ||
| $ENV{OSGEO4W_ROOT}/lib | ||
| $ENV{ORACLE_HOME}/lib | ||
| ) | ||
|
|
||
| IF (OCI_INCLUDE_DIR) | ||
| SET(OCI_FOUND TRUE) | ||
| ELSE (OCI_INCLUDE_DIR) | ||
| SET(OCI_FOUND FALSE) | ||
| ENDIF(OCI_INCLUDE_DIR) | ||
|
|
||
| IF (OCI_FOUND) | ||
| IF (NOT OCI_FIND_QUIETLY) | ||
| MESSAGE(STATUS "Found OCI: ${OCI_LIBRARY}") | ||
| ENDIF (NOT OCI_FIND_QUIETLY) | ||
| ELSE (OCI_FOUND) | ||
| IF (OCI_FIND_REQUIRED) | ||
| MESSAGE(FATAL_ERROR "Could not find OCI") | ||
| ELSE (OCI_FIND_REQUIRED) | ||
| IF (NOT OCI_FIND_QUIETLY) | ||
| MESSAGE(STATUS "Could not find OCI") | ||
| ENDIF (NOT OCI_FIND_QUIETLY) | ||
| ENDIF (OCI_FIND_REQUIRED) | ||
| ENDIF (OCI_FOUND) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /**************************************************************************** | ||
| ** | ||
| ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). | ||
| ** Contact: http://www.qt-project.org/legal | ||
| ** | ||
| ** This file is part of the plugins of the Qt Toolkit. | ||
| ** | ||
| ** $QT_BEGIN_LICENSE:LGPL$ | ||
| ** Commercial License Usage | ||
| ** Licensees holding valid commercial Qt licenses may use this file in | ||
| ** accordance with the commercial license agreement provided with the | ||
| ** Software or, alternatively, in accordance with the terms contained in | ||
| ** a written agreement between you and Digia. For licensing terms and | ||
| ** conditions see http://qt.digia.com/licensing. For further information | ||
| ** use the contact form at http://qt.digia.com/contact-us. | ||
| ** | ||
| ** GNU Lesser General Public License Usage | ||
| ** Alternatively, this file may be used under the terms of the GNU Lesser | ||
| ** General Public License version 2.1 as published by the Free Software | ||
| ** Foundation and appearing in the file LICENSE.LGPL included in the | ||
| ** packaging of this file. Please review the following information to | ||
| ** ensure the GNU Lesser General Public License version 2.1 requirements | ||
| ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
| ** | ||
| ** In addition, as a special exception, Digia gives you certain additional | ||
| ** rights. These rights are described in the Digia Qt LGPL Exception | ||
| ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | ||
| ** | ||
| ** GNU General Public License Usage | ||
| ** Alternatively, this file may be used under the terms of the GNU | ||
| ** General Public License version 3.0 as published by the Free Software | ||
| ** Foundation and appearing in the file LICENSE.GPL included in the | ||
| ** packaging of this file. Please review the following information to | ||
| ** ensure the GNU General Public License version 3.0 requirements will be | ||
| ** met: http://www.gnu.org/copyleft/gpl.html. | ||
| ** | ||
| ** | ||
| ** $QT_END_LICENSE$ | ||
| ** | ||
| ** Oracle Spatial Support: (C) 2012-2013 Juergen E. Fischer < jef at norbit dot de >, norBIT GmbH | ||
| ** | ||
| ****************************************************************************/ | ||
|
|
||
| #include <qsqldriverplugin.h> | ||
| #include <qstringlist.h> | ||
| #include "qsql_ocispatial.h" | ||
|
|
||
| QT_BEGIN_NAMESPACE | ||
|
|
||
| class QOCISpatialDriverPlugin : public QSqlDriverPlugin | ||
| { | ||
| public: | ||
| QOCISpatialDriverPlugin(); | ||
|
|
||
| QSqlDriver* create( const QString & ); | ||
| QStringList keys() const; | ||
| }; | ||
|
|
||
| QOCISpatialDriverPlugin::QOCISpatialDriverPlugin() | ||
| : QSqlDriverPlugin() | ||
| { | ||
| } | ||
|
|
||
| QSqlDriver* QOCISpatialDriverPlugin::create( const QString &name ) | ||
| { | ||
| if ( name == QLatin1String( "QOCISPATIAL" ) || name == QLatin1String( "QOCISPATIAL8" ) ) | ||
| { | ||
| QOCISpatialDriver* driver = new QOCISpatialDriver(); | ||
| return driver; | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| QStringList QOCISpatialDriverPlugin::keys() const | ||
| { | ||
| QStringList l; | ||
| l.append( QLatin1String( "QOCISPATIAL8" ) ); | ||
| l.append( QLatin1String( "QOCISPATIAL" ) ); | ||
| return l; | ||
| } | ||
|
|
||
| Q_EXPORT_STATIC_PLUGIN( QOCISpatialDriverPlugin ) | ||
| Q_EXPORT_PLUGIN2( qsqloci, QOCISpatialDriverPlugin ) | ||
|
|
||
| QT_END_NAMESPACE |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| /**************************************************************************** | ||
| ** | ||
| ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). | ||
| ** Contact: http://www.qt-project.org/legal | ||
| ** | ||
| ** This file is part of the QtSql module of the Qt Toolkit. | ||
| ** | ||
| ** $QT_BEGIN_LICENSE:LGPL$ | ||
| ** Commercial License Usage | ||
| ** Licensees holding valid commercial Qt licenses may use this file in | ||
| ** accordance with the commercial license agreement provided with the | ||
| ** Software or, alternatively, in accordance with the terms contained in | ||
| ** a written agreement between you and Digia. For licensing terms and | ||
| ** conditions see http://qt.digia.com/licensing. For further information | ||
| ** use the contact form at http://qt.digia.com/contact-us. | ||
| ** | ||
| ** GNU Lesser General Public License Usage | ||
| ** Alternatively, this file may be used under the terms of the GNU Lesser | ||
| ** General Public License version 2.1 as published by the Free Software | ||
| ** Foundation and appearing in the file LICENSE.LGPL included in the | ||
| ** packaging of this file. Please review the following information to | ||
| ** ensure the GNU Lesser General Public License version 2.1 requirements | ||
| ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
| ** | ||
| ** In addition, as a special exception, Digia gives you certain additional | ||
| ** rights. These rights are described in the Digia Qt LGPL Exception | ||
| ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | ||
| ** | ||
| ** GNU General Public License Usage | ||
| ** Alternatively, this file may be used under the terms of the GNU | ||
| ** General Public License version 3.0 as published by the Free Software | ||
| ** Foundation and appearing in the file LICENSE.GPL included in the | ||
| ** packaging of this file. Please review the following information to | ||
| ** ensure the GNU General Public License version 3.0 requirements will be | ||
| ** met: http://www.gnu.org/copyleft/gpl.html. | ||
| ** | ||
| ** | ||
| ** $QT_END_LICENSE$ | ||
| ** | ||
| ****************************************************************************/ | ||
|
|
||
| #ifndef QSQL_OCISPATIAL_H | ||
| #define QSQL_OCISPATIAL_H | ||
|
|
||
| #include <QtSql/qsqlresult.h> | ||
| #include <QtSql/qsqldriver.h> | ||
| #include "qsqlcachedresult_p.h" | ||
|
|
||
| #ifdef QT_PLUGIN | ||
| #define Q_EXPORT_SQLDRIVER_OCISPATIAL | ||
| #else | ||
| #define Q_EXPORT_SQLDRIVER_OCISPATIAL Q_SQL_EXPORT | ||
| #endif | ||
|
|
||
| QT_BEGIN_HEADER | ||
|
|
||
| typedef struct OCIEnv OCIEnv; | ||
| typedef struct OCISvcCtx OCISvcCtx; | ||
|
|
||
| QT_BEGIN_NAMESPACE | ||
|
|
||
| class QOCISpatialDriver; | ||
| class QOCISpatialCols; | ||
| struct QOCISpatialDriverPrivate; | ||
| struct QOCISpatialResultPrivate; | ||
|
|
||
| class Q_EXPORT_SQLDRIVER_OCISPATIAL QOCISpatialResult : public QSqlCachedResult | ||
| { | ||
| friend class QOCISpatialDriver; | ||
| friend struct QOCISpatialResultPrivate; | ||
| friend class QOCISpatialCols; | ||
| public: | ||
| QOCISpatialResult( const QOCISpatialDriver * db, const QOCISpatialDriverPrivate* p ); | ||
| ~QOCISpatialResult(); | ||
| bool prepare( const QString& query ); | ||
| bool exec(); | ||
| QVariant handle() const; | ||
|
|
||
| protected: | ||
| bool gotoNext( ValueCache &values, int index ); | ||
| bool reset( const QString& query ); | ||
| int size(); | ||
| int numRowsAffected(); | ||
| QSqlRecord record() const; | ||
| QVariant lastInsertId() const; | ||
| void virtual_hook( int id, void *data ); | ||
|
|
||
| private: | ||
| QOCISpatialResultPrivate *d; | ||
| }; | ||
|
|
||
| class Q_EXPORT_SQLDRIVER_OCISPATIAL QOCISpatialDriver : public QSqlDriver | ||
| { | ||
| Q_OBJECT | ||
| friend struct QOCISpatialResultPrivate; | ||
| friend class QOCISpatialPrivate; | ||
| public: | ||
| explicit QOCISpatialDriver( QObject* parent = 0 ); | ||
| QOCISpatialDriver( OCIEnv* env, OCISvcCtx* ctx, QObject* parent = 0 ); | ||
| ~QOCISpatialDriver(); | ||
| bool hasFeature( DriverFeature f ) const; | ||
| bool open( const QString & db, | ||
| const QString & user, | ||
| const QString & password, | ||
| const QString & host, | ||
| int port, | ||
| const QString& connOpts ); | ||
| void close(); | ||
| QSqlResult *createResult() const; | ||
| QStringList tables( QSql::TableType ) const; | ||
| QSqlRecord record( const QString& tablename ) const; | ||
| QSqlIndex primaryIndex( const QString& tablename ) const; | ||
| QString formatValue( const QSqlField &field, | ||
| bool trimStrings ) const; | ||
| QVariant handle() const; | ||
| QString escapeIdentifier( const QString &identifier, IdentifierType ) const; | ||
|
|
||
| protected: | ||
| bool beginTransaction(); | ||
| bool commitTransaction(); | ||
| bool rollbackTransaction(); | ||
| private: | ||
| QOCISpatialDriverPrivate *d; | ||
| }; | ||
|
|
||
| QT_END_NAMESPACE | ||
|
|
||
| QT_END_HEADER | ||
|
|
||
| #endif // QSQL_OCISPATIAL_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| /**************************************************************************** | ||
| ** | ||
| ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). | ||
| ** Contact: http://www.qt-project.org/legal | ||
| ** | ||
| ** This file is part of the QtSql module of the Qt Toolkit. | ||
| ** | ||
| ** $QT_BEGIN_LICENSE:LGPL$ | ||
| ** Commercial License Usage | ||
| ** Licensees holding valid commercial Qt licenses may use this file in | ||
| ** accordance with the commercial license agreement provided with the | ||
| ** Software or, alternatively, in accordance with the terms contained in | ||
| ** a written agreement between you and Digia. For licensing terms and | ||
| ** conditions see http://qt.digia.com/licensing. For further information | ||
| ** use the contact form at http://qt.digia.com/contact-us. | ||
| ** | ||
| ** GNU Lesser General Public License Usage | ||
| ** Alternatively, this file may be used under the terms of the GNU Lesser | ||
| ** General Public License version 2.1 as published by the Free Software | ||
| ** Foundation and appearing in the file LICENSE.LGPL included in the | ||
| ** packaging of this file. Please review the following information to | ||
| ** ensure the GNU Lesser General Public License version 2.1 requirements | ||
| ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | ||
| ** | ||
| ** In addition, as a special exception, Digia gives you certain additional | ||
| ** rights. These rights are described in the Digia Qt LGPL Exception | ||
| ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | ||
| ** | ||
| ** GNU General Public License Usage | ||
| ** Alternatively, this file may be used under the terms of the GNU | ||
| ** General Public License version 3.0 as published by the Free Software | ||
| ** Foundation and appearing in the file LICENSE.GPL included in the | ||
| ** packaging of this file. Please review the following information to | ||
| ** ensure the GNU General Public License version 3.0 requirements will be | ||
| ** met: http://www.gnu.org/copyleft/gpl.html. | ||
| ** | ||
| ** | ||
| ** $QT_END_LICENSE$ | ||
| ** | ||
| ****************************************************************************/ | ||
|
|
||
| #ifndef QSQLCACHEDRESULT_P_H | ||
| #define QSQLCACHEDRESULT_P_H | ||
|
|
||
| // | ||
| // W A R N I N G | ||
| // ------------- | ||
| // | ||
| // This file is not part of the Qt API. It exists for the convenience | ||
| // of other Qt classes. This header file may change from version to | ||
| // version without notice, or even be removed. | ||
| // | ||
| // We mean it. | ||
| // | ||
|
|
||
| #include "QtSql/qsqlresult.h" | ||
|
|
||
| QT_BEGIN_NAMESPACE | ||
|
|
||
| class QVariant; | ||
| template <typename T> class QVector; | ||
|
|
||
| class QSqlCachedResultPrivate; | ||
|
|
||
| class Q_SQL_EXPORT QSqlCachedResult: public QSqlResult | ||
| { | ||
| public: | ||
| virtual ~QSqlCachedResult(); | ||
|
|
||
| typedef QVector<QVariant> ValueCache; | ||
|
|
||
| protected: | ||
| QSqlCachedResult( const QSqlDriver * db ); | ||
|
|
||
| void init( int colCount ); | ||
| void cleanup(); | ||
| void clearValues(); | ||
|
|
||
| virtual bool gotoNext( ValueCache &values, int index ) = 0; | ||
|
|
||
| QVariant data( int i ); | ||
| bool isNull( int i ); | ||
| bool fetch( int i ); | ||
| bool fetchNext(); | ||
| bool fetchPrevious(); | ||
| bool fetchFirst(); | ||
| bool fetchLast(); | ||
|
|
||
| int colCount() const; | ||
| ValueCache &cache(); | ||
|
|
||
| void virtual_hook( int id, void *data ); | ||
| private: | ||
| bool cacheNext(); | ||
| QSqlCachedResultPrivate *d; | ||
| }; | ||
|
|
||
| QT_END_NAMESPACE | ||
|
|
||
| #endif // QSQLCACHEDRESULT_P_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /*************************************************************************** | ||
| wkbptr.h | ||
| --------------------- | ||
| begin : Dezember 2012 | ||
| copyright : (C) 2012 by Juergen E. Fischer | ||
| email : jef at norbit dot de | ||
| *************************************************************************** | ||
| * * | ||
| * This file may be used under the terms of the GNU Lesser * | ||
| * General Public License version 2.1 as published by the Free Software * | ||
| * Foundation and appearing in the file LICENSE.LGPL included in the * | ||
| * packaging of this file. Please review the following information to * | ||
| * ensure the GNU Lesser General Public License version 2.1 requirements * | ||
| * will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. * | ||
| * * | ||
| ***************************************************************************/ | ||
| #ifndef WKBPTR_H | ||
| #define WKBPTR_H | ||
|
|
||
| #include <QSharedData> | ||
|
|
||
| union wkbPtr | ||
| { | ||
| void *vPtr; | ||
| double *dPtr; | ||
| int *iPtr; | ||
| unsigned char *ucPtr; | ||
| char *cPtr; | ||
|
|
||
| }; | ||
|
|
||
| const int SDO_ARRAY_SIZE = 1024; | ||
|
|
||
| #define SDO_GTYPE_D(g) (g/1000%10) | ||
| #define SDO_GTYPE_L(g) (g/100%10) | ||
| #define SDO_GTYPE_TT(g) (g%100) | ||
| #define SDO_GTYPE(g,tt) (g*1000+tt) | ||
|
|
||
| enum SDO_GTYPE_TT | ||
| { | ||
| gtUnknown = 0, | ||
| gtPoint = 1, | ||
| gtLine = 2, | ||
| gtPolygon = 3, | ||
| gtCollection = 4, | ||
| gtMultiPoint = 5, | ||
| gtMultiLine = 6, | ||
| gtMultiPolygon = 7, | ||
| }; | ||
|
|
||
|
|
||
| class QOCISpatialGeometry : public QSharedData | ||
| { | ||
| public: | ||
| bool isNull; | ||
| int gtype; | ||
| int srid; | ||
| double x, y, z; | ||
|
|
||
| QVector<int> eleminfo; | ||
| QVector<double> ordinates; | ||
| }; | ||
|
|
||
| Q_DECLARE_METATYPE( QOCISpatialGeometry ); | ||
|
|
||
| #endif // WKBPTR_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /*************************************************************************** | ||
| qgscolumntypethread.cpp - lookup oracle geometry type and srid in a thread | ||
| ------------------- | ||
| begin : 3.1.2012 | ||
| copyright : (C) 2012 by Juergen E. Fischer | ||
| email : jef at norbit dot de | ||
| ***************************************************************************/ | ||
|
|
||
| /*************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #include "qgsoraclecolumntypethread.h" | ||
|
|
||
| #include <QMetaType> | ||
|
|
||
| QgsOracleColumnTypeThread::QgsOracleColumnTypeThread( QgsOracleConn *conn, bool useEstimatedMetaData ) | ||
| : QThread() | ||
| , mConn( conn ) | ||
| , mUseEstimatedMetadata( useEstimatedMetaData ) | ||
| { | ||
| qRegisterMetaType<QgsOracleLayerProperty>( "QgsOracleLayerProperty" ); | ||
| } | ||
|
|
||
| void QgsOracleColumnTypeThread::addGeometryColumn( QgsOracleLayerProperty layerProperty ) | ||
| { | ||
| layerProperties << layerProperty; | ||
| } | ||
|
|
||
| void QgsOracleColumnTypeThread::stop() | ||
| { | ||
| mStopped = true; | ||
| } | ||
|
|
||
| void QgsOracleColumnTypeThread::run() | ||
| { | ||
| if ( !mConn ) | ||
| return; | ||
|
|
||
| mStopped = false; | ||
|
|
||
| foreach ( QgsOracleLayerProperty layerProperty, layerProperties ) | ||
| { | ||
| if ( !mStopped ) | ||
| { | ||
| mConn->retrieveLayerTypes( layerProperty, mUseEstimatedMetadata ); | ||
| } | ||
|
|
||
| if ( mStopped ) | ||
| { | ||
| layerProperty.types.clear(); | ||
| layerProperty.srids.clear(); | ||
| } | ||
|
|
||
| // Now tell the layer list dialog box... | ||
| emit setLayerType( layerProperty ); | ||
| } | ||
|
|
||
| mConn->disconnect(); | ||
| mConn = 0; | ||
| } |