From 9a950bdb82bb6167e1b54e5525e511f04f81572c Mon Sep 17 00:00:00 2001
From: Jan Caron <j.caron@fz-juelich.de>
Date: Thu, 5 Dec 2019 18:18:38 +0100
Subject: [PATCH] removed Vectorplot.plot_quiver3d_to_2d
 plottools.plot_3d_to_2d function should be used now for more control!

---
 pyramid/fielddata.py | 69 +-------------------------------------------
 1 file changed, 1 insertion(+), 68 deletions(-)

diff --git a/pyramid/fielddata.py b/pyramid/fielddata.py
index 3ce9c15..44075da 100644
--- a/pyramid/fielddata.py
+++ b/pyramid/fielddata.py
@@ -8,12 +8,11 @@ import abc
 import logging
 import sys
 import os
-import tempfile  # TODO: remove if unused!
 from scipy.ndimage.interpolation import rotate
 from numbers import Number
 
 import numpy as np
-from PIL import Image  # TODO: remove if unused!
+from PIL import Image
 from matplotlib import patheffects
 from matplotlib import pyplot as plt
 from matplotlib.colors import ListedColormap, LinearSegmentedColormap
@@ -1374,72 +1373,6 @@ class VectorData(FieldData):
             scene.scene.camera.position = position
         return vecs
 
-    def plot_quiver3d_to_2d(self, dim_uv=None, axis=None, figsize=None, dpi=100, **kwargs):
-        # TODO: into plottools and make available for all 3D plots if possible!
-        # TODO: Maybe as a decorator? Rename to mayvi_to_matlotlib? or just convert_3d_to_2d?
-        # TODO: Look at https://docs.enthought.com/mayavi/mayavi/tips.html and implement!
-        from mayavi import mlab
-        if figsize is None:
-            figsize = plottools.FIGSIZE_DEFAULT
-        if axis is None:
-            self._log.debug('axis is None')
-            fig = plt.figure(figsize=figsize, dpi=dpi)
-            axis = fig.add_subplot(1, 1, 1, aspect='equal')
-            # TODO: ? axis.set_facecolor(kwargs.get('bgcolor', (0.7, 0.7, 0.7)))
-        else:
-            pass  # TODO: get current figures dpi, it is used later!
-        # figsize (in inches) and dpi (dots per pixel) determine the res (resolution -> # of dots)!
-        res = np.min([int(i * dpi) for i in figsize])
-        # Two ways of proceeding
-        # (needs screen resolution, hardcode now, later: https://github.com/rr-/screeninfo):
-        from PyQt5 import QtWidgets
-        myApp = QtWidgets.QApplication(sys.argv)
-        sgeo = myApp.desktop().screenGeometry()
-        screen_res = (3840, 2160)  # TODO: hardcode now, later: https://github.com/rr-/screeninfo)
-        screen_res = sgeo.height(), sgeo.width()
-        print(screen_res)
-        # IF resolution of mayavi image is smaller than screen resolution:
-        if res < np.min(screen_res):
-            self._log.info(f'BIG ENOUGH (res.: {res})')
-            # all is good, we can use the screenshot function to get the mappable image!
-            self.plot_quiver3d(size=(res, res), labels=False, orientation=False, mode='arrow',
-                                bgcolor=(0.7, 0.7, 0.7))
-            imgmap = mlab.screenshot(mode='rgb', antialiased=True)
-        # ELSE resolution of mayavi image would exceed screen resolution:
-        else:
-            self._log.info(f'TOO SMALL (res.: {res})')
-            # mlab.savefig is used to circumvent screen resolution, magnification factor is used:
-            mag = res/np.min(screen_res)
-            # image resolution is reduced by factor mag (so that it fits on screen again)
-            res //= mag
-            self.plot_quiver3d(size=(res, res), labels=False, orientation=False, mode='arrow',
-                                bgcolor=(0.7, 0.7, 0.7))
-            # mlab.savefig takes mag factor that saves an image that is bigger by factor mag
-            tmpdir = tempfile.mkdtemp()
-            temp_path = 'temp.png'#TODO:os.path.join(tmpdir, 'temp.png')
-            print('Temp file created')
-            try:
-                mlab.savefig(temp_path, magnification=mag)
-                print(f'SAVED with mag={mag}!')
-                imgmap = np.asarray(Image.open(temp_path))
-                print('LOADED!')
-            except Exception as e:
-                raise e
-            finally:
-                #TODO:os.remove(temp_path)
-                os.rmdir(tmpdir)
-        # In both cases, log mappable shape and do the rest:
-        mlab.close(mlab.gcf())
-        self._log.info(f'mappable shape: {imgmap.shape[:2]} (res.: {res})')
-        if dim_uv is None:
-            dim_uv = self.dim[1:]
-        axis.imshow(imgmap, extent=[0, dim_uv[0], 0, dim_uv[1]], origin='upper')
-        kwargs.setdefault('scalebar', False)
-        kwargs.setdefault('hideaxes', True)
-        # TODO: RETURN AXIS AND FORMAT AFTER! kwargs are for quiverplot (do some defaults here,
-        # TODO not adding stuff like colorbars!!!!)!!!!
-        return plottools.format_axis(axis, **kwargs)
-
 
 class ScalarData(FieldData):
     """Class for storing scalar field data.
-- 
GitLab