From f18f6570a760ed536b37dda1d445a4f8a628ecad Mon Sep 17 00:00:00 2001 From: jasminium Date: Thu, 5 Sep 2019 10:25:01 +0100 Subject: [PATCH] autotranslate at user_object level. --- gprMax/cmds_geometry/cmds_geometry.py | 3 +++ gprMax/cmds_multiple.py | 3 +++ gprMax/cmds_single_use.py | 3 +++ gprMax/scene.py | 2 +- gprMax/user_inputs.py | 9 +++++++-- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gprMax/cmds_geometry/cmds_geometry.py b/gprMax/cmds_geometry/cmds_geometry.py index d9cc5f6a..2f56fc2f 100644 --- a/gprMax/cmds_geometry/cmds_geometry.py +++ b/gprMax/cmds_geometry/cmds_geometry.py @@ -10,6 +10,9 @@ class UserObjectGeometry: # hash command self.hash = '#example' + # auto translate + self.autotranslate = True + def __str__(self): """Readble user string as per hash commands.""" s = '' diff --git a/gprMax/cmds_multiple.py b/gprMax/cmds_multiple.py index 5a3c1d65..9e0004e3 100644 --- a/gprMax/cmds_multiple.py +++ b/gprMax/cmds_multiple.py @@ -53,6 +53,9 @@ class UserObjectMulti: self.kwargs = kwargs self.order = None self.hash = '#example' + # auto translate + self.autotranslate = True + def __str__(self): """Readble user string as per hash commands.""" diff --git a/gprMax/cmds_single_use.py b/gprMax/cmds_single_use.py index 588d9b4d..62d3f2a6 100644 --- a/gprMax/cmds_single_use.py +++ b/gprMax/cmds_single_use.py @@ -52,6 +52,9 @@ class UserObjectSingle: self.order = None self.kwargs = kwargs self.props = Properties() + # auto translate + self.autotranslate = True + for k, v in kwargs.items(): setattr(self.props, k, v) diff --git a/gprMax/scene.py b/gprMax/scene.py index c7e1f191..7ad32c7d 100644 --- a/gprMax/scene.py +++ b/gprMax/scene.py @@ -71,7 +71,7 @@ class Scene: for obj in cmds_sorted: # in the first level all objects belong to the main grid - uip = create_user_input_points(grid) + uip = create_user_input_points(grid, obj) # Create an instance to check the geometry points provided by the # user. The way the point are checked depends on which grid the # points belong to. diff --git a/gprMax/user_inputs.py b/gprMax/user_inputs.py index 5fde9c6a..f25c1e63 100644 --- a/gprMax/user_inputs.py +++ b/gprMax/user_inputs.py @@ -1,7 +1,6 @@ from .exceptions import CmdInputError from .subgrids.base import SubGridBase from .utilities import round_value -from .utilities import Printer import gprMax.config as config import numpy as np @@ -18,10 +17,16 @@ are rounding continuous points or checking the point is within the grid. Additionally all logic related to rounding points etc is encapulsated here. """ -def create_user_input_points(grid): + +def create_user_input_points(grid, user_obj): """Return a point checker class based on the grid supplied.""" if isinstance(grid, SubGridBase): + # local object configuration trumps. User can turn of autotranslate for + # specfic objects. + if not user_obj.autotranslate and config.general['autotranslate']: + return MainGridUserInput(grid) + if config.general['autotranslate']: return SubgridUserInput(grid) else: