only complain about missing Mentat release if needed...

This commit is contained in:
Philip Eisenlohr 2012-12-12 08:33:42 +00:00
parent 34645a7222
commit dfb791bcaf
1 changed files with 29 additions and 36 deletions

View File

@ -4,13 +4,6 @@ import sys, os, string, damask
from colorsys import * from colorsys import *
from optparse import OptionParser from optparse import OptionParser
sys.path.append(damask.solver.Marc().libraryPath('../../'))
try:
from py_mentat import *
except:
sys.stderr.write('warning: no valid Mentat release found')
# ----------------------------- # -----------------------------
def readConfig(configFile,ownPath): def readConfig(configFile,ownPath):
@ -165,24 +158,24 @@ if len(colors) == 0:
hlsColor_range = (options.symmetric and [[0,0.2,0.9],[0.333,0.2,0.9]]) or \ hlsColor_range = (options.symmetric and [[0,0.2,0.9],[0.333,0.2,0.9]]) or \
[[0.167,0.9,0.1],[0.167,0.1,0.9]] [[0.167,0.9,0.1],[0.167,0.1,0.9]]
elif len(colors) == 2: elif len(colors) == 2:
hlsColor_range = [map(float, colors[i].split(',')) for i in range(2)] hlsColor_range = [map(float, colors[i].split(',')) for i in range(2)]
elif colors[0] in config: elif colors[0] in config:
options.symmetric = config[colors[0]]['symmetric'] options.symmetric = config[colors[0]]['symmetric']
hlsColor_range = [config[colors[0]]['lower'],\ hlsColor_range = [config[colors[0]]['lower'],\
config[colors[0]]['upper']] config[colors[0]]['upper']]
else: else:
msg.append('two color tuples required') msg.append('two color tuples required')
if msg == []: if msg == []:
hlsColors_limits = [[0.0,0.0,0.0],[1.0,1.0,1.0]] hlsColors_limits = [[0.0,0.0,0.0],[1.0,1.0,1.0]]
if options.inverse: if options.inverse:
hlsColor_range = [hlsColor_range[1],hlsColor_range[0]] hlsColor_range = [hlsColor_range[1],hlsColor_range[0]]
for i in range(2): for i in range(2):
for j in range(min(3,len(hlsColor_range[i]))): for j in range(min(3,len(hlsColor_range[i]))):
if hlsColor_range[i][j] < hlsColors_limits[0][j] or hlsColor_range[i][j] > hlsColors_limits[1][j]: if hlsColor_range[i][j] < hlsColors_limits[0][j] or hlsColor_range[i][j] > hlsColors_limits[1][j]:
msg.append('%s of %s color exceeds limit'%(['hue','lightness','saturation'][j],limit)) msg.append('%s of %s color exceeds limit'%(['hue','lightness','saturation'][j],limit))
if msg != []: if msg != []:
parser.error('\n'+'\n'.join(msg)+'\n') parser.error('\n'+'\n'.join(msg)+'\n')
@ -205,27 +198,27 @@ else:
rgbColors = [ hls_to_rgb(hlsColor[0], hlsColor[1], hlsColor[2]) rgbColors = [ hls_to_rgb(hlsColor[0], hlsColor[1], hlsColor[2])
for hlsColor in hlsColors ] for hlsColor in hlsColors ]
if options.palette: if options.palette or options.palettef:
for rgb in rgbColors: for rgb in rgbColors:
print '\t'.join(map(lambda x: str(int(255*x)),rgb)) print '\t'.join(map(lambda x: {True: str(int(255*x)),
sys.exit(0) False:str( x)}[options.palette],rgb))
if options.palettef: else:
for rgb in rgbColors:
print '\t'.join(map(str,rgb))
sys.exit(0)
### connect to mentat and change colorMap ### connect to mentat and change colorMap
sys.path.append(damask.solver.Marc().libraryPath('../../'))
try:
from py_mentat import *
except:
sys.stderr.write('error: no valid Mentat release found\n')
sys.exit(1)
outputLocals = {} outputLocals = {}
print 'waiting to connect...' print 'waiting to connect...'
py_connect('',options.port) py_connect('',options.port)
print 'connected...' print 'connected...'
cmds = colorMap(rgbColors,options.baseIdx)
output(['*show_table']+cmds+['*show_model *redraw'],outputLocals,'Mentat')
py_disconnect()
if options.verbose:
output(cmds,outputLocals,'Stdout')
cmds = colorMap(rgbColors,options.baseIdx)
output(['*show_table']+cmds+['*show_model *redraw'],outputLocals,'Mentat')
py_disconnect()
if options.verbose:
output(cmds,outputLocals,'Stdout')