Skip to content
Snippets Groups Projects
Commit 36532b05 authored by Arnaud Billon's avatar Arnaud Billon :speech_balloon:
Browse files

[refactor] Simplify statusBar and gridProperties

parent 3d61729a
No related branches found
No related tags found
No related merge requests found
......@@ -38,36 +38,21 @@ import lidarview.planefit as planefit
class AppLogic(object):
def __init__(self):
self.createStatusBarWidgets()
self.reader = None
self.trailingFrame = []
self.position = None
self.sensor = None
self.gridProperties = None
def createStatusBarWidgets(self):
self.logoLabel = QtGui.QLabel()
self.logoLabel.setPixmap(QtGui.QPixmap(":/vvResources/SoftwareInformation/bottom_logo.png"))
self.logoLabel.setScaledContents(True)
self.filenameLabel = QtGui.QLabel()
self.statusLabel = QtGui.QLabel()
self.sensorInformationLabel = QtGui.QLabel()
self.positionPacketInfoLabel = QtGui.QLabel()
class GridProperties:
def __init__(self):
self.Normal = [0, 0, 0]
self.Origin = [0, 0, 0]
self.Scale = 0
self.GridNbTicks = 0
self.LineWidth = 0
self.Color = [0, 0, 0]
self.Persist = False
# WIP this can be removed by providing SensorList singleton python wrappings
self.reader = None
self.sensor = None
self.trailingFrame = []
self.position = None
# WIP This can be removed through Statusbar creation and python wrappings in VeloViewManager
# Fields that Can be overriden to show some statuses
self.filenameLabel = QtGui.QLabel()
self.sensorInformationLabel = QtGui.QLabel()
self.positionPacketInfoLabel = QtGui.QLabel()
statusBar = getMainWindow().statusBar()
statusBar.addWidget(self.filenameLabel)
statusBar.addWidget(self.sensorInformationLabel)
statusBar.addWidget(self.positionPacketInfoLabel)
# Array Helper
def hasArrayName(sourceProxy, arrayName):
......@@ -755,14 +740,6 @@ def exportToDirectory(outDir, timesteps):
def onClose():
# Save grid properties for this session
app.gridProperties.Normal = app.grid.Normal
app.gridProperties.Origin = app.grid.Origin
app.gridProperties.Scale = app.grid.Scale
app.gridProperties.GridNbTicks = app.grid.GridNbTicks
app.gridProperties.LineWidth = app.grid.LineWidth
app.gridProperties.Color = app.grid.Color
smp.GetAnimationScene().Stop()
unloadData()
app.scene.AnimationTime = 0
......@@ -923,16 +900,42 @@ def showSourceInSpreadSheet(source):
def createGrid():
app.grid = smp.GridSource(guiName='Measurement Grid')
if app.gridProperties.Persist == False:
app.grid.GridNbTicks = (int(math.ceil(50000 * app.DistanceResolutionM/ app.grid.Scale )))
# Reset to default if not persistent asked
if (getPVSettings().value('LidarPlugin/grid/gridPropertiesPersist') != "true"):
# Default Settings # WIP NEED TO INIT OTHER PROPS ?
app.grid.GridNbTicks = 10
else:
# Restore grid properties
grid.Normal = app.gridProperties.Normal
grid.Origin = app.gridProperties.Origin
grid.Scale = app.gridProperties.Scale
grid.GridNbTicks = app.gridProperties.GridNbTicks
grid.LineWidth = app.gridProperties.LineWidth
grid.Color = app.gridProperties.Color
# Restore grid properties
lineWidth = getPVSettings().value('LidarPlugin/grid/LineWidth')
if lineWidth :
app.grid.LineWidth = int(lineWidth)
gridNbTicks = getPVSettings().value('LidarPlugin/grid/GridNbTicks')
if gridNbTicks :
app.grid.GridNbTicks = int(gridNbTicks)
if getPVSettings().value('LidarPlugin/grid/Normal'):
normal_x = getPVSettings().value('LidarPlugin/grid/Normal')[0]
normal_y = getPVSettings().value('LidarPlugin/grid/Normal')[1]
normal_z = getPVSettings().value('LidarPlugin/grid/Normal')[2]
app.grid.Normal = [float(normal_x), float(normal_y), float(normal_z)]
if getPVSettings().value('LidarPlugin/grid/Origin'):
origin_x = getPVSettings().value('LidarPlugin/grid/Origin')[0]
origin_y = getPVSettings().value('LidarPlugin/grid/Origin')[1]
origin_z = getPVSettings().value('LidarPlugin/grid/Origin')[2]
app.grid.Origin = [float(origin_x), float(origin_y), float(origin_z)]
scale = getPVSettings().value(getPVSettings().value('LidarPlugin/grid/Scale'))
if scale :
app.grid.Scale = float(scale)
if getPVSettings().value('LidarPlugin/grid/gridColor') :
r = getPVSettings().value('LidarPlugin/grid/gridColor')[0]
g = getPVSettings().value('LidarPlugin/grid/gridColor')[1]
b = getPVSettings().value('LidarPlugin/grid/gridColor')[2]
app.grid.Color = [float(r), float(g), float(b)]
rep = smp.Show(app.grid)
rep.LineWidth = app.grid.LineWidth
......@@ -984,7 +987,6 @@ def start():
# Create Grid #WIP not perfect requires loaded plugin
app.DistanceResolutionM = 0.002
app.gridProperties = GridProperties() # Reset Grid Properties
createGrid()
def findQObjectByName(widgets, name):
......@@ -1028,10 +1030,19 @@ def setupStatusBar():
def onGridProperties():
if not app.grid:
createGrid()
if gridAdjustmentDialog.showDialog(getMainWindow(), app.grid, app.gridProperties):
if gridAdjustmentDialog.showDialog(getMainWindow(), app):
rep = smp.Show(app.grid)
rep.LineWidth = app.grid.LineWidth
rep.DiffuseColor = app.grid.Color
if(getPVSettings().value('LidarPlugin/grid/gridPropertiesPersist') == "true") :
getPVSettings().setValue('LidarPlugin/grid/gridColor', app.grid.Color)
getPVSettings().setValue('LidarPlugin/grid/LineWidth', app.grid.LineWidth)
getPVSettings().setValue('LidarPlugin/grid/GridNbTicks', app.grid.GridNbTicks)
getPVSettings().setValue('LidarPlugin/grid/Normal', app.grid.Normal)
getPVSettings().setValue('LidarPlugin/grid/Origin', app.grid.Origin)
getPVSettings().setValue('LidarPlugin/grid/Scale', app.grid.Scale)
smp.Render()
def hideColorByComponent():
......
......@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from PythonQt import QtCore, QtGui, QtUiTools
from PythonQt import QtCore, QtGui, QtUiTools, paraview
import math
def showDialog(mainWindow, grid, gridProperties):
def showDialog(mainWindow, app):
loader = QtUiTools.QUiLoader()
uifile = QtCore.QFile(':/LidarViewPlugin/vvGridAdjustmentDialog.ui')
......@@ -26,41 +26,51 @@ def showDialog(mainWindow, grid, gridProperties):
dialog = loader.load(uifile, mainWindow)
uifile.close()
# Delete "?" Button that appears on windows os
# Rewrite the flags without QtCore.Qt.WindowContextHelpButtonHint
flags = QtCore.Qt.Dialog | QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowCloseButtonHint
dialog.setWindowFlags(flags)
def w(name):
for widget in dialog.children():
if widget.objectName == name:
return widget
w('SensorUpX').setValue(grid.Normal[0])
w('SensorUpY').setValue(grid.Normal[1])
w('SensorUpZ').setValue(grid.Normal[2])
w('SensorUpX').setValue(app.grid.Normal[0])
w('SensorUpY').setValue(app.grid.Normal[1])
w('SensorUpZ').setValue(app.grid.Normal[2])
w('SensorOriginX').setValue(-grid.Origin[0])
w('SensorOriginY').setValue(-grid.Origin[1])
w('SensorOriginZ').setValue(-grid.Origin[2])
w('SensorOriginX').setValue(-app.grid.Origin[0])
w('SensorOriginY').setValue(-app.grid.Origin[1])
w('SensorOriginZ').setValue(-app.grid.Origin[2])
w('GridResolution').setValue(grid.Scale)
w('GridWidth').setValue(grid.Scale*grid.GridNbTicks)
w('GridLineWidth').setValue(grid.LineWidth)
w('GridResolution').setValue(app.grid.Scale)
w('GridWidth').setValue(app.grid.Scale*app.grid.GridNbTicks)
w('GridLineWidth').setValue(app.grid.LineWidth)
r = grid.Color[0] * 255
g = grid.Color[1] * 255
b = grid.Color[2] * 255
r = app.grid.Color[0] * 255
g = app.grid.Color[1] * 255
b = app.grid.Color[2] * 255
w('GridColorPicker').setStyleSheet("background-color: rgb(" + str(r) + "," + str(g) + "," + str(b) +");")
w('ShouldPropertiesPersist').checked = gridProperties.Persist
pvsettings = paraview.pqPVApplicationCore.instance().settings()
w('ShouldPropertiesPersist').setChecked(pvsettings.value('LidarPlugin/grid/gridPropertiesPersist') == "true")
def pickColor():
colorPicker = QtGui.QColorDialog()
qColor = colorPicker.getColor()
colorPicker.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
if(colorPicker.exec()):
qColor = colorPicker.selectedColor()
if not qColor.isValid():
return False
if not qColor.isValid():
return False
r = qColor.red()
g = qColor.green()
b = qColor.blue()
w('GridColorPicker').setStyleSheet("background-color: rgb(" + str(r) + "," + str(g) + "," + str(b) +");")
r = qColor.red()
g = qColor.green()
b = qColor.blue()
w('GridColorPicker').setStyleSheet("background-color: rgb(" + str(r) + "," + str(g) + "," + str(b) +");")
w('GridColorPicker').connect('clicked()', pickColor)
......@@ -68,13 +78,14 @@ def showDialog(mainWindow, grid, gridProperties):
if not accepted:
return False
grid.Normal = [w('SensorUpX').value, w('SensorUpY').value, w('SensorUpZ').value]
grid.Origin = [-w('SensorOriginX').value, -w('SensorOriginY').value, -w('SensorOriginZ').value]
grid.Scale = w('GridResolution').value
grid.GridNbTicks = int(math.ceil(w('GridWidth').value / w('GridResolution').value))
grid.LineWidth = w('GridLineWidth').value
app.grid.Normal = [w('SensorUpX').value, w('SensorUpY').value, w('SensorUpZ').value]
app.grid.Origin = [-w('SensorOriginX').value, -w('SensorOriginY').value, -w('SensorOriginZ').value]
app.grid.Scale = w('GridResolution').value
app.grid.GridNbTicks = int(math.ceil(w('GridWidth').value / w('GridResolution').value))
app.grid.LineWidth = w('GridLineWidth').value
color = w('GridColorPicker').palette.color(QtGui.QPalette.Background)
grid.Color = [color.redF(), color.greenF(), color.blueF()]
gridProperties.Persist = w('ShouldPropertiesPersist').checked
app.grid.Color = [color.redF(), color.greenF(), color.blueF()]
#app.gridPropertiesPersist = w('ShouldPropertiesPersist').checked #Useless
pvsettings.setValue('LidarPlugin/grid/gridPropertiesPersist', "true" if w('ShouldPropertiesPersist').checked else "false" )
return True
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment