Skip to content

Commit

Permalink
Merge vector overlay branch (diagram plugin)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@10484 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 6, 2009
1 parent 326f472 commit 846a43c
Show file tree
Hide file tree
Showing 97 changed files with 19,566 additions and 73 deletions.
84 changes: 34 additions & 50 deletions python/plugins/plugin_installer/installer_gui.py
Expand Up @@ -571,6 +571,10 @@ def installPlugin(self):
if plugin["status"] == "newer" and not plugin["error"]: # ask for confirmation if user downgrades an usable plugin
if QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), self.tr("Are you sure you want to downgrade the plugin to the latest available version? The installed one is newer!"), QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
return
if plugin["status"] == "newer":
if QMessageBox.warning(self, self.tr("QGIS Python Plugin Installer"), self.tr("Are you sure you want to downgrade the plugin to the latest available version? The installed one is newer!"), QMessageBox.Yes, QMessageBox.No) == QMessageBox.No:
return

dlg = QgsPluginInstallerInstallingDialog(self,plugin)
dlg.exec_()

Expand All @@ -582,58 +586,38 @@ def installPlugin(self):
self.getAllAvailablePlugins()
QApplication.restoreOverrideCursor()
else:
try:
exec ("sys.path_importer_cache.clear()")
exec ("import %s" % plugin["localdir"])
exec ("reload (%s)" % plugin["localdir"])
except:
pass
plugins.updatePlugin(key, False)
plugin = plugins.all()[key]
if not plugin["error"]:
if previousStatus in ["not installed", "new"]:
infoString = (self.tr("Plugin installed successfully"),
self.tr("Python plugin installed.\nNow you need to enable it in Plugin Manager."))
else:
infoString = (self.tr("Plugin reinstalled successfully"),
self.tr("Python plugin reinstalled.\nYou need to restart Quantum GIS in order to reload it."))

path = QDir.cleanPath(QgsApplication.qgisSettingsDirPath() + "/python/plugins/" + key)
if not QDir(path).exists():
infoString = (self.tr("Plugin has disappeared"), self.tr("The plugin seems to have been installed but I don't know where. Probably the plugin package contained a wrong named directory.\nPlease search the list of installed plugins. I'm nearly sure you'll find the plugin there, but I just can't determine which of them it is. It also means that I won't be able to determine if this plugin is installed and inform you about available updates. However the plugin may work. Please contact the plugin author and submit this issue."))
QApplication.setOverrideCursor(Qt.WaitCursor)
self.getAllAvailablePlugins()
QApplication.restoreOverrideCursor()
else:
if plugin["error"] == "incompatible":
message = self.tr("The plugin is designed for a newer version of Quantum GIS. The minimum required version is:")
message += " <b>" + plugin["error_details"] + "</b>"
elif plugin["error"] == "dependent":
message = self.tr("The plugin depends on some components missing on your system. You need to install the following Python module in order to enable it:")
message += "<b> " + plugin["error_details"] + "</b>"
else:
message = self.tr("The plugin is broken. Python said:")
message += "<br><b>" + plugin["error_details"] + "</b>"
dlg = QgsPluginInstallerPluginErrorDialog(self,message)
dlg.exec_()
if dlg.result():
# revert installation
plugins.setPluginData(key, "status", "not installed")
plugins.setPluginData(key, "version_inst", "")
plugins.setPluginData(key, "desc_local", "")
plugins.setPluginData(key, "error", "")
plugins.setPluginData(key, "error_details", "")
pluginDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/" + plugin["localdir"]
removeDir(pluginDir)
if QDir(pluginDir).exists():
infoString = (self.tr("Plugin uninstall failed"), result)
try:
exec ("sys.path_importer_cache.clear()")
exec ("import %s" % plugin["localdir"])
exec ("reload (%s)" % plugin["localdir"])
except:
pass
plugins.updatePlugin(key, False)
try:
exec ("sys.path_importer_cache.clear()")
exec ("del sys.modules[%s]" % plugin["localdir"]) # remove old version if exist
except:
pass
try:
exec ("import %s" % plugin["localdir"])
exec ("reload (%s)" % plugin["localdir"])
if plugin["status"] == "not installed" or plugin["status"] == "new":
infoString = (self.tr("Plugin installed successfully"), self.tr("Python plugin installed.\nYou have to enable it in the Plugin Manager."))
else:
try:
exec ("del sys.modules[%s]" % plugin["localdir"])
except:
pass
if not plugin["repository"]:
plugins.remove(key)
infoString = (self.tr("Plugin installed successfully"),self.tr("Python plugin reinstalled.\nYou have to restart Quantum GIS to reload it."))
except Exception, error:
dlg = QgsPluginInstallerPluginErrorDialog(self,error.message)
dlg.exec_()
if dlg.result():
pluginDir = unicode(QFileInfo(QgsApplication.qgisUserDbFilePath()).path()+"/python/plugins/"+ str(plugin["localdir"]))
result = removeDir(pluginDir)
if result:
QMessageBox.warning(self, self.tr("Plugin uninstall failed"), result)
plugins.updatePlugin(key, False)
self.populatePluginTree()
return
plugins.updatePlugin(key, False)
self.populatePluginTree()
if infoString[0]:
QMessageBox.information(self, infoString[0], infoString[1])
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -4367,8 +4367,6 @@ void QgisApp::loadPythonSupport()
}
}



void QgisApp::checkQgisVersion()
{
QApplication::setOverrideCursor( Qt::WaitCursor );
Expand Down
37 changes: 37 additions & 0 deletions src/app/qgsoptions.cpp
Expand Up @@ -241,6 +241,20 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
#ifdef Q_WS_MAC //MH: disable incremental update on Mac for now to avoid problems with resizing
groupBox_5->setEnabled( false );
#endif //Q_WS_MAC

//overlay placement algorithm
mOverlayAlgorithmComboBox->insertItem(0, tr("Central point (fastest)"));
mOverlayAlgorithmComboBox->insertItem(1, tr("Chain (fast)"));
mOverlayAlgorithmComboBox->insertItem(2, tr("Popmusic tabu chain (slow)"));
mOverlayAlgorithmComboBox->insertItem(3, tr("Popmusic tabu (slow)"));
mOverlayAlgorithmComboBox->insertItem(4, tr("Popmusic chain (very slow)"));

QString overlayAlgorithmString = settings.value( "qgis/overlayPlacementAlgorithm", "Central point").toString();
if(overlayAlgorithmString == "Chain"){mOverlayAlgorithmComboBox->setCurrentIndex(1);}
else if(overlayAlgorithmString == "Popmusic tabu chain"){mOverlayAlgorithmComboBox->setCurrentIndex(2);}
else if(overlayAlgorithmString == "Popmusic tabu"){mOverlayAlgorithmComboBox->setCurrentIndex(3);}
else if(overlayAlgorithmString == "Popmusic chain"){mOverlayAlgorithmComboBox->setCurrentIndex(4);}
else{mOverlayAlgorithmComboBox->setCurrentIndex(0);} //default is central point
}

//! Destructor
Expand Down Expand Up @@ -330,6 +344,29 @@ void QgsOptions::saveOptions()
settings.setValue( "qgis/askToSaveProjectChanges", chbAskToSaveProjectChanges->isChecked() );
settings.setValue( "qgis/warnOldProjectVersion", chbWarnOldProjectVersion->isChecked() );

//overlay placement method
int overlayIndex = mOverlayAlgorithmComboBox->currentIndex();
if(overlayIndex == 1)
{
settings.setValue( "qgis/overlayPlacementAlgorithm", "Chain");
}
else if(overlayIndex == 2)
{
settings.setValue( "qgis/overlayPlacementAlgorithm", "Popmusic tabu chain");
}
else if(overlayIndex == 3)
{
settings.setValue( "qgis/overlayPlacementAlgorithm", "Popmusic tabu");
}
else if(overlayIndex == 4)
{
settings.setValue( "qgis/overlayPlacementAlgorithm", "Popmusic chain");
}
else
{
settings.setValue( "qgis/overlayPlacementAlgorithm", "Central point" );
}

if ( cmbTheme->currentText().length() == 0 )
{
settings.setValue( "/Themes", "default" );
Expand Down
12 changes: 12 additions & 0 deletions src/app/qgspluginregistry.cpp
Expand Up @@ -269,6 +269,7 @@ void QgsPluginRegistry::loadCppPlugin( QString theFullPathName )
{
case QgisPlugin::RENDERER:
case QgisPlugin::UI:
case QgisPlugin::VECTOR_OVERLAY:
{
// UI only -- doesn't use mapcanvas
create_ui *cf = ( create_ui * ) cast_to_fptr( myLib.resolve( "classFactory" ) );
Expand Down Expand Up @@ -438,3 +439,14 @@ bool QgsPluginRegistry::isPythonPluginCompatible( QString packageName )
}
return true;
}

QList<QgsPluginMetadata*> QgsPluginRegistry::pluginData()
{
QList<QgsPluginMetadata*> resultList;
QMap<QString, QgsPluginMetadata>::iterator it = mPlugins.begin();
for(; it != mPlugins.end(); ++it)
{
resultList.push_back(&(it.value()));
}
return resultList;
}
3 changes: 3 additions & 0 deletions src/app/qgspluginregistry.h
Expand Up @@ -84,6 +84,9 @@ class QgsPluginRegistry
//! Check whether plugin is compatible with current version of QGIS
bool isPythonPluginCompatible( QString packageName );

//! Returns metadata of all loaded plugins
QList<QgsPluginMetadata*> pluginData();

protected:
//! protected constructor
QgsPluginRegistry();
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsprojectproperties.cpp
Expand Up @@ -166,7 +166,6 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
mSnappingLayerSettings.insert( *idIter, newEntry );
}
}

}

QgsProjectProperties::~QgsProjectProperties()
Expand Down
50 changes: 50 additions & 0 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -22,6 +22,7 @@
#include "qgisapp.h"
#include "qgsapplication.h"
#include "qgsattributeactiondialog.h"
#include "qgsapplydialog.h"
#include "qgscontexthelp.h"
#include "qgscontinuouscolordialog.h"
#include "qgscoordinatetransform.h"
Expand All @@ -30,13 +31,16 @@
#include "qgslabel.h"
#include "qgsgenericprojectionselector.h"
#include "qgslogger.h"
#include "qgspluginmetadata.h"
#include "qgspluginregistry.h"
#include "qgsproject.h"
#include "qgssinglesymboldialog.h"
#include "qgsuniquevaluedialog.h"
#include "qgsvectorlayer.h"
#include "qgsvectorlayerproperties.h"
#include "qgsconfig.h"
#include "qgsvectordataprovider.h"
#include "qgsvectoroverlayplugin.h"

#ifdef HAVE_POSTGRESQL
#include "qgspgquerybuilder.h"
Expand Down Expand Up @@ -120,6 +124,19 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(

connect( sliderTransparency, SIGNAL( valueChanged( int ) ), this, SLOT( sliderTransparency_valueChanged( int ) ) );

//for each overlay plugin create a new tab
int position;
QList<QgsVectorOverlayPlugin*> overlayPluginList = overlayPlugins();
QList<QgsVectorOverlayPlugin*>::const_iterator it = overlayPluginList.constBegin();

for(; it != overlayPluginList.constEnd(); ++it)
{
QgsApplyDialog* d = (*it)->dialog(lyr);
position = tabWidget->addTab(d, (*it)->name());
tabWidget->setCurrentIndex(position); //ugly, but otherwise the properties dialog is a mess
mOverlayDialogs.push_back(d);
}

tabWidget->setCurrentIndex( 0 );
} // QgsVectorLayerProperties ctor

Expand Down Expand Up @@ -598,6 +615,12 @@ void QgsVectorLayerProperties::apply()
}
layer->setTransparency( static_cast < unsigned int >( 255 - sliderTransparency->value() ) );

//apply overlay dialogs
for(QList<QgsApplyDialog*>::iterator it = mOverlayDialogs.begin(); it != mOverlayDialogs.end(); ++it)
{
(*it)->apply();
}

// update symbology
emit refreshLegend( layer->getLayerID(), false );

Expand Down Expand Up @@ -1026,3 +1049,30 @@ void QgsVectorLayerProperties::on_pbnSaveStyleAs_clicked()
myQSettings.setValue( "style/lastStyleDir", myFileDialog->directory().absolutePath() );
}
}

QList<QgsVectorOverlayPlugin*> QgsVectorLayerProperties::overlayPlugins() const
{
QList<QgsVectorOverlayPlugin*> pluginList;

QgisPlugin* thePlugin = 0;
QgsVectorOverlayPlugin* theOverlayPlugin = 0;

QList<QgsPluginMetadata*> pluginData = QgsPluginRegistry::instance()->pluginData();
for(QList<QgsPluginMetadata*>::iterator it = pluginData.begin(); it != pluginData.end(); ++it)
{
if(*it)
{
thePlugin = (*it)->plugin();
if(thePlugin && thePlugin->type() == QgisPlugin::VECTOR_OVERLAY)
{
theOverlayPlugin = dynamic_cast<QgsVectorOverlayPlugin*>(thePlugin);
if(theOverlayPlugin)
{
pluginList.push_back(theOverlayPlugin);
}
}
}
}

return pluginList;
}
7 changes: 7 additions & 0 deletions src/app/qgsvectorlayerproperties.h
Expand Up @@ -30,8 +30,10 @@
class QgsMapLayer;

class QgsAttributeActionDialog;
class QgsApplyDialog;
class QgsLabelDialog;
class QgsVectorLayer;
class QgsVectorOverlayPlugin;

class QgsVectorLayerProperties : public QDialog, private Ui::QgsVectorLayerPropertiesBase
{
Expand Down Expand Up @@ -120,10 +122,15 @@ class QgsVectorLayerProperties : public QDialog, private Ui::QgsVectorLayerPrope
/**Actions dialog. If apply is pressed, the actions are stored for later use */
QgsAttributeActionDialog* actionDialog;

QList<QgsApplyDialog*> mOverlayDialogs;

void updateButtons();
void loadRows();
void setRow( int row, int idx, const QgsField &field );

/**Requests all overlay plugis from the plugin registry. Usefull for inserting their dialogs as new tabs*/
QList<QgsVectorOverlayPlugin*> overlayPlugins() const;

/**Buffer pixmap which takes the picture of renderers before they are assigned to the vector layer*/
//QPixmap bufferPixmap;
static const int context_id = 94000531;
Expand Down
27 changes: 27 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -7,6 +7,7 @@ SET(QGIS_CORE_SRCS
qgis.cpp
qgsapplication.cpp
qgsattributeaction.cpp
qgscentralpointpositionmanager.cpp
qgsclipper.cpp
qgscontexthelp.cpp
qgscoordinatetransform.cpp
Expand All @@ -25,6 +26,8 @@ SET(QGIS_CORE_SRCS
qgsmaprenderer.cpp
qgsmaptopixel.cpp
qgsmessageoutput.cpp
qgsoverlayobject.cpp
qgspalobjectpositionmanager.cpp
qgspoint.cpp
qgsproject.cpp
qgsprojectfiletransform.cpp
Expand All @@ -47,6 +50,7 @@ SET(QGIS_CORE_SRCS
qgsvectordataprovider.cpp
qgsvectorfilewriter.cpp
qgsvectorlayer.cpp
qgsvectoroverlay.cpp

composer/qgscomposeritem.cpp
composer/qgscomposeritemgroup.cpp
Expand All @@ -64,6 +68,21 @@ SET(QGIS_CORE_SRCS
composer/qgsticksscalebarstyle.cpp
composer/qgscomposition.cpp

pal/feature.cpp
pal/geomfunction.cpp
pal/label.cpp
pal/labelposition.cpp
pal/layer.cpp
pal/pal.cpp
pal/palstat.cpp
pal/pointset.cpp
pal/priorityqueue.cpp
pal/problem.cpp
pal/util.cpp
pal/linkedlist.hpp
pal/hashtable.hpp
pal/rtree.hpp

raster/qgscliptominmaxenhancement.cpp
raster/qgscolorrampshader.cpp
raster/qgscontrastenhancement.cpp
Expand Down Expand Up @@ -188,6 +207,7 @@ QT4_WRAP_CPP(QGIS_CORE_MOC_SRCS ${QGIS_CORE_MOC_HDRS})
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
composer
pal
raster
renderer
symbology
Expand All @@ -209,6 +229,13 @@ IF (WIN32)
ENDIF (MSVC)
ENDIF (WIN32)

#for PAL classes
IF (WIN32)
ADD_DEFINITIONS("-D_HAVE_WINDOWS_H_")
ELSE (WIN32)
ADD_DEFINITIONS("-D_HAVE_PTHREAD_")
ENDIF (WIN32)

#############################################################
# spatial indexing library

Expand Down

0 comments on commit 846a43c

Please sign in to comment.