Example #1
0
	def execute(self):
		"Convert to postscript button has been clicked. Export the canvas as a postscript file."
		postscriptFileName = archive.getFilePathWithUnderscoredBasename( self.fileName, self.suffix )
		boundingBox = self.canvas.bbox( settings.Tkinter.ALL ) # tuple (w, n, e, s)
		boxW = boundingBox[0]
		boxN = boundingBox[1]
		boxWidth = boundingBox[2] - boxW
		boxHeight = boundingBox[3] - boxN
		print('Exported postscript file saved as ' + postscriptFileName )
		self.canvas.postscript( file = postscriptFileName, height = boxHeight, width = boxWidth, pageheight = boxHeight, pagewidth = boxWidth, x = boxW, y = boxN )
		fileExtension = self.fileExtension.value
		postscriptProgram = self.postscriptProgram.value
		if postscriptProgram == '':
			return
		postscriptFilePath = '"' + os.path.normpath( postscriptFileName ) + '"' # " to send in file name with spaces
		shellCommand = postscriptProgram
		print('')
		if fileExtension == '':
			shellCommand += ' ' + postscriptFilePath
			print('Sending the shell command:')
			print(shellCommand)
			commandResult = os.system(shellCommand)
			if commandResult != 0:
				print('It may be that the system could not find the %s program.' % postscriptProgram )
				print('If so, try installing the %s program or look for another one, like the Gnu Image Manipulation Program (Gimp) which can be found at:' % postscriptProgram )
				print('http://www.gimp.org/')
			return
		shellCommand += ' ' + archive.getFilePathWithUnderscoredBasename( postscriptFilePath, '.' + fileExtension + '"')
		print('Sending the shell command:')
		print(shellCommand)
		commandResult = os.system(shellCommand)
		if commandResult != 0:
			print('The %s program could not convert the postscript to the %s file format.' % ( postscriptProgram, fileExtension ) )
			print('Try installing the %s program or look for another one, like Image Magick which can be found at:' % postscriptProgram )
			print('http://www.imagemagick.org/script/index.php')
Example #2
0
	def execute(self):
		"Convert to postscript button has been clicked. Export the canvas as a postscript file."
		postscriptFileName = archive.getFilePathWithUnderscoredBasename( self.fileName, self.suffix )
		boundingBox = self.canvas.bbox( settings.Tkinter.ALL ) # tuple (w, n, e, s)
		boxW = boundingBox[0]
		boxN = boundingBox[1]
		boxWidth = boundingBox[2] - boxW
		boxHeight = boundingBox[3] - boxN
		print('Exported postscript file saved as ' + postscriptFileName )
		self.canvas.postscript( file = postscriptFileName, height = boxHeight, width = boxWidth, pageheight = boxHeight, pagewidth = boxWidth, x = boxW, y = boxN )
		fileExtension = self.fileExtension.value
		postscriptProgram = self.postscriptProgram.value
		if postscriptProgram == '':
			return
		postscriptFilePath = '"' + os.path.normpath( postscriptFileName ) + '"' # " to send in file name with spaces
		shellCommand = postscriptProgram
		print('')
		if fileExtension == '':
			shellCommand += ' ' + postscriptFilePath
			print('Sending the shell command:')
			print(shellCommand)
			commandResult = os.system(shellCommand)
			if commandResult != 0:
				print('It may be that the system could not find the %s program.' % postscriptProgram )
				print('If so, try installing the %s program or look for another one, like the Gnu Image Manipulation Program (Gimp) which can be found at:' % postscriptProgram )
				print('http://www.gimp.org/')
			return
		shellCommand += ' ' + archive.getFilePathWithUnderscoredBasename( postscriptFilePath, '.' + fileExtension + '"')
		print('Sending the shell command:')
		print(shellCommand)
		commandResult = os.system(shellCommand)
		if commandResult != 0:
			print('The %s program could not convert the postscript to the %s file format.' % ( postscriptProgram, fileExtension ) )
			print('Try installing the %s program or look for another one, like Image Magick which can be found at:' % postscriptProgram )
			print('http://www.imagemagick.org/script/index.php')
Example #3
0
	def execute(self):
		"Export the canvas as an svg file."
		svgFileName = archive.getFilePathWithUnderscoredBasename( self.fileName, self.suffix )
		boundingBox = self.canvas.bbox( settings.Tkinter.ALL ) # tuple (w, n, e, s)
		self.boxW = boundingBox[0]
		self.boxN = boundingBox[1]
		boxWidth = boundingBox[2] - self.boxW
		boxHeight = boundingBox[3] - self.boxN
		print('Exported svg file saved as ' + svgFileName )
		svgTemplateText = archive.getFileTextInFileDirectory( settings.__file__, os.path.join('templates', 'canvas_template.svg') )
		output = cStringIO.StringIO()
		lines = archive.getTextLines( svgTemplateText )
		firstWordTable = {}
		firstWordTable['height="999px"'] = '		height="%spx"' % int( round( boxHeight ) )
		firstWordTable['<!--replaceLineWith_coloredLines-->'] = self.getCanvasLinesOutput()
		firstWordTable['replaceLineWithTitle'] = archive.getSummarizedFileName( self.fileName )
		firstWordTable['width="999px"'] = '		width="%spx"' % int( round( boxWidth ) )
		for line in lines:
			parseLineReplace( firstWordTable, line, output )
		archive.writeFileText( svgFileName, output.getvalue() )
		fileExtension = self.fileExtension.value
		svgViewer = self.svgViewer.value
		if svgViewer == '':
			return
		if svgViewer == 'webbrowser':
			settings.openWebPage( svgFileName )
			return
		svgFilePath = '"' + os.path.normpath( svgFileName ) + '"' # " to send in file name with spaces
		shellCommand = svgViewer + ' ' + svgFilePath
		print('')
		if fileExtension == '':
			print('Sending the shell command:')
			print( shellCommand )
			commandResult = os.system( shellCommand )
			if commandResult != 0:
				print('It may be that the system could not find the %s program.' % svgViewer )
				print('If so, try installing the %s program or look for another svg viewer, like Netscape which can be found at:' % svgViewer )
				print('http://www.netscape.org/')
			return
		convertedFileName = archive.getFilePathWithUnderscoredBasename( svgFilePath, '.' + fileExtension + '"')
		shellCommand += ' ' + convertedFileName
		print('Sending the shell command:')
		print( shellCommand )
		commandResult = os.system( shellCommand )
		if commandResult != 0:
			print('The %s program could not convert the svg to the %s file format.' % ( svgViewer, fileExtension ) )
			print('Try installing the %s program or look for another one, like Image Magick which can be found at:' % svgViewer )
			print('http://www.imagemagick.org/script/index.php')
Example #4
0
def writeOutput(fileName=''):
	"Carve a GNU Triangulated Surface file."
	startTime = time.time()
	print('File ' + archive.getSummarizedFileName(fileName) + ' is being carved.')
	repository = CarveRepository()
	settings.getReadRepository(repository)
	carveGcode = getCraftedText( fileName, '', repository )
	if carveGcode == '':
		return
	suffixFileName = archive.getFilePathWithUnderscoredBasename( fileName, '_carve.svg')
	archive.writeFileText( suffixFileName, carveGcode )
	print('The carved file is saved as ' + archive.getSummarizedFileName(suffixFileName) )
	print('It took %s to carve the file.' % euclidean.getDurationString( time.time() - startTime ) )
	settings.openSVGPage( suffixFileName, repository.svgViewer.value )
Example #5
0
def writeOutput(fileName=''):
	"Carve a GNU Triangulated Surface file."
	startTime = time.time()
	print('File ' + archive.getSummarizedFileName(fileName) + ' is being carved.')
	repository = CarveRepository()
	settings.getReadRepository(repository)
	carveGcode = getCraftedText( fileName, '', repository )
	if carveGcode == '':
		return
	suffixFileName = archive.getFilePathWithUnderscoredBasename( fileName, '_carve.svg')
	archive.writeFileText( suffixFileName, carveGcode )
	print('The carved file is saved as ' + archive.getSummarizedFileName(suffixFileName) )
	print('It took %s to carve the file.' % euclidean.getDurationString( time.time() - startTime ) )
	settings.openSVGPage( suffixFileName, repository.svgViewer.value )
Example #6
0
def writeOutput(fileName, shouldAnalyze=True):
    "Carve a GNU Triangulated Surface file."
    startTime = time.time()
    print("File " + archive.getSummarizedFileName(fileName) + " is being carved.")
    repository = CarveRepository()
    settings.getReadRepository(repository)
    carveGcode = getCraftedText(fileName, "", repository)
    if carveGcode == "":
        return
    suffixFileName = archive.getFilePathWithUnderscoredBasename(fileName, "_carve.svg")
    archive.writeFileText(suffixFileName, carveGcode)
    print("The carved file is saved as " + archive.getSummarizedFileName(suffixFileName))
    print("It took %s to carve the file." % euclidean.getDurationString(time.time() - startTime))
    if shouldAnalyze:
        settings.openSVGPage(suffixFileName, repository.svgViewer.value)