Skip to content

Commit 522db23

Browse files
committed
QGIS 3 Migration
1 parent 7c5331c commit 522db23

177 files changed

Lines changed: 908 additions & 1715 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deploy/

Project_example/example_project.qgs

Lines changed: 0 additions & 495 deletions
This file was deleted.

README.md

Lines changed: 6 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -6,96 +6,20 @@ This plugin allows the visualization of equirectangular local images, although m
66

77
## Prerequisites
88

9-
The libraries [CefPython](https://github.com/cztomczak/cefpython) is required, you can find them in:
10-
- [x86](https://github.com/All4Gis/EquirectangularViewer/tree/master/ext-libs/x86/cefpython3)
11-
- [x64](https://github.com/All4Gis/EquirectangularViewer/tree/master/ext-libs/x64/cefpython3)
9+
The libraries [CefPython](https://github.com/cztomczak/cefpython) is required and Pillow, install the **cefpython3** python package and **Pillow**.
10+
Always from command prompt:
1211

13-
These libraries must be placed in Windows `D:\OSGeo4W64\apps\Python27\Lib\site-packages ` or something similar depending on your Qgis installation.
12+
`python3 -m pip install cefpython3`
13+
`python3 -m pip install pillow`
1414

15-
If you don't find this path ,are wrong or you are using other platform, open the python console of QGIS and try with this for print it:
15+
Or using:
1616

17-
`import site; site.getsitepackages()`
18-
19-
On the other hand, the plugin must be placed in the `.qgis` path, it should be something like
17+
`python3 -m pip install -r requirements.txt`
2018

21-
- Windows
22-
23-
`C:\Users\<username>\.qgis2\python\plugins`
24-
25-
- Linux
26-
27-
`/home/<username>/.qgis2/python/plugins`
28-
29-
- Mac OSX
30-
31-
`/Users/<username>/.qgis2/python/plugins`
3219

33-
If you don't find this path ,are wrong or you are using other platform, open the python console of QGIS and try with this for print it:
34-
35-
`print QgsApplication.qgisSettingsDirPath()`
36-
37-
and search the `python/plugins` folder in this path.
38-
3920
Once installed, you can test the correct functioning of the plugin with the example that is provided,a shapefile with some images.
4021
[Test Project](https://github.com/All4Gis/EquirectangularViewer/tree/master/Project_example)
4122

42-
## Install Note for Windows 10
43-
44-
***As for python in the environment variables:***
45-
46-
Don't add anything in user environment variables,In system environment variables create a new variable:
47-
48-
Name: `PYTHONHOME`
49-
Folder: `C:\Program Files\QGIS 2.18\apps\Python27`
50-
51-
Instead, in the already existing `Path` variable add:
52-
53-
C:\OSGeo4W64\bin
54-
55-
If there is not the folder `C:\OSGeo4W64\bin` add alternatively in `Path` variable:
56-
57-
C:\Program Files\QGIS 2.18\bin
58-
59-
**Test** working python in command windows opening it as administrator ad typing `python`and If says python version all works.
60-
61-
If says `python` is not recognized as an internal or external command remove `C:\OSGeo4W64\bin` from `Path` variable (even if it exists) and use `C:\Program Files\QGIS 2.18\bin`.
62-
63-
***Open the command prompt as an administrator:***
64-
65-
Right click on the windows button at the bottom left,
66-
Search for **CMD**,
67-
Key combination **CTRL + SHIFT + ENTER** (*administrator mode*).
68-
69-
Type python, returns the python version.Type: `import pip`
70-
If not errors it means that pip is present. **CTRL + Z** to exit the python console.
71-
72-
Install the **cefpython3** python package.
73-
Always from command prompt:
74-
75-
python -m pip install cefpython3
76-
77-
***Copy the plugin folder:***
78-
79-
Copy EquirectangularViewer in the QGIS plugins folder.
80-
Type in the python console of QGIS:
81-
82-
print QgsApplication.qgisSettingsDirPath ()
83-
84-
to find the QGIS plugins folder:
85-
86-
C:\Users\user\.qgis2\python\plugins
87-
88-
89-
### Note :
90-
For show the images you need put the absolute path in the shapefile or modify the code ,method GetImage() in Geo360Dialog.py
91-
92-
93-
### common mistakes:
94-
95-
If not work or show this log:
96-
`NameError: global name 'cefpython' is not defined`
97-
Please,install cefpython using pip.
98-
`pip install cefpython3`
9923

10024
## How it works?
10125

code/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/.pydevproject
2+
/.project
3+
/Compile.bat
4+
/py3-env.bat
5+
*.pyc
6+
.settings/
7+
__pycache__/

Geo360.py renamed to code/Geo360.py

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,18 @@
1818
* *
1919
***************************************************************************/
2020
"""
21-
import os.path
21+
from qgis.gui import QgsMapToolIdentify
2222

23-
from Geo360Dialog import Geo360Dialog
24-
from PyQt4.QtCore import QTimer, Qt
25-
from PyQt4.QtGui import QAction, QIcon, QCursor, QPixmap
26-
from qgis.core import *
27-
from qgis.gui import QgsMapToolIdentify, QgsMessageBar
28-
import qgis.utils
29-
from server.local_server import *
30-
from utils.log import log
31-
from utils.qgsutils import qgsutils
32-
33-
34-
from PyQt4 import QtGui
23+
from PyQt5.QtCore import QTimer, Qt, QSettings, QThread
24+
from PyQt5.QtGui import QIcon, QCursor, QPixmap
25+
from PyQt5.QtWidgets import QAction
3526

27+
from EquirectangularViewer.Geo360Dialog import Geo360Dialog
28+
import EquirectangularViewer.config as config
29+
from EquirectangularViewer.server.local_server import openWebApp
30+
from EquirectangularViewer.utils.log import log
31+
from EquirectangularViewer.utils.qgsutils import qgsutils
32+
from qgis.core import QgsApplication
3633

3734
try:
3835
from pydevd import *
@@ -54,8 +51,13 @@ def __init__(self, iface):
5451

5552
self.iface = iface
5653
self.canvas = self.iface.mapCanvas()
57-
58-
self.plugin_path = os.path.dirname(os.path.realpath(__file__))
54+
threadcount = QThread.idealThreadCount()
55+
# use all available cores and parallel rendering
56+
QgsApplication.setMaxThreads(threadcount)
57+
QSettings().setValue("/qgis/parallel_rendering", True)
58+
# OpenCL acceleration
59+
QSettings().setValue("/core/OpenClEnabled", True)
60+
self.dlg = None
5961

6062
def createTimer(self):
6163
self.timer = QTimer()
@@ -65,17 +67,14 @@ def createTimer(self):
6567
def onTimer(self):
6668
try:
6769
cefpython.MessageLoopWork()
68-
except:
70+
except Exception:
6971
None
7072

7173
def stopTimer(self):
7274
self.timer.stop()
7375

7476
def StartCefPython(self):
7577
''' Start CefPython '''
76-
qgsutils.showUserAndLogMessage(
77-
self, u"Information: ", u"Create Viewer.", QgsMessageBar.INFO,
78-
onlyLog=True)
7978
settings = {}
8079
settings["browser_subprocess_path"] = "%s/%s" % (
8180
cefpython.GetModuleDirectory(), "subprocess")
@@ -114,23 +113,17 @@ def run(self):
114113
lys = self.canvas.layers()
115114
if len(lys) == 0:
116115
qgsutils.showUserAndLogMessage(
117-
self, u"Information: ", u"You need to upload the photo layer.",
118-
QgsMessageBar.INFO)
116+
u"Information: ", u"You need to upload the photo layer.")
119117
return
120118

121119
# Folder viewer for local server
122-
folder = self.plugin_path + "\\viewer"
123-
120+
folder = QgsApplication.qgisSettingsDirPath() + 'python/plugins/EquirectangularViewer/viewer'
124121
# Start local server in plugin folder
125122
openWebApp(folder)
126-
QtGui.qApp.processEvents()
127-
128123
self.StartCefPython()
129-
QtGui.qApp.processEvents()
130124

131125
# Create Timer is necessary for cefpython
132126
self.createTimer()
133-
QtGui.qApp.processEvents()
134127

135128
for layer in lys:
136129
if layer.name() == config.layer_name:
@@ -140,8 +133,7 @@ def run(self):
140133

141134
if self.encontrado is False:
142135
qgsutils.showUserAndLogMessage(
143-
self, u"Information: ", u"You need to upload the photo layer.",
144-
level=QgsMessageBar.INFO)
136+
u"Information: ", u"You need to upload the photo layer.")
145137

146138
return
147139

@@ -150,22 +142,12 @@ def ShowDialog(self, featuresId=None, layer=None):
150142
self.featuresId = featuresId
151143
self.layer = layer
152144

153-
Geo360 = qgis.utils.plugins["EquirectangularViewer"]
154-
try:
155-
if (Geo360.dlg):
156-
qgsutils.removeAllHighlightFeaturesFromCanvasScene(self.canvas)
157-
self.dlg.ReloadView(self.featuresId)
158-
159-
if(Geo360.dlg.isVisible() is False):
160-
self.dlg.show()
161-
return
162-
except:
163-
self.dlg = Geo360Dialog(self.iface, parent=self.iface.mainWindow(
164-
), featuresId=featuresId, layer=self.layer)
165-
self.dlg.setWindowFlags(
166-
Qt.WindowSystemMenuHint | Qt.WindowTitleHint)
145+
if self.dlg is None:
146+
self.dlg = Geo360Dialog(self.iface, parent=self, featuresId=featuresId, layer=self.layer)
147+
self.dlg.setWindowFlags(Qt.Window | Qt.WindowCloseButtonHint)
167148
self.dlg.show()
168-
None
149+
else:
150+
self.dlg.ReloadView(self.featuresId)
169151

170152

171153
class SelectTool(QgsMapToolIdentify):

0 commit comments

Comments
 (0)