def process_draw(self, gc: wx.GraphicsContext): if self.p1 is not None and self.p2 is not None: x0 = min(self.p1.real, self.p2.real) y0 = min(self.p1.imag, self.p2.imag) x1 = max(self.p1.real, self.p2.real) y1 = max(self.p1.imag, self.p2.imag) if self.scene.context.elements.default_stroke is None: self.pen.SetColour(wx.BLUE) else: self.pen.SetColour( wx.Colour( swizzlecolor( self.scene.context.elements.default_stroke))) gc.SetPen(self.pen) if self.scene.context.elements.default_fill is None: gc.SetBrush(wx.TRANSPARENT_BRUSH) else: gc.SetBrush( wx.Brush( wx.Colour( swizzlecolor( self.scene.context.elements.default_fill)), wx.BRUSHSTYLE_SOLID, )) gc.DrawRectangle(x0, y0, x1 - x0, y1 - y0)
def process_draw(self, gc: wx.GraphicsContext): if self.p1 is not None and self.p2 is not None: x0 = min(self.p1.real, self.p2.real) y0 = min(self.p1.imag, self.p2.imag) x1 = max(self.p1.real, self.p2.real) y1 = max(self.p1.imag, self.p2.imag) if self.scene.context.elements.default_stroke is None: self.pen.SetColour(wx.BLUE) else: self.pen.SetColour( wx.Colour( swizzlecolor( self.scene.context.elements.default_stroke))) gc.SetPen(self.pen) if self.scene.context.elements.default_fill is None: gc.SetBrush(wx.TRANSPARENT_BRUSH) else: gc.SetBrush( wx.Brush( wx.Colour( swizzlecolor( self.scene.context.elements.default_fill)), wx.BRUSHSTYLE_SOLID, )) ellipse = Circle((x1 + x0) / 2.0, (y1 + y0) / 2.0, abs(self.p1 - self.p2) / 2) t = Path(ellipse) bbox = t.bbox() if bbox is not None: gc.DrawEllipse(bbox[0], bbox[1], bbox[2] - bbox[0], bbox[3] - bbox[1])
def process_draw(self, gc: wx.GraphicsContext): if self.point_series: if self.scene.context.elements.default_stroke is None: self.pen.SetColour(wx.BLUE) else: self.pen.SetColour( wx.Colour( swizzlecolor( self.scene.context.elements.default_stroke))) gc.SetPen(self.pen) if self.scene.context.elements.default_fill is None: gc.SetBrush(wx.TRANSPARENT_BRUSH) else: gc.SetBrush( wx.Brush( wx.Colour( swizzlecolor( self.scene.context.elements.default_fill)), wx.BRUSHSTYLE_SOLID, )) points = list(self.point_series) if self.mouse_position is not None: points.append(self.mouse_position) points.append(points[0]) gc.DrawLines(points)
def click(event=None): color_data = wx.ColourData() color_data.SetColour(wx.Colour(swizzlecolor(ctrl.color))) dlg = wx.ColourDialog(self, color_data) if dlg.ShowModal() == wx.ID_OK: color_data = dlg.GetColourData() data = Color( swizzlecolor(color_data.GetColour().GetRGB()), 1.0 ) set_color(data) try: setattr(obj, param, data_type(data)) except ValueError: # cannot cast to data_type, pass pass
def process_draw(self, gc: wx.GraphicsContext): if self.scene.context.elements.default_stroke is None: self.pen.SetColour(wx.BLUE) else: self.pen.SetColour( wx.Colour( swizzlecolor(self.scene.context.elements.default_stroke))) gc.SetPen(self.pen) gc.SetBrush(wx.RED_BRUSH) gc.DrawEllipse(self.track_object[0], self.track_object[1], 5000, 5000) if self.last_position: gc.DrawEllipse(self.last_position[0], self.last_position[1], 5000, 5000) if self.series is not None and len(self.series) > 1: gc.SetPen(self.pen) gc.StrokeLines(self.series)
def event( self, window_pos=None, space_pos=None, event_type=None, nearest_snap=None ): response = RESPONSE_CHAIN if event_type == "leftdown": self.p1 = complex(space_pos[0], space_pos[1]) _ = self.scene.context._ self.text = SVGText("") if nearest_snap is None: x = space_pos[0] y = space_pos[1] else: x = nearest_snap[0] y = nearest_snap[1] self.x = x self.y = y self.text *= "translate({x}, {y}) scale({scale})".format( x=x, y=y, scale=UNITS_PER_PIXEL ) dlg = TextEntry(self.scene.context, "", None, wx.ID_ANY, "") if dlg.ShowModal() == wx.ID_OK: self.text.text = dlg.result_text if dlg.result_anchor == 1: self.text.anchor = "middle" elif dlg.result_anchor == 2: self.text.anchor = "end" else: self.text.anchor = "start" elements = self.scene.context.elements node = elements.elem_branch.add(text=self.text, type="elem text") color = dlg.result_colour rgb = color.GetRGB() color = swizzlecolor(rgb) color = Color(color, 1.0) node.fill = color # Translate wxFont to SVG font.... node.wxfont = dlg.result_font dlg.store_font_history() wxfont_to_svg(node) if elements.classify_new: elements.classify([node]) self.notify_created(node) dlg.Destroy() response = RESPONSE_CONSUME return response
def process_draw(self, gc): """ Draws the background on the scene. """ # print ("Bedwidget draw %s" % self.name) if self.scene.context.draw_mode & DRAW_MODE_BACKGROUND == 0: context = self.scene.context unit_width = context.device.unit_width unit_height = context.device.unit_height background = self.background if background is None: brush = wx.Brush( colour=self.scene.colors.color_bed, style=wx.BRUSHSTYLE_SOLID ) gc.SetBrush(brush) gc.DrawRectangle(0, 0, unit_width, unit_height) elif isinstance(background, int): gc.SetBrush(wx.Brush(wx.Colour(swizzlecolor(background)))) gc.DrawRectangle(0, 0, unit_width, unit_height) else: gc.DrawBitmap(background, 0, 0, unit_width, unit_height)
def process_button(myidx): col, image = get_bitmap() if image is None: return if col is not None: self.buttons[myidx].SetBackgroundColour(wx.Colour(swizzlecolor(col))) else: self.buttons[myidx].SetBackgroundColour(wx.LIGHT_GREY) if image is None: self.buttons[myidx].SetBitmap(wx.NullBitmap) else: self.buttons[myidx].SetBitmap(image) # self.buttons[myidx].SetBitmapDisabled(icons8_padlock_50.GetBitmap(color=Color("Grey"), resize=(self.iconsize, self.iconsize), noadjustment=True, keepalpha=True)) self.buttons[myidx].SetToolTip( str(node) + "\n" + _("Assign the selected elements to the operation.") + "\n" + _("Left click: consider stroke as main color, right click: use fill") ) self.buttons[myidx].Show()
def set_color(color: Color): control.SetLabel(str(color.hex)) control.SetBackgroundColour(wx.Colour(swizzlecolor(color))) control.color = color