Ejemplo n.º 1
0
    def __init__(self, assy, name, scale, pov, zoomFactor, wxyz):
        """
        @param pov: the inverse of the "center of view" in model coordinates
        @type pov: position vector (Numeric.array of 3 ints or floats, as made
                   by V(x,y,z))

        @param wxyz: orientation of view
        @type wxyz: a Quaternion (class VQT.Q), or a sequence of 4 floats
                    which can be passed to that class to make one, e.g.
                    Q(W, x, y, z) is the quaternion with axis vector x,y,z
                    and sin(theta/2) = W
        """
        self.const_pixmap = imagename_to_pixmap("modeltree/NamedView.png")
        if not name:
            name = gensym("%s" % self.sym, assy)
        Node.__init__(self, assy, name)
        self.scale = scale
        assert type(pov) is type(V(1, 0, 0))
        self.pov = V(pov[0], pov[1], pov[2])
        self.zoomFactor = zoomFactor
        self.quat = Q(wxyz)
            #bruce 050518/080303 comment: wxyz is passed as an array of 4 floats
            # (in same order as in mmp file's csys record), when parsing
            # csys mmp records, or with wxyz a quat in other places.
        return
Ejemplo n.º 2
0
    def __init__(self, assy, name, scale, pov, zoomFactor, wxyz):
        """
        @param pov: the inverse of the "center of view" in model coordinates
        @type pov: position vector (Numeric.array of 3 ints or floats, as made
                   by V(x,y,z))

        @param wxyz: orientation of view
        @type wxyz: a Quaternion (class VQT.Q), or a sequence of 4 floats
                    which can be passed to that class to make one, e.g.
                    Q(W, x, y, z) is the quaternion with axis vector x,y,z
                    and sin(theta/2) = W
        """
        self.const_pixmap = imagename_to_pixmap("modeltree/NamedView.png")
        if not name:
            name = gensym("%s" % self.sym, assy)
        Node.__init__(self, assy, name)
        self.scale = scale
        assert type(pov) is type(V(1, 0, 0))
        self.pov = V(pov[0], pov[1], pov[2])
        self.zoomFactor = zoomFactor
        self.quat = Q(wxyz)
            #bruce 050518/080303 comment: wxyz is passed as an array of 4 floats
            # (in same order as in mmp file's csys record), when parsing
            # csys mmp records, or with wxyz a quat in other places.
        return
Ejemplo n.º 3
0
 def __init__(self, assy, name, text=''):
     self.const_pixmap = imagename_to_pixmap("modeltree/comment.png")
     if not name:
         name = gensym("%s" % self.sym, assy)
     Node.__init__(self, assy, name)
     self.lines = [] # this makes set_text changed() test legal (result of test doesn't matter)
     self.set_text(text)
     return
Ejemplo n.º 4
0
 def readmmp_info_leaf_setitem(self, key, val, interp):  #bruce 060522
     "[extends superclass method]"
     if key[0] == 'commentline' and len(key) == 2:
         # key[1] is the encoding, and val is one line in the comment
         self._add_line(val, key[1])
     else:
         Node.readmmp_info_leaf_setitem(self, key, val, interp)
     return
Ejemplo n.º 5
0
 def readmmp_info_leaf_setitem( self, key, val, interp ): #bruce 060522
     "[extends superclass method]"
     if key[0] == 'commentline' and len(key) == 2:
         # key[1] is the encoding, and val is one line in the comment
         self._add_line(val, key[1])
     else:
         Node.readmmp_info_leaf_setitem( self, key, val, interp)
     return
Ejemplo n.º 6
0
    def remove_atom(self, atom, **opts):
        # bruce 080311 added **opts to match superclass method signature
        """
        Delete self if *any* of its atoms are deleted

        [overrides superclass method]
        """
        Node.kill(self)  # superclass is Jig, not Node; see long comment above
Ejemplo n.º 7
0
    def remove_atom(self, atom, **opts):
        # bruce 080311 added **opts to match superclass method signature
        """
        Delete self if *any* of its atoms are deleted

        [overrides superclass method]
        """
        Node.kill(self) # superclass is Jig, not Node; see long comment above
Ejemplo n.º 8
0
 def __init__(self, assy, name, text=''):
     self.const_pixmap = imagename_to_pixmap("modeltree/comment.png")
     if not name:
         name = gensym("%s" % self.sym, assy)
     Node.__init__(self, assy, name)
     self.lines = [] # this makes set_text changed() test legal (result of test doesn't matter)
     self.set_text(text)
     return
Ejemplo n.º 9
0
 def unpick(self):
     """
     Unselect the reference geometry.
     """
     if self.picked:
         Node.unpick(self)
         # see also a copy method which has to use the same statement to
         # compensate for this kluge
         self.color = self.normcolor
Ejemplo n.º 10
0
 def pick(self):
     """
     Select the reference geometry.
     """
     if not self.picked:
         Node.pick(self)
         self.normcolor = self.color
         self.color = env.prefs[selectionColor_prefs_key]  # russ 080603: pref.
     return
 def unpick(self):
     """
     Unselect the reference geometry.
     """
     if self.picked:
         Node.unpick(self)
         # see also a copy method which has to use the same statement to
         #compensate for this kluge
         self.color = self.normcolor
 def pick(self):
     """
     Select the reference geometry.
     """
     if not self.picked:
         Node.pick(self)
         self.normcolor = self.color
         self.color = env.prefs[
             selectionColor_prefs_key]  # russ 080603: pref.
     return
Ejemplo n.º 13
0
 def kill(self, require_confirmation=True):
     """
     Delete the POV-Ray Scene node and its associated .pov file if it exists.
     If <require_confirmation> is True, make the user confirm first [for deleting the file and the node both, as one op].
     [WARNING: user confirmation is not yet implemented.]
     Otherwise, delete the file without user confirmation.
     """
     if os.path.isfile(self.povrayscene_file):
         if 0:  # Don't require confirmation for A8. Mark 060701. [but see comment below about why this is a bad bug]
             # if require_confirmation:
             msg = "Please confirm that you want to delete " + self.name
             from widgets.widget_helpers import PleaseConfirmMsgBox
             confirmed = PleaseConfirmMsgBox(msg)
             if not confirmed:
                 return
         # warn the user that you are about to remove what might be an irreplaceable rendering of a prior version
         # of the main file, without asking, or even checking if other nodes in this assy still point to it
         # [this warning added by bruce 060711 for Mac A8, not present in Windows A8]
         env.history.message(
             orangemsg("Warning: deleting file [%s]" %
                       self.povrayscene_file))
         # do it
         os.remove(self.povrayscene_file)
         #bruce 060711 comment -- the above policy is a dangerous bug, since you can copy a node (not changing the filename)
         # and then delete one of the copies. This should not silently delete the file!
         # (Besides, even if you decide not to delete the file, .kill() should still delete the node.)
         #   This behavior is so dangerous that I'm tempted to fix it for Mac A8 even though it's too late
         # to fix it for Windows A8. Certainly it ought to be reported and releasenoted. But I think I will refrain
         # from the temptation to fix it for Mac A8, since doing it well is not entirely trivial, and any big bug-difference
         # in A8 on different platforms might cause confusion. But at least I will add a history message, so the user knows
         # right away if it caused a problem. And it needs to be fixed decently well for A8.1. ###@@@
         #   As for a better behavior, it would be good (and not too hard) to find out if other nodes
         # in the same assy point to the same file, and not even ask (just don't delete the file) if they do.
         # If not, ask, but always delete the node itself.
         #   But this is not trivial, since during a recursive kill of a Group, I'm not sure we can legally scan the tree.
         # (And if we did, it would then be quadratic time to delete a very large series of POV-Ray nodes.)
         # So we need a dictionary from filenames to lists or dicts of nodes that might refer to that filename.
         #   Of course there should also (for any filenode) be CM commands to delete or rename the file,
         # or (if other nodes also point to it) to copy it so this node owns a unique one.
     Node.kill(self)
Ejemplo n.º 14
0
    def kill(self, require_confirmation=True):
        """
        Delete the POV-Ray Scene node and its associated .pov file if it exists.
        If <require_confirmation> is True, make the user confirm first [for deleting the file and the node both, as one op].
        [WARNING: user confirmation is not yet implemented.]
        Otherwise, delete the file without user confirmation.
        """
        if os.path.isfile(self.povrayscene_file):
            if 0:  # Don't require confirmation for A8. Mark 060701. [but see comment below about why this is a bad bug]
                # if require_confirmation:
                msg = "Please confirm that you want to delete " + self.name
                from widgets.widget_helpers import PleaseConfirmMsgBox

                confirmed = PleaseConfirmMsgBox(msg)
                if not confirmed:
                    return
            # warn the user that you are about to remove what might be an irreplaceable rendering of a prior version
            # of the main file, without asking, or even checking if other nodes in this assy still point to it
            # [this warning added by bruce 060711 for Mac A8, not present in Windows A8]
            env.history.message(orangemsg("Warning: deleting file [%s]" % self.povrayscene_file))
            # do it
            os.remove(self.povrayscene_file)
            # bruce 060711 comment -- the above policy is a dangerous bug, since you can copy a node (not changing the filename)
            # and then delete one of the copies. This should not silently delete the file!
            # (Besides, even if you decide not to delete the file, .kill() should still delete the node.)
            #   This behavior is so dangerous that I'm tempted to fix it for Mac A8 even though it's too late
            # to fix it for Windows A8. Certainly it ought to be reported and releasenoted. But I think I will refrain
            # from the temptation to fix it for Mac A8, since doing it well is not entirely trivial, and any big bug-difference
            # in A8 on different platforms might cause confusion. But at least I will add a history message, so the user knows
            # right away if it caused a problem. And it needs to be fixed decently well for A8.1. ###@@@
            #   As for a better behavior, it would be good (and not too hard) to find out if other nodes
            # in the same assy point to the same file, and not even ask (just don't delete the file) if they do.
            # If not, ask, but always delete the node itself.
            #   But this is not trivial, since during a recursive kill of a Group, I'm not sure we can legally scan the tree.
            # (And if we did, it would then be quadratic time to delete a very large series of POV-Ray nodes.)
            # So we need a dictionary from filenames to lists or dicts of nodes that might refer to that filename.
            #   Of course there should also (for any filenode) be CM commands to delete or rename the file,
            # or (if other nodes also point to it) to copy it so this node owns a unique one.
        Node.kill(self)
Ejemplo n.º 15
0
 def __init__(self, assy, name, params = None):
     #bruce 060620 removed name from params list, made that optional, made name a separate argument,
     # all to make this __init__ method compatible with that of other nodes (see above for one reason);
     # also revised this routine in other ways, e.g. to avoid redundant sets of self.assy and self.name
     # (which are set by Node.__init__).
     if not name: 
         # [Note: this code might be superceded by code in Node.__init__ once nodename suffix numbers are revised.]
         # If this code is superceded, Node.__init__ must provide a way to verify that the filename (derived from the name)
         # doesn't exist, since this would be an invalid name. Mark 060702.
         name = generate_povrayscene_name(assy, self.sym, self.extension)
         
     self.const_pixmap = imagename_to_pixmap("modeltree/povrayscene.png")
         # note: this might be changed later; this value is not always correct; that may be a bug when this node is copied.
         # [bruce 060620 comment]
         
     Node.__init__(self, assy, name)
     if params:
         self.set_parameters(params)
     else:
         def_params = (assy.o.width, assy.o.height, 'png')
         self.set_parameters(def_params)
     
     return
Ejemplo n.º 16
0
    def __init__(self, assy, name, params=None):
        #bruce 060620 removed name from params list, made that optional, made name a separate argument,
        # all to make this __init__ method compatible with that of other nodes (see above for one reason);
        # also revised this routine in other ways, e.g. to avoid redundant sets of self.assy and self.name
        # (which are set by Node.__init__).
        if not name:
            # [Note: this code might be superceded by code in Node.__init__ once nodename suffix numbers are revised.]
            # If this code is superceded, Node.__init__ must provide a way to verify that the filename (derived from the name)
            # doesn't exist, since this would be an invalid name. Mark 060702.
            name = generate_povrayscene_name(assy, self.sym, self.extension)

        self.const_pixmap = imagename_to_pixmap("modeltree/povrayscene.png")
        # note: this might be changed later; this value is not always correct; that may be a bug when this node is copied.
        # [bruce 060620 comment]

        Node.__init__(self, assy, name)
        if params:
            self.set_parameters(params)
        else:
            def_params = (assy.o.width, assy.o.height, 'png')
            self.set_parameters(def_params)

        return
Ejemplo n.º 17
0
    def ModelTree_context_menu_section(
            self):  #bruce 080225, for Mark to review and revise
        """
        Return a menu_spec list to be included in the Model Tree's context
        menu for this node, when this is the only selected node
        (which implies the context menu is specifically for this node).

        [extends superclass implementation]
        """
        # start with superclass version
        menu_spec = Node.ModelTree_context_menu_section(self)

        # then add more items to it, in order:

        # Change to this view

        text = "Change to '%s' (left click)" % (self.name, )
        command = self.ModelTree_plain_left_click
        disabled = self.sameAsCurrentView()
        menu_spec.append((text, command, disabled and 'disabled' or None))

        # Replace saved view with current view

        text = "Replace '%s' with the current view" % (self.name, )
        # (fyi, I don't know how to include bold text here, or whether it's possible)
        command = self._replace_saved_view_with_current_view
        disabled = self.sameAsCurrentView()
        menu_spec.append((text, command, disabled and 'disabled' or None))

        # Return to previous view (NIM) [mark 060122]

        # @note: This is very helpful when the user accidentally clicks
        # a Named View node and needs an easy way to restore the previous view.

        if 0:
            text = "Return to previous View"
            command = self.restore_previous_view
            disabled = True  # should be: disabled if no previous view is available
            menu_spec.append((text, command, disabled and 'disabled' or None))

        # Note: we could also add other items here instead of defining them in __CM methods.
        # If they never need to be disabled, just use menu_spec.append( (text, command) ).

        return menu_spec
Ejemplo n.º 18
0
 def __init__(self, stuff, name = None):
     assy = env.mainwindow().assy #k wrongheaded??
     Node.__init__(self, assy, name)###WRONG now that Node is no longer a superclass
     self.stuff = stuff # exprs for what to draw (list of objects)
Ejemplo n.º 19
0
 def __init__(self, assy, name = "prefnode"):
     Node.__init__(self, assy, name)
     return
Ejemplo n.º 20
0
 def writemmp_info_leaf(self, mapping):
     Node.writemmp_info_leaf(self, mapping)
     x, y, z = self.constrainedPosition()
     mapping.write("info leaf handle = %g %g %g\n" % (x, y, z))
Ejemplo n.º 21
0
 def writemmp_info_leaf(self, mapping):
     Node.writemmp_info_leaf(self, mapping)
     x, y, z = self.constrainedPosition()
     mapping.write("info leaf handle = %g %g %g\n" % (x, y, z))