Skip to content

Commit 325a1ea

Browse files
committed
fix linux version
1 parent ae58696 commit 325a1ea

173 files changed

Lines changed: 11973 additions & 350 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.
5.07 KB
Binary file not shown.

Project_example/images/4.jpg

6.9 MB
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"type": "FeatureCollection",
3+
"name": "photos_4326",
4+
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
5+
"features": [
6+
{ "type": "Feature", "properties": { "GID": null, "ORDER": 0.0, "PATH": "\/home\/fragalop\/Desktop\/Git\/EquirectangularViewer\/Project_example\/images\/0.jpg", "DIRECTION": 310.0 }, "geometry": { "type": "Point", "coordinates": [ -3.685760342621331, 40.400419291455293 ] } },
7+
{ "type": "Feature", "properties": { "GID": null, "ORDER": 1.0, "PATH": "images\/3.png", "DIRECTION": 310.0 }, "geometry": { "type": "Point", "coordinates": [ -3.685817060712635, 40.400469527479018 ] } },
8+
{ "type": "Feature", "properties": { "GID": null, "ORDER": 2.0, "PATH": "images\/2.jpg", "DIRECTION": 310.0 }, "geometry": { "type": "Point", "coordinates": [ -3.685865676219466, 40.400516522468955 ] } },
9+
{ "type": "Feature", "properties": { "GID": null, "ORDER": 3.0, "PATH": "\/home\/fragalop\/Desktop\/Git\/EquirectangularViewer\/Project_example\/images\/1.jpg", "DIRECTION": 310.0 }, "geometry": { "type": "Point", "coordinates": [ -3.685917532760087, 40.400561896942001 ] } },
10+
{ "type": "Feature", "properties": { "GID": null, "ORDER": 4.0, "PATH": "images\/2.jpg", "DIRECTION": 310.0 }, "geometry": { "type": "Point", "coordinates": [ -3.68597425085139, 40.400615373999514 ] } },
11+
{ "type": "Feature", "properties": { "GID": null, "ORDER": 5.0, "PATH": "images\/1.jpg", "DIRECTION": 310.0 }, "geometry": { "type": "Point", "coordinates": [ -3.68602610739201, 40.400670471573925 ] } },
12+
{ "type": "Feature", "properties": { "GID": null, "ORDER": 6.0, "PATH": "images\/0.jpg", "DIRECTION": 310.0 }, "geometry": { "type": "Point", "coordinates": [ -3.686079584449525, 40.400712605013176 ] } },
13+
{ "type": "Feature", "properties": { "GID": null, "ORDER": 7.0, "PATH": "images\/3.png", "DIRECTION": 310.0 }, "geometry": { "type": "Point", "coordinates": [ -3.686133061507039, 40.400759600003113 ] } },
14+
{ "type": "Feature", "properties": { "GID": null, "ORDER": 8.0, "PATH": "images\/4.jpg", "DIRECTION": 310.0 }, "geometry": { "type": "Point", "coordinates": [ -3.685701428121899, 40.400360181318021 ] } }
15+
]
16+
}

code/Geo360.py

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
/***************************************************************************
43
Equirectangular Viewer
@@ -18,37 +17,48 @@
1817
* *
1918
***************************************************************************/
2019
"""
21-
from qgis.gui import QgsMapToolIdentify
2220

21+
import sys
22+
import os
23+
from qgis.gui import QgsMapToolIdentify
2324
from PyQt5.QtCore import QTimer, Qt, QSettings, QThread
2425
from PyQt5.QtGui import QIcon, QCursor, QPixmap
2526
from PyQt5.QtWidgets import QAction
2627

2728
from EquirectangularViewer.Geo360Dialog import Geo360Dialog
2829
import EquirectangularViewer.config as config
29-
from EquirectangularViewer.server.local_server import openWebApp
30+
from EquirectangularViewer.server.local_server import serverInFolder, serverShutdown
3031
from EquirectangularViewer.utils.log import log
3132
from EquirectangularViewer.utils.qgsutils import qgsutils
3233
from qgis.core import QgsApplication
34+
import platform
3335

3436
try:
3537
from pydevd import *
3638
except ImportError:
3739
None
3840

41+
# libs_path = os.path.join(os.path.dirname(__file__), "libs")
42+
# sys.path.append(libs_path)
43+
3944
try:
40-
from cefpython3 import cefpython
45+
from cefpython3 import cefpython as cef
46+
import ctypes
4147
except ImportError:
4248
None
4349

50+
WINDOWS = (platform.system() == "Windows")
51+
LINUX = (platform.system() == "Linux")
52+
MAC = (platform.system() == "Darwin")
4453

4554
class Geo360:
46-
timer = None
4755

4856
"""QGIS Plugin Implementation."""
4957

5058
def __init__(self, iface):
5159

60+
if not cef.GetAppSetting("external_message_pump"):
61+
self.timer = self.createTimer()
5262
self.iface = iface
5363
self.canvas = self.iface.mapCanvas()
5464
threadcount = QThread.idealThreadCount()
@@ -60,13 +70,14 @@ def __init__(self, iface):
6070
self.dlg = None
6171

6272
def createTimer(self):
63-
self.timer = QTimer()
64-
self.timer.timeout.connect(self.onTimer)
65-
self.timer.start(10)
73+
timer = QTimer()
74+
timer.timeout.connect(self.onTimer)
75+
timer.start(10)
76+
return timer
6677

6778
def onTimer(self):
6879
try:
69-
cefpython.MessageLoopWork()
80+
cef.MessageLoopWork()
7081
except Exception:
7182
None
7283

@@ -77,18 +88,24 @@ def StartCefPython(self):
7788
''' Start CefPython '''
7889
settings = {}
7990
settings["browser_subprocess_path"] = "%s/%s" % (
80-
cefpython.GetModuleDirectory(), "subprocess")
81-
settings["log_severity"] = cefpython.LOGSEVERITY_DISABLE
91+
cef.GetModuleDirectory(), "subprocess")
92+
settings["log_severity"] = cef.LOGSEVERITY_DISABLE
8293
settings["context_menu"] = {
83-
"enabled": False,
94+
"enabled": True,
8495
"navigation": False, # Back, Forward, Reload
85-
"print": False,
86-
"view_source": False,
96+
"print": True,
97+
"view_source": True,
8798
"external_browser": False, # Open in external browser
88-
"devtools": False, # Developer Tools
99+
"devtools": True, # Developer Tools
89100
}
101+
102+
if MAC:
103+
# requires enabling message pump on Mac
104+
# in Qt example. Calling cef.DoMessageLoopWork in a timer
105+
# doesn't work anymore.
106+
settings["external_message_pump"] = True
90107

91-
cefpython.Initialize(settings)
108+
cef.Initialize(settings)
92109

93110
def initGui(self):
94111
''' Add Geo360 tool '''
@@ -104,38 +121,38 @@ def unload(self):
104121
''' Unload Geo360 tool '''
105122
self.iface.removePluginMenu(u"&Equirectangular Viewer", self.action)
106123
self.iface.removeToolBarIcon(self.action)
124+
#ShutDown server
125+
serverShutdown()
126+
#ShutDown Cef
127+
cef.Shutdown()
107128

108129
def run(self):
109130
''' Run click feature '''
110-
self.encontrado = False
131+
#Trick fix AttributeError: module 'sys' has no attribute 'argv'
132+
# We need fedback about this
133+
sys.argv = []
134+
135+
self.found = False
111136

112137
# Check if mapa foto is loaded
113138
lys = self.canvas.layers()
114-
if len(lys) == 0:
139+
for layer in lys:
140+
if layer.name() == config.layer_name:
141+
self.found = True
142+
self.mapTool = SelectTool(self.iface, parent=self, layer=layer)
143+
self.iface.mapCanvas().setMapTool(self.mapTool)
144+
145+
if self.found is False:
115146
qgsutils.showUserAndLogMessage(
116147
u"Information: ", u"You need to upload the photo layer.")
117148
return
118149

119150
# Folder viewer for local server
120151
folder = QgsApplication.qgisSettingsDirPath() + 'python/plugins/EquirectangularViewer/viewer'
121152
# Start local server in plugin folder
122-
openWebApp(folder)
153+
serverInFolder(folder)
123154
self.StartCefPython()
124155

125-
# Create Timer is necessary for cefpython
126-
self.createTimer()
127-
128-
for layer in lys:
129-
if layer.name() == config.layer_name:
130-
self.encontrado = True
131-
self.mapTool = SelectTool(self.iface, parent=self, layer=layer)
132-
self.iface.mapCanvas().setMapTool(self.mapTool)
133-
134-
if self.encontrado is False:
135-
qgsutils.showUserAndLogMessage(
136-
u"Information: ", u"You need to upload the photo layer.")
137-
138-
return
139156

140157
def ShowDialog(self, featuresId=None, layer=None):
141158
''' Run dialog Geo360 '''

0 commit comments

Comments
 (0)