Пример #1
0
 def RightMousePressed(self, mouseinfo):
     #r.logInfo("rightmouse down")
     if self.windowActive:
         self.right_button_down = True
         
         results = []
         results = r.rayCast(mouseinfo.x, mouseinfo.y)
         
         ent = None
         
         if results is not None and results[0] != 0:
             id = results[0]
             ent = r.getEntity(id)
             
         found = False
         if ent is not None:                
             #print "Got entity:", ent.id
             for entity in self.sels:
                 if entity.id == ent.id:
                     found = True #clicked on an already selected entity
                     #print "multiselect clicked entity is already in selection"
             
             #if self.active is None or self.active.id != ent.id: #a diff ent than prev sel was changed  
             if self.validId(ent.id):
                 if not found:
                     #print "new ent to add to multiselect found:", ent.id
                     self.multiselect(ent)
                 else: #remove this entity which was previously in the selection
                     self.deselect(ent)
                 self.canmove = True
Пример #2
0
    def RightMousePressed(self, mouseinfo):
        #r.logInfo("rightmouse down")
        if self.windowActive:
            self.right_button_down = True

            results = []
            results = r.rayCast(mouseinfo.x, mouseinfo.y)

            ent = None

            if results is not None and results[0] != 0:
                id = results[0]
                ent = r.getEntity(id)

            found = False
            if ent is not None:
                #print "Got entity:", ent.id
                for entity in self.sels:
                    if entity.id == ent.id:
                        found = True  #clicked on an already selected entity
                        #print "multiselect clicked entity is already in selection"

                #if self.active is None or self.active.id != ent.id: #a diff ent than prev sel was changed
                if self.validId(ent.id):
                    if not found:
                        #print "new ent to add to multiselect found:", ent.id
                        self.multiselect(ent)
                    else:  #remove this entity which was previously in the selection
                        self.deselect(ent)
                    self.canmove = True
Пример #3
0
    def LeftMousePressed(self, mouseinfo):
        #r.logDebug("LeftMousePressed") #, mouseinfo, mouseinfo.x, mouseinfo.y
        #r.logDebug("point " + str(mouseinfo.x) + "," + str(mouseinfo.y))

        self.dragStarted(
            mouseinfo)  #need to call this to enable working dragging

        #         if self.selection_box is None:
        #             self.selection_box = r.createEntity("Selection.mesh", -10000)

        self.left_button_down = True

        results = []
        results = r.rayCast(mouseinfo.x, mouseinfo.y)
        ent = None

        if results is not None and results[0] != 0:
            id = results[0]
            ent = r.getEntity(id)

        if not self.manipulatorsInit:
            self.manipulatorsInit = True
            for manipulator in self.manipulators.values():
                manipulator.initVisuals()

        self.manipulator.initManipulation(ent, results)

        if ent is not None:
            #print "Got entity:", ent, ent.editable
            if not self.manipulator.compareIds(
                    ent.id
            ) and ent.editable:  #ent.id != self.selection_box.id and
                #if self.sel is not ent: #XXX wrappers are not reused - there may now be multiple wrappers for same entity

                r.eventhandled = self.EVENTHANDLED
                found = False
                for entity in self.sels:
                    if entity.id == ent.id:
                        found = True

                if self.active is None or self.active.id != ent.id:  #a diff ent than prev sel was changed
                    if self.validId(ent.id):
                        if not found:
                            self.select(ent)

                elif self.active.id == ent.id:  #canmove is the check for click and then another click for moving, aka. select first, then start to manipulate
                    self.canmove = True

        else:
            self.selection_rect_startpos = (mouseinfo.x, mouseinfo.y)
            #print "canmove:", self.canmove
            self.canmove = False
            self.deselect_all()
Пример #4
0
    def LeftMousePressed(self, mouseinfo):
        # r.logDebug("LeftMousePressed") #, mouseinfo, mouseinfo.x, mouseinfo.y
        # r.logDebug("point " + str(mouseinfo.x) + "," + str(mouseinfo.y))

        self.dragStarted(mouseinfo)  # need to call this to enable working dragging

        if self.selection_box is None:
            self.selection_box = r.createEntity("Selection.mesh", -10000)

        self.left_button_down = True

        results = []
        results = r.rayCast(mouseinfo.x, mouseinfo.y)
        ent = None

        if results is not None and results[0] != 0:
            id = results[0]
            ent = r.getEntity(id)

        if not self.manipulatorsInit:
            self.manipulatorsInit = True
            for manipulator in self.manipulators.values():
                manipulator.initVisuals()

        self.manipulator.initManipulation(ent, results)

        if ent is not None:
            # print "Got entity:", ent, ent.editable
            if not self.manipulator.compareIds(ent.id) and ent.id != self.selection_box.id and ent.editable:
                # if self.sel is not ent: #XXX wrappers are not reused - there may now be multiple wrappers for same entity

                r.eventhandled = self.EVENTHANDLED
                found = False
                for entity in self.sels:
                    if entity.id == ent.id:
                        found = True

                if self.active is None or self.active.id != ent.id:  # a diff ent than prev sel was changed
                    if self.validId(ent.id):
                        if not found:
                            self.select(ent)

                elif (
                    self.active.id == ent.id
                ):  # canmove is the check for click and then another click for moving, aka. select first, then start to manipulate
                    self.canmove = True

        else:
            self.selection_rect_startpos = (mouseinfo.x, mouseinfo.y)
            # print "canmove:", self.canmove
            self.canmove = False
            self.deselect_all()
Пример #5
0
 def on_mousemove(self, event_id, mouseinfo, callback):
     """for hilighting manipulator parts when hovering over them"""
     #print "m"
     if self.windowActive:# and event_id == :
         #~ print "m"
         results = []
         results = r.rayCast(mouseinfo.x, mouseinfo.y)
         if results is not None and results[0] != 0:
             id = results[0]
             
             if self.manipulator.compareIds(id):
                 self.manipulator.highlight(results)
         else:
             self.manipulator.resethighlight()
Пример #6
0
    def on_mousemove(self, event_id, mouseinfo, callback):
        """for hilighting manipulator parts when hovering over them"""
        #print "m"
        if self.windowActive:  # and event_id == :
            #~ print "m"
            results = []
            results = r.rayCast(mouseinfo.x, mouseinfo.y)
            if results is not None and results[0] != 0:
                id = results[0]

                if self.manipulator.compareIds(id):
                    self.manipulator.highlight(results)
            else:
                self.manipulator.resethighlight()
Пример #7
0
    def on_mouseleftpressed(self, mouseinfo):
        if not self.editing:
            return
        if mouseinfo.IsItemUnderMouse():
            return
        if not self.selection_box_inited:
            self.init_selection_box()
        if mouseinfo.HasShiftModifier() and not mouseinfo.HasCtrlModifier(
        ) and not mouseinfo.HasAltModifier():
            self.on_multiselect(mouseinfo)
            return

        self.dragStarted(
            mouseinfo)  #need to call this to enable working dragging
        self.left_button_down = True

        results = []
        results = r.rayCast(mouseinfo.x, mouseinfo.y)
        ent = None
        if results is not None and results[0] != 0:
            id = results[0]
            ent = naali.getEntity(id)

        if not self.manipulatorsInit:
            self.manipulatorsInit = True
            for manipulator in self.manipulators.values():
                manipulator.initVisuals()

        if ent is not None:
            if editable(ent):
                r.eventhandled = self.EVENTHANDLED
                if self.manipulator.compareIds(
                        ent.id
                ):  # don't start selection box when manipulator is hit
                    self.manipulator.initManipulation(ent, results, self.sels)
                    self.usingManipulator = True
                else:
                    if self.active is None or self.active.id != ent.id:  #a diff ent than prev sel was changed
                        if not ent in self.sels:
                            self.select(ent)
                    elif self.active.id == ent.id:  #canmove is the check for click and then another click for moving, aka. select first, then start to manipulate
                        self.canmove = True
        else:
            self.hideManipulator()
            # Start box select if nothing was hit? :P cant follow the logic here...
            self.selection_rect_startpos = (mouseinfo.x, mouseinfo.y)
            self.selection_box.Show()
            self.canmove = False
            self.deselect_all()
Пример #8
0
    def on_mouseleftpressed(self, mouseinfo):
        if not self.windowActive:
            return
        if mouseinfo.IsItemUnderMouse():
            return
        if mouseinfo.HasShiftModifier() and not mouseinfo.HasCtrlModifier(
        ) and not mouseinfo.HasAltModifier():
            self.on_multiselect(mouseinfo)
            return

        self.dragStarted(
            mouseinfo)  #need to call this to enable working dragging
        self.left_button_down = True

        results = []
        results = r.rayCast(mouseinfo.x, mouseinfo.y)
        ent = None
        if results is not None and results[0] != 0:
            id = results[0]
            ent = r.getEntity(id)

        if not self.manipulatorsInit:
            self.manipulatorsInit = True
            for manipulator in self.manipulators.values():
                manipulator.initVisuals()
        self.manipulator.initManipulation(ent, results)
        self.usingManipulator = True

        if ent is not None:
            if not self.manipulator.compareIds(ent.id) and editable(
                    ent):  #ent.id != self.selection_box.id and
                r.eventhandled = self.EVENTHANDLED
                found = False
                for entity in self.sels:
                    if entity.id == ent.id:
                        found = True

                if self.active is None or self.active.id != ent.id:  #a diff ent than prev sel was changed
                    if self.validId(ent.id):
                        if not found:
                            self.select(ent)

                elif self.active.id == ent.id:  #canmove is the check for click and then another click for moving, aka. select first, then start to manipulate
                    self.canmove = True

        else:
            self.selection_rect_startpos = (mouseinfo.x, mouseinfo.y)
            self.canmove = False
            self.deselect_all()
Пример #9
0
    def on_mouseleftpressed(self, mouseinfo):
        if not self.windowActive:
            return
        if mouseinfo.IsItemUnderMouse():
            return
        if mouseinfo.HasShiftModifier() and not mouseinfo.HasCtrlModifier() and not mouseinfo.HasAltModifier():
            self.on_multiselect(mouseinfo)
            return
            
        self.dragStarted(mouseinfo) #need to call this to enable working dragging
        self.left_button_down = True

        results = []
        results = r.rayCast(mouseinfo.x, mouseinfo.y)
        ent = None
        if results is not None and results[0] != 0:
            id = results[0]
            ent = r.getEntity(id)

        if not self.manipulatorsInit:
            self.manipulatorsInit = True
            for manipulator in self.manipulators.values():
                manipulator.initVisuals()
        self.manipulator.initManipulation(ent, results)
        self.usingManipulator = True

        if ent is not None:
            if not self.manipulator.compareIds(ent.id) and editable(ent): #ent.id != self.selection_box.id and 
                r.eventhandled = self.EVENTHANDLED
                found = False
                for entity in self.sels:
                    if entity.id == ent.id:
                        found = True
               
                if self.active is None or self.active.id != ent.id: #a diff ent than prev sel was changed  
                    if self.validId(ent.id):
                        if not found:
                            self.select(ent)

                elif self.active.id == ent.id: #canmove is the check for click and then another click for moving, aka. select first, then start to manipulate
                    self.canmove = True
                    
        else:
            self.selection_rect_startpos = (mouseinfo.x, mouseinfo.y)
            self.canmove = False
            self.deselect_all()
Пример #10
0
    def on_mouseleftpressed(self, mouseinfo):
        if not self.editing:
            return       
        if mouseinfo.IsItemUnderMouse():
            return
        if not self.selection_box_inited:
            self.init_selection_box()
        if mouseinfo.HasShiftModifier() and not mouseinfo.HasCtrlModifier() and not mouseinfo.HasAltModifier():
            self.on_multiselect(mouseinfo)
            return
            
        self.dragStarted(mouseinfo) #need to call this to enable working dragging
        self.left_button_down = True

        results = []
        results = r.rayCast(mouseinfo.x, mouseinfo.y)
        ent = None
        if results is not None and results[0] != 0:
            id = results[0]
            ent = naali.getEntity(id)

        if not self.manipulatorsInit:
            self.manipulatorsInit = True
            for manipulator in self.manipulators.values():
                manipulator.initVisuals()

        if ent is not None:
            if editable(ent):
                r.eventhandled = self.EVENTHANDLED
                if self.manipulator.compareIds(ent.id): # don't start selection box when manipulator is hit
                    self.manipulator.initManipulation(ent, results, self.sels)
                    self.usingManipulator = True
                else:
                    if self.active is None or self.active.id != ent.id: #a diff ent than prev sel was changed  
                        if not ent in self.sels:
                            self.select(ent)
                    elif self.active.id == ent.id: #canmove is the check for click and then another click for moving, aka. select first, then start to manipulate
                        self.canmove = True
        else:
            self.hideManipulator()
            # Start box select if nothing was hit? :P cant follow the logic here...
            self.selection_rect_startpos = (mouseinfo.x, mouseinfo.y)
            self.selection_box.Show()
            self.canmove = False
            self.deselect_all()
Пример #11
0
    def on_mousemove(self, mouseinfo):
        """Handle mouse move events. When no button is pressed, just check
        for hilites necessity in manipulators. When a button is pressed, handle
        drag logic."""
        if self.windowActive:
            if self.left_button_down:
                self.on_mousedrag(mouseinfo)
            else:
                # check for manipulator hilites
                results = []
                results = r.rayCast(mouseinfo.x, mouseinfo.y)
                if results is not None and results[0] != 0:
                    id = results[0]

                    if self.manipulator.compareIds(id):
                        self.manipulator.highlight(results)
                else:
                    self.manipulator.resethighlight()
Пример #12
0
 def on_mousemove(self, mouseinfo):
     """Handle mouse move events. When no button is pressed, just check
     for hilites necessity in manipulators. When a button is pressed, handle
     drag logic."""
     if self.windowActive:
         if self.left_button_down:
             self.on_mousedrag(mouseinfo)
         else:
             # check for manipulator hilites
             results = []
             results = r.rayCast(mouseinfo.x, mouseinfo.y)
             if results is not None and results[0] != 0:
                 id = results[0]
                 
                 if self.manipulator.compareIds(id):
                     self.manipulator.highlight(results)
             else:
                 self.manipulator.resethighlight()
Пример #13
0
 def on_multiselect(self, mouseinfo):
     if not self.editing:
         return
     results = []
     results = r.rayCast(mouseinfo.x, mouseinfo.y)
     ent = None
     if results is not None and results[0] != 0:
         id = results[0]
         ent = naali.getEntity(id)
         
     found = False
     if ent is not None:                
         for entity in self.sels:
             if entity.id == ent.id:
                 found = True
         if not found:
             self.multiselect(ent)
         else:
             self.deselect(ent)
         self.canmove = True
Пример #14
0
    def on_multiselect(self, mouseinfo):
        if self.windowActive:
            results = []
            results = r.rayCast(mouseinfo.x, mouseinfo.y)
            ent = None
            if results is not None and results[0] != 0:
                id = results[0]
                ent = naali.getEntity(id)

            found = False
            if ent is not None:
                for entity in self.sels:
                    if entity.id == ent.id:
                        found = True
                if self.validId(ent.id):
                    if not found:
                        self.multiselect(ent)
                    else:
                        self.deselect(ent)
                    self.canmove = True
Пример #15
0
 def on_multiselect(self, mouseinfo):
     if self.windowActive:           
         results = []
         results = r.rayCast(mouseinfo.x, mouseinfo.y)
         ent = None
         if results is not None and results[0] != 0:
             id = results[0]
             ent = r.getEntity(id)
             
         found = False
         if ent is not None:                
             for entity in self.sels:
                 if entity.id == ent.id:
                     found = True
             if self.validId(ent.id):
                 if not found:
                     self.multiselect(ent)
                 else:
                     self.deselect(ent)
                 self.canmove = True