Merge branch '15.06'

* 15.06:
  Install the entire plugins directory into $prefix/lib/cura instead of just the contents
  Install the right source files
  Rename cura.py to cura_app.py to prevent conflicts with "cura" directory
  Set default brim size to 10 lines
  Fix context menu entries
  Move src to cura so we can use the same package for installed and source
  Add standard Cura install directories to resource and plugin paths
  Set default engine location to unix standard bin dir
  Make it possible to ignore translation targets and add install target
  Add support for loading files from command line
  Set version to 15.05.90 to indicate first beta release of 15.06
  Add __init__ file or else py2exe fails.
This commit is contained in:
Arjen Hiemstra 2015-05-27 15:12:24 +02:00
commit 4f6c8df224
14 changed files with 82 additions and 57 deletions

View file

@ -4,45 +4,58 @@ cmake_minimum_required(VERSION 2.8.12)
set(URANIUM_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/../uranium/scripts" CACHE DIRECTORY "The location of the scripts directory of the Uranium repository") set(URANIUM_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/../uranium/scripts" CACHE DIRECTORY "The location of the scripts directory of the Uranium repository")
# Extract Strings if(${URANIUM_SCRIPTS_DIR})
add_custom_target(extract-messages ${URANIUM_SCRIPTS_DIR}/extract-messages ${CMAKE_SOURCE_DIR} cura) # Extract Strings
add_custom_target(extract-messages ${URANIUM_SCRIPTS_DIR}/extract-messages ${CMAKE_SOURCE_DIR} cura)
# Build Translations # Build Translations
find_package(Gettext) find_package(Gettext)
include(${URANIUM_SCRIPTS_DIR}/ECMPoQmTools.cmake) include(${URANIUM_SCRIPTS_DIR}/ECMPoQmTools.cmake)
if(GETTEXT_FOUND) if(GETTEXT_FOUND)
# translations target will convert .po files into .mo and .qm as needed. # translations target will convert .po files into .mo and .qm as needed.
# The files are checked for a _qt suffix and if it is found, converted to # The files are checked for a _qt suffix and if it is found, converted to
# qm, otherwise they are converted to .po. # qm, otherwise they are converted to .po.
add_custom_target(translations) add_custom_target(translations)
# copy-translations can be used to copy the built translation files from the # copy-translations can be used to copy the built translation files from the
# build directory to the source resources directory. This is mostly a convenience # build directory to the source resources directory. This is mostly a convenience
# during development, normally you want to simply use the install target to install # during development, normally you want to simply use the install target to install
# the files along side the rest of the application. # the files along side the rest of the application.
add_custom_target(copy-translations) add_custom_target(copy-translations)
#TODO: Properly install the built files. This should be done after we move the applications out of the Uranium repo. #TODO: Properly install the built files. This should be done after we move the applications out of the Uranium repo.
set(languages set(languages
en en
x-test x-test
) )
foreach(lang ${languages}) foreach(lang ${languages})
file(GLOB po_files resources/i18n/${lang}/*.po) file(GLOB po_files resources/i18n/${lang}/*.po)
foreach(file ${po_files}) foreach(file ${po_files})
string(REGEX MATCH "qt\\.po$" match "${file}") string(REGEX MATCH "qt\\.po$" match "${file}")
if(match) if(match)
ecm_process_po_files_as_qm(${lang} PO_FILES ${file}) ecm_process_po_files_as_qm(${lang} PO_FILES ${file})
else() else()
string(REGEX REPLACE ".*/(.*).po" "${lang}/\\1.mo" mofile ${file}) string(REGEX REPLACE ".*/(.*).po" "${lang}/\\1.mo" mofile ${file})
add_custom_command(TARGET translations POST_BUILD COMMAND mkdir ARGS -p ${lang} COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} ARGS ${file} -o ${mofile}) add_custom_command(TARGET translations POST_BUILD COMMAND mkdir ARGS -p ${lang} COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} ARGS ${file} -o ${mofile})
endif() endif()
endforeach()
file(GLOB qm_files ${CMAKE_BINARY_DIR}/${lang}/*.qm)
file(GLOB mo_files ${CMAKE_BINARY_DIR}/${lang}/*.mo)
foreach(file ${qm_files} ${mo_files})
add_custom_command(TARGET copy-translations POST_BUILD COMMAND mkdir ARGS -p ${CMAKE_SOURCE_DIR}/resources/i18n/${lang}/LC_MESSAGES/ COMMAND cp ARGS ${file} ${CMAKE_SOURCE_DIR}/resources/i18n/${lang}/LC_MESSAGES/ COMMENT "Copying ${file}...")
endforeach()
endforeach() endforeach()
endif()
file(GLOB qm_files ${CMAKE_BINARY_DIR}/${lang}/*.qm)
file(GLOB mo_files ${CMAKE_BINARY_DIR}/${lang}/*.mo)
foreach(file ${qm_files} ${mo_files})
add_custom_command(TARGET copy-translations POST_BUILD COMMAND mkdir ARGS -p ${CMAKE_SOURCE_DIR}/resources/i18n/${lang}/LC_MESSAGES/ COMMAND cp ARGS ${file} ${CMAKE_SOURCE_DIR}/resources/i18n/${lang}/LC_MESSAGES/ COMMENT "Copying ${file}...")
endforeach()
endforeach()
endif() endif()
include(GNUInstallDirs)
find_package(PythonInterp 3.4.0 REQUIRED)
set(PYTHON_SITE_PACKAGES_DIR ${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages CACHE PATH "Install location of Python package")
install(DIRECTORY resources DESTINATION ${CMAKE_INSTALL_DATADIR}/cura)
install(DIRECTORY plugins DESTINATION ${CMAKE_INSTALL_LIBDIR}/cura)
file(GLOB cura_SRCS cura/*)
install(FILES ${cura_SRCS} DESTINATION ${PYTHON_SITE_PACKAGES_DIR}/cura)
install(FILES cura_app.py DESTINATION ${CMAKE_INSTALL_BINDIR})

View file

@ -7,6 +7,7 @@ from UM.Scene.Camera import Camera
from UM.Scene.Platform import Platform from UM.Scene.Platform import Platform
from UM.Math.Vector import Vector from UM.Math.Vector import Vector
from UM.Math.Matrix import Matrix from UM.Math.Matrix import Matrix
from UM.Math.Quaternion import Quaternion
from UM.Resources import Resources from UM.Resources import Resources
from UM.Scene.ToolHandle import ToolHandle from UM.Scene.ToolHandle import ToolHandle
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
@ -35,6 +36,7 @@ from . import PrintInformation
from PyQt5.QtCore import pyqtSlot, QUrl, Qt, pyqtSignal, pyqtProperty from PyQt5.QtCore import pyqtSlot, QUrl, Qt, pyqtSignal, pyqtProperty
from PyQt5.QtGui import QColor from PyQt5.QtGui import QColor
import platform
import sys import sys
import os.path import os.path
import numpy import numpy
@ -42,10 +44,11 @@ numpy.seterr(all="ignore")
class CuraApplication(QtApplication): class CuraApplication(QtApplication):
def __init__(self): def __init__(self):
Resources.addResourcePath(os.path.join(QtApplication.getInstallPrefix(), "share", "cura"))
if not hasattr(sys, "frozen"): if not hasattr(sys, "frozen"):
Resources.addResourcePath(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..")) Resources.addResourcePath(os.path.join(os.path.abspath(os.path.dirname(__file__)), ".."))
super().__init__(name = "cura", version = "master") super().__init__(name = "cura", version = "15.05.90")
self.setRequiredPlugins([ self.setRequiredPlugins([
"CuraEngineBackend", "CuraEngineBackend",
@ -72,6 +75,7 @@ class CuraApplication(QtApplication):
## Handle loading of all plugin types (and the backend explicitly) ## Handle loading of all plugin types (and the backend explicitly)
# \sa PluginRegistery # \sa PluginRegistery
def _loadPlugins(self): def _loadPlugins(self):
self._plugin_registry.addPluginLocation(os.path.join(QtApplication.getInstallPrefix(), "lib", "cura"))
if not hasattr(sys, "frozen"): if not hasattr(sys, "frozen"):
self._plugin_registry.addPluginLocation(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "plugins")) self._plugin_registry.addPluginLocation(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "plugins"))
@ -85,6 +89,9 @@ class CuraApplication(QtApplication):
self._plugin_registry.loadPlugin("CuraEngineBackend") self._plugin_registry.loadPlugin("CuraEngineBackend")
def addCommandLineOptions(self, parser):
parser.add_argument("file", nargs="*", help="Files to load after starting the application.")
def run(self): def run(self):
self._i18n_catalog = i18nCatalog("cura"); self._i18n_catalog = i18nCatalog("cura");
@ -153,6 +160,10 @@ class CuraApplication(QtApplication):
if self._engine.rootObjects: if self._engine.rootObjects:
self.closeSplash() self.closeSplash()
for file in self.getCommandLineOption("file", []):
job = ReadMeshJob(os.path.abspath(file))
job.start()
self.exec_() self.exec_()
def registerObjects(self, engine): def registerObjects(self, engine):
@ -205,9 +216,7 @@ class CuraApplication(QtApplication):
node = self.getController().getScene().findObject(object_id) node = self.getController().getScene().findObject(object_id)
if node: if node:
transform = node.getLocalTransformation() op = SetTransformOperation(node, Vector())
transform.setTranslation(Vector(0, 0, 0))
op = SetTransformOperation(node, transform)
op.push() op.push()
## Delete all mesh data on the scene. ## Delete all mesh data on the scene.
@ -240,9 +249,7 @@ class CuraApplication(QtApplication):
op = GroupedOperation() op = GroupedOperation()
for node in nodes: for node in nodes:
transform = node.getLocalTransformation() op.addOperation(SetTransformOperation(node, Vector()))
transform.setTranslation(Vector(0, 0, 0))
op.addOperation(SetTransformOperation(node, transform))
op.push() op.push()
@ -259,8 +266,7 @@ class CuraApplication(QtApplication):
op = GroupedOperation() op = GroupedOperation()
for node in nodes: for node in nodes:
transform = Matrix() op.addOperation(SetTransformOperation(node, Vector(), Quaternion(), Vector(1, 1, 1)))
op.addOperation(SetTransformOperation(node, transform))
op.push() op.push()
@ -274,12 +280,18 @@ class CuraApplication(QtApplication):
nodes.append(node) nodes.append(node)
if nodes: if not nodes:
file_name = node.getMeshData().getFileName() return
job = ReadMeshJob(file_name) for node in nodes:
job.finished.connect(lambda j: node.setMeshData(j.getResult())) if not node.getMeshData():
job.start() continue
file_name = node.getMeshData().getFileName()
if file_name:
job = ReadMeshJob(file_name)
job.finished.connect(lambda j: node.setMeshData(j.getResult()))
job.start()
## Get logging data of the backend engine ## Get logging data of the backend engine
# \returns \type{string} Logging data # \returns \type{string} Logging data

0
cura/__init__.py Normal file
View file

View file

@ -3,7 +3,7 @@
# Copyright (c) 2015 Ultimaker B.V. # Copyright (c) 2015 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher. # Cura is released under the terms of the AGPLv3 or higher.
from src.CuraApplication import CuraApplication import cura.CuraApplication
app = CuraApplication.getInstance() app = cura.CuraApplication.CuraApplication.getInstance()
app.run() app.run()

View file

@ -26,7 +26,7 @@ class CuraEngineBackend(Backend):
super().__init__() super().__init__()
# Find out where the engine is located, and how it is called. This depends on how Cura is packaged and which OS we are running on. # Find out where the engine is located, and how it is called. This depends on how Cura is packaged and which OS we are running on.
default_engine_location = "../PinkUnicornEngine/CuraEngine" default_engine_location = os.path.join(Application.getInstallPrefix(), "bin", "CuraEngine")
if hasattr(sys, "frozen"): if hasattr(sys, "frozen"):
default_engine_location = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), "CuraEngine") default_engine_location = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), "CuraEngine")
if sys.platform == "win32": if sys.platform == "win32":

View file

@ -912,7 +912,7 @@
"label": "Brim Line Count", "label": "Brim Line Count",
"description": "The amount of lines used for a brim: More lines means a larger brim which sticks better, but this also makes your effective print area smaller.", "description": "The amount of lines used for a brim: More lines means a larger brim which sticks better, but this also makes your effective print area smaller.",
"type": "int", "type": "int",
"default": 1, "default": 10,
"active_if": { "active_if": {
"setting": "adhesion_type", "setting": "adhesion_type",
"value": "Brim" "value": "Brim"

View file

@ -46,9 +46,9 @@ setup(name="Cura",
author_email="d.braam@ultimaker.com", author_email="d.braam@ultimaker.com",
url="http://software.ultimaker.com/", url="http://software.ultimaker.com/",
license="GNU AFFERO GENERAL PUBLIC LICENSE (AGPL)", license="GNU AFFERO GENERAL PUBLIC LICENSE (AGPL)",
scripts=["cura.py"], scripts=["cura_app.py"],
#windows=[{"script": "printer.py", "dest_name": "Cura"}], #windows=[{"script": "printer.py", "dest_name": "Cura"}],
console=[{"script": "cura.py"}], console=[{"script": "cura_app.py"}],
options={"py2exe": {"skip_archive": False, "includes": includes}}) options={"py2exe": {"skip_archive": False, "includes": includes}})
print("Coping Cura plugins.") print("Coping Cura plugins.")