Beispiel #1
0
 def _update_select_area(self,event):        
     p = event.scenePos()
     for it in self.home_map_scene.items(p):                    
         if HMItem.type(it) == HMItem.MAP_AREA:
             HMItem.repr(it)
             if HMItem.select(it) :
                 HMItem.select(it,False)
                 it.setBrush(QBrush(Qt.NoBrush))
                 if id(it) in self.current_op_stat['items']:
                     del self.current_op_stat['items'][id(it)]
             else:
                 HMItem.select(it,True)
                 it.setBrush(QBrush(Qt.Dense4Pattern))
                 self.current_op_stat['items'][id(it)] = it
Beispiel #2
0
   def _finish_select_area(self):
       self.unregister_handler(self.home_map_scene,
                               QEvent.GraphicsSceneMouseRelease)
       self.unregister_handler(self.home_map_scene,
                               QEvent.KeyRelease)        
       item = None
       for id,it in self.current_op_stat['items'].items() : 
           print "%d,%s" % (id,HMItem.repr(it))       
           p = it.polygon().first()        
           item = None
       
       self.current_op = ''
       self.current_op_stat = None        
 
       el_it = QGraphicsEllipseItem(p.x()-2,p.y()-2,4,4)
       
       HMItem.module(el_it,self.__class__.__name__)
       HMItem.type(el_it,HMItem.ARTIFACT)
       HMItem.level(el_it, -1)
       
       el_it.setPen(QPen(Qt.blue,
                         1, 
                         Qt.SolidLine, 
                         Qt.RoundCap, 
                         Qt.RoundJoin))
       
       el_it.setBrush(QBrush(Qt.blue))
       el_it.setZValue(1)
       self.home_map_scene.addItem(el_it)
Beispiel #3
0
    def _enter_move_object(self,event):            
        p =  event.scenePos()
        print "enter move object scene %s " % p
        self.current_op_stat['start_point'] = p
        self.current_op_stat['position'] = p
        
        for it in self.home_map_scene.items(p):                    
            if HMItem.type(it) == self.current_op_stat['type'] :          
                HMItem.repr(it)
                self.current_op_stat['item'] = it
#                 if HMItem.type(it) == HMItem.MAP_AREA:
#                     it.setAcceptDrops(True)                               
#                     HMItem.repr(it)
        
        if not  self.current_op_stat['item'] is None:
            print "enter move object item %s "  %  self.current_op_stat['item'].scenePos()
            drag_obj = QDrag(self)        
            drag_obj.setMimeData(QMimeData())
            self.current_op_stat['drag'] = drag_obj
            drag_obj.start(Qt.MoveAction)