Ejemplo n.º 1
0
	def OnNewObject(self, event):
		if event is not None:
			event.GetId()
		dlg = ObjDialog(self)
		#dlg.AddChoice(wx.ArtProvider_GetBitmap(str(ed_glob.ID_DECA_EMPTY), wx.ART_MENU, wx.Size(16, 16)), '', '')
		repo = Deca.world.GetLayer(Deca.World.ID_Repository)
		dlg.Repository = repo
		dlg.CurrentLayer = self.graph
		# fill templates list
		img = wx.ArtProvider_GetBitmap(str(ed_glob.ID_CLASS_TYPE), wx.ART_MENU, wx.Size(16, 16))
		for o in repo.GetTemplates():
			dlg.AddChoice(img, o.Name, o.ID)
		# fill objects list
		img = wx.ArtProvider_GetBitmap(str(ed_glob.ID_ATTR_TYPE), wx.ART_MENU, wx.Size(16, 16))
		for o in repo.GetObjects():
			dlg.AddChoice(img, o.GetTitle(), o.ID)
		for o in self.graph.GetObjects():
			dlg.AddChoice(img, o.GetTitle(), o.ID)
		dlg.EnableReflection()
		dlg.cbProto.Select(0)
		dlg.OnPrototype(event)
		if dlg.ShowModal() == wx.ID_OK:
			source = dlg.cbProto.GetSelection()
			if source != wx.NOT_FOUND:
				source = dlg.cbProto.GetClientData(source)
			obj = Deca.Object()
			if dlg.chReflection.Value:
				obj.ID = source
				obj.IsReflection = True
			for x in xrange(dlg.attrGrid.GetNumberRows()) :
				nm = dlg.attrGrid.GetCellValue(row=x, col=0)
				vl = dlg.attrGrid.GetCellValue(row=x, col=1)
				obj.Attributes[nm] = vl
			if dlg.TitlePos > -1:
				obj.TitleAttr = dlg.attrGrid.GetCellValue(row=dlg.TitlePos, col=0)
			obj.TemplateName = dlg.cbProto.GetString(dlg.cbProto.GetSelection())
			if obj.TemplateName == "":
				obj.TemplateName = repo.GetTemplate(repo.ID_DefaultTemplate).Name
			# attributes copied
			self.graph.AddObject(obj)
			self.graph.AddObjectShape(obj, getattr(event, 'x', None), getattr(event, 'y', None))
			self.Refresh()

			Deca.world.Modified = True
			if self.graph.propsGrid:
				self.graph.propsGrid.UpdateGrid()
		# end if wx.ID_OK
		dlg.Destroy()
Ejemplo n.º 2
0
	def EditObject(self) :
		shape = self.GetShape()
		canvas = shape.GetCanvas()
		obj = canvas.GetObject(shape.GetRegionName())
		if obj:
			dlg = ObjDialog(self.statbarFrame)
			# fill the dialog
			dlg.AddChoice(wx.ArtProvider_GetBitmap(str(ed_glob.ID_CLASS_TYPE), wx.ART_MENU, wx.Size(16, 16)),
							obj.TemplateName, None)
			if obj.IsReflection:
				dlg.chReflection.Value = True
			dlg.AppendRows(len(obj.Attributes))
			x = 0
			dlg.SetEditMode()
			for k,v in obj.Attributes.items():
				dlg.attrGrid.SetRowLabelValue(x, '')
				if k == obj.TitleAttr:
					dlg.attrGrid.SetRowLabelValue(x, '*')
					dlg.TitlePos = x
					dlg.stTitle.Label = _("Title attribute: %s") % k
				dlg.attrGrid.SetCellValue(row=x, col=0, s=k)
				dlg.attrGrid.SetCellValue(row=x, col=1, s=v)
				x += 1
			if not dlg.shapeSel.SetStringSelection(str(obj.Graphics)):
				dlg.shapeSel.SetSelection(0)
			# show dialog
			if dlg.ShowModal() == wx.ID_OK:
				obj.Attributes.clear()
				for x in xrange(dlg.attrGrid.GetNumberRows()) :
					nm = dlg.attrGrid.GetCellValue(row=x, col=0)
					vl = dlg.attrGrid.GetCellRawValue(row=x, col=1)
					obj.Attributes[nm] = vl
				if dlg.TitlePos > -1:
					obj.TitleAttr = dlg.attrGrid.GetCellValue(row=dlg.TitlePos, col=0)
				# update vision
				obj.Graphics = dlg.GetShapeName()
				shape.Update()
				canvas.GetParent().UpdateView(None)
			dlg.FixGrid()
			dlg.Destroy()
		pass
Ejemplo n.º 3
0
	def AddObject(self, event):
		event.GetId()
		dlg = ObjDialog(self)
		#dlg.AddChoice(wx.ArtProvider_GetBitmap(str(ed_glob.ID_DECA_EMPTY), wx.ART_MENU, wx.Size(16, 16)), '', '')
		repo = Deca.world.GetLayer(Deca.World.ID_Repository)
		dlg.Repository = repo
		dlg.CurrentLayer = repo
		# fill templates list
		img = wx.ArtProvider_GetBitmap(str(ed_glob.ID_CLASS_TYPE), wx.ART_MENU, wx.Size(16, 16))
		for o in repo.GetTemplatesNames():
			dlg.AddChoice(img, o, o)
		# fill objects list
		img = wx.ArtProvider_GetBitmap(str(ed_glob.ID_ATTR_TYPE), wx.ART_MENU, wx.Size(16, 16))
		for o in repo.GetObjects():
			dlg.AddChoice(img, o.GetTitle(), o.ID)
		res = dlg.ShowModal()
		if res == wx.ID_OK:
			pass
Ejemplo n.º 4
0
	def OnListDouble(self, event):
		"""Edit selected item"""
		event.GetId()
		repo = Deca.world.GetLayer(Deca.World.ID_Repository)
		idx = self.mRepoList.GetFirstSelected()
		if idx > -1:
			itm = self.mRepoList.GetItem(idx)
			tp = itm.Image
			if not tp:
				# edit the template
				code = uuid.UUID(itm.GetText())
				dlg = TmplDialog(self)
				dlg.EditMode = True
				dlg.cbProto.Clear()
				dlg.cbProto.Append("")
				dlg.cbProto.AppendItems(repo.GetTemplatesNames())
				dlg.txtName.Value = self.mRepoList.GetItem(idx, col = 1).Text
				dlg.cbProto.StringSelection = dlg.txtName.Value
				dlg.OnPrototype(event)
				tpl = repo.GetTemplate(code)
				try:
					dlg.shapeSel.SetStringSelection(tpl.Graphics)
				except Exception:
					dlg.shapeSel.SetStringSelection("DefaultShape")
				if code == repo.ID_DefaultTemplate:
					dlg.txtName.Enabled = False
				res = dlg.ShowModal()
				if res == wx.ID_OK:
					tpl = repo.GetTemplate(code)
					tpl.Name = dlg.txtName.Value
					tpl.TitleAttr = None
					tpl.Attributes.clear()
					for x in xrange(dlg.attrGrid.GetNumberRows()) :
						nm = dlg.attrGrid.GetCellValue(row = x, col= 0)
						vl = dlg.attrGrid.GetCellValue(row = x, col= 1)
						tpl.Attributes[nm] = vl
					if dlg.TitlePos > -1:
						tpl.TitleAttr = dlg.attrGrid.GetCellValue(row = dlg.TitlePos, col= 0)
					tpl.Graphics = dlg.shapeSel.GetStringSelection()
					repo.LazyReindex()
					self.UpdateView(None)
					if repo.propsGrid is not None :
						repo.propsGrid.UpdateGrid()
				dlg.Destroy()
			elif tp == 1:
				# edit the object
				#code = uuid.UUID(itm.GetText())
				dlg = ObjDialog(self)
				dlg.AddChoice(wx.NullBitmap, '', '')
				repo = Deca.world.GetLayer(Deca.World.ID_Repository)
				# fill templates list
				img = wx.ArtProvider_GetBitmap(str(ed_glob.ID_CLASS_TYPE), wx.ART_MENU, wx.Size(16, 16))
				for o in repo.GetTemplatesNames():
					dlg.AddChoice(img, o, o)
				# fill objects list
				img = wx.ArtProvider_GetBitmap(str(ed_glob.ID_ATTR_TYPE), wx.ART_MENU, wx.Size(16, 16))
				for o in repo.GetObjects():
					dlg.AddChoice(img, o.GetTitle(), o.ID)
				res = dlg.ShowModal()
				if res == wx.ID_OK:
					pass
			elif tp == 2:
				# edit the shape
				path = Deca.world.ShapesPath
				path = os.path.join(path, itm.GetText() + '.py')
				self._OpenShapeEditor(path)
				pass