def ClearDrawing(self, dc=None): #print "ihm.ClearDrawing()" if dc is None: dc = wxClientDC(self.two_d_window) # draw background picture two_d_bitmap = ImageManager.get2DBackgrounddWxBitmap() dc.DrawBitmap(two_d_bitmap, 0, 0, TRUE)
def DoDrawing(self, dc=None): if dc is None: dc = wxClientDC(self.two_d_window) # opions for the device context dc.SetBackground( wxBrush("White",wxSOLID) ) dc.SetBackgroundMode(wxTRANSPARENT) dc.SetFont( wxFont(10, wxSWISS, wxNORMAL, wxBOLD, FALSE) ) dc.SetPen( wxPen("White",1) ) dc.SetTextForeground("White") dc.SetBrush( wxBrush("White",wxTRANSPARENT) ) # draw background picture two_d_bitmap = ImageManager.get2DBackgrounddWxBitmap() dc.DrawBitmap(two_d_bitmap, 0, 0, TRUE) # display the image and the pseudo of my node if self.myNode_pseudo : avatar_bitmap = wxImage(self.myNode_avatar, wxBITMAP_TYPE_PNG).ConvertToBitmap() self.pos_avatar_x = long(((self.two_d_window.GetClientSize().GetWidth()- avatar_bitmap.GetWidth()) /2) + self.delta_x) self.pos_avatar_y = long(((self.two_d_window.GetClientSize().GetHeight()- avatar_bitmap.GetHeight()) /2) + self.delta_y) dc.DrawBitmap(avatar_bitmap, self.pos_avatar_x,self.pos_avatar_y, TRUE) # display pseudo of my node if self.isDisplayPseudos == 1: self.pos_pseudo_x = self.pos_avatar_x self.pos_pseudo_y = long(self.pos_avatar_y + avatar_bitmap.GetHeight()) dc.DrawText(self.myNode_pseudo, self.pos_pseudo_x, self.pos_pseudo_y) # we display the awarness radius if self.myNode_ar : # Coordinates of the square enclosing the circle #arInDisplay2d = long(self.newCoordinates(long(self.myNode_ar))) #dc.DrawCircle(self.pos_avatar_x, self.pos_avatar_y, arInDisplay2d) dc.DrawCircle( self.two_d_window.GetClientSize().GetWidth()/2, self.two_d_window.GetClientSize().GetHeight()/2, self.two_d_window.GetClientSize().GetWidth()/2) # display neighbor items for neighbor_object in self.neighbor_item.values(): # recompute position in the screen posX = long(self.newCoordinates(neighbor_object[0])+(self.two_d_window.GetClientSize().GetWidth() /2)) posY = long(self.newCoordinates(neighbor_object[1])+(self.two_d_window.GetClientSize().GetHeight() /2)) pseudo = neighbor_object[2] #print "display Neighbor : [%s]" %pseudo # display neighbor image if it belongs to the screen if 0 < posY < self.two_d_window.GetClientSize().GetHeight() and 0 < posX < self.two_d_window.GetClientSize().GetWidth(): #print "display Neighbor image : [%s]" %pseudo # resize the image in accordance with the ar #self.display2d.chgSize(id) # get the photo image object if self.isDisplayAvatars == 1: if (neighbor_object[6]): avatar_bitmap = wxImage(neighbor_object[6], wxBITMAP_TYPE_PNG).ConvertToBitmap() else: # if the neighbor has no image, display the default image avatar_bitmap = wxImage(self.neighbor_avatar, wxBITMAP_TYPE_PNG).ConvertToBitmap() else: avatar_bitmap = wxImage("img//avat_blanc.png", wxBITMAP_TYPE_PNG).ConvertToBitmap() # display the image of neighbor pos_avatar_x = long(posX-(avatar_bitmap.GetWidth())/2) pos_avatar_y = long(posY-(avatar_bitmap.GetHeight())/2) dc.DrawBitmap(avatar_bitmap, pos_avatar_x, pos_avatar_y, TRUE) # display pseudo of the neighbor if self.isDisplayPseudos == 1: pos_pseudo_x = pos_avatar_x pos_pseudo_y = long(pos_avatar_y + avatar_bitmap.GetHeight()) dc.DrawText(pseudo, pos_pseudo_x, pos_pseudo_y) # display services picto bitmap chat_bitmap = wxImage('img//picto_chat.png', wxBITMAP_TYPE_PNG).ConvertToBitmap() pos_chat_x = long(pos_avatar_x + avatar_bitmap.GetWidth()) pos_chat_y = pos_avatar_y avat_bitmap = wxImage('img//picto_avat.png', wxBITMAP_TYPE_PNG).ConvertToBitmap() pos_avat_x = long(pos_avatar_x + avatar_bitmap.GetWidth()) pos_avat_y = long(pos_chat_y + chat_bitmap.GetHeight()) file_bitmap = wxImage('img//picto_fichier.png', wxBITMAP_TYPE_PNG).ConvertToBitmap() pos_file_x = long(pos_avatar_x + avatar_bitmap.GetWidth()) pos_file_y = long(pos_avat_y + avat_bitmap.GetHeight()) # display the image of neighbor chat service if neighbor_object[3]: dc.DrawBitmap(chat_bitmap, pos_chat_x, pos_chat_y, TRUE) # display the image of neighbor display2d service if neighbor_object[4]: dc.DrawBitmap(avat_bitmap, pos_avat_x, pos_avat_y, TRUE) # display the image of neighbor chat service if neighbor_object[5]: dc.DrawBitmap(file_bitmap, pos_file_x, pos_file_y, TRUE)