Skip to content

Commit

Permalink
Merge pull request #666 from thopiekar/master-code-fixes
Browse files Browse the repository at this point in the history
Fixing small issues in the code (#2)
  • Loading branch information
Ghostkeeper committed Mar 17, 2016
2 parents a20e98d + f93f033 commit 14f5d23
Show file tree
Hide file tree
Showing 25 changed files with 49 additions and 85 deletions.
2 changes: 1 addition & 1 deletion cura/ConvexHullNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, node, hull, parent = None):
self._convex_hull_head_mesh = None
self._hull = hull

hull_points = self._hull.getPoints()
hull_points = self._hull.getPoints() # TODO: @UnusedVariable
hull_mesh = self.createHullMesh(self._hull.getPoints())
if hull_mesh:
self.setMeshData(hull_mesh)
Expand Down
2 changes: 1 addition & 1 deletion cura/CuraActions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, QUrl
from PyQt5.QtCore import QObject, pyqtSlot, QUrl
from PyQt5.QtGui import QDesktopServices

from UM.Event import CallFunctionEvent
Expand Down
11 changes: 3 additions & 8 deletions cura/CuraApplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,16 @@
from UM.Scene.Camera import Camera
from UM.Scene.Platform import Platform
from UM.Math.Vector import Vector
from UM.Math.Matrix import Matrix
from UM.Math.Quaternion import Quaternion
from UM.Math.AxisAlignedBox import AxisAlignedBox
from UM.Resources import Resources
from UM.Scene.ToolHandle import ToolHandle
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
from UM.Mesh.WriteMeshJob import WriteMeshJob
from UM.Mesh.ReadMeshJob import ReadMeshJob
from UM.Logger import Logger
from UM.Preferences import Preferences
from UM.Message import Message
from UM.PluginRegistry import PluginRegistry
from UM.JobQueue import JobQueue
from UM.Math.Polygon import Polygon

from UM.Scene.BoxRenderer import BoxRenderer
from UM.Scene.Selection import Selection
from UM.Scene.GroupDecorator import GroupDecorator

Expand All @@ -41,7 +35,7 @@
from . import ZOffsetDecorator
from . import CuraSplashScreen

from PyQt5.QtCore import pyqtSlot, QUrl, Qt, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
from PyQt5.QtGui import QColor, QIcon
from PyQt5.QtQml import qmlRegisterUncreatableType

Expand Down Expand Up @@ -353,7 +347,7 @@ def multiplyObject(self, object_id, count):

if node:
op = GroupedOperation()
for i in range(count):
for _ in range(count):
if node.getParent() and node.getParent().callDecoration("isGroup"):
new_node = copy.deepcopy(node.getParent()) #Copy the group node.
new_node.callDecoration("setConvexHull",None)
Expand Down Expand Up @@ -528,6 +522,7 @@ def mergeSelected(self):
try:
group_node = Selection.getAllSelectedObjects()[0]
except Exception as e:
Logger.log("d", "mergeSelected: Exception:", e)
return
multi_material_decorator = MultiMaterialDecorator.MultiMaterialDecorator()
group_node.addDecorator(multi_material_decorator)
Expand Down
14 changes: 6 additions & 8 deletions cura/LayerData.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from UM.Math.Vector import Vector

import numpy
import math
import copy

class LayerData(MeshData):
def __init__(self):
Expand All @@ -20,11 +18,11 @@ def addLayer(self, layer):
if layer not in self._layers:
self._layers[layer] = Layer(layer)

def addPolygon(self, layer, type, data, line_width):
def addPolygon(self, layer, polygon_type, data, line_width):
if layer not in self._layers:
self.addLayer(layer)

p = Polygon(self, type, data, line_width)
p = Polygon(self, polygon_type, data, line_width)
self._layers[layer].polygons.append(p)

def getLayer(self, layer):
Expand Down Expand Up @@ -69,8 +67,8 @@ def build(self):
self.addIndices(indices.flatten())

class Layer():
def __init__(self, id):
self._id = id
def __init__(self, layer_id):
self._id = layer_id
self._height = 0.0
self._thickness = 0.0
self._polygons = []
Expand Down Expand Up @@ -173,9 +171,9 @@ class Polygon():
MoveCombingType = 8
MoveRetractionType = 9

def __init__(self, mesh, type, data, line_width):
def __init__(self, mesh, polygon_type, data, line_width):
self._mesh = mesh
self._type = type
self._type = polygon_type
self._data = data
self._line_width = line_width / 1000

Expand Down
2 changes: 0 additions & 2 deletions cura/PlatformPhysics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

from UM.Scene.SceneNode import SceneNode
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
from UM.Operations.TranslateOperation import TranslateOperation
from UM.Math.Float import Float
from UM.Math.Vector import Vector
from UM.Math.AxisAlignedBox import AxisAlignedBox
from UM.Application import Application
Expand Down
2 changes: 0 additions & 2 deletions cura/PlatformPhysicsOperation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# Cura is released under the terms of the AGPLv3 or higher.

from UM.Operations.Operation import Operation
from UM.Operations.AddSceneNodeOperation import AddSceneNodeOperation
from UM.Operations.TranslateOperation import TranslateOperation
from UM.Operations.GroupedOperation import GroupedOperation

## A specialised operation designed specifically to modify the previous operation.
Expand Down
4 changes: 1 addition & 3 deletions cura/PrintInformation.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Copyright (c) 2015 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher.

from PyQt5.QtCore import QObject, QDateTime, QTimer, pyqtSignal, pyqtSlot, pyqtProperty
from PyQt5.QtCore import QObject, pyqtSignal, pyqtProperty

from UM.Application import Application
from UM.Resources import Resources
from UM.Scene.SceneNode import SceneNode
from UM.Qt.Duration import Duration

import math
Expand Down
2 changes: 1 addition & 1 deletion plugins/ChangeLogPlugin/ChangeLog.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def getChangeLogs(self):
@pyqtSlot(result = str)
def getChangeLogString(self):
logs = self.getChangeLogs()
latest_version = Version(Preferences.getInstance().getValue("general/latest_version_changelog_shown"))
latest_version = Version(Preferences.getInstance().getValue("general/latest_version_changelog_shown")) #TODO: @UnusedVariable
result = ""
for version in logs:
result += "<h1>" + str(version) + "</h1><br>"
Expand Down
6 changes: 0 additions & 6 deletions plugins/CuraEngineBackend/CuraEngineBackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,19 @@
from UM.Backend.Backend import Backend
from UM.Application import Application
from UM.Scene.SceneNode import SceneNode
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
from UM.Preferences import Preferences
from UM.Math.Vector import Vector
from UM.Signal import Signal
from UM.Logger import Logger
from UM.Qt.Bindings.BackendProxy import BackendState #To determine the state of the slicing job.
from UM.Resources import Resources
from UM.Settings.SettingOverrideDecorator import SettingOverrideDecorator
from UM.Message import Message
from UM.PluginRegistry import PluginRegistry

from cura.OneAtATimeIterator import OneAtATimeIterator
from . import ProcessSlicedObjectListJob
from . import ProcessGCodeJob
from . import StartSliceJob

import os
import sys
import numpy

from PyQt5.QtCore import QTimer

Expand Down
13 changes: 6 additions & 7 deletions plugins/CuraEngineBackend/ProcessSlicedObjectListJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from cura import LayerDataDecorator

import numpy
import struct

catalog = i18nCatalog("cura")

Expand Down Expand Up @@ -51,7 +50,7 @@ def run(self):

object_id_map = {}
new_node = SceneNode()
## Put all nodes in a dict identified by ID
## Put all nodes in a dictionary identified by ID
for node in DepthFirstIterator(self._scene.getRoot()):
if type(node) is SceneNode and node.getMeshData():
if node.callDecoration("getLayerData"):
Expand All @@ -74,15 +73,15 @@ def run(self):
layer_count += self._message.getRepeatedMessage("objects", i).repeatedMessageCount("layers")

current_layer = 0
for i in range(self._message.repeatedMessageCount("objects")):
object = self._message.getRepeatedMessage("objects", i)
for object_position in range(self._message.repeatedMessageCount("objects")):
current_object = self._message.getRepeatedMessage("objects", object_position)
try:
node = object_id_map[object.id]
node = object_id_map[current_object.id]
except KeyError:
continue

for l in range(object.repeatedMessageCount("layers")):
layer = object.getRepeatedMessage("layers", l)
for l in range(current_object.repeatedMessageCount("layers")):
layer = current_object.getRepeatedMessage("layers", l)

layer_data.addLayer(layer.id)
layer_data.setLayerHeight(layer.id, layer.height)
Expand Down
8 changes: 4 additions & 4 deletions plugins/CuraEngineBackend/StartSliceJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ def run(self):
group_message = slice_message.addRepeatedMessage("object_lists")
if group[0].getParent().callDecoration("isGroup"):
self._handlePerObjectSettings(group[0].getParent(), group_message)
for object in group:
mesh_data = object.getMeshData().getTransformed(object.getWorldTransformation())
for current_object in group:
mesh_data = current_object.getMeshData().getTransformed(current_object.getWorldTransformation())

obj = group_message.addRepeatedMessage("objects")
obj.id = id(object)
obj.id = id(current_object)

verts = numpy.array(mesh_data.getVertices())
verts[:,[1,2]] = verts[:,[2,1]]
verts[:,1] *= -1

obj.vertices = verts

self._handlePerObjectSettings(object, obj)
self._handlePerObjectSettings(current_object, obj)

Job.yieldThread()

Expand Down
1 change: 1 addition & 0 deletions plugins/CuraProfileReader/CuraProfileReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Cura is released under the terms of the AGPLv3 or higher.

from UM.Application import Application #To get the machine manager to create the new profile in.
from UM.Logger import Logger
from UM.Settings.Profile import Profile
from UM.Settings.ProfileReader import ProfileReader

Expand Down
1 change: 0 additions & 1 deletion plugins/CuraProfileWriter/CuraProfileWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from UM.Logger import Logger
from UM.SaveFile import SaveFile
from UM.Settings.Profile import Profile
from UM.Settings.ProfileWriter import ProfileWriter

## Writes profiles to Cura's own profile format with config files.
Expand Down
1 change: 0 additions & 1 deletion plugins/GCodeWriter/GCodeWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from UM.Mesh.MeshWriter import MeshWriter
from UM.Logger import Logger
from UM.Application import Application
import io
import re #For escaping characters in the settings.
import copy

Expand Down
7 changes: 3 additions & 4 deletions plugins/ImageReader/ImageReader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) 2015 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher.

import os
import numpy

from PyQt5.QtGui import QImage, qRed, qGreen, qBlue
Expand Down Expand Up @@ -49,8 +48,8 @@ def read(self, file_name):
return self._generateSceneNode(file_name, size, self._ui.peak_height, self._ui.base_height, self._ui.smoothing, 512, self._ui.image_color_invert)

def _generateSceneNode(self, file_name, xz_size, peak_height, base_height, blur_iterations, max_size, image_color_invert):
mesh = None
scene_node = None
mesh = None # TODO: @UnusedVariable
scene_node = None # TODO: @UnusedVariable

scene_node = SceneNode()

Expand Down Expand Up @@ -111,7 +110,7 @@ def _generateSceneNode(self, file_name, xz_size, peak_height, base_height, blur_
if image_color_invert:
height_data = 1 - height_data

for i in range(0, blur_iterations):
for _ in range(0, blur_iterations):
copy = numpy.pad(height_data, ((1, 1), (1, 1)), mode= "edge")

height_data += copy[1:-1, 2:]
Expand Down
2 changes: 1 addition & 1 deletion plugins/LayerView/LayerView.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def setLayer(self, value):

def calculateMaxLayers(self):
scene = self.getController().getScene()
renderer = self.getRenderer() # TODO: Unused variable
renderer = self.getRenderer() # TODO: @UnusedVariable
self._activity = True

self._old_max_layers = self._max_layers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _findInTree(self, t, n):
if type(t) is dict:
if "_name" in t and t["_name"] == n:
ret.append(t)
for k, v in t.items():
for k, v in t.items(): # TODO: @UnusedVariable "k"
ret += self._findInTree(v, n)
if type(t) is list:
for v in t:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
from UM.OutputDevice.OutputDevice import OutputDevice
from UM.OutputDevice import OutputDeviceError
from UM.Preferences import Preferences

from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")
Expand Down
1 change: 0 additions & 1 deletion plugins/RemovableDriveOutputDevice/RemovableDrivePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import threading
import time

from UM.Signal import Signal
from UM.Message import Message
from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin

Expand Down
Loading

0 comments on commit 14f5d23

Please sign in to comment.