Esempio n. 1
0
    def ask_parameters(self):
        cache = context.application.cache
        nodes = cache.nodes
        last = cache.last
        next_to_last = cache.next_to_last

        if isinstance(last, Vector):
            if (len(nodes) >= 2) and isinstance(next_to_last, Vector):
                parent = nodes[-2].parent
                b1 = last.children[0].translation_relative_to(parent)
                e1 = last.children[1].translation_relative_to(parent)
                b2 = next_to_last.children[0].translation_relative_to(parent)
                e2 = next_to_last.children[1].translation_relative_to(parent)
                if (b1 is not None) and (e1 is not None) and (b2 is not None) and (e2 is not None):
                    angle = compute_angle(e1 - b1, e2 - b2)
                    axis = numpy.cross(e1 - b1, e2 - b2)
                    self.parameters.center = Translation(0.5*(b1+b2))
                    self.parameters.rotation = Rotation.from_properties(angle, axis, False)
            else:
                parent = next_to_last.parent
                b = last.children[0].translation_relative_to(parent)
                e = last.children[1].translation_relative_to(parent)
                if (b is not None) and (e is not None):
                    self.parameters.center = Translation(b)
                    self.parameters.rotation = Rotation.from_properties(numpy.pi*0.25, e - b, False)
        elif isinstance(last, GLTransformationMixin) and isinstance(last.transformation, Translation):
            parent = last.parent
            self.parameters.center = Translation(last.get_frame_relative_to(parent).t)
            self.parameters.rotation = Rotation.identity()
        else:
            self.parameters.center = Translation(calculate_center(cache.translations))

        if self.parameters_dialog.run(self.parameters) != gtk.RESPONSE_OK:
            self.parameters.clear()
Esempio n. 2
0
 def do(self):
     cache = context.application.cache
     for node in cache.nodes:
         child_translations = []
         translated_children = []
         for child in node.children:
             if isinstance(child, GLTransformationMixin) and isinstance(child.transformation, Translation):
                 if child.get_fixed():
                     translated_children = []
                     break
                 translated_children.append(child)
                 child_translations.append(child.transformation)
         if len(translated_children) > 0:
             translation = Translation(calculate_center(child_translations))
             CenterAlignBase.do(self, node, translated_children, translation)
Esempio n. 3
0
 def do(self):
     cache = context.application.cache
     for node in cache.nodes:
         child_translations = []
         translated_children = []
         for child in node.children:
             if isinstance(child, GLTransformationMixin) and isinstance(
                     child.transformation, Translation):
                 if child.get_fixed():
                     translated_children = []
                     break
                 translated_children.append(child)
                 child_translations.append(child.transformation)
         if len(translated_children) > 0:
             translation = Translation(calculate_center(child_translations))
             CenterAlignBase.do(self, node, translated_children,
                                translation)
Esempio n. 4
0
    def ask_parameters(self):
        cache = context.application.cache
        nodes = cache.nodes
        last = cache.last
        next_to_last = cache.next_to_last

        if isinstance(last, Vector):
            if (len(nodes) >= 2) and isinstance(next_to_last, Vector):
                parent = nodes[-2].parent
                b1 = last.children[0].translation_relative_to(parent)
                e1 = last.children[1].translation_relative_to(parent)
                b2 = next_to_last.children[0].translation_relative_to(parent)
                e2 = next_to_last.children[1].translation_relative_to(parent)
                if (b1 is not None) and (e1 is not None) and (
                        b2 is not None) and (e2 is not None):
                    angle = compute_angle(e1 - b1, e2 - b2)
                    axis = numpy.cross(e1 - b1, e2 - b2)
                    self.parameters.center = Translation(0.5 * (b1 + b2))
                    self.parameters.rotation = Rotation.from_properties(
                        angle, axis, False)
            else:
                parent = next_to_last.parent
                b = last.children[0].translation_relative_to(parent)
                e = last.children[1].translation_relative_to(parent)
                if (b is not None) and (e is not None):
                    self.parameters.center = Translation(b)
                    self.parameters.rotation = Rotation.from_properties(
                        numpy.pi * 0.25, e - b, False)
        elif isinstance(last, GLTransformationMixin) and isinstance(
                last.transformation, Translation):
            parent = last.parent
            self.parameters.center = Translation(
                last.get_frame_relative_to(parent).t)
            self.parameters.rotation = Rotation.identity()
        else:
            self.parameters.center = Translation(
                calculate_center(cache.translations))

        if self.parameters_dialog.run(self.parameters) != gtk.RESPONSE_OK:
            self.parameters.clear()
Esempio n. 5
0
    def ask_parameters(self):
        cache = context.application.cache
        nodes = cache.nodes
        last = cache.last
        next_to_last = cache.next_to_last

        if isinstance(last, Vector):
            if (len(nodes) >= 2) and isinstance(next_to_last, Vector):
                raise NotImplementedError("This part of the code is not supported yet.")
                b1 = last.children[0].translation_relative_to(parent)
                e1 = last.children[1].translation_relative_to(parent)
                b2 = next_to_last.children[0].translation_relative_to(parent)
                e2 = next_to_last.children[1].translation_relative_to(parent)
                if (b1 is not None) and (e1 is not None) and (b2 is not None) and (e2 is not None):
                    if last.children[0].target == next_to_last.children[0].target:
                        self.parameters.complete.t = copy.copy(b1)
                    angle = angle(e1 - b1, e2 - b2)
                    rotation_vector = numpy.cross(e1 - b1, e2 - b2)
                    self.parameters.complete.set_rotation_properties(angle, rotation_vector, False)
            else:
                parent = next_to_last.parent
                b = last.children[0].translation_relative_to(parent)
                e = last.children[1].translation_relative_to(parent)
                if (b is not None) and (e is not None):
                    self.parameters.complete.t = b
                    self.parameters.complete.set_rotation_properties(math.pi*0.25, e - b, False)
        elif isinstance(last, GLTransformationMixin) and isinstance(last.transformation, Translation):
            parent = last.parent
            self.parameters.complete.t = last.get_frame_relative_to(parent).t
        else:
            self.parameters.complete.t = calculate_center(cache.translations)

        if self.parameters_dialog.run(self.parameters.complete) != gtk.RESPONSE_OK:
            self.parameters.clear()
        else:
            self.parameters.complete.t -= numpy.dot(self.parameters.complete.r, self.parameters.complete.t)