Esempio n. 1
0
	def __init__(self, parent, active=0, onchange=None):
		self.active = active
		self.toggles = [None, None, None, None]
		self.onchange = onchange
		VPanel.__init__(self, parent)
		row1 = wx.BoxSizer(HORIZONTAL)
		self.box.Add(row1)

		icons_dict = {True:[icons.CTX_ROUNDED_RECT2_ON, '', ],
				False:[icons.CTX_ROUNDED_RECT2_OFF, '', ], }
		tgl = BitmapToggle(self, False, icons_dict, self.changed)
		self.toggles[1] = tgl
		row1.Add(tgl)
		icons_dict = {True:[icons.CTX_ROUNDED_RECT3_ON, '', ],
				False:[icons.CTX_ROUNDED_RECT3_OFF, '', ], }
		tgl = BitmapToggle(self, False, icons_dict, self.changed)
		self.toggles[2] = tgl
		row1.Add(tgl)

		row2 = wx.BoxSizer(HORIZONTAL)
		self.box.Add(row2, 0)

		icons_dict = {True:[icons.CTX_ROUNDED_RECT1_ON, '', ],
				False:[icons.CTX_ROUNDED_RECT1_OFF, '', ], }
		tgl = BitmapToggle(self, False, icons_dict, self.changed)
		self.toggles[0] = tgl
		row2.Add(tgl)
		icons_dict = {True:[icons.CTX_ROUNDED_RECT4_ON, '', ],
				False:[icons.CTX_ROUNDED_RECT4_OFF, '', ], }
		tgl = BitmapToggle(self, False, icons_dict, self.changed)
		self.toggles[3] = tgl
		row2.Add(tgl)

		self.toggles[self.active].set_active(True)
Esempio n. 2
0
    def build(self):

        self.toggles[ARC_ARC] = wal.ImageToggleButton(self, False,
                                                      icons.CTX_CIRCLE_ARC,
                                                      onchange=self.toggled,
                                                      tooltip=_('Arc'))
        self.add(self.toggles[ARC_ARC], 0, wal.LEFT | wal.CENTER)

        self.toggles[ARC_CHORD] = wal.ImageToggleButton(self, False,
                                                        icons.CTX_CIRCLE_CHORD,
                                                        onchange=self.toggled,
                                                        tooltip=_('Chord'))
        self.add(self.toggles[ARC_CHORD], 0, wal.LEFT | wal.CENTER)

        idx = ARC_PIE_SLICE
        self.toggles[idx] = wal.ImageToggleButton(self, False,
                                                  icons.CTX_CIRCLE_PIE_SLICE,
                                                  onchange=self.toggled,
                                                  tooltip=_('Pie slice'))
        self.add(self.toggles[ARC_PIE_SLICE], 0, wal.LEFT | wal.CENTER)

        self.slider = wal.Slider(self, 0, (0, 360),
                                 onchange=self.slider_changes,
                                 on_final_change=self.slider_final_changes)
        self.add(self.slider, 0, wal.LEFT | wal.CENTER, 2)

        self.angle_spin = AngleSpin(self, onchange=self.angle_changes)
        self.add(self.angle_spin, 0, wal.LEFT | wal.CENTER, 2)

        txt1 = _('Start angle')
        txt2 = _('End angle')
        icons_dict = {True: [icons.CTX_CIRCLE_START_ANGLE, txt1, ],
                      False: [icons.CTX_CIRCLE_END_ANGLE, txt2, ], }
        self.switch = BitmapToggle(self, True, icons_dict, self.switched)
        self.add(self.switch, 0, wal.LEFT | wal.CENTER, 2)
Esempio n. 3
0
 def __init__(self, parent, val, state=False, onchange=None):
     self.val = val
     icons_dict = {True: [make_artid('check-yes'), ''],
                   False: [make_artid('check-no'), '']}
     if val == (0.0, 0.0):
         icons_dict = {True: [make_artid('check-yes-center'), ''],
                       False: [make_artid('check-no'), '']}
     BitmapToggle.__init__(self, parent, state, icons_dict, onchange)
Esempio n. 4
0
	def __init__(self, parent, val, state=False, onchange=None):
		self.val = val
		icons_dict = { True:[make_artid('check-yes'), ''],
					False:[make_artid('check-no'), ''] }
		if val == (0.0, 0.0):
			icons_dict = { True:[make_artid('check-yes-center'), ''],
						False:[make_artid('check-no'), ''] }
		BitmapToggle.__init__(self, parent, state, icons_dict, onchange)
Esempio n. 5
0
	def build(self):

		self.toggles[ARC_ARC] = wal.ImageToggleButton(self, False,
								icons.CTX_CIRCLE_ARC,
								onchange=self.toggled,
								tooltip=_('Arc'))
		self.add(self.toggles[ARC_ARC], 0, wal.LEFT | wal.CENTER)

		self.toggles[ARC_CHORD] = wal.ImageToggleButton(self, False,
								icons.CTX_CIRCLE_CHORD,
								onchange=self.toggled,
								tooltip=_('Chord'))
		self.add(self.toggles[ARC_CHORD], 0, wal.LEFT | wal.CENTER)

		self.toggles[ARC_PIE_SLICE] = wal.ImageToggleButton(self, False,
								icons.CTX_CIRCLE_PIE_SLICE,
								onchange=self.toggled,
								tooltip=_('Pie slice'))
		self.add(self.toggles[ARC_PIE_SLICE], 0, wal.LEFT | wal.CENTER)

		self.slider = wal.Slider(self, 0, (0, 360), onchange=self.slider_changes,
								on_final_change=self.slider_final_changes)
		self.add(self.slider, 0, wal.LEFT | wal.CENTER, 2)

		self.angle_spin = AngleSpin(self, onchange=self.angle_changes)
		self.add(self.angle_spin, 0, wal.LEFT | wal.CENTER, 2)

		txt1 = _('Start angle')
		txt2 = _('End angle')
		icons_dict = {True:[icons.CTX_CIRCLE_START_ANGLE, txt1, ],
				False:[icons.CTX_CIRCLE_END_ANGLE, txt2, ], }
		self.switch = BitmapToggle(self, True, icons_dict, self.switched)
		self.add(self.switch, 0, wal.LEFT | wal.CENTER, 2)
Esempio n. 6
0
    def __init__(self, parent, active=0, onchange=None):
        self.active = active
        self.toggles = [None, None, None, None]
        self.onchange = onchange
        wal.GridPanel.__init__(self, parent)

        icons_dict = {
            True: [
                icons.CTX_ROUNDED_RECT2_ON,
                '',
            ],
            False: [
                icons.CTX_ROUNDED_RECT2_OFF,
                '',
            ],
        }
        tgl = BitmapToggle(self, False, icons_dict, self.changed)
        self.toggles[1] = tgl
        self.add(tgl)

        icons_dict = {
            True: [
                icons.CTX_ROUNDED_RECT3_ON,
                '',
            ],
            False: [
                icons.CTX_ROUNDED_RECT3_OFF,
                '',
            ],
        }
        tgl = BitmapToggle(self, False, icons_dict, self.changed)
        self.toggles[2] = tgl
        self.add(tgl)

        icons_dict = {
            True: [
                icons.CTX_ROUNDED_RECT1_ON,
                '',
            ],
            False: [
                icons.CTX_ROUNDED_RECT1_OFF,
                '',
            ],
        }
        tgl = BitmapToggle(self, False, icons_dict, self.changed)
        self.toggles[0] = tgl
        self.add(tgl)

        icons_dict = {
            True: [
                icons.CTX_ROUNDED_RECT4_ON,
                '',
            ],
            False: [
                icons.CTX_ROUNDED_RECT4_OFF,
                '',
            ],
        }
        tgl = BitmapToggle(self, False, icons_dict, self.changed)
        self.toggles[3] = tgl
        self.add(tgl)

        self.toggles[self.active].set_active(True)
Esempio n. 7
0
class CirclePlugin(CtxPlugin):
    name = 'CirclePlugin'
    update_flag = False
    circle_type = ARC_CHORD
    start = 0
    end = 0
    toggles = {}

    target = None
    orig_type = ARC_CHORD
    orig_start = 0
    orig_end = 0

    slider = None
    angle_spin = None
    switch = None

    def __init__(self, app, parent):
        CtxPlugin.__init__(self, app, parent)
        events.connect(events.DOC_CHANGED, self.update)
        events.connect(events.SELECTION_CHANGED, self.update)

    def build(self):

        self.toggles[ARC_ARC] = wal.ImageToggleButton(self,
                                                      False,
                                                      icons.CTX_CIRCLE_ARC,
                                                      onchange=self.toggled,
                                                      tooltip=_('Arc'))
        self.pack(self.toggles[ARC_ARC])

        self.toggles[ARC_CHORD] = wal.ImageToggleButton(self,
                                                        False,
                                                        icons.CTX_CIRCLE_CHORD,
                                                        onchange=self.toggled,
                                                        tooltip=_('Chord'))
        self.pack(self.toggles[ARC_CHORD])

        idx = ARC_PIE_SLICE
        self.toggles[idx] = wal.ImageToggleButton(self,
                                                  False,
                                                  icons.CTX_CIRCLE_PIE_SLICE,
                                                  onchange=self.toggled,
                                                  tooltip=_('Pie slice'))
        self.pack(self.toggles[ARC_PIE_SLICE])

        self.slider = wal.Slider(self,
                                 0, (0, 360),
                                 onchange=self.slider_changes,
                                 on_final_change=self.slider_final_changes)
        self.pack(self.slider, padding=2)

        self.angle_spin = AngleSpin(self, onchange=self.angle_changes)
        self.pack(self.angle_spin, padding=2)

        txt1 = _('Start angle')
        txt2 = _('End angle')
        icons_dict = {
            True: [
                icons.CTX_CIRCLE_START_ANGLE,
                txt1,
            ],
            False: [
                icons.CTX_CIRCLE_END_ANGLE,
                txt2,
            ],
        }
        self.switch = BitmapToggle(self, True, icons_dict, self.switched)
        self.pack(self.switch, padding=2)

    def update(self, *args):
        if self.insp.is_selection():
            sel = self.app.current_doc.selection
            if len(sel.objs) == 1 and self.insp.is_obj_circle(sel.objs[0]):
                obj = sel.objs[0]
                self.circle_type = obj.circle_type
                self.start = obj.angle1
                self.end = obj.angle2
                self.update_flag = True
                for item in CIRCLE_TYPES:
                    self.toggles[item].set_active(item == self.circle_type)
                self.update_flag = False
                self.switched()
                if not obj == self.target:
                    self.target = obj
                    self.store_props()

    def store_props(self):
        self.orig_type = self.target.circle_type
        self.orig_start = self.target.angle1
        self.orig_end = self.target.angle2

    def toggled(self, *args):
        if self.update_flag:
            return
        self.update_flag = True
        val = -1
        for item in CIRCLE_TYPES:
            if self.toggles[item].get_active() and item != self.circle_type:
                val = item
            elif self.toggles[item].get_active() and item == self.circle_type:
                self.toggles[item].set_active(False)
        if val < 0:
            self.toggles[self.circle_type].set_active(True)
        else:
            self.circle_type = val
        self.update_flag = False
        self.apply_changes(True)

    def switched(self, *args):
        self.update_flag = True
        if self.switch.get_active():
            self.slider.set_value(int(self.start * 180.0 / math.pi))
            self.angle_spin.set_angle_value(self.start)
        else:
            self.slider.set_value(int(self.end * 180.0 / math.pi))
            self.angle_spin.set_angle_value(self.end)
        self.update_flag = False

    def angle_changes(self, *args):
        if self.update_flag:
            return
        if self.switch.get_active():
            self.start = self.angle_spin.get_angle_value()
        else:
            self.end = self.angle_spin.get_angle_value()
        self.apply_changes(True)

    def slider_changes(self, *args):
        if self.update_flag:
            return
        val = self.slider.get_value() * math.pi / 180.0
        if self.switch.get_active():
            self.start = val
        else:
            self.end = val
        self.apply_changes()

    def slider_final_changes(self, *args):
        if self.update_flag:
            return
        val = self.slider.get_value() * math.pi / 180.0
        if self.switch.get_active():
            self.start = val
        else:
            self.end = val
        self.apply_changes(True)

    def apply_changes(self, final=False):
        if self.insp.is_selection():
            sel = self.app.current_doc.selection
            if len(sel.objs) == 1 and self.insp.is_obj_circle(sel.objs[0]):
                obj = sel.objs[0]
                api = self.app.current_doc.api
                if final:
                    api.set_circle_properties_final(self.circle_type,
                                                    self.start, self.end,
                                                    self.orig_type,
                                                    self.orig_start,
                                                    self.orig_end)
                    self.store_props()
                elif not self.start == obj.angle1 or \
                        not self.end == obj.angle2:
                    api.set_circle_properties(self.circle_type, self.start,
                                              self.end)
Esempio n. 8
0
class CirclePlugin(CtxPlugin):

	name = 'CirclePlugin'
	update_flag = False
	circle_type = ARC_CHORD
	start = 0
	end = 0
	toggles = {}

	target = None
	orig_type = ARC_CHORD
	orig_start = 0
	orig_end = 0

	def __init__(self, app, parent):
		CtxPlugin.__init__(self, app, parent)
		events.connect(events.DOC_CHANGED, self.update)
		events.connect(events.SELECTION_CHANGED, self.update)

	def build(self):

		self.toggles[ARC_ARC] = wal.ImageToggleButton(self, False,
								icons.CTX_CIRCLE_ARC,
								onchange=self.toggled,
								tooltip=_('Arc'))
		self.add(self.toggles[ARC_ARC], 0, wal.LEFT | wal.CENTER)

		self.toggles[ARC_CHORD] = wal.ImageToggleButton(self, False,
								icons.CTX_CIRCLE_CHORD,
								onchange=self.toggled,
								tooltip=_('Chord'))
		self.add(self.toggles[ARC_CHORD], 0, wal.LEFT | wal.CENTER)

		self.toggles[ARC_PIE_SLICE] = wal.ImageToggleButton(self, False,
								icons.CTX_CIRCLE_PIE_SLICE,
								onchange=self.toggled,
								tooltip=_('Pie slice'))
		self.add(self.toggles[ARC_PIE_SLICE], 0, wal.LEFT | wal.CENTER)

		self.slider = wal.Slider(self, 0, (0, 360), onchange=self.slider_changes,
								on_final_change=self.slider_final_changes)
		self.add(self.slider, 0, wal.LEFT | wal.CENTER, 2)

		self.angle_spin = AngleSpin(self, onchange=self.angle_changes)
		self.add(self.angle_spin, 0, wal.LEFT | wal.CENTER, 2)

		txt1 = _('Start angle')
		txt2 = _('End angle')
		icons_dict = {True:[icons.CTX_CIRCLE_START_ANGLE, txt1, ],
				False:[icons.CTX_CIRCLE_END_ANGLE, txt2, ], }
		self.switch = BitmapToggle(self, True, icons_dict, self.switched)
		self.add(self.switch, 0, wal.LEFT | wal.CENTER, 2)

	def update(self, *args):
		if self.insp.is_selection():
			sel = self.app.current_doc.selection
			if len(sel.objs) == 1 and self.insp.is_obj_circle(sel.objs[0]):
				obj = sel.objs[0]
				self.circle_type = obj.circle_type
				self.start = obj.angle1
				self.end = obj.angle2
				self.update_flag = True
				for item in CIRCLE_TYPES:
					self.toggles[item].set_active(item == self.circle_type)
				self.update_flag = False
				self.switched()
				if not obj == self.target:
					self.target = obj
					self.store_props()

	def store_props(self):
		self.orig_type = self.target.circle_type
		self.orig_start = self.target.angle1
		self.orig_end = self.target.angle2

	def toggled(self, *args):
		if self.update_flag: return
		self.update_flag = True
		val = -1
		for item in CIRCLE_TYPES:
			if self.toggles[item].get_active() and not item == self.circle_type:
				val = item
			elif self.toggles[item].get_active() and item == self.circle_type:
				self.toggles[item].set_active(False)
		if val < 0: self.toggles[self.circle_type].set_active(True)
		else: self.circle_type = val
		self.update_flag = False
		self.apply_changes(True)

	def switched(self, *args):
		self.update_flag = True
		if self.switch.get_active():
			self.slider.set_value(int(self.start * 180.0 / math.pi))
			self.angle_spin.set_angle_value(self.start)
		else:
			self.slider.set_value(int(self.end * 180.0 / math.pi))
			self.angle_spin.set_angle_value(self.end)
		self.update_flag = False

	def angle_changes(self, *args):
		if self.update_flag: return
		if self.switch.get_active():
			self.start = self.angle_spin.get_angle_value()
		else:
			self.end = self.angle_spin.get_angle_value()
		self.apply_changes(True)

	def slider_changes(self, *args):
		if self.update_flag: return
		val = self.slider.get_value() * math.pi / 180.0
		if self.switch.get_active(): self.start = val
		else: self.end = val
		self.apply_changes()

	def slider_final_changes(self, *args):
		if self.update_flag: return
		val = self.slider.get_value() * math.pi / 180.0
		if self.switch.get_active(): self.start = val
		else: self.end = val
		self.apply_changes(True)

	def apply_changes(self, final=False):
		if self.insp.is_selection():
			sel = self.app.current_doc.selection
			if len(sel.objs) == 1 and self.insp.is_obj_circle(sel.objs[0]):
				obj = sel.objs[0]
				api = self.app.current_doc.api
				if final:
					api.set_circle_properties_final(self.circle_type,
								self.start, self.end, self.orig_type,
								self.orig_start, self.orig_end)
					self.store_props()
				elif not self.start == obj.angle1 or \
					not self.end == obj.angle2:
					api.set_circle_properties(self.circle_type,
											self.start, self.end)