Exemplo n.º 1
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()
Exemplo n.º 2
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()
Exemplo n.º 3
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()
Exemplo n.º 4
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()