Skip to content

Commit fa2f889

Browse files
author
mhugent
committed
Merge vector overlay branch (diagram plugin)
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10484 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent ea24e10 commit fa2f889

File tree

97 files changed

+19566
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+19566
-73
lines changed

python/plugins/plugin_installer/installer_gui.py

+34-50
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,10 @@ def installPlugin(self):
571571
if plugin["status"] == "newer" and not plugin["error"]: # ask for confirmation if user downgrades an usable plugin
572572
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:
573573
return
574+
if plugin["status"] == "newer":
575+
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:
576+
return
577+
574578
dlg = QgsPluginInstallerInstallingDialog(self,plugin)
575579
dlg.exec_()
576580

@@ -582,58 +586,38 @@ def installPlugin(self):
582586
self.getAllAvailablePlugins()
583587
QApplication.restoreOverrideCursor()
584588
else:
585-
try:
586-
exec ("sys.path_importer_cache.clear()")
587-
exec ("import %s" % plugin["localdir"])
588-
exec ("reload (%s)" % plugin["localdir"])
589-
except:
590-
pass
591-
plugins.updatePlugin(key, False)
592-
plugin = plugins.all()[key]
593-
if not plugin["error"]:
594-
if previousStatus in ["not installed", "new"]:
595-
infoString = (self.tr("Plugin installed successfully"),
596-
self.tr("Python plugin installed.\nNow you need to enable it in Plugin Manager."))
597-
else:
598-
infoString = (self.tr("Plugin reinstalled successfully"),
599-
self.tr("Python plugin reinstalled.\nYou need to restart Quantum GIS in order to reload it."))
589+
590+
path = QDir.cleanPath(QgsApplication.qgisSettingsDirPath() + "/python/plugins/" + key)
591+
if not QDir(path).exists():
592+
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."))
593+
QApplication.setOverrideCursor(Qt.WaitCursor)
594+
self.getAllAvailablePlugins()
595+
QApplication.restoreOverrideCursor()
600596
else:
601-
if plugin["error"] == "incompatible":
602-
message = self.tr("The plugin is designed for a newer version of Quantum GIS. The minimum required version is:")
603-
message += " <b>" + plugin["error_details"] + "</b>"
604-
elif plugin["error"] == "dependent":
605-
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:")
606-
message += "<b> " + plugin["error_details"] + "</b>"
607-
else:
608-
message = self.tr("The plugin is broken. Python said:")
609-
message += "<br><b>" + plugin["error_details"] + "</b>"
610-
dlg = QgsPluginInstallerPluginErrorDialog(self,message)
611-
dlg.exec_()
612-
if dlg.result():
613-
# revert installation
614-
plugins.setPluginData(key, "status", "not installed")
615-
plugins.setPluginData(key, "version_inst", "")
616-
plugins.setPluginData(key, "desc_local", "")
617-
plugins.setPluginData(key, "error", "")
618-
plugins.setPluginData(key, "error_details", "")
619-
pluginDir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/" + plugin["localdir"]
620-
removeDir(pluginDir)
621-
if QDir(pluginDir).exists():
622-
infoString = (self.tr("Plugin uninstall failed"), result)
623-
try:
624-
exec ("sys.path_importer_cache.clear()")
625-
exec ("import %s" % plugin["localdir"])
626-
exec ("reload (%s)" % plugin["localdir"])
627-
except:
628-
pass
629-
plugins.updatePlugin(key, False)
597+
try:
598+
exec ("sys.path_importer_cache.clear()")
599+
exec ("del sys.modules[%s]" % plugin["localdir"]) # remove old version if exist
600+
except:
601+
pass
602+
try:
603+
exec ("import %s" % plugin["localdir"])
604+
exec ("reload (%s)" % plugin["localdir"])
605+
if plugin["status"] == "not installed" or plugin["status"] == "new":
606+
infoString = (self.tr("Plugin installed successfully"), self.tr("Python plugin installed.\nYou have to enable it in the Plugin Manager."))
630607
else:
631-
try:
632-
exec ("del sys.modules[%s]" % plugin["localdir"])
633-
except:
634-
pass
635-
if not plugin["repository"]:
636-
plugins.remove(key)
608+
infoString = (self.tr("Plugin installed successfully"),self.tr("Python plugin reinstalled.\nYou have to restart Quantum GIS to reload it."))
609+
except Exception, error:
610+
dlg = QgsPluginInstallerPluginErrorDialog(self,error.message)
611+
dlg.exec_()
612+
if dlg.result():
613+
pluginDir = unicode(QFileInfo(QgsApplication.qgisUserDbFilePath()).path()+"/python/plugins/"+ str(plugin["localdir"]))
614+
result = removeDir(pluginDir)
615+
if result:
616+
QMessageBox.warning(self, self.tr("Plugin uninstall failed"), result)
617+
plugins.updatePlugin(key, False)
618+
self.populatePluginTree()
619+
return
620+
plugins.updatePlugin(key, False)
637621
self.populatePluginTree()
638622
if infoString[0]:
639623
QMessageBox.information(self, infoString[0], infoString[1])

src/app/qgisapp.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -4367,8 +4367,6 @@ void QgisApp::loadPythonSupport()
43674367
}
43684368
}
43694369

4370-
4371-
43724370
void QgisApp::checkQgisVersion()
43734371
{
43744372
QApplication::setOverrideCursor( Qt::WaitCursor );

src/app/qgsoptions.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,20 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
241241
#ifdef Q_WS_MAC //MH: disable incremental update on Mac for now to avoid problems with resizing
242242
groupBox_5->setEnabled( false );
243243
#endif //Q_WS_MAC
244+
245+
//overlay placement algorithm
246+
mOverlayAlgorithmComboBox->insertItem(0, tr("Central point (fastest)"));
247+
mOverlayAlgorithmComboBox->insertItem(1, tr("Chain (fast)"));
248+
mOverlayAlgorithmComboBox->insertItem(2, tr("Popmusic tabu chain (slow)"));
249+
mOverlayAlgorithmComboBox->insertItem(3, tr("Popmusic tabu (slow)"));
250+
mOverlayAlgorithmComboBox->insertItem(4, tr("Popmusic chain (very slow)"));
251+
252+
QString overlayAlgorithmString = settings.value( "qgis/overlayPlacementAlgorithm", "Central point").toString();
253+
if(overlayAlgorithmString == "Chain"){mOverlayAlgorithmComboBox->setCurrentIndex(1);}
254+
else if(overlayAlgorithmString == "Popmusic tabu chain"){mOverlayAlgorithmComboBox->setCurrentIndex(2);}
255+
else if(overlayAlgorithmString == "Popmusic tabu"){mOverlayAlgorithmComboBox->setCurrentIndex(3);}
256+
else if(overlayAlgorithmString == "Popmusic chain"){mOverlayAlgorithmComboBox->setCurrentIndex(4);}
257+
else{mOverlayAlgorithmComboBox->setCurrentIndex(0);} //default is central point
244258
}
245259

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

347+
//overlay placement method
348+
int overlayIndex = mOverlayAlgorithmComboBox->currentIndex();
349+
if(overlayIndex == 1)
350+
{
351+
settings.setValue( "qgis/overlayPlacementAlgorithm", "Chain");
352+
}
353+
else if(overlayIndex == 2)
354+
{
355+
settings.setValue( "qgis/overlayPlacementAlgorithm", "Popmusic tabu chain");
356+
}
357+
else if(overlayIndex == 3)
358+
{
359+
settings.setValue( "qgis/overlayPlacementAlgorithm", "Popmusic tabu");
360+
}
361+
else if(overlayIndex == 4)
362+
{
363+
settings.setValue( "qgis/overlayPlacementAlgorithm", "Popmusic chain");
364+
}
365+
else
366+
{
367+
settings.setValue( "qgis/overlayPlacementAlgorithm", "Central point" );
368+
}
369+
333370
if ( cmbTheme->currentText().length() == 0 )
334371
{
335372
settings.setValue( "/Themes", "default" );

src/app/qgspluginregistry.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ void QgsPluginRegistry::loadCppPlugin( QString theFullPathName )
269269
{
270270
case QgisPlugin::RENDERER:
271271
case QgisPlugin::UI:
272+
case QgisPlugin::VECTOR_OVERLAY:
272273
{
273274
// UI only -- doesn't use mapcanvas
274275
create_ui *cf = ( create_ui * ) cast_to_fptr( myLib.resolve( "classFactory" ) );
@@ -438,3 +439,14 @@ bool QgsPluginRegistry::isPythonPluginCompatible( QString packageName )
438439
}
439440
return true;
440441
}
442+
443+
QList<QgsPluginMetadata*> QgsPluginRegistry::pluginData()
444+
{
445+
QList<QgsPluginMetadata*> resultList;
446+
QMap<QString, QgsPluginMetadata>::iterator it = mPlugins.begin();
447+
for(; it != mPlugins.end(); ++it)
448+
{
449+
resultList.push_back(&(it.value()));
450+
}
451+
return resultList;
452+
}

src/app/qgspluginregistry.h

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ class QgsPluginRegistry
8484
//! Check whether plugin is compatible with current version of QGIS
8585
bool isPythonPluginCompatible( QString packageName );
8686

87+
//! Returns metadata of all loaded plugins
88+
QList<QgsPluginMetadata*> pluginData();
89+
8790
protected:
8891
//! protected constructor
8992
QgsPluginRegistry();

src/app/qgsprojectproperties.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
166166
mSnappingLayerSettings.insert( *idIter, newEntry );
167167
}
168168
}
169-
170169
}
171170

172171
QgsProjectProperties::~QgsProjectProperties()

src/app/qgsvectorlayerproperties.cpp

+50
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "qgisapp.h"
2323
#include "qgsapplication.h"
2424
#include "qgsattributeactiondialog.h"
25+
#include "qgsapplydialog.h"
2526
#include "qgscontexthelp.h"
2627
#include "qgscontinuouscolordialog.h"
2728
#include "qgscoordinatetransform.h"
@@ -30,13 +31,16 @@
3031
#include "qgslabel.h"
3132
#include "qgsgenericprojectionselector.h"
3233
#include "qgslogger.h"
34+
#include "qgspluginmetadata.h"
35+
#include "qgspluginregistry.h"
3336
#include "qgsproject.h"
3437
#include "qgssinglesymboldialog.h"
3538
#include "qgsuniquevaluedialog.h"
3639
#include "qgsvectorlayer.h"
3740
#include "qgsvectorlayerproperties.h"
3841
#include "qgsconfig.h"
3942
#include "qgsvectordataprovider.h"
43+
#include "qgsvectoroverlayplugin.h"
4044

4145
#ifdef HAVE_POSTGRESQL
4246
#include "qgspgquerybuilder.h"
@@ -120,6 +124,19 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
120124

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

127+
//for each overlay plugin create a new tab
128+
int position;
129+
QList<QgsVectorOverlayPlugin*> overlayPluginList = overlayPlugins();
130+
QList<QgsVectorOverlayPlugin*>::const_iterator it = overlayPluginList.constBegin();
131+
132+
for(; it != overlayPluginList.constEnd(); ++it)
133+
{
134+
QgsApplyDialog* d = (*it)->dialog(lyr);
135+
position = tabWidget->addTab(d, (*it)->name());
136+
tabWidget->setCurrentIndex(position); //ugly, but otherwise the properties dialog is a mess
137+
mOverlayDialogs.push_back(d);
138+
}
139+
123140
tabWidget->setCurrentIndex( 0 );
124141
} // QgsVectorLayerProperties ctor
125142

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

618+
//apply overlay dialogs
619+
for(QList<QgsApplyDialog*>::iterator it = mOverlayDialogs.begin(); it != mOverlayDialogs.end(); ++it)
620+
{
621+
(*it)->apply();
622+
}
623+
601624
// update symbology
602625
emit refreshLegend( layer->getLayerID(), false );
603626

@@ -1026,3 +1049,30 @@ void QgsVectorLayerProperties::on_pbnSaveStyleAs_clicked()
10261049
myQSettings.setValue( "style/lastStyleDir", myFileDialog->directory().absolutePath() );
10271050
}
10281051
}
1052+
1053+
QList<QgsVectorOverlayPlugin*> QgsVectorLayerProperties::overlayPlugins() const
1054+
{
1055+
QList<QgsVectorOverlayPlugin*> pluginList;
1056+
1057+
QgisPlugin* thePlugin = 0;
1058+
QgsVectorOverlayPlugin* theOverlayPlugin = 0;
1059+
1060+
QList<QgsPluginMetadata*> pluginData = QgsPluginRegistry::instance()->pluginData();
1061+
for(QList<QgsPluginMetadata*>::iterator it = pluginData.begin(); it != pluginData.end(); ++it)
1062+
{
1063+
if(*it)
1064+
{
1065+
thePlugin = (*it)->plugin();
1066+
if(thePlugin && thePlugin->type() == QgisPlugin::VECTOR_OVERLAY)
1067+
{
1068+
theOverlayPlugin = dynamic_cast<QgsVectorOverlayPlugin*>(thePlugin);
1069+
if(theOverlayPlugin)
1070+
{
1071+
pluginList.push_back(theOverlayPlugin);
1072+
}
1073+
}
1074+
}
1075+
}
1076+
1077+
return pluginList;
1078+
}

src/app/qgsvectorlayerproperties.h

+7
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
class QgsMapLayer;
3131

3232
class QgsAttributeActionDialog;
33+
class QgsApplyDialog;
3334
class QgsLabelDialog;
3435
class QgsVectorLayer;
36+
class QgsVectorOverlayPlugin;
3537

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

125+
QList<QgsApplyDialog*> mOverlayDialogs;
126+
123127
void updateButtons();
124128
void loadRows();
125129
void setRow( int row, int idx, const QgsField &field );
126130

131+
/**Requests all overlay plugis from the plugin registry. Usefull for inserting their dialogs as new tabs*/
132+
QList<QgsVectorOverlayPlugin*> overlayPlugins() const;
133+
127134
/**Buffer pixmap which takes the picture of renderers before they are assigned to the vector layer*/
128135
//QPixmap bufferPixmap;
129136
static const int context_id = 94000531;

src/core/CMakeLists.txt

+27
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SET(QGIS_CORE_SRCS
77
qgis.cpp
88
qgsapplication.cpp
99
qgsattributeaction.cpp
10+
qgscentralpointpositionmanager.cpp
1011
qgsclipper.cpp
1112
qgscontexthelp.cpp
1213
qgscoordinatetransform.cpp
@@ -25,6 +26,8 @@ SET(QGIS_CORE_SRCS
2526
qgsmaprenderer.cpp
2627
qgsmaptopixel.cpp
2728
qgsmessageoutput.cpp
29+
qgsoverlayobject.cpp
30+
qgspalobjectpositionmanager.cpp
2831
qgspoint.cpp
2932
qgsproject.cpp
3033
qgsprojectfiletransform.cpp
@@ -47,6 +50,7 @@ SET(QGIS_CORE_SRCS
4750
qgsvectordataprovider.cpp
4851
qgsvectorfilewriter.cpp
4952
qgsvectorlayer.cpp
53+
qgsvectoroverlay.cpp
5054

5155
composer/qgscomposeritem.cpp
5256
composer/qgscomposeritemgroup.cpp
@@ -64,6 +68,21 @@ SET(QGIS_CORE_SRCS
6468
composer/qgsticksscalebarstyle.cpp
6569
composer/qgscomposition.cpp
6670

71+
pal/feature.cpp
72+
pal/geomfunction.cpp
73+
pal/label.cpp
74+
pal/labelposition.cpp
75+
pal/layer.cpp
76+
pal/pal.cpp
77+
pal/palstat.cpp
78+
pal/pointset.cpp
79+
pal/priorityqueue.cpp
80+
pal/problem.cpp
81+
pal/util.cpp
82+
pal/linkedlist.hpp
83+
pal/hashtable.hpp
84+
pal/rtree.hpp
85+
6786
raster/qgscliptominmaxenhancement.cpp
6887
raster/qgscolorrampshader.cpp
6988
raster/qgscontrastenhancement.cpp
@@ -188,6 +207,7 @@ QT4_WRAP_CPP(QGIS_CORE_MOC_SRCS ${QGIS_CORE_MOC_HDRS})
188207
INCLUDE_DIRECTORIES(
189208
${CMAKE_CURRENT_SOURCE_DIR}
190209
composer
210+
pal
191211
raster
192212
renderer
193213
symbology
@@ -209,6 +229,13 @@ IF (WIN32)
209229
ENDIF (MSVC)
210230
ENDIF (WIN32)
211231

232+
#for PAL classes
233+
IF (WIN32)
234+
ADD_DEFINITIONS("-D_HAVE_WINDOWS_H_")
235+
ELSE (WIN32)
236+
ADD_DEFINITIONS("-D_HAVE_PTHREAD_")
237+
ENDIF (WIN32)
238+
212239
#############################################################
213240
# spatial indexing library
214241

0 commit comments

Comments
 (0)