Skip to content

Commit

Permalink
gui: Add types for lmgr constructor argument of GLWindow (3D) and Map…
Browse files Browse the repository at this point in the history
…Panel (2D) (OSGeo#4877)
  • Loading branch information
echoix authored Dec 27, 2024
1 parent fcfc5fa commit 36321f7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
26 changes: 16 additions & 10 deletions gui/wxpython/mapdisp/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
@author Stepan Turek <stepan.turek seznam.cz> (handlers support)
"""

import os
from __future__ import annotations

import copy
import os
from typing import TYPE_CHECKING

from core import globalvar
import wx
Expand All @@ -40,16 +43,16 @@
from gui_core.query import QueryDialog, PrepareQueryResults
from mapwin.buffered import BufferedMapWindow
from mapwin.decorations import (
LegendController,
BarscaleController,
ArrowController,
BarscaleController,
DtextController,
LegendController,
LegendVectController,
)
from mapwin.analysis import (
ProfileController,
MeasureDistanceController,
MeasureAreaController,
MeasureDistanceController,
ProfileController,
)
from gui_core.forms import GUI
from core.giface import Notification
Expand All @@ -59,9 +62,12 @@
from main_window.page import MainPageBase

import grass.script as gs

from grass.pydispatch.signal import Signal

if TYPE_CHECKING:
import lmgr.frame
import main_window.frame


class MapPanel(SingleMapPanel, MainPageBase):
"""Main panel for map display window. Drawing takes place in
Expand All @@ -76,7 +82,7 @@ def __init__(
toolbars=["map"],
statusbar=True,
tree=None,
lmgr=None,
lmgr: main_window.frame.GMFrame | lmgr.frame.GMFrame | None = None,
Map=None,
auimgr=None,
dockable=False,
Expand Down Expand Up @@ -296,7 +302,7 @@ def GetMapWindow(self):

def _addToolbarVDigit(self):
"""Add vector digitizer toolbar"""
from vdigit.main import haveVDigit, VDigit
from vdigit.main import VDigit, haveVDigit
from vdigit.toolbars import VDigitToolbar

if not haveVDigit:
Expand Down Expand Up @@ -401,7 +407,7 @@ def _updateVDigitLayers(self, layer):

def AddNviz(self):
"""Add 3D view mode window"""
from nviz.main import haveNviz, GLWindow, errorMsg
from nviz.main import GLWindow, errorMsg, haveNviz

# check for GLCanvas and OpenGL
if not haveNviz:
Expand Down Expand Up @@ -1603,7 +1609,7 @@ def _switchMapWindow(self, map_win):
def AddRDigit(self):
"""Adds raster digitizer: creates toolbar and digitizer controller,
binds events and signals."""
from rdigit.controller import RDigitController, EVT_UPDATE_PROGRESS
from rdigit.controller import EVT_UPDATE_PROGRESS, RDigitController
from rdigit.toolbars import RDigitToolbar

self.rdigit = RDigitController(self._giface, mapWindow=self.GetMapWindow())
Expand Down
25 changes: 20 additions & 5 deletions gui/wxpython/nviz/mapwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@
@author Anna Kratochvilova <kratochanna gmail.com> (Google SoC 2011)
"""

from __future__ import annotations

import copy
import math
import os
import sys
import time
import copy
import math

from threading import Thread
from typing import TYPE_CHECKING

import wx
from wx.lib.newevent import NewEvent
from wx import glcanvas
from wx.glcanvas import WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE
from wx.glcanvas import WX_GL_DEPTH_SIZE, WX_GL_DOUBLEBUFFER, WX_GL_RGBA

import grass.script as gs
from grass.pydispatch.signal import Signal
Expand All @@ -45,6 +47,10 @@
from core.utils import str2rgb
from core.giface import Notification

if TYPE_CHECKING:
import lmgr.frame
import main_window.frame

wxUpdateProperties, EVT_UPDATE_PROP = NewEvent()
wxUpdateView, EVT_UPDATE_VIEW = NewEvent()
wxUpdateLight, EVT_UPDATE_LIGHT = NewEvent()
Expand Down Expand Up @@ -74,7 +80,16 @@ def GetDisplay(self):
class GLWindow(MapWindowBase, glcanvas.GLCanvas):
"""OpenGL canvas for Map Display Window"""

def __init__(self, parent, giface, frame, Map, tree, lmgr, id=wx.ID_ANY):
def __init__(
self,
parent,
giface,
frame,
Map,
tree,
lmgr: main_window.frame.GMFrame | lmgr.frame.GMFrame,
id=wx.ID_ANY,
) -> None:
"""All parameters except for id are mandatory. The todo is to remove
them completely."""
self.parent = parent
Expand Down

0 comments on commit 36321f7

Please sign in to comment.