Skip to content

Commit

Permalink
Merge remote-tracking branch 'TurBoss/VTK_METRIC'
Browse files Browse the repository at this point in the history
  • Loading branch information
KurtJacobson committed Jul 27, 2019
2 parents d1a1b19 + 9405f78 commit 73ce8d5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
45 changes: 41 additions & 4 deletions qtpyvcp/widgets/display_widgets/vtk_backplot/vtk_backplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@
from qtpyvcp.plugins import getPlugin
from qtpyvcp.widgets import VCPWidget
from qtpyvcp.utilities import logger
from qtpyvcp.utilities.info import Info

from base_canon import StatCanon
from base_backplot import BaseBackPlot

INFO = Info()

LOG = logger.getLogger(__name__)
STATUS = getPlugin('status')
TOOLTABLE = getPlugin('tooltable')
IN_DESIGNER = os.getenv('DESIGNER', False)
INIFILE = linuxcnc.ini(os.getenv("INI_FILE_NAME"))
MACHINE_UNITS = 2 if INFO.getIsMachineMetric() else 1

COLOR_MAP = {
'traverse': (188, 252, 201, 75),
Expand All @@ -34,6 +38,10 @@ class VTKCanon(StatCanon):
def __init__(self, colors=COLOR_MAP, *args, **kwargs):
super(VTKCanon, self).__init__(*args, **kwargs)

self.status = STATUS

self.units = MACHINE_UNITS

self.path_colors = colors

# Create a vtkUnsignedCharArray container and store the colors in it
Expand All @@ -51,7 +59,16 @@ def __init__(self, colors=COLOR_MAP, *args, **kwargs):
self.append_path_point = self.path_points.append

def add_path_point(self, line_type, start_point, end_point):
self.append_path_point((line_type, end_point[:3]))
if self.units == 2:
point_list = list()
for point in end_point:
point *= 25.4
point_list.append(point)

self.append_path_point((line_type, point_list[:3]))

else:
self.append_path_point((line_type, end_point[:3]))

def draw_lines(self):

Expand Down Expand Up @@ -118,6 +135,8 @@ def __init__(self, parent=None):
self.status = STATUS
self.stat = STATUS.stat

self.units = MACHINE_UNITS

self.axis = self.stat.axis

self.nav_style = vtk.vtkInteractorStyleTrackballCamera()
Expand Down Expand Up @@ -724,6 +743,7 @@ def __init__(self, axis):

x_max = axis[0]["max_position_limit"]
x_min = axis[0]["min_position_limit"]

y_max = axis[1]["max_position_limit"]
y_min = axis[1]["min_position_limit"]

Expand Down Expand Up @@ -795,6 +815,15 @@ def get_actor(self):

class Axes:
def __init__(self):

self.status = STATUS
self.units = MACHINE_UNITS

if self.units == 2:
self.length = 10.0
else:
self.length = 1.0

transform = vtk.vtkTransform()
transform.Translate(0.0, 0.0, 0.0) # Z up

Expand All @@ -804,14 +833,22 @@ def __init__(self):
self.actor.AxisLabelsOff()
self.actor.SetShaftType(vtk.vtkAxesActor.CYLINDER_SHAFT)

self.actor.SetTotalLength(self.length, self.length, self.length)

def get_actor(self):
return self.actor


class Tool:
def __init__(self, tool, offset):

self.height = 2.0
self.status = STATUS
self.units = MACHINE_UNITS

if self.units == 2:
self.height = 25.4 * 2.0
else:
self.height = 2.0

transform = vtk.vtkTransform()

Expand All @@ -823,8 +860,8 @@ def __init__(self, tool, offset):
transform.RotateWXYZ(90, 0, 1, 0)
else:
source = vtk.vtkCylinderSource()
source.SetHeight(1)
source.SetCenter(-offset[0], .5 - offset[2], offset[1])
source.SetHeight(self.height / 2)
source.SetCenter(-offset[0], self.height / 4 - offset[2], offset[1])
source.SetRadius(tool.diameter / 2)
transform.RotateWXYZ(90, 1, 0, 0)

Expand Down
12 changes: 12 additions & 0 deletions sim/xyz-metric.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ MAX_ANGULAR_VELOCITY = 180.0000
MIN_ANGULAR_VELOCITY = 1.6667
GEOMETRY = xyz

[VTK]
# VTK_Widget Options
MACHINE_BOUNDRY = True
MACHINE_TICKS = True
MACHINE_LABELS = False

PROGRAM_BOUNDRY = True
PROGRAM_TICKS = True
PROGRAM_LABELS = False

GRID_LINES = True

[FILTER]
PROGRAM_EXTENSION = .nc,.txt,.tap ; .ngc is always accepted

Expand Down

0 comments on commit 73ce8d5

Please # to comment.