def test_floatcanvas_group(self): item1 = FloatCanvas.Circle((0, 0), 10) item2 = FloatCanvas.Circle((0, 5), 10) item3 = FloatCanvas.Circle((5, 5), 10) try: FloatCanvas.Group([item1, item2, item3]) except AttributeError: self.fail( "Has wx/lib/floatcanvas/FCObjects.py been edited correctly?")
def __init__(self, Label, XY, Diameter, TextColor="Black", LineColor="Black", LineStyle="Solid", LineWidth=1, FillColor=None, FillStyle="Solid", InForeground=False, IsVisible=True): self.XY = np.asarray(XY, np.float).reshape(2, ) Label = FC.ScaledText( Label, self.XY, Size=Diameter / 2.0, Color=TextColor, Position='cc', ) self.Circle = FC.Circle( self.XY, Diameter, FillColor=FillColor, LineStyle=None, ) FC.Group.__init__(self, [self.Circle, Label], InForeground, IsVisible)
def test_lib_floatcanvas_fc_circle(self): fccanvas = fc.FloatCanvas(self.frame) obj = fc.Circle((2, 2), 2) fccanvas.AddObject(obj) fccanvas.Destroy()
def Draw_Poolinglayer(self,status_object) : start_position, last_position = status_object.get_mouse_position() object_id = status_object.get_layer_id() Dense_object = FloatCanvas.Circle(start_position, 20, LineWidth=3, FillColor='green') Dense_object.id = object_id self.AddObject(Dense_object) Dense_object.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.Trigger_Pooling_layer_dialog) Dense_object.Bind(wx.EVT_ENTER_WINDOW, self.Show_layer_data) self.Draw(Force=True)
def Draw_Denselayer(self,status_object): # 'Dense' : [[int'units',str'init',str'activation', str 'regularization' start_position, last_position = status_object.get_mouse_position() object_id = status_object.get_layer_id() Dense_object = FloatCanvas.Circle(start_position,20,LineWidth=3,FillColor = 'red') Dense_object.id = object_id self.AddObject(Dense_object) Dense_object.Bind(FloatCanvas.EVT_FC_LEFT_DOWN,self.Trigger_Dense_layer_dialog) Dense_object.Bind(wx.EVT_ENTER_WINDOW,self.Show_layer_data) self.Draw(Force = True)
def Test_object(self): print("test object") self.RotArrow = self.AddArrow((16, 4), 80, Direction=0, LineWidth=3, LineColor="Green", ArrowHeadAngle=30) self.RotArrow.HitLineWidth = 6 self.RotArrow.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.Trigger_Pooling_layer_dialog) self.Dense_object = FloatCanvas.Circle((10,10), 20, LineWidth=3, FillColor='red') self.AddObject(self.Dense_object) self.Dense_object.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.Trigger_Pooling_layer_dialog) #Dense_object.Bind(FloatCanvas.EVT_ENTER_WINDOW, self.Show_layer_data) self.Draw(Force=True)
def draw_die_center(self): """Plot the die centers as a small dot.""" for die in self.xyd: # Determine the die's lower-left coordinate lower_left_coord = wm_utils.grid_to_rect_coord( die[:2], self.die_size, self.grid_center) # then adjust back to the die center lower_left_coord = (lower_left_coord[0] + self.die_size[0] / 2, lower_left_coord[1] + self.die_size[1] / 2) circ = FloatCanvas.Circle( lower_left_coord, 0.5, FillColor=wm_const.wm_DIE_CENTER_DOT_COLOR, ) self.canvas.AddObject(circ)
def draw_generic_patient(self, gender, number, observedCP, patientCoords): settings = PATIENT_SETTINGS group = FloatCanvas.Group() if gender == MALE: lineColor = settings['line_color_male'] else: lineColor = settings['line_color_female'] MRSAStr = observedCP[0] and "M+" or "M-" VREStr = observedCP[1] and "V+" or "V-" group.AddObject( FloatCanvas.Circle(patientCoords, settings['radius'] * 2, LineWidth=settings['line_width'], LineColor=lineColor, FillStyle="Solid")) group.AddObject( FloatCanvas.ScaledText("x {0}".format(number), patientCoords, Position="cc", Size=settings['id_text_size'], Weight=wx.BOLD)) group.AddObject( FloatCanvas.ScaledText(str(MRSAStr), (patientCoords[0] - settings['radius'], patientCoords[1] + settings['radius']), Position="cc", Size=settings['acuity_text_size'], Weight=wx.BOLD)) group.AddObject( FloatCanvas.ScaledText(str(VREStr), (patientCoords[0] + settings['radius'], patientCoords[1] + settings['radius']), Position="cc", Size=settings['acuity_text_size'], Weight=wx.BOLD)) return group
def draw_crosshairs(dia=150, dot=False): """Draw the crosshairs or wafer center dot.""" if dot: circ = FloatCanvas.Circle( (0, 0), 2.5, FillColor=wm_const.wm_WAFER_CENTER_DOT_COLOR, ) return FloatCanvas.Group([circ]) else: # Default: use crosshairs rad = dia / 2 xline = FloatCanvas.Line( [(rad * 1.05, 0), (-rad * 1.05, 0)], LineColor=wx.CYAN, ) yline = FloatCanvas.Line( [(0, rad * 1.05), (0, -rad * 1.05)], LineColor=wx.CYAN, ) return FloatCanvas.Group([xline, yline])
def __init__(self): super(Frame, self).__init__(None) self.SetTitle('My Title') self.SetClientSize((500, 500)) self.Center() self.Canvas = FloatCanvas.FloatCanvas(self, -1, size=(500, 500), ProjectionFun=None, Debug=0, BackgroundColor="White", ) # add a circle cir = FloatCanvas.Circle((10, 10), 100) self.Canvas.AddObject(cir) # add a rectangle rect = FloatCanvas.Rectangle((110, 10), (100, 100), FillColor='Red') self.Canvas.AddObject(rect) self.Canvas.Draw()
def draw_wafer_outline(dia=150, excl=5, flat=None): """ Draw a wafer outline for a given radius, including any exclusion lines. Parameters ---------- dia : float, optional The wafer diameter in mm. Defaults to `150`. excl : float, optional The exclusion distance from the edge of the wafer in mm. Defaults to `5`. flat : float, optional The exclusion distance from the wafer flat in mm. If ``None``, uses the same value as ``excl``. Defaults to ``None``. Returns ------- :class:`wx.lib.floatcanvas.FloatCanvas.Group` A ``Group`` that can be added to any floatcanvas.FloatCanvas instance. """ rad = float(dia) / 2.0 if flat is None: flat = excl # Full wafer outline circle circ = FloatCanvas.Circle( (0, 0), dia, LineColor=wm_const.wm_OUTLINE_COLOR, LineWidth=1, ) # Calculate the exclusion Radius exclRad = 0.5 * (dia - 2.0 * excl) if dia in wm_const.wm_FLAT_LENGTHS: # A flat is defined, so we draw it. flat_size = wm_const.wm_FLAT_LENGTHS[dia] x = flat_size / 2 y = -math.sqrt(rad**2 - x**2) # Wfr Flat's Y Location arc = FloatCanvas.Arc( (x, y), (-x, y), (0, 0), LineColor=wm_const.wm_WAFER_EDGE_COLOR, LineWidth=3, ) # actually a wafer flat, but called notch notch = draw_wafer_flat(rad, wm_const.wm_FLAT_LENGTHS[dia]) # Define the arc angle based on the flat exclusion, not the edge # exclusion. Find the flat exclusion X and Y coords. FSSflatY = y + flat if exclRad < abs(FSSflatY): # Then draw a circle with no flat excl_arc = FloatCanvas.Circle( (0, 0), exclRad * 2, LineColor=wm_const.wm_WAFER_EDGE_COLOR, LineWidth=3, ) excl_group = FloatCanvas.Group([excl_arc]) else: FSSflatX = math.sqrt(exclRad**2 - FSSflatY**2) # Define the wafer arc excl_arc = FloatCanvas.Arc( (FSSflatX, FSSflatY), (-FSSflatX, FSSflatY), (0, 0), LineColor=wm_const.wm_WAFER_EDGE_COLOR, LineWidth=3, ) excl_notch = draw_wafer_flat(exclRad, FSSflatX * 2) excl_group = FloatCanvas.Group([excl_arc, excl_notch]) else: # Flat not defined, so use a notch to denote wafer orientation. ang = 2.5 start_xy, end_xy = calc_flat_coords(rad, ang) arc = FloatCanvas.Arc( start_xy, end_xy, (0, 0), LineColor=wm_const.wm_WAFER_EDGE_COLOR, LineWidth=3, ) notch = draw_wafer_notch(rad) # Flat not defined, so use a notch to denote wafer orientation. start_xy, end_xy = calc_flat_coords(exclRad, ang) excl_arc = FloatCanvas.Arc( start_xy, end_xy, (0, 0), LineColor=wm_const.wm_WAFER_EDGE_COLOR, LineWidth=3, ) excl_notch = draw_wafer_notch(exclRad) excl_group = FloatCanvas.Group([excl_arc, excl_notch]) # Group the outline arc and the orientation (flat / notch) together group = FloatCanvas.Group([circ, arc, notch, excl_group]) return group
def process_jsonfile(self, T): for room, dim in T.items(): for par, dim1 in dim.items(): if par == "topright_pos_y": xx = int(T[room]["topright_pos_x"]) y1 = int(T[room]["topright_pos_y"]) yy = 0 - y1 # changing the +Y-axis to -Y-axis ll = int(T[room]["length"]) bb = int(T[room]["breadth"]) drline1 = FloatCanvas.Line([(xx, yy), (xx + ll, yy)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline1) drline2 = FloatCanvas.Line([(xx, yy), (xx, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline2) drline3 = FloatCanvas.Line([(xx + ll, yy), (xx + ll, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline3) drline4 = FloatCanvas.Line([(xx, yy - bb), (xx + ll, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline4) self.Canvas.Draw() if par == "Nodes": for i in range(len(T[room]["Nodes"])): N.append(int(T[room][par][i]["node_id"])) X.append(int(T[room][par][i]["node_pos_x"])) Y.append(int(T[room][par][i]["node_pos_y"])) for node_par, node_val in T[room][par][i].items(): print("----", T[room][par][i]["node_id"], "------") if T[room][par][i]["type"] == "s": cir = FloatCanvas.Circle([ int(T[room][par][i]["node_pos_x"]), -int(T[room][par][i]["node_pos_y"]) ], 7, FillColor='red') self.Canvas.AddObject(cir) print(T[room][par][i]["type"]) if T[room][par][i]["type"] == "k": poly = FloatCanvas.Polygon([ (int(T[room][par][i]["node_pos_x"]) - 4, -int(T[room][par][i]["node_pos_y"]) - 4), (int(T[room][par][i]["node_pos_x"]) + 4, -int(T[room][par][i]["node_pos_y"]) - 4), (int(T[room][par][i]["node_pos_x"]) + 4, -int(T[room][par][i]["node_pos_y"]) + 4), (int(T[room][par][i]["node_pos_x"]) - 4, -int(T[room][par][i]["node_pos_y"]) + 4) ], FillColor='yellow') self.Canvas.AddObject(poly) print(T[room][par][i]["type"]) if T[room][par][i]["type"] == "r": rect = FloatCanvas.Rectangle([ int(T[room][par][i]["node_pos_x"]), -int(T[room][par][i]["node_pos_y"]) ], (8, 8), FillColor='blue') self.Canvas.AddObject(rect) print(T[room][par][i]["type"]) if room == "Blank_Area": points = [(int(T[room]['x1']), -int(T[room]['y1'])), (int(T[room]['x2']), -int(T[room]['y2'])), (int(T[room]['x3']), -int(T[room]['y3'])), (int(T[room]['x4']), -int(T[room]['y4'])), (int(T[room]['x5']), -int(T[room]['y5'])), (int(T[room]['x6']), -int(T[room]['y6'])), (int(T[room]['x7']), -int(T[room]['y7'])), (int(T[room]['x8']), -int(T[room]['y8'])), (int(T[room]['x9']), -int(T[room]['y9'])), (int(T[room]['x10']), -int(T[room]['y10'])), (int(T[room]['x11']), -int(T[room]['y11']))] blankarea = FloatCanvas.Polygon(points, LineWidth=4, LineColor='black', FillColor="#95bce7", FillStyle='Solid') self.Canvas.AddObject(blankarea)
def OnClickLeft(self, event): with open('testjson.json', 'r') as file1: T = json.load(file1) for room, dim in T.items(): for par, dim1 in dim.items(): if par == "topright_pos_y": xx = int(T[room]["topright_pos_x"]) y1 = int(T[room]["topright_pos_y"]) yy = 0 - y1 ll = int(T[room]["length"]) bb = int(T[room]["breadth"]) drline1 = FloatCanvas.Line([(xx, yy), (xx + ll, yy)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline1) self.Canvas.Draw() drline2 = FloatCanvas.Line([(xx, yy), (xx, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline2) self.Canvas.Draw() drline3 = FloatCanvas.Line([(xx + ll, yy), (xx + ll, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline3) self.Canvas.Draw() drline4 = FloatCanvas.Line([(xx, yy - bb), (xx + ll, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline4) self.Canvas.Draw() self.Canvas.Draw() if par == "nodes": for i in range(len(T[room]["nodes"])): for node_par, node_val in T[room][par][i].items(): if T[room][par][i]["type"] == "s": cir = FloatCanvas.Circle([ int(T[room][par][i]["node_pos_x"]), 0 - int(T[room][par][i]["node_pos_y"]) ], 7, FillColor='red') self.Canvas.AddObject(cir) if T[room][par][i]["type"] == "p": rect = FloatCanvas.Rectangle([ int(T[room][par][i]["node_pos_x"]), 0 - int(T[room][par][i]["node_pos_y"]) ], (8, 8), FillColor='blue') self.Canvas.AddObject(rect) if T[room][par][i]["type"] == "k": poly = FloatCanvas.Polygon( [(int(T[room][par][i]["node_pos_x"]) - 4, 0 - int(T[room][par][i]["node_pos_y"]) - 4), (int(T[room][par][i]["node_pos_x"]) + 4, 0 - int(T[room][par][i]["node_pos_y"]) - 4), (int(T[room][par][i]["node_pos_x"]) + 4, 0 - int(T[room][par][i]["node_pos_y"]) + 4), (int(T[room][par][i]["node_pos_x"]) - 4, 0 - int(T[room][par][i]["node_pos_y"]) + 4)], FillColor='yellow') self.Canvas.AddObject(poly) if T[room][par][i]["type"] == "r": poly1 = FloatCanvas.Polygon( [(int(T[room][par][i]["node_pos_x"]), 0 - int(T[room][par][i]["node_pos_y"]) - 7), (int(T[room][par][i]["node_pos_x"]) - 7, 0 - int(T[room][par][i]["node_pos_y"]) + 7), (int(T[room][par][i]["node_pos_x"]) + 7, 0 - int(T[room][par][i]["node_pos_y"]) + 7)], FillColor='cyan') self.Canvas.AddObject(poly1) self.Canvas.Draw() if room == "Blank_Area": points = [(int(T[room]['x1']), 0 - int(T[room]['y1'])), (int(T[room]['x2']), 0 - int(T[room]['y2'])), (int(T[room]['x3']), 0 - int(T[room]['y3'])), (int(T[room]['x4']), 0 - int(T[room]['y4'])), (int(T[room]['x5']), 0 - int(T[room]['y5'])), (int(T[room]['x6']), 0 - int(T[room]['y6'])), (int(T[room]['x7']), 0 - int(T[room]['y7'])), (int(T[room]['x8']), 0 - int(T[room]['y8'])), (int(T[room]['x9']), 0 - int(T[room]['y9'])), (int(T[room]['x10']), 0 - int(T[room]['y10'])), (int(T[room]['x11']), 0 - int(T[room]['y11']))] blankarea = FloatCanvas.Polygon(points, LineWidth=4, LineColor='black', FillColor="SKY BLUE", FillStyle='Solid') self.Canvas.AddObject(blankarea) self.Canvas.Draw()
def OnClickLeft(self,event): with open('testjson.json','r') as file1: T = json.load(file1) for room,dim in T.items(): for par,dim1 in dim.items(): if par == "topright_pos_y": xx=int(T[room]["topright_pos_x"]) y1=int(T[room]["topright_pos_y"]) yy=0-y1 # changing the +Y-axis to -Y-axis ll=int(T[room]["length"]) bb=int(T[room]["breadth"]) drline1 = FloatCanvas.Line([(xx,yy),(xx+ll,yy)],LineWidth=4,LineColor='black') self.Canvas.AddObject(drline1) drline2 = FloatCanvas.Line([(xx,yy),(xx,yy-bb)],LineWidth=4,LineColor='black') self.Canvas.AddObject(drline2) drline3 = FloatCanvas.Line([(xx+ll,yy),(xx+ll,yy-bb)],LineWidth=4,LineColor='black') self.Canvas.AddObject(drline3) drline4 = FloatCanvas.Line([(xx,yy-bb),(xx+ll,yy-bb)],LineWidth=4,LineColor='black') self.Canvas.AddObject(drline4) self.Canvas.Draw() if par == "nodes": for i in range(len(T[room]["nodes"])): N.append(int(T[room][par][i]["node_id"])) X.append(int(T[room][par][i]["node_pos_x"])) Y.append(int(T[room][par][i]["node_pos_y"])) # Drawing Nodes for node_par,node_val in T[room][par][i].items(): if T[room][par][i]["type"] == "s": cir = FloatCanvas.Circle([int(T[room][par][i]["node_pos_x"]),-int(T[room][par][i]["node_pos_y"])],7,FillColor = 'red') self.Canvas.AddObject(cir) if T[room][par][i]["type"] == "p": rect = FloatCanvas.Rectangle([int(T[room][par][i]["node_pos_x"]),-int(T[room][par][i]["node_pos_y"])],(8,8),FillColor='blue') self.Canvas.AddObject(rect) if T[room][par][i]["type"] == "k": poly = FloatCanvas.Polygon([(int(T[room][par][i]["node_pos_x"])-4,-int(T[room][par][i]["node_pos_y"])-4), (int(T[room][par][i]["node_pos_x"])+4,-int(T[room][par][i]["node_pos_y"])-4), (int(T[room][par][i]["node_pos_x"])+4,-int(T[room][par][i]["node_pos_y"])+4), (int(T[room][par][i]["node_pos_x"])-4,-int(T[room][par][i]["node_pos_y"])+4)], FillColor='yellow') self.Canvas.AddObject(poly) if T[room][par][i]["type"] == "r": poly1 = FloatCanvas.Polygon([(int(T[room][par][i]["node_pos_x"]),-int(T[room][par][i]["node_pos_y"])-7), (int(T[room][par][i]["node_pos_x"])-7,-int(T[room][par][i]["node_pos_y"])+7), (int(T[room][par][i]["node_pos_x"])+7,-int(T[room][par][i]["node_pos_y"])+7)], FillColor='cyan') self.Canvas.AddObject(poly1) # Drawing and highlighting the unused area if room == "Blank_Area": points = [(int(T[room]['x1']),-int(T[room]['y1'])), (int(T[room]['x2']),-int(T[room]['y2'])), (int(T[room]['x3']),-int(T[room]['y3'])), (int(T[room]['x4']),-int(T[room]['y4'])), (int(T[room]['x5']),-int(T[room]['y5'])), (int(T[room]['x6']),-int(T[room]['y6'])), (int(T[room]['x7']),-int(T[room]['y7'])), (int(T[room]['x8']),-int(T[room]['y8'])), (int(T[room]['x9']),-int(T[room]['y9'])), (int(T[room]['x10']),-int(T[room]['y10'])), (int(T[room]['x11']),-int(T[room]['y11']))] blankarea = FloatCanvas.Polygon(points,LineWidth=4,LineColor='black',FillColor = "SKY BLUE" , FillStyle='Solid') self.Canvas.AddObject(blankarea) # Making edges for distances < 100 between two nodes for i in range (len(N)): for j in range (len(N)): dist = self.distance_calc(X[i],-Y[i],X[j],-Y[j]) if dist < 100: self.Canvas.AddObject(FloatCanvas.Line([(X[i],-Y[i]),(X[j],-Y[j])], LineColor = 'Black', LineStyle='Solid',LineWidth=1)) self.Canvas.Draw()
def OnClickLeft(self, event): with open('testjson.json', 'r') as file1: T = json.load(file1) for room, dim in T.items(): for par, dim1 in dim.items(): if par == "topright_pos_y": xx = int(T[room]["topright_pos_x"]) y1 = int(T[room]["topright_pos_y"]) yy = 0 - y1 # changing the +Y-axis to -Y-axis ll = int(T[room]["length"]) bb = int(T[room]["breadth"]) drline1 = FloatCanvas.Line([(xx, yy), (xx + ll, yy)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline1) drline2 = FloatCanvas.Line([(xx, yy), (xx, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline2) drline3 = FloatCanvas.Line([(xx + ll, yy), (xx + ll, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline3) drline4 = FloatCanvas.Line([(xx, yy - bb), (xx + ll, yy - bb)], LineWidth=4, LineColor='black') self.Canvas.AddObject(drline4) self.Canvas.Draw() if par == "nodes": for i in range(len(T[room]["nodes"])): N.append(int(T[room][par][i]["node_id"])) X.append(int(T[room][par][i]["node_pos_x"])) Y.append(int(T[room][par][i]["node_pos_y"])) for node_par, node_val in T[room][par][i].items(): if T[room][par][i]["type"] == "s": cir = FloatCanvas.Circle([ int(T[room][par][i]["node_pos_x"]), -int(T[room][par][i]["node_pos_y"]) ], 7, FillColor='red') self.Canvas.AddObject(cir) if T[room][par][i]["type"] == "p": rect = FloatCanvas.Rectangle([ int(T[room][par][i]["node_pos_x"]), -int(T[room][par][i]["node_pos_y"]) ], (8, 8), FillColor='blue') self.Canvas.AddObject(rect) if T[room][par][i]["type"] == "k": poly = FloatCanvas.Polygon([ (int(T[room][par][i]["node_pos_x"]) - 4, -int(T[room][par][i]["node_pos_y"]) - 4), (int(T[room][par][i]["node_pos_x"]) + 4, -int(T[room][par][i]["node_pos_y"]) - 4), (int(T[room][par][i]["node_pos_x"]) + 4, -int(T[room][par][i]["node_pos_y"]) + 4), (int(T[room][par][i]["node_pos_x"]) - 4, -int(T[room][par][i]["node_pos_y"]) + 4) ], FillColor='yellow') self.Canvas.AddObject(poly) if T[room][par][i]["type"] == "r": poly1 = FloatCanvas.Polygon([ (int(T[room][par][i]["node_pos_x"]), -int(T[room][par][i]["node_pos_y"]) - 7), (int(T[room][par][i]["node_pos_x"]) - 7, -int(T[room][par][i]["node_pos_y"]) + 7), (int(T[room][par][i]["node_pos_x"]) + 7, -int(T[room][par][i]["node_pos_y"]) + 7) ], FillColor='cyan') self.Canvas.AddObject(poly1) if room == "Blank_Area": points = [(int(T[room]['x1']), -int(T[room]['y1'])), (int(T[room]['x2']), -int(T[room]['y2'])), (int(T[room]['x3']), -int(T[room]['y3'])), (int(T[room]['x4']), -int(T[room]['y4'])), (int(T[room]['x5']), -int(T[room]['y5'])), (int(T[room]['x6']), -int(T[room]['y6'])), (int(T[room]['x7']), -int(T[room]['y7'])), (int(T[room]['x8']), -int(T[room]['y8'])), (int(T[room]['x9']), -int(T[room]['y9'])), (int(T[room]['x10']), -int(T[room]['y10'])), (int(T[room]['x11']), -int(T[room]['y11']))] blankarea = FloatCanvas.Polygon(points, LineWidth=4, LineColor='black', FillColor="#95bce7", FillStyle='Solid') self.Canvas.AddObject(blankarea) # Dialog Box to input the limiting distance dlg_limit = wx.TextEntryDialog(self, 'Enter the Limiting Distance:') if dlg_limit.ShowModal() == wx.ID_OK: limit = int(dlg_limit.GetValue()) dlg_limit.Destroy() # Drawing lines for shortest distances between two nodes for i in range(len(N)): for j in range(len(N)): dist = self.distance_calc(X[i], -Y[i], X[j], -Y[j]) if dist < limit: self.Canvas.AddObject( FloatCanvas.Line([(X[i], -Y[i]), (X[j], -Y[j])], LineColor='Black', LineStyle='Solid', LineWidth=1)) self.Canvas.Draw()
def draw_patient(self, patient, patientCoords): settings = PATIENT_SETTINGS group = FloatCanvas.Group() if isinstance(patient, CleaningPatient): fillColor = settings['fill_color_cleaning'] lineWidth = settings['line_width'] lineColor = settings['line_color_cleaning'] else: if patient.gender == MALE: lineColor = settings['line_color_male'] else: lineColor = settings['line_color_female'] patID = patient.id fillColor = None lineWidth = patient.acuity if isinstance(patient, PhantomPatient): fillColor = settings['fill_color_phantom'] patID = patient.realPatient.id group.AddObject( FloatCanvas.Circle(patientCoords, settings['radius'] * 2, LineWidth=lineWidth, LineColor=lineColor, FillColor=fillColor, FillStyle="Solid")) if isinstance(patient, BasePatient): #id num group.AddObject( FloatCanvas.ScaledText(str(patID), patientCoords, Position="cc", Size=settings['id_text_size'], Weight=wx.BOLD)) #acuity num group.AddObject( FloatCanvas.ScaledText(str(patient.acuity), (patientCoords[0] - settings['radius'], patientCoords[1] - settings['radius']), Position="cc", Size=settings['acuity_text_size'], Weight=wx.BOLD)) #service group.AddObject( FloatCanvas.ScaledText(str(patient.service), (patientCoords[0] + settings['radius'], patientCoords[1] - settings['radius']), Position="cc", Size=settings['acuity_text_size'], Weight=wx.BOLD)) #MRSA VRE MRSAStr = patient.has_observed_MRSA() and "M+" or "M-" VREStr = patient.has_observed_VRE() and "V+" or "V-" group.AddObject( FloatCanvas.ScaledText(str(MRSAStr), (patientCoords[0] - settings['radius'], patientCoords[1] + settings['radius']), Position="cc", Size=settings['acuity_text_size'], Weight=wx.BOLD)) group.AddObject( FloatCanvas.ScaledText(str(VREStr), (patientCoords[0] + settings['radius'], patientCoords[1] + settings['radius']), Position="cc", Size=settings['acuity_text_size'], Weight=wx.BOLD)) else: group.AddObject( FloatCanvas.ScaledText("C", patientCoords, Position="cc", Size=settings['id_text_size'], Weight=wx.BOLD)) return group
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.CreateStatusBar() # Add the Canvas NC = NavCanvas.NavCanvas( self, -1, size=(500, 500), ProjectionFun=None, Debug=0, BackgroundColor="DARK SLATE BLUE", ) Canvas = NC.Canvas self.Canvas = Canvas self.Canvas.Bind(FloatCanvas.EVT_MOTION, self.OnMove) Point = (45, 40) ## create a few Objects: C = FloatCanvas.Circle((0, 0), 10, FillColor="Red") R = FloatCanvas.Rectangle((5, 5), (15, 8), FillColor="Blue") E = FloatCanvas.Ellipse((1.5, 1.5), (12, 8), FillColor="Purple") C2 = FloatCanvas.Circle((0, 5), 10, FillColor="cyan") T = FloatCanvas.Text("Group A", (5.5, 5.5), Position="cc", Size=16, Weight=wx.BOLD, Family=wx.SWISS) self.GroupA = FloatCanvas.Group((R, C, E)) self.GroupA.AddObjects((C2, T)) Canvas.AddObject(self.GroupA) ## create another Groups of objects R = FloatCanvas.Rectangle((15, 15), (10, 18), FillColor="orange") E = FloatCanvas.Ellipse((22, 28), (12, 8), FillColor="yellow") C = FloatCanvas.Circle((25, 20), 15, FillColor="Green") C2 = FloatCanvas.Circle((12, 22), 10, FillColor="cyan") T = FloatCanvas.Text("Group B", (19, 24), Position="cc", Size=16, Weight=wx.BOLD, Family=wx.SWISS) self.GroupB = FloatCanvas.Group((R, E, C, C2, T)) Canvas.AddObject(self.GroupB) self.Groups = {"A": self.GroupA, "B": self.GroupB} # Add a couple of tools to the Canvas Toolbar tb = NC.ToolBar # tb.AddSeparator() for Group in self.Groups: Button = wx.Button(tb, wx.ID_ANY, "Remove %s" % Group) tb.AddControl(Button) Button.Bind(wx.EVT_BUTTON, lambda evt, group=Group: self.RemoveGroup(evt, group)) Button = wx.Button(tb, wx.ID_ANY, "Replace%s" % Group) tb.AddControl(Button) Button.Bind(wx.EVT_BUTTON, lambda evt, group=Group: self.ReplaceGroup(evt, group)) tb.Realize() self.Show() Canvas.ZoomToBB()